carlos / platform Public

Custom-domain certs wait out the customer's negative-DNS TTL Issue open

Claimed by claude~paul@keymail.dev 3 weeks ago

What happens

A customer attaches a custom domain, then adds the CNAME that carlos domains attach told them to add. The cert can then take up to the domain's negative-cache TTL (the SOA minimum) plus a few minutes to appear. Seen on the flagship on 2026-11-09: 38 minutes from attach to a working cert, on a zone whose SOA minimum is 1800 s. The console says nothing about why.

Why

The home box stamps dns_status with net.DefaultResolver.LookupHost (internal/host/agent.go:4074), which goes to systemd-resolved's stub at 127.0.0.53. That resolver caches negative answers.

  1. Attach writes the claim and wakes the home box. The box looks the name up straight away, before the customer has had time to add the CNAME, and gets NXDOMAIN. resolved caches that for the zone's SOA minimum.
  2. Every StampHealth tick reads the cached NXDOMAIN, so the alias stays at dns_status "". The edges-file publisher withholds it (internal/host/edgesfile.go:769, "alias … not published — dns_status \"\"").
  3. The issuer is another box, so it never learns the name exists. The home box answers every handshake with acme: not available here.
  4. When the cache entry expires, the next tick stamps pointing. The alias is published and the issuer warms the cert. In the 2026-11-09 case that took about 2.5 minutes (published 11:55:54Z, cert served 11:58:29Z).

On the box, during the wait: resolvectl query shop.example.com said "Name not found". resolvectl query --cache=no shop.example.com returned the right answer.

Following the printed instructions in order (attach, then add the record) triggers this every time. So the expected wait is "the customer's SOA minimum", which is commonly 30 min to an hour and sometimes a day, not "a few minutes".

Fix direction (not designed)

  • Make the health stamp's lookup skip the stub's cache. Options: ask the VPC resolver directly, or ask the zone's authoritative servers. Either way, check whether the VPC resolver also caches negatives.
  • Or stamp from an uncached lookup only while a name is still un-pointing, keeping the cached path for steady state.
  • Either way, the console/CLI status for a name stuck at dns_status "" could say "waiting for DNS to point here" rather than leaving the customer to wait on SSL.

Target: a cert within a few minutes of the record going live, whatever the customer's zone TTLs are.

Fixed on main as f3a9531 (squash of dns-fresh-lookup-724). The per-box DNS health stamp now takes an uncached, zone-verified look at a non-apps-domain name the cache reads as not pointing, and can only upgrade it to "pointing". Astra R1 NOT READY, R2 READY AFTER FIXES, fix check confirmed; census on #280.

Not released. Handed to the agent manager (8a3d302) for a version and the dev-first roll, then a timed attach (expect about 5 minutes from the record going live).

Follow-up from the dev timed attach (evidence /home/paulca/.cache/dnstest-724/log.md on docs-t1).

f3a9531 works for publication: on dev v0.34.35 the alias reached the edges file 3m20s after the CNAME went in, while the home box's resolver still cached NXDOMAIN (1 h negative TTL test zone).

The cert issuer has a second cached-resolver gate: internal/edge/certwarm.go dnsGate uses warmResolver (cached net.DefaultResolver) before placing a new order. If the issuer has a cached miss for the name (the issuer is also the home box, a single-box deployment, or any earlier lookup), the order waits out the same negative TTL. On dev it held the cert because the issuer's cache had been primed by a manual check.

Proposed fix: when the cached answer does not point here, ask the same FreshResolver (zone-verified, authoritative) and open the gate only if every fresh address is in the edge set. Bounded like the stamp pass. Awaiting Paul's go; would ride v0.34.36.

The cert-warm follow-up (warm-gate-fresh-724) is CUT after three Astra rounds, by agreement with Paul. What remains open:

  • Fixed and shipping (f3a9531, v0.34.35): publication. A custom hostname is published about 3 minutes after its record goes live, whatever the home box's resolver has cached.
  • Not fixed: when the cert issuer itself has a cached NXDOMAIN for the name (the app is homed on the issuer box, a single-box deployment, or anything looked the name up before the record existed), the cert waits for that cache entry to expire.

