Fleet public routes Task 6 fix round 3: one fleet-arm verdict for Reload, the edges file and the alias pass
edge.FleetArmVerdict decides, over one registry listing and in Reload's order, which hosts the fleet arm refuses: a sidecar is not judged, a row that is not ready is not judged unless it is a forward row (refused), a forward row is always judged by FleetServeEligible and any other row only where tunnels are on, and a platform alias of a refused source is refused with it. Reload serves by it, the edges-file writer publishes by it, and the alias pass derives wildcard parents by it through AliasReport.FleetRefused, now the verdict over the pass's own listing. The host's fleetServeRefusal is gone; fleetArmInputs and fleetRefusedFor only read the inputs and pass the set through. This closes the claim on a platform alias of a refused source (its wildcard parent was kept on the hub) and stops judging a not-ready non-forward row that Reload never judges. Spec §4.4 and §7 reconciled with the census card.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 files changed,
+364
−119
docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md+28 −2internal/domains/aliases.go+13 −8internal/edge/edge.go+23 −29internal/edge/fleetforward.go+73 −6internal/edge/fleetverdict_test.go+154 −0internal/host/agent.go+1 −1internal/host/edgesfile.go+22 −39internal/host/edgesfile_forward_test.go+20 −4internal/host/hub.go+30 −30
CI failed — run details
Intent
Attributed to this commit: 17.1 g CO₂e (2,189,798 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-fleet-public-routes, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
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 187ece321..fd4d7debd 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 |
| @@ -477,7 +477,10 @@ Callers: |
| 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 |
| + cannot trace. All three (Reload, the writer, the alias pass) take the |
| + refused set from one function, `edge.FleetArmVerdict`, over the listing |
| + each read (Task 6 fix round 3), so they cannot disagree about a row's |
| + readiness or a platform alias of a refused source. 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 |
| @@ -1039,7 +1042,30 @@ Units, by file (N = new, R = removed, otherwise a changed body or sites): |
| `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 |
| + envelope. Fix round 3 (controller ruling: the refusal decision lives in |
| + one place) replaces `fleetServeRefusal` (never released, gone) with |
| + `internal/edge/fleetforward.go` `FleetArmVerdict` (new, `+registry:Host` |
| + x3, `+registry:Status`, `+whole:Route` x3): over one listing, in |
| + Reload's order (a sidecar not judged; a row that is not ready not judged |
| + unless it is a forward row, which is refused; a forward row always |
| + judged by `FleetServeEligible`, any other row only where tunnels are on; |
| + a platform alias of a refused source refused with it), the refused set |
| + with reasons and the accountless notes. `Edge.Reload` serves by it (the |
| + card now shows `+registry:FleetBox`, `+registry:Host` x7, `+whole:Route` |
| + x3: the inline predicate calls and the per-arm marks are gone, one |
| + refusal check before the switch, the accountless note, the alias-fold |
| + skip and `refusedHosts` read the verdict), the writer publishes by it, |
| + and the alias pass derives by it through `AliasReport.FleetRefused`, |
| + now `func([]registry.Route) map[string]string`, called once on the |
| + pass's own listing (`ReconcileAliasesReport`: `+registry:Host`, |
| + `+whole:Route`). The host side keeps two thin adapters that decide |
| + nothing: `internal/host/hub.go` `fleetArmInputs` (new, `+registry:Account`, |
| + `+registry:Name`, `+whole:Fleet` x2: the fleets table where the edge |
| + reads it, and the hub and tunnels tests) and `fleetRefusedFor` (new, |
| + `+whole:Route`: passes the verdict's refused set through). |
| + `edgesFileWriteClaims`: `+registry:Alias` x5, `+registry:Host` x4, |
| + `+whole:Route`, `+whole:RouteAlias` x2, `+whole:RoutePath` x7, |
| + `+whole:WildcardDomain`. `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 be0bec09c..12ee4bfed 100644 |
| --- a/internal/domains/aliases.go |
| +++ b/internal/domains/aliases.go |
| @@ -302,16 +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 |
| + // FleetRefused is an INPUT, set by the caller before the pass: the |
| + // hosts the edge's fleet arm refuses in a registry listing (fleet public |
| + // routes spec §4.4, edge.FleetArmVerdict, the decision Reload serves by; |
| + // this package cannot import the edge, so the agent passes it in). The |
| + // pass calls it once, on the routes it read. A Wildcard claim whose |
| + // primary is refused 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 |
| + FleetRefused func(routes []registry.Route) map[string]string |
| } |
| // relevantDropped returns the hosts of the listed-but-unread claims that the |
| @@ -406,6 +406,11 @@ func ReconcileAliasesReport(ctx context.Context, s release.Store, reg *registry. |
| for _, rt := range routes { |
| byHost[rt.Host] = rt |
| } |
| + // The edge's fleet-arm refusals over this listing (AliasReport.FleetRefused). |
| + var fleetRefused map[string]string |
| + if rep != nil && rep.FleetRefused != nil { |
| + fleetRefused = rep.FleetRefused(routes) |
| + } |
| existing, err := reg.ListAliases() |
| if err != nil { |
| return err |
| @@ -693,7 +698,7 @@ func ReconcileAliasesReport(ctx context.Context, s release.Store, reg *registry. |
| // 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 _, refused := fleetRefused[rt.Host]; !refused { |
| if wildCount >= maxWildcardDomains { |
| log.Printf("domains: wildcard %s dropped: per-box cap %d reached", c.Host, maxWildcardDomains) |
| continue |
diff --git a/internal/edge/edge.go b/internal/edge/edge.go| index cd23a961c..ba6743d3f 100644 |
| --- a/internal/edge/edge.go |
| +++ b/internal/edge/edge.go |
| @@ -764,14 +764,15 @@ func (e *Edge) Reload() error { |
| var fleetAuth map[string]string |
| var owners map[string]string |
| hub := false |
| - // fleetRefused collects every host the fleet arm refused in the loop below |
| - // (an ineligible forward row, or a fleet-placed row FleetServeEligible |
| - // refused), and every forward row not served for any other reason. A |
| - // refusal is not just a missing entry: after every fold, refusedHosts |
| - // takes each of these names out of the map and out of its catch-all, so |
| - // no attached hostname, regional row or "*.<parent>" fallback of another |
| - // route serves the refused name. |
| - fleetRefused := make(map[string]bool) |
| + // verdict is FleetArmVerdict over this listing, the one decision the |
| + // edges-file writer and the alias pass also make: every host the fleet |
| + // arm refuses (an ineligible forward row, a forward row that is not |
| + // ready, a fleet-placed row FleetServeEligible refused, a platform alias |
| + // of a refused source). A refusal is not just a missing entry: the loop |
| + // builds none, the alias fold folds nothing onto one, and after every |
| + // fold refusedHosts takes each name out of the map and out of its |
| + // catch-all, so no attached hostname, regional row or "*.<parent>" |
| + // fallback of another route serves the refused name. |
| if e.tunnels != nil { |
| fleetAuth, err = e.reg.FleetChannelAuth() |
| if err != nil { |
| @@ -787,6 +788,7 @@ func (e *Edge) Reload() error { |
| } |
| hub = HubArmed(os.Getenv) |
| } |
| + verdict := FleetArmVerdict(routes, owners, hub, e.tunnels != nil) |
| for _, t := range routes { |
| // A sidecar is a member that serves nothing: it binds no socket, and |
| // nothing — inside the box or outside it — may ever dial it. Refused |
| @@ -810,9 +812,10 @@ func (e *Edge) Reload() error { |
| // is the autocert HostPolicy, serving it would burn an ACME issuance |
| // on a host that can't answer yet. |
| if t.Status != "ready" { |
| - if t.IsForward() { |
| - fleetRefused[t.Host] = true |
| - } |
| + continue |
| + } |
| + if why, refused := verdict.Refused[t.Host]; refused { |
| + e.logThrottled("fleet-refused "+t.Host, fmt.Sprintf("route %s is not served: %s", t.Host, why)) |
| continue |
| } |
| var proxy http.Handler |
| @@ -829,17 +832,12 @@ func (e *Edge) Reload() error { |
| // is ever served is through its fleet's tunnel. FIRST, ahead of the |
| // Tunnel, socket and addr arms, so a forward row that carries a stray |
| // backend column can never reach one of them: an eligible row takes |
| - // fleetProxy, an ineligible one gets no map entry (so Allowed is false |
| - // and no certificate is ordered for it) and never falls through. |
| - // Eligibility is FleetServeEligible, the one rule: the hub only, inert, |
| - // on a fleet in this box's fleets table, its raw account the fleet's |
| - // owner. |
| + // fleetProxy, an ineligible one was refused above (verdict) and gets |
| + // no map entry (so Allowed is false and no certificate is ordered for |
| + // it) and never falls through. Eligibility is FleetServeEligible, the |
| + // one rule: the hub only, inert, on a fleet in this box's fleets |
| + // table, its raw account the fleet's owner. |
| case t.IsForward(): |
| - if ok, why := FleetServeEligible(t, hub, owners); !ok { |
| - e.logThrottled("forward-refused "+t.Host, fmt.Sprintf("route %s is not served: %s", t.Host, why)) |
| - fleetRefused[t.Host] = true |
| - continue |
| - } |
| p := fleetProxy(fleet, t.FleetBox, e.tunnels) |
| p.ModifyResponse = e.responseModifier(t) |
| proxy = p |
| @@ -903,11 +901,7 @@ func (e *Edge) Reload() error { |
| // its traffic would go. An accountless row is the pre-account |
| // compatibility case: served, and logged. |
| case isFleetPlaced && e.tunnels != nil: |
| - if ok, why := FleetServeEligible(t, hub, owners); !ok { |
| - e.logThrottled("fleet-refused "+t.Host, fmt.Sprintf("route %s is not served: %s", t.Host, why)) |
| - fleetRefused[t.Host] = true |
| - continue |
| - } else if why != "" { |
| + if why, noted := verdict.Noted[t.Host]; noted { |
| e.logThrottled("fleet-accountless "+t.Host, fmt.Sprintf("route %s: %s", t.Host, why)) |
| } |
| p := fleetProxy(fleet, t.FleetBox, e.tunnels) |
| @@ -1183,7 +1177,7 @@ func (e *Edge) Reload() error { |
| // name is itself attached to another route earlier in this loop: m |
| // holds that alias by now, and resolving through it would serve the |
| // refused row's own attached names with another row's entry. |
| - if fleetRefused[a.Host] { |
| + if _, refused := verdict.Refused[a.Host]; refused { |
| continue |
| } |
| up, ok := m[a.Host] |
| @@ -1206,7 +1200,7 @@ func (e *Edge) Reload() error { |
| } |
| e.foldRegional(m, routes, regionalRows) |
| // Refusals hold through every fold above: last, so nothing re-adds them. |
| - refusedHosts(m, fleetRefused) |
| + refusedHosts(m, verdict.Refused) |
| // Fleet channel auth and the door's tenancy map, read before the routes |
| // loop (above), applied here as they always were. |
| if e.tunnels != nil { |
| @@ -1483,7 +1477,7 @@ func lookupIn(m map[string]upstream, host string) (upstream, bool) { |
| // one-label catch-all ("*.<parent>"), which lookupIn consults, so the |
| // catch-all keeps serving every other name under parent. The catch-all's |
| // entry is a copy (map values), so marking it touches no other key. |
| -func refusedHosts(m map[string]upstream, refused map[string]bool) { |
| +func refusedHosts(m map[string]upstream, refused map[string]string) { |
| for h := range refused { |
| delete(m, h) |
| i := strings.IndexByte(h, '.') |
diff --git a/internal/edge/fleetforward.go b/internal/edge/fleetforward.go| index 4a9c1eaa3..8b3e2b003 100644 |
| --- a/internal/edge/fleetforward.go |
| +++ b/internal/edge/fleetforward.go |
| @@ -21,9 +21,8 @@ func HubArmed(getenv func(string) string) bool { |
| // TunnelsArmed reports whether this box's edge enables its tunnel hub |
| // (enableTunnelsFromEnv): CARLOS_TUNNEL_HOST set, read as it stands. It is |
| // the edge's dispatch, not the hub test: on every box where it holds, Reload |
| -// sends a fleet-placed row with no Tunnel through the fleet arm and asks |
| -// FleetServeEligible about it, so the edges-file writer asks about the same |
| -// rows. HubArmed is narrower (trimmed, and CARLOS_FLEET unset) and gates |
| +// sends a fleet-placed row with no Tunnel through the fleet arm, and |
| +// FleetArmVerdict judges it there. HubArmed is narrower (trimmed, and CARLOS_FLEET unset) and gates |
| // forward rows. |
| func TunnelsArmed(getenv func(string) string) bool { |
| return getenv("CARLOS_TUNNEL_HOST") != "" |
| @@ -31,9 +30,9 @@ func TunnelsArmed(getenv func(string) string) bool { |
| // FleetServeEligible decides whether rt may take the fleet arm: be served |
| // through a fleet's tunnel (spec §4.4, with the controller's ruling on |
| -// invalid accounts). It is the one place the rule is written; Reload asks it |
| -// for every forward row and for every other row that reaches the fleet arm, |
| -// and the edges-file writer asks it the same question. owners maps a fleet's |
| +// invalid accounts). It is the one place the rule is written; it is asked |
| +// only through FleetArmVerdict, which applies it in Reload's order for |
| +// Reload, the edges-file writer and the alias pass alike. owners maps a fleet's |
| // name to its owning account, from this box's own fleets table; hub is |
| // HubArmed on a box whose tunnels are enabled. why is a log fragment: the |
| // reason for a refusal, or the note that an accountless row was served. |
| @@ -96,3 +95,71 @@ func FleetServeEligible(rt registry.Route, hub bool, owners map[string]string) ( |
| } |
| return true, "" |
| } |
| + |
| +// FleetVerdict is the fleet arm's judgment of one registry listing. |
| +type FleetVerdict struct { |
| + // Refused maps every host the fleet arm refuses to the reason, a log |
| + // fragment. A refused host is in no routing map and is held out |
| + // through every fold: no alias of it is folded, no attached hostname |
| + // or regional row serves its name, and no "*.<parent>" catch-all |
| + // answers it. |
| + Refused map[string]string |
| + // Noted maps a served fleet-placed host to a log fragment: the |
| + // accountless compatibility case. |
| + Noted map[string]string |
| +} |
| + |
| +// FleetArmVerdict decides, over one registry listing, which hosts the fleet |
| +// arm refuses (fleet public routes spec §4.4). It is the one place the |
| +// decision is made: Reload serves by it, the edges-file writer publishes by |
| +// it, and the alias pass derives wildcard parents by it, each from the |
| +// listing it read. owners is the box's fleets table (fleet name to owning |
| +// account); hub is HubArmed on a box whose tunnels are on; tunnels is |
| +// whether the edge enables its tunnel hub (TunnelsArmed), which is what |
| +// sends a fleet-placed row through the fleet arm at all. |
| +// |
| +// In Reload's order, row by row: |
| +// - a sidecar serves nothing and is not judged; |
| +// - a row that is not ready is not served and not judged, except a |
| +// forward row, which is refused (a forward row is only ever served |
| +// through the fleet arm); |
| +// - a forward row is judged by FleetServeEligible always; any other row |
| +// only where tunnels are on (FleetServeEligible passes a row that is |
| +// not fleet-placed or carries its own Tunnel); |
| +// |
| +// then over the listing: a platform alias whose source is refused is |
| +// refused with it (it is served with its source's own entry, |
| +// PlatformAliasFold), so whatever is attached to or claimed on it goes too. |
| +func FleetArmVerdict(routes []registry.Route, owners map[string]string, hub, tunnels bool) FleetVerdict { |
| + v := FleetVerdict{Refused: map[string]string{}, Noted: map[string]string{}} |
| + for _, rt := range routes { |
| + if rt.IsSidecar() { |
| + continue |
| + } |
| + if rt.Status != "ready" { |
| + if rt.IsForward() { |
| + v.Refused[rt.Host] = "forward row is not ready" |
| + } |
| + continue |
| + } |
| + if !rt.IsForward() && !tunnels { |
| + continue |
| + } |
| + ok, why := FleetServeEligible(rt, hub, owners) |
| + switch { |
| + case !ok: |
| + v.Refused[rt.Host] = why |
| + case why != "": |
| + v.Noted[rt.Host] = why |
| + } |
| + } |
| + sources, _ := PlatformAliasFold(routes) |
| + for host, src := range sources { |
| + if _, refused := v.Refused[src]; refused { |
| + if _, own := v.Refused[host]; !own { |
| + v.Refused[host] = fmt.Sprintf("platform alias of %s, which is refused", src) |
| + } |
| + } |
| + } |
| + return v |
| +} |
diff --git a/internal/edge/fleetverdict_test.go b/internal/edge/fleetverdict_test.go| new file mode 100644 |
| index 000000000..c90245390 |
| --- /dev/null |
| +++ b/internal/edge/fleetverdict_test.go |
| @@ -0,0 +1,154 @@ |
| +package edge |
| + |
| +import ( |
| + "database/sql" |
| + "maps" |
| + "slices" |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/registry" |
| +) |
| + |
| +// Fleet public routes, Task 6 fix round 3: FleetArmVerdict is the one place |
| +// the fleet arm's refusals are decided, over one registry listing, in |
| +// Reload's order. This test pins the set for a fixture that holds every |
| +// shape the order matters for, and checks that Reload serves exactly the |
| +// names the set does not refuse. |
| +// |
| +// Every fixture host is also attached as an alias of a served anchor row. A |
| +// host the routes loop skips for any other reason (not ready, no backend) |
| +// is then still served under that alias; only a refused host, which Reload |
| +// holds out through every fold, is not. So Allowed(host) == !refused[host] |
| +// for every fixture host, and a host that is merely unserved cannot pass for |
| +// a refused one or the other way round. |
| +func TestFleetArmVerdictIsWhatReloadRefuses(t *testing.T) { |
| + const anchor = "anchor.example.com" |
| + hand := func(host, account string) registry.Route { |
| + return registry.Route{Host: host, Kind: "instance", Socket: "/run/carlos/" + host + ".sock", Status: "ready", |
| + Region: registry.PlacementTarget("home"), Account: account, App: "shop"} |
| + } |
| + rows := func() []registry.Route { |
| + idle := forwardRow("idle.bah.example.com", "home", fwdOwner) |
| + creating := hand("creating.baj.example.com", fwdOther) |
| + creating.Status = "creating" |
| + handBaj := hand("hand.baj.example.com", fwdOther) |
| + handBaj.Socket = "/run/carlos/hand.sock" |
| + apex := registry.Route{Host: "apex.baj.example.com", Kind: "instance", Socket: "/run/carlos/hand.sock", |
| + Status: "ready", Platform: true, Account: fwdOther, App: "shop"} |
| + // A sidecar serves nothing and is not judged, wherever it is placed. |
| + sidecar := hand("side.baj.example.com", fwdOther) |
| + sidecar.Kind, sidecar.Socket = "sidecar", "" |
| + tunnel := hand("tunnel.baj.example.com", fwdOther) |
| + tunnel.Tunnel, tunnel.Socket = "t1", "" |
| + return []registry.Route{ |
| + {Host: anchor, Kind: "service", Addr: "10.0.0.1:3000", Status: "ready"}, |
| + forwardRow("shop.bah.example.com", "home", fwdOwner), |
| + forwardRow("shop.baj.example.com", "home", fwdOther), |
| + idle, |
| + hand("hand.bah.example.com", fwdOwner), |
| + hand("hand.none.example.com", ""), |
| + handBaj, |
| + apex, |
| + creating, |
| + sidecar, |
| + tunnel, |
| + } |
| + } |
| + all := []string{"shop.bah.example.com", "shop.baj.example.com", "idle.bah.example.com", "hand.bah.example.com", |
| + "hand.none.example.com", "hand.baj.example.com", "apex.baj.example.com", "creating.baj.example.com", |
| + "side.baj.example.com", "tunnel.baj.example.com"} |
| + cases := []struct { |
| + name, tunnelHost, fleet string |
| + refused []string |
| + }{ |
| + // The not-ready hand row of a non-owner is not judged (readiness |
| + // first), the not-ready forward row is refused, and the platform |
| + // alias inherits its refused source. |
| + {"hub", "tunnel.example.com", "", []string{"shop.baj.example.com", "idle.bah.example.com", |
| + "hand.baj.example.com", "apex.baj.example.com"}}, |
| + {"tunnels on, not the hub", "tunnel.example.com", "home", []string{"shop.bah.example.com", "shop.baj.example.com", |
| + "idle.bah.example.com", "hand.baj.example.com", "apex.baj.example.com"}}, |
| + {"no tunnels", "", "", []string{"shop.bah.example.com", "shop.baj.example.com", "idle.bah.example.com"}}, |
| + } |
| + for _, c := range cases { |
| + t.Run(c.name, func(t *testing.T) { |
| + t.Setenv("CARLOS_TUNNEL_HOST", c.tunnelHost) |
| + t.Setenv("CARLOS_FLEET", c.fleet) |
| + reg := openReg(t) |
| + if err := reg.UpsertFleet(registry.Fleet{Name: "home", Account: fwdOwner, Bucket: "home-data"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, rt := range rows() { |
| + put := reg.Upsert |
| + if rt.IsForward() { |
| + put = reg.PutForward |
| + } |
| + if err := put(rt); err != nil { |
| + t.Fatalf("%s: %v", rt.Host, err) |
| + } |
| + } |
| + // PutForward forces ready; the hand edit that leaves one not ready. |
| + 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) |
| + } |
| + for _, h := range all { |
| + if err := reg.UpsertAlias(registry.RouteAlias{Alias: h, Host: anchor}); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + |
| + routes, err := reg.List() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + tunnels := TunnelsArmed(func(k string) string { |
| + return map[string]string{"CARLOS_TUNNEL_HOST": c.tunnelHost, "CARLOS_FLEET": c.fleet}[k] |
| + }) |
| + var owners map[string]string |
| + if tunnels { |
| + owners = map[string]string{"home": fwdOwner} |
| + } |
| + hub := tunnels && HubArmed(func(k string) string { |
| + return map[string]string{"CARLOS_TUNNEL_HOST": c.tunnelHost, "CARLOS_FLEET": c.fleet}[k] |
| + }) |
| + v := FleetArmVerdict(routes, owners, hub, tunnels) |
| + got := slices.Sorted(maps.Keys(v.Refused)) |
| + want := slices.Sorted(slices.Values(c.refused)) |
| + if !slices.Equal(got, want) { |
| + t.Fatalf("refused = %v, want %v", got, want) |
| + } |
| + for h, why := range v.Refused { |
| + if why == "" { |
| + t.Errorf("%s refused with no reason", h) |
| + } |
| + } |
| + |
| + e, err := New(reg, nil) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(e.probers.Stop) |
| + if tunnels { |
| + e.EnableTunnels(NewTunnelHub(c.tunnelHost, map[string]string{"t1": fwdT1Tok})) |
| + } |
| + if err := e.Reload(); err != nil { |
| + t.Fatal(err) |
| + } |
| + if !e.Allowed(anchor) { |
| + t.Fatal("positive control: the anchor is not served") |
| + } |
| + for _, h := range all { |
| + _, refused := v.Refused[h] |
| + if served := e.Allowed(h); served == refused { |
| + t.Errorf("%s: Reload serves %v, the verdict refuses %v", h, served, refused) |
| + } |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/host/agent.go b/internal/host/agent.go| index 96dae64b0..1e6259d3d 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -1184,7 +1184,7 @@ func aliasPassReporting(ctx context.Context, store release.Store, reg *registry. |
| // 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) |
| + refused, err := fleetRefusedFor(reg, os.Getenv) |
| if err != nil { |
| auth.aliasPass(start, rep) |
| return fmt.Errorf("alias pass: %w", err) |
diff --git a/internal/host/edgesfile.go b/internal/host/edgesfile.go| index 3ba012da7..0a217e3cc 100644 |
| --- a/internal/host/edgesfile.go |
| +++ b/internal/host/edgesfile.go |
| @@ -551,22 +551,23 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re |
| // advertised either, nor anything attached to it (#338 follow-up). |
| platformSources, refusedAliases := edge.PlatformAliasFold(routes) |
| // 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 |
| - // (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. |
| - fleetRefused, err := fleetServeRefusal(reg, os.Getenv) |
| + // serves, so the refusals are edge.FleetArmVerdict's over this listing, |
| + // the decision Reload serves by. Its inputs besides the listing are read |
| + // inside each write (fleetArmInputs: the environment the edge reads, no |
| + // parameter, since the writer has some thirty callers; this box's fleets |
| + // table where Reload reads it). withheld is the refused set: none of it |
| + // is published, and after every fold below each name is taken out |
| + // again, so no alias, instance catch-all or catch-all of another row |
| + // names it, and no claim on it publishes a certificate entry. |
| + fleetOwners, hub, tunnels, err := fleetArmInputs(reg, os.Getenv) |
| if err != nil { |
| return fmt.Errorf("edges: %w", err) |
| } |
| - withheld := map[string]bool{} |
| + verdict := edge.FleetArmVerdict(routes, fleetOwners, hub, tunnels) |
| + withheld := make(map[string]bool, len(verdict.Refused)) |
| + for host := range verdict.Refused { |
| + withheld[host] = true |
| + } |
| forwards := map[string]bool{} |
| for _, r := range routes { |
| // edge.Reload (internal/edge/edge.go) is the deployment's own |
| @@ -576,13 +577,9 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re |
| // here means this file never claims role:"home" for a host nothing |
| // actually serves. Hibernating routes stay Status "ready" (that is |
| // what makes wake-on-request possible), so nothing reachable is |
| - // excluded by this filter. A forward row that is not ready is |
| - // refused as well (Reload's fleetRefused), so its name stays out |
| - // under every alias and catch-all too. |
| + // excluded by this filter. (A forward row that is not ready is in |
| + // withheld as well, so its name stays out under every alias.) |
| if r.Status != "ready" { |
| - if r.IsForward() { |
| - withheld[r.Host] = true |
| - } |
| continue |
| } |
| // A sidecar is NEVER advertised as served — by this box or any |
| @@ -606,13 +603,7 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re |
| if r.IsSidecar() { |
| continue |
| } |
| - // The fleet arm, in Reload's order: a forward row always, any other |
| - // row only where the tunnels are on (FleetServeEligible passes a row |
| - // 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 fleetRefused(r) { |
| - withheld[r.Host] = true |
| + if withheld[r.Host] { |
| continue |
| } |
| if refusedAliases[r.Host] { |
| @@ -643,19 +634,11 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re |
| hosts[r.Host] = h |
| } |
| // A platform alias is served with its source's own entry, so one whose |
| - // source was withheld above is not served either (Reload drops it when |
| - // the source has no entry). It is not a refused name (Reload does not |
| - // hold it through the later folds), but whatever a claim derives from it |
| - // is refused with it: certRefused is every primary whose claims publish |
| - // no certificate entry, the withheld rows and these aliases. |
| - certRefused := make(map[string]bool, len(withheld)) |
| - for host := range withheld { |
| - certRefused[host] = true |
| - } |
| + // source is not served is not served either (Reload drops it when the |
| + // source has no entry; one of a refused source is in withheld already). |
| for host, src := range platformSources { |
| if _, served := hosts[src]; !served { |
| delete(hosts, host) |
| - certRefused[host] = true |
| } |
| } |
| // Owners (#175 P7): computed over the served rows alone, before any alias |
| @@ -804,7 +787,7 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re |
| // alias row points at, the route the edge serves the catch-all with. |
| catchallServed := map[string]string{} |
| // parentRefused names each parent whose claim's primary is refused |
| - // (certRefused): the primary its "*.<parent>" catch-all alias names, the |
| + // (withheld): the primary its "*.<parent>" catch-all alias names, the |
| // one its plain alias (the parent itself, for a claim with a Route) |
| // names, or the parent's own row (a claim that is its own primary). |
| // Neither half of its wildcard entry is published, so no reader loads or |
| @@ -812,7 +795,7 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re |
| // of these refused (a certificate-only or regional parent) is unchanged. |
| parentRefused := map[string]bool{} |
| for _, wd := range wds { |
| - parentRefused[wd.Host] = certRefused[wd.Host] |
| + parentRefused[wd.Host] = withheld[wd.Host] |
| } |
| for _, a := range aliases { |
| parent, star := strings.CutPrefix(a.Alias, "*.") |
| @@ -821,7 +804,7 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re |
| catchallServed[parent] = p |
| } |
| } |
| - if _, ok := parentRefused[parent]; ok && certRefused[a.Host] { |
| + if _, ok := parentRefused[parent]; ok && withheld[a.Host] { |
| parentRefused[parent] = true |
| } |
| } |
diff --git a/internal/host/edgesfile_forward_test.go b/internal/host/edgesfile_forward_test.go| index 59abc93bc..f2982f1c5 100644 |
| --- a/internal/host/edgesfile_forward_test.go |
| +++ b/internal/host/edgesfile_forward_test.go |
| @@ -654,6 +654,17 @@ func TestAliasPassDerivesNoWildcardParentForARefusedPrimary(t *testing.T) { |
| // 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"}, |
| + // The refused tenant's hand row on the owner's fleet and a |
| + // platform alias sharing its socket: the alias has no fleet |
| + // placement of its own and is refused with its source. |
| + {Host: "hand.baj.example.com", Kind: "instance", Socket: "/run/carlos/hand.sock", Status: "ready", |
| + Region: registry.PlacementTarget("home"), Account: fpOther, App: "shop"}, |
| + {Host: "apex.baj.example.com", Kind: "instance", Socket: "/run/carlos/hand.sock", Status: "ready", |
| + Platform: true, Account: fpOther, App: "shop"}, |
| + // A hand row of the refused tenant that is not ready: Reload does |
| + // not judge it, so a claim on it is not refused for the fleet. |
| + {Host: "creating.baj.example.com", Kind: "instance", Socket: "/run/carlos/creating.sock", Status: "creating", |
| + Region: registry.PlacementTarget("home"), Account: fpOther, App: "shop"}, |
| } { |
| if err := reg.Upsert(rt); err != nil { |
| t.Fatal(err) |
| @@ -683,18 +694,23 @@ func TestAliasPassDerivesNoWildcardParentForARefusedPrimary(t *testing.T) { |
| {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}, |
| + {Host: "baj-apex.example.com", Account: fpOther, App: "shop", Route: "apex.baj.example.com", Wildcard: true}, |
| + {Host: "baj-creating.example.com", Account: fpOther, App: "shop", Route: "creating.baj.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"} |
| + refused := []string{"baj-wild.example.com", "baj-certonly.example.com", "baj-own.example.com", "bah-idle.example.com", |
| + "baj-apex.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"}}, |
| + {"hub", fpTunnel, "", []string{"bah-wild.example.com", "plain-wild.example.com", "baj-creating.example.com"}}, |
| + // With no tunnels the hand row is served from its socket, and so |
| + // is its platform alias: the claim on the alias keeps its parent. |
| + {"no tunnels", "", "", []string{"plain-wild.example.com", "baj-creating.example.com", "baj-apex.example.com"}}, |
| } { |
| t.Run(c.name, func(t *testing.T) { |
| setHubEnv(t, c.tunnel, c.fleet) |
| @@ -715,7 +731,7 @@ func TestAliasPassDerivesNoWildcardParentForARefusedPrimary(t *testing.T) { |
| } |
| hosts, _ := fpHosts(t, fpWrite(t, reg)) |
| for _, p := range refused { |
| - if h, ok := hosts["*."+p]; ok { |
| + if h, ok := hosts["*."+p]; ok && !slices.Contains(c.eligible, p) { |
| t.Errorf("the published file names *.%s: %+v", p, h) |
| } |
| } |
diff --git a/internal/host/hub.go b/internal/host/hub.go| index 12508ac96..570b80c34 100644 |
| --- a/internal/host/hub.go |
| +++ b/internal/host/hub.go |
| @@ -19,36 +19,36 @@ import ( |
| // 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 |
| - } |
| +// fleetArmInputs reads what edge.FleetArmVerdict judges a listing by, |
| +// besides the listing: this box's fleets table (fleet name to owning |
| +// account), read only where the edge reads it (tunnels on), and the hub and |
| +// tunnels tests from the environment the edge reads. It decides nothing. |
| +func fleetArmInputs(reg *registry.Registry, getenv func(string) string) (owners map[string]string, hub, tunnels bool, err error) { |
| + tunnels, hub = edge.TunnelsArmed(getenv), edge.HubArmed(getenv) |
| + if !tunnels { |
| + return nil, false, false, nil |
| } |
| - 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 |
| + fleets, err := reg.ListFleets() |
| + if err != nil { |
| + return nil, false, false, fmt.Errorf("list fleets: %w", err) |
| + } |
| + owners = make(map[string]string, len(fleets)) |
| + for _, f := range fleets { |
| + owners[f.Name] = f.Account |
| + } |
| + return owners, hub, true, nil |
| +} |
| + |
| +// fleetRefusedFor is the alias pass's FleetRefused input: edge.FleetArmVerdict |
| +// over the listing the pass itself reads (internal/domains cannot import the |
| +// edge), with the inputs read here once per pass. It passes the verdict's |
| +// refused set through and decides nothing of its own. |
| +func fleetRefusedFor(reg *registry.Registry, getenv func(string) string) (func([]registry.Route) map[string]string, error) { |
| + owners, hub, tunnels, err := fleetArmInputs(reg, getenv) |
| + if err != nil { |
| + return nil, err |
| + } |
| + return func(routes []registry.Route) map[string]string { |
| + return edge.FleetArmVerdict(routes, owners, hub, tunnels).Refused |
| }, nil |
| } |