carlos / platform Public

Console plans: Astra round 7 fixes (perf-2, operator-pages)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev f760262b9c504259eeaa2456c0cb8ec419307cb9 parent f72474f
2 files changed, +23 −10
  • docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md +17 −7
  • docs/superpowers/plans/2026-10-25-operator-pages.md +6 −3

CI passed — run details

diff --git a/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md b/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md
index 86fd6f0f9..a881db945 100644
--- a/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md
+++ b/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md
@@ -256,7 +256,7 @@ Spec §2.4 C rows "Settings, `populateAppSettings`", "`appDeployEmpty`" and "`en
- Everything that needs local state, the registry or the clock is joined per request, in the screen's fill, from the cached facts. Each later task names, per loader, what is cached and what is joined.
- `func viewPeek[A any, T viewCloner[T]](c *viewCache, key viewKey, window time.Duration, load viewLoader[A, T], arg A) (viewResult[T], bool)`: never blocks. A valid entry returns a clone and `true`, with `Stale` when older than `window`, in which case a refresh is started unless one is running at the entry's current generation. A missing or invalid entry returns `false` and starts a load unless one is running at the current generation.
- `func viewWait[A any, T viewCloner[T]](ctx context.Context, c *viewCache, key viewKey, window time.Duration, load viewLoader[A, T], arg A) (viewResult[T], error)`: a valid entry returns a clone at once; otherwise joins the load running at the current generation or starts one, and waits for it or for `ctx`.
- - read sets: every entry carries `type readSet struct { keys map[string]bool; prefixes []string }`, the object keys its load read and the prefixes it listed, filled while the load runs by Task 8's tracker through the load's context (`withReadSet(ctx, *readSet) context.Context`). An entry keeps two: the **published** set, of the value it is serving, and the **in-flight** set, of the load running now. A load starts with an empty in-flight set. Only a successful publish replaces the published set with the in-flight one. A failed or discarded load drops its in-flight set and leaves the published set alone. *(Astra round 4, finding 1: a refresh that has not yet reached a key must not hide that the value being served depends on it.)*
+ - read sets: every entry carries `type readSet struct { keys map[string]bool; prefixes []string }`, the object keys its load read and the prefixes it listed, filled while the load runs by Task 8's tracker through the load's context (`withReadSet(ctx, *readSet) context.Context`). Read sets are bounded and stay sound. **Subsumption:** a listed prefix covers every key under it, so a key under a prefix the set already holds is not recorded, and adding a prefix removes the keys it covers. A log or error window, which lists its app's log prefix before fetching chunks (`applog/read.go:38-106`), therefore records a few prefixes, not one key per chunk. **Cap:** past `readSetMax = 256` exact keys, the set collapses its keys into their parent prefixes (dropping the last path segment), repeating until it is under the cap. Over-approximating a dependency only ever invalidates more, never less. A test checks that the published and in-flight sets of every entry together stay under the cap. *(Astra round 7, finding 3.)* An entry keeps two: the **published** set, of the value it is serving, and the **in-flight** set, of the load running now. A load starts with an empty in-flight set. Only a successful publish replaces the published set with the in-flight one. A failed or discarded load drops its in-flight set and leaves the published set alone. *(Astra round 4, finding 1: a refresh that has not yet reached a key must not hide that the value being served depends on it.)*
- `func (c *viewCache) touched(key string) []viewKey`: for every entry whose published or in-flight read set holds `key` or a prefix of it (an entry exists, with its set, from the moment its first load starts), bump its generation and mark it invalid; a load that started at an older generation, first load or refresh, then discards its result. Returns the entries it invalidated.
- `func (c *viewCache) reread(ctx context.Context, keys []viewKey) (failed int)`: for each key that has an entry, start a load at its current generation; all run concurrently under `ctx`, and `reread` waits for them. A success publishes; a failure leaves the entry invalid and counts in `failed`.
- `func (c *viewCache) reset()`: drops every entry under the cache's lock, after `waitBackground` (a load that ends afterwards finds no entry and discards its result).
@@ -278,6 +278,7 @@ The rules the implementation keeps:
- `TestLoadInFlightAtAWriteNeverPublishes`: two sub-tests. *First load:* a peek on a miss starts a load that records key `k` in its read set, reads value A and blocks; `touched("k")` then `reread` with a loader now answering B; release the first load; the entry holds B, never A, at any point a peek can see. *Refresh:* the same with a warm stale entry whose refresh reads A.
- `TestWriteToADependencyTheRefreshHasNotReachedInvalidates`: a warm entry whose published set holds `a` and `b`; a refresh starts, reads `a` and blocks before `b`; `touched("b")` invalidates the entry (from the published set), and the refresh, released, discards its result.
- `TestWriteAfterAFailedRefreshStillInvalidates`: a warm entry whose published set holds `b`; a refresh that fails after reading only `a`; the entry still serves its old value (stale) with its published set intact; `touched("b")` invalidates it.
+ - `TestReadSetsSubsumeAndStayBounded`: a load that lists `a/` then reads 2,000 keys under it records one prefix; a load that reads 2,000 unlisted keys is collapsed under `readSetMax`; in both cases `touched` of any one of those keys invalidates the entry.
- `TestTouchedCoversExactKeysAndListedPrefixes`: three entries, one that read `a/x`, one that listed `a/`, one that read `b/y`; `touched("a/x")` invalidates the first two and not the third; `touched("a/z")` invalidates only the lister.
- `TestRereadFailureLeavesEntryInvalid`: the re-read fails; `failed == 1`; the next peek is a miss, not the pre-write value.
- `TestFixtureClockDrivesExpiry`: on `newPerfFixture`, warm an entry; move `fx.clock` past its window; the next peek reports it stale and starts exactly one refresh.
@@ -288,7 +289,7 @@ The rules the implementation keeps:
- `TestViewCacheEvictsLeastRecentlyUsed`: `max` 3; four keys loaded; the least recently peeked is gone; an entry mid-load is not evicted.
- `TestViewValuesAreCopies`: changing a slice element of a peeked value does not change the next peek's value.
- `TestAsOfText`: 20 s → CPF-20 with CPF-21; 60 s → CPF-22; 150 s → CPF-23 with 2; 1 h → CPF-24; 3 h → CPF-25 with 3 (approved text verbatim).
-- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestView|TestLoadInFlight|TestWriteToADependency|TestWriteAfterAFailedRefresh|TestTouched|TestRereadFailure|TestFixtureClockDrivesExpiry|TestWriteAfterColdReset|TestBackgroundWait|TestHungLoad|TestAsOfText' -count=1 -race`. Expected: FAIL.
+- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestView|TestLoadInFlight|TestWriteToADependency|TestWriteAfterAFailedRefresh|TestReadSetsSubsume|TestTouched|TestRereadFailure|TestFixtureClockDrivesExpiry|TestWriteAfterColdReset|TestBackgroundWait|TestHungLoad|TestAsOfText' -count=1 -race`. Expected: FAIL.
- [ ] **Step 3: Implement**; add CPF-20 to CPF-25 to `consolePerfCopyBuilt`; set `perfQuiesce` and the fixture clock.
- [ ] **Step 4: Run** Step 2's command and `go test . -run TestConsolePerfCopy -count=1`. Expected: PASS.
- [ ] **Step 5: Commit**, message `console: in-process view cache: view-triggered single-flight refresh, read sets, generations that cover in-flight loads, immutable values`, ending with the Co-Authored-By line.
@@ -493,19 +494,21 @@ Spec §2.4 C row `instances.Report`: HTTP to the app host, 30 s cache, blocks up
**Interfaces:**
- Produces:
- - `func viewFilterKey(prefix string, filter any) string`: `prefix + "?" +` the hex SHA-256 of the canonical JSON encoding of the effective filter the loader runs with (`applog.Filter` after `browserLogsFilterFromQuery` and the page's default window; the errors, availability and analytics option structs after their own parsing). It keys on what the read will actually do, losslessly: no trimming, no truncation, no parameter the loader ignores. Two requests share an entry exactly when their loads would read the same thing. *(Astra round 2, finding 5.)* Time-relative filters ("the last hour") are made absolute by the parser; the key then carries the window's start rounded down to `liveWindow`, so a view within the same 30 s shares the entry and a later one does not.
+ - `func viewFilterKey(prefix string, filter any) string`: `prefix + "?" +` the hex SHA-256 of the canonical JSON encoding of the effective filter the loader runs with (`applog.Filter` after `browserLogsFilterFromQuery` and the page's default window; the errors, availability and analytics option structs after their own parsing). It keys on what the read will actually do, losslessly: no trimming, no truncation, no parameter the loader ignores. Two requests share an entry exactly when their loads would read the same thing. *(Astra round 2, finding 5.)* Time-relative filters are resolved against one clock reading per window, before the key is hashed and before the loader runs. Both endpoints use it: `since` and `until`, as `since=24h&until=1h` in the errors and availability parser (`errorsview.go:177`) and its log and analytics equivalents. That reading is `viewNow = s.now().Truncate(liveWindow)`. Every request inside one 30 s window then resolves the same relative filter to the same absolute range, shares one entry, and the loader reads that range. Absolute endpoints are hashed as given. *(Astra round 7, finding 4.)*
- `func (s *Server) logWindowView(ctx context.Context, p *page, mode viewMode, sqid, app string, f applog.Filter, key string) (logWindow, error)`: the first window of rows for a filter (`applog.ReadWindow`, `{sqid, app, viewFilterKey("logs", f)}`, `liveWindow`, a `logWindow` with `viewClone`), shared by the page and by `/logs/data`. `handleAppLogs` reads it in `viewCached` mode: a miss renders the table empty with `data-load-now` on the form, and the existing script (`app_logs.html:66-196`) calls its fetch of `/logs/data` once at load without starting to follow. `handleAppLogsData` without a `cursor` reads the same entry in `viewBlocking` mode, so it joins the load the page started instead of reading the window again; with a `cursor` (following) it reads as today, uncached. *(Astra finding 10.)*
- the host picker (`ListRecordHosts`, `{sqid, app, partRecordHosts}`, `liveWindow`) as its own part `logs-hosts`: the `<select name="host">` element alone, from the template's existing markup with the current `?host=` selected. On a miss, the page renders the picker from the routes it already has (local) and a placeholder for the select. The loader replaces it with the full list; with JavaScript off, a reload shows it. The select keeps its `name`, so the filter form submits it as before, and it holds no script. *(Astra round 3, finding 4.)*
- parts `errors`, `availability`, `analytics`; reads through `viewGet`: `telemetry.Resolve` (`{sqid, app, partTelemetry}`, `writtenWindow`; the error-level and analytics-setting doors re-read it, Task 8), `apperr.ReadWindow` and the platform-stream `applog.ReadWindow` (`viewFilterKey("errors", …)`, `viewFilterKey("availability", …)`, `liveWindow`), `analytics.ReadRange` (`viewFilterKey("analytics", …)`, `liveWindow`).
- [ ] **Step 1: Write the failing tests:**
- `TestLogsWarmMakesNoRemoteCalls`.
+ - `TestLargeHistoryEmptySearchesStayBounded`: 2,000 log chunks; 50 distinct searches that match nothing, each a cached entry; every entry's read set stays under `readSetMax`, and the 50 together hold no more than a few prefixes each; a new chunk written under the app's log prefix invalidates all 50.
- `TestColdLogsFillsTheHostPicker`: with a record-only host (an instance record with no route), the cold page's picker lacks it; `getAssembled` of the page has it in the `select`, still `name="host"`; selecting it (`?host=<it>`) is preserved in the assembled select.
- `TestColdLogsReadTheWindowOnce`: fresh fixture; GET `/apps/kass/logs` (cold: `data-load-now`, no rows); GET `/logs/data` with the page's own query and no cursor; across both, the log prefix's listings appear in `Keys()` exactly as many times as one `ReadWindow` makes them; `/logs/data` answers the rows.
- `TestLogsFollowStillReadsLive`: a `/logs/data` with a cursor reads the store each time.
- `TestErrorsAvailabilityAnalyticsWarmMakeNoCalls`.
+ - `TestRelativeFilterKeyIsStableInsideOneWindow`: `fx.clock` advancing one second per request through one 30 s window, ten GETs of `?since=24h&until=1h` on Errors (and the same on Logs): one entry and one load; the first request after the window boundary is a new entry.
- `TestFilterKeysAreLossless`: `?since=1h&host=a` and `?host=a&since=1h&junk=x` share one entry (same effective filter); `text=failed` and `text=%20failed` do not; two 300-byte searches that differ only in their last byte do not.
-- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestLogsWarm|TestColdLogsFillsTheHostPicker|TestColdLogsRead|TestLogsFollow|TestErrorsAvailabilityAnalytics|TestFilterKeysAreLossless|TestInstanceCreateRefreshes' -count=1`. Expected: FAIL.
+- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestLogsWarm|TestColdLogsFillsTheHostPicker|TestColdLogsRead|TestLogsFollow|TestErrorsAvailabilityAnalytics|TestFilterKeysAreLossless|TestRelativeFilterKeyIsStable|TestLargeHistoryEmptySearches|TestInstanceCreateRefreshes' -count=1`. Expected: FAIL.
- [ ] **Step 3: Implement.** Existing tests run unchanged on the untracked fixture; run the nav plan's `TestLogsToolbar` on `newPerfFixture` too, through `getAssembled`. Remove `TestInstanceCreateRefreshesHostsAndEnvs`' skip (Task 8) once Environments is cached in Task 13, if it is not yet. Update claim probes whose markers moved.
- [ ] **Step 4: Run** Step 2's command, `go test ./internal/console/ -run 'TestAppLogs|TestLogsToolbar|TestAppErrors|TestAppAvailability|TestAppAnalytics|TestErrorLevel|TestAnalyticsSetting|TestTelemetryHints|TestClaimRead' -count=1`, and the walk with `CI=1`.
- [ ] **Step 5: Delete** the `over:` records for `/logs`, `/errors`, `/availability`, `/analytics`; walk (PASS); commit, message `console: Logs, Errors, Availability and Analytics read through the view cache; the first log window is read once`, ending with the Co-Authored-By line.
@@ -520,16 +523,22 @@ Spec §2.4 C rows `settingsGates` (cache), `aliasReadings`/`LoadBoxes` (cache, o
- Test: `internal/console/viewscreens_test.go` (extend)
**Interfaces:**
-- Produces: parts `settings` (its `Gate` reads `?section=` and refuses one not in `appSettingsSections`, as the page refuses the path) and `domain-readings` (the box readings on Domains alone, deferred on a miss of `partBoxes` while the rest of Domains renders). Reads through `viewGet`, keyed `{sqid, app, …}` with `writtenWindow` unless marked live: `settingsGates`' records (`partGates`; the plan limits shown beside them, `EffectiveLimits`, are SQLite and joined per request), the claims, without `ClaimCache` (the server-owned incremental cache at `domains/claimcache.go:47`, which a restricted loader can neither be handed nor capture): an index entry `{"", "", partClaims}` (`writtenWindow`, loader `loadClaimIndex`: one `ListMod` of the claims prefix, keys and modification times), and one entry per claim at the modification time listed, `{"", "", "claim:" + key + "@" + modtime}` (`writtenWindow`, loader `loadClaim`: one `Get`). Per request the index selects the entries; an unchanged claim is a hit, and a changed one has a new modification time, so it is a new entry and one `Get`. That is `ClaimCache`'s read cost, one listing plus a `Get` per changed claim, kept by the view cache instead of a second cache. Superseded entries age out by the LRU. `ClaimCache` stays for its other callers (the domain doors and passes). *(Astra round 6, finding 1.)*, `warmRecords` (`partCertWarm`, live), catch-all facts, not views (Astra round 4, finding 4): the release manifest each catch-all claim derives from (`{sqid, app, partCatchall}`, `writtenWindow`, loader `loadCatchallManifests`), and each proof TXT answer (`{"", "", "dns:" + name}`, `liveWindow`, loader `loadCatchallTXT` through `env.LookupTXT`: DNS is outside the object store, so its entry has no read set and is refreshed by its window alone, which is the same freshness the live check has today). The catch-all rows (`domaincatchall.go:279-320`) are built per request from those facts, the current `partBoxes` readings, the certificate records and `s.now()`, `appDeployEmpty` (`partDeployEmpty`), `envCards` (`partEnvs`: the config bundles and store records only; the route-derived host list each card shows is joined per request from `p.Detail.Routes`, rule (a)), `storeCard` and `storeEnvCards` (`partStore`), `mailCard` (`partMail`), `featuresCard` (`partFeatures`), `telemetry.Resolve` on `errors-analytics` (Task 12's key), `loadSwapPolicy` (`partSwap`); `aliasReadings` reads the shared `partBoxes` entry. Placement is local and stays direct. The pipeline section reads the core's pipeline (Task 9).
+- Produces: parts `settings` (its `Gate` reads `?section=` and refuses one not in `appSettingsSections`, as the page refuses the path) and `domain-readings` (the box readings on Domains alone, deferred on a miss of `partBoxes` while the rest of Domains renders). Reads through `viewGet`, keyed `{sqid, app, …}` with `writtenWindow` unless marked live: `settingsGates`' records (`partGates`; the plan limits shown beside them, `EffectiveLimits`, are SQLite and joined per request), the claims, without `ClaimCache` (the server-owned incremental cache at `domains/claimcache.go:47`, which a restricted loader can neither be handed nor capture), but with its exact read cost and its safety bound:
+ - an index entry `{"", "", partClaims}` (`writtenWindow`, loader `loadClaimIndex`: one `ListMod` of the claims prefix, keys and modification times, plus the listing's `ReadAt`);
+ - one entry per claim at the modification time listed, `{"", "", "claim:" + key + "@" + modtime}` (loader `loadClaim`: one `Get`). These bodies are immutable facts, because the key names the version. They have no window and are never refreshed by age; they are reused for as long as the index lists that modification time, and leave only by LRU eviction. The one exception is `ClaimCache`'s own bound, `modSettle` (`claimcache.go:63-73`). A claim whose listed modification time is within `modSettle` of the listing's `ReadAt` cannot be trusted as an unchanged-marker, because S3's stamps have one-second granularity. Its entry is used for that view but published with window zero, so the next view fetches it again. *(Astra round 7, finding 2.)*
+ - **The index fills what it selects.** A load of the index, whether a view's or a write's re-read, ends by loading, concurrently and before it publishes, every claim entry its listing selects that the cache does not hold: the changed claim's new modification time, or a first attachment's new key. Those child loads are recorded in the index load's own read set too. So the write's re-read of the index leaves every entry the redirect will select already loaded, and the redirect makes no read. This is `ClaimCache`'s incremental fold (`claimcache.go:137-171`) expressed as cache entries: one listing plus one `Get` per changed or new claim. Superseded entries age out by the LRU. `ClaimCache` stays for its other callers (the domain doors and passes). *(Astra rounds 6 and 7, finding 1.)*, `warmRecords` (`partCertWarm`, live), catch-all facts, not views (Astra round 4, finding 4): the release manifest each catch-all claim derives from (`{sqid, app, partCatchall}`, `writtenWindow`, loader `loadCatchallManifests`), and each proof TXT answer (`{"", "", "dns:" + name}`, `liveWindow`, loader `loadCatchallTXT` through `env.LookupTXT`: DNS is outside the object store, so its entry has no read set and is refreshed by its window alone, which is the same freshness the live check has today). The catch-all rows (`domaincatchall.go:279-320`) are built per request from those facts, the current `partBoxes` readings, the certificate records and `s.now()`, `appDeployEmpty` (`partDeployEmpty`), `envCards` (`partEnvs`: the config bundles and store records only; the route-derived host list each card shows is joined per request from `p.Detail.Routes`, rule (a)), `storeCard` and `storeEnvCards` (`partStore`), `mailCard` (`partMail`), `featuresCard` (`partFeatures`), `telemetry.Resolve` on `errors-analytics` (Task 12's key), `loadSwapPolicy` (`partSwap`); `aliasReadings` reads the shared `partBoxes` entry. Placement is local and stays direct. The pipeline section reads the core's pipeline (Task 9).
- [ ] **Step 1: Write the failing tests:**
- - `TestClaimsCostOneListingAndChangedGets`: 20 claims, Domains warm; change one claim through its door; between the warm view and the next Domains view (the write's re-read included) the claims prefix is listed once and one claim is fetched, the same count an uncached `ClaimCache` makes for one changed claim over the same store (measured in the test).
+ - `TestClaimsCostOneListingAndChangedGets`: 20 claims, Domains warm; change one claim through its door; inside the POST the claims prefix is listed once and the changed claim fetched once; the redirect's Domains view makes zero S3 requests. That is the count an uncached `ClaimCache` makes for one changed claim over the same store, measured in the test.
+ - `TestFirstAttachmentIsLoadedBeforeTheRedirect`: Domains warm with no claim for `shop.example.com`; attach it; the redirect's view shows it with zero S3 requests (the index's re-read loaded the new claim entry).
+ - `TestUnchangedClaimsAreNotRefetchedAfterTheWindow`: 20 settled claims, Domains warm; move `fx.clock` past `writtenWindow` with no store change; the next view re-lists the index once and fetches no claim body.
+ - `TestJustWrittenClaimIsFetchedAgain`: a claim whose modification time is within `modSettle` of the listing: the first view fetches it; the next view, with the listing unchanged, fetches it once more; after `modSettle` has passed, it is reused.
- `TestEverySettingsSectionWarmMakesNoCalls` (one sub-test per key of `appSettingsSections`, with the populated seeds).
- `TestDomainsArrivesBeforeBoxReadings`: cold, latency on, 50 fresh box snapshots seeded: Domains answers within 150 ms with a `data-part` for `domain-readings`.
- `TestDomainAttachShowsTheNewDomain`: warm Domains; attach `shop.example.com`; the redirect target shows it with zero S3 calls.
- `TestPipelineSaveShowsTheNewPipeline`: warm the pipeline section; save a changed pipeline; the redirect target shows it with zero S3 calls.
- `TestRenameFailureRerendersWithoutStaleData`: the existing rename-failure re-render (`renderAppSettingsForm`) still shows its message and the current values.
-- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestClaimsCostOneListing|TestEverySettingsSection|TestDomainsArrives|TestDomainAttachShows|TestPipelineSaveShows|TestRenameFailureRerenders' -count=1`. Expected: FAIL.
+- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestClaimsCostOneListing|TestFirstAttachmentIsLoaded|TestUnchangedClaimsAreNotRefetched|TestJustWrittenClaimIsFetched|TestEverySettingsSection|TestDomainsArrives|TestDomainAttachShows|TestPipelineSaveShows|TestRenameFailureRerenders' -count=1`. Expected: FAIL.
- [ ] **Step 3: Implement.** Existing settings tests run unchanged on the untracked fixture; run the nav plan's `TestAppSettingsSectionRoutes` and `TestErrorsAndAnalyticsSection` on `newPerfFixture` too. Remove the skips of `TestShipRefreshesDeployEmpty` and `TestInstanceCreateRefreshesHostsAndEnvs` (Task 8). Update the `settings/{section}` claim probe if its marker moved.
- [ ] **Step 4: Run** Step 2's command, `go test ./internal/console/ -run 'TestAppSettings|TestBucketless|TestDomain|TestAppGate|TestAppRateLimit|TestStoreDestroy|TestPipeline|TestAppSwap|TestControlPlane|TestErrorsAndAnalyticsSection|TestClaimRead' -count=1`, and the walk with `CI=1`.
- [ ] **Step 5: Delete** the `over:` records for the settings sections and `/settings`; walk (PASS); commit, message `console: settings sections read through the view cache; box readings deferred on Domains`, ending with the Co-Authored-By line.
@@ -635,6 +644,7 @@ Spec §2.4 C last row: `SetMaxOpenConns(1)` (`store.go:99`, `store_gate.go:1828`
- **Spec coverage.** §2.4 C, row by row: account manifest (Task 2, now off the response path), `SetLastAccount` (Task 2), `AccountsFor` and `registry.List` once (Task 2), `assembleChannels` (Task 9), `dnsTargets` fold (Task 3), Overview `Versions` bounded and cached (Tasks 3, 9), pipeline once (Task 3), `instances.Report` (Task 11), `populateAppSettings` (Task 4), `appDeployEmpty` (Task 4), `settingsGates` (Task 13), `aliasReadings` (Task 13), `envCards` + `storeEnvCards` (Task 4), console DB (Task 16). Concurrency as a fallback: part endpoints start every missing load before waiting (Task 7). §2.4 A: serve cached, background refresh single flight (Task 6), miss renders a placeholder (Tasks 7, 9 to 14), read your own writes declared at the mutation, generations covering in-flight loads, re-read in the request, invalidated on failure (Tasks 6, 8; end to end in Tasks 10, 13, 14, 15), refresh only on view (Global Constraints, Task 6), windows (Task 6), "as of" (Tasks 6, 7). §2.4 B: fetch parts following the Logs pattern, HTML fragments from the same templates, no framework, usable without JavaScript, gated like their page (Task 7; Logs through its own data endpoint in Task 12). §2.5 step 3 order: C (Tasks 2 to 5), then A and B (Tasks 6 to 15). §2.6: Task 17. Every task that makes a screen fast deletes its `over:` records; Task 17 ends with none and with a lower whole-session S3 total.
- **Review round 1 (Astra, at `e9f42e19`), findings that applied here:** 1 parts run their page's own gate, no operator part routes, refused store operator tested (Tasks 7, 15); 2 effects declared per door with cross-scope rules (Task 8; Tasks 14, 15 tests); 3 generations cover first loads and refreshes in flight (Task 6); 4 marking at the mutation after admission and success, refusals tested (Task 8); 5 immutable values with `viewClone` and a concurrent `-race` render test (Tasks 6, 9); 6 the production flag cached, the route-dependent view derived per request (Task 9); 7 claim route, fixture and probe entries (Task 7); 8 `HoldNext` keeps the read's result and holds one read only (Tasks 2, 10); 10 page and `/logs/data` share the first window (Task 12); 11 the manifest check off the response path, tested with a held read (Task 2); 12 written against the nav plan's code, test conversion owned here, Live now survives a failed listing (Branch notes, Tasks 9, 10); 13 `boxSnapshot` keeps completeness (Task 5); 14 whole-session S3 ceiling (Task 17, with plan 1 Task 10).
+- **Astra round 7 (`CODEX-FINDINGS-CONSOLE-PLANS-R7.md`):** 1 the claims index loads the entries it selects before publishing, so a write's re-read leaves the redirect with no read, first attachments included (Task 13); 2 timestamped claim bodies are immutable and windowless, with `ClaimCache`'s `modSettle` bound kept (Task 13); 3 read sets use prefix subsumption and a sound collapsing cap (Tasks 6, 12); 4 both relative filter endpoints resolve against one per-window clock reading (Task 12).
- **Astra round 6 (`CODEX-FINDINGS-CONSOLE-PLANS-R6.md`):** 1 claims cached as an index plus per-claim entries keyed by modification time, `ClaimCache`'s cost without a second cache (Task 13); 2 one canonical `fleetBoxesPart(fleet)` key, account filtering per request, and a two-consumer witness (Tasks 11, 14); 3 fixture deletes forwarded through the observed store, a forwarding test and a warmed canary-retirement case (Task 8); 4 the cache reads `s.now` through an indirection and is reset in place, so the tracker stays bound (Task 6).
- **Astra round 5 (`CODEX-FINDINGS-CONSOLE-PLANS-R5.md`):** 1 bills per month and fleet meters per fleet, box and day, selected per request, with rollover and period-switch witnesses (Task 15); 2 edge files and per-fleet snapshots cached as raw facts, liveness and the expected inventory derived per request, and a reviewed callee list for cross-package calls (Tasks 6, 11); 3 the app-host capability `env.AppHost`, host chosen per request and keyed (Tasks 6, 11); 4 errors cached as text (Tasks 5, 6, 9); 5 the `carlos:part` payload stated as the contract (Task 7).
- **Astra round 4 (`CODEX-FINDINGS-CONSOLE-PLANS-R4.md`):** rule (a) made structural, `viewLoadEnv` and `TestViewLoadersAreRestricted` (Task 6); 1 published and in-flight read sets, published replaced only on success (Task 6); 2 economics caches per-day usage, scenario, bill and fleet-meter facts, with tiers, accounts, registry and period derived per request, plus a tier-save witness (Task 15); 3 one metrics entry, loader, type and window (Task 9, consumed by Task 15); 4 catch-all caches manifest and TXT facts, rows per request (Task 13); 5 a tombstone primer (Tasks 8, 14); 6 the coverage oracle walks `perfWalkTargets` (Task 8).
diff --git a/docs/superpowers/plans/2026-10-25-operator-pages.md b/docs/superpowers/plans/2026-10-25-operator-pages.md
index 940d65740..4bad1cbec 100644
--- a/docs/superpowers/plans/2026-10-25-operator-pages.md
+++ b/docs/superpowers/plans/2026-10-25-operator-pages.md
@@ -562,7 +562,8 @@ Each loop wraps one pass in `s.jobs.Run` with its worker name as a string litera
- Consumes: `opPage`, `opJobRows(s.jobs.Snapshot())`, the `op_*` partials, OPS-11, OPS-137, OPS-146, OPS-147.
- Produces (the seams Task 13 and plan 2 Task 15 repoint; each a direct read in this task):
- `func (s *Server) opFleetJSON(ctx context.Context, p *page) (*status.Fleet, error)`: `FleetView(ctx, s.cfg.Releases)`.
- - `func (s *Server) opHostRows(ctx context.Context, p *page) ([]HostRow, error)`: `HostRows(ctx, s.cfg.Releases, time.Now())`.
+ - `func (s *Server) opHostRows(ctx context.Context, p *page) ([]HostRow, error)`: `HostRows(ctx, s.cfg.Releases, s.now())`.
+ - The server clock: every operator handler and seam reads time through `s.now()`, never `time.Now()`. Plan 2 Task 6 adds `Server.now func() time.Time` (and `newPerfFixture` points it at `fx.clock`); if this task runs before plan 2 has landed, it adds that same field here, defaulting to `time.Now` in `NewServer`, and plan 2 reuses it.
- `func (s *Server) opStorePending(ctx context.Context, p *page) (*int, error)`: for a store operator, `len(pendingStoreApplications)` under `storeTimeout`; `nil, nil` for anyone else or with no bucket.
- `func (s *Server) handleBoxes(w http.ResponseWriter, r *http.Request)`.
@@ -606,7 +607,7 @@ Each loop wraps one pass in `s.jobs.Run` with its worker name as a string litera
- `TestDashboardAllClear`: with no problems seeded, the callout is `positive` with OPS-21 and no list.
- `TestDashboardCountsFromFixtureRows`: the band shows People with the seeded total and OPS-34 with the active count, New people this week with its delta text, Deploys today `2` with OPS-45 for 2 apps.
- `TestDashboardSeriesHasThirtyDaysWithZerosFilled`: 30 `co-bar` spans; the hidden table has 30 rows; the rows for days 10 to 20 ago say 0; the last row is today's and says 2; the tallest bar is `co-h="20"`; no bar of a non-zero day is `co-h="0"`.
- - `TestAttentionAndBoxesAgreeAcrossTheFifteenMinuteLine`: a box heartbeat at `now − 14 min` and a `fleet.json` built at `now − 2 min` with that box not stale; warm `/fleet` (Healthy row, no box item). Move `fx.clock` 2 minutes (the heartbeat is now 16 minutes old; the summary is 4 minutes old, so not itself stale) and GET again with no new reads: the row is Silent and the callout lists OPS-24 for that box with `warning`. A second box present only in `HostRows` (absent from `fleet.json`) and dark is listed in both too. The same holds on the assembled page after a cold load in which the box entry arrived late (the whole-body part, Task 13), checked there.
+ - `TestAttentionAndBoxesAgreeAcrossTheFifteenMinuteLine` (direct seams, injected clock; no claim about reads, since before Task 13 every GET reads again): set `fx.srv.now` to a fixed `t0`; a box heartbeat at `t0 − 14 min` and a `fleet.json` built at `t0 − 2 min` with that box not stale; GET `/fleet`: the row is Healthy and the callout has no box item. Set `fx.srv.now` to `t0 + 2 min` (the heartbeat is now 16 minutes old; the summary 4 minutes, not itself stale); GET: the row is Silent and the callout lists OPS-24 for that box with `warning`. A second, dark box present only in `HostRows` (absent from `fleet.json`) is listed in both. A seam that read `time.Now()` instead of `s.now()` fails the second GET.
- `TestDashboardBoxStatuses` (not acceptance, over `dashBoxes`): comfortable is Healthy, busy is Busy (warning), critical is Busy (negative), a stale `HostRow` is Silent with no meter, a summary older than 15 minutes makes every row Stale, a `FleetBox` with no `HostRow` is Silent; an empty region is OPS-76.
- `TestDashboardLatestActivityAndNewestPeople`: newest 10 activity rows, newest first, with `none` for the sign-in's app; the newest five people with their first account.
- `TestDashboardReadFailuresDegrade`: on `newConsoleFixtureWith` with `WrapReleases` set to an `opProbeStore` failing `status/fleet.json`, the page is 200 with OPS-26 in the callout.
@@ -718,6 +719,7 @@ On a miss of either `fleet.json` or the box entry, the dashboard's whole body is
- `TestEconomicsEditAndSaveAfterColdLoad` (acceptance; skipped unless `exec.LookPath("chromium")` succeeds, and run locally before the task closes): on a fresh `newPerfFixture` (economics cold), a `127.0.0.1` test server in front of `fx.srv` adds Paul's session cookie and, for `/fleet/economics` only, appends a harness script before `</body>` that waits for the `carlos:part` event plan 2's real `partloader` dispatches (no synthetic event; the harness only listens, checking `e.detail.part === "economics"`), then, after the page's own listener has run, sets the first number input inside `#econ-live` to a new value, dispatches `input`, then copies `#scenario-json-field`'s value into a new `<pre id="harness-out">`. `chromium --headless=new --no-sandbox --disable-gpu --virtual-time-budget=15000 --dump-dom <url>` (60 s `exec.CommandContext`, profile under `t.TempDir()`). The dumped DOM's `harness-out` is valid scenario JSON that differs from the server's `scenarioJSON` in exactly that knob. The test then POSTs it to `/fleet/economics/scenarios` with a name and the CSRF token as the form does, follows the redirect, and the economics page lists the saved scenario.
- `TestEconomicsListenerMatchesThePartLoaderPayload` (no browser): the rendered `partloader` (plan 2's partial, from the real template set) dispatches `carlos:part` with a `detail` carrying `part` and `root`; each economics frame's listener reads `e.detail.part` and `e.detail.root` and nothing else from `detail`, compares `part` with a name that is a `fleetParts` key (`economics`, `economics-accounts`), and passes `root` to its initializer. A listener that read `e.detail.id` or passed `e.detail` itself fails it.
- `TestEconomicsPartIsInitialisedNotJustPresent` (no browser): the assembled cold economics page has the `carlos:part` listener in the frame and no `<script>` of any type inside the part body; plan 2's own no-script check over every registered part passes for `economics` and `economics-accounts`.
+ - `TestAttentionAndBoxesAgreeFromTheCache` (Task 9's case, now cached): on `newPerfFixture` with `fx.clock`, the same heartbeat and summary; warm `/fleet` (`getAssembled`, `perfQuiesce`), Healthy and no box item; `ResetKeys()`; move `fx.clock` 2 minutes (inside every window); GET: the row is Silent and the callout lists OPS-24, with zero S3 requests (the staleness is judged per request from the cached snapshot).
- `TestBoxReadsOncePerWindowOnlyOnView`: with `fx.clock`: three dashboard GETs and one Boxes GET within 60 s make one `status/boxes/` listing and one `Get` per seeded box in total (counted with plan 2's `Keys()`); moving the clock 61 s and making no request makes no read; the next view serves the old rows and starts exactly one refresh; two concurrent views after the window start one.
- `TestEveryFleetPartGatesLikeItsPage`: for each `fleetParts` key, signed out and a non-operator get the missing-route 404 body and start no load (`perfLatency.Calls()` unchanged); an operator who is not a store operator gets the 404 for `store` and starts no `store-pending` load.
- Operator writes rely on plan 2 Task 8's read-set invalidation; each gets a warm-before-write test (warm every reader, write through the real door, then read without waiting):
@@ -728,7 +730,7 @@ On a miss of either `fleet.json` or the box entry, the dashboard's whole body is
- `TestOperatorPagesJoinLocalStatePerRequest`: warm `/fleet`, `/fleet/store` and `/fleet/economics/accounts`; then, with no object-store write: rename an account in SQLite (the economics accounts table shows the new name at once), delete the account whose storage application is pending (the store page and the dashboard's storage item drop it at once), and move `fx.clock` 16 minutes (the dashboard says the fleet summary is old and the boxes read Stale at once); every one with zero S3 requests.
- `TestDashboardCountsAreNeverCached`: warm `/fleet`; create a user and an audit row through the store (no object-store write); the next GET's counts and Latest activity include them at once, with zero S3 requests (rule (a)).
- `TestEveryOperatorPageRendersInTheShell` and the page tests from Tasks 3 to 12 read assembled pages (`getAssembled`) and still pass.
-- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestOperatorPagesWarm|TestDashboardCold|TestDashboardWaitsForBoxEvidence|TestBoxReadsOncePerWindow|TestEveryFleetPart|TestDashboardAfterAStore|TestEconomicsScenarioSaveWarm|TestArchitectureRefreshWarm|TestDashboardCountsAreNeverCached|TestOperatorPagesJoinLocalState|TestEconomicsEditAndSave|TestEconomicsListenerMatches|TestEconomicsPartIsInitialised|TestEveryOperatorPage' -count=1`. Expected: FAIL.
+- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestOperatorPagesWarm|TestDashboardCold|TestDashboardWaitsForBoxEvidence|TestAttentionAndBoxesAgreeFromTheCache|TestBoxReadsOncePerWindow|TestEveryFleetPart|TestDashboardAfterAStore|TestEconomicsScenarioSaveWarm|TestArchitectureRefreshWarm|TestDashboardCountsAreNeverCached|TestOperatorPagesJoinLocalState|TestEconomicsEditAndSave|TestEconomicsListenerMatches|TestEconomicsPartIsInitialised|TestEveryOperatorPage' -count=1`. Expected: FAIL.
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run** Step 2's command, the page tests of Tasks 3 to 12 (`-run 'TestDashboard|TestBoxes|TestPeoplePage|TestActivityPage|TestEconomics|TestFleetMetrics|TestArchitecture|TestStoreQueue|TestOperatorGate'`), `nice -n 19 go test ./internal/console/ -run '^TestClaimConsoleMutationInvariant$' -count=1`, and the walk with `CI=1`: every operator screen within 150 ms with zero remote calls warm, and `grep -c '/fleet.* over:' internal/console/testdata/perf-budgets.txt` prints `0`.
- [ ] **Step 5: Commit**, message `console: operator pages read through the view cache; deferred parts behind each page's own gate`. If this task lands on `operator-pages-cache`, run Task 15 on that branch with `NAME=operator-pages-cache`.
@@ -782,6 +784,7 @@ ls "$SHOTS"/*.png | wc -l # 44
- **Astra round 2 (`d9e0277a`), findings that applied here:** 3, economics initializers run after fragment insertion, with an edit-and-save test after a cold load (Tasks 12, 13); 9, the six account actions are recorded on claim-gated consoles through the gate's `FreeWhenNoApp` rule, with its own gate review (Task 6A; the follow-up discussion is gone); 10, the last-seen hour is reserved under one mutex and write attempts are counted under concurrency (Task 5); 11, swallowed per-item failures mark the run Failed in every pass, with an AST check and an injected alert failure seen on the dashboard (Tasks 7, 9); 12b, plan 2's `HoldNext("list", …)` (no hold helper of this plan's own) and joining in-flight loads through the seams in blocking mode (Task 13); 12c, mux canonicalisation tested apart from the unknown-asset 404 (Task 2).
- **Astra round 3 (`4d963091`), findings that applied here:** 7, the dashboard reads an in-process projection of what is firing now, kept by the watcher from the published objects, one entry per rule, with firing-then-cleared across a recipient change tested (Task 7A, Task 9); 8, explicit walk targets for every query-selected view (`?show=accounts`, searches, pages, every activity kind, an account filter, a deep `before`) over a populated fixture, with a test that each `show` and `kind` has one (Tasks 9, 10, 11); R2-12c, the traversal test follows each hop of the mux's redirect chain to the final 404, apart from the unknown-asset 404 (Task 2). Economics initializers follow plan 2's no-script rule for fragments (the data moves to an attribute) and its `carlos:part` event (Tasks 12, 13).
+- **Astra round 7, finding 5:** Task 9's fifteen-minute test runs over the direct seams with an injected server clock (`s.now()`, which `opHostRows` now uses) and asserts no read counts; the cached, zero-read version is Task 13's `TestAttentionAndBoxesAgreeFromTheCache`.
- **Astra round 5, findings that applied here:** 5, the economics listeners read plan 2's `{part, root}` payload and are tested against the real `partloader` (Task 13); 6, the callout and the Boxes table come from one per-request `dashBoxes` slice built from `HostRows` at request time, the separate box part is gone, and the 14-to-16-minute case is tested on the page and after a cold load (Tasks 9, 13); 7, the query-plan witness checks each query's own access pattern, allowing total-count and bounded ordered scans, kind filters go through `audit_by_action` one action at a time, the bite checks are stated correctly, and the scale witness stays (Task 4).
- **Astra round 4, findings that applied here:** 7, active counts are set-based over new covering indexes, with an `EXPLAIN QUERY PLAN` witness over every statement and a scale run (Task 4); 9, each landing branch has its own census NAME, card, overlay and ruling (Branch, Tasks 13, 15); 10, the Activity filter resolves accounts with an operator-only, tombstone-inclusive lookup, and following a deleted account's link is tested (Tasks 4, 11). Plan 2's restricted load environment: every operator load caches only object-store facts, with per-request builders for the rest (Global Constraints, Task 13).
- **Plan 2's read-set redesign (coordinator, 2026-10-25).** This plan no longer leans on a per-door effect table. Only the seven object-store loads above are cached; every SQLite count and list, the job registry and the alert projection are read per request; status words and ages are joined per request; the operator writes (store approve and decline, economics scenario save, architecture refresh) are covered by read-set invalidation with warm-before-write tests (Task 13).