What a future attempt has to get right, from the three rounds: every address family must be known (an unresolved CNAME AAAA fails closed); fresh work needs a hard per-probe and per-pass bound and never runs for abandoned names; a probe's fresh "points here" must be consumed by the issuing pass inside its validity period (multi-host test with slow cached lookups); and retained evidence must be re-checked against the current edge set so an empty edge set still refuses. A simpler direction worth weighing first: have the issuer bypass only the local systemd-resolved cache for names in their first hour, instead of a second gate.

New attempt for the issuer side, approved by Paul 2026-11-09: branch issuer-fresh-gate-724.

Two corrections to the notes above. First, bypassing only the local systemd-resolved cache is not enough: the VPC resolver behind it caches the same negative answer for the same SOA minimum, and the home box's attach-time lookup already went through it. The issuer has to ask the zone's own nameservers, as the stamp pass does. Second, every finding in the last two review rounds was about carrying a fresh result from the probe to the pass. This attempt carries nothing: the gate takes a fresh, zone-verified look only when the cached lookup returns no addresses at all, the probe and the pass each take their own look, successes are never rate limited per name, and the fresh looks are plain counts scoped to one pass (10) or one probe (4), for names in their first hour on the miss schedule only. Empty edge set still refuses first; a cached answer pointing elsewhere never triggers a fresh look.

Opus builds, Astra reviews (three rounds at most), census on #280, then a dev timed attach with the app homed on the issuer and no manual resolver probes.

Second issuer-side attempt, branch issuer-fresh-gate-724 (tip 473193f2), is CUT after three Astra rounds, per the round limit.

What held up through the rounds and is worth keeping for a future attempt: nothing retained between probe and pass (each takes its own fresh look through the same gate); plain per-call counts (10 per pass, 4 per probe) with backed-off answers handed back; first-hour names only; fresh-backed probe successes gated first in the pass it triggers; the empty edge set refusing before any lookup; a cached positive answer deciding alone. Astra found no bound, loop, wake or fail-open problem in any of those after round 1.

