carlos / platform Public

Fleet public routes Task 4 fix round 1: a refused host stays refused through aliases and catch-alls

Astra P1: a refusal was only a missing map entry, so an attached hostname
of the same name (the alias fold checks only the map for a collision) or a
one-label catch-all of another route revived the refused name, down that
route's tunnel and through its cacheable answer. Reload now collects every
host the fleet arm refused (an ineligible forward row, a fleet-placed row
FleetServeEligible refused, a forward row not ready) and, after every fold,
refusedHosts deletes each from the map and names it in refusedUnder on its
"*.<parent>" entry, which lookupIn consults. Regressions with a connected
tunnel and an armed cache for the alias and the catch-all cases, each with
a control.

Spec §7: Task 4's card reconciled (FleetServeEligible in fleetforward.go;
HubArmed, refusedHosts and lookupIn have no read site), beside Task 3's
C01 entries.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 506cce429d47f60f3cbd967898f7252e3e65a6e2 parent 40337fd
3 files changed, +173 −3
  • docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md +26 −2
  • internal/edge/edge.go +53 −1
  • internal/edge/fleetforward_test.go +94 −0

Intent

Attributed to this commit: 11.6 g CO₂e (1,508,743 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 9f647c873..d5494548d 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
@@ -973,8 +973,32 @@ Units, by file (N = new, R = removed, otherwise a changed body or sites):
- `internal/host/plans_pass.go`: `planThrottleFor` (admit).
- `internal/edge/edge.go`: `Edge.Reload` (forward case, eligibility, fleets
read moved before the routes loop, path rows of forward hosts not
- folded); `Edge.ServeHTTP` (`loginPost`, `cacheable`); `FleetServeEligible`
- (N).
+ folded, refused hosts held through every fold); `Edge.ServeHTTP`
+ (`loginPost`, `cacheable`).
+- `internal/edge/fleetforward.go` (a new file): `FleetServeEligible` (N).
+
+ Task 4's card (with its fix round 1), reconciled with this list.
+ `Edge.Reload`: `sites` (`+registry:FleetBox`, `+registry:Host` x9,
+ `+whole:Route` x4: the forward case's `fleetProxy` call and its
+ throttled refusal, the fleet case's refusal and accountless log lines,
+ the three `fleetRefused[t.Host]` marks, the two predicate calls and the
+ path fold's `IsForward` check; the `ListFleets` and `FleetChannelAuth`
+ reads moved before the loop and add no site). `Edge.ServeHTTP`: `sites`
+ (`+whole:Route` x2, the `IsForward` calls in `loginPost` and
+ `cacheable`). `Edge.localAssetCatch` (`assetcatch.go`, below): `sites`
+ (`+whole:Route`, its `IsForward` call). `FleetServeEligible`: N,
+ `+registry:Account` x7, `+registry:Region` x2, `+registry:Tunnel`,
+ `+whole:Route`. Differences from rev 4's list, recorded here:
+ `FleetServeEligible` is in `fleetforward.go`, not `edge.go`.
+ `HubArmed`, the one hub test (preflight 1.4, 3.6), is in the same file
+ and is not on the card: it reads its environment through its `getenv`
+ parameter, and `Reload` passes `os.Getenv` as a function value, so
+ neither is a read site; it moves only the `internal/edge` envelope.
+ `internal/host/hub.go`'s `hubArmed` now calls it and moves only the
+ `internal/host` envelope. The fix round's `refusedHosts` (a refused
+ host leaves the map after the alias and regional folds and is named on
+ its one-label catch-all) and `lookupIn`'s check of that mark read only
+ the edge's own map, no registry field, and are not on the card either.
- `internal/edge/ratelimit.go`: `Edge.rateAdmit`.
- `internal/edge/planthrottle.go`: `Edge.planThrottleOf`, `Edge.trackUpgrade`.
- `internal/edge/assetcatch.go`: `Edge.localAssetCatch`.
diff --git a/internal/edge/edge.go b/internal/edge/edge.go
index 4f1c112d0..4d5a4cd70 100644
--- a/internal/edge/edge.go
+++ b/internal/edge/edge.go
@@ -445,6 +445,11 @@ type upstream struct {
// captured here would be a stale copy of the target's entry the moment
// the target's route changed within the same map build.
paths map[string]string
+ // refusedUnder, on a one-label catch-all entry ("*.<parent>") only, names
+ // the hosts directly under parent that Reload refused (refusedHosts):
+ // lookupIn never resolves one of them through this catch-all. Nil on
+ // every other entry, and on a catch-all with no refused host under it.
+ refusedUnder map[string]bool
// genManaged marks an activator-managed instance proxied through
// appSocketProxy (generations on). Its cacheable responses are stored
// only when tagged with the generation that served them (cache.go).
@@ -759,6 +764,14 @@ 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)
if e.tunnels != nil {
fleetAuth, err = e.reg.FleetChannelAuth()
if err != nil {
@@ -797,6 +810,9 @@ 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
}
var proxy http.Handler
@@ -821,6 +837,7 @@ func (e *Edge) Reload() error {
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)
@@ -888,6 +905,7 @@ func (e *Edge) Reload() error {
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 != "" {
e.logThrottled("fleet-accountless "+t.Host, fmt.Sprintf("route %s: %s", t.Host, why))
@@ -1180,6 +1198,8 @@ func (e *Edge) Reload() error {
return err
}
e.foldRegional(m, routes, regionalRows)
+ // Refusals hold through every fold above: last, so nothing re-adds them.
+ refusedHosts(m, fleetRefused)
// 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 {
@@ -1439,13 +1459,45 @@ func lookupIn(m map[string]upstream, host string) (upstream, bool) {
return up, true
}
if i := strings.IndexByte(host, '.'); i > 0 {
- if up, ok := m["*"+host[i:]]; ok {
+ if up, ok := m["*"+host[i:]]; ok && !up.refusedUnder[host] {
return up, true
}
}
return upstream{}, false
}
+// refusedHosts makes each refused host resolve to nothing in m (fleet public
+// routes spec §4.4: a refused row is in no map, so Allowed is false and no
+// request reaches a tunnel or the cache under its name). Called once, after
+// every fold: the alias fold checks only m for a collision, and the regional
+// fold writes its own keys, so a host the routes loop left out could
+// otherwise come back as another route's attached hostname or regional
+// entry. Each refused host is deleted, and is named in refusedUnder on its
+// 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) {
+ for h := range refused {
+ delete(m, h)
+ i := strings.IndexByte(h, '.')
+ if i <= 0 {
+ continue
+ }
+ wk := "*" + h[i:]
+ w, ok := m[wk]
+ if !ok {
+ continue
+ }
+ under := make(map[string]bool, len(w.refusedUnder)+1)
+ for k := range w.refusedUnder {
+ under[k] = true
+ }
+ under[h] = true
+ w.refusedUnder = under
+ m[wk] = w
+ }
+}
+
// lookupUpstream resolves a hostname alone. Kept as the primitive because not
// every caller is answering "where does this REQUEST go" — the :80->:443
// routability check in httpFallbackHandler asks only whether this box serves
diff --git a/internal/edge/fleetforward_test.go b/internal/edge/fleetforward_test.go
index 62876a26a..547aa74d1 100644
--- a/internal/edge/fleetforward_test.go
+++ b/internal/edge/fleetforward_test.go
@@ -728,3 +728,97 @@ func TestReloadRefusesAHandFleetRowOfAnotherAccount(t *testing.T) {
}
}
}
+
+// refusedCollisionHub is the fixture for the two collision regressions: a
+// hub with an armed response cache whose box counts what reaches it per
+// host and answers cacheably, holding the eligible targets good (an
+// accountless fleet hand row, cacheable, through the tunnel) and fwd-good (an
+// eligible forward row), and the refused rows bad (a forward row of an
+// account that does not own fleet home) and bad-hand (a fleet hand row of
+// that account).
+func refusedCollisionHub(t *testing.T, extra ...registry.Route) (string, *Edge, *countingBox) {
+ t.Helper()
+ cb := &countingBox{}
+ rows := append([]registry.Route{
+ {Host: "good.example.com", Kind: "instance", Status: "ready", Region: registry.PlacementTarget("home")},
+ forwardRow("fwd-good.example.com", "home", fwdOwner),
+ }, extra...)
+ hubURL, hub, _ := forwardHubAndBox(t, rows, nil, cb)
+ hub.EnableCache(NewCache(DefaultCacheMaxEntries, DefaultCacheMaxBodyBytes))
+ return hubURL, hub, cb
+}
+
+// wantRefused asserts host is not Allowed, resolves to nothing, answers the
+// unknown-host answer (twice, so a cached answer would show) and that no
+// request for it reached the box.
+func wantRefused(t *testing.T, hubURL string, hub *Edge, cb *countingBox, host string) {
+ t.Helper()
+ if hub.Allowed(host) {
+ t.Errorf("Allowed(%s) = true, want false (refused)", host)
+ }
+ if up, ok := hub.lookupUpstream(host); ok {
+ t.Errorf("lookupUpstream(%s) resolved to %s, want nothing (refused)", host, up.route.Host)
+ }
+ unknown, unknownBody := fwdDo(t, hubURL, "GET", "never-registered.example.com", "/", "", nil)
+ for i := 0; i < 2; i++ {
+ resp, body := fwdDo(t, hubURL, "GET", host, "/page", "", nil)
+ if resp.StatusCode != unknown.StatusCode || string(body) != string(unknownBody) {
+ t.Errorf("GET %s #%d = %d %q, want the unknown-host answer %d %q", host, i+1, resp.StatusCode, body, unknown.StatusCode, unknownBody)
+ }
+ }
+ if n := cb.count(host); n != 0 {
+ t.Errorf("the box saw %d requests for refused %s, want 0", n, host)
+ }
+}
+
+// TestRefusedHostIsNotRevivedByAnAlias (Astra task 4 review, P1): a refused
+// forward host, and a refused fleet hand row, keep no service when an
+// attached hostname of the SAME name targets an eligible route. The alias
+// fold only checks the map for a collision, and a refusal is the absence of
+// a map entry, so without the refused set the alias took the name and sent
+// it down the eligible route's tunnel (and through its cacheable answer).
+func TestRefusedHostIsNotRevivedByAnAlias(t *testing.T) {
+ hubURL, hub, cb := refusedCollisionHub(t,
+ forwardRow("bad.example.com", "home", fwdOther),
+ registry.Route{Host: "bad-hand.example.com", Kind: "instance", Status: "ready", Region: registry.PlacementTarget("home"), Account: fwdOther},
+ )
+ for _, a := range []registry.RouteAlias{
+ {Alias: "bad.example.com", Host: "good.example.com", App: "good", CreatedAt: 1},
+ {Alias: "bad-hand.example.com", Host: "fwd-good.example.com", Account: fwdOwner, App: "shop", CreatedAt: 1},
+ // Control: an alias of a free name is served, through the tunnel.
+ {Alias: "free.example.com", Host: "good.example.com", App: "good", CreatedAt: 1},
+ } {
+ if err := hub.reg.UpsertAlias(a); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := hub.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ if resp, body := fwdDo(t, hubURL, "GET", "free.example.com", "/page", "", nil); resp.StatusCode != 200 || !strings.HasPrefix(string(body), "call ") {
+ t.Fatalf("control: the alias of a free name answered %d %q, want the box", resp.StatusCode, body)
+ }
+ wantRefused(t, hubURL, hub, cb, "bad.example.com")
+ wantRefused(t, hubURL, hub, cb, "bad-hand.example.com")
+}
+
+// TestRefusedHostIsNotRevivedByAWildcard (Astra task 4 review, P1): a refused
+// forward host one label under a catch-all ("*.<parent>") does not resolve to
+// the catch-all's route; another name under it still does.
+func TestRefusedHostIsNotRevivedByAWildcard(t *testing.T) {
+ hubURL, hub, cb := refusedCollisionHub(t,
+ forwardRow("bad.shop.example.com", "home", fwdOther),
+ registry.Route{Host: "bad-hand.shop.example.com", Kind: "instance", Status: "ready", Region: registry.PlacementTarget("home"), Account: fwdOther},
+ )
+ if err := hub.reg.UpsertAlias(registry.RouteAlias{Alias: "*.shop.example.com", Host: "good.example.com", App: "good", CreatedAt: 1}); err != nil {
+ t.Fatal(err)
+ }
+ if err := hub.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ if resp, body := fwdDo(t, hubURL, "GET", "other.shop.example.com", "/page", "", nil); resp.StatusCode != 200 || !strings.HasPrefix(string(body), "call ") {
+ t.Fatalf("control: another name under the catch-all answered %d %q, want the box", resp.StatusCode, body)
+ }
+ wantRefused(t, hubURL, hub, cb, "bad.shop.example.com")
+ wantRefused(t, hubURL, hub, cb, "bad-hand.shop.example.com")
+}