carlos / platform Public

domains: keep only exact aliases on an unread claim (scope cut)

Census rounds 1-3 (Astra) each found a kept row class that rests on
authority the row cannot show: wildcard parents (fleet refusal), path
prefixes (target tenancy), instance names (the parent claim). Rather
than a fourth tolerance round, keep only what the 11-07 shrink needs:
an exact-name alias whose own claim is unread, re-checked against every
refusal the plain derivation makes without the claim body (target
tenancy, local route owns the name, another box's route, normalised,
sidecar suffix). Catch-all, instance, wildcard and path rows are
removed as on main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev f6f0978c42aa404cfb5706484b12a2557e798032 parent 853cf5c
2 files changed, +113 −237
  • internal/domains/aliases.go +47 −85
  • internal/domains/aliases_unread_keep_test.go +66 −152

CI cancelled — superseded by a newer push — run details

diff --git a/internal/domains/aliases.go b/internal/domains/aliases.go
index c6ff6dfff..4a2338dee 100644
--- a/internal/domains/aliases.go
+++ b/internal/domains/aliases.go
@@ -429,15 +429,15 @@ func ReconcileAliasesReport(ctx context.Context, s release.Store, reg *registry.
if err != nil {
return err
}
- // keep is the claims whose rows this pass keeps as they are (below):
- // exactly the unread claims that make it incomplete, so a complete pass
- // never kept anything.
- keep := map[string]bool{}
+ // unreadAlias is the claims whose exact-name alias rows this pass keeps
+ // (keepUnreadAlias, below): exactly the unread claims that make it
+ // incomplete, so a complete pass never kept anything.
+ unreadAlias := map[string]bool{}
if h := relevantDropped(dropped, routes, existing); len(h) > 0 {
log.Printf("domains: %d claim(s) listed but unreadable this pass (e.g. %s) — the pass is incomplete", len(h), h[0])
incomplete = true
for _, host := range h {
- keep[host] = true
+ unreadAlias[host] = true
}
}
desired := map[string]bool{}
@@ -778,26 +778,9 @@ func ReconcileAliasesReport(ctx context.Context, s release.Store, reg *registry.
}, reg, now) {
incomplete = true
}
- // A row whose claim the listing shows but whose body this pass did not
- // read (a failed GET, an unparseable body, a not-found that
- // relevantDropped counts) was not decided on, so it is kept exactly as
- // it is, box stamps included, in every pass-owned table below, while
- // its target route here still belongs to the row's account and app
- // (Reload serves an alias with its target's entry, so a reused host
- // must not inherit the name). The pass is already incomplete for it. Deleting it instead is the 2026-11-07 flagship
- // shrink: an edge restart's first pass ran out of time on 75 claim GETs,
- // dropped every custom domain's row, and the next pass re-inserted them
- // with a blank dns_status, which the edges file withholds until the DNS
- // sweep comes round again. A claim that has left the listing is not in
- // dropped, so a detach still removes its rows on the same pass.
- unread := make(map[string]bool, len(dropped))
- for _, d := range dropped {
- unread[d.host] = true
- }
for _, a := range existing {
if !desired[a.Alias] {
- if rt, ok := byHost[a.Host]; ok && rt.App == a.App && release.RouteAccount(rt) == a.Account &&
- aliasClaimUnread(a.Alias, keep, listed) {
+ if keepUnreadAlias(a, unreadAlias, byHost, deploymentRoutes) {
continue
}
if err := reg.DeleteAlias(a.Alias); err != nil {
@@ -807,10 +790,16 @@ func ReconcileAliasesReport(ctx context.Context, s release.Store, reg *registry.
}
}
- // regional_domains is wholly pass-owned too, with the same exception
- // for an unread claim's rows. Reload judges a kept row again against
- // the routes it serves (spec §7.3), so keeping it never binds a target
- // that has stopped qualifying.
+ // regional_domains is wholly pass-owned too, with one exception: a row
+ // whose claim the listing shows but whose body this pass did not read
+ // (a failed GET, an unparseable body, a not-found) is kept exactly as
+ // it is, and the pass is incomplete. Reload judges a kept row again
+ // against the routes it serves (spec §7.3), so keeping it never binds a
+ // target that has stopped qualifying.
+ unread := make(map[string]bool, len(dropped))
+ for _, d := range dropped {
+ unread[d.host] = true
+ }
if writeRegional(reg, existingRegional, desiredRegional, unread) {
incomplete = true
}
@@ -852,40 +841,6 @@ func ReconcileAliasesReport(ctx context.Context, s release.Store, reg *registry.
wildCount++
desiredWild[w.Host] = w
}
- // Any other unread claim's wildcard parent is kept as it is (the alias
- // loop's rule), within the same per-box cap, while its account and app
- // still hold a local route here and NONE of their local routes is
- // fleet-refused. The row does not name its primary, but the primary is
- // one of those routes, so the fleet-arm refusal above still removes a
- // parent whose primary it refuses: a refused route must not drive a
- // certificate order on the strength of a claim this pass did not read.
- for _, w := range existingWild {
- if _, ok := desiredWild[w.Host]; ok || !keep[w.Host] {
- continue
- }
- if _, regional := keptRegional[w.Host]; regional {
- continue // decided by the regional rule above
- }
- held, refused := false, false
- for _, rt := range routes {
- if rt.App != w.App || release.RouteAccount(rt) != w.Account {
- continue
- }
- held = true
- if _, r := fleetRefused[rt.Host]; r {
- refused = true
- }
- }
- if !held || refused {
- continue
- }
- if wildCount >= maxWildcardDomains {
- log.Printf("domains: wildcard %s dropped: per-box cap %d reached", w.Host, maxWildcardDomains)
- continue
- }
- wildCount++
- desiredWild[w.Host] = w
- }
for h, w := range desiredWild {
cur := false
for _, e := range existingWild {
@@ -927,15 +882,6 @@ func ReconcileAliasesReport(ctx context.Context, s release.Store, reg *registry.
}
for _, p := range existingPaths {
if _, ok := desiredPaths[p.Host+"\x00"+p.Prefix]; !ok {
- // Kept only while it would still derive: the host's route is the
- // row's account and app, and the target is a local READY route
- // of the same account (the derivation's tenancy rule above).
- rt, ok := byHost[p.Host]
- tgt, tok := byHost[p.Target]
- if ok && tok && keep[p.Host] && rt.App == p.App && release.RouteAccount(rt) == p.Account &&
- tgt.Status == "ready" && release.RouteAccount(tgt) == p.Account {
- continue // its claim was not read this pass: kept as it is
- }
if err := reg.DeletePath(p.Host, p.Prefix); err != nil {
log.Printf("domains: remove path %s/%s: %v", p.Host, p.Prefix, err)
incomplete = true
@@ -1100,24 +1046,40 @@ func deriveHAIngressAliases(c Claim, local map[string]registry.Route, deployment
}
}
-// aliasClaimUnread reports whether the claim an alias row came from is in
-// unread (listed this pass, body not read). A row's claim is found from its
-// name alone: a plain alias is its claim's host, a catch-all "*.<host>" row
-// is <host>'s Wildcard claim, and an instance name "<label>.<parent>" is the
-// "*.<parent>" instance catch-all claim's, unless the name has a listed
-// claim of its own, which then decides alone.
-func aliasClaimUnread(alias string, unread, listed map[string]bool) bool {
- if len(unread) == 0 {
+// keepUnreadAlias reports whether an exact-name alias row whose own claim
+// was listed but not read this pass is kept as it is, box stamps included,
+// instead of deleted.
+//
+// Deleting it is the 2026-11-07 flagship shrink: an edge restart's first
+// alias pass ran under the startup HA ingress deadline with a cold claim
+// cache, 75 claim GETs timed out, and every custom domain's row went. The
+// next pass re-inserted them with a blank dns_status, which the edges file
+// withholds until the DNS sweep comes round again, so the other edges
+// answered 404 for those names for about a minute.
+//
+// Only the plain alias, the row named exactly by its unread claim, is kept,
+// and only while every refusal the plain derivation makes without the
+// claim's body still passes on what this pass did read: the target route
+// is local and still the row's account and app, no local route owns the
+// name, no other box serves it as a route, the name is normalised, and
+// neither end is under the reserved sidecar suffix. Catch-all, instance,
+// wildcard-parent and path rows each rest on further authority the row
+// cannot show (a parent claim, the fleet arm, a path target), so they are
+// still removed as before. A claim that has left the listing is a detach
+// and is not in unread.
+func keepUnreadAlias(a registry.RouteAlias, unread map[string]bool, byHost map[string]registry.Route, deploymentRoutes map[string]bool) bool {
+ if !unread[a.Alias] || strings.HasPrefix(a.Alias, "*.") {
return false
}
- if unread[alias] || listed[alias] {
- return unread[alias]
+ if strings.HasSuffix(a.Alias, sidecarSuffix) || strings.HasSuffix(a.Host, sidecarSuffix) {
+ return false
}
- if host, ok := strings.CutPrefix(alias, "*."); ok {
- return unread[host]
+ if n, ok := NormalizeAliasHost(a.Alias); !ok || n != a.Alias {
+ return false
}
- if _, parent, ok := strings.Cut(alias, "."); ok {
- return unread["*."+parent]
+ if _, taken := byHost[a.Alias]; taken || deploymentRoutes[a.Alias] {
+ return false
}
- return false
+ rt, ok := byHost[a.Host]
+ return ok && rt.App == a.App && release.RouteAccount(rt) == a.Account
}
diff --git a/internal/domains/aliases_unread_keep_test.go b/internal/domains/aliases_unread_keep_test.go
index 076c326f1..80415cf28 100644
--- a/internal/domains/aliases_unread_keep_test.go
+++ b/internal/domains/aliases_unread_keep_test.go
@@ -4,7 +4,6 @@ import (
"context"
"testing"
- "github.com/carlosframework/platform/internal/registry"
"github.com/carlosframework/platform/internal/release"
)
@@ -23,21 +22,20 @@ func (u unreadKeysStore) Get(ctx context.Context, key string) ([]byte, string, e
return u.DirStore.Get(ctx, key)
}
-// TestUnreadClaimsKeepTheirRows is the 2026-11-07 flagship shrink (v0.34.14
-// annie). A box's first alias pass after an edge restart ran under the
-// startup HA ingress deadline with a cold ClaimCache; 75 claim GETs ran out
-// of time, and the pass deleted every row those claims had derived. The
-// next pass re-inserted them with a blank dns_status, and the edges file
-// withheld every custom domain until the DNS sweep stamped them again, about
-// a minute later. Other edges served 404 for those names for that minute.
+// TestUnreadClaimKeepsItsExactAlias is the 2026-11-07 flagship shrink
+// (v0.34.14 annie). A box's first alias pass after an edge restart ran under
+// the startup HA ingress deadline with a cold ClaimCache; 75 claim GETs ran
+// out of time, and the pass deleted every alias row those claims had
+// derived. The next pass re-inserted them with a blank dns_status, and the
+// edges file withheld every custom domain until the DNS sweep stamped them
+// again, about a minute later.
//
-// A claim the listing shows but whose body this pass did not read was not
-// decided on. Every row it derived (plain alias, catch-all alias, wildcard
-// parent, path prefix, instance alias under its catch-all) stays exactly as
-// it is, box stamps included, and the pass reports incomplete. The control
-// at the end shows a claim that has actually left the listing still loses
-// its row on the same kind of pass.
-func TestUnreadClaimsKeepTheirRows(t *testing.T) {
+// An exact-name alias whose own claim is listed but unread is kept exactly
+// as it is, DNS stamp included, and the pass reports incomplete. The rows
+// that rest on further authority (catch-all star, instance names, wildcard
+// parent, path prefixes) still go as before: that is the scope cut. A claim
+// that has left the listing still loses its row on the same kind of pass.
+func TestUnreadClaimKeepsItsExactAlias(t *testing.T) {
e := newAliasEnv(t)
addRoute(t, e.reg, "shop.example.com", "abc", "shop")
addRoute(t, e.reg, "api.example.com", "abc", "api")
@@ -45,31 +43,10 @@ func TestUnreadClaimsKeepTheirRows(t *testing.T) {
putClaim(t, e.store, Claim{Host: "gone.example.com", Account: "abc", App: "shop", Route: "shop.example.com"})
putClaim(t, e.store, Claim{Host: "wild.example.org", Account: "abc", App: "shop", Route: "shop.example.com", Wildcard: true, Catchall: true})
putClaim(t, e.store, Claim{Host: "shop.example.com", Account: "abc", App: "shop", Paths: map[string]string{"api": "api.example.com"}})
- // The instance catch-all: the apex stays readable, the catch-all does not.
putClaim(t, e.store, Claim{Host: "example.net", Account: "abc", App: "shop-site"})
putClaim(t, e.store, Claim{Host: "*.example.net", Account: "abc", App: "shop", Instances: true})
addInstance(t, e.reg, "acme.abc.carlos.example.net", "acme", "abc", "shop")
- for _, cached := range []bool{false, true} {
- var cache *ClaimCache
- if cached {
- cache = &ClaimCache{}
- }
- if rep, err := e.pass(e.store, known(), cache); err != nil || !rep.Complete {
- t.Fatalf("cache=%v control: complete=%v err=%v", cached, rep.Complete, err)
- }
- }
- aliases := []string{"www.example.com", "gone.example.com", "*.wild.example.org", "acme.example.net"}
- got := aliasMap(t, e.reg)
- for _, a := range aliases {
- if _, ok := got[a]; !ok {
- t.Fatalf("setup: alias %s not derived (have %v)", a, got)
- }
- if err := e.reg.SetAliasDNSStatus(a, "pointing", 1755000000); err != nil {
- t.Fatal(err)
- }
- }
-
unread := unreadKeysStore{e.store, map[string]bool{
ClaimKey("www.example.com"): true,
ClaimKey("gone.example.com"): true,
@@ -78,6 +55,18 @@ func TestUnreadClaimsKeepTheirRows(t *testing.T) {
ClaimKey("*.example.net"): true,
}}
for _, cached := range []bool{false, true} {
+ e.mustPass()
+ got := aliasMap(t, e.reg)
+ for _, a := range []string{"www.example.com", "gone.example.com", "*.wild.example.org", "acme.example.net"} {
+ if _, ok := got[a]; !ok {
+ t.Fatalf("setup: alias %s not derived (have %v)", a, got)
+ }
+ }
+ for _, a := range []string{"www.example.com", "gone.example.com"} {
+ if err := e.reg.SetAliasDNSStatus(a, "pointing", 1755000000); err != nil {
+ t.Fatal(err)
+ }
+ }
var cache *ClaimCache
if cached {
cache = &ClaimCache{} // cold, as after a restart
@@ -89,8 +78,8 @@ func TestUnreadClaimsKeepTheirRows(t *testing.T) {
if rep.Complete {
t.Fatalf("cache=%v: the pass hid unread claims as complete", cached)
}
- got := aliasMap(t, e.reg)
- for _, a := range aliases {
+ got = aliasMap(t, e.reg)
+ for _, a := range []string{"www.example.com", "gone.example.com"} {
row, ok := got[a]
if !ok {
t.Fatalf("cache=%v: alias %s was deleted on a pass that never read its claim", cached, a)
@@ -99,19 +88,10 @@ func TestUnreadClaimsKeepTheirRows(t *testing.T) {
t.Fatalf("cache=%v: alias %s lost its DNS stamp (%q): the row was rewritten", cached, a, row.DNSStatus)
}
}
- wds, err := e.reg.ListWildcardDomains()
- if err != nil {
- t.Fatal(err)
- }
- if len(wds) != 1 || wds[0].Host != "wild.example.org" {
- t.Fatalf("cache=%v: wildcard parent not kept: %+v", cached, wds)
- }
- paths, err := e.reg.ListPaths()
- if err != nil {
- t.Fatal(err)
- }
- if len(paths) != 1 || paths[0].Host != "shop.example.com" || paths[0].Prefix != "api" {
- t.Fatalf("cache=%v: path prefix not kept: %+v", cached, paths)
+ for _, a := range []string{"*.wild.example.org", "acme.example.net"} {
+ if _, ok := got[a]; ok {
+ t.Fatalf("cache=%v: %s was kept; only exact aliases are (scope cut)", cached, a)
+ }
}
}
@@ -120,113 +100,47 @@ func TestUnreadClaimsKeepTheirRows(t *testing.T) {
if _, err := e.pass(unread, known(), nil); err != nil {
t.Fatal(err)
}
- if _, ok := aliasMap(t, e.reg)["gone.example.com"]; ok {
+ got := aliasMap(t, e.reg)
+ if _, ok := got["gone.example.com"]; ok {
t.Fatal("a detached claim's alias was kept")
}
- if _, ok := aliasMap(t, e.reg)["www.example.com"]; !ok {
+ if _, ok := got["www.example.com"]; !ok {
t.Fatal("the unread claim's alias was dropped alongside the detach")
}
}
-// TestUnreadWildcardParentStillFollowsTheFleetRefusal: keeping an unread
-// claim's wildcard parent must not outlive the fleet-arm refusal. Once the
-// primary is refused, the parent goes on the same pass even though its claim
-// was not read, because that table is the wildcard manager's order source.
-func TestUnreadWildcardParentStillFollowsTheFleetRefusal(t *testing.T) {
- e := newAliasEnv(t)
- addRoute(t, e.reg, "shop.example.com", "abc", "shop")
- putClaim(t, e.store, Claim{Host: "wild.example.org", Account: "abc", App: "shop", Route: "shop.example.com", Wildcard: true})
- e.mustPass()
- unread := unreadKeysStore{e.store, map[string]bool{ClaimKey("wild.example.org"): true}}
- for _, refuse := range []bool{false, true} {
- rep := AliasReport{Complete: true, FleetRefused: func([]registry.Route) map[string]string {
- if refuse {
- return map[string]string{"shop.example.com": "fleet closed"}
+// TestUnreadClaimKeepStillRefuses: every refusal the plain derivation can
+// make without the claim's body still removes a kept row: the target host
+// reused by another tenant, a local route now owning the name, and another
+// box serving the name as a route.
+func TestUnreadClaimKeepStillRefuses(t *testing.T) {
+ cases := []struct {
+ name string
+ change func(e *aliasEnv)
+ routes map[string]bool
+ }{
+ {"target reused by another tenant", func(e *aliasEnv) {
+ addRoute(t, e.reg, "shop.example.com", "xyz", "other")
+ }, known()},
+ {"a local route owns the name", func(e *aliasEnv) {
+ addRoute(t, e.reg, "www.example.com", "xyz", "other")
+ }, known()},
+ {"another box serves the name as a route", func(e *aliasEnv) {}, map[string]bool{"www.example.com": true}},
+ }
+ for _, c := range cases {
+ t.Run(c.name, func(t *testing.T) {
+ e := newAliasEnv(t)
+ addRoute(t, e.reg, "shop.example.com", "abc", "shop")
+ putClaim(t, e.store, Claim{Host: "www.example.com", Account: "abc", App: "shop", Route: "shop.example.com"})
+ e.mustPass()
+ c.change(e)
+ unread := unreadKeysStore{e.store, map[string]bool{ClaimKey("www.example.com"): true}}
+ if _, err := e.pass(unread, c.routes, nil); err != nil {
+ t.Fatal(err)
}
- return nil
- }}
- if err := ReconcileAliasesReport(context.Background(), unread, e.reg, aliasNow(), known(), nil, &rep); err != nil {
- t.Fatal(err)
- }
- wds, err := e.reg.ListWildcardDomains()
- if err != nil {
- t.Fatal(err)
- }
- if kept := len(wds) == 1; kept == refuse {
- t.Fatalf("refused=%v: wildcard rows %+v", refuse, wds)
- }
- }
-}
-
-// TestUnreadClaimKeepRechecksTenancy: a kept row must still name a target
-// its own account and app hold here. If the target host now belongs to
-// someone else, the row goes even though its claim was not read, because
-// Reload would serve the name with the new owner's app.
-func TestUnreadClaimKeepRechecksTenancy(t *testing.T) {
- e := newAliasEnv(t)
- addRoute(t, e.reg, "shop.example.com", "abc", "shop")
- putClaim(t, e.store, Claim{Host: "www.example.com", Account: "abc", App: "shop", Route: "shop.example.com"})
- e.mustPass()
- addRoute(t, e.reg, "shop.example.com", "xyz", "other") // host reused
- unread := unreadKeysStore{e.store, map[string]bool{ClaimKey("www.example.com"): true}}
- if _, err := e.pass(unread, known(), nil); err != nil {
- t.Fatal(err)
- }
- if _, ok := aliasMap(t, e.reg)["www.example.com"]; ok {
- t.Fatal("a kept alias now points at another tenant's route")
- }
-}
-
-// TestUnreadCatchallDoesNotShieldAListedSibling: a name under an instance
-// catch-all that has a listed claim of its own is decided by that claim. An
-// unread catch-all must not keep it after its own claim is detached.
-func TestUnreadCatchallDoesNotShieldAListedSibling(t *testing.T) {
- e := newAliasEnv(t)
- putClaim(t, e.store, Claim{Host: "example.net", Account: "abc", App: "shop-site"})
- putClaim(t, e.store, Claim{Host: "*.example.net", Account: "abc", App: "shop", Instances: true})
- addInstance(t, e.reg, "acme.abc.carlos.example.net", "acme", "abc", "shop")
- addRoute(t, e.reg, "shop.example.com", "abc", "shop")
- putClaim(t, e.store, Claim{Host: "www.example.net", Account: "abc", App: "shop", Route: "shop.example.com"})
- e.mustPass()
- if _, ok := aliasMap(t, e.reg)["www.example.net"]; !ok {
- t.Fatal("setup: www.example.net not derived")
- }
- // Its own claim now reads as a refusal (another app), while the
- // catch-all's read times out.
- deleteClaim(t, e.store, "www.example.net")
- putClaim(t, e.store, Claim{Host: "www.example.net", Account: "abc", App: "nope", Route: "shop.example.com"})
- unread := unreadKeysStore{e.store, map[string]bool{ClaimKey("*.example.net"): true}}
- if _, err := e.pass(unread, known(), nil); err != nil {
- t.Fatal(err)
- }
- got := aliasMap(t, e.reg)
- if _, ok := got["www.example.net"]; ok {
- t.Fatal("an unread catch-all kept a sibling its own claim refused")
- }
- if _, ok := got["acme.example.net"]; !ok {
- t.Fatal("the unread catch-all's own instance name was dropped")
- }
-}
-
-// TestUnreadClaimKeptPathRechecksItsTarget: a kept path prefix must still
-// name a target of its own account. If the target host now belongs to
-// another account, the prefix goes even though its claim was not read.
-func TestUnreadClaimKeptPathRechecksItsTarget(t *testing.T) {
- e := newAliasEnv(t)
- addRoute(t, e.reg, "shop.example.com", "abc", "shop")
- addRoute(t, e.reg, "api.example.com", "abc", "api")
- putClaim(t, e.store, Claim{Host: "shop.example.com", Account: "abc", App: "shop", Paths: map[string]string{"api": "api.example.com"}})
- e.mustPass()
- addRoute(t, e.reg, "api.example.com", "xyz", "api") // target reused
- unread := unreadKeysStore{e.store, map[string]bool{ClaimKey("shop.example.com"): true}}
- if _, err := e.pass(unread, known(), nil); err != nil {
- t.Fatal(err)
- }
- paths, err := e.reg.ListPaths()
- if err != nil {
- t.Fatal(err)
- }
- if len(paths) != 0 {
- t.Fatalf("a kept prefix now sends traffic to another account: %+v", paths)
+ if _, ok := aliasMap(t, e.reg)["www.example.com"]; ok {
+ t.Fatal("a kept alias survived a refusal the pass could see")
+ }
+ })
}
}