What cut it, all on the CNAME path, which is the common customer setup (CNAME at edge.<apps-domain>):

  • R1: the out-of-zone target was resolved with the cached resolver, which hides a failed AAAA query behind a successful A (Go's default StrictErrors=false).
  • R2: per-family cached lookups of the target cannot tell NODATA from NXDOMAIN; an AAAA reply ending in an out-of-zone CNAME was dropped.
  • R3: accepting a target by NAME (under the apps domain or a wildcard parent) does not prove its addresses are all edges: wildcard parents include delegated customer zones, and steering manages only A records on edge.<apps-domain>, so a foreign AAAA there would survive. Separately, a CNAME inside the customer zone into a delegated child can be answered by the parent with its cached target records after an authoritative CNAME, so a lexical "in zone" test on the terminal owner is not authority.

The narrowest direction left, not tried: accept a Target only when it is exactly edge.<apps-domain> (the one name the console advertises) and resolve THAT name with the cached resolver built with StrictErrors=true, applying the usual all-addresses-are-edges rule to the result. Our own name is never negatively cached, both families are then positively known or the lookup errors, and a stale cached answer only refuses. For in-zone addresses, accept only when the terminal owner is the queried name itself, or verify each CNAME hop's zone the way the first hop is verified. Needs Paul's go, as a fresh round budget.

Fixed and shipping meanwhile (f3a9531, v0.34.35): publication within minutes of the record going live. Still open: the cert waits out the issuer's own cached miss when the app is homed on the issuer box or the deployment has one box.

Third direction, approved by Paul 2026-11-09, branch no-negative-prime-724: leave the issuer's gate alone and stop OUR boxes planting the negative cache entry in the first place.

Why it is enough: the issuer only learns a name after publication. If nobody in its VPC queried the name before the record existed, its first cached lookup is a clean miss and the cert follows in a minute or two. The only thing of ours that queries the name early is the home box's health stamp at attach time (cached dnsStatus), plus the fresh resolver's own zone discovery, which sends a cached LookupCNAME and LookupNS for the name itself (an NXDOMAIN is cached for the name, every type, RFC 2308).

The change, confined to internal/domains and the stamp path Astra already reviewed twice: (A) FreshResolver finds the zone from the parent upward and asks about the name itself only last, when no parent zone answered, which is the apex case where the name exists already; (B) section 4 takes the fresh look FIRST for names whose previous stamp is not "pointing", trusting a definitive answer (addresses or authoritative not-found), and falls back to the cached lookup only on a fresh error or past the per-pass budget. Names already pointing keep the cached-first path, so the fresh path still cannot unpublish anything.

Expected result: about 5 minutes from the record going live on every box, including single-box deployments and apps homed on the issuer. Opus builds, Astra reviews (three rounds max), then a dev timed attach with the app homed on the issuer and no manual probes.

Branch no-negative-prime-724 (tip 2828ac11) is CUT, by Paul's rule for the bounded fix round: a new P1 from either reviewer cuts. Reviewers: Astra (three rounds plus the delta) and Fable 5.2 via the Claude CLI (round 3 and the delta).

What held, and is the shape a future attempt should start from: the stamp pass takes the fresh look first for names not yet pointing and trusts a definitive authoritative answer; names already pointing keep the cached-first path plus the upgrade re-check, serviced before new names in one shared budget; the fresh resolver walks top-down from the ICANN registrable domain (publicsuffix, climbing past private and wildcard rules) following referrals with every zone verified by its own SOA, so no cached query carries the hostname or any label between it and the registrable domain; glue only inside the child zone and public-only; a failure recorded while a name was unpublished is cleared when it reaches "pointing"; a published name whose top-down walk fails falls back to the nearest-parent zone (main's behaviour) so deep delegations stay published. Both reviewers found the security properties, bounds and the "fresh never unpublishes" rule intact on the common path.

What cut it, all from the last delta, with the fix each reviewer named:

  • Fable P1: an authoritative NODATA for A (a TXT-only name, an empty non-terminal under _acme-challenge, or a zone using compact denial) made a NEW name take the cached look, which plants a per-type negative entry for A/AAAA, the very thing #724 is about. Fix: on NODATA for A ask the same verified server for AAAA, classify, and stamp "" with no cached query when both are NODATA; require the zone's SOA in the authority section before calling a reply NODATA (Astra's P2 is the same SOA point).
  • Astra P1: the on-path nameserver skip (added so a stale NS host on the hostname's path is not looked up through the cache) also ran for published names, so a zone whose only nameserver host is an intermediate label of the hostname got zero servers and the upgrade failed, unpublishing it. Fix: apply the skip to new names only; the upgrade path may use cached address discovery.
  • Astra P2: the strike map (two failures before the cached fallback) evicts arbitrarily at 4096 entries, so a pending first strike can be forgotten; keep pending strikes through their second attempt. Fable P2: the upgrade fallback shares the Timeout the top-down walk already spent; give it its own share or try it first. Fable P3s: dedupe a host present as both route and alias; do not run the on-path skip inside the nearest fallback; the fallback repeats the registrable zone for a name directly under it.

Each round's fix introduced the next round's P1, which is what the round limit is for. The branch is complete enough that a future attempt should start by applying the list above to it, then run one fresh review with both reviewers before any further change.

Shipping meanwhile (f3a9531, v0.34.35): publication within minutes of the record going live. Still open: the cert waits out the issuer's own cached miss when the app is homed on the issuer box or the deployment has one box.

MERGED as 89f6d8ed (branch no-negative-prime-724, tip 821db123; GitHub mirror fast-forwarded). Not released.

How it got there after the cut above: Paul had Fable 5.2 (via the Claude CLI) apply the whole reviewers' checklist in one commit (259abef0), Astra found two narrow P1s (a co-hosted parent/child answering a TXT-only name with the child's SOA; a published name with a non-zone label under a deep delegation), Fable 5.2 fixed those plus the P2s (a0a112d8), and Astra's second pass was READY with no findings. Census approved by Astra on #280. CI passed on the third run; the two failures before it were unrelated flakes in internal/activator and internal/edge (see #772, #785, #786).

What ships: the home box's health stamp asks the customer zone's own nameservers first for any name not yet pointing, walking top-down from the ICANN registrable domain and following referrals with every zone verified by its SOA, so no box of ours plants a negative entry for the name or any label on its path. The cert issuer's gate is unchanged; it simply gets a clean miss on its first lookup after publication. Expected: about 5 minutes from the record going live on every box, single-box deployments and apps homed on the issuer included.

Next: a release and a dev-first roll (agent manager 8a3d302), then a timed attach on dev with the app homed on the issuer box and no manual resolver probes, expecting a cert within about 5 minutes of the CNAME. Then flagship.

Dev timed attach on v0.34.37 (89f6d8ed), 2026-11-10, app homed on the ISSUER box (leo, housekeeper lease holder), no manual resolver probes, evidence ~/.cache/dnstest-724/log2.md on docs-t1. Test zone: a Route53 sub-zone with SOA minimum 3600 and SOA TTL 900, so a planted negative entry lives 15 minutes (RFC 2308: min of the two).

  • T0 attach 01:33:21Z; T1 CNAME 01:33:38Z.
  • Publication: alias in leo's edges file 01:38:43Z, 5m05s after the CNAME. PASS (the stamp pass cadence; the fresh look worked, the home box never queried the name through its cache).
  • Cert: "edge: cert warmed for" 01:53:31Z, 19m53s after the CNAME and 14m48s after publication. NOT the 5 minutes expected.

Why: the cert warm's set on the issuer (internal/edge/certwarm.go warmSet) takes this box's OWN hosts from the edge's local route table (e.current()), which gains the alias at attach, before any DNS stamp; the published-hosts fold (homeMap.ServedHosts) excludes the box's own rows, which is why warmSet unions e.current(). So at 01:33:2x the route reload nudged the warm, whose dnsGate ran the cached lookup for the brand-new name, planting the 15-minute negative entry in leo's stub and the VPC resolver. The probe schedule then found it clear at the 5-minute probe after expiry (01:53:3x). The gate logs nothing on a miss, so the journal shows only the two lines above, but the arithmetic fits: 01:33:2x + 900 s = 01:48:2x, next five-minute probe 01:53:2x, cert 01:53:31.

So the stamp path no longer primes (the first half of this fix is confirmed on the box that matters), and one source remains: the issuer's own warm set. Fix direction: the warm set must take this box's own CUSTOM hosts only once they are published in its own edges file (which withholds an alias until dns_status is "pointing"), i.e. the home map keeps this box's own published host set beside the fold, and warmSet unions that instead of e.current() for non-apps-domain names. Then the issuer's first lookup of a new alias happens after publication, on a clean cache. v0.34.37 is strictly better than v0.34.36 and can go to flagship as planned; the follow-up branch is warm-set-published-724.

MERGED as 0b6fb0c9 (branch warm-set-published-724, tip 61546731; GitHub mirror fast-forwarded). Not released.

What ships: the edges file carries an additive dns_pointing mark per custom host; the home map exposes this box's own published pointing names; the issuer's cert warm set reads publication instead of the local route table (regional names excepted), so the issuer's first lookup of a new custom name happens after its home box published it pointing, on a clean cache. A name published not pointing is neither ordered nor re-armed by the warm (its cached cert keeps serving and re-arms on a handshake; aliases on other boxes already behaved this way). DNS-miss entries are retired when a name leaves the set; the pass reads the set only after the issuer gate; failure records are kept while any box publishes the exact name. Built by Fable 5.2 via the Claude CLI; Astra reviewed in five rounds (the cached-certificate renewal exemption was tried and removed after Astra showed autocert can mint behind it); census approved on #280. CI passed on the second run (activator flake #785 family on the first).

With 89f6d8ed (stamp path) and this, no box of ours queries a new custom hostname through a cache before its record exists. Expected after the next release: about 5 minutes from the record going live to a cert, on every box, including the app's home box being the issuer. Next: release + dev-first roll via the agent manager, then a repeat of the dev timed attach on the issuer box (same recipe, log2.md) expecting the cert within about a minute of publication.

Dev timed attach on v0.34.40 (89f6d8ed + 0b6fb0c9), 2026-11-10, app homed on the ISSUER box (leo), CNAME after attach, no manual resolver probes, same test zone shape (SOA TTL 900, minimum 3600, so a planted negative entry would have lived 15 minutes). Evidence ~/.cache/dnstest-724/log3.md on docs-t1.

  • T0 attach 13:45:00Z; T1 CNAME 13:45:16Z.
  • Publication: the warm saw the name at 13:52:04Z (edges file poll 13:52:22Z), 6m48s after the CNAME: the stamp pass cadence.
  • Gate: passed on the first look. "cert warm for t3.dnstest.carlosframework.com waits 45s for the other edges to learn the name" at 13:52:04Z, "cert warmed for" at 13:52:56Z, https 200 at 13:53:11Z.

Cert 52 s after publication (v0.34.37: 14m48s), 7m40s after the CNAME (v0.34.37: 19m53s; flagship before #724: 38 min). PASS. What remains of the wait is the stamp pass cadence (about 5 to 7 minutes), which is a separate question from this issue. v0.34.40 can go to flagship.