console: read fleet-corner acks only on a truly bounded page lister
Astra final re-review, controller ruling (cut). DirStore's ListPage reads and sorts every key under the prefix before it slices a page, and a store with no ListPage lists whole, so a fleet box could still make a relay-status request allocate memory for all its keys. relayConfigAcks now reads the fleet corner only when fleetAckPager admits the store: *release.S3Store (one ListObjectsV2 per page) or a test fake that opts in with boundedPages. On any other store the corner is never listed and its routes read awaiting delivery, as before #966. internal/release is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/console/fleetsecrets_relay_test.go+42 −0internal/console/relayacks_bound_test.go+84 −2internal/console/relayops.go+39 −14
CI failed — run details
Intent
<task-notification> <task-id>ac5aa318d110c155f</task-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2b517942-2259-467d-a8d0-994fd28c9e84/tasks/ac5aa318d110c155f.output</output-file> <status>completed</status> <summary>Agent "Final-review fix wave" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Status:** all five findings are fixed and committed. The census proposal is regenerated; the census reviewer's verdict is still owed. **Commits:** - af5698be console: bound the fleet-corner config-ack read (#966) - 214b8f9c rollout: a fresh box's relayed install is an install wait (#1061) - dd49a061 activator: pace install waits for the resident tick (#1061) - 9b61fc3e edge, console: pin fleet-corner ack delete; drop unread kick field - 3ec93ebe census: sr-followups final fixes (#1061) **Tests:** each new test failed against the old code and passes now. The full `internal/activator`, `internal/rollout` and `internal/release` runs pass, as do the filtered `internal/console` run (`Relay|ConfigAck|Fleet|Seal|Kick`), the door ACL matrix test and the two census tests in `internal/provision`. **Concerns:** - **No production-wired test for #2.** No test runs a real fresh box from the install through the planner to the activator. A release test proves `MaterializeHost` returns the new `ErrInstallRelayed` error, and a planner test proves that error becomes an install wait. The activator side was already covered by `TestJoinInstallWaitKeepsStepOpen`. - **#2 covers only the missing-link case.** A dangling link after a relay, or a failed install pass, still backs off as a crash, as the brief asked. - **#1 limits.** - A compromised box can still fill the 10,000-key listing cap or the per-request read cap with its own keys. That only hides acks in its own fleet, so its own app reads as awaiting delivery. - The 16 KiB read limit streams only on stores that support streaming reads. Test fakes without that are read whole first. - `restart_error` is cut to 512 bytes with no marker, so no new user-facing text needed copy review. **Report:** /home/paulca/amadan.net/carlos/platform/.claude/worktrees/sr-followups/.superpowers/sdd/2026-11-14-sr-followups/final-fix-report.md</result> <usage><subagent_tokens>171231</subagent_tokens><tool_uses>80</tool_uses><duration_ms>1220235</duration_ms></usage> </task-notification>
<task-notification> <task-id>b8zsez7pr</task-id> <tool-use-id>toolu_01NtCs62VpLKwjio3FuYszf3</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2b517942-2259-467d-a8d0-994fd28c9e84/tasks/b8zsez7pr.output</output-file> <status>completed</status> <summary>Background command "git push origin HEAD:refs/heads/sr-followups 2>&1 | tail -1; git diff -U10 74734bdf..HEAD > .superpowers/sdd/2026-11-14-sr-followups/final-fix.diff; git log --oneline 74734bdf..HEAD | cat; P=.superpowers/sdd/2026-11-14-sr-followups; timeout 3000 codex exec -m gpt-6-astra -c model_reasoning_effort=high -s read-only "Scoped re-review of the final fix wave on branch sr-followups, read-only (do not edit files, spawn reviewers or run full suites). Findings it addresses: your final ... [939 characters truncated] ... puts; weakened checks root relies on). End with exactly one verdict covering both parts: READY / READY AFTER FIXES / NOT READY." </dev/null > $P/final-rereview.txt 2>&1; f=$P/final-rereview.txt; n=$(grep -n '^codex$' $f | tail -1 | cut -d: -f1); sed -n "$n,\$p" $f | head -50" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 36.5 g CO₂e (4,533,911 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on sr-followups, 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/internal/console/fleetsecrets_relay_test.go b/internal/console/fleetsecrets_relay_test.go| index 3582c881a..fbe67f6c1 100644 |
| --- a/internal/console/fleetsecrets_relay_test.go |
| +++ b/internal/console/fleetsecrets_relay_test.go |
| @@ -665,6 +665,7 @@ func TestRelayReconcileReportsSealKeyFailures(t *testing.T) { |
| // keyed for a home host whose body names an away host, are all ignored. |
| func TestRelayStatusReadsFleetCornerAcks(t *testing.T) { |
| w := fsrRelayWorld(t, "code-fsr-acks", true) |
| + w.fx.srv.cfg.Releases = optInPages{w.fx.rel} |
| ctx := context.Background() |
| if status, body := postJSON(t, fleetsURL(w.fx, w.fx.sqid)+"/new", map[string]string{"name": "away", "bucket": "away-data"}, w.token); status != http.StatusOK { |
| t.Fatalf("create away = %d %v", status, body) |
| @@ -735,6 +736,7 @@ func TestRelayStatusReadsFleetCornerAcks(t *testing.T) { |
| // home's corner. |
| func TestRelayFleetAckNeedsTheRegistryPlacement(t *testing.T) { |
| w := fsrRelayWorld(t, "code-fsr-acks-reg", true) |
| + w.fx.srv.cfg.Releases = optInPages{w.fx.rel} |
| ctx := context.Background() |
| fskAway(t, w.fx) // cdef owns the fleet away |
| if status, body := postJSON(t, fleetsURL(w.fx, w.fx.sqid)+"/new", map[string]string{"name": "spare", "bucket": "spare-data"}, w.token); status != http.StatusOK { |
| @@ -802,3 +804,43 @@ func TestRelayFleetAckNeedsTheRegistryPlacement(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// TestRelayStatusSkipsFleetCornerOnADirStore (Astra final re-review): a |
| +// console whose store has a ListPage but not a truly bounded one (a |
| +// DirStore enumerates the prefix for each page) never lists the fleet |
| +// corner, which any fleet box can fill with keys. |
| +// An ack there is ignored and its route reads awaiting delivery, as |
| +// before #966. |
| +func TestRelayStatusSkipsFleetCornerOnADirStore(t *testing.T) { |
| + w := fsrRelayWorld(t, "code-fsr-acks-dir", true) |
| + ctx := context.Background() |
| + rec := &listRecorder{Store: w.fx.rel} |
| + w.fx.srv.cfg.Releases = rec |
| + rt := registry.Route{Host: "a.shop.example.com", Region: "fleet/home", Account: w.fx.sqid, App: "shop", Kind: "service", Status: "ready", Unit: "shop-a.service"} |
| + w.fx.addRoute(t, rt) |
| + fsrEnableRelay(t, w, "shop") |
| + issued := relayRecord(t, w.fx, "shop").IssuedSuffixes |
| + home := release.NewPrefixStore(w.fx.rel, "fleets/home/") |
| + if err := appconfig.WriteConfigAck(ctx, home, appconfig.ConfigAck{ |
| + Box: "box-1", Host: rt.Host, Shape: "unit", At: time.Now(), |
| + Restarted: true, RelaySuffixes: maps.Clone(issued), |
| + }); err != nil { |
| + t.Fatalf("seed ack: %v", err) |
| + } |
| + rec.mu.Lock() |
| + rec.prefixes = nil |
| + rec.mu.Unlock() |
| + |
| + _, out := getJSON(t, relayURL(w.fx, "shop"), w.token) |
| + rows := relayRouteRows(t, out) |
| + if got := str(t, rows[rt.Host], "delivery"); got != "written, awaiting delivery" { |
| + t.Fatalf("delivery = %q, want the fleet-corner ack unread on an unbounded store", got) |
| + } |
| + rec.mu.Lock() |
| + defer rec.mu.Unlock() |
| + for _, p := range rec.prefixes { |
| + if strings.HasPrefix(p, "fleets/") { |
| + t.Fatalf("listed %q: a console without bounded pages listed the fleet corner", p) |
| + } |
| + } |
| +} |
diff --git a/internal/console/relayacks_bound_test.go b/internal/console/relayacks_bound_test.go| index 4472b2f76..e0ecc20bf 100644 |
| --- a/internal/console/relayacks_bound_test.go |
| +++ b/internal/console/relayacks_bound_test.go |
| @@ -6,6 +6,7 @@ import ( |
| "encoding/json" |
| "fmt" |
| "io" |
| + "slices" |
| "strings" |
| "sync" |
| "testing" |
| @@ -36,6 +37,10 @@ func (c *ackCountingStore) Open(ctx context.Context, key string) (io.ReadCloser, |
| return &countingRC{rc: rc, n: func(n int) { c.mu.Lock(); c.read[key] += n; c.mu.Unlock() }}, etag, nil |
| } |
| +// boundedPages opts the counting store in to the fleet-corner read |
| +// (fleetAckPager), as an S3 store is. |
| +func (c *ackCountingStore) boundedPages() {} |
| + |
| func (c *ackCountingStore) Get(ctx context.Context, key string) ([]byte, string, error) { |
| c.mu.Lock() |
| c.gets++ |
| @@ -91,7 +96,7 @@ func TestFleetAcksOversizedObjectIgnoredUnread(t *testing.T) { |
| RestartError: strings.Repeat("é", 2*fleetAckTextMax), |
| }) |
| s := &Server{cfg: Config{Releases: st}} |
| - acks, err := s.relayFleetAcksUnder(ctx, boundPrefix, func(h string) bool { return h == "a.example.com" }, 10) |
| + acks, err := s.relayFleetAcksUnder(ctx, st, boundPrefix, func(h string) bool { return h == "a.example.com" }, 10) |
| if err != nil { |
| t.Fatalf("relayFleetAcksUnder: %v", err) |
| } |
| @@ -124,7 +129,7 @@ func TestFleetAcksStopAtReadCap(t *testing.T) { |
| putAck(t, st, boundPrefix+box+"/other.example.com.json", appconfig.ConfigAck{Box: box, Host: "other.example.com", Shape: "unit"}) |
| } |
| s := &Server{cfg: Config{Releases: st}} |
| - acks, err := s.relayFleetAcksUnder(ctx, boundPrefix, func(h string) bool { return h == "a.example.com" }, 4) |
| + acks, err := s.relayFleetAcksUnder(ctx, st, boundPrefix, func(h string) bool { return h == "a.example.com" }, 4) |
| if err != nil { |
| t.Fatalf("relayFleetAcksUnder: %v", err) |
| } |
| @@ -166,3 +171,80 @@ func TestListBoundedStopsAtLimit(t *testing.T) { |
| t.Fatal("cutText does not cut on a rune boundary") |
| } |
| } |
| + |
| +// pageOf answers ListPage over st: its own where it has one, else a |
| +// whole List cut to the page. |
| +func pageOf(ctx context.Context, st release.Store, prefix, after string, limit int) ([]string, error) { |
| + if pl, ok := st.(release.PageLister); ok { |
| + return pl.ListPage(ctx, prefix, after, limit) |
| + } |
| + keys, err := st.List(ctx, prefix) |
| + if err != nil { |
| + return nil, err |
| + } |
| + slices.Sort(keys) |
| + var out []string |
| + for _, k := range keys { |
| + if k > after && (limit <= 0 || len(out) < limit) { |
| + out = append(out, k) |
| + } |
| + } |
| + return out, nil |
| +} |
| + |
| +// optInPages is a store that opts in to the fleet-corner read, standing |
| +// in for an S3 store in the relay-status tests. |
| +type optInPages struct{ release.Store } |
| + |
| +func (optInPages) boundedPages() {} |
| + |
| +func (o optInPages) ListPage(ctx context.Context, prefix, after string, limit int) ([]string, error) { |
| + return pageOf(ctx, o.Store, prefix, after, limit) |
| +} |
| + |
| +// listRecorder is a store with a ListPage, as DirStore has, that records |
| +// every listing prefix asked of it and does not opt in. |
| +type listRecorder struct { |
| + release.Store |
| + mu sync.Mutex |
| + prefixes []string |
| +} |
| + |
| +func (r *listRecorder) note(prefix string) { |
| + r.mu.Lock() |
| + r.prefixes = append(r.prefixes, prefix) |
| + r.mu.Unlock() |
| +} |
| + |
| +func (r *listRecorder) List(ctx context.Context, prefix string) ([]string, error) { |
| + r.note(prefix) |
| + return r.Store.List(ctx, prefix) |
| +} |
| + |
| +func (r *listRecorder) ListPage(ctx context.Context, prefix, after string, limit int) ([]string, error) { |
| + r.note(prefix) |
| + return pageOf(ctx, r.Store, prefix, after, limit) |
| +} |
| + |
| +// TestFleetAckPagerOnlyTrulyBounded (Astra final re-review): the fleet |
| +// corner is read only through a store that lists one bounded page per |
| +// request. The S3 store does; DirStore enumerates the prefix for each |
| +// page, and a store with no ListPage lists whole, so neither may. |
| +func TestFleetAckPagerOnlyTrulyBounded(t *testing.T) { |
| + dir := release.NewDirStore(t.TempDir()) |
| + for _, c := range []struct { |
| + name string |
| + store release.Store |
| + want bool |
| + }{ |
| + {"S3", &release.S3Store{}, true}, |
| + {"opted-in fake", optInPages{dir}, true}, |
| + {"DirStore", dir, false}, |
| + {"prefix store", release.NewPrefixStore(dir, "x/"), false}, |
| + {"no ListPage", struct{ release.Store }{dir}, false}, |
| + } { |
| + if _, ok := fleetAckPager(c.store); ok != c.want { |
| + t.Errorf("%s: fleetAckPager = %t, want %t", c.name, ok, c.want) |
| + } |
| + } |
| +} |
diff --git a/internal/console/relayops.go b/internal/console/relayops.go| index 08972b04f..1fdc144fa 100644 |
| --- a/internal/console/relayops.go |
| +++ b/internal/console/relayops.go |
| @@ -1375,7 +1375,8 @@ func (s *Server) relayHeartbeats(ctx context.Context) ([]relay.Heartbeat, error) |
| // before a single Get is issued, so a status call costs a List per place |
| // plus a Get per THIS APP's route, never a Get per ack in the whole fleet |
| // (review finding 2026-09-07). The fleet corner is fleet-writable, so its |
| -// read is bounded besides (relayFleetAcksUnder): it lists at most |
| +// read is bounded besides (relayFleetAcksUnder): it is read only through a |
| +// store that lists in truly bounded pages (fleetAckPager), lists at most |
| // fleetAckListMax keys, not the whole corner, and bounds objects read, |
| // bytes per object and the free text an ack keeps. |
| func (s *Server) relayConfigAcks(ctx context.Context, acct, app string, hosts map[string]string) ([]appconfig.ConfigAck, error) { |
| @@ -1393,6 +1394,13 @@ func (s *Server) relayConfigAcks(ctx context.Context, acct, app string, hosts ma |
| if !onFleet { |
| return out, nil |
| } |
| + pager, ok := fleetAckPager(s.cfg.Releases) |
| + if !ok { |
| + // Only a store that lists in truly bounded pages may list the |
| + // fleet-writable corner (Astra final re-review): its routes read |
| + // as awaiting delivery, as before #966. |
| + return out, nil |
| + } |
| fleet, err := s.relayAckFleet(acct, app) |
| if err != nil { |
| // Fail closed: the fleet corner is unread, so its routes read as |
| @@ -1412,7 +1420,7 @@ func (s *Server) relayConfigAcks(ctx context.Context, acct, app string, hosts ma |
| if eligible == 0 { |
| return out, nil |
| } |
| - more, err := s.relayFleetAcksUnder(ctx, "fleets/"+fleet+"/"+configAckPrefix, func(host string) bool { |
| + more, err := s.relayFleetAcksUnder(ctx, pager, "fleets/"+fleet+"/"+configAckPrefix, func(host string) bool { |
| return hosts[host] == fleet |
| }, s.fleetAckReadCap(fleet, eligible)) |
| if err != nil { |
| @@ -1462,8 +1470,8 @@ func (s *Server) fleetAckReadCap(fleet string, eligible int) int { |
| // maxReads matching objects are read (the rest are left unread), each |
| // through a fleetAckMaxBytes limit (a bigger one is skipped, not an error), |
| // and the free text an ack keeps is cut to fleetAckTextMax bytes. |
| -func (s *Server) relayFleetAcksUnder(ctx context.Context, prefix string, want func(host string) bool, maxReads int) ([]appconfig.ConfigAck, error) { |
| - keys, err := listBounded(ctx, s.cfg.Releases, prefix, fleetAckListMax) |
| +func (s *Server) relayFleetAcksUnder(ctx context.Context, pager release.PageLister, prefix string, want func(host string) bool, maxReads int) ([]appconfig.ConfigAck, error) { |
| + keys, err := listBounded(ctx, pager, prefix, fleetAckListMax) |
| if err != nil { |
| return nil, err |
| } |
| @@ -1504,17 +1512,34 @@ func (s *Server) relayFleetAcksUnder(ctx context.Context, prefix string, want fu |
| return out, nil |
| } |
| -// listBounded lists at most limit keys under prefix: by page where the |
| -// store can, else whole and cut. |
| -func listBounded(ctx context.Context, st release.Store, prefix string, limit int) ([]string, error) { |
| - pl, ok := st.(release.PageLister) |
| - if !ok { |
| - keys, err := st.List(ctx, prefix) |
| - if len(keys) > limit { |
| - keys = keys[:limit] |
| - } |
| - return keys, err |
| +// boundedPager marks a store whose ListPage with a limit costs one bounded |
| +// request, whatever the prefix holds. *release.S3Store is the production |
| +// one (ListObjectsV2 with MaxKeys); a test fake opts in by implementing it. |
| +// DirStore does not: its ListPage reads and sorts every key under the |
| +// prefix before it slices a page, and a store with no ListPage at all |
| +// lists whole. |
| +type boundedPager interface { |
| + release.PageLister |
| + boundedPages() |
| +} |
| + |
| +// fleetAckPager is st's truly bounded page lister, and false for any store |
| +// that cannot list one page without enumerating the prefix. The fleet |
| +// corner is read only through one (relayConfigAcks): any fleet box can |
| +// fill that prefix with keys. |
| +func fleetAckPager(st release.Store) (release.PageLister, bool) { |
| + switch p := st.(type) { |
| + case *release.S3Store: |
| + return p, true |
| + case boundedPager: |
| + return p, true |
| } |
| + return nil, false |
| +} |
| + |
| +// listBounded lists at most limit keys under prefix through pl, a truly |
| +// bounded page lister (fleetAckPager), one page at a time. |
| +func listBounded(ctx context.Context, pl release.PageLister, prefix string, limit int) ([]string, error) { |
| var keys []string |
| after := "" |
| for len(keys) < limit { |