carlos / platform Public

Fleet public routes Task 7: the readers that must skip a forward row do, root egress included

Root egress (boxWhollyNested) skips an inert forward row and refuses one
with any forbidden column ("<host> is a forward row with a local
backend"); every unknown kind is still refused, and the skip covers only
the forward row itself. Retention and the expired-canary count skip
forward rows, so a hub reads no retention record or channel pointer for a
fleet app. The domains pass's whole-app trash loop keeps forward rows
ahead of DeleteIfUnchanged; the forward phase alone retires them.

Tests: per-column egress refusal over ForwardForbidden (raw-SQL
corruption, read back through root's read-only list), retention and
canary skips with positive controls, the trash-loop keep, no platform
name minted from a live forward row, and one table pinning the §4.15
selectors that already ignore an inert forward row (each shown failing by
a mutation). Spec §7 records Task 7's census card.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 5f5d5d1d4ab40648888fbf4661022ecba55b0413 parent 44d17f6
7 files changed, +520 −4
  • docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md +29 −0
  • internal/domains/forward_trash_test.go +128 −0
  • internal/domains/reconcile.go +8 −0
  • internal/host/agent.go +3 −1
  • internal/host/egress_source.go +14 −2
  • internal/host/forward_readers_test.go +334 −0
  • internal/host/retention.go +4 −1

Intent

Attributed to this commit: 21.5 g CO₂e (2,768,874 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 fd4d7debd..a96e6b5b7 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
@@ -1083,6 +1083,35 @@ Units, by file (N = new, R = removed, otherwise a changed body or sites):
row can only skip itself, never another row, and that a non-inert
forward row is still refused.
- `internal/host/retention.go`: `retentionPass` (skip).
+
+ Task 7's card, reconciled with this list. `boxWhollyNested` (root):
+ `sites` (`+registry:Host`, `+registry:Kind`): one case after the
+ backing check and before the unknown-kind refusal, `rt.Kind ==
+ registry.KindForward`, which `continue`s past that one row when
+ `rt.InertForward()` (the 50 forbidden fields, read inside
+ `InertForward`, a registry unit since Task 2) and otherwise returns
+ false with `<host> is a forward row with a local backend`. An
+ agent-written row can only skip itself: the case never returns true
+ and never touches another row, so a flat, sidecar, unknown-kind or
+ agent-user unit row beside it is still refused, and `railEvidence`
+ still decides after the rows. Every unknown kind is still refused. A
+ forward row with a non-empty `backing` is refused earlier, by the
+ existing backing check; with a `unit`, the existing unit check reads
+ its user first and the forward case refuses after it. No new file,
+ path or command is read. `retentionPass`: `body`, read sites
+ unchanged (10): a forward row brings its app into no pass (an
+ `IsForward()` method call). `countExpiredCanaries` (`agent.go`):
+ `body`, read sites unchanged (6): a forward row is skipped before its
+ channel pointer is read. `internal/domains/reconcile.go` `Reconcile`:
+ `sites` (`+whole:Route` x3, the new skip's `keptLive = append(keptLive,
+ rt)`): the whole-app trash loop keeps every forward row, ahead of
+ `DeleteIfUnchanged` (which refuses one anyway, Task 3), so a trashed
+ fleet app's forward row is retired by the forward phase alone (Task
+ 10). No unit on the card for Task 7 is missing from this list, and
+ none listed here for Task 7 is missing from the card. Envelopes
+ re-pinned: `internal/host`, `internal/domains`. The selectors in
+ "Root's own row readers" below are pinned, unchanged, by
+ `TestReadersIgnoreInertForwardRows`.
- `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
diff --git a/internal/domains/forward_trash_test.go b/internal/domains/forward_trash_test.go
new file mode 100644
index 000000000..f5d5d06a3
--- /dev/null
+++ b/internal/domains/forward_trash_test.go
@@ -0,0 +1,128 @@
+package domains_test
+
+// Fleet public routes, Task 7 (spec §4.3, §4.11, §4.15): the domains pass
+// never removes a forward row and never mints from one. A trashed fleet
+// app's forward row is retired by the hub's forward phase alone, under its
+// whole-scan, fresh-store and production rules (preflight 1.9); the trash
+// loop here keeps it. A live forward row has no socket, no address and no
+// static channel, so no platform name is minted from it.
+//
+// Account: domains.Sqid(7) ("bah"), a valid non-ops sqid.
+
+import (
+ "bytes"
+ "log"
+ "os"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/domains"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// fwdRow is an inert forward row of app on fleet home for acct.
+func fwdRow(host, app, acct string) registry.Route {
+ return registry.Route{Host: host, Kind: registry.KindForward, Slug: app, App: app,
+ Account: acct, Region: registry.PlacementTarget("home"), Channel: "production"}
+}
+
+func putFwd(t *testing.T, reg *registry.Registry, rt registry.Route) {
+ t.Helper()
+ if err := reg.PutForward(rt); err != nil {
+ t.Fatalf("PutForward(%s): %v", rt.Host, err)
+ }
+}
+
+// captureLog sends the standard logger to a buffer for the rest of the test.
+func captureLog(t *testing.T) *bytes.Buffer {
+ t.Helper()
+ var buf bytes.Buffer
+ log.SetOutput(&buf)
+ t.Cleanup(func() { log.SetOutput(os.Stderr) })
+ return &buf
+}
+
+// TestDomainsTrashLoopKeepsForwardRows: shop (a forward row) and blog (an
+// instance row) are both trashed. After Reconcile blog's row is gone and
+// shop's forward row is exactly as it was: the trash loop skips it before
+// DeleteIfUnchanged, and leaves it to the forward phase.
+func TestDomainsTrashLoopKeepsForwardRows(t *testing.T) {
+ s := dirStore(t)
+ acct := writeAccountManifest(t, s, 7, "Bah")
+ reg := regWith(t, registry.Route{Host: "blog.example.com", Kind: "instance", App: "blog",
+ Account: acct, Status: "ready", Addr: "127.0.0.1:9000"})
+ putFwd(t, reg, fwdRow("shop.example.com", "shop", acct))
+ before := mustGet(t, reg, "shop.example.com")
+ for _, app := range []string{"shop", "blog"} {
+ putKey(t, s, "apps/"+acct+"/"+app+"/channels/stable.json")
+ if err := release.TrashApp(ctx, s, acct, app, "owner@example.com", time.Unix(1753900000, 0)); err != nil {
+ t.Fatal(err)
+ }
+ }
+ logged := captureLog(t)
+
+ if err := domains.Reconcile(ctx, s, reg, cfg(t)); err != nil {
+ t.Fatal(err)
+ }
+ if got := routesFor(t, reg, "blog"); len(got) != 0 {
+ t.Errorf("trashed blog still routed: %+v", got)
+ }
+ after := mustGet(t, reg, "shop.example.com")
+ if !after.InertForward() || *after != *before {
+ t.Errorf("shop's forward row changed:\nbefore %+v\nafter %+v", *before, *after)
+ }
+ if strings.Contains(logged.String(), "shop.example.com") {
+ t.Errorf("the trash loop acted on the forward row:\n%s", logged)
+ }
+}
+
+// TestDomainsMintsNoPlatformNameFromALiveForwardRow: apps domain
+// example.com, account bah materialized, a live forward row for shop and
+// shop's canary channel pointer present. Reconcile mints no platform name
+// and no canary host for shop, and does not try to (no log line about
+// minting shop: firstReadyUpstream never picks the forward row, spec
+// §4.11). The positive control in the same pass: blog, an instance with an
+// address, gets its apex, so the route count grows by that one row only.
+func TestDomainsMintsNoPlatformNameFromALiveForwardRow(t *testing.T) {
+ s := dirStore(t)
+ acct := writeAccountManifest(t, s, 7, "Bah")
+ reg := regWith(t, registry.Route{Host: "blog.example.org", Kind: "instance", App: "blog",
+ Account: acct, Status: "ready", Addr: "127.0.0.1:9000"})
+ putFwd(t, reg, fwdRow("shop-1.bah.example.com", "shop", acct))
+ putKey(t, s, "apps/"+acct+"/blog/channels/stable.json")
+ putKey(t, s, "apps/"+acct+"/shop/channels/production.json")
+ putKey(t, s, "apps/"+acct+"/shop/channels/canary/x.json")
+ before := routeCount(t, reg)
+ shopBefore := routesFor(t, reg, "shop")
+ c := cfg(t)
+ c.AppsDomain = "example.com"
+ logged := captureLog(t)
+
+ if err := domains.Reconcile(ctx, s, reg, c); err != nil {
+ t.Fatal(err)
+ }
+
+ shopAfter := routesFor(t, reg, "shop")
+ if len(shopAfter) != 1 || shopAfter[0] != shopBefore[0] {
+ t.Errorf("shop's rows changed:\nbefore %+v\nafter %+v", shopBefore, shopAfter)
+ }
+ for _, rt := range shopAfter {
+ if rt.Platform {
+ t.Errorf("a platform row for shop: %+v", rt)
+ }
+ }
+ for _, line := range strings.Split(logged.String(), "\n") {
+ if strings.Contains(line, "mint") && strings.Contains(line, "shop") {
+ t.Errorf("the pass tried to mint from the forward row: %s", line)
+ }
+ }
+ apex := mustGet(t, reg, "blog."+acct+".example.com")
+ if !apex.Platform || apex.Addr != "127.0.0.1:9000" {
+ t.Errorf("control: blog's apex = %+v", apex)
+ }
+ if got := routeCount(t, reg); got != before+1 {
+ t.Errorf("route count %d -> %d, want +1 (blog's apex only)", before, got)
+ }
+}
diff --git a/internal/domains/reconcile.go b/internal/domains/reconcile.go
index 6f891e83d..4829f110e 100644
--- a/internal/domains/reconcile.go
+++ b/internal/domains/reconcile.go
@@ -223,6 +223,14 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
}
keptLive := routes[:0]
for _, rt := range routes {
+ // A forward row is retired by the hub's forward phase alone,
+ // under its whole-scan, fresh-store and production rules (fleet
+ // public routes spec §4.3); DeleteIfUnchanged would refuse it
+ // anyway.
+ if rt.IsForward() {
+ keptLive = append(keptLive, rt)
+ continue
+ }
if rt.App != "" && trashed[appKey{release.RouteAccount(rt), rt.App}] != nil {
if jerr != nil || journaled[rt.Host] {
if jerr == nil {
diff --git a/internal/host/agent.go b/internal/host/agent.go
index 1e6259d3d..d13a2b653 100644
--- a/internal/host/agent.go
+++ b/internal/host/agent.go
@@ -3368,7 +3368,9 @@ func countExpiredCanaries(ctx context.Context, routes []registry.Route, store re
cache := map[key]*release.ChannelPointer{}
n := 0
for _, rt := range routes {
- if rt.Platform || !isCanaryRoute(rt) {
+ // A forward row keeps Channel for display only; the fleet box runs
+ // the canary and counts it (fleet public routes spec §4.15).
+ if rt.Platform || rt.IsForward() || !isCanaryRoute(rt) {
continue
}
if store == nil || len(pub) != ed25519.PublicKeySize {
diff --git a/internal/host/egress_source.go b/internal/host/egress_source.go
index 4b696b967..a28622841 100644
--- a/internal/host/egress_source.go
+++ b/internal/host/egress_source.go
@@ -49,12 +49,15 @@ import (
// foreign or conflict: the activator spawns it as the agent's user);
// - backed by a named systemd unit (Route.Unit) that unitAsAgent says
// runs as the agent's user, or whose user it cannot read; or
+// - a forward row that is not InertForward (fleet public routes spec
+// §4.15); or
// - a kind or backing this code does not know (fail closed, ruling C14).
//
// Rows with no local process of the agent's user do not count: carlos-app@
// unit tenants (DynamicUser), tunnel-served, addr-only, unflagged socket
-// rows run by another supervisor, static rows, and service rows (each
-// still subject to the named-unit check). A rootfs app's row is an
+// rows run by another supervisor, static rows, service rows (each still
+// subject to the named-unit check), and an inert forward row, which the hub
+// serves only over a fleet tunnel. A forward row skips only itself. A rootfs app's row is an
// ordinary managed nested row; this check never reads Route.Runtime.
func boxWhollyNested(rows []registry.Route, dataDir string, unitAsAgent func(unit string) (bool, error)) (ok bool, reason string) {
in := activator.LayoutInputs{
@@ -87,6 +90,15 @@ func boxWhollyNested(rows []registry.Route, dataDir string, unitAsAgent func(uni
return false, fmt.Sprintf("%s has backing %q, which this check does not know", rt.Host, rt.Backing)
case rt.Kind == "static" || rt.Kind == "service":
continue
+ case rt.Kind == registry.KindForward:
+ // A forward row (fleet public routes spec §4.15) runs nothing on
+ // this box: the hub forwards it over a fleet tunnel. An inert one
+ // skips only itself. One with any column a local process would
+ // need is refused, never skipped.
+ if rt.InertForward() {
+ continue
+ }
+ return false, rt.Host + " is a forward row with a local backend"
case rt.Kind != "instance":
return false, fmt.Sprintf("%s is a %q row, which this check does not know", rt.Host, rt.Kind)
case activator.ActivatorManaged(rt):
diff --git a/internal/host/forward_readers_test.go b/internal/host/forward_readers_test.go
new file mode 100644
index 000000000..58e009447
--- /dev/null
+++ b/internal/host/forward_readers_test.go
@@ -0,0 +1,334 @@
+package host
+
+// Fleet public routes, Task 7 (spec §4.15): every host-side reader that must
+// ignore a forward row does. Root egress (boxWhollyNested) skips an inert
+// forward row, refuses one that is not inert, and still refuses every kind
+// it does not know; retention and the expired-canary count skip a forward
+// row (no bucket read for its app); and the root and agent selectors of
+// §4.15 never admit an inert one.
+//
+// Accounts: fpOwner (domains.Sqid(7), "bah"), as in edgesfile_forward_test.go.
+
+import (
+ "context"
+ "os"
+ "path/filepath"
+ "strings"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/activator"
+ "github.com/carlosframework/platform/internal/ops"
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+const (
+ frForward = "shop.bah.example.com"
+ frNested = "blog.bah.example.com"
+)
+
+// noUnitAsAgent is the unit reader for rows that name no unit the agent
+// runs: every unit runs as someone else.
+func noUnitAsAgent(string) (bool, error) { return false, nil }
+
+// frEgressBox is a registry in its own data dir holding one nested managed
+// instance (blog) and an inert forward row (shop), written by their own
+// writers (Upsert, PutForward).
+func frEgressBox(t *testing.T) (*registry.Registry, string) {
+ t.Helper()
+ reg, dd := egressRegistry(t)
+ blog := nestedRow(dd, frNested)
+ blog.App, blog.Account = "blog", fpOwner
+ upsertRows(t, reg, blog)
+ fpPutForward(t, reg, fpForward(frForward, "home", fpOwner))
+ return reg, dd
+}
+
+// frRootRows is what root reads: the registry listed read-only, the
+// production reader of registryEgressSource.
+func frRootRows(t *testing.T, reg *registry.Registry) []registry.Route {
+ t.Helper()
+ rows, err := listRegistryReadOnly(reg.Path())
+ if err != nil {
+ t.Fatalf("listRegistryReadOnly: %v", err)
+ }
+ return rows
+}
+
+// TestEgressNestedWithAnInertForwardRow: an inert forward row runs no local
+// process, so a box whose only other row is nested stays wholly nested. The
+// skip is the forward row's own: beside a flat row, a sidecar or a kind this
+// check does not know, the box is still refused and the reason names that
+// other row.
+func TestEgressNestedWithAnInertForwardRow(t *testing.T) {
+ reg, dd := frEgressBox(t)
+ rows := frRootRows(t, reg)
+ var fw registry.Route
+ for _, rt := range rows {
+ if rt.Host == frForward {
+ fw = rt
+ }
+ }
+ if !fw.InertForward() {
+ t.Fatalf("fixture: the forward row read back is not inert: %+v", fw)
+ }
+ if ok, reason := boxWhollyNested(rows, dd, noUnitAsAgent); !ok {
+ t.Fatalf("a nested row and an inert forward row: boxWhollyNested = false (%q), want true", reason)
+ }
+
+ sidecar := registry.Route{Host: "worker.bah.example.com", Kind: "sidecar", App: "blog"}
+ unknown := registry.Route{Host: "new.bah.example.com", Kind: "frobnicate"}
+ for _, tc := range []struct {
+ name string
+ extra registry.Route
+ reason string
+ }{
+ {"a flat row", flatRow(dd, "old.bah.example.com"), "old.bah.example.com is flat"},
+ {"a sidecar member", sidecar, "worker.bah.example.com is a sidecar member"},
+ {"an unknown kind", unknown, `new.bah.example.com is a "frobnicate" row, which this check does not know`},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ ok, reason := boxWhollyNested(append(append([]registry.Route{}, rows...), tc.extra), dd, noUnitAsAgent)
+ if ok {
+ t.Fatalf("boxWhollyNested passed beside %s", tc.name)
+ }
+ if !strings.Contains(reason, tc.reason) {
+ t.Fatalf("reason %q, want it to hold %q", reason, tc.reason)
+ }
+ })
+ }
+ // A "frobnicate" row alone is refused as it was before forward rows.
+ if ok, reason := boxWhollyNested([]registry.Route{unknown}, dd, noUnitAsAgent); ok || !strings.Contains(reason, "new.bah.example.com") {
+ t.Fatalf("a frobnicate row alone: boxWhollyNested = %v (%q), want false naming its host", ok, reason)
+ }
+}
+
+// TestEgressRefusesEachNonInertForwardRow: for every forbidden column, the
+// same box with the forward row's column corrupted by raw SQL (persisted and
+// read back) is not wholly nested, and the reason names the forward host. A
+// corrupt backing is refused by the backing check that runs before the kind
+// switch; every other column by the forward case's own reason.
+func TestEgressRefusesEachNonInertForwardRow(t *testing.T) {
+ if len(registry.ForwardForbidden) == 0 {
+ t.Fatal("ForwardForbidden is empty")
+ }
+ for _, c := range registry.ForwardForbidden {
+ t.Run(c.Column, func(t *testing.T) {
+ reg, dd := frEgressBox(t)
+ if ok, reason := boxWhollyNested(frRootRows(t, reg), dd, noUnitAsAgent); !ok {
+ t.Fatalf("before the corruption: boxWhollyNested = false (%q)", reason)
+ }
+ corruptRow(t, reg.Path(), frForward, c)
+ ok, reason := boxWhollyNested(frRootRows(t, reg), dd, noUnitAsAgent)
+ if ok {
+ t.Fatalf("%s corrupted: boxWhollyNested = true", c.Column)
+ }
+ want := frForward + " is a forward row with a local backend"
+ if c.Column == "backing" {
+ want = frForward + ` has backing "x"`
+ }
+ if !strings.HasPrefix(reason, want) {
+ t.Fatalf("%s corrupted: reason %q, want %q", c.Column, reason, want)
+ }
+ })
+ }
+}
+
+// frStore is a DirStore that records every key read and deleted.
+type frStore struct {
+ *release.DirStore
+ mu sync.Mutex
+ gets []string
+ deletes []string
+}
+
+func (s *frStore) Get(ctx context.Context, key string) ([]byte, string, error) {
+ s.mu.Lock()
+ s.gets = append(s.gets, key)
+ s.mu.Unlock()
+ return s.DirStore.Get(ctx, key)
+}
+
+func (s *frStore) Delete(ctx context.Context, key string) error {
+ s.mu.Lock()
+ s.deletes = append(s.deletes, key)
+ s.mu.Unlock()
+ return s.DirStore.Delete(ctx, key)
+}
+
+func (s *frStore) seen(keys []string, want func(string) bool) []string {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ var out []string
+ for _, k := range keys {
+ if want(k) {
+ out = append(out, k)
+ }
+ }
+ return out
+}
+
+// TestRetentionIgnoresForwardRows: the hub's forward row for shop brings
+// shop into no retention pass (spec §4.15 rev 2): shop's record is never
+// read and none of its versions is deleted. In the same pass blog, an
+// instance row with the same record and versions, has its two oldest
+// pruned. The record keeps 20, release.KeepFloor (the brief's keep 1 is
+// below the floor and refused); 22 versions leave two eligible.
+func TestRetentionIgnoresForwardRows(t *testing.T) {
+ ctx := context.Background()
+ dir := t.TempDir()
+ ds := release.NewDirStore(dir)
+ now := time.Now()
+ base := now.Add(-30 * 24 * time.Hour)
+ vname := func(i int) string { return "v" + string(rune('0'+i/10)) + string(rune('0'+i%10)) }
+ for _, app := range []string{"shop", "blog"} {
+ for i := 1; i <= 22; i++ {
+ stampKey(t, ds, dir, release.ManifestKey(fpOwner, app, vname(i)), base.Add(time.Duration(i)*time.Hour))
+ }
+ if err := release.SetRetention(ctx, ds, fpOwner, app, release.KeepFloor, "test", now); err != nil {
+ t.Fatal(err)
+ }
+ }
+ _, pub := retentionKeys(t)
+ reg := testRegistry(t)
+ fpPutForward(t, reg, fpForward(frForward, "home", fpOwner))
+ upsertRows(t, reg, registry.Route{Host: frNested, Kind: "instance", App: "blog", Account: fpOwner,
+ Version: "v22", Status: "ready"})
+
+ s := &frStore{DirStore: ds}
+ if err := retentionPass(ctx, s, &boxReports{status: release.NewDirStore(t.TempDir())}, pub, reg); err != nil {
+ t.Fatal(err)
+ }
+
+ if got := s.seen(s.gets, func(k string) bool { return k == release.RetentionKey(fpOwner, "shop") }); len(got) != 0 {
+ t.Errorf("shop's retention record was read %d times, want 0", len(got))
+ }
+ shopPrefix := release.AppPrefix(fpOwner, "shop")
+ if got := s.seen(s.deletes, func(k string) bool { return strings.HasPrefix(k, shopPrefix) }); len(got) != 0 {
+ t.Errorf("retention deleted under shop: %v", got)
+ }
+ for i := 1; i <= 22; i++ {
+ if _, _, err := ds.Get(ctx, release.ManifestKey(fpOwner, "shop", vname(i))); err != nil {
+ t.Errorf("shop %s pruned: %v", vname(i), err)
+ }
+ }
+ // The positive control, same pass: blog's record was read and its two
+ // oldest are gone.
+ if got := s.seen(s.gets, func(k string) bool { return k == release.RetentionKey(fpOwner, "blog") }); len(got) == 0 {
+ t.Error("blog's retention record was never read")
+ }
+ for _, gone := range []string{"v01", "v02"} {
+ if _, _, err := ds.Get(ctx, release.ManifestKey(fpOwner, "blog", gone)); err == nil {
+ t.Errorf("blog %s still present, want pruned", gone)
+ }
+ }
+ for _, kept := range []string{"v03", "v22"} {
+ if _, _, err := ds.Get(ctx, release.ManifestKey(fpOwner, "blog", kept)); err != nil {
+ t.Errorf("blog %s pruned, want kept: %v", kept, err)
+ }
+ }
+}
+
+// TestExpiredCanariesIgnoreForwardRows: a forward row on canary/x keeps its
+// Channel for display only, so the count skips it and reads no pointer for
+// shop. The positive control in the same call: blog's instance row on its
+// own expired canary/x is read and counted, so the answer is 1.
+func TestExpiredCanariesIgnoreForwardRows(t *testing.T) {
+ ctx := context.Background()
+ ds := release.NewDirStore(t.TempDir())
+ priv, pub := testCanaryKeys(t)
+ expired := time.Now().Add(-(release.CanaryTTL + 24*time.Hour))
+ writeBackdatedPointer(t, ds, priv, fpOwner, "shop", "canary/x", "v1", expired)
+ writeBackdatedPointer(t, ds, priv, fpOwner, "blog", "canary/x", "v1", expired)
+
+ reg := testRegistry(t)
+ fw := fpForward(frForward, "home", fpOwner)
+ fw.Channel = "canary/x"
+ fpPutForward(t, reg, fw)
+ upsertRows(t, reg, registry.Route{Host: frNested, Kind: "instance", App: "blog", Account: fpOwner,
+ Channel: "canary/x", Status: "ready"})
+ routes, err := reg.List()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ s := &countingStore{Store: ds}
+ got := countExpiredCanaries(ctx, routes, s, pub, time.Now())
+ if got == nil {
+ t.Fatal("count = nil (unknown), want 1 (blog only)")
+ }
+ if *got != 1 {
+ t.Errorf("count = %d, want 1 (blog only)", *got)
+ }
+ shopPrefix := release.AppPrefix(fpOwner, "shop")
+ for k, n := range s.gets {
+ if strings.HasPrefix(k, shopPrefix) {
+ t.Errorf("read %s %d times for a forward row", k, n)
+ }
+ }
+ if s.gets[release.ChannelKey(fpOwner, "blog", "canary/x")] != 1 {
+ t.Errorf("blog's pointer reads = %d, want 1", s.gets[release.ChannelKey(fpOwner, "blog", "canary/x")])
+ }
+}
+
+// TestReadersIgnoreInertForwardRows: the §4.15 selectors that pass with no
+// code change, pinned (preflight 3.4: each case is shown failing by a
+// one-line mutation in the report). Each is asked about an inert forward row
+// as root and the agent read it: from the registry, after PutForward.
+func TestReadersIgnoreInertForwardRows(t *testing.T) {
+ reg, dd := frEgressBox(t)
+ var fw registry.Route
+ for _, rt := range frRootRows(t, reg) {
+ if rt.Host == frForward {
+ fw = rt
+ }
+ }
+ if !fw.InertForward() {
+ t.Fatalf("fixture: the forward row read back is not inert: %+v", fw)
+ }
+
+ for _, tc := range []struct {
+ name string
+ got bool
+ }{
+ {"release.Adoptable", release.Adoptable(fw)},
+ {"release.SidecarAdoptable", release.SidecarAdoptable(fw)},
+ {"release.CapabilityRoute", release.CapabilityRoute(fw)},
+ {"restartEligible", restartEligible(fw)},
+ {"keepsBuildState, claims off", keepsBuildState(fw, false)},
+ {"keepsBuildState, claims on", keepsBuildState(fw, true)},
+ {"activator.ActivatorManaged", activator.ActivatorManaged(fw)},
+ } {
+ if tc.got {
+ t.Errorf("%s admits an inert forward row", tc.name)
+ }
+ }
+
+ // ops.FleetDBs: a database file at the forward host's default path is
+ // claimed by no row, so it is not replicated.
+ planted := provision.DefaultDBPath(dd, frForward)
+ if err := os.WriteFile(planted, []byte("x"), 0o600); err != nil {
+ t.Fatal(err)
+ }
+ dbs, err := ops.FleetDBs(reg, dd)
+ if err != nil {
+ t.Fatalf("FleetDBs: %v", err)
+ }
+ for _, p := range dbs {
+ if filepath.Clean(p) == filepath.Clean(planted) {
+ t.Errorf("FleetDBs replicates %s for the forward row", p)
+ }
+ }
+
+ // The staged-version sweep: the forward row pins nothing and does not
+ // stop the sweep, so a staged build nothing else names is removed.
+ opt := t.TempDir()
+ stageSweepVersion(t, opt, fpOwner, "v1", "shop", 48*time.Hour)
+ sweepStagedVersions(fakeLister{routes: []registry.Route{fw}}, opt, noGenerations(t), 6*time.Hour, time.Now())
+ if staged(t, opt, "v1") {
+ t.Error("staged-version sweep: v1 survived with only an inert forward row on the box")
+ }
+}
diff --git a/internal/host/retention.go b/internal/host/retention.go
index f1a6ff60f..c137e794a 100644
--- a/internal/host/retention.go
+++ b/internal/host/retention.go
@@ -48,7 +48,10 @@ func retentionPass(ctx context.Context, store release.Store, reports *boxReports
type appKey struct{ acct, app string }
pins := map[appKey]map[string]bool{}
for _, rt := range routes {
- if rt.App == "" {
+ // A forward row (fleet public routes spec §4.15) is the hub's name
+ // for an app a fleet box runs. The fleet box's versions are in no
+ // report this pass reads, so the row brings its app into no pass.
+ if rt.App == "" || rt.IsForward() {
continue
}
k := appKey{release.RouteAccount(rt), rt.App}