Fleet public routes Task 6 fix round 2: a refused primary derives no wildcard parent on its own box
The alias pass derives no wildcard_domains row for a Wildcard claim whose primary the edge refuses through the fleet arm, and retires an earlier one by its ordinary removal, so a hub that is the elected issuer orders no wildcard certificate for it from its own rows. The rule comes in as AliasReport.FleetRefused (internal/domains cannot import the edge), built by the agent's new fleetServeRefusal: edge.FleetServeEligible with HubArmed and the box's fleets table, as Reload applies it. The edges-file writer uses the same helper. When the fleets table cannot be read the alias pass does not run. Covers the named-Route claim shape the writer cannot trace. Spec §4.4 and §7 reconciled with the census card.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 files changed,
+241
−32
docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md+30 −2internal/domains/aliases.go+24 −7internal/host/agent.go+11 −1internal/host/edgesfile.go+12 −21internal/host/edgesfile_forward_test.go+124 −0internal/host/hub.go+40 −1
diff --git a/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md b/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md| index eb853d8e7..187ece321 100644 |
| --- a/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md |
| +++ b/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md |
| @@ -470,7 +470,14 @@ Callers: |
| dropped with a refused source) is left out, so it is in no issuer's |
| delegated set; a parent no refused claim derives (certificate-only, |
| regional) is unchanged. Aliases resolve as `Reload`'s alias fold does, |
| - through earlier aliases in name order. The one thing |
| + through earlier aliases in name order. The box's own wildcard source is |
| + closed at its writer: the alias pass derives no `wildcard_domains` row |
| + for a Wildcard claim whose primary the same rule refuses (the agent |
| + hands the rule in as `AliasReport.FleetRefused`), and retires an |
| + earlier one, so a hub that is the elected issuer orders no wildcard for |
| + it either. This covers every claim shape, including a named-Route claim |
| + whose own host is another local route of its tenant, which the writer |
| + cannot trace. The one thing |
| the file cannot say is `refusedUnder`: a refused name under another |
| row's served `*.<parent>` is not in the file (`KnownHost` is exact), and |
| a far edge that dials it through that catch-all reaches the hub, which |
| @@ -976,6 +983,9 @@ Units, by file (N = new, R = removed, otherwise a changed body or sites): |
| by the plan; `ReconcileConfig` (the `FleetOwners` field; envelope unless |
| a site). |
| - `internal/domains/reconcile.go`: `Reconcile` (trash-loop skip). |
| +- `internal/domains/aliases.go`: `ReconcileAliasesReport` (no wildcard |
| + parent for a refused primary; Task 6 fix round 2, card under |
| + `edgesfile.go` below). |
| - `internal/host/agent.go`: `boxProvisionConfig` (hub predicate, owner map, |
| reads `Fleet.Name`, `Fleet.Account`); `instancesLoop` (hub-only |
| bindings); `countExpiredCanaries` (skip). The hub predicate `hubArmed` |
| @@ -1011,7 +1021,25 @@ Units, by file (N = new, R = removed, otherwise a changed body or sites): |
| named by its `*.<parent>` alias, its plain alias or its own row, is |
| certificate-refused) leaves out both halves of that parent's entry, so |
| no separate issuer's `WildcardParents` or delegated set holds it. Rows |
| - read, all already read in the pass. `Edge.Reload` moves |
| + read, all already read in the pass. Fix round 2 (controller ruling on |
| + the hub's own wildcard source) moves the fleets read and the predicate |
| + call into `internal/host/hub.go` `fleetServeRefusal` (new, `+registry:Account`, |
| + `+registry:Name`, `+registry:Status`, `+whole:Fleet` x2, `+whole:Route`: |
| + `edge.FleetServeEligible` with `edge.HubArmed`, judged on every forward |
| + row and, where `edge.TunnelsArmed`, every other row; a forward row that |
| + is not ready refused), which the writer and the alias pass both call, so |
| + `edgesFileWriteClaims` shows as `sites` (`+registry:Alias` x5, |
| + `+registry:Host` x5, `+whole:Route`, `+whole:RouteAlias` x2, |
| + `+whole:RoutePath` x7, `+whole:WildcardDomain`). `internal/domains/aliases.go` |
| + `ReconcileAliasesReport`: `sites` (`+whole:Route`): a Wildcard claim whose |
| + primary `AliasReport.FleetRefused` refuses derives no `wildcard_domains` |
| + row, and an earlier row goes with the pass's ordinary removal; the |
| + catch-all alias is derived as before. `AliasReport.FleetRefused` (an |
| + input field; `internal/domains` cannot import the edge) moves only the |
| + `internal/domains` envelope, and `aliasPassReporting` (`agent.go`), which |
| + sets it and returns an incomplete pass without running when the fleets |
| + table cannot be read, has no read site and moves only the `internal/host` |
| + envelope. `Edge.Reload` moves |
| from `+registry:Host` x9 to x10: the alias fold skips an alias whose |
| primary is a refused row (`fleetRefused[a.Host]`), so a refused row's |
| attached names are not served through an alias that carries the |
diff --git a/internal/domains/aliases.go b/internal/domains/aliases.go| index 0c5757618..be0bec09c 100644 |
| --- a/internal/domains/aliases.go |
| +++ b/internal/domains/aliases.go |
| @@ -302,6 +302,16 @@ type AliasReport struct { |
| // regional claim (#447) derives its regional_domains rows for this |
| // region's placement. |
| Region string |
| + // FleetRefused is an INPUT, set by the caller before the pass: whether |
| + // the edge refuses to serve a route through the fleet arm (fleet public |
| + // routes spec §4.4, edge.FleetServeEligible with this box's fleet owners |
| + // and hub test, as Reload applies it). This package cannot import the |
| + // edge, so the rule comes in from the agent. A Wildcard claim whose |
| + // primary it refuses derives no wildcard_domains row, and a row an |
| + // earlier pass wrote for it goes with the pass's ordinary removal: a |
| + // refused route must not drive a certificate order anywhere, and this |
| + // table is the box's own wildcard manager's source. Nil refuses nothing. |
| + FleetRefused func(registry.Route) bool |
| } |
| // relevantDropped returns the hosts of the listed-but-unread claims that the |
| @@ -678,13 +688,20 @@ func ReconcileAliasesReport(ctx context.Context, s release.Store, reg *registry. |
| c.Host, primaryHost, release.RouteAccount(rt), rt.App, c.Account, c.App) |
| continue |
| } |
| - if wildCount >= maxWildcardDomains { |
| - log.Printf("domains: wildcard %s dropped: per-box cap %d reached", c.Host, maxWildcardDomains) |
| - continue |
| - } |
| - wildCount++ |
| - desiredWild[c.Host] = registry.WildcardDomain{ |
| - Host: c.Host, Account: c.Account, App: c.App, CreatedAt: now().Unix(), |
| + // A primary the edge refuses (fleet public routes §4.4) derives no |
| + // parent: not desired, so an earlier row is removed below like any |
| + // other. The catch-all alias is derived as before; the edge folds |
| + // nothing onto a refused primary and the edges file publishes none |
| + // of it. |
| + if rep == nil || rep.FleetRefused == nil || !rep.FleetRefused(rt) { |
| + if wildCount >= maxWildcardDomains { |
| + log.Printf("domains: wildcard %s dropped: per-box cap %d reached", c.Host, maxWildcardDomains) |
| + continue |
| + } |
| + wildCount++ |
| + desiredWild[c.Host] = registry.WildcardDomain{ |
| + Host: c.Host, Account: c.Account, App: c.App, CreatedAt: now().Unix(), |
| + } |
| } |
| if c.Catchall { |
| star := "*." + c.Host |
diff --git a/internal/host/agent.go b/internal/host/agent.go| index 4e083405a..96dae64b0 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -1180,7 +1180,17 @@ func aliasPassReporting(ctx context.Context, store release.Store, reg *registry. |
| defer auth.passEnd() |
| deploymentRoutes, routesWhole := edgesfile.DeploymentRoutesComplete(ctx, store, time.Now()) |
| rep := domains.AliasReport{DeploymentRoutesPartial: deploymentRoutes != nil && !routesWhole, Region: region} |
| - err := domains.ReconcileAliasesReport(ctx, store, reg, time.Now, deploymentRoutes, cache, &rep) |
| + // The edge's fleet-arm refusal (fleet public routes §4.4): a Wildcard |
| + // claim on a primary the edge refuses derives no wildcard parent. When |
| + // the fleets table cannot be read the pass does not run (incomplete), |
| + // so no row is written or retired on a guess. |
| + refused, err := fleetServeRefusal(reg, os.Getenv) |
| + if err != nil { |
| + auth.aliasPass(start, rep) |
| + return fmt.Errorf("alias pass: %w", err) |
| + } |
| + rep.FleetRefused = refused |
| + err = domains.ReconcileAliasesReport(ctx, store, reg, time.Now, deploymentRoutes, cache, &rep) |
| auth.aliasPass(start, rep) |
| return err |
| } |
diff --git a/internal/host/edgesfile.go b/internal/host/edgesfile.go| index 2722c3187..3ba012da7 100644 |
| --- a/internal/host/edgesfile.go |
| +++ b/internal/host/edgesfile.go |
| @@ -553,25 +553,18 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re |
| // Fleet public routes (spec §4.4): the file names exactly what the edge |
| // serves, so the writer asks edge.FleetServeEligible what Reload asks, of |
| // the rows Reload asks it about: every forward row, and, on a box whose |
| - // tunnels are on (edge.TunnelsArmed, Reload's fleet arm), every other row. |
| - // hub is the one hub test, read inside each write from the environment |
| - // the edge reads (no parameter: the writer has some thirty callers), and |
| - // the owners are this box's own fleets table, read once per write, and |
| - // only where Reload reads it. withheld collects every name the rule left |
| + // tunnels are on (edge.TunnelsArmed, Reload's fleet arm), every other row |
| + // (fleetServeRefusal, shared with the alias pass). The hub test is read |
| + // inside each write from the environment the edge reads (no parameter: |
| + // the writer has some thirty callers), and the owners are this box's own |
| + // fleets table, read once per write, and only where Reload reads it. |
| + // withheld collects every name the rule left |
| // out, and a forward row that is not ready, as Reload's fleetRefused does; |
| // after every fold below each is taken out again, so no alias, instance |
| // catch-all or catch-all of another row names it. |
| - tunnels, hub := edge.TunnelsArmed(os.Getenv), edge.HubArmed(os.Getenv) |
| - var fleetOwners map[string]string |
| - if tunnels { |
| - fleets, err := reg.ListFleets() |
| - if err != nil { |
| - return fmt.Errorf("edges: list fleets: %w", err) |
| - } |
| - fleetOwners = make(map[string]string, len(fleets)) |
| - for _, f := range fleets { |
| - fleetOwners[f.Name] = f.Account |
| - } |
| + fleetRefused, err := fleetServeRefusal(reg, os.Getenv) |
| + if err != nil { |
| + return fmt.Errorf("edges: %w", err) |
| } |
| withheld := map[string]bool{} |
| forwards := map[string]bool{} |
| @@ -618,11 +611,9 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re |
| // that is not fleet-placed, or that carries its own Tunnel). Before |
| // the platform-alias refusal, as in Reload, so a refused platform |
| // alias the fleet rule also refuses is withheld under every name. |
| - if r.IsForward() || tunnels { |
| - if ok, _ := edge.FleetServeEligible(r, hub, fleetOwners); !ok { |
| - withheld[r.Host] = true |
| - continue |
| - } |
| + if fleetRefused(r) { |
| + withheld[r.Host] = true |
| + continue |
| } |
| if refusedAliases[r.Host] { |
| continue |
diff --git a/internal/host/edgesfile_forward_test.go b/internal/host/edgesfile_forward_test.go| index 4f3e052ba..59abc93bc 100644 |
| --- a/internal/host/edgesfile_forward_test.go |
| +++ b/internal/host/edgesfile_forward_test.go |
| @@ -22,9 +22,11 @@ import ( |
| "path/filepath" |
| "reflect" |
| "regexp" |
| + "slices" |
| "strings" |
| "sync" |
| "testing" |
| + "time" |
| "github.com/carlosframework/platform/internal/domains" |
| "github.com/carlosframework/platform/internal/edge" |
| @@ -603,3 +605,125 @@ func TestEdgesFileForwardHostOwnerIgnoresItsPathRows(t *testing.T) { |
| wantOwner(t, hosts, "tickets.example.com", fpOwner, "shop") |
| wantOwner(t, hosts, "plain.example.com", "", "") // the positive control: mixed |
| } |
| + |
| +// fpClaim writes a claim into s as the console's attach door would. |
| +func fpClaim(t *testing.T, s release.Store, c domains.Claim) { |
| + t.Helper() |
| + c.Schema = 1 |
| + body, err := json.Marshal(c) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := s.Put(context.Background(), domains.ClaimKey(c.Host), body, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| + |
| +// fpWildcardRows is the box's wildcard_domains, by parent. |
| +func fpWildcardRows(t *testing.T, reg *registry.Registry) map[string]bool { |
| + t.Helper() |
| + wds, err := reg.ListWildcardDomains() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + out := make(map[string]bool, len(wds)) |
| + for _, w := range wds { |
| + out[w.Host] = true |
| + } |
| + return out |
| +} |
| + |
| +// The hub's own wildcard source is its wildcard_domains table, which the |
| +// alias pass writes and its wildcard manager reads for DNS-01 orders when it |
| +// is the elected issuer (wildcard.go's delegated source: these local rows |
| +// plus every other box's published parents). A Wildcard claim whose primary |
| +// is a fleet-placed row the edge refuses derives no row there, and a row an |
| +// earlier pass wrote is retired, so neither the hub's local source nor the |
| +// file it publishes (every other issuer's source) names the parent. That |
| +// covers the claim shapes the edges-file writer cannot trace too: a named |
| +// Route claim whose own host is another local route of the same tenant. A |
| +// claim on an eligible forward row, and one on a row of no fleet, keep |
| +// theirs. |
| +func TestAliasPassDerivesNoWildcardParentForARefusedPrimary(t *testing.T) { |
| + world := func(t *testing.T) (*registry.Registry, release.Store) { |
| + reg := fpRegistry(t) |
| + fpPutForward(t, reg, fpForward(fpEligible, "home", fpOwner)) |
| + fpPutForward(t, reg, fpForward(fpRefused, "home", fpOther)) |
| + for _, rt := range []registry.Route{ |
| + {Host: "plain.example.com", Kind: "service", Addr: "10.0.0.1:3001", Status: "ready", Account: fpOwner, App: "shop"}, |
| + // The refused tenant's own host, served here (no fleet), which |
| + // its named-Route claim also names. |
| + {Host: "baj-own.example.com", Kind: "service", Addr: "10.0.0.1:3002", Status: "ready", Account: fpOther, App: "shop"}, |
| + } { |
| + if err := reg.Upsert(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + // The owner's forward row left not ready by a hand edit: Reload |
| + // refuses it like an ineligible one. |
| + fpPutForward(t, reg, fpForward("idle.bah.example.com", "home", fpOwner)) |
| + db, err := sql.Open("sqlite", reg.Path()) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + _, err = db.Exec(`UPDATE routes SET status = 'creating' WHERE host = ?`, "idle.bah.example.com") |
| + db.Close() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + // A row an earlier pass wrote for the refused claim. |
| + if err := reg.UpsertWildcardDomain(registry.WildcardDomain{Host: "baj-wild.example.com", Account: fpOther, App: "shop"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + s := release.NewDirStore(t.TempDir()) |
| + for _, c := range []domains.Claim{ |
| + {Host: "bah-wild.example.com", Account: fpOwner, App: "shop", Route: fpEligible, Wildcard: true, Catchall: true}, |
| + {Host: "plain-wild.example.com", Account: fpOwner, App: "shop", Route: "plain.example.com", Wildcard: true}, |
| + {Host: "baj-wild.example.com", Account: fpOther, App: "shop", Route: fpRefused, Wildcard: true, Catchall: true}, |
| + {Host: "baj-certonly.example.com", Account: fpOther, App: "shop", Route: fpRefused, Wildcard: true}, |
| + {Host: "baj-own.example.com", Account: fpOther, App: "shop", Route: fpRefused, Wildcard: true}, |
| + {Host: "bah-idle.example.com", Account: fpOwner, App: "shop", Route: "idle.bah.example.com", Wildcard: true}, |
| + } { |
| + fpClaim(t, s, c) |
| + } |
| + return reg, s |
| + } |
| + refused := []string{"baj-wild.example.com", "baj-certonly.example.com", "baj-own.example.com", "bah-idle.example.com"} |
| + for _, c := range []struct { |
| + name, tunnel, fleet string |
| + eligible []string // derive a row |
| + }{ |
| + {"hub", fpTunnel, "", []string{"bah-wild.example.com", "plain-wild.example.com"}}, |
| + {"no tunnels", "", "", []string{"plain-wild.example.com"}}, |
| + } { |
| + t.Run(c.name, func(t *testing.T) { |
| + setHubEnv(t, c.tunnel, c.fleet) |
| + reg, s := world(t) |
| + if err := aliasPassReporting(context.Background(), s, reg, nil, newAssetAuthority(time.Now), ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + rows := fpWildcardRows(t, reg) |
| + for _, p := range c.eligible { |
| + if !rows[p] { |
| + t.Errorf("positive control: no wildcard_domains row for %s: %v", p, rows) |
| + } |
| + } |
| + for _, p := range append([]string{"bah-wild.example.com"}, refused...) { |
| + if rows[p] && !slices.Contains(c.eligible, p) { |
| + t.Errorf("wildcard_domains holds %s, a refused claim's parent: %v", p, rows) |
| + } |
| + } |
| + hosts, _ := fpHosts(t, fpWrite(t, reg)) |
| + for _, p := range refused { |
| + if h, ok := hosts["*."+p]; ok { |
| + t.Errorf("the published file names *.%s: %+v", p, h) |
| + } |
| + } |
| + for _, p := range c.eligible { |
| + if _, ok := hosts["*."+p]; !ok { |
| + t.Errorf("positive control: the published file lacks *.%s", p) |
| + } |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/host/hub.go b/internal/host/hub.go| index 9edeca39f..12508ac96 100644 |
| --- a/internal/host/hub.go |
| +++ b/internal/host/hub.go |
| @@ -1,6 +1,11 @@ |
| package host |
| -import "github.com/carlosframework/platform/internal/edge" |
| +import ( |
| + "fmt" |
| + |
| + "github.com/carlosframework/platform/internal/edge" |
| + "github.com/carlosframework/platform/internal/registry" |
| +) |
| // hubArmed reports whether this box is the hub: the box that holds the |
| // tunnel's reserved hostname (CARLOS_TUNNEL_HOST set) and is not itself a |
| @@ -13,3 +18,37 @@ import "github.com/carlosframework/platform/internal/edge" |
| // and the edges-file writer read too, so the box that serves forward rows, |
| // the box that publishes them and the box that binds them are one box. |
| func hubArmed(getenv func(string) string) bool { return edge.HubArmed(getenv) } |
| + |
| +// fleetServeRefusal is the edge's fleet-arm refusal as this box's Reload |
| +// applies it, for the readers that must agree with what it serves: the |
| +// edges-file writer and the alias pass's wildcard derivation. A forward row |
| +// is always judged (a forward row that is not ready is refused, as Reload's |
| +// fleetRefused marks it); any other row only where the tunnels are on |
| +// (edge.TunnelsArmed, Reload's fleet arm), elsewhere never. The rule is |
| +// edge.FleetServeEligible with edge.HubArmed and this box's fleets table, |
| +// read once here (a local registry read, where Reload reads it), so the |
| +// caller judges a whole pass by one reading. |
| +func fleetServeRefusal(reg *registry.Registry, getenv func(string) string) (func(registry.Route) bool, error) { |
| + tunnels, hub := edge.TunnelsArmed(getenv), edge.HubArmed(getenv) |
| + var owners map[string]string |
| + if tunnels { |
| + fleets, err := reg.ListFleets() |
| + if err != nil { |
| + return nil, fmt.Errorf("list fleets: %w", err) |
| + } |
| + owners = make(map[string]string, len(fleets)) |
| + for _, f := range fleets { |
| + owners[f.Name] = f.Account |
| + } |
| + } |
| + return func(rt registry.Route) bool { |
| + if !rt.IsForward() && !tunnels { |
| + return false |
| + } |
| + if rt.IsForward() && rt.Status != "ready" { |
| + return true |
| + } |
| + ok, _ := edge.FleetServeEligible(rt, hub, owners) |
| + return !ok |
| + }, nil |
| +} |