carlos / platform Public

edge: cert warm DNS gate takes the fresh look too (#724)

The dev timed attach for #724 showed the alias published 3m20s after
the CNAME, but the issuer did not order: its cert warm DNS gate asks the
cached system resolver, which held NXDOMAIN for the name. The issuer has
a cached miss whenever it is also the home box, the deployment has one
box, or anything looked the name up before the record existed.

When the cached answer does not open the gate, the gate now asks the
zone-verified FreshResolver from f3a9531 and opens only if every fresh
address is an edge: the same all-must-match rule, so the shared ACME
validation budget is protected as before. Its failure backoff is 6 h,
because the warm revisits a pending name hourly forever.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Human

Prompt

yes (build the cert warm gate follow-up for #724)

From this commit's own message. The prompt ledger has no entries for it — which is what a squashed, rebased or amended commit looks like, and what every commit looks like in a repo without a ledger.

Summary

dnsGateWithFresh: uncached, zone-verified second look in the cert warm gate; all fresh addresses must be edges.
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev a66bf836df3f4615fa55643dc2e72c3d5cecd701 parent fd6d39e
6 files changed, +130 −8
  • docs/superpowers/notes/census-proposal-warm-gate-fresh-724.md +19 −0
  • internal/edge/certwarm.go +37 −7
  • internal/edge/certwarm_fresh_test.go +67 −0
  • internal/edge/edge.go +1 −1
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-warm-gate-fresh-724.tsv +5 −0

CI cancelled — superseded by a newer push — run details

diff --git a/docs/superpowers/notes/census-proposal-warm-gate-fresh-724.md b/docs/superpowers/notes/census-proposal-warm-gate-fresh-724.md
new file mode 100644
index 000000000..0ccbeb2af
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-warm-gate-fresh-724.md
@@ -0,0 +1,19 @@
+# Census approval: warm-gate-fresh-724
+
+Ruling `census-ruling-warm-gate-fresh-724`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/edge/edge.go` `RunWithActivatorReady` | body | unchanged (5) | the cert warm DNS gate is built with dnsGateWithFresh(warmResolver, warmFresh.Resolve, ...): when the cached answer does not point here, the zone-verified FreshResolver from #724 is asked and the gate opens only if every fresh address is an edge (#724 follow-up) |
+
+Envelopes re-pinned: `internal/edge`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/edge/edge.go` `RunWithActivatorReady`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-certwarm-wake;basis=registers the cert warm's nudge on OnReload and on the home map's new served-hosts wake (#386); nudge only sends on a buffered channel; no read added, same 5 sites;rev3=census-ruling-edge-roll-blip;basis=the :80/:443 (and dev) listeners are bound on the calling goroutine with net.Listen via listen()/listenAddr (same empty-address defaults as ListenAndServe) before the serve goroutines, which now call Serve/ServeTLS on them, and one log line names the bound addresses; no read added, same 5 sites;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): the inline home-map arming (newHomeMap, one boot Refresh, Store, run) moves unchanged into the new Edge.ArmHomeMap and is called here as e.ArmHomeMap(); same refresh, same timeout, same order. The reads are moved, none added.;rev3=census-ruling-agent-start-demo-1;basis=Logs the combined explicit wildcard parents through demoWildcardDomains; no new watcher or read loop.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: invoke the local admission Close before HTTP/HTTPS draining and door shutdown in both dev and normal listeners. Preserve merged main's startup behavior and its census basis; the same five read sites, no new reads.;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: defer stopping and joining the edge's replica jobs at shutdown. Existing five direct read sites unchanged; no new reader or authority.;rev3=census-ruling-region-ha-p3b;basis=Wrap dev, HTTP and HTTPS listeners through ConfigureGroupHairpin before serving. Indirectly read protected root boot identity and group-ingress.json; kernel local/peer addresses mark local ingress, never HTTP headers. Agent edge uses verified public source for accounting; direct read sites unchanged and absent marker keeps original listeners. CI fix removes interface enumeration: local peer must match snapshot primary IPv4, an ingress IPv4 installed locally by root, or loopback; kernel destination must still be an ingress EIP on port 80/443. Merge 45cebde4 retains deferred stopReplicaProbes alongside group listener wrapping and shutdown admission closure.;rev3=census-ruling-demo-api-site-route;basis=Change the startup failure context from load routes to initialize because origin validation now runs during construction. Existing five read sites unchanged; no new read or runtime authority.;rev3=census-ruling-region-ha-graceful-terminate-t2;basis=Invoke the agent shutdown timestamp hook synchronously at SIGTERM/SIGINT receipt before closing admission in dev and TLS paths. No read added.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 5: registers the https and http servers with the connection drain (conns.serve) so a drain can close idle keep-alive connections; no read added
+
+Seal: `250e3ba91e1bc5fcd6be5cc2bafce4c7d6645d2d2f0c080913b99f01b1d19129` → `427eb007fdb787d2a98998bbe14b1cf6ddb65f76a37b9cba7ee26747a2391483`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-warm-gate-fresh-724.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/edge/certwarm.go b/internal/edge/certwarm.go
index 789903d3e..4246f2afb 100644
--- a/internal/edge/certwarm.go
+++ b/internal/edge/certwarm.go
@@ -38,6 +38,7 @@ import (
"golang.org/x/crypto/acme"
"github.com/carlosframework/platform/internal/certwarm"
+ "github.com/carlosframework/platform/internal/domains"
"github.com/carlosframework/platform/internal/release"
)
@@ -774,6 +775,19 @@ func dnsGate(resolve func(string) ([]string, error), edgeIPs func() []string) fu
}
func dnsGateAt(resolve func(string) ([]string, error), edgeIPs func() []string, now func() time.Time) func(string) bool {
+ return dnsGateWithFresh(resolve, nil, edgeIPs, now)
+}
+
+// dnsGateWithFresh is dnsGate with a second, uncached look (#724). The
+// issuer's own resolver can hold a "no such name" for a customer hostname
+// for the zone's SOA minimum: the issuer is also the name's home box, the
+// deployment has one box, or something looked the name up before the
+// customer added the record. When the cached answer does not open the gate,
+// fresh asks the zone's own nameservers, and the gate opens only if every
+// fresh address is in the edge set: the same all-must-match rule as the
+// cached answer, so the shared validation budget is protected as before.
+// fresh nil is the cached gate alone.
+func dnsGateWithFresh(resolve, fresh func(string) ([]string, error), edgeIPs func() []string, now func() time.Time) func(string) bool {
var (
mu sync.Mutex
cached map[string]bool
@@ -801,19 +815,35 @@ func dnsGateAt(resolve func(string) ([]string, error), edgeIPs func() []string,
if len(set) == 0 {
return false
}
- ips, err := resolve(host)
- if err != nil || len(ips) == 0 {
- return false
- }
- for _, ip := range ips {
- if !set[ip] {
+ allOurs := func(ips []string, err error) bool {
+ if err != nil || len(ips) == 0 {
return false
}
+ for _, ip := range ips {
+ if !set[ip] {
+ return false
+ }
+ }
+ return true
}
- return true
+ if allOurs(resolve(host)) {
+ return true
+ }
+ return fresh != nil && allOurs(fresh(host))
}
}
+// warmFresh is the DNS gate's uncached second look (#724), with its own
+// failure backoff. The backoff is long because the warm comes back to a
+// pending name hourly forever: a name whose nameservers are dead costs one
+// timeout per six hours here, and the cached look still runs every time.
+var warmFresh = &domains.FreshResolver{
+ LookupNS: net.DefaultResolver.LookupNS,
+ LookupHost: net.DefaultResolver.LookupHost,
+ LookupCNAME: net.DefaultResolver.LookupCNAME,
+ Backoff: 6 * time.Hour,
+}
+
// warmResolver is the DNS gate's lookup: the system resolver, bounded so a
// hung one costs this host its turn in the pass and not the pass itself.
func warmResolver(host string) ([]string, error) {
diff --git a/internal/edge/certwarm_fresh_test.go b/internal/edge/certwarm_fresh_test.go
new file mode 100644
index 000000000..db1d9817f
--- /dev/null
+++ b/internal/edge/certwarm_fresh_test.go
@@ -0,0 +1,67 @@
+package edge
+
+import (
+ "errors"
+ "net"
+ "testing"
+ "time"
+)
+
+// #724 follow-up: the issuer's own resolver can hold a "no such name" for
+// a customer hostname (it is also the home box, a single-box deployment, or
+// it looked the name up before the record existed). The gate then asks the
+// zone's own nameservers, uncached, and opens only when every fresh address
+// is one of ours: the same all-must-match rule, so the shared ACME
+// validation budget is protected exactly as before.
+func TestDNSGateAsksFreshWhenTheCacheSaysNo(t *testing.T) {
+ edges := func() []string { return []string{"203.0.113.7", "198.51.100.9"} }
+ nx := func(string) ([]string, error) { return nil, &net.DNSError{Err: "no such host", IsNotFound: true} }
+ for name, tc := range map[string]struct {
+ cached func(string) ([]string, error)
+ fresh []string
+ ferr error
+ want bool
+ asked bool
+ }{
+ "cached miss, fresh ours": {cached: nx, fresh: []string{"203.0.113.7"}, want: true, asked: true},
+ "cached miss, fresh partly elsewhere": {cached: nx, fresh: []string{"203.0.113.7", "192.0.2.1"}, want: false, asked: true},
+ "cached miss, fresh elsewhere": {cached: nx, fresh: []string{"192.0.2.1"}, want: false, asked: true},
+ "cached miss, fresh empty": {cached: nx, fresh: nil, want: false, asked: true},
+ "cached miss, fresh failed": {cached: nx, ferr: errors.New("timeout"), want: false, asked: true},
+ "cached elsewhere, fresh ours": {cached: func(string) ([]string, error) { return []string{"192.0.2.1"}, nil },
+ fresh: []string{"198.51.100.9"}, want: true, asked: true},
+ "cached ours": {cached: func(string) ([]string, error) { return []string{"203.0.113.7"}, nil },
+ fresh: []string{"192.0.2.1"}, want: true, asked: false},
+ } {
+ asked := false
+ fresh := func(string) ([]string, error) { asked = true; return tc.fresh, tc.ferr }
+ gate := dnsGateWithFresh(tc.cached, fresh, edges, time.Now)
+ if got := gate("www.customer.test"); got != tc.want {
+ t.Errorf("%s: gate = %v, want %v", name, got, tc.want)
+ }
+ if asked != tc.asked {
+ t.Errorf("%s: fresh asked = %v, want %v", name, asked, tc.asked)
+ }
+ }
+}
+
+// An empty edge set still fails closed, before anyone is asked anything.
+func TestDNSGateWithFreshFailsClosedOnAnEmptyEdgeSet(t *testing.T) {
+ asked := false
+ gate := dnsGateWithFresh(
+ func(string) ([]string, error) { return nil, errors.New("nx") },
+ func(string) ([]string, error) { asked = true; return []string{"203.0.113.7"}, nil },
+ func() []string { return nil },
+ time.Now,
+ )
+ if gate("www.customer.test") || asked {
+ t.Fatalf("empty edge set: gate opened or fresh asked (asked=%v)", asked)
+ }
+}
+
+// The production gate is built with the fresh lookup wired in.
+func TestWarmDNSGateWiresTheFreshLookup(t *testing.T) {
+ if warmFresh == nil || warmFresh.LookupNS == nil || warmFresh.LookupHost == nil || warmFresh.LookupCNAME == nil {
+ t.Fatal("warmFresh is not wired to the system resolver")
+ }
+}
diff --git a/internal/edge/edge.go b/internal/edge/edge.go
index 0d012d33c..ae06dcc45 100644
--- a/internal/edge/edge.go
+++ b/internal/edge/edge.go
@@ -4903,7 +4903,7 @@ func RunWithActivatorReady(args []string, act Activator, cache *Cache, ready fun
warm := newCertWarm(
func() []string { return e.warmSet(appsDomain, parents) },
perHostCert,
- dnsGate(warmResolver, edgeIPs),
+ dnsGateWithFresh(warmResolver, warmFresh.Resolve, edgeIPs, time.Now),
e.issuerGate,
store,
)
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 51af650d7..74eb69a60 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -140,3 +140,4 @@ plan14-root-reads-gvisor-update-dirs.tsv 1f1b2fdb569b7be42e75e10d1943d7e51270829
plan14-root-reads-region-ha-held-build.tsv beb085e4c6cdb3d430d12a8dc3c93f25cc3faf1aa7d62be37698ff9c9c82ecce
plan14-root-reads-fixedbox-health-alarms.tsv 0f7153571df8c1b4b50c31f57efcfdf60c71a12c80fd935fb3ea202fa0201dd5
plan14-root-reads-fixed-host-ignore-user-data.tsv 250e3ba91e1bc5fcd6be5cc2bafce4c7d6645d2d2f0c080913b99f01b1d19129
+plan14-root-reads-warm-gate-fresh-724.tsv 427eb007fdb787d2a98998bbe14b1cf6ddb65f76a37b9cba7ee26747a2391483
diff --git a/internal/provision/testdata/plan14-root-reads-warm-gate-fresh-724.tsv b/internal/provision/testdata/plan14-root-reads-warm-gate-fresh-724.tsv
new file mode 100644
index 000000000..0407c81c6
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-warm-gate-fresh-724.tsv
@@ -0,0 +1,5 @@
+# Census overlay warm-gate-fresh-724, written by census-propose (#369). census-ruling-warm-gate-fresh-724, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-warm-gate-fresh-724.md.
+# 1 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@legacy dee655330d2b73bba900a0eeff07a26886ce8fedb880cdf039f36ab1d8501ae3 internal/edge/edge.go RunWithActivatorReady legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-certwarm-wake;basis=registers the cert warm's nudge on OnReload and on the home map's new served-hosts wake (#386); nudge only sends on a buffered channel; no read added, same 5 sites;rev3=census-ruling-edge-roll-blip;basis=the :80/:443 (and dev) listeners are bound on the calling goroutine with net.Listen via listen()/listenAddr (same empty-address defaults as ListenAndServe) before the serve goroutines, which now call Serve/ServeTLS on them, and one log line names the bound addresses; no read added, same 5 sites;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): the inline home-map arming (newHomeMap, one boot Refresh, Store, run) moves unchanged into the new Edge.ArmHomeMap and is called here as e.ArmHomeMap(); same refresh, same timeout, same order. The reads are moved, none added.;rev3=census-ruling-agent-start-demo-1;basis=Logs the combined explicit wildcard parents through demoWildcardDomains; no new watcher or read loop.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: invoke the local admission Close before HTTP/HTTPS draining and door shutdown in both dev and normal listeners. Preserve merged main's startup behavior and its census basis; the same five read sites, no new reads.;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: defer stopping and joining the edge's replica jobs at shutdown. Existing five direct read sites unchanged; no new reader or authority.;rev3=census-ruling-region-ha-p3b;basis=Wrap dev, HTTP and HTTPS listeners through ConfigureGroupHairpin before serving. Indirectly read protected root boot identity and group-ingress.json; kernel local/peer addresses mark local ingress, never HTTP headers. Agent edge uses verified public source for accounting; direct read sites unchanged and absent marker keeps original listeners. CI fix removes interface enumeration: local peer must match snapshot primary IPv4, an ingress IPv4 installed locally by root, or loopback; kernel destination must still be an ingress EIP on port 80/443. Merge 45cebde4 retains deferred stopReplicaProbes alongside group listener wrapping and shutdown admission closure.;rev3=census-ruling-demo-api-site-route;basis=Change the startup failure context from load routes to initialize because origin validation now runs during construction. Existing five read sites unchanged; no new read or runtime authority.;rev3=census-ruling-region-ha-graceful-terminate-t2;basis=Invoke the agent shutdown timestamp hook synchronously at SIGTERM/SIGINT receipt before closing admission in dev and TLS paths. No read added.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 5: registers the https and http servers with the connection drain (conns.serve) so a drain can close idle keep-alive connections; no read added;rev3=census-ruling-warm-gate-fresh-724;basis=the cert warm DNS gate is built with dnsGateWithFresh(warmResolver, warmFresh.Resolve, ...): when the cached answer does not point here, the zone-verified FreshResolver from #724 is asked and the gate opens only if every fresh address is an edge (#724 follow-up) data-literal@129,data-literal@148,data-literal@284,data-literal@417,file:Open@1013 de02404e292762ef22540b43a1fefbcd1b3dedbcfa60d16646f652ee1dcfe4c0
+internal/edge/edge.go RunWithActivatorReady legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-certwarm-wake;basis=registers the cert warm's nudge on OnReload and on the home map's new served-hosts wake (#386); nudge only sends on a buffered channel; no read added, same 5 sites;rev3=census-ruling-edge-roll-blip;basis=the :80/:443 (and dev) listeners are bound on the calling goroutine with net.Listen via listen()/listenAddr (same empty-address defaults as ListenAndServe) before the serve goroutines, which now call Serve/ServeTLS on them, and one log line names the bound addresses; no read added, same 5 sites;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): the inline home-map arming (newHomeMap, one boot Refresh, Store, run) moves unchanged into the new Edge.ArmHomeMap and is called here as e.ArmHomeMap(); same refresh, same timeout, same order. The reads are moved, none added.;rev3=census-ruling-agent-start-demo-1;basis=Logs the combined explicit wildcard parents through demoWildcardDomains; no new watcher or read loop.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: invoke the local admission Close before HTTP/HTTPS draining and door shutdown in both dev and normal listeners. Preserve merged main's startup behavior and its census basis; the same five read sites, no new reads.;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: defer stopping and joining the edge's replica jobs at shutdown. Existing five direct read sites unchanged; no new reader or authority.;rev3=census-ruling-region-ha-p3b;basis=Wrap dev, HTTP and HTTPS listeners through ConfigureGroupHairpin before serving. Indirectly read protected root boot identity and group-ingress.json; kernel local/peer addresses mark local ingress, never HTTP headers. Agent edge uses verified public source for accounting; direct read sites unchanged and absent marker keeps original listeners. CI fix removes interface enumeration: local peer must match snapshot primary IPv4, an ingress IPv4 installed locally by root, or loopback; kernel destination must still be an ingress EIP on port 80/443. Merge 45cebde4 retains deferred stopReplicaProbes alongside group listener wrapping and shutdown admission closure.;rev3=census-ruling-demo-api-site-route;basis=Change the startup failure context from load routes to initialize because origin validation now runs during construction. Existing five read sites unchanged; no new read or runtime authority.;rev3=census-ruling-region-ha-graceful-terminate-t2;basis=Invoke the agent shutdown timestamp hook synchronously at SIGTERM/SIGINT receipt before closing admission in dev and TLS paths. No read added.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 5: registers the https and http servers with the connection drain (conns.serve) so a drain can close idle keep-alive connections; no read added;rev3=census-ruling-warm-gate-fresh-724;basis=the cert warm DNS gate is built with dnsGateWithFresh(warmResolver, warmFresh.Resolve, ...): when the cached answer does not point here, the zone-verified FreshResolver from #724 is asked and the gate opens only if every fresh address is an edge (#724 follow-up) data-literal@129,data-literal@148,data-literal@284,data-literal@417,file:Open@1013 de02404e292762ef22540b43a1fefbcd1b3dedbcfa60d16646f652ee1dcfe4c0
+@coverage internal/edge 1c8c57fd2b01c754c47113799232b917a66e674d72751d9471050dab6991d2f8