Merge console-ux-perf plan revisions into console-ux-nav
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 files changed,
+314
−49
docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md+48 −24docs/superpowers/plans/2026-10-25-console-ux-nav.md+11 −7docs/superpowers/plans/2026-10-25-operator-pages.md+32 −18docs/superpowers/plans/CODEX-FINDINGS-CONSOLE-PLANS-R5.md+91 −0docs/superpowers/plans/CODEX-FINDINGS-CONSOLE-PLANS-R6.md+67 −0docs/superpowers/plans/CODEX-FINDINGS-CONSOLE-PLANS-R7.md+65 −0
CI failed — 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 9af2dda2a..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 |
| @@ -218,8 +218,8 @@ Spec §2.4 C rows "Settings, `populateAppSettings`", "`appDeployEmpty`" and "`en |
| **Interfaces:** |
| - Produces: |
| - - `type boxSnapshot struct { Boxes []status.Box; Complete bool; Err error }`: what `status.LoadBoxesComplete` (`status/fleet.go:224`) returns, kept whole so a reader that must fail closed on partial evidence still can. |
| - - `func (s *Server) platformBoxes(ctx context.Context) boxSnapshot` (memo key `boxes:platform`), read once per request. Strict readers (`loadBoxJoinComplete`, automatic placement) use `Complete` and `Err` exactly as they use `LoadBoxesComplete`'s results today; lenient readers (`loadBoxJoin`, `systemBoxes`, `geoipInventory`, `aliasReadings`) take `Boxes` and treat `Err` as they treat `LoadBoxes`' error today. |
| + - `type boxSnapshot struct { Boxes []status.Box; Complete bool; ErrText string }`: what `status.LoadBoxesComplete` (`status/fleet.go:224`) returns, kept whole so a reader that must fail closed on partial evidence still can. The error is kept as plain data (its text, empty for none), because the snapshot is cached from Task 9 on and cached types hold no interface fields (Task 6). `func (b boxSnapshot) Err() error` gives it back as an `error` (nil when `ErrText` is empty) for the callers below. `Complete == false && ErrText == ""` keeps meaning "partial, no error", exactly as `LoadBoxesComplete`'s `complete == false, err == nil` does today. *(Astra round 5, finding 4.)* |
| + - `func (s *Server) platformBoxes(ctx context.Context) boxSnapshot` (memo key `boxes:platform`), read once per request. Strict readers (`loadBoxJoinComplete`, automatic placement) use `Complete` and `Err()` exactly as they use `LoadBoxesComplete`'s results today; lenient readers (`loadBoxJoin`, `systemBoxes`, `geoipInventory`, `aliasReadings`) take `Boxes` and treat `Err()` as they treat `LoadBoxes`' error today. |
| - `liveEdges` behind the memo (key `edges`); `instanceDomainFor` and `appPolicy`'s instance-manifest read behind the memo (key `instances-manifest:<sqid>/<app>`). |
| - [ ] **Step 1: Write the failing tests:** |
| @@ -236,10 +236,10 @@ Spec §2.4 C rows "Settings, `populateAppSettings`", "`appDeployEmpty`" and "`en |
| **Files:** |
| - Create: `internal/console/viewcache.go`; Test: `internal/console/viewcache_test.go` |
| - Create: `internal/console/viewloaders.go` (every loader lives here; empty but for the probe's in this task); Test: `internal/console/viewloaders_test.go` (`TestViewLoadersAreRestricted`) |
| -- Modify: `internal/console/server.go` (`Server.views *viewCache`, set in `NewServer` to `newViewCache(s.now, viewCacheMax)`; `Server.now func() time.Time`, `time.Now` by default, the clock every request-time derivation in Tasks 9 to 14 reads) |
| +- Modify: `internal/console/server.go` (`Server.views *viewCache`, set in `NewServer` to `newViewCache(func() time.Time { return s.now() }, viewCacheMax)`, an indirection that reads the field on every call, so a test that replaces `s.now` after construction moves the cache's clock too; `Server.now func() time.Time`, `time.Now` by default, the clock every request-time derivation in Tasks 9 to 14 reads and the source of `viewLoadEnv.ReadAt`. *(Astra round 6, finding 4.)*) |
| - Modify: `internal/console/perfwalk_test.go` (`perfQuiesce = func(fx *consoleFixture) { fx.srv.waitBackground() }`; `perfColdReset = func(fx *consoleFixture) { fx.srv.resetForColdView() }`; `newPerfFixture` sets `fx.clock` and points `fx.srv.now` at it) |
| - Modify: `internal/console/metricsview.go:361`, `internal/console/economicsview.go:288-300` (their own background sweeps run through `s.bg.Go`, Task 2's `bgWork`, as view loads do from this task on). |
| -- Create: `internal/console/viewreset_test.go`: `func (s *Server) waitBackground()` (test-only: `s.bg.Wait()`) and `func (s *Server) resetForColdView()` (test-only), which first waits for background work and then gives the server what a restart would: a fresh `newViewCache(s.now, viewCacheMax)`, an empty `manifestSeen`, an unset edge fold, and empty inner caches in `LoadMetrics` and `LoadEconomics`. `perfQuiesce` is `fx.srv.waitBackground()`, so counts and resets never run while a request-triggered worker is still reading. *(Astra round 3, finding 9.)* |
| +- Create: `internal/console/viewreset_test.go`: `func (s *Server) waitBackground()` (test-only: `s.bg.Wait()`) and `func (s *Server) resetForColdView()` (test-only), which first waits for background work and then gives the server what a restart would: an emptied view cache, reset **in place** by `s.views.reset()` (every entry, read set and in-flight generation dropped; the same `*viewCache`, so Task 8's tracker, bound to it once in `NewServer`, keeps invalidating the cache that serves pages), an empty `manifestSeen`, an unset edge fold, and empty inner caches in `LoadMetrics` and `LoadEconomics`. `perfQuiesce` is `fx.srv.waitBackground()`, so counts and resets never run while a request-triggered worker is still reading. *(Astra round 3, finding 9.)* |
| **Interfaces:** |
| - Produces: |
| @@ -250,15 +250,16 @@ Spec §2.4 C rows "Settings, `populateAppSettings`", "`appDeployEmpty`" and "`en |
| - `type viewResult[T any] struct { Val T; At time.Time; Stale bool }` |
| - `func newViewCache(now func() time.Time, max int) *viewCache` |
| - **The restricted loader** (rule (a), made structural; Astra round 4, findings 2 to 4): |
| - - `type viewLoadEnv struct { Ctx context.Context; Store release.Store; Pub ed25519.PublicKey; ReadAt time.Time; LookupTXT func(ctx context.Context, name string) ([]string, error) }`, built by the cache for each load. It holds the observed object store, the release key, the time the load started (only for library calls that need a read time, such as the box listing's 24-hour horizon; nothing derived from it is shown), and DNS as one explicit, named dependency. It holds no `*Server`, no console `Store`, no registry and no clock. |
| + - `type viewLoadEnv struct { Ctx context.Context; Store release.Store; Pub ed25519.PublicKey; ReadAt time.Time; LookupTXT func(ctx context.Context, name string) ([]string, error); AppHost func(ctx context.Context, host string) InstanceReport }`, built by the cache for each load. It holds the observed object store, the release key, the time the load started (only for library calls that need a read time, such as the box listing's 24-hour horizon; nothing derived from it is shown), and two explicit, named outside dependencies. DNS is one. The other is the app-host capability: `AppHost` is the instance fetcher's `fetch` (`instances.go:122-158`), bound to the configured `Config.AppClient` as plan 1 wraps it (`perf.TimeDoer`, so the walk's counting transport still sees every call), with its scheme, timeout and size caps. Neither has a read set; each is refreshed by its window only (Astra round 5, finding 3). It holds no `*Server`, no console `Store`, no registry and no clock. |
| - `type viewLoader[A, T any] func(env viewLoadEnv, key viewKey, arg A) (T, error)`. Every loader is a package-level function in `internal/console/viewloaders.go`, so it can reach neither a `*Server` nor the console `Store`: it is given neither, and that is checked by the compiler. `arg` carries the load's inputs as plain data (a page number, a filter, a period's dates). |
| - - `TestViewLoadersAreRestricted` (`viewloaders_test.go`, built on `go/parser`) closes the remaining doors, which are package-level globals. (1) At every call of `viewPeek`, `viewWait` and `viewGet`, the loader argument is an identifier naming a function declared in `viewloaders.go`: no function literal, no method value, nothing that could capture state. (2) No function in `viewloaders.go`, nor any package-level function of package `console` they call, transitively by name, mentions `openRegistry`, `memoRoutes`, `registry.`, `database/sql`, `time.Now`, `time.Since`, `time.Until`, `context.Background` or `context.TODO` (a store call off `env.Ctx` would escape the read set), or has a receiver. (3) Every `A` and `T` named in `var viewLoaderTypes` (one entry per loader, kept complete by (1)'s scan) is, by `reflect`, plain data, with no pointer to anything mutable outside the value, no func, chan or interface field. The two read-only pointers `appCore` holds (`*release.Pipeline`, `*release.ProductionFlag`) are listed by name as allowed. |
| + - `TestViewLoadersAreRestricted` (`viewloaders_test.go`, built on `go/parser`) closes the remaining doors, which are package-level globals. (1) At every call of `viewPeek`, `viewWait` and `viewGet`, the loader argument is an identifier naming a function declared in `viewloaders.go`: no function literal, no method value, nothing that could capture state. (2) No function in `viewloaders.go`, nor any package-level function of package `console` they call, transitively by name, mentions `openRegistry`, `memoRoutes`, `registry.`, `database/sql`, `time.Now`, `time.Since`, `time.Until`, `context.Background` or `context.TODO` (a store call off `env.Ctx` would escape the read set), or has a receiver. (3) Every `A` and `T` named in `var viewLoaderTypes` (one entry per loader, kept complete by (1)'s scan) is, by `reflect`, plain data, with no pointer to anything mutable outside the value, and no func, chan or interface field: errors included, which cached types keep as text (`ErrText`, `ProductionErrText`, `PipelineErrText`). The two read-only pointers `appCore` holds (`*release.Pipeline`, `*release.ProductionFlag`) are listed by name as allowed. (4) Every call from `viewloaders.go` to another package names a function on `var viewLoaderCallees`, a reviewed list of read-only functions that return what they read (for example `release.Channel`, `release.GetProduction`, `release.GetPipeline`, `release.ListTags`, `release.GetRetention`, `status.LoadBoxesComplete`, `telemetry.Read`, `applog.ReadWindow`, `apperr.ReadWindow`, `analytics.ReadRange`, `provision.ListRecordHosts`). Each entry carries a comment saying what it reads and that it derives nothing from local state or the clock beyond choosing what to read. A function that derives liveness, freshness or an expected set (such as `edgesfile.ReadSnapshot`'s freshness, `edgesfile/snapshot.go:152`, or the GeoIP inventory's registry join) cannot be on it; its read half is split out and listed instead. Adding a callee is a reviewed change to the list, and that is how cross-package derivation stays visible. *(Astra round 5, finding 2.)* |
| - 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). |
| - `func (c *viewCache) snapshot() []viewEntryInfo` (test-only: key, generation, valid, read set), for Task 8's coverage check. |
| - `func asOfText(now, at time.Time) string`: CPF-20 with CPF-21 to CPF-25 (under a minute, 1 minute, n minutes, 1 hour, n hours). |
| @@ -277,15 +278,18 @@ 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. |
| + - `TestWriteAfterColdResetInvalidatesTheLiveCache`: warm an entry with a recorded read set; `resetForColdView`; warm it again; write its key through the observed store; the next read misses and answers the new value, and the tracker's `touched` reached the live cache, not a discarded one. |
| - `TestBackgroundWaitCoversEveryWorker`: a view load, a `bg.Go` worker and a held loader; `waitBackground` returns only after all three end. |
| - `TestHungLoadIsBoundedAndRetried`: with `viewLoadTimeout` shortened to 50 ms, a loader that blocks until its context ends; while it runs, peeks start no second goroutine; after it ends, the next peek of the stale entry starts one. |
| - `TestViewKeysAreAccountScoped`: `{Acct: "a", App: "api"}` and `{Acct: "b", App: "api"}` hold different values. |
| - `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|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. |
| @@ -314,7 +318,7 @@ The rules the implementation keeps: |
| - test-only: `func getAssembled(t *testing.T, c *http.Client, u string) (status int, body string)`: GET `u`; then, up to five rounds, replace each `<div class="deferred" data-part="X">…</div>` with the body of a GET of `X` on the same client, as the loader script does. `claimPageRead` uses the same splice, so claim probes assert on the assembled page. |
| - test-only: `func registerProbePart(t *testing.T, key viewKey, objectKey string)`: adds an app part `probe` (gate: `appPage`'s) whose `Fill` reads `objectKey` through `viewGet` with the loader `loadProbeObject` (in `viewloaders.go`: one `env.Store.Get` of its `arg`) into `p.Msg` and renders `part_text`; removed in `t.Cleanup`. Tests that use it are not parallel. |
| -The loader script, in the Logs tab's style: for each `[data-part]` element, `fetch(el.dataset.part, {headers: {Accept: "text/html"}, signal})` with an `AbortController` aborting after 20 s; on `ok` replace the element's `outerHTML` with the response text; otherwise (or on abort) replace it with the response text when there is one, else with CPF-28. After each replacement it dispatches `document.dispatchEvent(new CustomEvent("carlos:part", {detail: {part: <the part URL>, root: <the inserted element>}}))`. This plan owns that event; the operator-pages plan uses the same one. No polling and no retry: a part is fetched once per page view. |
| +The loader script, in the Logs tab's style: for each `[data-part]` element, `fetch(el.dataset.part, {headers: {Accept: "text/html"}, signal})` with an `AbortController` aborting after 20 s; on `ok` replace the element's `outerHTML` with the response text; otherwise (or on abort) replace it with the response text when there is one, else with CPF-28. After each replacement it dispatches `document.dispatchEvent(new CustomEvent("carlos:part", {detail: {part: <the part URL>, root: <the inserted element>}}))`. **That payload is the contract**, owned by this plan: `detail.part` is the part URL that was fetched (a string, as in `data-part`), and `detail.root` is the element now in the page (the inserted fragment's root). There are no other fields. A listener chooses by `detail.part` or by what it finds under `detail.root`, and initializes inside `detail.root`. The operator-pages plan consumes it as stated (Astra round 5, finding 5). No polling and no retry: a part is fetched once per page view. |
| **No script inside a deferred fragment.** A fragment inserted with `outerHTML` does not run its `<script>` elements, so a template rendered as a part never contains one. A page's behaviour lives in its frame as an initializer that runs once on `DOMContentLoaded` over the whole document and again on every `carlos:part` over `event.detail.root`, finds its elements by id or attribute inside the root it is given, and never uses `document.currentScript`. *(Astra round 3, finding 5.)* With JavaScript off the `<noscript>` text stands, and a reload is a warm view because the miss started the load. |
| @@ -328,7 +332,7 @@ Every screen converted in Tasks 9 to 14 follows one shape: its template becomes |
| - `TestAsOfShowsOnStaleData`: with `fx.clock` moved past `writtenWindow`, the part still answers `one` and now carries CPF-20. |
| - `TestGetAssembledFollowsParts`: a body holding one `deferred` div for the probe assembles to `one`. |
| - `TestNoDeferredFragmentHasAScript`: on `newPerfFixture` with every seed, for every key of `appParts` and `accountParts` (the tables, so later parts are covered without an edit) and every target `perfTargets` gives it, the fragment's body contains no `<script` (case-insensitive). Tasks 9 to 14 keep it passing. |
| - - `TestPartLoaderFiresTheEvent`: the rendered `partloader` contains `carlos:part` and dispatches it after the `outerHTML` replacement (a source assertion on the partial; no browser in CI). |
| + - `TestPartLoaderFiresTheEvent`: the rendered `partloader` contains `carlos:part` and dispatches it after the `outerHTML` replacement with exactly the `detail` keys `part` and `root` (a source assertion on the partial; no browser in CI). |
| - [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestEveryPartGates|TestPartRenders|TestPartFailure|TestDeferredPartials|TestAsOfShows|TestGetAssembled|TestNoDeferredFragmentHasAScript|TestPartLoaderFiresTheEvent' -count=1`. Expected: FAIL. |
| - [ ] **Step 3: Implement**; add CPF-26 to CPF-28 to `consolePerfCopyBuilt`. Add `route GET /a/{sqid}/apps/{app}/part/{part}` and `route GET /a/{sqid}/part/{part}` to `claim-routes.txt` in its sorted place; `claimFixtures` entries `claimRead("deferred part of an app page; the page's own gate")` and `claimRead("deferred part of an account page; the page's own gate")`; `claimReadProbes` entries `claimPageRead(nil, "/a/bab/apps/titogo/part/<a part Task 9 adds>", <its marker>)` and the account equivalent (until Tasks 9 and 14 add parts, point them at an unknown part name and expect the 404, then repoint them in those tasks). Add the two routes to `perfTargets` (one target per key of each table) and record each `deferred: deferred part`. |
| - [ ] **Step 4: Run** Step 2's command, `go test ./internal/console/ -run 'TestClaimRouteInventory|TestClaimFixture|TestClaimRead' -count=1`, `nice -n 19 go test ./internal/console/ -run '^TestClaimConsoleMutationInvariant$' -count=1`, `go test . -run TestConsolePerfCopy -count=1`, and the walk with `CI=1`. Expected: PASS. |
| @@ -353,7 +357,7 @@ Admission falls out of the design. A refused request (session, CSRF, owner, conf |
| - Create: `internal/console/viewtrack.go`; Test: `internal/console/viewtrack_test.go` |
| - Modify: `internal/console/server.go` (`Config.Track`; `NewServer` binds it), `internal/console/claim_routes.go:59-69` (`registerRoute`: non-GET, non-HEAD requests get a write set and the re-read writer) |
| - Modify: `cmd/console/main.go` (`openStore` sets the observer on the store it opens; `serve()` passes the tracker in `Config.Track`); Test: `cmd/console/perfs3_test.go` (extend) |
| -- Modify: `internal/console/claim_invariant_world_test.go` (`newClaimCaseWith`: when an option sets `Config.Track`, the claim world's `DirStore` gets its observer), `internal/console/claim_invariant_test.go` (`runClaimDoor`: the coverage check) |
| +- Modify: `internal/console/claim_invariant_world_test.go` (`newClaimCaseWith`: when an option sets `Config.Track`, the claim world's `DirStore` gets its observer), `internal/console/view_test.go:51` (`deletableStore.Delete` keeps its key validation, then forwards to the underlying `DirStore.Delete(ctx, key)` with the caller's context instead of calling `os.Remove`, so every fixture write reaches the observed store; *Astra round 6, finding 3*), `internal/console/claim_invariant_test.go` (`runClaimDoor`: the coverage check) |
| **Interfaces:** |
| - Consumes: `viewCache.touched`, `viewCache.reread`, `viewCache.snapshot`, `withReadSet`, plan 2 Task 2's `perfLatency.Keys`. |
| @@ -382,9 +386,10 @@ Admission falls out of the design. A refused request (session, CSRF, owner, conf |
| - `TestInstanceCreateRefreshesHostsAndEnvs`: Logs' host picker (`partRecordHosts`) and Environments (`partEnvs`) warm; create an instance through the CLI door; the picker lists the new host and Environments shows it (its host join is per request, rule (a)). |
| - `TestScenarioActivationRefreshesArchitecture`: Architecture warm; activate a scenario through the economics door; Architecture's rate card is the new scenario's. |
| - `TestRefusedWritesInvalidateNothing`: a CSRF failure, a non-member, a plain member on an owner door, a validation error, and a promote stopped at its confirmation page. For each, the fake saw no write and every entry's generation is unchanged. |
| + - `TestFixtureStoresForwardEveryWrite`: for `deletableStore` and the claim world's `claimRawStore`, each write method (`Put`, `PutFrom`, `Delete`, `DeleteIfMatch`) produces one write observation on the underlying `DirStore` with the caller's context; the method list comes from `reflect` over each type, so a new write-shaped method without forwarding fails it. |
| - `TestReadSetsCoverEveryRead`: on `newPerfFixture`, for each target plan 1's `perfWalkTargets(fx)` gives (every screen in `perfInventory` with its defaults expanded exactly as the walk expands them, `skip` records excluded; Astra round 4, finding 6): `resetForColdView`, `ResetKeys`, `getAssembled`, `waitBackground`. Every `GetObject` key and `ListObjectsV2` prefix the fake saw is held by some entry's read set, or is on a short allowlist of reads the cache does not hold: the account-manifest check, the change index, and reads that plan 1's warm walk already allows by a `calls` record. |
| - - The coverage check inside `TestClaimConsoleMutationInvariant`. The suite builds its door consoles with `newClaimCaseWith(t, func(c *Config) { c.Track = NewStoreTracker() })`; `newClaimCaseWith`, seeing `Track` set after the options run, calls `dir.SetObserver(cfg.Track.Observe)` on the claim world's `DirStore` (`claim_invariant_world_test.go:464`). Every other `newClaimCase` user stays untracked and reads inline, unchanged. In each door's `setup`, outside every measured window, `runClaimDoor` assembles every app tab, settings section and account page of the door's account and app, then calls `waitBackground` and `snapshot`. After each run, it calls `waitBackground` and `snapshot` and runs `assertWriteCoverage` with that run's written keys from the suite's own raw-store recorder (`claimRawStore`'s events: an oracle the tracker does not feed). For a foreign run (`check(…, false)`), which writes nothing, no generation may move. |
| -- [ ] **Step 2: Run** `go test ./internal/release/ -run 'TestStoreObserver' -count=1`, `go test ./internal/console/ -run 'TestReadRecordedBefore|TestUntrackedServer|TestShipRefreshes|TestInstanceCreateRefreshes|TestScenarioActivation|TestRefusedWrites|TestReadSetsCoverEveryRead' -count=1 -race`, `go test ./cmd/console/ -run TestProductionStoreIsObserved -count=1`. Expected: FAIL. |
| + - The coverage check inside `TestClaimConsoleMutationInvariant`. The suite builds its door consoles with `newClaimCaseWith(t, func(c *Config) { c.Track = NewStoreTracker() })`; `newClaimCaseWith`, seeing `Track` set after the options run, calls `dir.SetObserver(cfg.Track.Observe)` on the claim world's `DirStore` (`claim_invariant_world_test.go:464`). Every other `newClaimCase` user stays untracked and reads inline, unchanged. In each door's `setup`, outside every measured window, `runClaimDoor` assembles every app tab, settings section and account page of the door's account and app, then calls `waitBackground` and `snapshot`. After each run, it calls `waitBackground` and `snapshot` and runs `assertWriteCoverage` with that run's written keys from the suite's own raw-store recorder (`claimRawStore`'s events: an oracle the tracker does not feed). For a foreign run (`check(…, false)`), which writes nothing, no generation may move. The door fixtures include a warmed canary retirement (`POST …/canary/retire`, whose handler deletes the channel pointer, `server.go:5353`): the warmed core entry's generation must move, which fails if any fixture delete bypasses the observer. |
| +- [ ] **Step 2: Run** `go test ./internal/release/ -run 'TestStoreObserver' -count=1`, `go test ./internal/console/ -run 'TestReadRecordedBefore|TestFixtureStoresForwardEveryWrite|TestUntrackedServer|TestShipRefreshes|TestInstanceCreateRefreshes|TestScenarioActivation|TestRefusedWrites|TestReadSetsCoverEveryRead' -count=1 -race`, `go test ./cmd/console/ -run TestProductionStoreIsObserved -count=1`. Expected: FAIL. |
| - [ ] **Step 3: Implement.** Some of these tests need screens converted later (Logs in Task 12, Architecture in Task 15). Write them now with `t.Skip("cached in Task N")` and remove the skip in that task. Every other case runs here, with the probe part standing in for a cached screen. |
| - [ ] **Step 4: Run** Step 2's commands, the gate-order tests `go test ./internal/console/ -run 'NonMember|CSRF|StepUp|FreshAuth|TestEveryCLIDoorNamesItsRoles|TestAuthCLIFamily|TestPromoteFlow|TestRollbackFlow' -count=1`, and `nice -n 19 go test ./internal/console/ -run '^TestClaimConsoleMutationInvariant$' -count=1`. The claim run's background reads happen in setup, outside measured windows. A door's own re-reads are reads inside its window. If the suite's recorder treats them as anything but the door's reads, record them as the door's reads; never silence the check. Expected: PASS. |
| - [ ] **Step 5: Prove the check bites.** Make one loader read a key without recording it (an `env.Store` call on `context.Background()` instead of `env.Ctx`, with the AST rule against it temporarily disabled). `TestReadSetsCoverEveryRead` must name that key, and the matching warm-before-write case must fail. Restore, then commit with message `console: writes invalidate what they touched, by read set; the writing request re-reads it before answering`, ending with the Co-Authored-By line. |
| @@ -401,7 +406,7 @@ Spec §2.4 C row `assembleChannels`: List plus one Get per channel, sequential, |
| **Interfaces:** |
| - Produces: |
| - - `type appCore struct { Channels []ChannelView; ProductionFlag *release.ProductionFlag; ProductionErr error; Pipeline *release.Pipeline; PipelineErr error }` with `viewClone` (copies `Channels`; the two pointers are read-only), and `func loadAppCore(ctx context.Context, s release.Store, pub ed25519.PublicKey, acct, app string) (appCore, error)`: `assembleChannels`, `release.GetProduction` and `release.GetPipeline`, under `ctx`. It holds only what is read remotely, and only facts that do not change with the clock: every cached `ChannelView` has a zero `BakedUntil`, and the core keeps `PromotedAt`, `FastTrack` and the channel name from which it is derived. *(Astra round 2, finding 6.)* |
| + - `type appCore struct { Channels []ChannelView; ProductionFlag *release.ProductionFlag; ProductionErrText string; Pipeline *release.Pipeline; PipelineErrText string }` with `viewClone` (copies `Channels`; the two pointers are read-only). The two read errors are kept as their text, empty for none (Astra round 5, finding 4): `productionView` takes `ProductionErrText` where it took the error (the existing "fail toward baking" branch, `view.go:765-768`, runs when it is non-empty and puts the same text in `ProductionView.Err`). `applyPipelineView` sets the per-request `AppView.PipelineErr` (Task 3, not cached) to `errors.New(PipelineErrText)` when it is non-empty, so the pipeline page still tells a failed read from an absent pipeline. A failed channel read already degrades to `ChannelView.Err`, a string. and `func loadAppCore(ctx context.Context, s release.Store, pub ed25519.PublicKey, acct, app string) (appCore, error)`: `assembleChannels`, `release.GetProduction` and `release.GetPipeline`, under `ctx`. It holds only what is read remotely, and only facts that do not change with the clock: every cached `ChannelView` has a zero `BakedUntil`, and the core keeps `PromotedAt`, `FastTrack` and the channel name from which it is derived. *(Astra round 2, finding 6.)* |
| - `assembleChannels` loses its `now` parameter and its bake computation (`view.go:749-753`); `func channelBakes(channels []ChannelView, pipe *release.Pipeline, prod ProductionView, now time.Time)` sets `BakedUntil` on the request's copy: the legacy hold (`release.HoldFor(release.DefaultHolds, name)`) when there is no pipeline, the pipeline's `holdWindow` when there is (what `applyPipelineView` does today, `server.go:3480-3490`), cleared for fast-tracked channels and when production is off (`view.go:615-626`). `Assemble` calls it with its `now` argument and `applyPipelineView` with `s.now()`; the ladder is rebuilt from its result. Production's turning-off estimate is already derived per request in `productionView`. |
| - `func productionView(flag *release.ProductionFlag, err error, channels []ChannelView, routes []RouteView, now time.Time) ProductionView` (`now` is `s.now()`): `assembleProduction` minus its read (`view.go:763`), so the route-dependent nudge (`:794-803`) is still computed from the request's routes. *(Astra finding 6: the routes are a local registry read and are never cached.)* |
| - `Assemble(ctx context.Context, regPath string, s release.Store, pub ed25519.PublicKey, acct string, apps []string, dns DNSTargets, now time.Time, core func(app string) (appCore, error)) ([]AppView, error)`: `now` is explicit (screens pass `s.now()`, tests their clock, `storeCore` callers `time.Now()`), so the clock-dependent derivation below has a clock; routes come from `memoRoutes`; each app's channels, production flag and pipeline from `core`; `productionView`, the channel post-processing at `:615-626` and the ladder run on the request's own copy. An error from `core` is returned (callers map `errViewPending` to the placeholder). |
| @@ -463,15 +468,19 @@ Spec §2.4 C row `instances.Report`: HTTP to the app host, 30 s cache, blocks up |
| **Interfaces:** |
| - Produces: |
| - parts `instances`, `instance` (its `Gate` checks `?host=` against the app's own routes exactly as the page checks `{host}`, else 404), and `instances-report` (the self-report section alone). |
| - - `instances.Report` (its only caller is the Running tab) through `viewGet` with `{sqid, app, partAppReport}`, `liveWindow`. A miss of the report alone renders the rest of the tab and a placeholder for `instances-report` only (the part the spec names). |
| - - Reads through `viewGet`: `appResourceMetrics` (Task 9's key), `liveEdges` (`{"", "", partEdges}`, `liveWindow`), `platformBoxes` (Task 9's `partBoxes`, the whole `boxSnapshot`), the instance manifest (Task 10's key), the instance page's fleet boxes (`{sqid, "", "fleet-boxes:<fleet>"}`, `liveWindow`, a `boxSnapshot` each), `updatesPage`'s record and manifest (`{sqid, app, "updates:<host>"}`, `liveWindow`), the geoip inventory (`{"", "", "geoip-inventory"}`, `liveWindow`). The region line's reads go through the same entries. Registry and SQLite reads stay direct. |
| + - The app's self-report: the host is chosen per request by `instances.Report`'s existing rule (first ready, non-static, non-sidecar, non-hibernating route, `instances.go:83-101`, over the request's routes), and becomes part of the key, `{sqid, app, partAppReport + ":" + host}`, `liveWindow`, loader `loadAppReport(env, key, host string)` calling `env.AppHost`. A different eligible host (one went to sleep) is a different entry; no eligible host is no read at all, as today. `instanceFetcher` keeps host choice and its client; its cache map goes. A miss of the report alone renders the rest of the tab and a placeholder for `instances-report` only (the part the spec names). |
| + - Reads through `viewGet`: `appResourceMetrics` (Task 9's key), the edge files as raw facts (`{"", "", partEdges}`, `liveWindow`, loader `loadEdgeFiles`: the read half of `edgesfile.ReadSnapshot`, `control/edges/` listed and each file read, split out and put on `viewLoaderCallees`); `liveEdges`' freshness and its clock-dependent box completeness (`edgesfile/snapshot.go:152`) are computed per request from those facts, the `partBoxes` snapshot and `s.now()` by the split's pure half, `platformBoxes` (Task 9's `partBoxes`, the whole `boxSnapshot`), the instance manifest (Task 10's key), every fleet's heartbeat snapshot under one canonical key, `{"", "", fleetBoxesPart(fleet)}` (`liveWindow`, a `boxSnapshot` each, loader `loadFleetBoxes`), shared by the instance page's system-wide box view (`systemBoxes`), its account rollout join (`loadRolloutJoin`), the GeoIP inventory and the account pages (Task 14). Which fleets a consumer may see is decided per request from the registry: the rollout join and the account pages keep only fleets whose `Account` is the viewer's account, exactly as `apiinstances.go:514-570` filters today, so the shared deployment-wide entry never widens what an account sees *(Astra round 6, finding 2)*, `updatesPage`'s record and manifest (`{sqid, app, "updates:<host>"}`, `liveWindow`), the GeoIP inventory as facts only: the platform boxes (`partBoxes`) and one heartbeat snapshot per fleet (`{"", "", fleetBoxesPart(fleet)}`, the same entries as the instance page's fleet boxes). The expected inventory (which fleets and boxes exist, `ListFleets`/`ListFleetBoxes`, `apisystemgeoip.go:281`) is read from the registry per request, and selects which fleet entries the request needs. A fleet registered since is then a miss for its own entry, never absent from a stale aggregate. The region line's reads go through the same entries. Registry and SQLite reads stay direct. |
| - [ ] **Step 1: Write the failing tests:** |
| - `TestRunningWarmMakesNoRemoteCalls` and `TestInstancePageWarmMakesNoRemoteCalls`. |
| - `TestRunningTabNeverWaitsOnTheAppHost`: `HostDelay` 1 s; a cold Running tab answers within 150 ms with the instances table and a `data-part` for `instances-report`; after quiesce the report shows; exactly one host call was made. |
| - `TestAppReportNeverWakesAHibernatingHost`: with every route `Hibernate`, no host call is ever made (the rule at `instances.go:83-92`). |
| + - `TestEdgeFreshnessCrossesItsBoundaryWithoutARefresh`: warm Running with fresh edge files; move `fx.clock` past the edges' freshness bound with no store change (the cached facts are now stale but served); the region line's freshness-dependent text changes on that very view, while a refresh is held with `HoldNext("list", …)`. |
| + - `TestFleetAddedOrRemovedReachesGeoipInventory`: warm the instance page's update section; register a new fleet and box in the registry (no object-store write); the next view lists it (its own entry loads); remove it from the registry; the next view drops it, with no store write either way. |
| + - `TestInstancePageReadsEachFleetOnce`: two fleets, one owned by the viewer's account and one by another; a cold instance page, then `waitBackground`: each fleet's heartbeat prefix appears once in `Keys()` (one entry serving both the system-wide view and the rollout join), and the assembled page's rollout section shows only the owned fleet. |
| + - `TestAppReportIsKeyedByHost`: two eligible routes; the report is fetched from the first; mark it hibernating; the next view fetches from the second (a new entry) and never polls the hibernating one. |
| - `TestInstancePartRefusesAForeignHost`: `/apps/kass/part/instance?host=otherapp.carlosapp.dev` (the fixture's other app's route) is the same 404 the page gives for that host, with no S3 call. |
| -- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestRunningWarm|TestInstancePageWarm|TestRunningTabNeverWaits|TestAppReportNeverWakes|TestInstancePartRefuses|TestRunningTabTimesTheAppHost|TestDeferredAppReportCountsAsBackground' -count=1`. Expected: FAIL. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestRunningWarm|TestInstancePageWarm|TestRunningTabNeverWaits|TestAppReportNeverWakes|TestEdgeFreshnessCrosses|TestFleetAddedOrRemoved|TestInstancePageReadsEachFleetOnce|TestAppReportIsKeyedByHost|TestInstancePartRefuses|TestRunningTabTimesTheAppHost|TestDeferredAppReportCountsAsBackground' -count=1`. Expected: FAIL. |
| - [ ] **Step 3: Implement.** This task's existing tests run unchanged on the untracked fixture. Plan 1's `TestRunningTabTimesTheAppHost` stays meaningful there: the report is fetched inline on the request, so the `box` span is in its `Server-Timing`. Add `TestDeferredAppReportCountsAsBackground`: on `newPerfFixture`, a cold Running tab's sample has no `box` call, `PerfBackground()["box"]` rose by one, and the `instances-report` part's assembled body has the report. Update the claim probes whose markers moved into a part. |
| - [ ] **Step 4: Run** Step 2's command, `go test ./internal/console/ -run 'TestInstancesTab|TestRunningTab|TestRunningLeftovers|TestInstancePage|TestBrowserRestart|TestBrowserUpdates|TestInstanceReport|TestClaimRead' -count=1`, and the walk with `CI=1`. |
| - [ ] **Step 5: Delete** the `over:` records for `/instances` and `/instances/{host}`; walk (PASS); commit, message `console: Running and the instance page read through the view cache; the app's self-report is a deferred part`, ending with the Co-Authored-By line. |
| @@ -485,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. |
| @@ -512,15 +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 listing (`partClaims`; `ClaimCache` stays underneath), `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; 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 '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. |
| @@ -533,7 +551,7 @@ Spec §2.4 C rows `settingsGates` (cache), `aliasReadings`/`LoadBoxes` (cache, o |
| - Test: `internal/console/viewscreens_test.go` (extend) |
| **Interfaces:** |
| -- Produces: parts in `accountParts`: `apps` (the account home's app list; each app's channels through Task 9's per-app `partCore` entries, so the home page and the app tabs share them), `settings` (its `Fill` keeps the owner-only panes behind the role check the page uses), `fleet`, `fleets` (its `Gate` reads `?fleet=` and runs `resolveOwnedFleet` as the page does), `trash` (the delete form for owners only, as the page), `new-app`. Reads through `viewGet`: `fleet.json` (`{"", "", partFleetJSON}`, `liveWindow`), each owned fleet's boxes (Task 11's key), the store entitlement (`{sqid, "", partEntitlement}`, `writtenWindow`), the account telemetry (`{sqid, "", partAccountTelemetry}`, `writtenWindow`), tombstones, one entry per trashed app (`{sqid, "", trashPart(app)}`, `writtenWindow`, loader `loadTombstone`; the list of trashed apps is SQLite, read per request, rule (b); a delete's tombstone write primes the new app's entry through Task 8's one primer, so the redirect's Trash view makes no read), the region picker's edges snapshot and boxes (the shared `partEdges` and `partBoxes`). Minting a first account (`server.go:2382`) is a write, unchanged. |
| +- Produces: parts in `accountParts`: `apps` (the account home's app list; each app's channels through Task 9's per-app `partCore` entries, so the home page and the app tabs share them), `settings` (its `Fill` keeps the owner-only panes behind the role check the page uses), `fleet`, `fleets` (its `Gate` reads `?fleet=` and runs `resolveOwnedFleet` as the page does), `trash` (the delete form for owners only, as the page), `new-app`. Reads through `viewGet`: `fleet.json` (`{"", "", partFleetJSON}`, `liveWindow`), each owned fleet's boxes (Task 11's canonical `fleetBoxesPart(fleet)` entries, filtered per request to fleets the account owns), the store entitlement (`{sqid, "", partEntitlement}`, `writtenWindow`), the account telemetry (`{sqid, "", partAccountTelemetry}`, `writtenWindow`), tombstones, one entry per trashed app (`{sqid, "", trashPart(app)}`, `writtenWindow`, loader `loadTombstone`; the list of trashed apps is SQLite, read per request, rule (b); a delete's tombstone write primes the new app's entry through Task 8's one primer, so the redirect's Trash view makes no read), the region picker's edges snapshot and boxes (the shared `partEdges` and `partBoxes`). Minting a first account (`server.go:2382`) is a write, unchanged. |
| - `app_new.html`'s region and timezone initializer (today an inline script in the body using `document.currentScript`, `templates/app_new.html:22`) moves into the frame. It runs once on `DOMContentLoaded` and again on `carlos:part` for the `new-app` part, and finds the hidden timezone input and the automatic-region label by id inside the root it is given. The fragment carries no script. *(Astra round 3, finding 5.)* |
| - [ ] **Step 1: Write the failing tests:** |
| @@ -566,7 +584,7 @@ Part 3 (`2026-10-25-operator-pages.md`) owns the `/fleet*` templates and the sha |
| - `func (s *Server) hostRowsView(ctx context.Context, p *page, mode viewMode) ([]HostRow, error)` (rows built per request from the shared `partBoxes` `boxSnapshot`, as `HostRows` builds them; what `opHostRows` returns) |
| - `func (s *Server) storePendingView(ctx context.Context, p *page, mode viewMode) (storePendingList, error)` (`partStorePending`; loader `loadStorePending` (object-store reads only; the per-account SQLite lookup is joined per request); `storePendingList` is the slice `pendingStoreApplications` returns, with `viewClone`; `opStorePending` takes its length and keeps its own store-operator and no-bucket checks) |
| - `func (s *Server) metricsView(ctx context.Context, p *page, mode viewMode) (metricsResult, error)`: Task 9's `partMetrics` entry, loader `loadMetricsFacts`, `metricsWindow`, unchanged; `metricsResult` (what `LoadMetrics` returns today) is built per request from `metricsFacts` and `s.now()`. |
| - - `func (s *Server) economicsView(ctx context.Context, p *page, mode viewMode, period string) (*EconomicsView, error)`: the period's dates are computed per request from `s.now()`. The remote facts are cached: one entry per day of usage (`{"", "", economicsPart(day)}`, loader `loadEconomicsDay`: the day's metrics, edge and storage objects that `sweepUsage` and `foldStorageAndCensus` read, `economicspass.go:318`, `:486`; `liveWindow` for today, `writtenWindow` for earlier days), the active scenario and scenario names (`economics-scenarios`, `writtenWindow`), the recent bills (`economics-bills`, `writtenWindow`) and the fleet meter objects (`economics-fleet-meters`, `liveWindow`). Then `buildEconomicsView` (`economicsview.go:401`) runs per request over those facts. The account names and tiers (`Accounts`, `AccountTiers`, SQLite), the registry attribution (`loadRoutesForEconomics`, `:729`, and `ListFleets`/`ListFleetBoxes`) and the period arithmetic are read and computed per request, never cached. *(Astra round 4, finding 2.)* |
| + - `func (s *Server) economicsView(ctx context.Context, p *page, mode viewMode, period string) (*EconomicsView, error)`: the period's dates are computed per request from `s.now()`. The remote facts are cached: one entry per day of usage (`{"", "", economicsPart(day)}`, loader `loadEconomicsDay`: the day's metrics, edge and storage objects that `sweepUsage` and `foldStorageAndCensus` read, `economicspass.go:318`, `:486`; `liveWindow` for today, `writtenWindow` for earlier days), the active scenario and scenario names (`economics-scenarios`, `writtenWindow`), the bills, one entry per month (`{"", "", economicsBillPart(month)}`, `writtenWindow`, loader `loadEconomicsBill`; the request picks the months `loadRecentBills` reads today, `economicsview.go:801`, from `s.now()`), and the fleet meters, one entry per fleet, box and day (`{"", "", economicsFleetMeterPart(fleet, box, day)}`, `liveWindow` for today, `writtenWindow` before; the request picks the triples from the registry's `ListFleets`/`ListFleetBoxes` and the period's dates, as `fleetMeters` picks objects today, `economicspass.go:667-700`). A key never stands for a set of objects chosen by local state or the clock; it names the objects it reads. *(Astra round 5, finding 1.)* Then `buildEconomicsView` (`economicsview.go:401`) runs per request over those facts. The account names and tiers (`Accounts`, `AccountTiers`, SQLite), the registry attribution (`loadRoutesForEconomics`, `:729`, and `ListFleets`/`ListFleetBoxes`) and the period arithmetic are read and computed per request, never cached. *(Astra round 4, finding 2.)* |
| - Both screens use their loaders, never `LoadMetrics`' or `LoadEconomics`' inner caches, whose hits record no reads. The inner caches stay for the callers that use them today (the CLI's economics door, `OwnerAppMetrics` outside views). |
| - `func (s *Server) storeUsageView(ctx context.Context, p *page, mode viewMode) (storeUsage, error)` (`partStoreUsage`; loader `loadStoreUsage`; what `storeBucketCount` returns) |
| - `func (s *Server) architectureView(ctx context.Context, p *page, mode viewMode) (architectureData, error)`: cached facts are the inventory object and the active scenario (`partArchitecture`, `writtenWindow`, loader `loadArchitectureFacts`), `fleet.json` (`partFleetJSON`) and the boxes (`partBoxes`); the registry route list and the rate card's arithmetic are joined per request. |
| @@ -580,8 +598,11 @@ Part 3 (`2026-10-25-operator-pages.md`) owns the `/fleet*` templates and the sha |
| - `TestStoreDecisionShowsOnRedirect`: warm `/fleet/store` and the applicant account's settings; approve; both redirect targets show the decision with zero S3 calls. |
| - `TestEconomicsSaveShowsOnRedirect`: warm `/fleet/economics` (and, with it, `LoadEconomics`' inner cache through the CLI economics door); save a changed active scenario; follow the redirect: the page shows the new scenario. Again with the view's sweep held in flight (`HoldNext("list", …)` on one of its listings) when the save lands: after release, the page still shows the new scenario. |
| - Remove `TestScenarioActivationRefreshesArchitecture`'s skip (Task 8). |
| + - `TestBillSaveAcrossMonthRolloverShows`: `fx.clock` at 23:59 on 31 October; warm `/fleet/economics` (October's and September's bill entries); move the clock to 00:01 on 1 November; save November's bill; the redirect shows it (November's entry is primed by the save's re-read or loads as a miss; never October's set reused). |
| + - `TestEconomicsPeriodSwitchReadsItsOwnDays`: warm `mtd`; switch to `7d` and to `last`: each view's totals equal an uncached `LoadEconomics` for that period over the same store, and the entries used are exactly that period's days. |
| + - `TestNewFleetShowsInEconomics`: register a fleet with one box in the registry (no store write) with a meter object for today; the next economics view counts it. |
| - `TestTierSaveShowsOnRedirect`: warm `/fleet/economics/accounts` (and `/fleet/economics`); save a new tier for an account through `/fleet/economics/tier`; follow the redirect: the account's tier and its revenue line are the new ones. The tier is SQLite, joined per request, so no invalidation is involved, and the test pins that. |
| -- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestOperatorPagesWarm|TestStoreQueueRefused|TestStoreDecisionShows|TestEconomicsSaveShows|TestScenarioActivationRefreshesArchitecture|TestTierSaveShowsOnRedirect|TestViewLoadersAreRestricted' -count=1`. Expected: FAIL. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestOperatorPagesWarm|TestStoreQueueRefused|TestStoreDecisionShows|TestEconomicsSaveShows|TestScenarioActivationRefreshesArchitecture|TestTierSaveShowsOnRedirect|TestBillSaveAcrossMonthRollover|TestEconomicsPeriodSwitch|TestNewFleetShowsInEconomics|TestViewLoadersAreRestricted' -count=1`. Expected: FAIL. |
| - [ ] **Step 3: Implement.** |
| - [ ] **Step 4: Run** Step 2's command, `go test ./internal/console/ -run 'TestFleet|TestStoreApprovals|TestEconomics|TestArchitecture|TestArchPage|TestClaimRead' -count=1`, and the walk with `CI=1`. |
| - [ ] **Step 5: Keep every operator screen's `over:` record**, in both cases. In `viewBlocking` mode each of them still waits for its remote reads on the walk's cold request (plan 1 Task 10), and only Part 3's Task 13, which adds their placeholders, makes the cold request fast. Each record's reason becomes "blocks on a cold view until operator-pages Task 13"; that task deletes them. Walk (PASS: warm views have zero remote calls and are fast; the recorded screens are exempt from the cold check). Commit, message `console: cache-backed loaders for the operator pages, for Part 3`, ending with the Co-Authored-By line. *(Astra round 3, finding 2.)* |
| @@ -623,6 +644,9 @@ 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). |
| - **Astra round 3 (`CODEX-FINDINGS-CONSOLE-PLANS-R3.md`):** the class behind R1-2, R2-4 and R3-3 is fixed by invalidating by read set (Task 8), checked by the coverage oracle in `TestClaimConsoleMutationInvariant` and the warm-before-write cases (deploy-empty on ship, record hosts and environments on instance create, Architecture on scenario activation); the scripts class (R2-3, R3-5) by the no-script-in-fragments rule, the `carlos:part` event and `app_new.html`'s initializer (Tasks 7, 14); 2 operator records kept until operator-pages Task 13 in both orders (Task 15); 4 the host picker is its own part (Task 12); 6 untracked fixtures read inline, so plan 1's instrumentation tests keep their meaning, and background attribution is asserted (Tasks 8, 9, 11); 9 `bgWork` and `waitBackground` cover every request-triggered worker (Task 6); R2-6 `Assemble` takes `now` (Task 9). |
| - **Astra round 2 (`CODEX-FINDINGS-CONSOLE-PLANS-R2.md`):** 1 the pager kept, one cache entry and fragment per page (Tasks 8, 10); 4 economics saves empty and generation-guard `LoadEconomics`' inner cache before re-reading (Tasks 8, 15); 5 filter keys are a hash of the whole effective filter (Task 12); 6 only clock-independent facts are cached and bake state is derived per request from `s.now()` (Tasks 6, 9); 7 the cold pass reset is `resetForColdView` (Task 6; plan 1 Task 10 runs it); 8 is plan 1's; 12a the cold Versions test warms the core through Activity (Task 10); R1 #14 counts come from the S3 fake at the transport (plan 1 Task 9), so `Keys`, `SetFail` and `HoldNext` act on real requests and `HoldNext` can hold a listing (Task 2). |
diff --git a/docs/superpowers/plans/2026-10-25-console-ux-nav.md b/docs/superpowers/plans/2026-10-25-console-ux-nav.md| index 8be691b43..7354346d3 100644 |
| --- a/docs/superpowers/plans/2026-10-25-console-ux-nav.md |
| +++ b/docs/superpowers/plans/2026-10-25-console-ux-nav.md |
| @@ -19,7 +19,7 @@ |
| - **Copy deck first.** Task 1 builds `docs/superpowers/plans/2026-10-25-console-ux-nav-copy.md`: every new or changed user-facing string with id, where, old, new, checked by, status. A Luna pass (codex, `gpt-5.6-luna`) reviews it before any template changes. Later tasks use the approved deck text **verbatim** and add their ids to `navCopyBuilt` (Task 1's gate). A string not in the deck is not written. |
| - **House voice.** No em dashes in new or changed strings: use a full stop and a new sentence, continuing in lower case where the string is CLI or error text, normal sentence case in page prose. Human text only. Error fragments, diagnostics, JSON keys and URLs stay out of the deck. No tenant names in code, tests, fixtures or copy: new tests and examples use neutral names (`shop`, `example.com`, `web-1.example.com`). Existing fixtures (`kass`, `titogo`) are reused as they are, never newly introduced. |
| - **Copy scope trap.** Before applying a rewrite, count the string's occurrences at the base commit (`git grep -n '<text>' 0d2e2762 -- internal/console`) and change only the occurrences the deck row names. "Instances" as a column header or a count noun ("Instances: 3 / 4") stays. |
| -- **URLs keep working.** Old URLs answer with a 303 redirect, never a 404: `/deployments` to `/releases`, `/pipeline` (GET) to `/settings/pipeline`, `/settings/advanced` to `/settings`. `POST /pipeline`, `POST /place`, and every other POST keep their path and behaviour. No new routes are registered, so `testdata/claim-routes.txt` does not change. |
| +- **URLs keep working.** Old URLs answer with a 303 redirect, never a 404: `/deployments` to `/releases`, `/pipeline` (GET) to `/settings/pipeline`, `/settings/advanced` to `/settings`. `POST /pipeline`, `POST /place`, and every other POST keep their path and behaviour. No new routes are registered, so `testdata/claim-routes.txt` does not change. **The perf walk moves with them:** perf plan 1 (landed first) walks every screen in `TestConsoleScreensMeetTheBudget` through `perfTargets` in `internal/console/perfwalk_test.go` (`type perfTarget struct { Path string; Expect int; Anonymous bool }`, keyed by route pattern) and checks every target's status, `over` records included. The commit that turns a page into a 303 also changes that screen's `perfTargets` entry to `Expect: 303` and adds a 200 target for the canonical page when the walk does not already reach it (Tasks 3, 5, 7). A new target whose warm call count exceeds the screen's allowance gets a `perf-budgets.txt` record with a reason, in perf 1's grammar, never a `skip`. |
| - **Gate order unchanged.** Console security gates stay session, CSRF, owner (byte-identical 404), `requireFreshAuth` last. Redirects run the session and membership gate (`accountApp`) before answering, so a non-member gets the same 404 an unknown account gets, never a 303. |
| - **Part 2 seam.** This plan lands first (see Merge order). Perf plan 2 later edits `handleAppInstances`, `handleAppSettings`/`populateAppSettings` and `handleAppReleases`, so keep each page's data flow explicit: Task 3 names every `p.Detail` field and store read the Releases page uses, in one place, so perf 2 can move them behind its cache without re-deriving them. Put new logic in named helpers. Behaviour perf 2 must keep: a failed version listing costs only the Versions part, never Live now (`TestReleasesLiveNowSurvivesListingFailure`). Do not add caching or timing here, and do not touch `instances.Report` or `assembleChannels`. |
| - **Tests.** Run only touched packages' tests, with `-run`. Never full `make test` locally; CI does the full run. `gofmt -l internal/console` prints nothing; `go vet ./internal/console/` is clean; `GOOS=darwin go build ./...` and `GOOS=windows go build ./...` pass. Leave `GOCACHE` at its default. Heavy runs (`TestClaimConsoleMutationInvariant`) go through `nice -n 19`, once per task that changes its tables. |
| @@ -224,7 +224,7 @@ Open each PNG with the Read tool. Pass: nine tabs in order with Overview (or Log |
| - Delete: `internal/console/templates/app_deployments.html` |
| - Modify: `internal/console/templates/app_overview.html:55,69,71,75`, `app_settings.html:563` (`DeploymentsCopy.History` becomes `.Title`; NAV-C36 to C39 text) |
| - Modify: `internal/console/templates/layout.html` (`.reveal > summary h2 { display: inline; font-size: inherit; margin: 0; }`) |
| -- Test: `internal/console/deployments_test.go`, `server_test.go` (`TestReleasesTab`), `pipelinepage_test.go:23-60,129-180`, `claim_invariant_fixtures_test.go:792`, `claim_invariant_probes_read_test.go:124` |
| +- Test: `internal/console/deployments_test.go`, `server_test.go` (`TestReleasesTab`), `pipelinepage_test.go:23-60,129-180`, `claim_invariant_fixtures_test.go:792`, `claim_invariant_probes_read_test.go:124`, `perfwalk_test.go` (`perfTargets`) |
| **Interfaces:** |
| - Produces: `func (s *Server) appRedirect(sub string) http.HandlerFunc` in `appredirect.go`. Calls `s.accountApp(w, r)`; on `ok` answers `http.Redirect(w, r, "/a/"+url.PathEscape(acct.Sqid)+"/apps/"+url.PathEscape(app)+sub, http.StatusSeeOther)`. No flash, query string dropped. Task 7 reuses it. |
| @@ -263,7 +263,8 @@ Open each PNG with the Read tool. Pass: nine tabs in order with Overview (or Log |
| - [ ] **Step 4: Implement** per the Interfaces block. Add `VersionCandidatesPage` and `VersionsPage`; in `handleAppReleases` replace the `Versions(r.Context(), …)` call with `VersionsPage(r.Context(), s.cfg.Releases, acct.Sqid, p.AppName, versionsPageParam(r))` and set `VersionsPageNum`, `VersionsMore`. Delete the `/deployments` branch, set `p.DeploymentTargets = liveNowTargets(p.Detail, assembleDeploymentTargets(p.Detail, acct.Sqid))` and load `p.Pending` exactly as the deleted branch did, before the existing release reads. Register the redirect. Point the activity channel link at `/releases`. Swap `DeploymentsCopy.History` for `.Title` and apply NAV-C36 to C39. Delete `app_deployments.html` and the `solorollback` define. |
| - [ ] **Step 5: Run** the Step 3 commands plus `go test ./internal/console/ -run 'TestAppTabBarIsOneLevel|TestNavCopyDeck|TestActivity|TestOverview|TestAPIVersion|TestRetention' -count=1` and `go test ./internal/release/ -run 'TestVersionCandidates|TestProgram|TestRootfsShip' -count=1` and `nice -n 19 go test ./internal/console/ -run '^TestClaimConsoleMutationInvariant$' -count=1`. Expected: PASS. Add NAV-C21 to C39 and NAV-C45 to `navCopyBuilt` first. |
| - [ ] **Step 6: Visual check.** Snapshot `releases` at 1280 and 390 (Task 2 Step 7 commands). Pass: callout, Live now, Versions open; three closed folds whose summaries read as headings; one Roll back. |
| -- [ ] **Step 7: Commit:** `git commit -m "Console: Releases is one page; /deployments redirects to it"`. |
| +- [ ] **Step 6b: Update the perf walk in this commit.** In `perfTargets`: `"GET /a/{sqid}/apps/{app}/deployments"` becomes `[]perfTarget{{Path: "/a/" + fx.sqid + "/apps/kass/deployments", Expect: 303}}`; `"GET /a/{sqid}/apps/{app}/releases"` becomes two targets, `/a/<sqid>/apps/kass/releases` and `/a/<sqid>/apps/kass/releases?page=2`, both `Expect: 200` (the fixture's page 2 is the empty-page state, which still runs the listing). Run `go test ./internal/console/ -run '^TestConsoleScreensMeetTheBudget$' -count=1`. Expected: PASS, structural checks clean and every status matching. If `?page=2`'s warm call count exceeds the releases screen's allowance, record it per the Global Constraints. |
| +- [ ] **Step 7: Commit:** `git commit -m "Console: Releases is one page; /deployments redirects to it"` (includes `perfwalk_test.go` and any `perf-budgets.txt` line). |
| --- |
| @@ -310,7 +311,7 @@ Open each PNG with the Read tool. Pass: nine tabs in order with Overview (or Log |
| - Modify: `internal/console/server.go:3692-3702` (remove the Placement block from `handleAppInstances`; keep the region line), `server.go:3980-4024` (`handleAppSettings` calls the helper for `placement`; nav item) |
| - Modify: `internal/console/fleets.go:812-815` (`handleAppPlace` back to `/settings/placement`) |
| - Modify: `internal/console/templates/app_instances.html:60-79` (the region line stays, without the `<h2>Placement</h2>`), `app_settings.html` (new `placement` section) |
| -- Test: `internal/console/fleets_test.go:1243-1410` |
| +- Test: `internal/console/fleets_test.go:1243-1410`. `perfwalk_test.go` needs no edit: the `settings/{section}` targets derive from `appSettingsSections`, so adding `placement` adds `/settings/placement` with `Expect: 200`. |
| **Interfaces:** |
| - Produces: `func (s *Server) populateAppPlacement(p *page, acct *Account)` in `fleets.go`, beside `appPlacementSection`. It sets `AppPlacement`, `OwnedFleetNames`, `AppPlacementKnown`, and `FlashErr` from the warning when `FlashErr` is empty (the lines removed from `handleAppInstances`, moved verbatim). |
| @@ -325,6 +326,7 @@ Open each PNG with the Read tool. Pass: nine tabs in order with Overview (or Log |
| - [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestAppPlacePage|TestAppSettingsPlacement|TestInstancesTabRegionLine|TestFleetPagePlaceForm' -count=1`. Expected: the three retargeted tests FAIL (404 on the section). |
| - [ ] **Step 3: Implement** per Interfaces. Add the `placement` nav item after Domains in `setAppSettingsSection` with the approved NAV-C40 label (Task 7 finishes the order). |
| - [ ] **Step 4: Run** the Step 2 command plus `-run 'TestAppSettingsSectionRoutes|TestClaimConsoleMutationInvariant'` (the claim run under `nice -n 19`). Expected: PASS; `TestAppSettingsSectionRoutes` may still list the old nav until Task 7 and must not fail here (it checks presence, not order). Add NAV-C40 to `navCopyBuilt`. |
| +- [ ] **Step 4b: Run the perf walk:** `go test ./internal/console/ -run '^TestConsoleScreensMeetTheBudget$' -count=1`. Expected: PASS, with `/settings/placement` answering 200. Over-allowance calls get a budgets record per the Global Constraints. |
| - [ ] **Step 5: Commit:** `git commit -m "Console: Placement moves from Running to Settings"`. |
| --- |
| @@ -361,7 +363,7 @@ Open each PNG with the Read tool. Pass: nine tabs in order with Overview (or Log |
| - Modify: `internal/console/errorsview.go:310` (`handleAppErrorLevel`'s `back`) and `internal/console/analyticsview.go:99` (`handleAppAnalyticsSetting`'s `back`): `appSettingsURL(acct.Sqid, app, "general")` becomes `appSettingsURL(acct.Sqid, app, "errors-analytics")`. That one variable carries every success and refusal redirect in each handler (errorsview.go:316,321,329,334; analyticsview.go:105,110,118,126). The account-level handlers below them are unchanged. |
| - Test: `internal/console/apianalytics_test.go:73-91` (`TestSettingsPagesShowAnalyticsSwitch` reads `/settings`) |
| - Modify: `internal/console/templates/app_settings.html:356-404` (Errors and Analytics blocks move to `errors-analytics`), `:521-551` (Control plane card moves to the end of General), `app_errors.html:78` (NAV-C43), `app_analytics.html:10-13` (NAV-C44), `app_releases.html` one-channel hint (already `/settings/pipeline` from Task 3) |
| -- Test: `internal/console/appsettings_sections_test.go`, `controlplane_test.go:58,346,359,442,450,495,928,1135,1188`, `claim_invariant_probes_read_test.go:130,133`, `claim_invariant_fixtures_test.go:798` |
| +- Test: `internal/console/appsettings_sections_test.go`, `controlplane_test.go:58,346,359,442,450,495,928,1135,1188`, `claim_invariant_probes_read_test.go:130,133`, `claim_invariant_fixtures_test.go:798`, `perfwalk_test.go` (`perfTargets`) |
| **Interfaces:** |
| - Consumes: `appRedirect` (Task 3). |
| @@ -381,7 +383,8 @@ Open each PNG with the Read tool. Pass: nine tabs in order with Overview (or Log |
| - [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestAppSettings|TestErrorsAndAnalyticsSection|TestTelemetryHints|TestTelemetrySaves|TestSettingsPagesShowAnalyticsSwitch|TestAppErrorLevel|TestAppAnalytics|TestPipelineSettings|TestControlPlane|TestBucketlessSettings' -count=1`. Expected: new and rewritten tests FAIL. |
| - [ ] **Step 3: Implement** per Interfaces; apply NAV-C41 to C44 verbatim. Moved blocks move unchanged. |
| - [ ] **Step 4: Run** the Step 2 command, then `nice -n 19 go test ./internal/console/ -run '^TestClaimConsoleMutationInvariant$' -count=1`. Expected: PASS. Add NAV-C41 to C44 to `navCopyBuilt`. |
| -- [ ] **Step 5: Commit:** `git commit -m "Console: settings sidebar gains Placement and Errors and analytics; Advanced folds into General"`. |
| +- [ ] **Step 4b: Update the perf walk in this commit.** In `perfTargets`: `"GET /a/{sqid}/apps/{app}/pipeline"` becomes `[]perfTarget{{Path: "/a/" + fx.sqid + "/apps/kass/pipeline", Expect: 303}}`; `"GET /a/{sqid}/apps/{app}/settings/{section}"` keeps its targets derived from `appSettingsSections` (now walking `errors-analytics` and `placement`, still walking `pipeline` as `/settings/pipeline`, no longer deriving `advanced`) and appends one explicit `{Path: "/a/" + fx.sqid + "/apps/kass/settings/advanced", Expect: 303}`. Run `go test ./internal/console/ -run '^TestConsoleScreensMeetTheBudget$' -count=1`. Expected: PASS, with 303 for `/pipeline` and `/settings/advanced` and 200 for `/settings/pipeline`, `/settings/errors-analytics` and `/settings/placement`. |
| +- [ ] **Step 5: Commit:** `git commit -m "Console: settings sidebar gains Placement and Errors and analytics; Advanced folds into General"` (includes `perfwalk_test.go`). |
| --- |
| @@ -430,6 +433,7 @@ GOOS=darwin go build ./... && GOOS=windows go build ./... |
| go test ./internal/console/ -run 'TestNavCopyDeck|TestAppTabBar|TestReleases|TestDeployment|TestRunning|TestToolbar|TestLogsToolbar|TestAppSettings|TestErrorsAndAnalytics|TestTelemetryHints|TestPipelineSettings|TestControlPlane|TestPageHeads|TestTrash|TestAccountSettings|TestHeaderWraps|TestOneChannelApp|TestAppPlace|TestInstancePage|TestVersionsPage|TestTelemetrySaves' -count=1 |
| go test ./internal/release/ -run 'TestVersionCandidates' -count=1 |
| nice -n 19 go test ./internal/console/ -run '^TestClaimConsoleMutationInvariant$' -count=1 |
| +go test ./internal/console/ -run '^TestConsoleScreensMeetTheBudget$' -count=1 |
| ``` |
| Expected: all clean and PASS. Confirm `navCopyBuilt` holds every deck id. |
| @@ -440,7 +444,7 @@ Expected: all clean and PASS. Confirm `navCopyBuilt` holds every deck id. |
| ## Self-review notes |
| - **Spec coverage.** 1.1: Task 2 (tabs, no sub-tabs), Task 9 (390 px header). 1.2: Task 4 (heading, Restart app, toolbar, All count, leftovers), Task 5 (BYO pointer now says Settings, Placement). 1.3: Task 3. 1.4: Tasks 5 and 7; "each section is built on its own" is Part 2's (spec 2.4, `populateAppSettings`), named in the Part 2 seam constraint. 1.5: out of scope by instruction. 1.6: toolbar (Tasks 4, 6; economics excluded), danger style (Tasks 3, 8; store Decline excluded as a `/fleet*` page; app delete and Roll back already use it), page heads (Task 8; operator pages excluded), account settings rows (Task 8), help-text pointers (Tasks 7, 8), Trash per-row delete (Task 8). 1.3's "link to older ones": Task 3's pager. |
| -- **Astra review (e9f42e19) dispositions.** Finding 9: accepted, Task 3 now pages Versions (`VersionsPage`, `?page=`) and tests that version 21 onward is reachable; cost stays one listing plus 20 manifest reads per page. Finding 15: accepted, Task 7 moves both app-level POST handlers' redirects and asserts them. Round 2 finding 2: accepted, `VersionsPage` and `VersionCandidatesPage` take `ctx` and the plan uses perf 1's `Versions(ctx, …)`. Finding 12: merge order stated in the header; Task 3 lists the Releases data flow for perf 2; perf 2 owns the fragment-test conversion. |
| +- **Astra review (e9f42e19) dispositions.** Finding 9: accepted, Task 3 now pages Versions (`VersionsPage`, `?page=`) and tests that version 21 onward is reachable; cost stays one listing plus 20 manifest reads per page. Finding 15: accepted, Task 7 moves both app-level POST handlers' redirects and asserts them. Round 6 finding 5: accepted, Tasks 3, 5 and 7 update `perfTargets` in the commit that changes each status (303 for `/deployments`, `/pipeline`, `/settings/advanced`; 200 targets for `/releases`, `/releases?page=2`, `/settings/pipeline`, `/settings/errors-analytics`, `/settings/placement`). Round 2 finding 2: accepted, `VersionsPage` and `VersionCandidatesPage` take `ctx` and the plan uses perf 1's `Versions(ctx, …)`. Finding 12: merge order stated in the header; Task 3 lists the Releases data flow for perf 2; perf 2 owns the fragment-test conversion. |
| - **Spec citations re-checked against 0d2e2762.** The Overview pointer is now `app_overview.html:69,71,75` (spec says :62) and the tile heading at :55; the settings pointer is `app_settings.html:563` (spec says :494); `fleet_byo.html:76-77`; `lognav` now holds Availability as a fourth sub-tab; an extra leftover link sits at `app_settings.html:202`; the activity feed links channel targets to `/deployments` at `server.go:3965`. |
| ## Decisions taken as my call |
diff --git a/docs/superpowers/plans/2026-10-25-operator-pages.md b/docs/superpowers/plans/2026-10-25-operator-pages.md| index 5d0d3c701..4bad1cbec 100644 |
| --- a/docs/superpowers/plans/2026-10-25-operator-pages.md |
| +++ b/docs/superpowers/plans/2026-10-25-operator-pages.md |
| @@ -365,23 +365,31 @@ file LICENSE LICENSE 3f3d9e0024b1921b067d6f7f88deb4a60cbe7a78e76c64e3f1d7fc3b779 |
| **Interfaces:** |
| - Produces: |
| - - `func (s *Store) migrateOperatorPages() error`: `ALTER TABLE users ADD COLUMN last_seen INTEGER NOT NULL DEFAULT 0;` (a "duplicate column" error is swallowed, as the ALTER list does), `CREATE INDEX IF NOT EXISTS audit_by_time ON audit (created_at);`, `CREATE INDEX IF NOT EXISTS audit_by_account ON audit (account_id, id);`, `CREATE INDEX IF NOT EXISTS sessions_by_time ON sessions (created_at, address);`, `CREATE INDEX IF NOT EXISTS users_by_created ON users (created_at);`, `CREATE INDEX IF NOT EXISTS users_by_last_seen ON users (last_seen);`, `CREATE INDEX IF NOT EXISTS memberships_by_address ON memberships (address, added_at);`, `CREATE INDEX IF NOT EXISTS apps_by_creator ON apps (created_by);`. |
| + - `func (s *Store) migrateOperatorPages() error`: `ALTER TABLE users ADD COLUMN last_seen INTEGER NOT NULL DEFAULT 0;` (a "duplicate column" error is swallowed, as the ALTER list does), `CREATE INDEX IF NOT EXISTS audit_by_time ON audit (created_at);`, `CREATE INDEX IF NOT EXISTS audit_by_account ON audit (account_id, id);`, `CREATE INDEX IF NOT EXISTS sessions_by_time ON sessions (created_at, address);`, `CREATE INDEX IF NOT EXISTS users_by_created ON users (created_at);`, `CREATE INDEX IF NOT EXISTS users_by_last_seen ON users (last_seen);`, `CREATE INDEX IF NOT EXISTS memberships_by_address ON memberships (address, added_at);`, `CREATE INDEX IF NOT EXISTS apps_by_creator ON apps (created_by);`, `CREATE INDEX IF NOT EXISTS audit_by_action ON audit (action, id);`. |
| - `type OperatorAccount struct { ID int64; Sqid, Name string; Deleted bool }`; `func (s *Store) OperatorAccountBySqid(sqid string) (*OperatorAccount, error)`: the account row whatever its `deleted_at` (nil when there is no row). Operator pages only: its doc comment says it must never back a member-facing lookup, which keeps using `AccountBySqid` and its tombstone exclusion (`store.go:1068`). |
| - `func (s *Store) TouchLastSeen(address string, now time.Time) error`: `UPDATE users SET last_seen = ? WHERE address = ? AND last_seen < ?` (never moves backwards; no row, no insert). |
| - `type OperatorCounts struct { People, Active30, Active7, ActiveToday, NewPeople7, NewPeoplePrev7, NewAccounts7, NewAccountsPrev7, Apps, NewApps7, DeploysToday, DeployApps int }`; `func (s *Store) OperatorCounts(now time.Time) (OperatorCounts, error)` with the windows from "Decisions" (active, set-based, never a correlated subquery: `SELECT COUNT(*) FROM (SELECT address FROM users WHERE last_seen >= ?1 UNION SELECT address FROM sessions WHERE created_at >= ?1)`, served by `users_by_last_seen` and the covering `sessions_by_time`; deploys: `audit.created_at >= <UTC midnight> AND action IN deployActions`, `DeployApps` = distinct `(account_id, app)` among them). |
| - `var deployActions = []string{"promote", "rollback"}` (check both strings against the `Action:` values in `server.go` and `apicli.go` before writing them). |
| - `type DayCount struct { Day time.Time; N int }`; `func (s *Store) NewPeoplePerDay(now time.Time, days int) ([]DayCount, error)`: `days` entries, oldest first, the last one today (UTC), zero-filled; rows created after `now` are not counted. |
| - - Every statement these methods run is a package-level constant (`opSQLActive`, `opSQLNewPeople`, `opSQLNewAccounts`, `opSQLApps`, `opSQLDeploys`, `opSQLPerDay`, `opSQLNewestPeople`, `opSQLPeoplePage`, `opSQLAccountsPage`, `opSQLFeed…` for each filter shape) so the plan witness below can `EXPLAIN QUERY PLAN` exactly what runs. The per-person columns of `NewestPeople` and `PeoplePage` (accounts, first account, apps) are computed only for the page's rows: the `LIMIT`/`OFFSET` is applied in an inner query over `users`, and the outer query looks each row up through `memberships_by_address` and `apps_by_creator`. |
| + - Every statement these methods run is a package-level constant (`opSQLPeopleTotal`, `opSQLActive`, `opSQLNewPeople`, `opSQLNewAccounts`, `opSQLApps`, `opSQLDeploys`, `opSQLPerDay`, `opSQLNewestPeople`, `opSQLPeoplePage`, `opSQLAccountsPage`, `opSQLFeed…` for each filter shape) so the plan witness below can `EXPLAIN QUERY PLAN` exactly what runs. The per-person columns of `NewestPeople` and `PeoplePage` (accounts, first account, apps) are computed only for the page's rows: the `LIMIT`/`OFFSET` is applied in an inner query over `users`, and the outer query looks each row up through `memberships_by_address` and `apps_by_creator`. |
| - `type PersonRow struct { Address string; Joined, LastSeen time.Time; Accounts int; FirstAccount string; Apps int }` (`LastSeen` zero when never seen; `FirstAccount` `""` when none); `func (s *Store) NewestPeople(limit int) ([]PersonRow, error)` (newest `created_at` first, ties by address); `func (s *Store) PeoplePage(q string, offset, limit int) ([]PersonRow, int, error)` (filtered by address `LIKE` with `ESCAPE '\'`, `%`, `_` and `\` escaped; newest first; returns the filtered total). |
| - `type AccountRow struct { ID int64; Sqid, Name, Plan string; Created time.Time; Apps, Members int }`; `func (s *Store) AccountsPage(q string, offset, limit int) ([]AccountRow, int, error)` (live accounts, `name` or `sqid` matching literally, newest first; `Plan` from `account_plans.plan`, `""` when none). |
| - - `type ActivityFilter struct { AccountID int64; Actions, Exclude []string }` (`AccountID` 0 means every account, and `-1` means "an account matched nothing", which answers no rows without a query); `type FeedRow struct { ID int64; At time.Time; Address, AccountName, AccountSqid, App, Action, Detail string }`; `func (s *Store) ActivityFeed(f ActivityFilter, beforeID int64, limit int) ([]FeedRow, error)` (`ORDER BY audit.id DESC`, `id < beforeID` when `beforeID > 0`, `LEFT JOIN accounts` for name and sqid, deleted accounts included). |
| + - `type ActivityFilter struct { AccountID int64; Actions, Exclude []string }` (`AccountID` 0 means every account, and `-1` means "an account matched nothing", which answers no rows without a query); `type FeedRow struct { ID int64; At time.Time; Address, AccountName, AccountSqid, App, Action, Detail string }`; `func (s *Store) ActivityFeed(f ActivityFilter, beforeID int64, limit int) ([]FeedRow, error)` (`ORDER BY audit.id DESC`, `id < beforeID` when `beforeID > 0`, `LEFT JOIN accounts` for name and sqid, deleted accounts included). Its shapes, each a constant: no filter walks `audit` by primary key newest first and stops at `limit`; `AccountID` alone walks `audit_by_account`; `Actions` runs one `WHERE action = ? AND id < ? ORDER BY id DESC LIMIT ?` per action through `audit_by_action` and merges the at most `limit × len(Actions)` rows in Go, newest first, cut to `limit` (so a rare kind never walks the whole table and no query sorts); `Actions` with `AccountID` runs the per-account walk with the action test in the row; `Exclude` (the `other` kind, most rows) walks by primary key with the exclusion in the row. |
| Every method is a read on `s.db` except `TouchLastSeen`, which writes `users`, a NonApp table (`store_gate.go:204`), so it needs no claim SQL adapter and passes the gate on a host-claim console. No method reaches a raw handle, so `TestClaimSQLSeamCallers` is unaffected. *(My call: new reads go in their own file with their own migration, "for the same reason" the other features' tables do, `store.go:524-551`.)* |
| - [ ] **Step 1: Write the failing tests** in `opstore_test.go`, each on a store from `Open(filepath.Join(t.TempDir(), "console.db"))` with rows written through the existing methods at fixed times (`now := time.Date(2026, 10, 25, 12, 0, 0, 0, time.UTC)`): `EnsureUser`, `CreateSessionMethod`, `CreateAccount`, `AddMember`, `DeleteAccount`, `RecordActivity`, `RecordEvent`, `SetAlertSeen` (or whatever writes `alert_seen`, `store.go:2277`), and the app-claim method the fixtures use. |
| - - `TestMigrateOperatorPagesIsIdempotent`: `Open` twice on one path; `PRAGMA index_list` names all seven new indexes on their tables; `users` has `last_seen`. |
| - - `TestOperatorQueryPlans` (the witness): on a store migrated by `Open`, `EXPLAIN QUERY PLAN` of every `opSQL…` constant with representative arguments. No plan line contains `CORRELATED`. `sessions`, `audit` and `users` appear only as `SEARCH … USING INDEX` or `… USING COVERING INDEX`, with two named exceptions where a scan is the query: `users` in `opSQLPeoplePage` with a non-empty search (a `LIKE '%q%'` cannot use an index) and `audit` in the `other` kind's `NOT IN` feed, which walks `audit` by primary key newest first and stops at its `LIMIT` (asserted as `SCAN audit` with no `USE TEMP B-TREE`). `accounts`, `apps`, `memberships` and `account_plans` may be scanned only in `opSQLApps` and `opSQLAccountsPage`, bounded by the number of accounts and apps. Removing `sessions_by_time` (by hand, once) makes it fail with the old `CORRELATED SCALAR SUBQUERY` shape. |
| - - `TestOperatorCountsAtScale`: a store with 20,000 users, 60,000 sessions over 30 days, 2,000 accounts, 8,000 apps and 200,000 audit rows (inserted in one transaction through a test helper); `OperatorCounts`, `NewPeoplePerDay`, `NewestPeople`, the first `PeoplePage` and each feed kind's first page are timed; each is printed, and under `CI` each must finish within 20 ms. Not parallel; listed in `.amadan/test-weights.tsv` if it takes a second or more. |
| + - `TestMigrateOperatorPagesIsIdempotent`: `Open` twice on one path; `PRAGMA index_list` names all eight new indexes on their tables; `users` has `last_seen`. |
| + - `TestOperatorQueryPlans` (the witness): on a store migrated by `Open`, `EXPLAIN QUERY PLAN` of every `opSQL…` constant with representative arguments, checked against that query's own intended access pattern, written as a table `opQueryPlans` (`name`, the constant, its args, the plan lines that must appear, the lines that must not). Every query forbids `CORRELATED` and `USE TEMP B-TREE FOR ORDER BY`; beyond that each states its pattern: |
| + - `opSQLPeopleTotal` (`COUNT(*) FROM users`): a total-count scan, `SCAN users USING COVERING INDEX …`. |
| + - `opSQLActive`: `SEARCH users USING … INDEX users_by_last_seen` and `SEARCH sessions USING COVERING INDEX sessions_by_time`, combined by the `UNION` (its `USE TEMP B-TREE FOR UNION` is allowed: it holds only addresses in the window). |
| + - `opSQLNewPeople`, `opSQLPerDay`: `SEARCH users USING COVERING INDEX users_by_created`. |
| + - `opSQLNewestPeople` and `opSQLPeoplePage` with no search: a bounded ordered scan, `SCAN users USING INDEX users_by_created` stopped by `LIMIT`/`OFFSET`, with the per-row `SEARCH memberships USING INDEX memberships_by_address` and `SEARCH apps USING INDEX apps_by_creator`; with a search, `SCAN users` (a `LIKE '%q%'` cannot use an index). |
| + - `opSQLDeploys`: `SEARCH audit USING INDEX audit_by_time`. |
| + - `opSQLFeedAll`: a bounded ordered scan, `SCAN audit` (by primary key, newest first, stopped by `LIMIT`); `opSQLFeedBefore`: `SEARCH audit USING INTEGER PRIMARY KEY (rowid<?)`; `opSQLFeedAccount`: `SEARCH audit USING INDEX audit_by_account`; `opSQLFeedAction`: `SEARCH audit USING INDEX audit_by_action (action=? AND rowid<?)`; `opSQLFeedOther`: `SCAN audit` as for all. |
| + - `opSQLApps`, `opSQLAccountsPage`: scans of `accounts`, `apps`, `memberships` and `account_plans` are allowed, bounded by the number of accounts and apps. |
| + The pattern check is shown to bite twice, by hand, once each: dropping `sessions_by_time` turns `opSQLActive`'s sessions line into `SCAN sessions` and fails; rewriting `opSQLActive` in the earlier per-user `EXISTS` form fails on `CORRELATED SCALAR SUBQUERY`. |
| + - `TestOperatorCountsAtScale`: a store with 20,000 users, 60,000 sessions over 30 days, 2,000 accounts, 8,000 apps and 200,000 audit rows (inserted in one transaction through a test helper); `OperatorCounts`, `NewPeoplePerDay`, `NewestPeople`, the first `PeoplePage` and each feed kind's first page (with and without an account filter, and with a rare kind of 50 rows among the 200,000) are timed; each is printed, and under `CI` each must finish within 20 ms. Not parallel; listed in `.amadan/test-weights.tsv` if it takes a second or more. |
| - `TestTouchLastSeenNeverMovesBack`: touch at `now`, then at `now-1h`: `last_seen` stays `now`; a touch for an unknown address inserts nothing. |
| - `TestOperatorCountsWindows`: users created at `now-1h`, `now-6d`, `now-8d`, `now-13d`, `now-20d`; accounts at `now-2d`, `now-10d`; apps (one deleted); audit `promote` rows today for two apps and one yesterday; `last_seen` for two people and a session at `now-3d` for a third → `People 5`, `NewPeople7 2`, `NewPeoplePrev7 2`, `NewAccounts7 1`, `NewAccountsPrev7 1`, `Active30 3`, `DeploysToday 2`, `DeployApps 2`, `Apps` excludes the deleted one. |
| - `TestNewPeoplePerDayFillsZeroDaysAndIgnoresFuture`: three users today, one 29 days ago, none between, one at `now+1h`: 30 entries, `[0].N == 1`, `[29].N == 3`, every other `N == 0`, `[29].Day` is 2026-10-25 UTC midnight. |
| @@ -554,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)`. |
| @@ -581,30 +590,31 @@ Each loop wraps one pass in `s.jobs.Run` with its worker name as a string litera |
| **Interfaces:** |
| - Consumes: Task 4's reads, `s.jobs.Snapshot()`, `opFleetJSON`, `opHostRows`, `opStorePending`, `Server.alertsNow.Firing()` (Task 7A), `op_meter`, OPS-8, OPS-20 to OPS-76. |
| - Produces: |
| - - `type attentionItem struct { Lead, Code, Tail, Href, Link string }` (`Code` is set for a box, service, rule or job name and renders in `<code>`); `type attentionInput struct { Fleet *status.Fleet; FleetErr error; Now time.Time; Alerts []FiringAlert; AlertsKnown bool; StorePending *int; Jobs []JobStatus }`; `func attentionItems(in attentionInput) (items []attentionItem, tone string)`: one item per silent box (OPS-24, link Boxes `#box-<label>`), one for an old summary (OPS-25), one for a read failure (OPS-26), one per down service (OPS-27), one per firing alert when `AlertsKnown` (OPS-28, link Metrics), one storage line (OPS-29 or OPS-30, link Storage requests) when `StorePending` is non-nil and positive, one per failed job (OPS-31, link `/fleet/boxes#jobs` labelled OPS-32); tone by the rule in "Decisions". |
| + - `type attentionItem struct { Lead, Code, Tail, Href, Link string }` (`Code` is set for a box, service, rule or job name and renders in `<code>`); `type attentionInput struct { Fleet *status.Fleet; FleetErr error; Boxes []dashBox; Now time.Time; Alerts []FiringAlert; AlertsKnown bool; StorePending *int; Jobs []JobStatus }`, where `Boxes` is the very slice the Boxes table renders, built once per request by `dashBoxes` from `HostRows` (staleness judged at request time, `status.BoxStale` against `now`), `fleet.json` and `now`; `func attentionItems(in attentionInput) (items []attentionItem, tone string)`: one item per row of `Boxes` whose status is Silent (OPS-24, link Boxes `#box-<label>`), which covers a box only `HostRows` lists, and never reads `FleetBox.Stale`, one for an old summary (OPS-25), one for a read failure (OPS-26), one per down service (OPS-27), one per firing alert when `AlertsKnown` (OPS-28, link Metrics), one storage line (OPS-29 or OPS-30, link Storage requests) when `StorePending` is non-nil and positive, one per failed job (OPS-31, link `/fleet/boxes#jobs` labelled OPS-32); tone by the rule in "Decisions". |
| - `type dashBar struct { Day time.Time; N, H int }`; `func dashBars(days []DayCount) []dashBar` (the height rule in "Decisions"). |
| - `func dashStats(c OperatorCounts) []opStat`: People (lead; note OPS-34), New people this week (delta OPS-37/38/39 against `NewPeoplePrev7`), New accounts this week (same against `NewAccountsPrev7`), Apps (delta OPS-41 or OPS-42 from `NewApps7`), Deploys today (note OPS-44/45 when `DeploysToday > 0`). Tones per "Decisions"; numbers through `opNumber`. |
| - `type dashBox struct { Label, Region string; Status opPill; Meter *opMeter; LastSeen time.Time }` (`Meter` nil for a silent box or one with no metrics block, rendered as OPS-76); `func dashBoxes(f *status.Fleet, hosts []HostRow, now time.Time) (rows []dashBox, stale bool)`: one row per `HostRow` in label order, plus a row for any `FleetBox` with no `HostRow` (Silent, no meter, no last report); the status rule in "Decisions"; an empty region is OPS-76. |
| - `type dashView struct { Attention []attentionItem; Tone string; Stats []opStat; Bars []dashBar; Newest []PersonRow; Activity []FeedRow; Boxes []dashBox; HasFleet bool; Jobs []opJobRow }` |
| - `func (s *Server) handleDashboard(w http.ResponseWriter, r *http.Request)`: `operatorOnly`; the SQLite reads (`OperatorCounts`, `NewPeoplePerDay(now, 30)`, `NewestPeople(5)`, `ActivityFeed({}, 0, 10)`) each log and leave their section empty on error (never a 500); `opFleetJSON`, `opHostRows` (a failure logs and the Boxes section shows its existing degrade line, never a 500), `opStorePending`, and `s.alertsNow.Firing()` (in-process, no read); render `ops_dashboard`. |
| -`ops_dashboard.html` follows the mockup top to bottom: `op_page_header` (OPS-8, OPS-20 with `.Brand`); the callout (`rst-callout rst-tone="{{.Dash.Tone}}"`, the matching icon `circle-check`, `triangle-alert` or `circle-x`, `aria-hidden`; the title OPS-21, OPS-22 or OPS-23; a `<ul co-attention>` of items, each `{{.Lead}}<code>{{.Code}}</code>{{.Tail}} <a href="{{.Href}}">{{.Link}}</a>`); the `rst-stats rst-card` band of `op_stat`; the chart (`rst-box-head` OPS-46; `<div rst-card>`, `<div co-bars aria-hidden="true">` of `<span co-bar co-h="{{.H}}">`, the axis with the first day as `2 Jan` and OPS-50, then `<table class="rst-sr-only">` with caption OPS-47, headings OPS-48 and OPS-49 and one row per day); Newest people (OPS-51, link OPS-52 to `/fleet/people`, `.co-people` rows: address as `.rst-nm`, account or OPS-56, `ago` joined, apps); Latest activity (OPS-58, link OPS-59, `.co-activity` rows: `ago`, address, `Detail`, app or OPS-56; OPS-64 when empty); Boxes (`{{define "ops_dashboard_boxes"}}` so Task 13 can serve it as its own part: h2 OPS-11, link OPS-65, `.co-boxes` rows of OPS-66 to OPS-70, the label as `.rst-nm` linking `/fleet/boxes#box-<label>`, `op_status`, the region, `op_meter` or OPS-76, `ago` of the last report; OPS-71 when there is no snapshot); `op_jobs`. Empty newest people is OPS-57. |
| +`ops_dashboard.html` follows the mockup top to bottom: `op_page_header` (OPS-8, OPS-20 with `.Brand`); the callout (`rst-callout rst-tone="{{.Dash.Tone}}"`, the matching icon `circle-check`, `triangle-alert` or `circle-x`, `aria-hidden`; the title OPS-21, OPS-22 or OPS-23; a `<ul co-attention>` of items, each `{{.Lead}}<code>{{.Code}}</code>{{.Tail}} <a href="{{.Href}}">{{.Link}}</a>`); the `rst-stats rst-card` band of `op_stat`; the chart (`rst-box-head` OPS-46; `<div rst-card>`, `<div co-bars aria-hidden="true">` of `<span co-bar co-h="{{.H}}">`, the axis with the first day as `2 Jan` and OPS-50, then `<table class="rst-sr-only">` with caption OPS-47, headings OPS-48 and OPS-49 and one row per day); Newest people (OPS-51, link OPS-52 to `/fleet/people`, `.co-people` rows: address as `.rst-nm`, account or OPS-56, `ago` joined, apps); Latest activity (OPS-58, link OPS-59, `.co-activity` rows: `ago`, address, `Detail`, app or OPS-56; OPS-64 when empty); Boxes (`{{define "ops_dashboard_boxes"}}`, a partial of the dashboard body: h2 OPS-11, link OPS-65, `.co-boxes` rows of OPS-66 to OPS-70, the label as `.rst-nm` linking `/fleet/boxes#box-<label>`, `op_status`, the region, `op_meter` or OPS-76, `ago` of the last report; OPS-71 when there is no snapshot); `op_jobs`. Empty newest people is OPS-57. |
| - [ ] **Step 1: Write the failing tests** in `opdashboard_test.go` (with Task 7A's `opProbeStore`). `seedOperatorWorld(t, fx)` (test-only, shared with Tasks 10, 11 and 14): eight people (`ann@example.com` and others under `example.com`, joined over 30 days with two today and none 10 to 20 days ago), accounts `shop` and `notes` minted through `mintAccount`, apps under them, activity rows (two `promote` today on two apps, a `signin`, an `invite-sent`), `seedHostBoxes` (one fresh box, one dark), `box-1` publishing `disk` firing and one `alertPass` run (so the projection holds it), plus a stale `alert_seen` firing row for a cleared `box-2`/`mem` (history the dashboard must ignore), a failed `StartEconomicsPass` run; Paul is operator and store operator with one pending storage application (as `storepage_test.go` seeds one). |
| - - `TestAttentionItemsEachCondition` (not acceptance, table-driven over `attentionItems`): nothing wrong gives no items and `positive`; a stale box gives OPS-24 with the label and `warning`; `GeneratedAt` older than 15 minutes gives OPS-25; `FleetErr` gives OPS-26; a down service gives OPS-27 and `negative`; an alert gives OPS-28; `StorePending` 1 and 3 give OPS-29 and OPS-30, nil gives none; a failed job gives OPS-31 linking `/fleet/boxes#jobs`. |
| + - `TestAttentionItemsEachCondition` (not acceptance, table-driven over `attentionItems`): nothing wrong gives no items and `positive`; a `Boxes` row with status Silent gives OPS-24 with the label and `warning`, and a `FleetBox.Stale` with no Silent row gives nothing (the callout reads only `Boxes`); `GeneratedAt` older than 15 minutes gives OPS-25; `FleetErr` gives OPS-26; a down service gives OPS-27 and `negative`; an alert gives OPS-28; `StorePending` 1 and 3 give OPS-29 and OPS-30, nil gives none; a failed job gives OPS-31 linking `/fleet/boxes#jobs`. |
| - `TestDashboardNeedsAttentionFromRealRows`: on the seeded world, the page's callout has `rst-tone="warning"`, OPS-23 with 4 (the dark box, the alert, the storage request, the failed job), and each item's link; an operator who is not a store operator sees 3 and no storage item. |
| - `TestSwallowedAlertFailureShowsAsFailed`, second half (Task 7's test, extended here): after the failed alert run, GET `/fleet`: the callout lists OPS-31 naming the Alerts label with its link to `/fleet/boxes#jobs`, and the jobs table shows Alerts with OPS-81. |
| - `TestDashboardIgnoresAlertHistory`: on the seeded world, no item names `box-2` or `mem`; with the projection not yet known (a fresh server, no pass), no alert item at all and the page is 200. |
| - `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` (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. |
| - `TestDashboardBoxesKeepTheMockupColumns`: on the seeded world (`seedHostBoxes`), the Boxes section has the five headings OPS-66 to OPS-70 in order; the fresh box's row has `op_status` Healthy, region `eu-west-1`, `<meter rst-meter-bar` with value 50 and `50%`, and an `ago` last report; the dark box's row is Silent with OPS-76 and a last report about an hour ago. |
| - `TestDashboardRemoteReadsAreTheDeclaredOnes`: with an `opProbeStore`, GET `/fleet`: every key it was asked for is `status/fleet.json`, the `status/boxes/` listing or a key under it, or the storage queue's. (Task 13 turns these into zero on a warm view.) |
| - Walk fixture: `newPerfFixture` (plan 1, `perfwalk_test.go`) gains `seedOperatorScale(t, fx)`, so every operator screen is measured over populated tables: 300 people (joined across 60 days, half with `last_seen`, sessions for a third), 60 accounts each with 2 to 6 members, 1 to 8 apps and a plan row, and 3,000 audit rows spread over the accounts, the six account actions and `promote`/`rollback` (written in one transaction through a test helper so the walk stays well under 10 s). Neutral names (`person-<n>@example.com`, `shop-<n>`). |
| -- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestAttentionItems|TestDashboard|TestEveryOperatorPage' -count=1`. Expected: FAIL. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestAttentionItems|TestAttentionAndBoxesAgree|TestDashboard|TestEveryOperatorPage' -count=1`. Expected: FAIL. |
| - [ ] **Step 3: Implement**; add OPS-20 to OPS-31 and OPS-33 to OPS-76 to `operatorPagesCopyBuilt` (OPS-8 and OPS-32 are already there). |
| - [ ] **Step 4: Run** Step 2's command, `go test . -run TestOperatorPagesCopy -count=1`, `go test ./internal/console/ -run 'TestOperatorGate|TestBoxes' -count=1`, `nice -n 19 go test ./internal/console/ -run '^TestClaimConsoleMutationInvariant$' -count=1`, and the walk without `CI`. |
| - [ ] **Step 5: Visual check.** Run Task 14's command for `dashboard` only, at 1280 and 390, light and dark; compare with the mockup. Pass: the order and shapes of the mockup; the callout lists four items; at 390 the stats band wraps and the back strip shows. Then commit, message `console: the operator dashboard`. |
| @@ -692,22 +702,24 @@ Each page: `op_top`, `op_page_header` (its rail label and its subhead row), then |
| - Produces: |
| - the seams now read through the loaders: `opFleetJSON` → `fleetJSONView(ctx, p, mode)`, `opHostRows` → `hostRowsView`, `opStorePending` → `storePendingView` (still only for a store operator); each seam gains a `mode viewMode` parameter. |
| - `const boxesWindow = 60 * time.Second`: the window the per-box entry (`{"", "", partBoxes}`, plan 2's key) is read with. If plan 2 Task 15's `hostRowsView` uses `liveWindow` (30 s), Task 13 gives it a window parameter and passes `boxesWindow` from both the dashboard and Boxes, so they share one entry. *(My call on the exact value, from the coordinator's "~60 s".)* |
| - - `var fleetParts map[string]viewPart` with `dashboard`, `dashboard-boxes` (the `ops_dashboard_boxes` section alone), `boxes`, `store`, `metrics`, `economics` and `economics-accounts` (both reading `?period=`; the accounts part also `q`, `pos`, `after`), `architecture`. `Gate` is the page's own (`operatorOnly` through a wrapper returning its `page`; `storePageOperator` for `store`; `handleEconomicsAccounts`' gate for its part); `Fill` the page's fill; `Template` `<name>_body`. |
| + - `var fleetParts map[string]viewPart` with `dashboard`, `boxes`, `store`, `metrics`, `economics` and `economics-accounts` (both reading `?period=`; the accounts part also `q`, `pos`, `after`), `architecture`. `Gate` is the page's own (`operatorOnly` through a wrapper returning its `page`; `storePageOperator` for `store`; `handleEconomicsAccounts`' gate for its part); `Fill` the page's fill; `Template` `<name>_body`. |
| - route `GET /fleet/part/{part}` → `handleFleetPart`, shaped like plan 2's `handleAppPart`: look up the part (unknown is the missing-route 404), run `Gate` first, `Fill(viewCached)` then `Fill(viewBlocking)` bounded by `viewLoadTimeout`, render with `Cache-Control: no-store`, 503 `partfailed` on a failure. |
| - - **Plan 2's part rules, which these parts follow:** a deferred fragment contains no `<script>` (the economics initializers and their `carlos:part` listeners live in the page frame; the data is an attribute), and plan 2 Task 7's `partloader` fires `carlos:part` with the inserted element after each replacement (its `TestPartLoaderFiresTheEvent`). Each economics page's script adds `document.addEventListener("carlos:part", e => { if (e.detail && e.detail.id === "econ-body") econInit(e.detail) })` (and `econAccountsInit` on the accounts page), and its `econ-body` wrapper is the root of the `economics` and `economics-accounts` parts. |
| + - **Plan 2's part rules, which these parts follow:** a deferred fragment contains no `<script>` (the economics initializers and their `carlos:part` listeners live in the page frame; the data is an attribute), and plan 2 Task 7's `partloader` fires `carlos:part` with the inserted element after each replacement (its `TestPartLoaderFiresTheEvent`). The event's payload is plan 2's `detail: {part, root}` (`part` the part name, `root` the inserted element). Each economics page's script adds `document.addEventListener("carlos:part", e => { if (e.detail && e.detail.part === "economics") econInit(e.detail.root) })`, and the accounts page the same with `"economics-accounts"` and `econAccountsInit`; each initializer finds `#econ-body` inside `root` (the part's root is that wrapper or contains it) before it binds anything. |
| - test-only: plan 2's `HoldNext("list", match)` (plan 2 Task 2, on the S3 fake's real requests) holds the next matching listing request after it has been read; this plan adds no hold helper of its own. |
| - every operator template follows plan 2's shape with the operator layout: `{{define "<name>"}}{{template "op_top" .}}{{template "op_page_header" …}}{{if .Deferred}}{{template "deferred" .}}{{else}}{{template "<name>_body" .}}{{end}}{{template "op_bottom" .}}{{end}}`, and `{{define "<name>_body"}}{{template "asof" .}}…{{end}}`. The header and rail stay outside the part. People, Activity and the index read only SQLite and get no part. |
| -On a `fleet.json` miss, the dashboard's whole body is the deferred part, because its first section (the callout) depends on it. On a per-box miss alone (`fleet.json` warm), the dashboard renders everything else and the Boxes section is the `dashboard-boxes` placeholder, filled a moment later. *(My call, matching plan 2's rule that the whole body is the part unless a section can render without the missing data.)* |
| +On a miss of either `fleet.json` or the box entry, the dashboard's whole body is the deferred part: the callout and the Boxes table must come from the same box evidence (Task 9's `attentionInput.Boxes`), so neither renders without it. A stale entry is served at once, so this costs only the first view after a start or an invalidation. *(My call; replaces the earlier separate `dashboard-boxes` part, which could show a callout built without the box rows beside them.)* |
| **S3 cost of the per-box data.** One `List` of `status/boxes/` plus one `Get` per box, at most once per `boxesWindow` (60 s), and only when an operator views the dashboard or Boxes (the two share the entry; single flight, so concurrent viewers make one load; app pages that read `partBoxes` at their own window share it too). No view, no reads: no timer refreshes it. The cached entry is the raw `boxSnapshot`; `HostRow`s, status words and ages are built per request from it and the clock (rule (a)). With 10 boxes and an operator watching continuously that is at most 11 requests a minute; on top, `fleet.json` is one `Get` per `liveWindow` and the storage queue one `List` plus one `Get` per pending account per its window. A warm dashboard GET makes zero S3 reads, within the at-most-one rule. |
| - [ ] **Step 1: Write the failing tests:** |
| - `TestOperatorPagesWarmMakeNoRemoteCalls`: one sub-test per operator screen on `newPerfFixture` with `seedOperatorWorld`, Paul as operator and store operator: `getAssembled` twice, `perfQuiesce(fx)` (plan 2's `waitBackground`), reset counts, GET: zero S3 and zero host calls. |
| - `TestDashboardColdArrivesWithAPlaceholder`: a fresh fixture with latency on: the first GET of `/fleet` answers within 150 ms (time to first byte) with `data-part="/fleet/part/dashboard"` and the rail; `getAssembled` gives the dashboard with the callout. |
| - - `TestDashboardBoxesColdAloneIsDeferred`: `held, release := lat.HoldNext("list", func(p string) bool { return p == "status/boxes/" })`; GET `/fleet` (cold: it starts the `fleet.json`, storage-queue and box loads and renders the whole-body placeholder); wait for `held` to close (the box load is inside its listing); then wait for the other two loads by joining them through the production seams in blocking mode, `fx.srv.opFleetJSON(ctx, &page{}, viewBlocking)` and `fx.srv.opStorePending(ctx, &storePage, viewBlocking)` (each joins the load in flight for its key and returns when it publishes; `ctx` has a 5 s deadline; `storePage` is a `page` built by `opPage` for Paul, so the store-operator check passes). Now GET `/fleet` again: within 150 ms, the callout and stats render and the Boxes section is `data-part="/fleet/part/dashboard-boxes"`. `release()`; GET that part: the five-column table. Finally `fx.srv.waitBackground()`. |
| - - `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 `carlos:part` on `econ-body`, 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. |
| + - `TestDashboardWaitsForBoxEvidenceAsAWhole`: `held, release := lat.HoldNext("list", func(p string) bool { return p == "status/boxes/" })`; GET `/fleet` (cold): within 150 ms, the whole-body placeholder `data-part="/fleet/part/dashboard"` and no callout; wait for `held`, then join the `fleet.json` and storage-queue loads through the seams in blocking mode (`fx.srv.opFleetJSON(ctx, &page{}, viewBlocking)`, `fx.srv.opStorePending(ctx, &storePage, viewBlocking)`, 5 s deadline); GET `/fleet` again: still the whole-body placeholder, never a callout without box rows. `release()`; the assembled page's callout and Boxes table agree (the dark seeded box is Silent in the table and listed as OPS-24 in the callout). Then advance `fx.clock` across the fifteen-minute line for the fresh box as in Task 9's test: the next assembled view, served from the cache, marks it Silent in both places. Finally `fx.srv.waitBackground()`. |
| + - `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): |
| @@ -718,7 +730,7 @@ On a `fleet.json` miss, the dashboard's whole body is the deferred part, because |
| - `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|TestDashboardBoxesCold|TestBoxReadsOncePerWindow|TestEveryFleetPart|TestDashboardAfterAStore|TestEconomicsScenarioSaveWarm|TestArchitectureRefreshWarm|TestDashboardCountsAreNeverCached|TestOperatorPagesJoinLocalState|TestEconomicsEditAndSave|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`. |
| @@ -772,8 +784,10 @@ 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). |
| - **Coordinator change (2026-10-25).** The dashboard's Boxes table keeps the mockup's columns from `HostRows` through the view cache (Decisions, Tasks 9 and 13); the spec's "`HostRows`' per-box reads stay off the dashboard" is met by keeping them off the request path of a warm view, with the per-window cost stated in Task 13. |
| - **Spec coverage.** §3.1: copy in (Task 2), `go:embed`, own origin, long cache, content hash (Task 2), `VERSION` and hash test (Task 2), MPL notice (Task 2, via `LICENSE` since the files carry no header), no `light.js` (not copied), fetches nothing (Task 3's shell test). §3.2: one layout ported from `console.html` (Task 3), brand and account menu with Customer console and Sign out (Task 3), rail order and labels (Tasks 1, 3), below 800 px index and page (Task 3's `/fleet/index`, Task 14), light and dark through the theme (Tasks 2, 14), `operatorOnly` unchanged (Task 3's gate test, every page task). §3.3: dashboard, page header, needs attention with all five conditions, the stats band, the 30-day bars with screen-reader numbers, newest people, latest activity, boxes, background jobs (Task 9); old `/fleet` content to Boxes (Task 8); errors and edge failures out of scope (not built). §3.4: `last_seen` with the hourly throttle (Tasks 4, 5), account-level audit rows and the feed newest-first with an index for time-window counts (Tasks 4, 6, 11), job registry, in-process, Not run yet after restart (Task 7), counts from SQLite and `fleet.json` through the view cache, per-box rows from `HostRows` through the cache too, never on a warm view's request path (Tasks 4, 9, 13), 150 ms and one S3 read (Tasks 9, 13). §3.5: People and accounts (Task 10), Activity (Task 11), Boxes plus jobs (Task 8), Metrics with Console speed, Storage requests, Economics with seg-tabs and a list-bar, Architecture (Tasks 3, 12), old URLs keep working (all registrations kept; `/fleet` stays 200). §3.6: one `<h1>`, rail `aria-current`, no inline style (Task 3, every page), screenshots (Task 14), every page in the walk (Tasks 2 to 13), Luna copy pass (Task 1). §3.7: lands after plan 1, alongside plan 2 and Part 1, Task 13 after plan 2 Task 15. |
| -- **Names that cross plans.** From plan 1: `consolePerfSkip`, `PerfGroups`, `consoleSpeedRows`, `newConsoleFixtureWith`, `newPerfFixture`, `perfInventory`, `perfTargets`, `loadPerfBudgets`, `TestConsoleScreensMeetTheBudget`, the budgets grammar. From plan 2: `viewGet`, `viewMode`, `viewCached`, `viewBlocking`, `errViewPending`, `viewPart`, `renderView`, `getAssembled`, `perfLatency` (`Calls`, `SetFail`, `Keys`, `Writes`, `ResetKeys`, `HoldNext`), `perfQuiesce`/`waitBackground`, `s.bg.Go`, the four partials, Task 8's read-set invalidation (no per-door declaration), `viewLoader`, `viewLoadEnv`, `viewloaders.go` and its `load…` functions (`loadFleetJSON`, `loadBoxSnapshot`, `loadStorePending`, `loadStoreUsage`, `loadMetricsFacts`, `loadEconomicsDay`, `loadArchitectureFacts`), `metricsFacts`, `buildEconomicsView`, and Task 15's seven views. This plan's names used across its own tasks: `assetURL`, `opShell`, `opRail`, `opPage`, `op_top`/`op_bottom`, the `op_*` partials and their data types, `opPages`, `opNumber`, `signInOperator`, `operatorScreens`, `opShellPending`, `assertOpShell`, `deployActions`, `accountAuditActions`, `OperatorCounts`, `DayCount`, `PersonRow`, `AccountRow`, `ActivityFilter`, `FeedRow`, `FiringAlert`, `TouchLastSeen`, `OperatorAccountBySqid`, `OperatorAccount`, the `opSQL…` constants, `noteSeen`, `alertNow`, `alertsNow`, `seedOperatorScale`, `peopleShows`, `auditAccount`, `jobRegistry`, `jobFailed`, `JobStatus`, `opJobRows`, `opFleetJSON`, `opHostRows`, `opStorePending`, `seedOperatorWorld`, `fleetParts`, `handleFleetPart`. |
| +- **Names that cross plans.** From plan 1: `consolePerfSkip`, `PerfGroups`, `consoleSpeedRows`, `newConsoleFixtureWith`, `newPerfFixture`, `perfInventory`, `perfTargets`, `loadPerfBudgets`, `TestConsoleScreensMeetTheBudget`, the budgets grammar. From plan 2: `viewGet`, `viewMode`, `viewCached`, `viewBlocking`, `errViewPending`, `viewPart`, `renderView`, `getAssembled`, `perfLatency` (`Calls`, `SetFail`, `Keys`, `Writes`, `ResetKeys`, `HoldNext`), `perfQuiesce`/`waitBackground`, `s.bg.Go`, the four partials, Task 8's read-set invalidation (no per-door declaration), `viewLoader`, `viewLoadEnv`, `viewloaders.go` and its `load…` functions (`loadFleetJSON`, `loadBoxSnapshot`, `loadStorePending`, `loadStoreUsage`, `loadMetricsFacts`, `loadEconomicsDay`, `loadArchitectureFacts`), `metricsFacts`, `buildEconomicsView`, and Task 15's seven views. This plan's names used across its own tasks: `assetURL`, `opShell`, `opRail`, `opPage`, `op_top`/`op_bottom`, the `op_*` partials and their data types, `opPages`, `opNumber`, `signInOperator`, `operatorScreens`, `opShellPending`, `assertOpShell`, `deployActions`, `accountAuditActions`, `OperatorCounts`, `DayCount`, `PersonRow`, `AccountRow`, `ActivityFilter`, `FeedRow`, `FiringAlert`, `TouchLastSeen`, `OperatorAccountBySqid`, `opQueryPlans`, `OperatorAccount`, the `opSQL…` constants, `noteSeen`, `alertNow`, `alertsNow`, `seedOperatorScale`, `peopleShows`, `auditAccount`, `jobRegistry`, `jobFailed`, `JobStatus`, `opJobRows`, `opFleetJSON`, `opHostRows`, `opStorePending`, `seedOperatorWorld`, `fleetParts`, `handleFleetPart`. |
diff --git a/docs/superpowers/plans/CODEX-FINDINGS-CONSOLE-PLANS-R5.md b/docs/superpowers/plans/CODEX-FINDINGS-CONSOLE-PLANS-R5.md| new file mode 100644 |
| index 000000000..6a7195930 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/CODEX-FINDINGS-CONSOLE-PLANS-R5.md |
| @@ -0,0 +1,91 @@ |
| +| Earlier finding | Disposition at `2fb56393` | Evidence | |
| +|---|---|---| |
| +| R4-1: Refresh loses dependencies of the served value | **Resolved** | Separate published/in-flight sets, including failed-refresh witnesses. [Perf-2 T6:259](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:259). | |
| +| R4-2: Economics caches SQLite-derived values | **Resolved** | Accounts, tiers, registry attribution and period arithmetic move to request-time derivation; tier-save witness added. [Perf-2 T15:569](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:569). New dependency-key issue below. | |
| +| R4-3: Shared metrics entry has incompatible loaders | **Resolved** | One `loadMetricsFacts`, result type and 60-second window; inner cache bypassed. [Perf-2 T9:411](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:411), [T15:568](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:568). | |
| +| R4-4: Catch-all cache freezes live status | **Resolved** | Manifest/TXT facts cached separately; rows rebuilt with current readings and clock. [Perf-2 T13:515](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:515). | |
| +| R4-5: New tombstone cannot satisfy zero-read Trash test | **Resolved** | Explicit tombstone primer creates and validates the new entry before responding. [Perf-2 T8:372](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:372). | |
| +| R4-6: Coverage oracle skips default targets | **Resolved** | Coverage uses the walk’s expanded `perfWalkTargets`. [Perf-2 T8:385](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:385). | |
| +| R4-7: Active-user counts perform correlated scans | **Resolved** | Set-based UNION and supporting indexes replace the correlated query. [Operator T4:368](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:368). New test-oracle defect below. | |
| +| R4-8: `over` pages can return errors without failing | **Resolved** | Status checks explicitly cover every request, including `over` and cold requests. [Perf-1 T10:408](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-1-measure.md:408). | |
| +| R4-9: Split landing reuses census proposal name | **Resolved** | Each landing gets its own proposal, card and ruling. [Operator T15:763](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:763). | |
| +| R4-10: Deleted-account Activity links lose history | **Resolved** | Tombstone-inclusive operator lookup and link-following test. [Operator T11:643](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:643). | |
| +| R2-6, previously partly: Legacy bake clock interface | **Resolved** | Explicit `now` argument and request-time bake computation. [Perf-2 T9:405](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:405). | |
| +| R2-12c, previously partly: Static traversal response | **Resolved** | Complete 301 → 301 → 404 sequence specified. [Operator T2:313](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:313). | |
| +| R1-9, previously partly: Older versions unreachable | **Resolved** | Pagination, page-specific cache entries and retained acceptance assertions. [Nav T3:233](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-ux-nav.md:233), [Perf-2 T10:437](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:437). | |
| +| R1-14, previously partly: Sparse fixtures/inaccurate S3 counts | **Resolved** | Production `S3Store`, transport counting, populated/paginated fixtures and whole-session ceiling. [Perf-1 T9:333](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-1-measure.md:333), [T10:382](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-1-measure.md:382). | |
| + |
| +“Resolved” describes the revised plan’s treatment of the reported defect, not implementation verification. |
| + |
| +1. **P2 — Economics’ singleton keys omit inputs that determine which objects are read.** |
| + |
| + **Perf-2 Task 15** gives recent bills one `economics-bills` key and fleet-meter objects one `economics-fleet-meters` key. Existing reads depend respectively on the current month, and on the requested dates plus locally registered fleets/boxes. |
| + |
| + Concrete stale-after-own-write case: warm bills just before November begins, recording September/October dependencies; after midnight save November’s bill. That write matches neither dependency, so the redirect can serve the old bill collection. Similarly, switching Economics periods or registering a fleet reuses a fleet-meter entry populated for a different object set. Moving attribution to request time does not fetch the missing objects. |
| + |
| + Cache bills per month and fleet-meter facts per fleet/box/day, selecting entries per request. Add month-rollover/save and period-switch witnesses. |
| + |
| + Evidence: [plan T15:569](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:569), [bill selection:801](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/economicsview.go:801), [bill save:1274](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/economicspass.go:1274), [fleet object selection:684](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/economicspass.go:684). |
| + |
| +2. **P2 — Task 11 still names aggregate loaders that violate the facts-only boundary.** |
| + |
| + **Perf-2 Task 11** caches `liveEdges` and the complete GeoIP inventory without specifying their required splits: |
| + |
| + - `liveEdges` returns freshness and completeness already derived from the clock and box snapshots. The derivation occurs in another package, beyond the proposed console-only transitive AST check. Caching that result freezes `Fresh` and clock-dependent `BoxesComplete`; refreshing `partBoxes` does not recompute them. |
| + - GeoIP inventory includes registry-derived expected boxes and selects heartbeat prefixes through `ListFleets`. A newly registered fleet has no dependency in the existing global entry. Passing a registry snapshot as plain loader arguments would satisfy the type restriction while preserving this defect. |
| + |
| + Cache raw edge facts and individual fleet snapshots; derive liveness and the expected inventory per request. Test crossing the freshness boundary and adding/removing a fleet without an S3 write. |
| + |
| + Evidence: [plan T11:467](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:467), [liveEdges:203](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/regioncandidates.go:203), [clock-derived result:152](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/edgesfile/snapshot.go:152), [GeoIP registry/prefix selection:281](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/apisystemgeoip.go:281). |
| + |
| +3. **P2 — The restricted loader environment cannot perform Running’s app-host request.** |
| + |
| + **Perf-2 Task 11** removes `instanceFetcher`’s cache and moves `instances.Report` into `viewGet`, while retaining its configured client, scheme, timeout and host-selection behavior. **Task 6’s** environment exposes only the object store, signing key, read time and DNS. Its restrictions prohibit passing the fetcher, client, method value or closure through loader arguments. |
| + |
| + The existing fetch requires `f.client.Do`; the configured client also carries perf-1’s counting/fake transport. There is no permitted way to preserve that capability as written. |
| + |
| + Specify an explicit app-host capability or separate report-cache boundary. Select the eligible host per request and include its identity in the cached report’s inputs/key. |
| + |
| + Evidence: [restricted environment:253](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:253), [Task 11:458](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:458), [host selection:93](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/instances.go:93), [HTTP call:130](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/instances.go:130). |
| + |
| +4. **P2 — `TestViewLoadersAreRestricted` rejects types the plan requires caching.** |
| + |
| + **Perf-2 Task 6** forbids interface fields in every loader argument/result type. However, Task 5 defines `boxSnapshot.Err error`, and Task 9 defines `appCore.ProductionErr error` and `PipelineErr error`. All three are interface fields, including when their values are nil. Both types are explicitly assigned to cached loaders, so the required reflection test cannot pass. |
| + |
| + Define plain-data representations for these retained error states, preserving the existing partial-evidence/degraded-rendering semantics, or specify a narrowly justified exception and its checks. |
| + |
| + Evidence: [restriction:255](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:255), [boxSnapshot:221](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:221), [appCore:404](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:404), [underlying completeness/error contract:224](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/status/fleet.go:224). |
| + |
| +5. **P2 — Economics listens for a different deferred-part event payload.** |
| + |
| + **Perf-2 Task 7** dispatches `detail: {part, root}`. **Operator Task 13** checks `e.detail.id === "econ-body"` and passes `e.detail` to the initializer. That condition is always false with the producer’s payload. |
| + |
| + Consequently, a cold Economics fragment receives no input/change listeners. Editing pricing does not update the calculated values or serialized scenario field used by Save. The listener must inspect and pass `e.detail.root`; test it using the actual producer’s payload. |
| + |
| + Evidence: [event producer:317](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:317), [event consumer:697](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:697), [serialized field/listeners:403](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/templates/economics.html:403). |
| + |
| +6. **P2 — Dashboard “Needs attention” can report healthy beside a Silent box.** |
| + |
| + **Operator Task 9’s** `attentionInput` receives `Fleet` but no `HostRows`. Its box warnings therefore rely on `FleetBox.Stale`, recorded when the summary was built. The dashboard table separately uses request-time `HostRow.Stale`. |
| + |
| + A summary built two minutes ago from a then-14-minute-old heartbeat remains a fresh summary, with `FleetBox.Stale=false`; the same heartbeat is now 16 minutes old and the table marks it Silent. With no other issue, the callout remains positive. A silent host present only in `HostRows` is also unavailable to `attentionItems`. |
| + |
| + Derive the callout and table from the same box evidence, including after deferred box loading. This is required by spec §3.3’s silent/stale-box attention item. |
| + |
| + Evidence: [attention input:584](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:584), [dashboard rows:587](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:587), [merge-time stale flag:171](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/status/fleet.go:171), [request-time stale flag:878](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/view.go:878), [spec:385](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/specs/2026-10-25-console-ux-perf-design.md:385). |
| + |
| +7. **P2 — The new query-plan oracle rejects legitimate required queries.** |
| + |
| + **Operator Task 4** permits `users`, `sessions` and `audit` only under indexed `SEARCH`, except two named cases. Required queries outside those exceptions naturally scan: |
| + |
| + - Total people: `COUNT(*) FROM users` scans a covering index. |
| + - Newest people: ordered traversal scans `users_by_created`. |
| + - Unfiltered first Activity page: descending primary-key traversal is `SCAN audit`, stopping at `LIMIT`. |
| + |
| + An in-memory SQLite check confirmed these shapes. They would fail the specified gate despite being appropriate queries. Also, dropping `sessions_by_time` cannot restore the claimed “old CORRELATED SCALAR SUBQUERY”: the replacement UNION SQL contains no correlation. |
| + |
| + Make assertions specific to each query’s intended access pattern, allowing bounded ordered scans and total-count scans; retain the scale witness. |
| + |
| + Evidence: [oracle:383](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:383), [required query contracts:371](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:371), [users schema:153](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/store.go:153), [audit schema:179](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/store.go:179). |
| + |
| +Read-only review; working tree unchanged. No repository tests run. Rastrillo’s pinned tag and all six hashes match local upstream; its licence is MPL-2.0. |
| \ No newline at end of file |
diff --git a/docs/superpowers/plans/CODEX-FINDINGS-CONSOLE-PLANS-R6.md b/docs/superpowers/plans/CODEX-FINDINGS-CONSOLE-PLANS-R6.md| new file mode 100644 |
| index 000000000..adddbff82 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/CODEX-FINDINGS-CONSOLE-PLANS-R6.md |
| @@ -0,0 +1,67 @@ |
| +Reviewed `f3193aaf`. “Resolved” below means addressed by the plan, not verified implementation. |
| + |
| +| Earlier finding | Disposition | Evidence | |
| +|---|---|---| |
| +| R5-1: Economics keys omit object-selection inputs | **Resolved** | Bills are keyed by month; fleet meters by fleet/box/day, selected per request. Rollover and period-switch witnesses added. [Perf-2 T15:572](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:572). | |
| +| R5-2: Edge/GeoIP loaders cache derived state | **Resolved** | Raw facts are cached; freshness and registry inventory are computed per request. Cross-package callees are explicitly reviewed. [Perf-2 T11:467](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:467), [T6:255](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:255). | |
| +| R5-3: Restricted loader cannot fetch app reports | **Resolved** | Explicit `AppHost` capability preserves the configured fetcher; eligible host is selected per request and included in the key. [Perf-2 T6:253](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:253), [T11:466](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:466). | |
| +| R5-4: Cached error interfaces violate plain-data restriction | **Resolved** | `boxSnapshot` and `appCore` retain errors as text. [Perf-2 T5:221](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:221), [T9:404](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:404). | |
| +| R5-5: Economics event payload mismatch | **Not** | Producer’s `detail.part` is the **full part URL**; revised listener and browser harness compare it with `"economics"`. The new source test explicitly enforces that incompatible short name. [Perf-2 T7:317](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:317), [Operator T13:706](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:706), [tests:718](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:718). | |
| +| R5-6: Attention callout contradicts box status | **Resolved** | Callout and table consume the same request-time box rows; cold rendering defers both together. Boundary witness added. [Operator T9:592](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:592), [T13:710](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:710). | |
| +| R5-7: Query-plan oracle rejects appropriate SQL | **Partly** | Legitimate scans and the index-drop witness are corrected. But the blanket `CORRELATED` ban still rejects bounded per-person scalar lookups; the address tie-break needs sorting with the specified single-column index; and SQLite can choose `audit_by_action` where the oracle insists on `audit_by_time`. Confirmed with in-memory SQLite. [Operator T4:368](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:368), [query contracts:374](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:374), [oracle:383](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:383). | |
| +| R1-9, previously partly: Older versions unreachable | **Resolved** | Pagination and page-specific cache entries remain, including the older-version acceptance test. [Nav T3:233](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-ux-nav.md:233), [Perf-2 T10:437](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:437). | |
| +| R1-14, previously partly: Sparse fixtures/inferred S3 counts | **Resolved** | Production S3Store, transport counting, populated/paginated fixtures and whole-session ceiling. [Perf-1 T9:333](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-1-measure.md:333), [T10:382](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-1-measure.md:382). | |
| +| R2-6, previously partly: Legacy bake clock interface | **Resolved** | Explicit `now` argument and request-time bake derivation. [Perf-2 T9:405](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:405). | |
| +| R2-12c, previously partly: Static traversal response | **Resolved** | Complete 301 → 301 → 404 sequence specified. [Operator T2:313](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:313). | |
| + |
| +New findings: |
| + |
| +1. **P2 — The restricted claims loader cannot retain the existing `ClaimCache`.** |
| + |
| + **Perf-2 Task 13** says the claims listing uses `viewGet` while “`ClaimCache` stays underneath.” Today that cache belongs to `Server`, and `settingsDomains` calls `s.claims.List`. Task 6 supplies neither that cache nor a capability for it; loader arguments cannot carry mutable shared state, and loaders cannot capture `Server`. |
| + |
| + Creating a fresh `ClaimCache` inside each load loses its incremental GET-saving behavior. Access through a package global would evade the intended restriction and lose the existing per-server ownership. |
| + |
| + Specify an explicit, reviewed claims capability preserving observation through the current load’s context, or define a replacement that preserves the existing read cost. |
| + |
| + Evidence: [plan T13:518](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:518), [restricted interface:253](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:253), [appsettings.go:701](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/appsettings.go:701), [claimcache.go:47](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/domains/claimcache.go:47). |
| + |
| +2. **P2 — Fleet snapshots receive two different keys despite being specified as shared.** |
| + |
| + **Perf-2 Task 11** assigns instance-page fleet boxes `{sqid, "", "fleet-boxes:<fleet>"}`, then assigns GeoIP fleet snapshots `{"", "", fleetBoxesPart(fleet)}` and calls them “the same entries.” Their account components differ. |
| + |
| + The instance page currently needs both the system-wide box view and the account rollout join. Following these keys preserves duplicate listings and GETs for the same fleet, with independent refreshes and read sets. |
| + |
| + Define one canonical fleet-snapshot key and retain account ownership filtering in the request-time join. Add a witness covering both consumers in one instance-page request. |
| + |
| + Evidence: [plan T11:467](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:467), [instancepage.go:285](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/instancepage.go:285), [apiinstances.go:514](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/apiinstances.go:514). |
| + |
| +3. **P2 — Claim-world deletes bypass the observer used by the required invalidation test.** |
| + |
| + **Perf-2 Task 8** attaches the observer to the claim world’s underlying `DirStore`. However, its `deletableStore.Delete` discards the context and calls `os.Remove` directly. `claimRawStore.Delete` records that successful write independently, so the oracle sees a deletion that the tracker never receives. |
| + |
| + A concrete case is canary retirement: the handler deletes the channel pointer, but the warmed core entry’s generation does not change. The required `TestClaimConsoleMutationInvariant` coverage assertion therefore fails with the prescribed wiring. |
| + |
| + Forward fixture deletes through the observed underlying store, retaining the context, and exercise a warmed canary-retirement case. |
| + |
| + Evidence: [plan T8:386](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:386), [world construction:459](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/claim_invariant_world_test.go:459), [raw recorder:226](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/claim_invariant_world_test.go:226), [bypass:51](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/view_test.go:51), [canary deletion:5353](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/server.go:5353). |
| + |
| +4. **P2 — Fixture clock changes and cold resets leave cache dependencies bound to their previous values.** |
| + |
| + **Perf-2 Task 6** constructs the cache with `newViewCache(s.now, …)` in `NewServer`, then has `newPerfFixture` replace `fx.srv.now`. Passing a function value captures the original clock; assigning the field later does not update the cache. Advancing `fx.clock` therefore does not trigger the expected expiry, and Task 10’s held-refresh test can wait for a refresh that never starts. |
| + |
| + Separately, `resetForColdView` replaces `s.views`, while **Task 8** binds the tracker to the original cache in `NewServer`. No reset step rebinds it. Subsequent writes can invalidate the discarded cache rather than the one serving pages. |
| + |
| + Install the clock before cache construction, or use an explicit indirection; reset the cache in place or rebind its tracker. Test expiry and warm→write→read after a cold reset. |
| + |
| + Evidence: [plan T6:239](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:239), [reset:242](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:242), [tracker binding:366](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:366), [refresh witness:445](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:445), [existing fixture construction:88](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/server_test.go:88). |
| + |
| +5. **P2 — Nav changes redirect statuses without updating the already-landed performance walk.** |
| + |
| + **Nav Tasks 3 and 7** turn `/deployments` and `/pipeline` into 303 redirects. **Perf-1 Task 10** expects 200 for both and checks statuses even for `over` entries. Nav updates claim probes and page tests but contains no corresponding `perfTargets` changes. |
| + |
| + With the settled merge order, nav therefore makes the performance gate fail. Add explicit 303 targets alongside each redirect change, preserving coverage of the new canonical pages. |
| + |
| + Evidence: [nav T3:263](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-ux-nav.md:263), [nav T7:378](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-ux-nav.md:378), [perf expectations:398](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-1-measure.md:398), [status enforcement:408](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-1-measure.md:408), [non-following browser:128](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/server_test.go:128). |
| + |
| +Read-only; no files changed or repository tests run. Rastrillo’s pinned commit and all six asset/licence hashes match local upstream. |
| \ No newline at end of file |
diff --git a/docs/superpowers/plans/CODEX-FINDINGS-CONSOLE-PLANS-R7.md b/docs/superpowers/plans/CODEX-FINDINGS-CONSOLE-PLANS-R7.md| new file mode 100644 |
| index 000000000..a21ccceab |
| --- /dev/null |
| +++ b/docs/superpowers/plans/CODEX-FINDINGS-CONSOLE-PLANS-R7.md |
| @@ -0,0 +1,65 @@ |
| +| Earlier finding | Disposition at `4272c75d` | Evidence | |
| +|---|---|---| |
| +| R6-1: Restricted claims loader cannot retain `ClaimCache` | **Partly** | Restricted loaders replace `Server.claims`, but their promised incremental read cost is not preserved. [Perf-2 T13:523](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:523). New defects below. | |
| +| R6-2: Conflicting fleet-snapshot keys | **Resolved** | One deployment-wide key, request-time ownership filtering, and a shared-consumer witness. [Perf-2 T11:471](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:471). | |
| +| R6-3: Fixture deletes bypass observation | **Resolved** | Context-preserving forwarding, method coverage and warmed canary-retirement witness. [Perf-2 T8:359](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:359), [tests:388](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:388). | |
| +| R6-4: Clock/reset retain obsolete dependencies | **Resolved** | Clock indirection and reset in place, with both regression witnesses. [Perf-2 T6:239](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:239), [tests:283](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:283). | |
| +| R6-5: Nav redirects break performance targets | **Resolved** | Redirect changes now update expected statuses and canonical-page targets together. [Nav T3:266](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-ux-nav.md:266), [T7:386](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-ux-nav.md:386). | |
| +| R5-5, carried forward: Economics event mismatch | **Not** | Producer still sends the full URL; consumer and its test require `"economics"`. [Perf-2:320](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:320), [Operator:706](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:706). | |
| +| R5-7, previously partly: Query-plan oracle | **Partly** | Still forbids bounded correlated lookups and sorting needed by the address tie-break; still mandates `audit_by_time` despite the competing action index. [Operator T4:374](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:374), [oracle:383](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:383). | |
| +| R1-9, previously partly: Older versions unreachable | **Resolved** | Pagination and page-specific cached entries remain. [Nav T3:233](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-ux-nav.md:233), [Perf-2 T10:441](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:441). | |
| +| R1-14, previously partly: Sparse fixtures/inferred counts | **Resolved** | Production S3Store, transport counting, populated fixtures and whole-session ceiling. [Perf-1 T9:333](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-1-measure.md:333), [T10:382](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-1-measure.md:382). | |
| +| R2-6, previously partly: Legacy bake clock | **Resolved** | Explicit clock argument and request-time derivation. [Perf-2 T9:409](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:409). | |
| +| R2-12c, previously partly: Static traversal response | **Resolved** | Complete 301 → 301 → 404 sequence specified. [Operator T2:313](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:313). | |
| + |
| +“Resolved” means addressed in the plan, not verified implementation. |
| + |
| +1. **P2 — Claim writes reread the wrong timestamped entry.** |
| + |
| + **Perf-2 Tasks 8 and 13:** a changed claim invalidates the index and existing `claim:<key>@<old-modtime>` entry. The POST rereads those concurrently. The refreshed index then selects `claim:<key>@<new-modtime>`, which neither rereading nor the tombstone-only primer populated. The redirect performs another GET; first attachments likewise select an unprimed entry. |
| + |
| + This contradicts both the one-changed-GET test and the zero-call attachment redirect. Specify how rereading the index populates the entries it selects before responding. |
| + |
| + Evidence: [T13:523–529](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:523), [T8 primer:375](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:375); existing incremental fold [claimcache.go:137](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/domains/claimcache.go:137). |
| + |
| +2. **P2 — Unchanged claims are fetched again every five minutes.** |
| + |
| + **Perf-2 Task 13** assigns `writtenWindow` to both the claim index and each timestamped claim entry. After that window, viewing Domains refreshes every expired claim body even when the listing’s timestamps remain unchanged. Existing `ClaimCache` deliberately has no TTL and carries unchanged bodies forward without GETs. |
| + |
| + Keep unchanged timestamped bodies reusable, while retaining safe handling of writes and recently modified objects. Add an unchanged-listing witness after window expiry; the present changed-claim test misses this regression. |
| + |
| + Evidence: [T13:523](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:523), [stale-entry behavior:257](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:257); [claimcache.go:32](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/domains/claimcache.go:32). |
| + |
| +3. **P2 — Bounded log results retain history-sized dependency sets for every filter.** |
| + |
| + **Perf-2 Tasks 6 and 12** retain every observed GET key per entry, with up to 4,096 filtered entries and simultaneous published/in-flight sets. `ReadChunks` fetches every selected chunk even when the search returns nothing; `collectCap` limits returned records, not dependencies. Distinct empty searches can therefore retain thousands of copies of the same large key set. |
| + |
| + The initial app-log prefix already covers these descendants for invalidation. Specify prefix subsumption or another bounded representation that preserves every dependency, and test large-history empty searches. |
| + |
| + Evidence: [T6 read sets:259](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:259), [T12:496](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:496); [applog/read.go:38](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/applog/read.go:38), [chunk reads:106](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/applog/read.go:106), [result trimming:139](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/applog/read.go:139). |
| + |
| +4. **P2 — Relative end times defeat the proposed filter-cache normalization.** |
| + |
| + **Perf-2 Task 12** hashes the complete effective filter but rounds only its start. For a supported query such as `since=24h&until=1h`, both endpoints are parsed relative to the current time. `Until` therefore changes on every request, producing another cache miss within the same thirty-second window. A frozen fixture clock hides this. |
| + |
| + Normalize both temporal inputs consistently before hashing and loading. Test repeated requests with an advancing clock inside one cache window. |
| + |
| + Evidence: [T12:496](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md:496); [errorsview.go:177](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/errorsview.go:177). |
| + |
| +5. **P2 — Operator Task 9 requires cache behavior introduced only in Task 13.** |
| + |
| + `TestAttentionAndBoxesAgreeAcrossTheFifteenMinuteLine` advances `fx.clock` and requires a second dashboard GET to change status **without new reads**. At Task 9, however, `opHostRows` explicitly calls `HostRows(..., time.Now())` directly. It ignores the fixture clock and reads snapshots again. Task 9’s required gate cannot pass as written. |
| + |
| + Move the cached/no-read witness to Task 13; give Task 9 an injected-clock test over its direct seams. |
| + |
| + Evidence: [Operator T9:609](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:609), [direct seam:565](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:565), [later conversion:702](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-operator-pages.md:702); [view.go:865](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/view.go:865). |
| + |
| +6. **P3 — Console speed’s empty-state setup already records requests.** |
| + |
| + **Perf-1 Task 7** expects the existing `TestFleetMetricsEmptyState` setup to produce an empty recorder. That setup signs in through HTTP first, recording `/auth/signin` and `/auth/callback` before Metrics renders. |
| + |
| + Seed the session directly or reset the recorder after authentication. |
| + |
| + Evidence: [Perf-1 T7:278](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/docs/superpowers/plans/2026-10-25-console-perf-1-measure.md:278); [server_test.go:1922](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/server_test.go:1922), [sign-in requests:177](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf/internal/console/server_test.go:177). |
| + |
| +Read-only review; no files changed or repository tests run. The pinned Rastrillo commit and all six asset/licence hashes match local upstream. |
| \ No newline at end of file |