carlos / platform Public

domains: round 3 fixes for fresh DNS stamping (#724)

Astra R3 P1: a published name's upgrade look uses the new
FreshResolver.ResolveUpgrade, which falls back to the name's nearest
zone (cached NS of the parent, then the name) when the top-down walk
gives no answer, so a delegation deeper than freshMaxZones stays
published. New names never take that path.

Fable R3 P2-1: two strikes before the cache. A new name's first fresh
failure in a row is held (stamp untouched, backoff forgiven via Strike);
only the second takes the cached look.

Astra R3 P2-2: an authoritative "exists, no A record" is errNoData, not
"no such name"; a new name then gets the cached look (AAAA edges).

Astra R3 P2-3: nameserver hosts on the name's own path are never looked
up through the cache. Fable R3 P2-2: never-checked names first, and
backoff hits do not count against the budget. Timeout, glue, Forget and
budget tests tightened; comments describe the top-down walk.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 2828ac11d5b1c1bc946918b784876b6c5e272666 parent 99dd275
10 files changed, +692 −82
  • docs/superpowers/notes/census-proposal-no-negative-prime-724.md +4 −5
  • internal/domains/export_test.go +17 −0
  • internal/domains/freshdns.go +140 −26
  • internal/domains/freshdns_stamp_test.go +263 −9
  • internal/domains/freshdns_test.go +186 −15
  • internal/domains/reconcile.go +69 −16
  • internal/host/agent.go +2 −0
  • internal/host/host_test.go +2 −2
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv +8 −8

CI passed — run details

diff --git a/docs/superpowers/notes/census-proposal-no-negative-prime-724.md b/docs/superpowers/notes/census-proposal-no-negative-prime-724.md
index c94cb1509..f3668ced0 100644
--- a/docs/superpowers/notes/census-proposal-no-negative-prime-724.md
+++ b/docs/superpowers/notes/census-proposal-no-negative-prime-724.md
@@ -1,11 +1,10 @@
# Census approval: no-negative-prime-724
-Ruling `census-ruling-no-negative-prime-724`. The independent reviewer approves or rejects every change below, 2 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+Ruling `census-ruling-no-negative-prime-724`. The independent reviewer approves or rejects every change below, 3 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
| unit | change | read sites | what changed |
|---|---|---|---|
-| `internal/host/agent.go` `domainsTickConfig` | body | unchanged (2) | builds the one FreshResolver per config as a local and wires both its Resolve (ResolveFresh) and its Forget (new FreshForget, clears that resolver's in-memory failure backoff for a host) into domains.Config; drops LookupCNAME from the resolver (the cached CNAME shortcut is gone: the fresh walk now starts at the ICANN registrable domain and follows verified referrals down); reads nothing new, no file, path, env var or command input added (#724) |
-| `internal/domains/reconcile.go` `StampHealth` | sites | -registry:Alias, +registry:DNSStatus ×2, -registry:Host, -whole:Route, -whole:RouteAlias | section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address "pointing", other "elsewhere", authoritative not-found ""), falling back to the cached lookup on a fresh error or past the budget; a previously "pointing" name keeps cached-first plus the upgrade-only fresh look, so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) |
+| `internal/host/agent.go` `domainsTickConfig` | body | unchanged (2) | builds the one FreshResolver per config as a local and wires four of its methods into domains.Config: Resolve (ResolveFresh), ResolveUpgrade (new: same lookup plus a nearest-zone fallback through the cached NS set, used only for names already "pointing"), Forget (FreshForget, clears that resolver's in-memory backoff and strike for a host) and Strike (new FreshStrike, the in-memory two-strike rule for a new name's fresh failure); drops LookupCNAME from the resolver; reads nothing new, no file, path, env var or command input added (#724) |
Envelopes re-pinned: `internal/domains`, `internal/host`.
@@ -14,13 +13,13 @@ Review: a model from the other family than the author reads the branch's diff ag
Recorded dispositions, which each change must still satisfy:
- `internal/host/agent.go` `domainsTickConfig`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-dns-fresh-lookup-724;basis=wires ResolveFresh to a FreshResolver over net.DefaultResolver (LookupNS, LookupHost, LookupCNAME) (#724)
-- `internal/domains/reconcile.go` `StampHealth`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724)
New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
- new `internal/domains/freshdns.go:FreshResolver.query`: reads +file:Read; written legacy, accepted-legacy, frozen
- quiet `internal/domains/freshdns.go:FreshResolver.exchange`: reads nothing now; retired while it reads nothing (or its row keeps no sites)
+- reads `internal/domains/reconcile.go:StampHealth`: -registry:Alias, +registry:DNSCheckedAt ×2, +registry:DNSStatus ×2, -registry:Host, -whole:Route, -whole:RouteAlias; keeps legacy, task accepted-legacy
-Seal: `8924fafc5b6083858a72f45c764081abe3bcad6a6de71901470586c076c64bb6` → `638b1b2c6720713927139989c74a0f133de77f765df4e3a0c0a333137582b2ca`.
+Seal: `8924fafc5b6083858a72f45c764081abe3bcad6a6de71901470586c076c64bb6` → `70bb4d8af6dc72d82a629d1c079acf6716a32e3fef5d7ae2b1f2c761b99c614e`.
Overlay: `internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/domains/export_test.go b/internal/domains/export_test.go
index c1cdec26f..56f8150fa 100644
--- a/internal/domains/export_test.go
+++ b/internal/domains/export_test.go
@@ -1,5 +1,7 @@
package domains
+import "time"
+
// MintedRoute is mintedRoute, for the external tests that drive a minted
// row through the edge (rootfs_apex_test.go): package edge imports this one,
// so only an external test package can import both.
@@ -19,3 +21,18 @@ var PublicNameserver = publicNameserver
// RegistrableDomain is registrableDomain, where the fresh walk starts.
var RegistrableDomain = registrableDomain
+
+// ErrFreshNoData and ErrFreshBackingOff are the fresh lookup's "exists, no
+// A record" and "answered from the backoff".
+var (
+ ErrFreshNoData = errNoData
+ ErrFreshBackingOff = errBackingOff
+)
+
+// SetFreshPassTime changes the per-pass fresh time budget for a test and
+// returns the restore.
+func SetFreshPassTime(d time.Duration) (restore func()) {
+ old := freshPassTime
+ freshPassTime = d
+ return func() { freshPassTime = old }
+}
diff --git a/internal/domains/freshdns.go b/internal/domains/freshdns.go
index 107d76b9c..ecd8f179e 100644
--- a/internal/domains/freshdns.go
+++ b/internal/domains/freshdns.go
@@ -20,7 +20,8 @@ import (
// name by asking authoritative servers top-down from the name's registrable
// domain, asks that zone's own nameservers, and trusts only an
// authoritative reply to the exact question it sent. Config.ResolveFresh is
-// its Resolve and Config.FreshForget its Forget.
+// its Resolve, Config.ResolveUpgrade its ResolveUpgrade, Config.FreshForget
+// its Forget and Config.FreshStrike its Strike.
//
// Why not just skip the box's cache: systemd-resolved is not the only
// cache between us and the customer's zone. The upstream (VPC) resolver
@@ -45,8 +46,11 @@ type FreshResolver struct {
// publicNameserver; nil is a net.Dialer. A seam for tests, which point
// a public test address at a loopback server.
Dial func(ctx context.Context, network, address string) (net.Conn, error)
- // Timeout bounds one whole Resolve; 0 is 4 s: two silent servers at
- // AttemptTimeout each, then a verified zone's two queries.
+ // Timeout bounds one whole Resolve, cached discovery included, and is
+ // the deadline every exchange runs under; 0 is 4 s. That is enough for
+ // a silent server at AttemptTimeout and a verified answer from the
+ // next, or for a few referrals at ordinary latency; a slow, deep
+ // delegation runs out of it and fails (closed, into the backoff).
Timeout time.Duration
// AttemptTimeout bounds one exchange with one nameserver inside it; 0
// is 1 s, so a silent server leaves time for the next.
@@ -61,21 +65,38 @@ type FreshResolver struct {
mu sync.Mutex
failedAt map[string]time.Time
+ struck map[string]bool // names whose last fresh-first look failed once; see Strike
}
// errNoAuthority is a fresh lookup that got no usable authoritative answer.
var errNoAuthority = errors.New("fresh dns: no authoritative answer")
+// errBackingOff is a Resolve answered from the failure backoff: nothing was
+// sent, so section 4 does not count it against its per-pass budget.
+var errBackingOff = errors.New("fresh dns: backing off")
+
+// errNoData is an authoritative "the name exists but has no A record" (an
+// AAAA-only name, say). It is definitive, so it never enters the backoff,
+// but it is not "no such name": section 4 then gives the name the cached
+// look, which sees every address family and primes nothing for a name that
+// exists.
+var errNoData = errors.New("fresh dns: name exists with no A record")
+
+// definitive reports a fresh result that settles the question: addresses,
+// "no such name", or "exists with no A record".
+func definitive(err error) bool {
+ return err == nil || isNotFound(err) || errors.Is(err, errNoData)
+}
+
const (
// freshMaxServers bounds the nameserver addresses tried per zone, so a
- // zone of silent servers leaves time for the next zone up.
+ // zone of silent servers leaves time for the referral below it.
freshMaxServers = 2
- // freshMaxZones bounds the parent zones tried, nearest first; the
- // registrable domain tried before them and the name itself tried last
- // are not counted. More than one, because a cached
- // CNAME at a parent level can make its NS set belong to the CNAME
- // target's zone, which then refuses, and a delegated sub-zone's parent
- // only refers down.
+ // freshMaxZones bounds the referrals followed below the registrable
+ // domain: up to four zones in all. Deeper delegation fails the
+ // top-down walk; a published name's upgrade look then falls back to
+ // its nearest zone (ResolveUpgrade), a new name to the rules in
+ // section 4.
freshMaxZones = 3
// freshMaxCNAMEs bounds a CNAME chain inside one reply.
freshMaxCNAMEs = 8
@@ -101,10 +122,26 @@ func freshPublicName(name string) bool {
return dot > 0 && !freshSkipTLDs[name[dot+1:]]
}
-// Resolve returns host's addresses as its zone's nameservers give them now.
-// An authoritative "no such name" is a *net.DNSError with IsNotFound, the
-// same shape the cached resolver gives, so callers classify both alike.
+// Resolve returns host's addresses as its zone's nameservers give them now,
+// found top-down from the registrable domain (resolve). An authoritative
+// "no such name" is a *net.DNSError with IsNotFound, the same shape the
+// cached resolver gives, so callers classify both alike; a name with no A
+// record is errNoData.
func (r *FreshResolver) Resolve(host string) ([]string, error) {
+ return r.lookup(host, false)
+}
+
+// ResolveUpgrade is Resolve for a name that is already published, so
+// exists: when the top-down walk gives no definitive answer (a delegation
+// deeper than freshMaxZones, say) it falls back to the name's nearest zone
+// through the cached NS set (nearest), as #724's first fix did. Section 4
+// uses it ONLY for names whose previous stamp is "pointing"; a new name
+// must never take it, since it asks the cache about the name's own levels.
+func (r *FreshResolver) ResolveUpgrade(host string) ([]string, error) {
+ return r.lookup(host, true)
+}
+
+func (r *FreshResolver) lookup(host string, near bool) ([]string, error) {
name := strings.ToLower(strings.TrimSuffix(host, "."))
if !freshPublicName(name) {
return nil, fmt.Errorf("%w: %s has no public zone", errNoAuthority, name)
@@ -126,7 +163,7 @@ func (r *FreshResolver) Resolve(host string) ([]string, error) {
}
if at, ok := r.failedAt[name]; ok {
r.mu.Unlock()
- return nil, fmt.Errorf("%w for %s (backing off since %s)", errNoAuthority, name, at.UTC().Format(time.RFC3339))
+ return nil, fmt.Errorf("%w: %w for %s since %s", errNoAuthority, errBackingOff, name, at.UTC().Format(time.RFC3339))
}
r.mu.Unlock()
@@ -137,8 +174,15 @@ func (r *FreshResolver) Resolve(host string) ([]string, error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
ips, err := r.resolve(ctx, name)
+ if near && !definitive(err) && ctx.Err() == nil {
+ ips, err = r.nearest(ctx, name)
+ }
- if err != nil && !isNotFound(err) {
+ if definitive(err) {
+ r.mu.Lock()
+ delete(r.struck, name)
+ r.mu.Unlock()
+ } else {
r.mu.Lock()
if r.failedAt == nil {
r.failedAt = map[string]time.Time{}
@@ -159,17 +203,46 @@ func (r *FreshResolver) Resolve(host string) ([]string, error) {
return ips, err
}
-// Forget ends host's failure backoff, so the next Resolve asks again.
-// Section 4 calls it when a name it looked at fresh before publication is
-// published by any path: a failure recorded while the name was unpublished
-// must never stop the look that keeps it published (Astra R2 on #724).
+// Forget ends host's failure backoff and its strike, so the next Resolve
+// asks again. Section 4 calls it when a name it looked at fresh before
+// publication is published by any path: a failure recorded while the name
+// was unpublished must never stop the look that keeps it published (Astra
+// R2 on #724).
func (r *FreshResolver) Forget(host string) {
name := strings.ToLower(strings.TrimSuffix(host, "."))
r.mu.Lock()
delete(r.failedAt, name)
+ delete(r.struck, name)
r.mu.Unlock()
}
+// Strike is section 4's two-strike rule for a NEW name whose fresh look
+// failed (Fable R3 on #724). The first failure in a row is forgiven: its
+// backoff is cleared so the next pass asks fresh again, and Strike reports
+// false (section 4 then asks nobody else). The second in a row reports true
+// and keeps the backoff (section 4 then takes the cached look). A
+// definitive fresh answer, or Forget, resets the count.
+func (r *FreshResolver) Strike(host string) (second bool) {
+ name := strings.ToLower(strings.TrimSuffix(host, "."))
+ r.mu.Lock()
+ defer r.mu.Unlock()
+ if r.struck[name] {
+ return true
+ }
+ if r.struck == nil {
+ r.struck = map[string]bool{}
+ }
+ if len(r.struck) >= freshMaxBackoff {
+ for n := range r.struck {
+ delete(r.struck, n)
+ break
+ }
+ }
+ r.struck[name] = true
+ delete(r.failedAt, name)
+ return false
+}
+
func isNotFound(err error) bool {
var dnsErr *net.DNSError
return errors.As(err, &dnsErr) && dnsErr.IsNotFound
@@ -267,7 +340,8 @@ func (r *FreshResolver) resolve(ctx context.Context, name string) ([]string, err
for i, ns := range nss {
hosts[i] = ns.Host
}
- servers := r.serverAddrs(ctx, zone, hosts, nil)
+ registrable := zone
+ servers := r.serverAddrs(ctx, name, registrable, zone, hosts, nil)
for referrals := 0; ; referrals++ {
ips, ref, err := r.askZone(ctx, servers, name, zone)
if ref == nil {
@@ -276,11 +350,42 @@ func (r *FreshResolver) resolve(ctx context.Context, name string) ([]string, err
if referrals >= freshMaxZones {
return nil, fmt.Errorf("%w: delegation to %s is more than %d levels below the registrable domain", errNoAuthority, name, freshMaxZones)
}
+ servers = r.serverAddrs(ctx, name, registrable, ref.zone, ref.hosts, ref.glue)
zone = ref.zone
- servers = r.serverAddrs(ctx, zone, ref.hosts, ref.glue)
}
}
+// nearest is ResolveUpgrade's fallback for a published name: the cached NS
+// set of the name's immediate parent, then of the name itself (an apex or
+// a delegated sub-zone, which the parent only refers to), each verified
+// and asked like any zone, inside the same Timeout. It may ask the cache
+// about the name's own levels, which is why only a name that already
+// exists ever comes here.
+func (r *FreshResolver) nearest(ctx context.Context, name string) ([]string, error) {
+ registrable, _ := registrableDomain(name)
+ var last error = fmt.Errorf("%w: no zone near %s", errNoAuthority, name)
+ for _, zone := range []string{name[strings.Index(name, ".")+1:], name} {
+ nss, err := r.LookupNS(ctx, zone)
+ if err == nil && len(nss) > 0 {
+ hosts := make([]string, len(nss))
+ for i, ns := range nss {
+ hosts[i] = ns.Host
+ }
+ ips, ref, err := r.askZone(ctx, r.serverAddrs(ctx, name, registrable, zone, hosts, nil), name, zone)
+ if ref == nil && definitive(err) {
+ return ips, err
+ }
+ if err != nil {
+ last = err
+ }
+ }
+ if ctx.Err() != nil {
+ break
+ }
+ }
+ return nil, last
+}
+
// askZone asks servers, which the caller found for zone, about name, one
// at a time: each is verified to hold zone first. It returns the first
// definitive answer or valid referral, else the last failure.
@@ -289,7 +394,7 @@ func (r *FreshResolver) askZone(ctx context.Context, servers []netip.AddrPort, n
for _, s := range servers {
if last = r.verifyZone(ctx, s, zone); last == nil {
ips, ref, err := r.ask(ctx, s, name, zone)
- if ref != nil || err == nil || isNotFound(err) {
+ if ref != nil || definitive(err) {
return ips, ref, err
}
last = err
@@ -314,15 +419,24 @@ type referral struct {
// without a working IPv6 route would otherwise spend its attempts on
// silence. For a referred zone (glue non-nil) a host inside the zone is
// taken from glue only, never the cache: the cache would be asked about a
-// name below the registrable domain. Other hosts go to the cached
-// LookupHost.
-func (r *FreshResolver) serverAddrs(ctx context.Context, zone string, hosts []string, glue map[string][]netip.Addr) []netip.AddrPort {
+// name below the registrable domain. A host that is name itself or one of
+// its levels below registrable (a stale NS entry naming eu.example.com, or
+// the name) is never looked up through the cache at all, at the
+// registrable domain or on a referral: that label may not exist, and the
+// lookup would plant its negative (Astra R3 on #724). Other hosts go to the
+// cached LookupHost.
+func (r *FreshResolver) serverAddrs(ctx context.Context, name, registrable, zone string, hosts []string, glue map[string][]netip.Addr) []netip.AddrPort {
+ onPath := func(host string) bool {
+ return host == name || (strings.HasSuffix(name, "."+host) && strings.HasSuffix(host, "."+registrable))
+ }
var v4, v6 []netip.AddrPort
for _, i := range rand.Perm(len(hosts)) {
host := strings.ToLower(strings.TrimSuffix(hosts[i], "."))
var addrs []netip.Addr
if glue != nil && (host == zone || strings.HasSuffix(host, "."+zone)) {
addrs = glue[host]
+ } else if onPath(host) {
+ continue
} else {
found, err := r.LookupHost(ctx, host)
if err != nil {
@@ -601,7 +715,7 @@ func (r *FreshResolver) answer(ctx context.Context, reply *dnsmessage.Message, s
target := strings.TrimSuffix(current, ".")
if target == name {
// Authoritative, the name exists, and it has no A record.
- return nil, &net.DNSError{Err: "no A record", Name: name, Server: server.String(), IsNotFound: true}
+ return nil, fmt.Errorf("%w: %s (from %s)", errNoData, name, server)
}
if target == zone || strings.HasSuffix(target, "."+zone) {
// In-zone target this server gave no address for: no fallback to
diff --git a/internal/domains/freshdns_stamp_test.go b/internal/domains/freshdns_stamp_test.go
index 29c8f3547..553af63de 100644
--- a/internal/domains/freshdns_stamp_test.go
+++ b/internal/domains/freshdns_stamp_test.go
@@ -534,6 +534,7 @@ type realFresh struct {
fa *fakeAuthority
live *atomic.Bool
cached *func(string) ([]string, error)
+ asked map[string]int // cached-resolver queries by name
now *time.Time
cfg domains.Config
}
@@ -549,7 +550,7 @@ func newRealFresh(t *testing.T) *realFresh {
r.Answers = []dnsmessage.Resource{aRecord("shop.example.com.", edgeIP)}
return true
})
- rf := &realFresh{fa: fa, live: live, now: clock()}
+ rf := &realFresh{fa: fa, live: live, now: clock(), asked: map[string]int{}}
cached := nxdomain
rf.cached = &cached
fresh := oneZone(fa).resolver(rf.now)
@@ -557,14 +558,18 @@ func newRealFresh(t *testing.T) *realFresh {
AppsDomain: "oncarlos.test",
EdgeIPs: func() []string { return []string{edgeIP} },
Resolve: func(h string) ([]string, error) {
+ rf.asked[h]++
if h == "shop.example.com" {
return (*rf.cached)(h)
}
return pointingAt(h)
},
- ResolveFresh: fresh.Resolve,
- FreshForget: fresh.Forget,
- Now: func() time.Time { return *rf.now },
+ // Wired exactly as domainsTickConfig wires production.
+ ResolveFresh: fresh.Resolve,
+ ResolveUpgrade: fresh.ResolveUpgrade,
+ FreshForget: fresh.Forget,
+ FreshStrike: fresh.Strike,
+ Now: func() time.Time { return *rf.now },
}
return rf
}
@@ -580,15 +585,16 @@ func (rf *realFresh) pass(t *testing.T, reg *registry.Registry, live bool, cache
// INVARIANT GUARD (Astra R2 P1-1 on #724): a fresh failure recorded while
// a name was unpublished never suppresses a look after it is published.
-// Pass A: the new name's fresh look fails (silent zone, backoff recorded)
-// and the cache says pointing, so it is published. Pass B, inside the
-// backoff: the cache has gone negative while the record still points
-// here. The upgrade look must really be sent, and the name stays
-// published.
+// Passes A1 and A2: the new name's fresh look fails twice (silent zone,
+// backoff recorded on the second) and the cache says pointing, so it is
+// published. Pass B, inside the backoff: the cache has gone negative while
+// the record still points here. The upgrade look must really be sent, and
+// the name stays published.
func TestStampHealthPublicationClearsAnOnboardingBackoff(t *testing.T) {
rf := newRealFresh(t)
reg := regWithAlias(t, "shop.example.com")
rf.pass(t, reg, false, pointingAt)
+ rf.pass(t, reg, false, pointingAt)
if got := aliasStatus(t, reg, "shop.example.com"); got != "pointing" {
t.Fatalf("pass A: alias = %q, want pointing from the cached fallback", got)
}
@@ -625,3 +631,251 @@ func TestStampHealthPublishedFailureStillBacksOff(t *testing.T) {
t.Fatalf("pass B asked inside the backoff (%d -> %d)", sent, rf.fa.queries.Load())
}
}
+
+// INVARIANT GUARD (Fable R3 P2-1 on #724): two strikes before the cache.
+// A new name's first fresh failure asks nobody else and leaves the stamp
+// alone; the next pass asks fresh again. Only a second failure in a row
+// takes the cached look, and then the backoff holds (no exchange on the
+// pass after, and no Forget for a name that stays "").
+func TestStampHealthNewNameTwoStrikes(t *testing.T) {
+ t.Run("fails, fails", func(t *testing.T) {
+ rf := newRealFresh(t)
+ reg := regWithAlias(t, "shop.example.com")
+ rf.pass(t, reg, false, nxdomain)
+ if rf.asked["shop.example.com"] != 0 {
+ t.Fatal("pass A: first fresh failure asked the cache")
+ }
+ if a := aliasRow(t, reg, "shop.example.com"); a.DNSStatus != "" || a.DNSCheckedAt != 0 {
+ t.Fatalf("pass A: stamp %q at %d, want untouched", a.DNSStatus, a.DNSCheckedAt)
+ }
+ sent := rf.fa.queries.Load()
+ rf.pass(t, reg, false, nxdomain)
+ if rf.fa.queries.Load() == sent {
+ t.Fatal("pass B: no fresh retry after the first failure")
+ }
+ if rf.asked["shop.example.com"] != 1 {
+ t.Fatalf("pass B: cached asked %d times, want 1 (second strike)", rf.asked["shop.example.com"])
+ }
+ if a := aliasRow(t, reg, "shop.example.com"); a.DNSStatus != "" || a.DNSCheckedAt == 0 {
+ t.Fatalf("pass B: stamp %q at %d, want the cached \"\" stamped", a.DNSStatus, a.DNSCheckedAt)
+ }
+ sent = rf.fa.queries.Load()
+ rf.pass(t, reg, true, nxdomain)
+ if rf.fa.queries.Load() != sent {
+ t.Fatal("pass C: asked inside the backoff (Forget called for a name that stayed \"\")")
+ }
+ })
+ t.Run("fails, then answers", func(t *testing.T) {
+ rf := newRealFresh(t)
+ reg := regWithAlias(t, "shop.example.com")
+ rf.pass(t, reg, false, nxdomain)
+ rf.pass(t, reg, true, nxdomain)
+ if got := aliasStatus(t, reg, "shop.example.com"); got != "pointing" {
+ t.Fatalf("pass B: alias = %q, want pointing", got)
+ }
+ if rf.asked["shop.example.com"] != 0 {
+ t.Fatalf("cached asked %d times, want 0", rf.asked["shop.example.com"])
+ }
+ })
+}
+
+func aliasRow(t *testing.T, reg *registry.Registry, alias string) registry.RouteAlias {
+ t.Helper()
+ aliases, err := reg.ListAliases()
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, a := range aliases {
+ if a.Alias == alias {
+ return a
+ }
+ }
+ t.Fatalf("alias %s not found", alias)
+ return registry.RouteAlias{}
+}
+
+// deepCfg is production wiring over deepWorld, with a cached resolver that
+// says NXDOMAIN for deepName and counts its queries.
+func deepCfg(t *testing.T, asked map[string]int) (domains.Config, *world) {
+ t.Helper()
+ w, _ := deepWorld(t)
+ fresh := w.resolver(clock())
+ return domains.Config{
+ AppsDomain: "oncarlos.test",
+ EdgeIPs: func() []string { return []string{edgeIP} },
+ Resolve: counted(func(h string) ([]string, error) {
+ if h == deepName {
+ return nxdomain(h)
+ }
+ return pointingAt(h)
+ }, asked),
+ ResolveFresh: fresh.Resolve,
+ ResolveUpgrade: fresh.ResolveUpgrade,
+ FreshForget: fresh.Forget,
+ FreshStrike: fresh.Strike,
+ Now: func() time.Time { return time.Unix(5000, 0) },
+ }, w
+}
+
+// INVARIANT GUARD (Astra R3 P1 on #724): a published name under a
+// delegation deeper than the top-down walk follows stays published: its
+// upgrade look falls back to the nearest zone. The same name as a NEW
+// candidate never takes that fallback: nothing below the registrable
+// domain reaches the cache.
+func TestStampHealthDeepDelegation(t *testing.T) {
+ t.Run("published", func(t *testing.T) {
+ asked := map[string]int{}
+ cfg, _ := deepCfg(t, asked)
+ reg := regWithAlias(t, deepName)
+ stampAlias(t, reg, deepName, "pointing")
+ if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil {
+ t.Fatal(err)
+ }
+ if got := aliasStatus(t, reg, deepName); got != "pointing" {
+ t.Fatalf("published alias = %q, want pointing", got)
+ }
+ })
+ t.Run("new", func(t *testing.T) {
+ asked := map[string]int{}
+ cfg, w := deepCfg(t, asked)
+ reg := regWithAlias(t, deepName)
+ if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil {
+ t.Fatal(err)
+ }
+ noCachedBelow(t, w, deepName, "example.com")
+ if asked[deepName] != 0 {
+ t.Fatalf("cached resolver asked about %s on the first failure", deepName)
+ }
+ })
+}
+
+// Astra R3 P2-2: a new name with only an AAAA record pointing at an IPv6
+// edge. The fresh look says "exists, no A record"; the cached look, which
+// sees AAAA, decides, and the name is "pointing".
+func TestStampHealthAAAAOnlyName(t *testing.T) {
+ const edge6 = "2001:db8::7"
+ fa := startAuthority(t, "example.com", authoritative())
+ fresh := oneZone(fa).resolver(clock())
+ reg := regWithAlias(t, "shop.example.com")
+ cfg := domains.Config{
+ AppsDomain: "oncarlos.test",
+ EdgeIPs: func() []string { return []string{edgeIP, edge6} },
+ Resolve: func(h string) ([]string, error) {
+ if h == "shop.example.com" {
+ return []string{edge6}, nil
+ }
+ return pointingAt(h)
+ },
+ ResolveFresh: fresh.Resolve,
+ ResolveUpgrade: fresh.ResolveUpgrade,
+ FreshForget: fresh.Forget,
+ FreshStrike: fresh.Strike,
+ Now: func() time.Time { return time.Unix(5000, 0) },
+ }
+ if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil {
+ t.Fatal(err)
+ }
+ if got := aliasStatus(t, reg, "shop.example.com"); got != "pointing" {
+ t.Fatalf("AAAA-only alias = %q, want pointing", got)
+ }
+}
+
+// Fable R3 P2-2: never-checked names get the fresh budget before standing
+// non-pointing ones, and a lookup answered from the backoff costs none.
+func TestStampHealthFreshBudgetOrder(t *testing.T) {
+ defer domains.SetFreshPassMax(1)()
+ t.Run("never checked first", func(t *testing.T) {
+ for trial := 0; trial < 10; trial++ {
+ reg := regWithAlias(t, "old.example.com")
+ if err := reg.SetAliasDNSStatus("old.example.com", "elsewhere", 100); err != nil {
+ t.Fatal(err)
+ }
+ if err := reg.UpsertAlias(registry.RouteAlias{Alias: "new.example.com", Host: "app.acct.oncarlos.test", Account: "acct", App: "app"}); err != nil {
+ t.Fatal(err)
+ }
+ var calls []string
+ cfg := freshCfg(pointingAt, nxdomain, &calls)
+ if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil {
+ t.Fatal(err)
+ }
+ if len(calls) != 1 || calls[0] != "new.example.com" {
+ t.Fatalf("fresh lookups = %v, want [new.example.com]", calls)
+ }
+ }
+ })
+ t.Run("backoff hits are free", func(t *testing.T) {
+ reg := regWithAlias(t, "a.example.com")
+ if err := reg.UpsertAlias(registry.RouteAlias{Alias: "b.example.com", Host: "app.acct.oncarlos.test", Account: "acct", App: "app"}); err != nil {
+ t.Fatal(err)
+ }
+ for alias, at := range map[string]int64{"a.example.com": 100, "b.example.com": 200} {
+ if err := reg.SetAliasDNSStatus(alias, "elsewhere", at); err != nil {
+ t.Fatal(err)
+ }
+ }
+ var calls []string
+ cfg := freshCfg(pointingAt, func(h string) ([]string, error) {
+ if h == "a.example.com" {
+ return nil, fmt.Errorf("%w", domains.ErrFreshBackingOff)
+ }
+ return nxdomain(h)
+ }, &calls)
+ if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil {
+ t.Fatal(err)
+ }
+ if len(calls) != 2 {
+ t.Fatalf("fresh lookups = %v, want both: the backoff hit cost nothing", calls)
+ }
+ })
+}
+
+// Fable R3 P2-3: past the budget, a published name keeps its cached
+// verdict (no upgrade look), by count and by time.
+func TestStampHealthPublishedNamePastTheBudget(t *testing.T) {
+ setup := func(t *testing.T) (*registry.Registry, domains.Config, *[]string) {
+ reg := regWithAlias(t, "a.example.com")
+ if err := reg.UpsertAlias(registry.RouteAlias{Alias: "b.example.com", Host: "app.acct.oncarlos.test", Account: "acct", App: "app"}); err != nil {
+ t.Fatal(err)
+ }
+ stampAlias(t, reg, "a.example.com", "pointing")
+ stampAlias(t, reg, "b.example.com", "pointing")
+ var calls []string
+ cfg := freshCfg(func(h string) ([]string, error) {
+ if h == "app.acct.oncarlos.test" {
+ return pointingAt(h)
+ }
+ return nxdomain(h)
+ }, pointingAt, &calls)
+ return reg, cfg, &calls
+ }
+ t.Run("count", func(t *testing.T) {
+ defer domains.SetFreshPassMax(1)()
+ reg, cfg, calls := setup(t)
+ if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil {
+ t.Fatal(err)
+ }
+ if len(*calls) != 1 {
+ t.Fatalf("fresh lookups = %v, want 1", *calls)
+ }
+ other := "a.example.com"
+ if (*calls)[0] == other {
+ other = "b.example.com"
+ }
+ if aliasStatus(t, reg, (*calls)[0]) != "pointing" || aliasStatus(t, reg, other) != "" {
+ t.Fatalf("looked-at name raised and the other on its cached \"\" expected")
+ }
+ })
+ t.Run("time", func(t *testing.T) {
+ defer domains.SetFreshPassTime(0)()
+ reg, cfg, calls := setup(t)
+ if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil {
+ t.Fatal(err)
+ }
+ if len(*calls) != 0 {
+ t.Fatalf("fresh lookups = %v, want none with no time budget", *calls)
+ }
+ if aliasStatus(t, reg, "a.example.com") != "" || aliasStatus(t, reg, "b.example.com") != "" {
+ t.Fatal("past the time budget a published name keeps its cached verdict")
+ }
+ })
+}
diff --git a/internal/domains/freshdns_test.go b/internal/domains/freshdns_test.go
index 0957fbac9..86d49a66f 100644
--- a/internal/domains/freshdns_test.go
+++ b/internal/domains/freshdns_test.go
@@ -656,32 +656,190 @@ func TestFreshResolverRefusesAReferralOffThePath(t *testing.T) {
// Delegation deeper than freshMaxZones referrals fails closed: the zone
// past the bound is never asked.
-func TestFreshResolverBoundsTheReferrals(t *testing.T) {
- name := "shop.a.b.c.d.example.com"
+// deepName sits four delegations below example.com, past freshMaxZones.
+const deepName = "shop.a.b.c.d.example.com"
+
+// deepWorld is the healthy hierarchy example.com -> d -> c -> b ->
+// a.b.c.d.example.com, each its own zone, the last serving deepName
+// pointing here. The cache also knows the last zone's NS set, as a
+// resolver that has followed the delegation would. last is its server.
+func deepWorld(t *testing.T) (w *world, last *fakeAuthority) {
+ t.Helper()
zones := []string{"example.com", "d.example.com", "c.d.example.com", "b.c.d.example.com", "a.b.c.d.example.com"}
- w := &world{
- ns: map[string][]string{"example.com": {"ns1.example.com."}},
- hosts: map[string][]string{"ns1.example.com": {"192.0.2.10"}},
+ w = &world{
+ ns: map[string][]string{
+ "example.com": {"ns1.example.com."},
+ "a.b.c.d.example.com": {"ns.provider.net."},
+ },
+ hosts: map[string][]string{"ns1.example.com": {"192.0.2.10"}, "ns.provider.net": {"192.0.2.14"}},
routes: map[string]*fakeAuthority{},
}
- var last *fakeAuthority
for i, z := range zones {
addr := fmt.Sprintf("192.0.2.%d", 10+i)
var fa *fakeAuthority
if i+1 < len(zones) {
fa = startAuthority(t, z, referral(zones[i+1], fmt.Sprintf("192.0.2.%d", 11+i)))
} else {
- fa = startAuthority(t, z, authoritative(aRecord(name+".", edgeIP)))
+ fa = startAuthority(t, z, authoritative(aRecord(deepName+".", edgeIP)))
last = fa
}
w.routes[addr+":53"] = fa
}
+ return w, last
+}
+
+func TestFreshResolverBoundsTheReferrals(t *testing.T) {
+ w, last := deepWorld(t)
+ name := deepName
if ips, err := w.resolver(clock()).Resolve(name); err == nil {
t.Fatalf("Resolve = %v, want delegation past the bound refused", ips)
}
if last.queries.Load() != 0 {
t.Fatal("asked the zone past the referral bound")
}
+ noCachedBelow(t, w, name, "example.com")
+}
+
+// Astra R3 P1 on #724: ResolveUpgrade, for a published name only, falls
+// back to the name's nearest zone when the top-down walk gives no answer,
+// so a deep delegation main reached still resolves.
+func TestFreshResolverUpgradeFallsBackToTheNearestZone(t *testing.T) {
+ w, last := deepWorld(t)
+ ips, err := w.resolver(clock()).ResolveUpgrade(deepName)
+ if err != nil || len(ips) != 1 || ips[0] != edgeIP {
+ t.Fatalf("ResolveUpgrade = %v, %v; want [%s] from the nearest zone", ips, err, edgeIP)
+ }
+ if last.queries.Load() == 0 {
+ t.Fatal("the nearest zone was never asked")
+ }
+}
+
+// Astra R3 P2-2: an authoritative "exists, no A record" (AAAA only) is
+// not "no such name": it is errNoData, and it does not back off.
+func TestFreshResolverTellsNoDataFromNXDOMAIN(t *testing.T) {
+ fa := startAuthority(t, "example.com", authoritative())
+ r := oneZone(fa).resolver(clock())
+ _, err := r.Resolve("shop.example.com")
+ if err == nil || isNotFoundErr(err) || !errors.Is(err, domains.ErrFreshNoData) {
+ t.Fatalf("Resolve error = %v, want errNoData", err)
+ }
+ sent := fa.queries.Load()
+ _, _ = r.Resolve("shop.example.com")
+ if fa.queries.Load() == sent {
+ t.Fatal("NODATA put the name into the failure backoff")
+ }
+}
+
+// Astra R3 P2-3 / Fable P3-4: a nameserver host that is the name or one of
+// its levels below the registrable domain (a stale NS entry) is never
+// looked up through the cache, at the registrable domain or on a referral.
+// Every cached query is listed.
+func TestFreshResolverNeverLooksUpAnOnPathNameserver(t *testing.T) {
+ t.Run("registrable NS set", func(t *testing.T) {
+ fa := startAuthority(t, "example.com", nxdomainAnswer)
+ w := &world{
+ ns: map[string][]string{"example.com": {"ns.provider.net.", "eu.example.com.", "shop.eu.example.com."}},
+ hosts: map[string][]string{"ns.provider.net": {"192.0.2.53"}},
+ routes: map[string]*fakeAuthority{"192.0.2.53:53": fa},
+ }
+ if _, err := w.resolver(clock()).Resolve("shop.eu.example.com"); !isNotFoundErr(err) {
+ t.Fatalf("Resolve error = %v, want the authoritative not-found", err)
+ }
+ if got := strings.Join(w.cached, ","); got != "NS example.com,HOST ns.provider.net" {
+ t.Fatalf("cached queries = %s, want only NS example.com and HOST ns.provider.net", got)
+ }
+ })
+ t.Run("referral NS set", func(t *testing.T) {
+ child := startAuthority(t, "b.a.example.com", nxdomainAnswer)
+ parent := startAuthority(t, "example.com", func(_ dnsmessage.Question, r *dnsmessage.Message) bool {
+ for _, h := range []string{"a.example.com.", "ns.provider.net."} {
+ r.Authorities = append(r.Authorities, dnsmessage.Resource{
+ Header: dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName("b.a.example.com."), Type: dnsmessage.TypeNS, Class: dnsmessage.ClassINET, TTL: 300},
+ Body: &dnsmessage.NSResource{NS: dnsmessage.MustNewName(h)},
+ })
+ }
+ return true
+ })
+ w := oneZone(parent)
+ w.hosts["ns.provider.net"] = []string{"192.0.2.40"}
+ w.routes["192.0.2.40:53"] = child
+ if _, err := w.resolver(clock()).Resolve("shop.b.a.example.com"); !isNotFoundErr(err) {
+ t.Fatalf("Resolve error = %v, want the child's not-found", err)
+ }
+ if got := strings.Join(w.cached, ","); got != "NS example.com,HOST ns1.example.com,HOST ns.provider.net" {
+ t.Fatalf("cached queries = %s, want no lookup of a.example.com", got)
+ }
+ })
+}
+
+// Astra R3 P2-4: Timeout bounds the whole lookup, not only each exchange.
+func TestFreshResolverTimeoutBoundsTheWholeLookup(t *testing.T) {
+ t.Run("below one attempt", func(t *testing.T) {
+ w := oneZone(startAuthority(t, "example.com", nil))
+ r := w.resolver(clock())
+ r.Timeout, r.AttemptTimeout = 150*time.Millisecond, time.Second
+ start := time.Now()
+ if _, err := r.Resolve("shop.example.com"); err == nil {
+ t.Fatal("Resolve against a silent server succeeded")
+ }
+ if took := time.Since(start); took > 400*time.Millisecond {
+ t.Fatalf("Resolve took %s with Timeout 150ms", took)
+ }
+ })
+ t.Run("timely exchanges, too many of them", func(t *testing.T) {
+ // Each zone answers in 120 ms, inside AttemptTimeout; four zones
+ // need 480 ms, past the 350 ms Timeout.
+ name := "shop.b.c.d.example.com"
+ zones := []string{"example.com", "d.example.com", "c.d.example.com", "b.c.d.example.com"}
+ w := &world{
+ ns: map[string][]string{"example.com": {"ns1.example.com."}},
+ hosts: map[string][]string{"ns1.example.com": {"192.0.2.10"}},
+ routes: map[string]*fakeAuthority{},
+ }
+ for i, z := range zones {
+ var answer func(dnsmessage.Question, *dnsmessage.Message) bool
+ if i+1 < len(zones) {
+ answer = referral(zones[i+1], fmt.Sprintf("192.0.2.%d", 11+i))
+ } else {
+ answer = authoritative(aRecord(name+".", edgeIP))
+ }
+ slow := func(q dnsmessage.Question, r *dnsmessage.Message) bool {
+ time.Sleep(120 * time.Millisecond)
+ return answer(q, r)
+ }
+ w.routes[fmt.Sprintf("192.0.2.%d:53", 10+i)] = startAuthority(t, z, slow)
+ }
+ r := w.resolver(clock())
+ r.Timeout, r.AttemptTimeout = 350*time.Millisecond, 300*time.Millisecond
+ start := time.Now()
+ if ips, err := r.Resolve(name); err == nil {
+ t.Fatalf("Resolve = %v, want the overall deadline to stop the walk", ips)
+ }
+ if took := time.Since(start); took > 600*time.Millisecond {
+ t.Fatalf("Resolve took %s with Timeout 350ms", took)
+ }
+ })
+ t.Run("during cached discovery", func(t *testing.T) {
+ r := &domains.FreshResolver{
+ LookupNS: func(ctx context.Context, _ string) ([]*net.NS, error) {
+ select {
+ case <-ctx.Done():
+ return nil, ctx.Err()
+ case <-time.After(3 * time.Second):
+ return []*net.NS{{Host: "ns1.example.com."}}, nil
+ }
+ },
+ LookupHost: func(context.Context, string) ([]string, error) { return nil, errNotFound },
+ Timeout: 150 * time.Millisecond,
+ }
+ start := time.Now()
+ if _, err := r.Resolve("shop.example.com"); err == nil {
+ t.Fatal("Resolve succeeded")
+ }
+ if took := time.Since(start); took > time.Second {
+ t.Fatalf("Resolve took %s: the cached discovery ignored the deadline", took)
+ }
+ })
}
// Astra R2 P2: every zone is verified before it is trusted, the
@@ -732,15 +890,28 @@ func TestFreshResolverVerifiesEveryZone(t *testing.T) {
// Glue is tenant input like any nameserver address: a non-public one is
// never dialled.
+// A nameserver inside the referred child with no glue is not looked up
+// through the cache either (Fable R3 P2-3): the cache would be asked about
+// a name below the registrable domain.
func TestFreshResolverNeverDialsNonPublicGlue(t *testing.T) {
- w := oneZone(startAuthority(t, "example.com", referral("eu.example.com", "10.0.0.5")))
- if _, err := w.resolver(clock()).Resolve("shop.eu.example.com"); err == nil {
- t.Fatal("Resolve succeeded")
- }
- for _, d := range w.dialed {
- if d != "192.0.2.53:53" {
- t.Fatalf("dialled %v", w.dialed)
- }
+ for name, glue := range map[string]string{"non-public glue": "10.0.0.5", "no glue": ""} {
+ t.Run(name, func(t *testing.T) {
+ w := oneZone(startAuthority(t, "example.com", referral("eu.example.com", glue)))
+ w.hosts["ns.eu.example.com"] = []string{"192.0.2.40"}
+ w.routes["192.0.2.40:53"] = startAuthority(t, "eu.example.com", authoritative(aRecord("shop.eu.example.com.", edgeIP)))
+ if _, err := w.resolver(clock()).Resolve("shop.eu.example.com"); err == nil {
+ t.Fatal("Resolve succeeded")
+ }
+ for _, d := range w.dialed {
+ if d != "192.0.2.53:53" {
+ t.Fatalf("dialled %v", w.dialed)
+ }
+ }
+ if w.cachedFor("ns.eu.example.com") != 0 {
+ t.Fatalf("looked up the in-child nameserver through the cache: %v", w.cached)
+ }
+ noCachedBelow(t, w, "shop.eu.example.com", "example.com")
+ })
}
}
diff --git a/internal/domains/reconcile.go b/internal/domains/reconcile.go
index ca9a5ce12..6458b652f 100644
--- a/internal/domains/reconcile.go
+++ b/internal/domains/reconcile.go
@@ -14,6 +14,7 @@ import (
"os"
"path/filepath"
"slices"
+ "sort"
"strings"
"time"
@@ -45,10 +46,18 @@ type Config struct {
// ResolveFresh asks without any cache (#724); see dnsVerdicts. nil
// leaves every verdict to Resolve alone.
ResolveFresh func(host string) ([]string, error)
+ // ResolveUpgrade is ResolveFresh for a published name's upgrade look,
+ // with a fallback to the name's nearest zone (FreshResolver's
+ // ResolveUpgrade); nil uses ResolveFresh. Never used for a new name.
+ ResolveUpgrade func(host string) ([]string, error)
// FreshForget ends ResolveFresh's failure backoff for a host (the same
// resolver's Forget); dnsVerdicts calls it when a name it looked at
// fresh before publication is published. nil skips that.
FreshForget func(host string)
+ // FreshStrike is the same resolver's Strike: the two-strike rule for a
+ // new name whose fresh look failed (see dnsVerdicts). nil takes the
+ // cached look on the first failure.
+ FreshStrike func(host string) (second bool)
// AcmeDir is the edge's autocert DirCache directory; "" skips TLS
// stamping entirely.
AcmeDir string
@@ -505,15 +514,15 @@ func StampHealth(ctx context.Context, reg *registry.Registry, cfg Config, routes
aliasStatus := make([]string, len(aliases))
var candidates []freshCandidate
for i, rt := range routes {
- candidates = append(candidates, freshCandidate{rt.Host, rt.DNSStatus, &routeStatus[i]})
+ candidates = append(candidates, freshCandidate{rt.Host, rt.DNSStatus, rt.DNSCheckedAt, &routeStatus[i]})
}
for i, a := range aliases {
- candidates = append(candidates, freshCandidate{a.Alias, a.DNSStatus, &aliasStatus[i]})
+ candidates = append(candidates, freshCandidate{a.Alias, a.DNSStatus, a.DNSCheckedAt, &aliasStatus[i]})
}
dnsVerdicts(cfg, edge, candidates)
for i, rt := range routes {
status := routeStatus[i]
- if status == unresolvedDNS && rt.DNSStatus != "" {
+ if status == heldDNS || status == unresolvedDNS && rt.DNSStatus != "" {
continue
}
if err := reg.SetDNSStatus(rt.Host, status, now); err != nil {
@@ -522,7 +531,7 @@ func StampHealth(ctx context.Context, reg *registry.Registry, cfg Config, routes
}
for i, a := range aliases {
status := aliasStatus[i]
- if status == unresolvedDNS && a.DNSStatus != "" {
+ if status == heldDNS || status == unresolvedDNS && a.DNSStatus != "" {
continue
}
if err := reg.SetAliasDNSStatus(a.Alias, status, now); err != nil {
@@ -555,6 +564,11 @@ func StampHealth(ctx context.Context, reg *registry.Registry, cfg Config, routes
// difference between blaming the customer and owning the outage.
const unresolvedDNS = "unresolved"
+// heldDNS is not a stamp: it is dnsVerdicts saying "this pass decided
+// nothing about this name, leave its stamp and check time alone" (a new
+// name's first fresh failure, see dnsVerdicts). Section 4 never writes it.
+const heldDNS = "\x00held"
+
// dnsStatus resolves host and classifies the answer against edge. Three
// distinct unknowns, deliberately:
//
@@ -570,6 +584,11 @@ const unresolvedDNS = "unresolved"
// never drift apart.
func dnsStatus(resolve func(host string) ([]string, error), host string, edge map[string]bool) string {
ips, err := resolve(host)
+ return classifyDNS(ips, err, edge)
+}
+
+// classifyDNS is dnsStatus's verdict for one lookup's result.
+func classifyDNS(ips []string, err error, edge map[string]bool) string {
if err != nil {
var dnsErr *net.DNSError
if errors.As(err, &dnsErr) && dnsErr.IsNotFound {
@@ -586,11 +605,13 @@ func dnsStatus(resolve func(host string) ([]string, error), host string, edge ma
}
// freshCandidate is one name section 4 stamps: its stamp before this pass
-// (prev) and where dnsVerdicts writes this pass's verdict.
+// (prev) and when that was checked (0 = never), and where dnsVerdicts
+// writes this pass's verdict.
type freshCandidate struct {
- host string
- prev string
- status *string
+ host string
+ prev string
+ checked int64
+ status *string
}
// The per-pass bound on fresh lookups (#724). Each costs at most the
@@ -609,7 +630,7 @@ var (
//
// A name that was NOT "pointing" before this pass is looked at fresh
// FIRST, and the cached resolver is not asked about it at all unless the
-// fresh look fails. The customer attaches a hostname and then adds the
+// fresh look fails twice in a row or the name is past the budget. The customer attaches a hostname and then adds the
// record (the order attach prints), so such a name may not exist yet, and
// a cached query for it would plant a "no such name" in systemd-resolved
// and the VPC resolver behind it for the zone's SOA minimum. The cert
@@ -617,9 +638,12 @@ var (
// them about the name before it exists, its first lookup after the record
// goes live is a clean miss. The fresh verdicts are the cached path's:
// addresses including an edge are "pointing", other addresses
-// "elsewhere", an authoritative not-found "". A fresh FAILURE (no
-// authority, backoff, timeout) decides nothing and the cached path stamps
-// as it always has.
+// "elsewhere", an authoritative not-found "". An authoritative "exists,
+// no A record" takes the cached look (it sees every address family, and
+// the name exists). A fresh FAILURE (no authority, backoff, timeout)
+// follows the two-strike rule: the first in a row decides nothing (the
+// stamp is held and the next pass asks fresh again), the second takes the
+// cached look as before #724.
//
// A name that WAS "pointing" keeps the cached-first path: a positive cache
// entry is cheap and cannot be a primed miss. Its fresh look may only
@@ -628,7 +652,10 @@ var (
// verdict as it was. So the fresh path can never unpublish a name: it
// decides the verdict only for names that were not "pointing" before this
// pass, and a published name stays decided by the cached path plus that
-// upgrade, as before. A cached lookup that FAILED is not upgraded either:
+// upgrade, as before. The upgrade look is ResolveUpgrade: top-down like
+// any fresh look, then the name's nearest zone if that gives no answer,
+// so a published name under a deep delegation is still found. A cached
+// lookup that FAILED is not upgraded either:
// that is our resolver's fault, handled by section 4's hold-last-verdict
// rule.
//
@@ -687,11 +714,16 @@ func dnsVerdicts(cfg Config, edge map[string]bool, candidates []freshCandidate)
}
}()
rand.Shuffle(len(upgrades), func(i, j int) { upgrades[i], upgrades[j] = upgrades[j], upgrades[i] })
+ // New names: never-checked first (a fresh attach is the case #724 is
+ // for), then the longest since checked, so standing non-pointing names
+ // cannot crowd a new one out of the budget (Fable R3 on #724).
rand.Shuffle(len(firsts), func(i, j int) { firsts[i], firsts[j] = firsts[j], firsts[i] })
+ sort.SliceStable(firsts, func(i, j int) bool { return firsts[i].checked < firsts[j].checked })
pending := append(upgrades, firsts...)
start := time.Now()
+ spent := 0
for n, c := range pending {
- if n >= freshPassMax || time.Since(start) >= freshPassTime {
+ if spent >= freshPassMax || time.Since(start) >= freshPassTime {
// Out of budget: a fresh-first name falls back to the cached
// look; an upgrade candidate keeps its cached verdict.
for _, rest := range pending[n:] {
@@ -701,14 +733,35 @@ func dnsVerdicts(cfg Config, edge map[string]bool, candidates []freshCandidate)
}
return
}
- fresh := dnsStatus(cfg.ResolveFresh, c.host, edge)
+ resolve := cfg.ResolveFresh
+ if c.prev == "pointing" && cfg.ResolveUpgrade != nil {
+ // Published, so it exists: the nearest-zone fallback cannot
+ // prime anything. A new name NEVER takes this path.
+ resolve = cfg.ResolveUpgrade
+ }
+ ips, err := resolve(c.host)
+ if !errors.Is(err, errBackingOff) {
+ spent++ // an answer from the backoff sent nothing
+ }
+ fresh := classifyDNS(ips, err, edge)
switch {
case c.prev == "pointing":
if fresh == "pointing" {
*c.status = "pointing"
}
- case fresh == unresolvedDNS:
+ case errors.Is(err, errNoData):
+ // The name exists with no A record (AAAA only, say): the
+ // cached look sees every family and primes nothing.
*c.status = dnsStatus(cfg.Resolve, c.host, edge)
+ case fresh == unresolvedDNS:
+ // Two strikes: the first failure in a row decides nothing and
+ // asks nobody else (the resolver forgives it, so the next pass
+ // asks fresh again); only the second takes the cached look.
+ if cfg.FreshStrike != nil && !cfg.FreshStrike(c.host) {
+ *c.status = heldDNS
+ } else {
+ *c.status = dnsStatus(cfg.Resolve, c.host, edge)
+ }
default:
*c.status = fresh
}
diff --git a/internal/host/agent.go b/internal/host/agent.go
index 454731a0e..382b9d4bc 100644
--- a/internal/host/agent.go
+++ b/internal/host/agent.go
@@ -3832,7 +3832,9 @@ func domainsTickConfig(getenv func(string) string, publicIP string) (domains.Con
LookupHost: net.DefaultResolver.LookupHost,
}
cfg.ResolveFresh = fresh.Resolve
+ cfg.ResolveUpgrade = fresh.ResolveUpgrade
cfg.FreshForget = fresh.Forget
+ cfg.FreshStrike = fresh.Strike
// EdgeIPs is deliberately left nil here — a Config out of this function
// alone stamps nothing. domainsLoop installs the fold once it has a
// store; see the doc comment.
diff --git a/internal/host/host_test.go b/internal/host/host_test.go
index 09be8bf0f..ec6809bdb 100644
--- a/internal/host/host_test.go
+++ b/internal/host/host_test.go
@@ -772,8 +772,8 @@ func TestDomainsTickConfig(t *testing.T) {
}
// #724: the uncached second look for a customer's hostname is wired in
// production, not only in the domains tests.
- if got.ResolveFresh == nil || got.FreshForget == nil {
- t.Error("ResolveFresh/FreshForget not populated on a configured deployment")
+ if got.ResolveFresh == nil || got.ResolveUpgrade == nil || got.FreshForget == nil || got.FreshStrike == nil {
+ t.Error("ResolveFresh/ResolveUpgrade/FreshForget/FreshStrike not populated on a configured deployment")
}
// No explicit edge IPs: the box's own public IP (IMDS) is the default.
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 4ea615b9a..453051fa9 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -144,4 +144,4 @@ plan14-root-reads-deploy-edge-718.tsv 250e3ba91e1bc5fcd6be5cc2bafce4c7d6645d2d2f
plan14-root-reads-demo-slice-adopt.tsv 707018faaa1fee3b47abb78389ae7854264e76621cc316889061adb69bf13e10
plan14-root-reads-security-review-mitigations.tsv a6f3f9eec4aac5ea88f20d0e52eaa0651fce80c0d49b60883ff61ceade33d288
plan14-root-reads-cli-registry-words.tsv 8924fafc5b6083858a72f45c764081abe3bcad6a6de71901470586c076c64bb6
-plan14-root-reads-no-negative-prime-724.tsv 638b1b2c6720713927139989c74a0f133de77f765df4e3a0c0a333137582b2ca
+plan14-root-reads-no-negative-prime-724.tsv 70bb4d8af6dc72d82a629d1c079acf6716a32e3fef5d7ae2b1f2c761b99c614e
diff --git a/internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv b/internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv
index a5f3f61b5..f7e5ad3df 100644
--- a/internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv
+++ b/internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv
@@ -1,13 +1,13 @@
# Census overlay no-negative-prime-724, written by census-propose (#369). census-ruling-no-negative-prime-724, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-no-negative-prime-724.md.
-# 1 body, 1 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
-# 2 new dispositions: 0 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 1 quiet units retired while they read nothing, 0 other.
-@legacy 727531fde7bbe7f11167a33b377ce1582223f96714e712f7c5d1342e90697a50 internal/host/agent.go domainsTickConfig legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-dns-fresh-lookup-724;basis=wires ResolveFresh to a FreshResolver over net.DefaultResolver (LookupNS, LookupHost, LookupCNAME) (#724);rev3=census-ruling-no-negative-prime-724;basis=builds the one FreshResolver per config as a local and wires both its Resolve (ResolveFresh) and its Forget (new FreshForget, clears that resolver's in-memory failure backoff for a host) into domains.Config; drops LookupCNAME from the resolver (the cached CNAME shortcut is gone: the fresh walk now starts at the ICANN registrable domain and follows verified referrals down); reads nothing new, no file, path, env var or command input added (#724) data-literal@469,data-literal@510 133e8f1ce245512bb3a8b5e0fddb32e86fcc0afe39c0e12cff4a4debf2f6366e
+# 1 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 3 new dispositions: 1 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 1 quiet units retired while they read nothing, 0 other.
+@legacy 0eaefef4c49973592bda938ef5dce716c9354263a531cb454a04b36ca92723a8 internal/host/agent.go domainsTickConfig legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-dns-fresh-lookup-724;basis=wires ResolveFresh to a FreshResolver over net.DefaultResolver (LookupNS, LookupHost, LookupCNAME) (#724);rev3=census-ruling-no-negative-prime-724;basis=builds the one FreshResolver per config as a local and wires four of its methods into domains.Config: Resolve (ResolveFresh), ResolveUpgrade (new: same lookup plus a nearest-zone fallback through the cached NS set, used only for names already "pointing"), Forget (FreshForget, clears that resolver's in-memory backoff and strike for a host) and Strike (new FreshStrike, the in-memory two-strike rule for a new name's fresh failure); drops LookupCNAME from the resolver; reads nothing new, no file, path, env var or command input added (#724) data-literal@469,data-literal@510 6e3e65fe420646b3321e0c309d2e821ce99cb58071aee2c47ab15ef067c24ce8
@legacy 5d212a8ac7796a96174c8f1eb2aa31288c958ad7ec7bbd1705715a2577614e34 internal/domains/freshdns.go FreshResolver.query legacy accepted-legacy accepted-legacy;rev3=census-ruling-no-negative-prime-724;basis=new: the body of the old FreshResolver.exchange moved here unchanged except that it no longer checks the authority and truncation flags (exchange still does, for SOA verification; ask checks truncation and reads a non-authoritative reply only as a referral down the name's path). The file:Read is the same conn.Read of one UDP reply from a nameserver that passed publicNameserver, with the same exact question matching; no file, path or new input (#724) file:Read@1214 f91e835feced403f06169f7fbec3816dbf5b4b53177915197b61a1ee40bff8ba
-@legacy 47d88f7e405dfbee51b1270d2d0c22c35a29bc750806a9955847be63b25310dd internal/domains/reconcile.go StampHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address "pointing", other "elsewhere", authoritative not-found ""), falling back to the cached lookup on a fresh error or past the budget; a previously "pointing" name keeps cached-first plus the upgrade-only fresh look, so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) registry:Alias@3172,registry:Alias@3700,registry:Alias@3790,registry:Alias@4224,registry:Alias@4288,registry:Alias@4376,registry:DNSStatus@3053,registry:DNSStatus@3181,registry:DNSStatus@3349,registry:DNSStatus@3624,registry:Host@3044,registry:Host@3421,registry:Host@3505,registry:Host@3993,registry:Host@4052,registry:Host@4134,whole:Route@199,whole:Route@236,whole:Route@2871,whole:Route@2984,whole:Route@3277,whole:Route@3947,whole:RouteAlias@2917,whole:RouteAlias@3111,whole:RouteAlias@3551,whole:RouteAlias@4177,whole:RouteAlias@780 8a40c0797f5e0dd2598359a130eeea4e7770fc4208d1b20d501143dd9925549f
-internal/host/agent.go domainsTickConfig legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-dns-fresh-lookup-724;basis=wires ResolveFresh to a FreshResolver over net.DefaultResolver (LookupNS, LookupHost, LookupCNAME) (#724);rev3=census-ruling-no-negative-prime-724;basis=builds the one FreshResolver per config as a local and wires both its Resolve (ResolveFresh) and its Forget (new FreshForget, clears that resolver's in-memory failure backoff for a host) into domains.Config; drops LookupCNAME from the resolver (the cached CNAME shortcut is gone: the fresh walk now starts at the ICANN registrable domain and follows verified referrals down); reads nothing new, no file, path, env var or command input added (#724) data-literal@469,data-literal@510 133e8f1ce245512bb3a8b5e0fddb32e86fcc0afe39c0e12cff4a4debf2f6366e
+@legacy d8aa81f4c5642ada2e77e51a01cf066e6cdcf5f704642fd8e195b3e9de54be92 internal/domains/reconcile.go StampHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address "pointing", other "elsewhere", authoritative not-found ""), falling back to the cached lookup on a fresh error or past the budget; a previously "pointing" name keeps cached-first plus the upgrade-only fresh look, so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; a new name's first fresh failure in a row is held (stamp and check time untouched, the resolver forgives it so the next pass asks fresh again) and only the second takes the cached look; a fresh "exists, no A record" takes the cached look; new names are ordered never-checked first, and lookups answered from the backoff do not count against the budget; a published name's upgrade look uses ResolveUpgrade, which may fall back to the nearest zone; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) registry:Alias@3189,registry:Alias@3775,registry:Alias@3865,registry:Alias@4299,registry:Alias@4363,registry:Alias@4451,registry:DNSCheckedAt@3067,registry:DNSCheckedAt@3211,registry:DNSStatus@3053,registry:DNSStatus@3198,registry:DNSStatus@3403,registry:DNSStatus@3699,registry:Host@3044,registry:Host@3475,registry:Host@3559,registry:Host@4068,registry:Host@4127,registry:Host@4209,whole:Route@199,whole:Route@236,whole:Route@2871,whole:Route@2984,whole:Route@3310,whole:Route@4022,whole:RouteAlias@2917,whole:RouteAlias@3128,whole:RouteAlias@3605,whole:RouteAlias@4252,whole:RouteAlias@780 a1345c0d3076a9cd7ff17bc95fed36df451b5391dce43eb77d8b5151a6d5fb13
+internal/host/agent.go domainsTickConfig legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-dns-fresh-lookup-724;basis=wires ResolveFresh to a FreshResolver over net.DefaultResolver (LookupNS, LookupHost, LookupCNAME) (#724);rev3=census-ruling-no-negative-prime-724;basis=builds the one FreshResolver per config as a local and wires four of its methods into domains.Config: Resolve (ResolveFresh), ResolveUpgrade (new: same lookup plus a nearest-zone fallback through the cached NS set, used only for names already "pointing"), Forget (FreshForget, clears that resolver's in-memory backoff and strike for a host) and Strike (new FreshStrike, the in-memory two-strike rule for a new name's fresh failure); drops LookupCNAME from the resolver; reads nothing new, no file, path, env var or command input added (#724) data-literal@469,data-literal@510 6e3e65fe420646b3321e0c309d2e821ce99cb58071aee2c47ab15ef067c24ce8
internal/domains/freshdns.go FreshResolver.query legacy accepted-legacy accepted-legacy;rev3=census-ruling-no-negative-prime-724;basis=new: the body of the old FreshResolver.exchange moved here unchanged except that it no longer checks the authority and truncation flags (exchange still does, for SOA verification; ask checks truncation and reads a non-authoritative reply only as a referral down the name's path). The file:Read is the same conn.Read of one UDP reply from a nameserver that passed publicNameserver, with the same exact question matching; no file, path or new input (#724) file:Read@1214 f91e835feced403f06169f7fbec3816dbf5b4b53177915197b61a1ee40bff8ba
-internal/domains/reconcile.go StampHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address "pointing", other "elsewhere", authoritative not-found ""), falling back to the cached lookup on a fresh error or past the budget; a previously "pointing" name keeps cached-first plus the upgrade-only fresh look, so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) registry:Alias@3172,registry:Alias@3700,registry:Alias@3790,registry:Alias@4224,registry:Alias@4288,registry:Alias@4376,registry:DNSStatus@3053,registry:DNSStatus@3181,registry:DNSStatus@3349,registry:DNSStatus@3624,registry:Host@3044,registry:Host@3421,registry:Host@3505,registry:Host@3993,registry:Host@4052,registry:Host@4134,whole:Route@199,whole:Route@236,whole:Route@2871,whole:Route@2984,whole:Route@3277,whole:Route@3947,whole:RouteAlias@2917,whole:RouteAlias@3111,whole:RouteAlias@3551,whole:RouteAlias@4177,whole:RouteAlias@780 8a40c0797f5e0dd2598359a130eeea4e7770fc4208d1b20d501143dd9925549f
+internal/domains/reconcile.go StampHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address "pointing", other "elsewhere", authoritative not-found ""), falling back to the cached lookup on a fresh error or past the budget; a previously "pointing" name keeps cached-first plus the upgrade-only fresh look, so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; a new name's first fresh failure in a row is held (stamp and check time untouched, the resolver forgives it so the next pass asks fresh again) and only the second takes the cached look; a fresh "exists, no A record" takes the cached look; new names are ordered never-checked first, and lookups answered from the backoff do not count against the budget; a published name's upgrade look uses ResolveUpgrade, which may fall back to the nearest zone; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) registry:Alias@3189,registry:Alias@3775,registry:Alias@3865,registry:Alias@4299,registry:Alias@4363,registry:Alias@4451,registry:DNSCheckedAt@3067,registry:DNSCheckedAt@3211,registry:DNSStatus@3053,registry:DNSStatus@3198,registry:DNSStatus@3403,registry:DNSStatus@3699,registry:Host@3044,registry:Host@3475,registry:Host@3559,registry:Host@4068,registry:Host@4127,registry:Host@4209,whole:Route@199,whole:Route@236,whole:Route@2871,whole:Route@2984,whole:Route@3310,whole:Route@4022,whole:RouteAlias@2917,whole:RouteAlias@3128,whole:RouteAlias@3605,whole:RouteAlias@4252,whole:RouteAlias@780 a1345c0d3076a9cd7ff17bc95fed36df451b5391dce43eb77d8b5151a6d5fb13
@remove internal/domains/freshdns.go FreshResolver.exchange
@removed internal/domains/freshdns.go FreshResolver.exchange H3 census-ruling-no-negative-prime-724;basis=quiet: now a wrapper over query that keeps the authority and truncation checks; its socket read moved to FreshResolver.query (#724)
-@coverage internal/domains 5d57b36e2d02560f18b9ab1df42f88f8f1d58e7c46d233af7ac8f669bd448321
-@coverage internal/host 401b918c04add12a03702679ba47fdf8cbad5139586ab505aef86b029149855b
+@coverage internal/domains 9517c8523e923180fa3e6af4cdb74ccea68d6cafb161abbe33dc2ef3d9dad782
+@coverage internal/host 010f9023d5ea24fab9b0c0a2d6320e1cd5a22272eae09d5effe30382fd41a4d7