Console round: plans for the 150 ms budget (measure, fixes) and the navigation fixes; spec marks Parts 1-2 approved and moves /fleet to Part 3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed,
+1,367
−8
docs/superpowers/plans/2026-10-25-console-perf-1-measure.md+421 −0docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md+500 −0docs/superpowers/plans/2026-10-25-console-ux-nav.md+440 −0docs/superpowers/specs/2026-10-25-console-ux-perf-design.md+6 −8
CI passed — run details
diff --git a/docs/superpowers/plans/2026-10-25-console-perf-1-measure.md b/docs/superpowers/plans/2026-10-25-console-perf-1-measure.md| new file mode 100644 |
| index 000000000..566e7d575 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-10-25-console-perf-1-measure.md |
| @@ -0,0 +1,421 @@ |
| +# Console perf, plan 1: measure every screen Implementation Plan |
| + |
| +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. |
| + |
| +**Goal:** Time every console request against a 150 ms first-byte budget, say where the time went in `Server-Timing`, show per-route p50/p95 on `/fleet/metrics`, and add a CI walk of every HTML screen that injects S3 and app-host latency and counts remote calls, with today's slow screens recorded as `over:` so CI stays green. |
| + |
| +**Architecture:** A new `internal/perf` package copies the design of Rastrillo's `perf` (no import): a ResponseWriter wrapper that stamps first byte, writes `Server-Timing`, keeps a 2,048-sample ring and throttles over-budget warnings. `console.NewServer` wraps its own mux with it, so every test built on `NewServer` and the production binary share one handler chain. Spans are opened at the seams: the S3 client's HTTP doer (`cmd/console`), the instance fetcher (`instances.go`), the console-DB reads in the shared page gates, the registry read in `Assemble`, and template execution in `render`. The CI walk (`internal/console/perfwalk_test.go`) derives its screen list from `registerRoute`'s own inventory and reads exceptions from `internal/console/testdata/perf-budgets.txt`. |
| + |
| +**Tech Stack:** Go 1.26, `net/http` ServeMux patterns, `log/slog`, `net/http/httptrace`, aws-sdk-go-v2 `service/s3` (`Options.HTTPClient`), SQLite console store, `release.DirStore` in tests. |
| + |
| +**Spec:** `docs/superpowers/specs/2026-10-25-console-ux-perf-design.md`, Part 2, §2.1 to §2.3 and §2.5 steps 1 and 2. Read Part 2 whole before starting; plan 2 (`2026-10-25-console-perf-2-fixes.md`) implements §2.4 and depends on the names this plan defines. Where this plan and the spec disagree, the spec wins and the plan is the bug. Model reading: Rastrillo's `docs/site/reference/perf.md` and `perftest.md` (in `/home/paulca/amadan.net/rastrillo/rastrillo-scaffold-shapes`) and its source `rastrillo/perf/perf.go` and `perf/perftest/screens.go` (in `/home/paulca/amadan.net/rastrillo/rastrillo`). Copy the design; never import rastrillo. |
| + |
| +**Branch:** `console-perf-1`, cut from amadan `main` after the spec branch `console-ux-perf` has landed. Part 1 of the spec (navigation and layout) is a separate plan built in parallel; it moves Placement into Settings and turns `/deployments` into a 303 to `/releases`. Nothing here depends on those templates' layout. Whichever branch lands second updates `perfTargets` (Task 10) for the routes Part 1 changes. Part 3 (operator `/fleet*` pages on the Rastrillo design system, in design) rewrites `metrics.html`; Task 7 keeps the Console speed table one self-contained section so it moves across intact. |
| + |
| +## Global Constraints |
| + |
| +Every task's requirements include this section. |
| + |
| +- **Targeted local tests; CI runs the full suite.** Run only the touched packages' tests, with `-run`: `go test ./internal/perf/ -count=1`, `go test ./internal/console/ -run 'TestName' -count=1`. Never `make test`, never a whole `internal/console` or root package run. `go build ./...`, `go vet ./...` and `gofmt -l .` stay clean. Prefix go commands with `GOFLAGS=-buildvcs=false` if the sandbox refuses VCS stamping. |
| +- **Cross-compiles stay green:** `GOOS=darwin GOARCH=arm64 go build ./...` and `GOOS=windows GOARCH=amd64 go build ./...` before every push. Nothing here needs a Linux-only syscall. |
| +- **Go cache:** leave `GOCACHE`, `GOMODCACHE` and `GOTMPDIR` at their defaults (`~/.cache/go-build`). Do not point them at `/tmp` or at a per-task directory, whatever AGENTS.md's sandbox note says. Run go with the sandbox off if the default cache is read-only. |
| +- **Production wiring, not stand-ins.** Every console test here builds the server with `NewServer` through the existing fixture (`newConsoleFixture*`, `internal/console/server_test.go:43-107`), the same constructor `cmd/console` calls (`cmd/console/main.go:520`). The only substitutes are at the seams the spec names for injection: the release store (wrapped, not replaced) and `Config.AppClient`. A pure unit test in `internal/perf` says "not acceptance" in its doc comment. |
| +- **S3 requests cost money.** Nothing in this plan adds an S3 request to any request path, timer or poll. Measuring adds zero requests. |
| +- **The budget, verbatim.** A GET or HEAD to a console screen sends its first byte within 150 ms. POST, PUT, DELETE have no budget. A stream or download is judged on when it started answering. No cold-start budget. Groups are route patterns, never paths. Over-budget warnings: at most once a minute per route and 120 a minute overall. Ring: the last 2,048 requests. Skip: `/healthz` (the console serves no static assets: templates are embedded, `internal/console/server.go:64`, and CSS is inline). |
| +- **The CI walk, verbatim.** Ten requests per screen, the first two discarded; the median within 150 ms and no single one over 450 ms. Latency: 25 ms per S3 call, 40 ms per HTTP call to a box or app host. Default allowance: zero remote calls on a warm-cache GET. Fails on timing only when `CI` (or `AMADAN_CI`) is set; locally it prints. Whole test well under 10 s. |
| +- **Copy goes through a Luna pass before it is written into a template.** Every user-facing string is a row in `docs/superpowers/plans/2026-10-25-console-perf-copy.md` (Task 1), reviewed by Luna (`codex exec -m gpt-5.6-luna`, delegated by Paul for plan copy) before any template carries it. House voice: no em dashes (a full stop and a new sentence, continuing in lower case); human text only (log lines, diagnostics, route patterns and JSON keys are not copy). No tenant names anywhere: code, tests, fixtures and copy use neutral names (`shop`, `example.com`; the existing fixture app `kass` and account `ops` may be reused). |
| +- **Console security gate order is unchanged:** session, then CSRF, then owner (byte-identical 404), then `requireFreshAuth`. The perf middleware sits outside the mux and reads nothing from the request but its pattern, method and timing. |
| +- **A ResponseWriter wrapper that edits headers needs care** (AGENTS.md, "Rules this repo has paid for"). The perf wrapper adds exactly one header, `Server-Timing`, once, at commit, before the real `WriteHeader`. It keeps `Flush`, `Hijack` and `Unwrap` working. |
| +- **Commit per task.** Every commit message ends with `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`. |
| +- **Amadan tasks.** One amadan task per plan task on the branch, advanced as each closes. |
| +- **Test weights.** A new top-level test in `internal/console` taking a second or more gets a row in `.amadan/test-weights.tsv`. |
| +- **Merge main first.** Before review and before merging: `git fetch origin && git merge origin/main`, re-run the census card (Task 11), push, wait for CI on that tip. Merge with `amadan branch merge carlos/platform console-perf-1 -expect <tip> -message "..."`. Never a bare `amadan branch merge`. |
| + |
| +## Review Focus |
| + |
| +1. **A handler that panics.** The middleware must record the request as a 500 and re-raise the panic untouched, so `net/http`'s own recovery still owns the response and the connection. Test: Task 3, `TestPanicIsRecordedAndReraised`. |
| +2. **A template that fails half way.** Today `render` writes the status and then streams the template, so a failed template leaves a truncated 200. With `render` buffering (Task 4) a person expects a plain 500 instead of half a page, and the first byte now honestly includes template time. Test: Task 4, `TestRenderTemplateErrorAnswers500`. |
| +3. **A URL that carries a secret.** `/invite/{token}` and any unknown path must never reach the ring, the log or the Console speed table as a concrete path. Test: Task 4, `TestPerfGroupsNeverCarryPaths` (requests `/invite/<token>` and `/no/such/path`, then asserts no group's screen contains the token or `/no/such/path`). |
| +4. **A method-less registration** (`/fleet/architecture`, `server.go:1473`). The walk must still find and time it, and production must group it under its pattern. Test: Task 8, `TestPerfInventoryIncludesMethodlessScreens`; Task 4, `TestPerfGroupsMethodlessPattern`. |
| +5. **Spans ended from goroutines a handler started, after the first byte.** They must not race the sample a reader of the ring holds, and must not reach a header already sent. Test: Task 3, `TestLateSpanDoesNotTouchRecordedSample` (run with `-race`). |
| + |
| +--- |
| + |
| +## File structure |
| + |
| +| File | Responsibility | |
| +|---|---| |
| +| `internal/perf/perf.go` (create) | `Sample`, `Group`, `Recorder`, `Groups`, `percentile`, the ring and the throttled log. | |
| +| `internal/perf/middleware.go` (create) | `Options`, `Middleware`, the writer wrapper, `Span`, `SpanContext`, `SpanFor`, `Doer`, `TimeDoer`. | |
| +| `internal/perf/perf_test.go`, `middleware_test.go` (create) | Unit tests (not acceptance). | |
| +| `internal/console/server.go` (modify) | `Server.perf`, `Server.handler`, wrap in `NewServer`, `ServeHTTP` at `:1775-1783`, buffered `render` at `:2202-2215`, db spans at the gate reads, Console speed rows in `handleFleetMetrics` at `:3144-3156`, `ctx` into `Assemble`/`Versions` calls. | |
| +| `internal/console/perfspeed.go` (create) | `consoleSpeedRows`: `[]perf.Group` to template rows. | |
| +| `internal/console/view.go` (modify) | `Assemble(ctx, …)` at `:552`, `Versions(ctx, …)` at `:941`, db span round `reg.List()` at `:558`. | |
| +| `internal/console/instances.go` (modify) | box span round `f.client.Do` at `:130`. | |
| +| `internal/console/apiversion.go` (modify) | `Versions` caller at `:205`. | |
| +| `internal/console/templates/metrics.html` (modify) | the Console speed table. | |
| +| `cmd/console/main.go`, `cmd/console/perfs3.go` (modify, create) | time every S3 request the deployment and seed-data stores make. | |
| +| `docs/superpowers/plans/2026-10-25-console-perf-copy.md` (create) | the copy record, rows `CPF-1` on. | |
| +| `approved_console_perf_copy_test.go` (create, repo root) | copy gate, modelled on `approved_asset_cache_copy_test.go`. | |
| +| `docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-PERF.md`, `LUNA-COPY-REVIEW-CONSOLE-PERF.md` (create) | the Luna brief and its answer. | |
| +| `internal/console/perfbudgets_test.go` (create) | `perf-budgets.txt` parser and the screen inventory. | |
| +| `internal/console/perflatency_test.go` (create) | latency-injecting, call-counting store and app client. | |
| +| `internal/console/perfwalk_test.go` (create) | the walk: fixtures, targets, measurement. | |
| +| `internal/console/testdata/perf-budgets.txt` (create) | exceptions, each with a reason. | |
| +| `internal/console/server_test.go` (modify) | `newConsoleFixtureWith` options constructor. | |
| + |
| +--- |
| + |
| +### Task 1: Copy record and Luna pass |
| + |
| +**Files:** |
| +- Create: `docs/superpowers/plans/2026-10-25-console-perf-copy.md` |
| +- Create: `approved_console_perf_copy_test.go` |
| +- Create: `docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-PERF.md`, `docs/superpowers/plans/LUNA-COPY-REVIEW-CONSOLE-PERF.md` |
| + |
| +**Interfaces:** |
| +- Produces: rows `CPF-1` to `CPF-9` (this plan) with status `approved`; `consolePerfCopyBuilt []string` in the gate, empty in this task. Plan 2 adds rows from `CPF-20` and appends to the same gate. Task 7 adds `CPF-1` to `CPF-9` to `consolePerfCopyBuilt`. |
| + |
| +The record uses the moves record's format (one table per heading, columns id, file, text, status), so the gate reuses the moves gate's parser exactly as `approved_asset_cache_copy_test.go` does (`assetCacheBuiltRows`, `checkAssetCacheBuilt`, `mustParseAssetCacheCopyRecord` there are the model; name them `consolePerfBuiltRows`, `checkConsolePerfBuilt`, `mustParseConsolePerfCopyRecord`). |
| + |
| +Draft rows (Luna may change any text; the ids and files are fixed): |
| + |
| +| id | file | draft text | |
| +|---|---|---| |
| +| CPF-1 | `internal/console/templates/metrics.html` | Console speed | |
| +| CPF-2 | same | How long this console took to send the first byte of each page, over the last 2,048 requests it served. Pages should answer within 150 ms. | |
| +| CPF-3 | same | Route | |
| +| CPF-4 | same | Requests | |
| +| CPF-5 | same | Over 150 ms | |
| +| CPF-6 | same | p50 | |
| +| CPF-7 | same | p95 | |
| +| CPF-8 | same | No requests measured since the console started. | |
| +| CPF-9 | `internal/console/perfspeed.go` | `<n> ms` (a time in whole milliseconds) | |
| + |
| +- [ ] **Step 1: Write the record** with the rows above as `pending`, a placeholder note (`<n>` a whole number), and the house rules section copied from `2026-10-24-edge-asset-cache-copy.md`. |
| +- [ ] **Step 2: Write the gate test** `approved_console_perf_copy_test.go` with `TestConsolePerfCopyInventory` (every row parses, ids unique, no em dash in any text) and `TestConsolePerfCopyBuiltRowsAreApprovedAndPresent` (every id in `consolePerfCopyBuilt` is `approved` and its text is in the named file). |
| +- [ ] **Step 3: Run the gate.** `go test . -run 'TestConsolePerfCopy' -count=1`. Expected: PASS (nothing built yet). |
| +- [ ] **Step 4: Write the Luna brief** `LUNA-COPY-BRIEF-CONSOLE-PERF.md`: the house rules (no em dashes, full stop and lower-case continuation; plain words; human text only; neutral names; keep placeholders), where each string appears (an operator-only metrics page, a table under the box metrics), and the output shape: a table `id | current | new | why`, then one line of counts. Commit the record, gate and brief before running Luna so it reviews a fixed commit. |
| +- [ ] **Step 5: Run Luna** from the worktree with the sandbox off, from a script file (the inline form is refused): `codex exec -m gpt-5.6-luna -s read-only -c 'sandbox_permissions=["disk-full-read-access"]' -o docs/superpowers/plans/LUNA-COPY-REVIEW-CONSOLE-PERF.md "Review the copy rows CPF-1 to CPF-9 in docs/superpowers/plans/2026-10-25-console-perf-copy.md following docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-PERF.md" </dev/null`. Expected: the review file exists with a table. |
| +- [ ] **Step 6: Apply Luna's text verbatim**, mark each row `approved` with the note "approved by delegation to Luna, 2026-10-25" (Paul's standing delegation for plan copy). Serve Paul only rows Luna flags. |
| +- [ ] **Step 7: Run the gate again**, expected PASS, then commit. |
| + |
| +```bash |
| +git add docs/superpowers/plans/2026-10-25-console-perf-copy.md approved_console_perf_copy_test.go docs/superpowers/plans/LUNA-COPY-*-CONSOLE-PERF.md |
| +git commit -m "console perf: copy record and Luna pass for the Console speed table |
| + |
| +Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>" |
| +``` |
| + |
| +### Task 2: `internal/perf`: samples, the ring, groups and the throttled log |
| + |
| +**Files:** |
| +- Create: `internal/perf/perf.go` |
| +- Test: `internal/perf/perf_test.go` |
| + |
| +**Interfaces:** |
| +- Produces: |
| + - `const Capacity = 2048`; `const DefaultBudget = 150 * time.Millisecond` |
| + - `type Sample struct { At time.Time; Screen, Method string; Status int; TTFB, Total float64; Spans map[string]float64; Budget float64; Over bool }` (milliseconds; JSON tags as Rastrillo's minus `label`, `startup_ms`, `cold`) |
| + - `type Group struct { Screen, Method string; Requests, Over int; P50, P95, Total95 float64 }` |
| + - `type Recorder struct { /* unexported; zero value ready */ }` |
| + - `func (c *Recorder) Snapshot() []Sample` (oldest first), `func (c *Recorder) Groups() []Group`, `func Groups(samples []Sample) []Group` |
| + - unexported `func (c *Recorder) add(s Sample, log *slog.Logger)` and `func percentile(values []float64, p int) float64` |
| + |
| +Copy Rastrillo's `Recorder`, `Groups` and `percentile` (nearest rank, `-1` for no values), minus `Label`, cold start and startup. Groups key on (screen, method), slowest p95 first, ties by method then screen. |
| + |
| +- [ ] **Step 1: Write the failing tests** (doc comment on the file: "unit tests, not acceptance"): |
| + - `TestRingKeepsTheLast2048`: add 2,050 samples with `TTFB` 0..2049; `Snapshot()` has length 2048, first `TTFB` 2, last 2049. |
| + - `TestGroupsPercentilesNearestRank`: one screen with TTFB 1..100 → `Requests` 100, `P50` 50, `P95` 95; a sample with `Over: true` counts in `Over`. |
| + - `TestGroupsSlowestFirst`: screens A (p95 10) and B (p95 90) → `[B, A]`. |
| + - `TestGroupsSplitByMethod`: same screen, GET and POST → two groups. |
| + - `TestOverBudgetLogIsThrottled`: with a `slog` handler that counts records, add over-budget samples for screen `GET /x` at `t0`, `t0+30s`, `t0+61s` → 2 log records; then 200 over-budget samples for 200 distinct screens inside one minute → at most 120 records in that minute. |
| + - `TestUnderBudgetNeverLogs`: `Over: false` samples log nothing. |
| +- [ ] **Step 2: Run** `go test ./internal/perf/ -count=1`. Expected: FAIL (package does not compile). |
| +- [ ] **Step 3: Implement** `perf.go` with the interfaces above. The log line is `log.Warn("request over performance budget", "screen", …, "method", …, "status", …, "ttfb_ms", …, "total_ms", …, "budget_ms", …, "spans_ms", …)` (a diagnostic, not copy). |
| +- [ ] **Step 4: Run** `go test ./internal/perf/ -count=1`. Expected: PASS. |
| +- [ ] **Step 5: Commit** `internal/perf/perf.go internal/perf/perf_test.go`, message `perf: the sample ring, per-route p50/p95 and the throttled over-budget log`, ending with the Co-Authored-By line. |
| + |
| +### Task 3: `internal/perf`: middleware, Server-Timing and spans |
| + |
| +**Files:** |
| +- Create: `internal/perf/middleware.go` |
| +- Test: `internal/perf/middleware_test.go` |
| + |
| +**Interfaces:** |
| +- Consumes: Task 2's `Recorder`, `Sample`, `DefaultBudget`. |
| +- Produces: |
| + - `type Options struct { Screen func(*http.Request) string; Skip func(*http.Request) bool; Budget time.Duration; Logger *slog.Logger }`. Nil `Screen` is `r.Pattern`, or `"unmatched"` when empty or the method is CONNECT. Nil `Skip` skips `/healthz` only. Zero `Budget` is `DefaultBudget`. Nil `Logger` is `slog.Default()`. |
| + - `func Middleware(c *Recorder, opts Options) func(http.Handler) http.Handler` |
| + - `func Span(r *http.Request, name string) func()` |
| + - `func SpanContext(ctx context.Context, name string) func()` |
| + - `func SpanFor(w http.ResponseWriter, name string) func()`: finds the perf writer by walking `Unwrap() http.ResponseWriter`; a no-op when there is none. |
| + - `type Doer interface { Do(*http.Request) (*http.Response, error) }` |
| + - `func TimeDoer(d Doer, name string) Doer`: each `Do` is one span `name` on the request's context. A nil `d` uses `http.DefaultClient`. |
| + |
| +Copy Rastrillo's writer wrapper (`commit`, `WriteHeader` with 1xx passthrough, `Write`, `Flush`/`FlushError` committing first, `Hijack` closing the sample as 101, `Unwrap`, `finish` recording a panic as 500 and re-raising, the lost-route warning, clearing `r2.Pattern` on the copy it passes down, folding unknown methods to `OTHER`). Drop cold start, `Started`, startup and `Label`. `Server-Timing` is `app;dur=%.3f` then each span sorted by name, `, <name>;dur=%.3f`. A GET or HEAD gets `Budget`; other methods get `Budget: 0` and are never over. |
| + |
| +- [ ] **Step 1: Write the failing tests** (not acceptance): |
| + - `TestServerTimingCarriesAppAndSpans`: a mux route `GET /x/{id}` whose handler runs `defer perf.Span(r, "db")()` twice with a 2 ms sleep each, then writes; the response's `Server-Timing` starts `app;dur=` and contains `db;dur=` once with a value of at least 4; the recorded sample's `Screen` is `GET /x/{id}`. |
| + - `TestSpanContextReachesTheSample`: the handler passes `r.Context()` to a helper that calls `perf.SpanContext(ctx, "s3")`; the header has `s3;dur=`. |
| + - `TestSpanForFindsTheWriterThroughUnwrap`: the handler wraps `w` in a type with `Unwrap()` and calls `perf.SpanFor(wrapped, "render")`; the header has `render;dur=`. |
| + - `TestTimeDoerSpansEachCall`: an `httptest.Server`; a handler calls `perf.TimeDoer(http.DefaultClient, "box").Do(req.WithContext(r.Context()))` twice; the sample's `Spans["box"]` is positive and the header has one `box;dur=`. |
| + - `TestOverBudgetIsJudgedOnFirstByte`: with `Budget: 20 * time.Millisecond`, a handler that flushes at once then sleeps 50 ms is not over; one that sleeps 50 ms before writing is over; a POST that sleeps 50 ms is not over and has `Budget` 0. |
| + - `TestSkipLeavesHealthzUnmeasured`: `GET /healthz` records nothing and has no `Server-Timing`. |
| + - `TestUnmatchedPathsGroupAsUnmatched`: a 404 for `/secret/abc123` records `Screen == "unmatched"`. |
| + - `TestPanicIsRecordedAndReraised`: a handler panics with value `"boom"`; calling the middleware's `ServeHTTP` directly re-panics with `"boom"` and the ring holds one sample with `Status` 500. |
| + - `TestLateSpanDoesNotTouchRecordedSample`: the handler starts a goroutine that ends a `db` span 20 ms after the handler returns; after waiting for it, the sample taken from `Snapshot()` right after the handler returned is unchanged. Run with `-race`. |
| + - `TestFlushAndHijackStillWork`: `http.NewResponseController(w).Flush()` succeeds through the wrapper; a hijack records status 101. |
| +- [ ] **Step 2: Run** `go test ./internal/perf/ -count=1 -race`. Expected: FAIL (undefined names). |
| +- [ ] **Step 3: Implement** `middleware.go` with the interfaces above. |
| +- [ ] **Step 4: Run** `go test ./internal/perf/ -count=1 -race`. Expected: PASS. |
| +- [ ] **Step 5: Commit** `internal/perf/middleware.go internal/perf/middleware_test.go`, message `perf: middleware, Server-Timing, spans by request, context, writer and HTTP doer`, ending with the Co-Authored-By line. |
| + |
| +### Task 4: Wire perf into the console's handler and make `render` measurable |
| + |
| +**Files:** |
| +- Modify: `internal/console/server.go`: `Server` struct (near `:888`, beside `claimEntries`), `NewServer` (`:1338`; after the struct literal at `:1385-1414`), `ServeHTTP` (`:1775-1783`), `render` (`:2202-2215`) |
| +- Test: `internal/console/perfwiring_test.go` (create) |
| + |
| +**Interfaces:** |
| +- Consumes: `perf.Middleware`, `perf.Recorder`, `perf.Options`, `perf.SpanFor`. |
| +- Produces: |
| + - `Server.perf perf.Recorder` (unexported field; zero value) and `Server.handler http.Handler`, set in `NewServer` to `perf.Middleware(&s.perf, perf.Options{Skip: consolePerfSkip})(s.mux)`. |
| + - `func consolePerfSkip(r *http.Request) bool`: true only for path `/healthz`. |
| + - `func (s *Server) PerfGroups() []perf.Group` (exported for `cmd/console` and plan 2's tests). |
| + - `render` keeps its signature `func (s *Server) render(w http.ResponseWriter, status int, name string, p page)`. |
| + |
| +`ServeHTTP` keeps the redirect-host branch first (unmeasured, unchanged) and then calls `s.handler.ServeHTTP(w, r)` instead of `s.mux.ServeHTTP`. The perf middleware must wrap `s.mux` directly, with nothing between them, so the mux's pattern reaches it (with `HostClaim` on, `registerRoute`'s `r.WithContext` at `claim_routes.go:66` runs inside the mux, after the pattern is set, which is fine). The step-up resume's direct `s.mux.ServeHTTP` (`stepup.go:467`) stays as it is: it runs inside an already-measured POST. |
| + |
| +`render` executes the template into a buffer taken from a `sync.Pool` (buffers grown past 1 MiB are not returned), timing the execution with `perf.SpanFor(w, "render")`, then sets `Content-Type`, calls `w.WriteHeader(status)` and writes the buffer. On a template error it logs as today and answers `http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)`; `recordBannerNotice` (`:2214`) runs only after a successful write, as now. |
| + |
| +- [ ] **Step 1: Write the failing tests** in `perfwiring_test.go`, each on `newConsoleFixture` and `signInPaul`: |
| + - `TestServerTimingOnAnAppPage`: GET `fx.u("/apps/kass")`; header `Server-Timing` matches `^app;dur=[0-9.]+` and contains `render;dur=`. |
| + - `TestPerfGroupsByPattern`: after that GET, `fx.srv.PerfGroups()` has a group with `Screen == "GET /a/{sqid}/apps/{app}"` and `Method == "GET"`, and no group's `Screen` contains `kass`. |
| + - `TestPerfGroupsMethodlessPattern`: GET `fx.ts.URL + "/fleet/architecture"` as Paul; a group has `Screen == "/fleet/architecture"`. |
| + - `TestPerfGroupsNeverCarryPaths`: GET `/invite/tok-abc123` and `/no/such/path`; no group's `Screen` contains `tok-abc123` or `/no/such/path`; `unmatched` is present. |
| + - `TestHealthzIsNotMeasured`: GET `/healthz`; no `Server-Timing` header and no group for it. |
| + - `TestRenderTemplateErrorAnswers500`: call `fx.srv.render(rec, 200, "no-such-template", page{})` on an `httptest.ResponseRecorder`; `rec.Code == 500` and the body does not contain `<html`. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestServerTimingOnAnAppPage|TestPerfGroups|TestHealthzIsNotMeasured|TestRenderTemplateErrorAnswers500' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement** the field, `consolePerfSkip`, the wrap in `NewServer`, `ServeHTTP` and buffered `render` as above. |
| +- [ ] **Step 4: Run** the same command. Expected: PASS. Then run the existing tests that pin chrome and redirects: `go test ./internal/console/ -run 'TestHealthzCarriesTheBuild|TestConsoleE2E|TestAppTabBar|TestRedirect' -count=1`. Expected: PASS. |
| +- [ ] **Step 5: Commit** `internal/console/server.go internal/console/perfwiring_test.go`, message `console: perf middleware around the mux; render buffers so first byte includes the template`, ending with the Co-Authored-By line. |
| + |
| +### Task 5: Spans at the seams: S3, app host, console DB, registry |
| + |
| +**Files:** |
| +- Create: `cmd/console/perfs3.go`; Test: `cmd/console/perfs3_test.go` |
| +- Modify: `cmd/console/main.go:718-731` (`openStore`) and `:389` (seed data store) |
| +- Modify: `internal/console/instances.go:122-131` (`fetch`) |
| +- Modify: `internal/console/view.go:552-560` (`Assemble`), `:941-943` (`Versions`) |
| +- Modify: `internal/console/server.go`: `Assemble` callers `:3251`, `:3407`; `Versions` callers `:3543`, `:3604`; `ListTags` at `:3622` (uses `context.Background()`); db spans at `:2241`, `:2426`, `:3088`, `:3344`, `:3353`, `:3384`, `:3419`, `:3566`, `:3571`, `:3594`, `:3948` |
| +- Modify: `internal/console/apiversion.go:205`; `internal/console/view_test.go` (the 16 `Assemble`/`Versions` call sites get `context.Background()`) |
| +- Test: `internal/console/perfwiring_test.go` (extend) |
| + |
| +**Interfaces:** |
| +- Consumes: `perf.SpanContext`, `perf.Span`, `perf.TimeDoer`. |
| +- Produces: |
| + - `func Assemble(ctx context.Context, regPath string, s release.Store, pub ed25519.PublicKey, acct string, apps []string, dns DNSTargets) ([]AppView, error)` (the `ctx := context.Background()` at `view.go:553` goes) |
| + - `func Versions(ctx context.Context, s release.Store, acct, app string) ([]VersionView, error)` (the `ctx := context.Background()` at `view.go:942` goes) |
| + - `cmd/console`: `func timeS3(s *release.S3Store) *release.S3Store` replacing `s.Client` with `awss3.New(s.Client.Options(), func(o *awss3.Options) { o.HTTPClient = perf.TimeDoer(o.HTTPClient, "s3") })`. |
| + |
| +Why at these seams and not by wrapping `Config.Releases`: code type-asserts the store for optional interfaces (`release.AppMutationRunner` at `claim_app_mutation.go:30` and `claim_relay.go:29`, `release.ModLister` at `runsweep.go:363`, `release.SizeLister` at `economicspass.go:141`, and `release.VersionCandidates`'s stamp check). A wrapper would change those answers, and for `AppMutationRunner` that is a claim boundary. Timing the S3 client's HTTP doer changes no method set. *(My call.)* |
| + |
| +Why the db span wraps the gate's calls rather than the Store: almost every `Store` method takes no `context.Context` (only `PendingChangesForContext` and a few others do), and new `Store` methods fall under the claim SQL adapters and census (`claim_sql_auto.go:11-13`). So the `db` span is opened in `Server` code around the reads every page makes: `SessionAddress` (`:2241`), `AccountsFor` in `account` (`:2426`), `IsOperator` (`:3088`), `SetLastAccount` and `AccountsFor` in `accountPage` (`:3344`, `:3353`), `HasAppIn` (`:3384`), `AppLife` (`:3419`), `Events` (`:3566`, `:3948`), `PendingChangesForContext` (`:3571`, `:3594`), plus `reg.List()` inside `Assemble` (`view.go:558`) through `perf.SpanContext(ctx, "db")`. Other Store reads stay unattributed; their time shows as `app` minus the named spans. *(My call.)* |
| + |
| +The only HTTP call on a screen path to a box or app host is the instance fetcher (`instances.go:130`, through `Config.AppClient`); it gets `defer perf.SpanContext(ctx, "box")()` round `f.client.Do`. |
| + |
| +- [ ] **Step 1: Write the failing tests:** |
| + - `cmd/console/perfs3_test.go` `TestOpenStoreTimesS3Requests`: an `httptest.Server` answering every request `404` with an S3 `NoSuchKey` XML body; `t.Setenv` `CARLOS_DEPLOYMENT_BUCKET=b`, `CARLOS_S3_ENDPOINT=<server URL>`, `AWS_ACCESS_KEY_ID=x`, `AWS_SECRET_ACCESS_KEY=y`, `AWS_REGION=us-east-1`; `st := openStore()`; a `perf.Middleware`-wrapped handler calls `st.Get(r.Context(), "k")`; the response's `Server-Timing` contains `s3;dur=` and the server saw one request. |
| + - `internal/console` `TestServerTimingNamesDBAndRegistry`: on the fixture, GET the app page; `Server-Timing` contains `db;dur=`. |
| + - `internal/console` `TestRunningTabTimesTheAppHost`: build the fixture with an `AppClient` (Task 9's `newConsoleFixtureWith` is not there yet, so set `fx.srv.instances.client` to an `http.Client` whose transport answers `200 []` for `/.carlos/instances`); GET `fx.u("/apps/kass/instances")`; `Server-Timing` contains `box;dur=`. |
| +- [ ] **Step 2: Run** `go test ./cmd/console/ -run TestOpenStoreTimesS3Requests -count=1` and `go test ./internal/console/ -run 'TestServerTimingNamesDBAndRegistry|TestRunningTabTimesTheAppHost' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement** the signature changes, the callers (every page caller passes `r.Context()`; `apiversion.go:205` passes `r.Context()`; `view_test.go` passes `context.Background()`), `ListTags` at `:3622` with `r.Context()`, the spans, `timeS3` applied in `openStore`'s S3 branch and to the seed data store at `main.go:389`. |
| +- [ ] **Step 4: Run** the Step 2 commands, then the existing view and app-page tests: `go test ./internal/console/ -run 'TestAssemble|TestVersions|TestAppPage|TestReleasesTab|TestInstancesTab' -count=1`. Expected: PASS. Then `go vet ./internal/console/ ./cmd/console/` and both cross-compiles. |
| +- [ ] **Step 5: Commit** the touched files, message `console: spans at the seams (s3 doer, app host, gate db reads, registry); Assemble and Versions take the request context`, ending with the Co-Authored-By line. |
| + |
| +### Task 6: Over-budget warnings reach the console's log |
| + |
| +**Files:** |
| +- Test: `internal/console/perfwiring_test.go` (extend) |
| + |
| +**Interfaces:** |
| +- Consumes: Task 4's wiring. No production change unless the test fails: the console logs through the standard `log` package, and `slog.Default()` writes through it, so `Options.Logger` stays nil. |
| + |
| +- [ ] **Step 1: Write the test** `TestOverBudgetPageIsLogged`: capture `log.SetOutput` into a buffer for the test (restore in `t.Cleanup`); build the fixture with `newConsoleFixtureOn(t, true, rel)` where `rel` is a fresh `release.NewDirStore` under `t.TempDir()` wrapped in a test type whose `Get` sleeps 160 ms (the app page's account-manifest read, `server.go:4092`, is a `Get` on every view, so the page goes over); GET `fx.u("/apps/kass")` twice within a second; the buffer contains `request over performance budget` once and `screen="GET /a/{sqid}/apps/{app}"`, and does not contain `kass`. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run TestOverBudgetPageIsLogged -count=1`. Expected: PASS (if it fails, the fix is in Task 4's wiring, not a new logger). |
| +- [ ] **Step 3: Commit** the test, message `console: pin that an over-budget page logs once, by pattern`, ending with the Co-Authored-By line. |
| + |
| +### Task 7: The Console speed table on `/fleet/metrics` |
| + |
| +**Files:** |
| +- Create: `internal/console/perfspeed.go`; Test: `internal/console/perfspeed_test.go` |
| +- Modify: `internal/console/server.go:3144-3156` (`handleFleetMetrics`), `page` struct (`:1817`, beside `Metrics` at `:1976`) |
| +- Modify: `internal/console/templates/metrics.html` (a new section after the box metrics, before `{{template "bottom" .}}`) |
| +- Modify: `approved_console_perf_copy_test.go` (`consolePerfCopyBuilt` gains `CPF-1` to `CPF-9`) |
| + |
| +**Interfaces:** |
| +- Consumes: `Server.PerfGroups()`, `perf.Group`, approved rows `CPF-1` to `CPF-9`. |
| +- Produces: `type consoleSpeedRow struct { Screen, Method string; Requests, Over int; P50, P95 string }`; `func consoleSpeedRows(groups []perf.Group) []consoleSpeedRow` (order kept: slowest p95 first; `P50`/`P95` formatted with CPF-9, rounded to whole milliseconds); `page.ConsoleSpeed []consoleSpeedRow`. |
| + |
| +The table lists every group, POSTs included (their over count is always 0). Column order: route (the pattern, as is), requests, over 150 ms, p50, p95. It is one self-contained section at the bottom of the template. The spec's Part 3 (in design) redesigns the `/fleet*` operator pages on the Rastrillo design system; that work carries this section and `consoleSpeedRows` over as they are. The metrics read's error path (`:3150-3153`) is unchanged. |
| + |
| +- [ ] **Step 1: Write the failing tests:** |
| + - `TestConsoleSpeedRowsFormat`: groups `{Screen: "GET /a", P50: 12.4, P95: 151.6, Requests: 3, Over: 1}` → row `P50 == "12 ms"`, `P95 == "152 ms"` (CPF-9's approved form), order preserved. |
| + - `TestFleetMetricsShowsConsoleSpeed`: Paul GETs `fx.u("/apps/kass")`, then `/fleet/metrics`; the body contains CPF-1's text, CPF-5's text and `GET /a/{sqid}/apps/{app}`, and does not contain `/apps/kass"` as a row. |
| + - `TestFleetMetricsConsoleSpeedEmptyState`: the existing `TestFleetMetricsEmptyState` setup; the body contains CPF-8's text only when no group exists. (The metrics GET itself is measured after it renders, so the first `/fleet/metrics` of a fresh fixture shows CPF-8.) |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestConsoleSpeedRows|TestFleetMetrics' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement** `consoleSpeedRows`, the page field, the handler line and the template section with the approved strings verbatim; add `CPF-1` to `CPF-9` to `consolePerfCopyBuilt`. |
| +- [ ] **Step 4: Run** the Step 2 command and `go test . -run TestConsolePerfCopy -count=1`. Expected: PASS. |
| +- [ ] **Step 5: Commit**, message `console: Console speed table on /fleet/metrics`, ending with the Co-Authored-By line. |
| + |
| +### Task 8: The budgets file and the screen inventory |
| + |
| +**Files:** |
| +- Create: `internal/console/perfbudgets_test.go` |
| +- Create: `internal/console/testdata/perf-budgets.txt` (header comment only in this task) |
| + |
| +**Interfaces:** |
| +- Consumes: `claimEntry{Kind, Pattern, Handler}` and `s.claimEntries.snapshot()` (`claim_routes.go:12-47`), which `registerRoute` fills for every registration. |
| +- Produces (test-only, package `console`): |
| + - `type perfRecord struct { Screen, Kind, Reason string; Calls, Line int }` with `Kind` one of `"over"`, `"skip"`, `"deferred"`, `"calls"` |
| + - `func parsePerfBudgets(r io.Reader) (map[string]perfRecord, error)` |
| + - `func loadPerfBudgets(t testing.TB) map[string]perfRecord` (reads `testdata/perf-budgets.txt`) |
| + - `func perfInventory(entries []claimEntry) []string`: sorted screen keys |
| + - `func perfScreenPath(screen string) (path string, hasParams bool)`: the method stripped, a trailing `{$}` removed; `hasParams` when any `{` remains |
| + |
| +The file's grammar, one record per line, `#` starts a comment: |
| + |
| +``` |
| +<screen> over: <reason> # known slow today; measured and printed, never failed; plan 2 deletes it |
| +<screen> calls <n>: <reason> # this screen may make n remote calls on a warm-cache GET (n >= 1) |
| +<screen> deferred: <reason> # a deferred-part endpoint: timed and printed, exempt from 150 ms and the call count |
| +<screen> skip: <reason> # not requested (a POST-only door that answers GET with the gate's 404, a JSON door) |
| +``` |
| + |
| +`<screen>` is the registered pattern verbatim: `GET /a/{sqid}/apps/{app}` (two fields when the first is an upper-case method) or `/fleet/architecture` (method-less registration). The inventory is every `claimEntry` with `Kind == "route"` whose pattern starts `GET ` or `/`, minus anything whose path is under `/api/` (the spec's call: CLI JSON doors are timed in production, not gated this round) and minus `GET /healthz` (perf skips it). |
| + |
| +- [ ] **Step 1: Write the failing tests:** |
| + - `TestParsePerfBudgets`: parses one line of each kind; `GET /a/{sqid}/apps/{app} calls 2: reads the edges file` gives `Kind "calls"`, `Calls 2`, `Reason "reads the edges file"`; `/fleet/architecture skip: x` gives `Screen "/fleet/architecture"`. |
| + - `TestParsePerfBudgetsRefuses`: each of these is an error naming its line, and all are reported at once: a missing reason (`GET /a over:`), an unknown kind (`GET /a slow: x`), `calls 0: x`, `calls two: x`, a duplicate screen, a lower-case method (`get /a over: x`). |
| + - `TestPerfInventoryIncludesMethodlessScreens`: entries `{route, "GET /a"}`, `{route, "/fleet/architecture"}`, `{route, "POST /b"}`, `{route, "/api/economics/bill"}`, `{route, "GET /api/cli/x"}`, `{route, "GET /healthz"}`, `{worker, "StartX"}` → `["/fleet/architecture", "GET /a"]`. |
| + - `TestPerfInventoryOfTheRealConsole`: on `newConsoleFixture`, `perfInventory(fx.srv.claimEntries.snapshot())` contains `GET /a/{sqid}/apps/{app}`, `GET /a/{sqid}/apps/{app}/settings/{section}`, `/fleet/architecture`, `GET /fleet/metrics`, and contains nothing under `/api/` and no `POST `. |
| + - `TestPerfScreenPath`: `GET /{$}` → `/`, false; `GET /a/{sqid}/{$}` → `/a/{sqid}/`, true; `/fleet/architecture` → `/fleet/architecture`, false. |
| + - `TestPerfBudgetsFileParses`: `loadPerfBudgets(t)` succeeds. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestParsePerfBudgets|TestPerfInventory|TestPerfScreenPath|TestPerfBudgetsFileParses' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement** the parser and inventory; write the file's header comment with the grammar above. |
| +- [ ] **Step 4: Run** the same command. Expected: PASS. |
| +- [ ] **Step 5: Commit**, message `console: perf-budgets.txt grammar and the screen inventory from registerRoute`, ending with the Co-Authored-By line. |
| + |
| +### Task 9: Latency injection and call counting at the store and the app host |
| + |
| +**Files:** |
| +- Create: `internal/console/perflatency_test.go` |
| +- Modify: `internal/console/server_test.go:49-107` (an options constructor; the three existing constructors call it) |
| + |
| +**Interfaces:** |
| +- Consumes: `deletableStore` (`view_test.go:20-100`: methods `Put`, `DeleteIfMatch`, `Delete`, `ListMod`, `ListSizes`, plus `Get`, `List`, `ListDirs` from the embedded `release.Store`). |
| +- Produces (test-only): |
| + - `type consoleFixtureOptions struct { WithKey bool; Releases release.Store; WrapReleases func(release.Store) release.Store; AppClient *http.Client }` |
| + - `func newConsoleFixtureWith(t *testing.T, o consoleFixtureOptions) *consoleFixture`: `newConsoleFixtureOn` becomes `newConsoleFixtureWith(t, consoleFixtureOptions{WithKey: withKey, Releases: rel})`. `fx.rel` stays the unwrapped store so seeding pays no latency. |
| + - `type perfLatency struct { S3Delay, HostDelay time.Duration; on atomic.Bool; s3, host atomic.Int64 }` with `func (l *perfLatency) Enable(on bool)`, `func (l *perfLatency) Calls() (s3, host int64)` |
| + - `type latencyStore struct { inner *deletableStore; l *perfLatency }` implementing exactly `Get`, `Put`, `List`, `ListDirs`, `Delete`, `DeleteIfMatch`, `ListMod`, `ListSizes`: each counts one S3 call, sleeps `S3Delay` when enabled, and delegates. |
| + - `func (l *perfLatency) AppClient() *http.Client`: a transport that counts one host call, sleeps `HostDelay` when enabled, and answers `200` with body `[{"slug":"web-1","status":"ok"}]` for `/.carlos/instances` and `404` otherwise. It never dials. |
| + |
| +The parity rule: `latencyStore` must have the same exported method set as `*deletableStore`, so the console under test sees the same optional interfaces it sees in every other test. *(My call; this is why the store is wrapped with an explicit method list instead of by embedding.)* |
| + |
| +The console makes no direct box HTTP call on a screen path today (Task 5); `HostDelay` is applied to `AppClient`, the app-host client. A future box client on a screen path must be added here. |
| + |
| +- [ ] **Step 1: Write the failing tests:** |
| + - `TestLatencyStoreMethodSetMatches`: the sorted exported method names of `reflect.TypeOf(&latencyStore{})` equal those of `reflect.TypeOf(&deletableStore{})`. |
| + - `TestLatencyStoreCountsAndDelays`: enabled with `S3Delay` 25 ms, one `Get` takes at least 25 ms and `Calls()` reports `(1, 0)`; disabled, a `List` takes under 5 ms and reports `(2, 0)`. |
| + - `TestLatencyAppClientAnswersTheContract`: `GET http://shop.example.com/.carlos/instances` answers 200 with one instance and counts `(0, 1)`. |
| + - `TestFixtureWithWrappedStoreServesAppPage`: `newConsoleFixtureWith` with `WrapReleases` set to a `latencyStore` (disabled), signed in, GET `/apps/kass` answers 200 and `Calls()` reports more than zero S3 calls. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestLatency|TestFixtureWithWrappedStoreServesAppPage' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement** the options constructor and the two injectors. |
| +- [ ] **Step 4: Run** the same command plus `go test ./internal/console/ -run 'TestConsoleE2E|TestCreateApp' -count=1` (existing fixture users). Expected: PASS. |
| +- [ ] **Step 5: Commit**, message `console tests: fixture options, latency-injecting store and app client that count remote calls`, ending with the Co-Authored-By line. |
| + |
| +### Task 10: The walk: every screen, timed and counted |
| + |
| +**Files:** |
| +- Create: `internal/console/perfwalk_test.go` |
| +- Modify: `internal/console/testdata/perf-budgets.txt` (the initial records) |
| +- Modify: `.amadan/test-weights.tsv` (a row for `TestConsoleScreensMeetTheBudget` with its measured seconds) |
| + |
| +**Interfaces:** |
| +- Consumes: Tasks 8 and 9 (`perfInventory`, `perfScreenPath`, `loadPerfBudgets`, `perfRecord`, `newConsoleFixtureWith`, `perfLatency`, `latencyStore`), `signInPaul`, `newBrowser`. |
| +- Produces (test-only; plan 2 extends `perfTargets` and relies on these names): |
| + - `type perfTarget struct { Path string; Expect int; Anonymous bool }` |
| + - `func newPerfFixture(t *testing.T) (*consoleFixture, *perfLatency)`: `newConsoleFixtureWith` with `WithKey: true`, `WrapReleases` to a `latencyStore` (`S3Delay` 25 ms, `HostDelay` 40 ms), `AppClient` from the same `perfLatency`, then the seeds below. |
| + - `func perfTargets(fx *consoleFixture) map[string][]perfTarget` |
| + - `func perfEnforce() bool`: `os.Getenv("CI") != "" || os.Getenv("AMADAN_CI") != ""` |
| + - `func TestConsoleScreensMeetTheBudget(t *testing.T)` (not parallel) |
| + - a hook plan 2 fills: `var perfQuiesce = func(fx *consoleFixture) {}`, called after every request before the call count is read. |
| + |
| +Seeds `newPerfFixture` adds on top of the fixture's own (`kass` with `v1`, `v2`, channels `stable` and `canary/x`, routes `kass.carlosapp.dev`, `docs.kass.carlosapp.dev`): |
| + |
| +- an invite: `fx.st.CreateInvite(OpsAccountID, "paul@keymail.dev", "paul@keymail.dev", time.Now())` returns the token (`store.go:1352`; used the same way at `server_test.go:685`); signed in as the invited address, `/invite/{token}` answers 200 `confirm_action`; |
| +- a customer fleet `fleet-a` owned by `fx.sqid`: `registry.CreateFleet(registry.Fleet{Name: "fleet-a", Account: fx.sqid, …})` and one `AddFleetBox` through the registry at `fx.regPath`, as `updatesgate_test.go:80-90` does (`openTestReg`, `fleets_test.go:53`), plus a heartbeat with `writeFleetHeartbeat` (`fleets_test.go:648`); |
| +- `seedFleetJSON(t, fx)` (`server_test.go:1629`) so `/fleet` and `/a/{sqid}/fleet` have a snapshot; |
| +- an email sign-in link for `GET /auth/email/link?t=` from the store's `CreateEmailChallenge` if that needs no mailer; otherwise a `skip:` record saying why (an unknown token answers 410, which must not be measured). |
| + |
| +Neutral names only (`shop`, `fleet-a`, `example.com`). |
| + |
| +`perfTargets` maps every screen with a path parameter to its paths: `{sqid}` is `fx.sqid`, `{app}` is `kass`, `{host}` is `kass.carlosapp.dev`, `{fleet}` is `fleet-a`, `{token}` the seeded invite, and `GET /a/{sqid}/apps/{app}/settings/{section}` gets one target per key of `appSettingsSections` (derived from the map, so a new section is walked without an edit). A parameter-less screen needs no entry: it gets `{Path: perfScreenPath(screen), Expect: 200}`. Entries are also how a parameter-less screen's status is set. Known today (inventory of 2026-10-25): |
| + |
| +| screen | target(s) | |
| +|---|---| |
| +| `GET /{$}` | signed in, `Expect: 302` (landing redirect); and `Anonymous: true`, `Expect: 200` (front page) | |
| +| `GET /auth/signin` | `Anonymous: true`, `Expect: 303` (builds the Keymail URL, makes no call) | |
| +| `GET /auth/confirm` | `Expect: 200` ("link expired" page, no input needed) | |
| +| `GET /auth/cli/tokens` | `Expect: 303` (to `/settings`) | |
| +| `GET /apps`, `GET /apps/{app}` | `Expect: 302` (legacy redirects into the account) | |
| +| `/fleet/architecture` | `Expect: 200` (method-less; GET and HEAD served) | |
| + |
| +Every other screen expects 200. Run the walk once and set any status that differs, but never record a 404 or a redirect to sign-in for a screen that has a real page (that means a fixture is missing). Routes no fixture can drive honestly get a `skip:` record instead: |
| + |
| +- `GET /auth/callback` and `GET /auth/stepup/callback`: need a live OAuth state and make a token POST to Keymail; |
| +- `GET /auth/cli/whoami`: a bearer-token JSON door, timed in production; |
| +- the method-less POST-only doors `/fleet/economics/scenarios`, `/fleet/economics/bill`, `/fleet/economics/tier`, `/fleet/architecture/refresh`: a GET answers 404 on its first line by design (`economicspass.go:1117`, `:1221`, `:1300`; `archpage.go:117`). (`/api/economics/*` is outside the inventory.) |
| + |
| +The walk, per screen in `perfInventory`: |
| + |
| +1. Structural checks, which fail always (not only under CI), all reported before anything is measured: a screen with a path parameter and no `perfTargets` entry; a `perfTargets` key or a budgets record naming no screen in the inventory ("stale: delete it"); a `skip` record on a screen that also has targets. |
| +2. A `skip` screen is not requested. |
| +3. An `over` screen: latency disabled; two requests; the call count of the second is printed with its reason as `"%s %s: over (%s): %d S3 and %d host calls warm"`. Never failed. (Measured without latency so the slow screens cost the test milliseconds, not seconds.) |
| +4. Every other screen: latency enabled; ten requests; the first two discarded. Time to first byte is `httptrace`'s `GotFirstResponseByte` as Rastrillo's `perftest` measures it; each response is read to the end. After each request, wait until the handler has returned (an in-flight counter in the `httptest` handler, as `perftest.screens` does), call `perfQuiesce(fx)`, then read the call delta. Status must equal `Expect`, always failed. Calls: the largest delta over the eight measured requests must not exceed the allowance (0, or `n` from a `calls n:` record), always failed, because counts are deterministic. *(My call: the spec says the test fails only when CI is set; that is applied to timing, which is noisy on a laptop, and not to counts, which are not.)* Time: median of the eight within 150 ms and none over 450 ms, failed only when `perfEnforce()`, printed always. A `deferred` screen is timed and printed but exempt from both the 150 ms rule and the count. |
| +5. Print each result with `t.Logf` (`median`, `worst`, `calls`). At the end, print the total elapsed time; when `perfEnforce()` and it exceeds 10 s, fail. |
| + |
| +- [ ] **Step 1: Write the walk test** with the behaviour above and an empty records file (header only). Run it locally without `CI`: `go test ./internal/console/ -run TestConsoleScreensMeetTheBudget -count=1 -v`. Expected: structural failures only for missing fixtures and statuses; fix fixtures and `Expect` values until the only lines left are timing and call-count results. |
| +- [ ] **Step 2: Run with `CI=1`.** Expected: FAIL, listing every screen over 150 ms or over its call allowance. That list is today's slow set. |
| +- [ ] **Step 3: Record each of them** in `perf-budgets.txt` as `over:` with a reason naming what makes it slow, read from the printed call counts and from the spec's §2.4 C table (for example `GET /a/{sqid}/apps/{app} over: Overview reads every channel, the pipeline twice and up to 20 manifests (plan 2)`), `skip:` records for the routes listed above with their reasons, and `deferred: deferred part` for `GET /a/{sqid}/apps/{app}/logs/data`, the Logs tab's existing data endpoint. |
| +- [ ] **Step 4: Run with `CI=1` again.** Expected: PASS, total under 10 s. Record the measured seconds in `.amadan/test-weights.tsv`. |
| +- [ ] **Step 5: Prove the gate bites.** Temporarily delete one `over:` line and confirm `CI=1` fails on that screen; temporarily add a `Get` to `handleFleetMetrics` and confirm the call count fails without `CI`; restore both. |
| +- [ ] **Step 6: Commit** `internal/console/perfwalk_test.go internal/console/testdata/perf-budgets.txt .amadan/test-weights.tsv`, message `console: CI walk of every screen with latency injection and remote-call counts; today's slow screens recorded as over`, ending with the Co-Authored-By line. |
| + |
| +### Task 11: Census, full gate, review and merge |
| + |
| +**Files:** |
| +- Create (by the tool): the census overlay and `docs/superpowers/notes/census-proposal-console-perf-1.md` |
| + |
| +- [ ] **Step 1: Census card.** `make census-card`. For every changed unit write a CLAIMS line (`<file>:<unit><TAB><what changed, and that no read was added>`). The changes add no read of root-owned state: perf spans, a buffered render, context threading, an S3 HTTP doer wrapper. Then `make census-propose NAME=console-perf-1 CLAIMS=<file>`. Expected: it writes the overlay and the card and reports the census clean. A `reads`, `new`, `removed` or `other` class is a decision for Paul on #280, not an approval. |
| +- [ ] **Step 2: Independent approval.** Give the card and the branch diff against amadan `main` to a reviewer of the other model family (Astra for this Claude-written branch); record each verdict on #280 with the reviewer and the tip. |
| +- [ ] **Step 3: Local gate.** `gofmt -l .` (empty), `go vet ./...`, `go build ./...`, `GOOS=darwin GOARCH=arm64 go build ./...`, `GOOS=windows GOARCH=amd64 go build ./...`, and the targeted runs from Tasks 2 to 10. Then one `-race` run of `go test ./internal/perf/ -race -count=1`. |
| +- [ ] **Step 4: Push, describe, wait for CI.** `amadan branch describe carlos/platform console-perf-1 -body -` (what changed, why, how it was tested, the census approval); `amadan ci status carlos/platform -branch console-perf-1` until exit 0. |
| +- [ ] **Step 5: Squash, re-run CI on the squashed tip, merge** with the `-expect <tip>` form. |
| + |
| +### Task 12: Roll and read the real numbers (after merge; needs Paul's go-ahead) |
| + |
| +Not a code task. Spec §2.5 step 1: ship and roll this on its own and read flagship's numbers before plan 2 changes anything. |
| + |
| +- [ ] **Step 1:** Release and roll in the house order (dev boxes, dev console, check, flagship boxes, flagship console), following the platform release and roll recipes in README and the memory notes. Ask Paul before the flagship console roll. |
| +- [ ] **Step 2:** On flagship, open the four pages in spec §1 "Why" twice each and read `Server-Timing` from the second response (`curl -s -D - -o /dev/null` with a session cookie, or the browser's network panel). Note `app` and each span. |
| +- [ ] **Step 3:** After a day, read the Console speed table on `/fleet/metrics`. Post both readings to the branch's amadan discussion as the "before" numbers plan 2 is judged against. |
| + |
| +--- |
| + |
| +## Self-review |
| + |
| +- **Spec coverage.** §2.1: budget, methods, streams, no cold start (Tasks 2, 3); API GETs timed in production but not walked (Task 8 inventory). §2.2: middleware on the console mux (Task 4), `Server-Timing` with `app` and spans (Task 3), spans `db`, `s3`, `box`, `render` at the seams (Tasks 4, 5), grouping by pattern (Tasks 3, 4), throttled warning (Tasks 2, 6), the 2,048 ring and Console speed table (Tasks 2, 7), `Skip` `/healthz` (Task 4). §2.3: walk over every `registerRoute` screen including method-less ones (Tasks 8, 10), production constructor (Tasks 9, 10), latency injection 25 ms and 40 ms (Task 9), warm-cache call counts with default zero and `perf-budgets.txt` reasons (Tasks 8, 10), fixtures for every parameter and failure for a missing one (Task 10), deferred parts listed and exempt (Task 8 grammar, Task 10), fails only under `CI` for timing (Task 10), under 10 s (Task 10). §2.5 steps 1 and 2: Tasks 1 to 10 and 12. |
| +- **Calls that cross plans.** Plan 2 uses `perf.SpanContext`, `Server.PerfGroups`, `newPerfFixture`, `perfTargets`, `perfTarget`, `perfQuiesce`, `perfRecord`, `loadPerfBudgets` and the `perf-budgets.txt` grammar by these names. |
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| new file mode 100644 |
| index 000000000..42873a3a0 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-10-25-console-perf-2-fixes.md |
| @@ -0,0 +1,500 @@ |
| +# Console perf, plan 2: make every screen fast Implementation Plan |
| + |
| +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. |
| + |
| +**Goal:** Bring every console screen under 150 ms to first byte with zero remote calls on a warm-cache GET, so that `internal/console/testdata/perf-budgets.txt` ends the round with no `over:` records, while net S3 requests per page view go down. |
| + |
| +**Architecture:** First stop doing work nobody needs (spec §2.4 C): one gate read per request through a request memo, a remembered account manifest, a last-account write only on change, an edge fold that refreshes behind the request, one pipeline read, the settings page building only the section shown, no duplicated reads inside a page. Then an in-process view cache (§2.4 A, `internal/console/viewcache.go`) holds the remote reads behind every screen, keyed by account and app. A view serves what it holds and, when an entry is older than its window, starts one background refresh for that key. A miss renders the page frame with a placeholder that a small script fills from a deferred-part endpoint (§2.4 B), following the Logs tab's `fetch()` pattern. A wrapper on every write route re-reads the written scope's entries inside the POST before the redirect goes out, and leaves them invalidated if that re-read fails. |
| + |
| +**Tech Stack:** Go 1.26 generics, `net/http`, `html/template`, inline vanilla JS (no framework, no CSP today), SQLite (`modernc.org/sqlite`), `release.Store`. |
| + |
| +**Spec:** `docs/superpowers/specs/2026-10-25-console-ux-perf-design.md`, §2.4 (A, B, C and the console DB question), §2.5 step 3, §2.6. Read Part 2 whole. Plan 1 (`2026-10-25-console-perf-1-measure.md`) must have merged: this plan uses its names exactly (`perf.SpanContext`, `Server.PerfGroups`, `newPerfFixture`, `perfTargets`, `perfTarget`, `perfQuiesce`, `perfLatency`, `latencyStore`, `loadPerfBudgets`, the `perf-budgets.txt` grammar, `Assemble(ctx, …)`, `Versions(ctx, …)`). Where this plan and the spec disagree, the spec wins and the plan is the bug. |
| + |
| +**Branch:** `console-perf-2`, cut from amadan `main` after plan 1 has merged and rolled (plan 1 Task 12 recorded the "before" numbers). Part 1 of the spec (navigation and layout, a separate plan) rewrites `app_releases.html`, `app_deployments.html`, `app_instances.html`, `app_settings.html` and `appnav.html`; it moves Placement into Settings and turns `/deployments` into a 303 to `/releases`. This plan touches those templates only to wrap each tab's body in a `{{define}}` (first and last lines). Whichever branch lands second re-applies the wrap to the other's markup and updates `perfTargets` and the parts table for moved or redirected routes. Part 3 (in design) redesigns the operator `/fleet*` pages on the Rastrillo design system; Task 15 changes their handlers and only wraps their template bodies, and if Part 3 lands first Task 15 applies the same wrap to the new templates. |
| + |
| +## Global Constraints |
| + |
| +Every task's requirements include this section. |
| + |
| +- **Targeted local tests; CI runs the full suite.** `go test ./internal/console/ -run 'TestName' -count=1`; never `make test`, never a whole `internal/console` run. `go build ./...`, `go vet ./...`, `gofmt -l .` clean. `GOFLAGS=-buildvcs=false` if the sandbox refuses VCS stamping. The walk (`TestConsoleScreensMeetTheBudget`) is run with `CI=1` once at the end of each task that deletes `over:` records, not in a loop. |
| +- **Cross-compiles stay green:** `GOOS=darwin GOARCH=arm64 go build ./...` and `GOOS=windows GOARCH=amd64 go build ./...` before every push. |
| +- **Go cache:** leave `GOCACHE`, `GOMODCACHE` and `GOTMPDIR` at their defaults. Run go with the sandbox off if `~/.cache/go-build` is read-only. |
| +- **Production wiring, not stand-ins.** Console tests build the server with `NewServer` through `newConsoleFixtureWith` / `newPerfFixture` (plan 1), the constructor `cmd/console` uses. The only injected seams are the wrapped release store and `Config.AppClient`. A test does not reach into `s.views` to plant a value; it makes the reads happen by viewing pages. |
| +- **S3 requests cost money.** Net S3 requests per page view go down. Refresh happens only when someone views the screen (a page GET, a deferred-part fetch) or inside a write's own POST. No timers, no tickers, no per-app or per-box polling, no warm-up at start. A background load is one goroutine per key, started by a view, ended within `viewLoadTimeout`. |
| +- **Freshness, verbatim from the spec.** About 30 s for live data (instance health, observed versions, box snapshots, edges, app self-reports, logs, errors, analytics windows): `liveWindow = 30 * time.Second`. About 5 min for data only console writes change (manifests, channels, pipeline, account manifest, settings records): `writtenWindow = 5 * time.Minute`. Write invalidation keeps the second class correct. |
| +- **Read your own writes.** Every console-mediated write that changes what a cached entry holds re-reads that scope's entries inside the POST before it redirects. If the re-read fails the POST still succeeds and the entries are left invalidated, never stale: the next GET treats them as a miss. The pre-write value is never served after the user's own write, including when a background refresh that started before the write finishes after it. |
| +- **Deferred parts.** The page arrives within 150 ms. A part the cache does not hold renders as a placeholder that a `fetch()` fills, following the Logs tab's pattern (`templates/app_logs.html:66-196`: inline script, `AbortController` with a 20 s timeout, `Accept` header). Parts are HTML fragments rendered by the same templates as the page. No new JS framework. With JavaScript off the page is still usable minus that part, and its placeholder says how to see it. Independent reads that remain on a request path run concurrently; removing them is the goal. |
| +- **Console security gate order is unchanged:** session, then CSRF, then owner (byte-identical 404), then `requireFreshAuth`. A deferred-part endpoint calls the same gate function as its page, first, and a request the gate refuses starts no load and makes no remote call. A write's re-read runs only after the handler's own gates admitted it. |
| +- **Copy goes through a Luna pass before it is written into a template** (Task 1). House voice: no em dashes (a full stop and a new sentence, continuing in lower case); human text only. No tenant names: neutral names in code, tests and fixtures (`shop`, `example.com`; the existing fixture app `kass` and account `ops` may be reused). |
| +- **`over:` records.** Each task deletes the `over:` records of the screens it makes fast, in the same commit, and the walk passes with `CI=1` before that commit. A screen that needs a remote call on a warm GET gets a `calls <n>: <reason>` record only with a reason a reviewer accepts; the target is none. |
| +- **A ResponseWriter wrapper that edits headers needs care** (AGENTS.md). The write wrapper in Task 8 edits no header; it only runs the re-read before passing `WriteHeader` down, and keeps `Flush`, `Hijack` and `Unwrap`. |
| +- **Commit per task.** Every commit message ends with `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`. |
| +- **Amadan tasks:** one per plan task on the branch, advanced as each closes. **Test weights:** a new top-level `internal/console` test of a second or more gets a row in `.amadan/test-weights.tsv`. **Merge main first** before review and before merging, re-run the census card, wait for CI on that tip, merge with `amadan branch merge carlos/platform console-perf-2 -expect <tip> -message "..."`; never a bare `amadan branch merge`. |
| + |
| +## Review Focus |
| + |
| +1. **A probe of someone else's app part.** A signed-in non-member requests `/a/<their-sqid>/apps/<app>/part/overview`. They expect, and must get, the byte-identical 404 a page probe gets, and the console must start no load: a probe that triggers S3 reads is both a cost and an oracle. Test: Task 7, `TestPartEndpointGatesLikeItsPage` (asserts the 404 body equals the page's and `perfLatency.Calls()` is unchanged). |
| +2. **Two accounts that each own an app with the same name.** App names are unique per account, not globally (`server.go:3500-3507`). A member of one must never see the other's channels from the cache. Test: Task 6, `TestViewKeysAreAccountScoped`, and Task 9, `TestSameAppNameInTwoAccountsNeverShares`. |
| +3. **A refresh that hangs.** S3 stalls for a minute while people keep opening the app. They expect the last reading with its "as of" age, not a pile of goroutines, and the next view after the hang ends to try again. Test: Task 6, `TestHungLoadIsBoundedAndRetried` (a loader blocking past `viewLoadTimeout`; one goroutine at a time; after it gives up the next view starts one more). |
| +4. **A refresh that started before the user's write and finishes after it.** It read the pre-write state and must not overwrite the re-read. Test: Task 6, `TestLoadStartedBeforeAnInvalidateIsDiscarded`; Task 10, `TestPromoteDuringABackgroundRefreshShowsTheNewVersion`. |
| +5. **Unbounded keys.** Logs, Errors and Analytics entries are keyed by their filter query, which a person types. Many distinct searches must not grow the console's memory without bound. Test: Task 6, `TestViewCacheEvictsLeastRecentlyUsed` (cap honoured, entries being loaded never evicted); Task 12 normalizes the query before keying. |
| + |
| +--- |
| + |
| +## File structure |
| + |
| +| File | Responsibility | |
| +|---|---| |
| +| `internal/console/pagememo.go` (create) | per-request memo: `withPageMemo`, `memoOnce`. | |
| +| `internal/console/viewcache.go` (create) | the view cache: keys, windows, single-flight loads, invalidate, re-read, eviction, quiesce. | |
| +| `internal/console/viewwrite.go` (create) | write target in the request context; the writer wrapper that re-reads before `WriteHeader`. | |
| +| `internal/console/viewparts.go` (create) | `viewMode`, `errViewPending`, `viewGet`, the parts tables, the three part handlers, `asOfText`. | |
| +| `internal/console/templates/parts.html` (create) | `deferred`, `asof` and `partfailed` partials and the loader script partial. | |
| +| `internal/console/claim_routes.go` (modify `:59-69`) | `registerRoute` installs the memo for every request and the write target for non-GET requests. | |
| +| `internal/console/server.go`, `view.go`, `appsettings.go`, `instancepage.go`, `errorsview.go`, `analyticsview.go`, `accountfleet.go`, `fleets.go`, `ownership.go`, `storepage.go`, `archpage.go`, `pipelinepage.go`, `pendinghandlers.go`, `regiondefault.go`, `regioncandidates.go`, `apisystemupdate.go`, `apiinstances.go`, `accountreview.go`, `instances.go` (modify) | screens read through the memo and the cache. | |
| +| `internal/console/templates/*.html` (modify) | each screen's body wrapped in `{{define "<name>_body"}}`, an `asof` line, a placeholder branch. | |
| +| `internal/console/store.go` (modify, Task 16 only if the measurement calls for it) | a read-only pool for the gate's reads. | |
| +| `internal/provision/provision.go` (modify) | export `ListRecordHosts` over `recordHosts` (`:2859`). | |
| +| `internal/console/perfwalk_test.go`, `perflatency_test.go` (modify) | `perfQuiesce` set; part targets; key log and failure switch on the latency store. | |
| +| `internal/console/testdata/perf-budgets.txt` (modify) | `over:` records deleted task by task; part routes recorded `deferred`. | |
| + |
| +--- |
| + |
| +### Task 1: Copy rows for the cache and the deferred parts |
| + |
| +**Files:** |
| +- Modify: `docs/superpowers/plans/2026-10-25-console-perf-copy.md` (rows from `CPF-20`) |
| +- Modify: `docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-PERF.md` (a plan 2 section) |
| +- Create: `docs/superpowers/plans/LUNA-COPY-REVIEW-CONSOLE-PERF-2.md` |
| + |
| +**Interfaces:** |
| +- Produces: approved rows `CPF-20` to `CPF-28`. Tasks 6 and 8 add them to `consolePerfCopyBuilt` (`approved_console_perf_copy_test.go`) when they write them. |
| + |
| +| id | file | draft text | |
| +|---|---|---| |
| +| CPF-20 | `internal/console/viewparts.go` | As of <age> ago. | |
| +| CPF-21 | same | less than a minute | |
| +| CPF-22 | same | 1 minute | |
| +| CPF-23 | same | <n> minutes | |
| +| CPF-24 | same | 1 hour | |
| +| CPF-25 | same | <n> hours | |
| +| CPF-26 | `internal/console/templates/parts.html` | Loading the latest from the platform. | |
| +| CPF-27 | same (inside `<noscript>`) | This part is still loading. Reload the page in a moment to see it. | |
| +| CPF-28 | same | This part could not be read just now. Reload the page to try again. | |
| + |
| +- [ ] **Step 1: Add the rows** as `pending`, placeholders noted (`<age>` is one of CPF-21 to CPF-25; `<n>` a whole number of 2 or more). |
| +- [ ] **Step 2: Extend the brief** with a plan 2 section: where each string shows (small text under a section of an app or operator page; a placeholder in place of a section while it loads; the same placeholder with JavaScript off; the text a failed load leaves), and that CPF-20 is assembled with one of CPF-21 to CPF-25. Commit, then run Luna exactly as plan 1 Task 1 Step 5, with output `LUNA-COPY-REVIEW-CONSOLE-PERF-2.md` and the prompt naming rows CPF-20 to CPF-28. |
| +- [ ] **Step 3: Apply Luna's text verbatim**, mark rows `approved` (delegation note as in plan 1), run `go test . -run TestConsolePerfCopy -count=1` (PASS), commit with message `console perf: copy for the view cache and deferred parts`, ending with the Co-Authored-By line. |
| + |
| +### Task 2: One gate read per request; no write or manifest read on every view |
| + |
| +Spec §2.4 C rows 1 to 3: `ensureAccountManifest` re-reads on every app tab; `SetLastAccount` writes on every view; `AccountsFor` runs three times and the route table is read twice per app tab. |
| + |
| +**Files:** |
| +- Create: `internal/console/pagememo.go`; Test: `internal/console/pagememo_test.go` |
| +- Modify: `internal/console/claim_routes.go:59-69` (`registerRoute`) |
| +- Modify: `internal/console/server.go`: `account` (`:2426`), `accountPage` (`:3344`, `:3353`), `memberAccount` (`:2361`), `ensureAccountManifest` (`:4087-4103`), `appPage` (`:3424`) |
| +- Modify: `internal/console/accountreview.go:37`, `:41` (`appAccountReview` gains `ctx context.Context` as its first parameter) |
| +- Modify: `internal/console/view.go:558` (`Assemble`'s route read) |
| +- Modify: `internal/console/perflatency_test.go` (`perfLatency` records keys) |
| + |
| +**Interfaces:** |
| +- Produces: |
| + - `func withPageMemo(ctx context.Context) context.Context` |
| + - `func memoOnce[T any](ctx context.Context, key string, f func() (T, error)) (T, error)`: the first call per key per request runs `f`, later calls return its result (error included); with no memo in `ctx` it just runs `f`. |
| + - `var pageMemoHits atomic.Int64`: incremented on every memo hit (read by tests). |
| + - `func (s *Server) accountsFor(ctx context.Context, addr string) ([]Account, error)` (memo key `accounts:<addr>`) and the package-level `func memoRoutes(ctx context.Context, regPath string) ([]registry.Route, error)` (memo key `routes:<regPath>`, through `openRegistry`), so `Assemble` and `appAccountReview` share one route read. Every page-path caller of `s.store.AccountsFor` and of `reg.List()` that has a request context uses these. Callers mutate neither result (copy before sorting or appending). |
| + - `Server.manifestSeen sync.Map` (sqid → struct{}): `ensureAccountManifest` returns at once for a sqid it has seen exist or has written. |
| + - `func (s *Server) noteLastAccount(addr string, id int64) (wrote bool)`: writes `SetLastAccount` only when `Server.lastAccount` (a `sync.Map` addr → id, filled on write and by `memberAccount`'s `LastAccount` read) differs from `id`. |
| + - test-only, on plan 1's `perfLatency`: `Keys() []string` (every key or prefix the latency store was asked for, in order), `ResetKeys()`, `SetFail(match func(key string) bool)` (a matching `Get` or listing returns an error after counting; nil clears it), `Hold(match func(key string) bool) (release func())` (a matching `Get` blocks until `release` is called), and `OnPut(f func(key string))` (runs after each `Put` reaches the store). Later tasks use these five by name. |
| + |
| +`registerRoute` wraps every handler with `withPageMemo` inside the mux (the mux has already set the pattern for plan 1's perf middleware), and keeps its existing claim-entry wrapping and order. |
| + |
| +- [ ] **Step 1: Write the failing tests:** |
| + - `TestMemoOnceRunsOncePerRequest`: three `memoOnce(ctx, "k", f)` calls on one memo context run `f` once and return the same value; a second `withPageMemo(context.Background())` runs it again; a context with no memo runs `f` every time. |
| + - `TestAppPageReadsAccountManifestOnce`: on `newPerfFixture`, GET `/apps/kass` twice; across both, `Keys()` holds `accounts/<sqid>/account.json` at most once. |
| + - `TestNoteLastAccountWritesOnlyOnChange`: on the fixture, `noteLastAccount(a, 1)` is true, again false, `noteLastAccount(a, 2)` true; `fx.st.LastAccount(a)` is 2. |
| + - `TestAppTabReusesGateReads`: record `pageMemoHits` before and after one GET of `/apps/kass`; the difference is at least 3 (two repeat `AccountsFor` reads and one repeat route read are now hits). |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestMemoOnce|TestAppPageReadsAccountManifestOnce|TestNoteLastAccount|TestAppTabReusesGateReads' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement** the interfaces above and switch the call sites listed. |
| +- [ ] **Step 4: Run** Step 2's command plus the gate tests `go test ./internal/console/ -run 'TestConsoleE2E|NonMember|Picker|TestAccountReview|TestTeamPage' -count=1`. Expected: PASS. |
| +- [ ] **Step 5: Walk** with `CI=1`; delete any `over:` record it now reports under budget. Commit, message `console: one gate read per request, remembered account manifest, last-account write only on change`, ending with the Co-Authored-By line. |
| + |
| +### Task 3: The edge fold refreshes behind the request; one pipeline read; bounded reads |
| + |
| +Spec §2.4 C rows 5 to 7, plus two wasted reads the 2026-10-25 inventory found. |
| + |
| +**Files:** |
| +- Modify: `internal/console/server.go:1281-1306` (`foldedEdgeIPs`), `:3467-3492` (`applyPipelineView`), `:3301-3338` (`handleAccountSettings`, `:3328`), `:3793-3805` (Logs host list) |
| +- Modify: `internal/console/view.go` (`AppView` gains `PipelineErr error`), `:941` (`Versions` bounds its own context) |
| +- Modify: `internal/console/pendinghandlers.go:473` (`pendingPipeline`), `internal/console/pipelinepage.go:224-231` |
| +- Modify: `internal/provision/provision.go` (export `ListRecordHosts`) |
| +- Test: `internal/console/perffixes_test.go` (create) |
| + |
| +**Interfaces:** |
| +- Produces: |
| + - `foldedEdgeIPs` never waits on a fold: it returns the last fold (or nothing before the first) and, when the fold is older than `edgeFoldTTL` and none is running, starts one in a goroutine. The empty-fold rule (`:1281-1286`) is kept. The fold is still triggered only by a request. |
| + - `AppView.PipelineErr error`: set by `applyPipelineView` when the read fails, so `Pipeline == nil && PipelineErr == nil` means "no pipeline". `func pipelineOf(view *AppView) (*release.Pipeline, error)` replaces the second `GetPipeline` in `pendingPipeline`'s callers (`server.go:3576`, `:3597`) and in `handlePipelineSettingsPage` (`pipelinepage.go:228`). |
| + - `var versionsTimeout = instanceStoreTimeout`: `Versions` wraps its `ctx` with it. |
| + - Account settings resolve the account level only: `telemetry.Read(ctx, s.cfg.Releases, telemetry.AccountKey(sqid))` folded with `telemetry.Fold(acct, telemetry.Settings{})`, instead of `telemetry.Resolve(..., "")`, which reads `apps/<sqid>//telemetry.json`, a key nothing writes. |
| + - `func ListRecordHosts(ctx context.Context, s release.Store, acct, app string, max int) ([]string, error)` in `internal/provision`: one listing of the records prefix through `recordHosts`, no `Get`. The Logs tab's host picker (`server.go:3795`) uses it instead of `ListRecords`, which fetched every record (up to 500) only for its host name. |
| + |
| +- [ ] **Step 1: Write the failing tests** in `perffixes_test.go`: |
| + - `TestEdgeFoldNeverBlocksARequest`: set `fx.srv.foldEdgeIPs` to a func that blocks on a channel; age the cache past `edgeFoldTTL`; two concurrent `fx.srv.dnsTargets()` calls return within 50 ms with the previous IPs; release the channel; the fold ran once. |
| + - `TestOverviewReadsThePipelineOnce`: seed a pipeline and one pending change for `kass`; `ResetKeys()`; GET `/apps/kass`; `pipeline.json` appears once in `Keys()`. |
| + - `TestPipelinePageReadsThePipelineOnce`: same, for `/apps/kass/settings/pipeline`. |
| + - `TestPipelineReadErrorStillSaysSo`: with `SetFail` matching keys ending `pipeline.json`, the pipeline page still shows its existing flash error (`pipelinepage.go:231`) and makes one pipeline read. |
| + - `TestVersionsGivesUpAtItsDeadline`: `versionsTimeout = 50 * time.Millisecond` for the test; a store whose listing blocks until its context ends; `Versions` returns an error within 200 ms. |
| + - `TestAccountSettingsReadsNoAppTelemetryKey`: GET `/settings` of the account; no key in `Keys()` contains `//`. |
| + - `TestLogsHostPickerReadsNoRecords`: seed three instance records; GET `/apps/kass/logs`; no `Get` of a key under `apps/<sqid>/kass/instances/`; all three hosts are in the picker. |
| + - `TestListRecordHostsMatchesListRecords` (in `internal/provision`): over a `DirStore` with records and a nested key, `ListRecordHosts` returns the hosts `ListRecords` returns, in the same order. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestEdgeFold|TestOverviewReadsThePipelineOnce|TestPipelinePage|TestPipelineReadError|TestVersionsGivesUp|TestAccountSettingsReads|TestLogsHostPicker' -count=1` and `go test ./internal/provision/ -run TestListRecordHosts -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement.** |
| +- [ ] **Step 4: Run** Step 2's commands plus `go test ./internal/console/ -run 'TestDomainGuidance|TestPending|TestPipeline|TestAccountSettingsPage|TestAppLogs' -count=1`. Expected: PASS. |
| +- [ ] **Step 5: Walk** with `CI=1`, delete the `over:` records it now passes, commit, message `console: edge fold behind the request, one pipeline read, bounded Versions, no wasted telemetry or record reads`, ending with the Co-Authored-By line. |
| + |
| +### Task 4: Settings builds only the section shown |
| + |
| +Spec §2.4 C rows "Settings, `populateAppSettings`", "`appDeployEmpty`" and "`envCards` + `storeEnvCards`". |
| + |
| +**Files:** |
| +- Modify: `internal/console/server.go:3980-4041` (`handleAppSettings`, `populateAppSettings`), `:4043-4056` (`renderAppSettingsForm`) |
| +- Modify: `internal/console/appsettings.go:328-401` (`assembleSettings`), `:502-570` (`envCards`, `storeEnvCards`), `:751-762` (`appDeployEmpty`) |
| +- Test: `internal/console/appsettings_sections_test.go` (extend) |
| + |
| +**Interfaces:** |
| +- Produces: |
| + - `func (s *Server) assembleSettings(ctx context.Context, p *page, acct *Account, section string) *SettingsView` (new last parameter; the direct caller at `appsettings_test.go:1139` passes the section it asserts on). It always returns a non-nil view and sets `NoBucket` for every section, and builds only: |
| + |
| + | section | builds | |
| + |---|---| |
| + | general | `AppFlags`, `appDeployEmpty` (only when owner, not control plane and no routes), the mismatch target (`AccountBySqid`, `Role`), `telemetry.Resolve`, `loadSwapPolicy` | |
| + | domains | `settingsDomains` (claims, `aliasReadings`, `warmRecords`, catch-all views), `readyRouteHost`, `settingsGates` | |
| + | environments | `envCards` | |
| + | storage | `storeCard`, `storeEnvCards` | |
| + | features | `featuresCard` | |
| + | email | `mailCard` | |
| + | advanced | `AppFlags` | |
| + | delete | nothing beyond `appPage` | |
| + |
| + `StoreUnavailable`, `MailUnavailable` and `FeaturesUnavailable` (`appsettings.go:388-390`) are set only inside their own section's builder, so an unbuilt section never reads as unavailable. `populateAppSettings(r, p, acct)` passes `p.SettingsSection`; `telemetry.Resolve` and `loadSwapPolicy` move inside the general builder. Part 1 adds a Placement section and an "Errors and analytics" section and folds Advanced into General; whichever plan lands second moves the rows of this table to match (telemetry goes with Errors and analytics). |
| + - `appDeployEmpty` asks each prefix for one key: `release.PageLister.ListPage(ctx, prefix, "", 1)`, falling back to `List` when the store is not a `PageLister` or answers `errors.ErrUnsupported` or `hostops.ErrContract` (the claim boundary's answer for a store without it, `hostops/mutation_boundary.go:135`). The rename door's uses (`appsettings.go:860`, `:915`) get the same. |
| + - `envCards` and `storeEnvCards` share one read of each `stores/<env>.json`: `func (s *Server) storeRecords(ctx context.Context, sqid, app string) (map[string]*objstore.Record, error)` behind the request memo (`memoOnce` key `stores:<sqid>/<app>`). In strict mode the strict listing's records are reused instead of read again. |
| + |
| +- [ ] **Step 1: Write the failing tests:** |
| + - `TestSettingsGeneralReadsNoOtherSection`: seed an instance record, a store and an environment; `ResetKeys()`; GET `/apps/kass/settings`; no key in `Keys()` is under `apps/<sqid>/kass/instances/`, `status/boxes/`, `control/cert-warm/`, `stores/` or the config environments prefix. |
| + - `TestSettingsDomainsReadsNoEnvironments`: GET `/settings/domains`; no `stores/` or environments key; the gates table still renders. |
| + - `TestEveryUnbuiltSectionIsNotUnavailable`: for each of general, domains, environments, delete: the body has none of the storage, email or features "unavailable" texts. |
| + - `TestStoreRecordReadOncePerPage`: GET `/settings/storage` with one environment store; its `stores/<env>.json` key appears once in `Keys()`. |
| + - `TestAppDeployEmptyAsksForOneKey`: a test store with `ListPage` that records `limit`; `appDeployEmpty` calls it with limit 1 and never calls `List`; over a store without `ListPage` it falls back to `List` and answers the same. |
| + - Existing: `TestBucketlessSettingsSectionsExplainConfiguration` (`appsettings_sections_test.go:100`) still passes. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestSettings|TestEveryUnbuiltSection|TestStoreRecordReadOnce|TestAppDeployEmpty|TestBucketless|TestAppSettings' -count=1`. Expected: the new tests FAIL. |
| +- [ ] **Step 3: Implement.** |
| +- [ ] **Step 4: Run** Step 2's command and `go test ./internal/console/ -run 'TestAppRename|TestAppDomain|TestAppGate|TestStoreDestroy|TestAppSwap' -count=1`. Expected: PASS. |
| +- [ ] **Step 5: Walk** with `CI=1`, delete the settings `over:` records it now passes, commit, message `console: settings builds only the section shown; one-key emptiness check; store records read once`, ending with the Co-Authored-By line. |
| + |
| +### Task 5: No read twice inside one page |
| + |
| +**Files:** |
| +- Modify: `internal/console/instancepage.go:285-298`, `internal/console/apisystemupdate.go:269` (`systemBoxes`), `internal/console/apiinstances.go:540` (`loadRolloutJoin`), the geoip inventory reached from `updatesPage` (`apisystemgeoip.go:241`, `:252`) |
| +- Modify: `internal/console/server.go:3707-3720` (`appDefault` and the second `liveEdges`), `internal/console/regiondefault.go:34-41`, `internal/console/regioncandidates.go:203` (`liveEdges`), `:285` (`appPolicy`), `server.go:5250` (`instanceDomainFor`) |
| +- Test: `internal/console/perffixes_test.go` (extend) |
| + |
| +**Interfaces:** |
| +- Produces, all behind `memoOnce` so each read happens once per request: `func (s *Server) platformBoxes(ctx context.Context) ([]status.Box, error)` (memo key `boxes:platform`, used by `systemBoxes`, `loadRolloutJoin`, `geoipInventory`, `loadBoxJoin`, `aliasReadings`); `liveEdges` (memo key `edges`); `instanceDomainFor` and `appPolicy`'s instance-manifest read (memo key `instances-manifest:<sqid>/<app>`). Each keeps its strictness: where a caller needs the complete listing (`LoadBoxesComplete`), the memo holds the complete form and the lenient callers read it too. |
| + |
| +- [ ] **Step 1: Write the failing tests:** |
| + - `TestInstancePageLoadsBoxesOnce`: GET `/apps/kass/instances/kass.carlosapp.dev`; the `status/boxes/` listing appears once in `Keys()`. |
| + - `TestRunningTabReadsEdgesAndManifestOnce`: GET `/apps/kass/instances`; `control/edges/` listed at most once and `instances.json` read at most once. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestInstancePageLoadsBoxesOnce|TestRunningTabReadsEdgesAndManifestOnce' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement.** |
| +- [ ] **Step 4: Run** Step 2's command and `go test ./internal/console/ -run 'TestInstancePage|TestInstancesTab|TestRegion|TestBrowserUpdates|TestSystemUpdate' -count=1`. Expected: PASS. |
| +- [ ] **Step 5: Walk** with `CI=1`, delete records it now passes, commit, message `console: each remote read once per page`, ending with the Co-Authored-By line. |
| + |
| +### Task 6: The view cache |
| + |
| +**Files:** |
| +- Create: `internal/console/viewcache.go`; Test: `internal/console/viewcache_test.go` |
| +- Modify: `internal/console/server.go` (`Server.views *viewCache`, set in `NewServer` to `newViewCache(time.Now, viewCacheMax)`) |
| +- Modify: `internal/console/perfwalk_test.go` (`perfQuiesce = func(fx *consoleFixture) { fx.srv.views.quiesce() }`) |
| + |
| +**Interfaces:** |
| +- Produces: |
| + - `type viewKey struct { Acct, App, Part string }`: `Acct` is the account sqid, `""` for deployment-wide entries; `App` is `""` for account-wide entries; `Part` names the read and, for filtered reads, carries the normalized query (`logs?host=a&since=1h`). |
| + - `const (liveWindow = 30 * time.Second; writtenWindow = 5 * time.Minute; viewCacheMax = 4096)` and `var viewLoadTimeout = 15 * time.Second` (a var so a test can shorten it) |
| + - `type viewResult[T any] struct { Val T; At time.Time; Stale bool }` |
| + - `func newViewCache(now func() time.Time, max int) *viewCache` |
| + - `func viewPeek[T any](c *viewCache, key viewKey, window time.Duration, load func(context.Context) (T, error)) (viewResult[T], bool)`: never blocks. A valid entry returns `true`, with `Stale` when older than `window`, in which case a background refresh is started unless one is running for the key. A missing or invalidated entry returns `false` and starts a background load unless one is running. |
| + - `func viewWait[T any](ctx context.Context, c *viewCache, key viewKey, window time.Duration, load func(context.Context) (T, error)) (viewResult[T], error)`: a valid entry returns at once; otherwise joins the running load or starts one, and waits for it or for `ctx`. |
| + - `func (c *viewCache) invalidate(match func(viewKey) bool)`: marks matching entries invalid and bumps each one's generation. |
| + - `func (c *viewCache) reread(ctx context.Context, match func(viewKey) bool) int`: for every matching entry that has been loaded before, bumps its generation and re-runs its loader under `ctx`, all concurrently, waiting for all; a success replaces the value with `At = now`, a failure leaves the entry invalid. Returns how many failed. |
| + - `func (c *viewCache) quiesce()`: waits until no background load is running (tests). |
| + - `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). |
| + |
| +The rules the implementation must keep: |
| +- A load runs in its own goroutine on `context.WithTimeout(context.Background(), viewLoadTimeout)`, never on a request's context, so a closed tab does not cancel a load other viewers share and no span lands on a finished request. |
| +- Each entry stores its loader (as `func(context.Context) (any, error)`) so `reread` can run it, its value, `At`, a generation and a loading flag. A load stores its result only if the entry's generation is the one it started with; otherwise the result is dropped. |
| +- A load that fails leaves a previously valid value in place (the next view retries once the window has passed again) but never makes an invalid entry valid. |
| +- Over `max` entries, the least recently used entries that are not loading are dropped. |
| +- No goroutine outlives its load, and nothing runs on a timer. |
| + |
| +- [ ] **Step 1: Write the failing tests** (a controllable clock and loaders that count and block on channels): |
| + - `TestViewPeekMissStartsOneLoad`: two peeks on a miss both return `false`; the loader runs once; after `quiesce`, a peek returns the value, not stale. |
| + - `TestViewPeekStaleServesAndRefreshesOnce`: after `window` passes, three peeks return the old value with `Stale` and the loader runs once more. |
| + - `TestViewWaitJoinsTheRunningLoad`: a peek starts a blocked load; `viewWait` waits; releasing the loader returns its value to both, with one run. |
| + - `TestViewWaitHonoursItsContext`: a blocked loader and a 20 ms `ctx`: `viewWait` returns `ctx.Err()`. |
| + - `TestInvalidateMakesTheNextPeekAMiss`. |
| + - `TestLoadStartedBeforeAnInvalidateIsDiscarded`: a load starts and blocks, `invalidate` runs, the load finishes with value A: the entry stays invalid and the next peek returns `false`. |
| + - `TestRereadReplacesOnlyLoadedEntries`: two keys loaded, one never; `reread` runs two loaders; a failing loader leaves its entry invalid and the count is 1. |
| + - `TestHungLoadIsBoundedAndRetried`: with `viewLoadTimeout` overridden to 50 ms for the test, 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. |
| + - `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|TestInvalidate|TestLoadStarted|TestReread|TestHungLoad|TestAsOfText' -count=1 -race`. Expected: FAIL. |
| +- [ ] **Step 3: Implement**; add CPF-20 to CPF-25 to `consolePerfCopyBuilt`; set `perfQuiesce`. |
| +- [ ] **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 with view-triggered single-flight refresh`, ending with the Co-Authored-By line. |
| + |
| +### Task 7: Deferred parts |
| + |
| +**Files:** |
| +- Create: `internal/console/viewparts.go`; Test: `internal/console/viewparts_test.go` |
| +- Create: `internal/console/templates/parts.html` |
| +- Modify: `internal/console/server.go` (registrations beside `:1525`, `:1512`, `:1461`; `page` gains `Deferred string` and `AsOf time.Time`) |
| +- Modify: `internal/console/templates/layout.html` (the loader script partial, included once before `</body>`) |
| +- Modify: `internal/console/perfwalk_test.go` (`perfTargets` gains one target per registered part), `internal/console/testdata/perf-budgets.txt` (three `deferred: deferred part` records) |
| + |
| +**Interfaces:** |
| +- Consumes: `viewPeek`, `viewWait`, `asOfText`, approved CPF-26 to CPF-28. |
| +- Produces: |
| + - `type viewMode int; const (viewCached viewMode = iota; viewBlocking)` |
| + - `var errViewPending = errors.New("console: part not loaded yet")` |
| + - `func viewGet[T any](ctx context.Context, s *Server, p *page, mode viewMode, key viewKey, window time.Duration, load func(context.Context) (T, error)) (T, error)`: `viewCached` peeks and returns `errViewPending` on a miss; `viewBlocking` waits under `ctx`. A stale result sets `p.AsOf` to the oldest stale `At` seen on this page. |
| + - `type viewPart struct { Template string; Fill func(s *Server, r *http.Request, p *page, acct *Account, mode viewMode) error }` |
| + - `var appParts, accountParts, fleetParts map[string]viewPart` (empty in this task; Tasks 9 to 15 add entries) |
| + - routes `GET /a/{sqid}/apps/{app}/part/{part}` → `handleAppPart` (gate: `appPage`'s gates, no remote read), `GET /a/{sqid}/part/{part}` → `handleAccountPart` (gate: `account` and `accountPage`), `GET /fleet/part/{part}` → `handleFleetPart` (gate: `operatorOnly`). Each: run the gate first; an unknown part is `http.NotFound`; then `Fill(viewCached)` (starts every missing load at once, so independent reads run concurrently) and `Fill(viewBlocking)` under `r.Context()` bounded by `viewLoadTimeout`; render `Template` with `Cache-Control: no-store`; on error answer 503 with the `partfailed` partial (CPF-28). Query parameters pass through to `Fill` (filters, `host`, `section`, `period`). |
| + - `func (s *Server) renderView(w http.ResponseWriter, r *http.Request, p page, name, partURL string, fill error)`: `errViewPending` sets `p.Deferred = partURL` and renders `name` (whose body branch shows the placeholder); any other error is the screen's existing error handling; nil renders normally. |
| + - partials in `parts.html`: `deferred` (`<div class="deferred" data-part="{{.Deferred}}">` with CPF-26 and a `<noscript>` CPF-27), `asof` (CPF-20 in small text when `.AsOf` is set), `partfailed` (CPF-28), `partloader` (the inline script), and `part_text` (`{{template "asof" .}}<p>{{.Msg}}</p>`, the fragment the tests' probe part renders). |
| + - test-only: `func registerProbePart(t *testing.T, fx *consoleFixture, table map[string]viewPart, key viewKey, objectKey string)`: adds a part `probe` whose `Fill` reads `objectKey` from `s.cfg.Releases` through `viewGet` (`writtenWindow`) 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. No polling and no retry: a part is fetched once per page view. With JavaScript off the `<noscript>` text stands, and a reload is a warm view because the miss started the load. |
| + |
| +Every screen converted in Tasks 9 to 15 follows one shape: its template becomes `{{define "<name>"}}{{template "top" .}}…chrome (flash, appnav, banners)…{{if .Deferred}}{{template "deferred" .}}{{else}}{{template "<name>_body" .}}{{end}}{{template "bottom" .}}{{end}}` and `{{define "<name>_body"}}{{template "asof" .}}…the existing body…{{end}}`; its handler becomes the gate, `Fill(viewCached)`, `renderView`; its part entry reuses the same `Fill` and `<name>_body`. *(My call: on a miss the whole tab body is the deferred part, except the two live parts the spec names, which Tasks 11 and 13 make parts of their own. This keeps the change to each template at its first and last lines, which Part 1 is rewriting.)* |
| + |
| +- [ ] **Step 1: Write the failing tests** (the probe part stores `"one"` at `apps/<sqid>/kass/probe.json` in `fx.rel`): |
| + - `TestPartEndpointGatesLikeItsPage`: signed out → the same 302 to `/` the page gives; a signed-in non-member → 404 whose body equals the body of the same user's 404 for `/a/<sqid>/apps/kass`; an unknown part → 404; for all three, `perfLatency.Calls()` is unchanged. |
| + - `TestPartRendersTheValue`: Paul GETs `/apps/kass/part/probe`: 200, `one`, `Cache-Control: no-store`; a second GET makes zero S3 calls. |
| + - `TestPartFailureAnswers503WithCopy`: with `SetFail` matching `probe.json`, the part answers 503 and its body is CPF-28. |
| + - `TestDeferredPartialsCarryTheirCopy`: executing `deferred` with `page{Deferred: "/x"}` gives `data-part="/x"`, CPF-26 and CPF-27 inside `<noscript>`; `asof` with a zero `AsOf` gives nothing and with one three minutes old gives CPF-20 with CPF-23. |
| + - `TestAsOfShowsOnStaleData`: with the fixture's clock moved past `writtenWindow`, the part still answers `one` and now carries CPF-20. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestPartEndpoint|TestPartRenders|TestPartFailure|TestDeferredPartials|TestAsOfShows' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement**; add CPF-26 to CPF-28 to `consolePerfCopyBuilt`; add the three part routes to `perfTargets` (one target per key of each parts table, so later tasks' parts are walked without an edit) and record each route `deferred: deferred part`. The cache's clock is `newViewCache`'s `now`; `newPerfFixture` replaces `fx.srv.views.now` with a clock the test can move (`fx.clock`, a new `consoleFixture` field). Moving time is the only thing a test does to the cache directly. |
| +- [ ] **Step 4: Run** Step 2's command, `go test . -run TestConsolePerfCopy -count=1`, and the walk with `CI=1`. Expected: PASS. |
| +- [ ] **Step 5: Commit**, message `console: deferred parts: placeholder, fragment endpoints behind the page's own gate, loader script`, ending with the Co-Authored-By line. |
| + |
| +### Task 8: Writes re-read their scope before the redirect |
| + |
| +**Files:** |
| +- Create: `internal/console/viewwrite.go`; Test: `internal/console/viewwrite_test.go` |
| +- Modify: `internal/console/claim_routes.go:59-69` (`registerRoute`: non-GET, non-HEAD requests get the write target and the writer wrapper) |
| +- Modify: `internal/console/server.go:2420-2455` (`account`: on a non-GET request, after membership is proven, marks the target), `:3082-3099` (`operatorOnly`: marks a deployment write) |
| +- Modify: `internal/console/apicli.go:217` (`apiPrincipalAccountSaying`: marks the target after the account resolves) |
| + |
| +**Interfaces:** |
| +- Consumes: `viewCache.reread`, `viewCache.invalidate`, `registerProbePart`. |
| +- Produces: |
| + - `type viewWriteTarget struct { acct, app string; deployment, marked bool }` |
| + - `func withViewWriteTarget(ctx context.Context) (context.Context, *viewWriteTarget)` |
| + - `func markViewWrite(ctx context.Context, acctSqid string)`: the app is the request's `{app}` path value, read when the write completes; `func markDeploymentWrite(ctx context.Context)` |
| + - `type viewWriteWriter struct { http.ResponseWriter; … }` with `WriteHeader`, `Write`, `Flush`, `Hijack`, `Unwrap`. On the first `WriteHeader` (or a `Write` without one, as 200), when the target is marked: a status below 400 runs `s.views.reread` over the scope with `context.WithTimeout(context.WithoutCancel(r.Context()), viewLoadTimeout)`, then forwards; 400 and above runs `invalidate` over the scope and forwards. An unmarked target does nothing. |
| + - The scope: an app write re-reads `key.Acct == acct && key.App == app` and invalidates (no re-read) the account's app list (`{acct, "", "apps"}`); an account write (no `{app}`) re-reads `key.Acct == acct && key.App == ""` and invalidates every other entry of `acct`; a deployment write re-reads `key.Acct == ""`. |
| + |
| +Every browser write under `/a/{sqid}/…` already passes `account()` (directly or through `owner` or `accountApp`), and every CLI write under `/api/cli/…/{account}/…` passes `apiPrincipalAccountSaying`, so marking there covers promote, roll back, channel and canary edits, settings saves, placement moves, restarts, domain changes, pipeline saves, pending confirms, ship and the rest without touching each handler. A refused request is never marked, because the gate refuses before it marks. *(My call: one wrapper and three marking points instead of a call in each of about forty handlers, so a new write door is covered by construction. CLI writes re-read too, since the spec's rule is about console-mediated writes, whatever the door.)* |
| + |
| +- [ ] **Step 1: Write the failing tests** on `newPerfFixture` with the probe part (`appParts`, key `{fx.sqid, "kass", "probe"}`) warm at `one`, then `two` written straight into `fx.rel` (uncounted): |
| + - `TestAppWriteRereadsItsScope`: Paul POSTs a real app write door that succeeds for an owner (the app error level, `POST /a/<sqid>/apps/kass/errors/level`, with CSRF); during the POST `probe.json` is read; after the 303, `ResetKeys()`; GET the probe part: `two` with zero S3 calls. |
| + - `TestRereadFailureLeavesEntryInvalid`: `SetFail` matching `probe.json` for the POST only; after it, clear; the next probe GET reads `probe.json` (a miss, not the old value) and answers `two`. |
| + - `TestFailedWriteInvalidatesWithoutRereading`: a write door the handler refuses with a 4xx today (a malformed form value on the same door, or whichever app door answers 4xx for bad input; check the status first): `probe.json` is not read during the POST; the next probe GET reads it. |
| + - `TestNonMemberWriteMarksNothing`: a second signed-in user POSTs to the same door: 404; `probe.json` not read; Paul's next probe GET makes zero S3 calls and still answers `one`. |
| + - `TestCLIWriteRereadsItsScope`: the same through a CLI write door for the app with a CLI token (an existing `apicli` test shows how to mint one). |
| + - `TestWriteWrapperKeepsFlushAndHijack`: through the wrapper, `http.NewResponseController(w).Flush()` succeeds. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestAppWriteRereads|TestRereadFailure|TestFailedWrite|TestNonMemberWrite|TestCLIWriteRereads|TestWriteWrapper' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement** the target, the marking points and the wrapper. |
| +- [ ] **Step 4: Run** Step 2's command and the gate-order tests `go test ./internal/console/ -run 'NonMember|CSRF|StepUp|FreshAuth|TestEveryCLIDoorNamesItsRoles|TestAuthCLIFamily' -count=1`. Expected: PASS. |
| +- [ ] **Step 5: Commit**, message `console: writes re-read their scope inside the POST before the redirect; invalidate on failure`, ending with the Co-Authored-By line. |
| + |
| +### Task 9: App core through the cache: every app tab's shared reads |
| + |
| +Spec §2.4 C row `assembleChannels`: List plus one Get per channel, sequential, on every app tab. |
| + |
| +**Files:** |
| +- Modify: `internal/console/view.go:552-643` (`Assemble`) |
| +- Modify: `internal/console/server.go:3398-3441` (`appPage`), `:3467-3492` (`applyPipelineView`), `:3537-3579` (`handleApp`), `:3942-3975` (`handleAppActivity`), `internal/console/accountreview.go:93` (`handleAppAccountReview`) |
| +- Modify: `internal/console/templates/app_overview.html`, `app_activity.html`, `account_review.html` (the body wrap) |
| +- Test: `internal/console/viewscreens_test.go` (create) |
| + |
| +**Interfaces:** |
| +- Produces: |
| + - `type appCore struct { Channels []ChannelView; Production ProductionView; Pipeline *release.Pipeline; PipelineErr error }` and `func loadAppCore(ctx context.Context, s release.Store, pub ed25519.PublicKey, acct, app string, now time.Time) (appCore, error)` (`assembleChannels`, `assembleProduction`, `GetPipeline`, one after another under `ctx`). |
| + - `Assemble(ctx context.Context, regPath string, s release.Store, pub ed25519.PublicKey, acct string, apps []string, dns DNSTargets, core func(app string) (appCore, error)) ([]AppView, error)`: routes come from the registry as before; each app's channels, production and pipeline come from `core`. An error from `core` for any app is returned (callers map `errViewPending` to the placeholder). The production/channel post-processing at `:615-626` and the ladder rebuild move to after `core`. |
| + - `func storeCore(ctx context.Context, s release.Store, pub ed25519.PublicKey, acct string) func(app string) (appCore, error)`: `loadAppCore` with no cache, for callers that are not screens and for `view_test.go`'s existing `Assemble` calls. |
| + - `func (s *Server) appCoreView(ctx context.Context, p *page, mode viewMode, sqid, app string) (appCore, error)`: `viewGet` with key `{sqid, app, "core"}`, `writtenWindow`. |
| + - `appPage` keeps the gates and chrome and no longer assembles; `func (s *Server) fillAppDetail(r *http.Request, p *page, acct *Account, mode viewMode) error` does `Assemble` with `appCoreView`, the account review and `applyPipelineView` (now from the core, no read). |
| + - parts `overview`, `activity`, `account-review` in `appParts`; Overview's extra reads through `viewGet`: `Versions` (`{sqid, app, "versions"}`, `writtenWindow`), `appResourceMetrics` (`{"", "", "metrics"}`, `liveWindow`, loader `LoadMetrics`, filtered per app after), `loadBoxJoin` (`{"", "", "boxes"}`, `liveWindow`, loader `platformBoxes`'s read). SQLite reads (events, pending changes) stay direct. |
| + |
| +- [ ] **Step 1: Write the failing tests:** |
| + - `TestOverviewWarmMakesNoRemoteCalls`: view `/apps/kass` and quiesce twice; reset counts; GET: zero S3 and zero host calls, 200, shows `v1` on `stable`. |
| + - `TestOverviewColdArrivesWithAPlaceholder`: fresh fixture with latency on: the first GET's time to first byte is under 150 ms and the body has `data-part` for `overview`; the part endpoint then answers the body. |
| + - `TestSameAppNameInTwoAccountsNeverShares`: a second account owning an app `kass` with a different channel version; each member sees only their own version, warm. |
| + - `TestActivityAndAccountReviewWarmMakeNoCalls`. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestOverview|TestSameAppNameInTwoAccounts|TestActivityAndAccountReview' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement.** |
| +- [ ] **Step 4: Run** Step 2's command, `go test ./internal/console/ -run 'TestAssemble|TestAppPage|TestOverviewIsALadder|TestRecentActivity|TestActivityTab|TestAccountReview|TestAppTabBar' -count=1`, and the walk with `CI=1`. |
| +- [ ] **Step 5: Delete** the `over:` records for `GET /a/{sqid}/apps/{app}`, `GET /a/{sqid}/apps/{app}/activity` and `GET /a/{sqid}/apps/{app}/account-review`; walk with `CI=1` (PASS); commit, message `console: app core, Overview, Activity and account review read through the view cache`, ending with the Co-Authored-By line. |
| + |
| +### Task 10: Releases and Deployments |
| + |
| +**Files:** |
| +- Modify: `internal/console/server.go:3587-3664` (`handleAppReleases`, `attachHint`), `:5250` (`instanceDomainFor`) |
| +- Modify: `internal/console/templates/app_releases.html`, `app_deployments.html` (body wrap) |
| +- Test: `internal/console/viewscreens_test.go` (extend) |
| + |
| +**Interfaces:** |
| +- Produces: parts `releases` and `deployments`; reads through `viewGet`: `Versions` (the Overview's key), `release.ListTags` (`{sqid, app, "tags"}`, `writtenWindow`, `ctx` from the load, not `context.Background()`), `release.GetRetention` (`{sqid, app, "retention"}`, `writtenWindow`), `instanceDomainFor` (`{sqid, app, "instances-manifest"}`, `writtenWindow`). |
| + |
| +- [ ] **Step 1: Write the failing tests:** `TestReleasesWarmMakesNoRemoteCalls`, `TestDeploymentsWarmMakesNoRemoteCalls` (same shape as Task 9's); `TestPromoteShowsTheNewVersionOnTheNextView` (warm `/apps/kass/releases`; promote `v2` to `stable` through the browser form; 303; `ResetKeys()`; GET the redirect target: zero S3 calls and `v2` on `stable`); `TestPromoteDuringABackgroundRefreshShowsTheNewVersion` (warm; move the clock past `writtenWindow`; `Hold` the channel pointer's key, then a view starts a refresh that blocks there; promote (its own reads are not held: release the hold only after the POST's handler has written, using `OnPut`); the refresh then finishes with the pre-write pointer; the next GET shows `v2`, never `v1`); `TestCLIPromoteShowsInTheBrowser` (the same promote through the CLI door; the next browser GET shows `v2` with zero S3 calls). |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestReleasesWarm|TestDeploymentsWarm|TestPromoteShows|TestPromoteDuring|TestCLIPromoteShows' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement.** |
| +- [ ] **Step 4: Run** Step 2's command, `go test ./internal/console/ -run 'TestReleasesTab|TestReleaseSummary|TestFirstPromote|TestPromoteFlow|TestRollbackFlow|TestCanaryFlow|TestRetireCanary' -count=1`, and the walk with `CI=1`. |
| +- [ ] **Step 5: Delete** the `over:` records for `/releases` and `/deployments`; walk (PASS); commit, message `console: Releases and Deployments read through the view cache`, ending with the Co-Authored-By line. |
| + |
| +### Task 11: Running, the instance page and the app's self-report |
| + |
| +Spec §2.4 C row `instances.Report`: HTTP to the app host, 30 s cache, blocks up to 1.5 s on a miss; deferred part on a miss, cached readings otherwise. |
| + |
| +**Files:** |
| +- Modify: `internal/console/instances.go:52-117` (the fetcher keeps its client, scheme, timeout, host choice and size caps; its own cache map goes: the view cache holds reports now) |
| +- Modify: `internal/console/server.go:3670-3729` (`handleAppInstances`), `internal/console/instancepage.go:242-298` (`handleAppInstance`) |
| +- Modify: `internal/console/templates/app_instances.html`, `app_instance.html` (body wrap; the self-report section becomes its own part) |
| +- Test: `internal/console/viewscreens_test.go` (extend) |
| + |
| +**Interfaces:** |
| +- Produces: |
| + - parts `instances`, `instance` (reads `?host=`, checked 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 `server.go:3675`) through `viewGet` with `{sqid, app, "app-report"}`, `liveWindow`. On the Running tab a miss of the report alone renders the rest of the tab and a `deferred` placeholder for `instances-report` only (the spec names this part). |
| + - Reads through `viewGet`: `appResourceMetrics` (Task 9's key), `liveEdges` (`{"", "", "edges"}`, `liveWindow`), `platformBoxes` (Task 9's `boxes` key), the instance manifest (Task 10's key), the instance page's fleet boxes (`{sqid, "", "fleet-boxes:<fleet>"}`, `liveWindow`), `updatesPage`'s record and manifest (`{sqid, app, "updates:<host>"}`, `liveWindow`), the geoip inventory (`{"", "", "geoip-inventory"}`, `liveWindow`). Placement, region and registry reads are local and 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 existing rule at `instances.go:83-92`). |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestRunningWarm|TestInstancePageWarm|TestRunningTabNeverWaits|TestAppReportNeverWakes' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement.** |
| +- [ ] **Step 4: Run** Step 2's command, `go test ./internal/console/ -run 'TestInstancesTab|TestAppPageInstances|TestInstancesEmptyState|TestInstancePage|TestBrowserRestart|TestBrowserUpdates|TestInstanceReport' -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. |
| + |
| +### Task 12: Logs, Errors, Availability, Analytics |
| + |
| +**Files:** |
| +- Modify: `internal/console/server.go:3745-3827` (`handleAppLogs`), `internal/console/errorsview.go:228-290` (`serveErrorView`), `internal/console/analyticsview.go:384-420` (`handleAppAnalytics`) |
| +- Modify: `internal/console/templates/app_logs.html` (the existing script loads once at page load when the rows are pending), `app_errors.html`, `app_availability.html`, `app_analytics.html` (body wrap) |
| +- Test: `internal/console/viewscreens_test.go` (extend) |
| + |
| +**Interfaces:** |
| +- Produces: |
| + - `func normalizedViewQuery(q url.Values, keep ...string) string`: only the named parameters, sorted, empty ones dropped, each value trimmed and capped at 256 bytes; used in `Part` (`logs?…`, `errors?…`, `availability?…`, `analytics?…`). |
| + - Logs: the host picker (`ListRecordHosts`, `{sqid, app, "record-hosts"}`, `liveWindow`) and the first page of rows (`applog.ReadWindow`, `{sqid, app, "logs?" + normalized}`, `liveWindow`) through `viewGet`. On a miss of the rows the page 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. This is the Logs-tab pattern the spec points at, so the Logs rows need no new part. |
| + - parts `errors`, `availability`, `analytics`; reads through `viewGet`: `telemetry.Resolve` (`{sqid, app, "telemetry"}`, `writtenWindow`; the error-level and analytics-setting writes re-read it through Task 8), `apperr.ReadWindow` and the platform-stream `applog.ReadWindow` (`errors?…`, `availability?…`, `liveWindow`), `analytics.ReadRange` (`analytics?…`, `liveWindow`). |
| + |
| +- [ ] **Step 1: Write the failing tests:** `TestLogsWarmMakesNoRemoteCalls`, `TestLogsColdLoadsRowsThroughTheDataEndpoint` (the cold page has `data-load-now` and no rows; `/logs/data` then answers the rows), `TestErrorsAvailabilityAnalyticsWarmMakeNoCalls`, `TestFilteredKeysAreNormalized` (`?since=1h&host=a` and `?host=a&since=1h&junk=x` share one entry). |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestLogsWarm|TestLogsCold|TestErrorsAvailabilityAnalytics|TestFilteredKeys' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement.** |
| +- [ ] **Step 4: Run** Step 2's command, `go test ./internal/console/ -run 'TestAppLogs|TestAppErrors|TestAppAvailability|TestAppAnalytics|TestErrorLevel|TestAnalyticsSetting' -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`, ending with the Co-Authored-By line. |
| + |
| +### Task 13: Settings sections and the pipeline page |
| + |
| +Spec §2.4 C rows `settingsGates` (cache), `aliasReadings`/`LoadBoxes` (cache, or a deferred part on Domains). |
| + |
| +**Files:** |
| +- Modify: `internal/console/appsettings.go` (the section builders from Task 4), `internal/console/apidomains.go:1361-1420` (`aliasReadings`, `warmRecords`), `internal/console/server.go:3980-4056`, `internal/console/pipelinepage.go:216-231` |
| +- Modify: `internal/console/templates/app_settings.html`, `pipeline.html` (body wrap per section; the box readings become their own part) |
| +- Test: `internal/console/viewscreens_test.go` (extend) |
| + |
| +**Interfaces:** |
| +- Produces: parts `settings` (reads `?section=`, validated against `appSettingsSections`) and `domain-readings` (the box readings on Domains alone, deferred on a miss of the `boxes` entry while the rest of Domains renders). Reads through `viewGet`, all keyed `{sqid, app, …}` with `writtenWindow` unless marked live: `settingsGates`' records (`gates`), the claims listing (`claims`; `ClaimCache` stays underneath), `warmRecords` (`cert-warm`, live), catch-all views including their DNS TXT lookup (`catchall`), `appDeployEmpty` (`deploy-empty`), `envCards` (`envs`), `storeCard` and `storeEnvCards` (`store`), `mailCard` (`mail`), `featuresCard` (`features`), `telemetry.Resolve` (Task 12's key), `loadSwapPolicy` (`swap`); `aliasReadings` reads the shared `boxes` entry. The pipeline page reads the core's pipeline (Task 9). |
| + |
| +- [ ] **Step 1: Write the failing tests:** `TestEverySettingsSectionWarmMakesNoCalls` (one sub-test per key of `appSettingsSections`), `TestDomainsArrivesBeforeBoxReadings` (cold, `S3Delay` 25 ms and 50 boxes 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`. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestEverySettingsSection|TestDomainsArrives|TestDomainAttachShows|TestPipelineSaveShows' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement.** |
| +- [ ] **Step 4: Run** Step 2's command, `go test ./internal/console/ -run 'TestAppSettings|TestBucketless|TestDomain|TestAppGate|TestAppRateLimit|TestStoreDestroy|TestPipeline|TestAppSwap|TestControlPlane' -count=1`, and the walk with `CI=1`. |
| +- [ ] **Step 5: Delete** the `over:` records for the settings sections, `/settings` and `/pipeline`; walk (PASS); commit, message `console: settings sections and the pipeline page read through the view cache; box readings deferred on Domains`, ending with the Co-Authored-By line. |
| + |
| +### Task 14: Account pages |
| + |
| +**Files:** |
| +- Modify: `internal/console/server.go:3233-3270` (`handleAccountHome`), `:3301-3338` (`handleAccountSettings`), `:4403` (`handleNewAppForm`), `internal/console/accountfleet.go:82-210`, `internal/console/fleets.go:1061-1160`, `internal/console/ownership.go:188` (`handleTrash`), `internal/console/view.go:484` (`TrashedApps`), `internal/console/regionpicker.go:35` |
| +- Modify: the templates `apps.html` (account home), `account_settings.html`, `account_fleet.html`, `fleetdetail.html`, `trash.html`, `app_new.html` (body wrap) |
| +- 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 `core` entries, so the home page and the app tabs share them), `settings`, `fleet`, `fleets` (reads `?fleet=`, checked with `resolveOwnedFleet` as the page does), `trash`, `new-app`. Reads through `viewGet`: `fleet.json` (`{"", "", "fleet-json"}`, `liveWindow`), each owned fleet's boxes (Task 11's key), the store entitlement (`{sqid, "", "entitlement"}`, `writtenWindow`), the account telemetry (`{sqid, "", "telemetry"}`, `writtenWindow`), tombstones (`{sqid, "", "trash"}`, `writtenWindow`), the region picker's edges snapshot and boxes (the shared `edges` and `boxes` entries). Minting a first account (`server.go:2382`) is a write, unchanged. |
| + |
| +- [ ] **Step 1: Write the failing tests:** `TestAccountPagesWarmMakeNoRemoteCalls` (one sub-test each for `/a/{sqid}/`, `/settings`, `/fleet`, `/fleets/fleet-a`, `/trash`, `/apps/new`), `TestAccountHomeSharesAppCoreWithAppTabs` (view `/apps/kass` and quiesce; the account home then makes zero channel reads for `kass`), `TestNewAppAppearsOnHomeAfterCreate` (create `shop`; the redirect target lists it). |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestAccountPagesWarm|TestAccountHomeShares|TestNewAppAppears' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement.** |
| +- [ ] **Step 4: Run** Step 2's command, `go test ./internal/console/ -run 'TestEmptyStateWelcomesNewUser|TestCreateApp|TestAccountSettingsPage|TestAccountFleet|TestFleetPage|TestTrash|TestRegionPicker' -count=1`, and the walk with `CI=1`. |
| +- [ ] **Step 5: Delete** the account pages' `over:` records; walk (PASS); commit, message `console: account pages read through the view cache`, ending with the Co-Authored-By line. |
| + |
| +### Task 15: Operator pages |
| + |
| +**Files:** |
| +- Modify: `internal/console/server.go:3104-3200` (`handleFleet`, `handleFleetMetrics`, `handleEconomics`, `handleEconomicsAccounts`), `internal/console/storepage.go:131-210`, `internal/console/archpage.go:23-110` |
| +- Modify: the templates `fleet.html`, `store_approvals.html`, `metrics.html`, `economics.html`, `economics_accounts.html`, `architecture.html` (body wrap; the Console speed table from plan 1 is in-process and stays outside any part) |
| +- Test: `internal/console/viewscreens_test.go` (extend) |
| + |
| +**Interfaces:** |
| +- Produces: parts in `fleetParts`: `fleet`, `store`, `metrics`, `economics` and `economics-accounts` (both read `?period=`), `architecture`. Reads through `viewGet`, all deployment-wide (`Acct ""`) and `liveWindow` unless marked: `fleet.json` (Task 14's key), `HostRows` (the shared `boxes` entry), pending store applications (`store-pending`), the bucket count (`store-usage`), `LoadMetrics` (Task 9's `metrics` key; its own 60 s cache stays underneath), `LoadEconomics` (`economics:<period>`; its own cache stays underneath), the architecture inventory and scenario (`architecture`, `writtenWindow`). The store decision and economics save doors are deployment writes (Task 8 marks them in `operatorOnly`), so their redirect targets re-read. |
| + |
| +- [ ] **Step 1: Write the failing tests:** `TestOperatorPagesWarmMakeNoRemoteCalls` (one sub-test per page, Paul as operator), `TestFleetMetricsColdArrivesWithAPlaceholder` (cold metrics: the page answers within 150 ms with the Console speed table and a `data-part` for `metrics`), `TestStoreDecisionShowsOnRedirect`. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestOperatorPagesWarm|TestFleetMetricsCold|TestStoreDecisionShows' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement.** |
| +- [ ] **Step 4: Run** Step 2's command, `go test ./internal/console/ -run 'TestFleet|TestStoreApprovals|TestEconomics|TestArchitecture|TestArchPage' -count=1`, and the walk with `CI=1`. |
| +- [ ] **Step 5: Delete** the operator pages' `over:` records; walk (PASS); commit, message `console: operator pages read through the view cache`, ending with the Co-Authored-By line. |
| + |
| +### Task 16: The console DB: measure, then decide on a read pool |
| + |
| +Spec §2.4 C last row: `SetMaxOpenConns(1)` (`store.go:99`, `store_gate.go:1828`) makes request queries queue behind background passes; WAL plus a separate read pool is the likely fix; the builder decides whether it is needed once the rest has landed. |
| + |
| +**Files:** |
| +- Test: `internal/console/storereadpool_test.go` (create) |
| +- Modify only if Step 3 says so: `internal/console/store.go:42-130` (`Store.readDB`, `Open`, `Close`), the gate reads in `server.go` listed in plan 1 Task 5 |
| + |
| +**Interfaces:** |
| +- Produces (only if built): `Store.readDB *sql.DB` (nil under `OpenGated`) and `func (s *Store) reader() sqlHandle` (the read pool when set, else `s.db`). Opened in `Open` on the same path, read-only and `query_only`, `busy_timeout=5000`, `SetMaxOpenConns(4)`. Used only by `SessionAddress`, `AccountsFor`, `HasAppIn`, `IsOperator`, `LastAccount`, `Role`, `AccountByID`, `AppLife`, `Events`. Writes and every transaction stay on the single writer, which `NewServicePrincipal`'s count-then-insert relies on (`authstore.go:294-302`). |
| + |
| +- [ ] **Step 1: Measure.** Write `TestGateReadsUnderAConcurrentWriter`: a goroutine holds a write transaction on the console store for 200 ms (`fx.st` opened by the fixture) while Paul GETs `/apps/kass` warm; log the page's `db` span from `Server-Timing`. Run it locally. Read flagship's `db` spans and the Console speed table from plan 1 Task 12 and after Tasks 2 to 15 have rolled to dev. |
| +- [ ] **Step 2: Decide.** If the `db` span on app pages stays under 20 ms at p95 on dev and flagship and the queueing in Step 1 traces only to a writer that no background pass holds that long in practice, record "read pool not needed" with the numbers in the branch description, keep the test as a pin of today's behaviour (asserting nothing about time), and skip to Step 6. Otherwise build it (Steps 3 to 5). |
| +- [ ] **Step 3: Write the failing tests:** `TestReadPoolServesGateReadsDuringAWrite` (with a 200 ms write transaction held, `SessionAddress` and `AccountsFor` return within 50 ms and see every committed row), `TestReadPoolRefusesWrites` (an `Exec` of an `INSERT` through `reader()` fails), `TestGatedStoreHasNoReadPool` (`OpenGated` leaves `readDB` nil). |
| +- [ ] **Step 4: Implement**, then run Step 3's tests and the store's own census and claim SQL tests: `go test ./internal/console/ -run 'TestReadPool|TestGatedStore|Census|ClaimSQL|TestStore' -count=1`. Expected: PASS. |
| +- [ ] **Step 5: For the gated store**, open an amadan discussion (`amadan discuss new carlos/platform -title "Console read pool under CARLOS_HOST_CLAIM" -body -`) describing why a second armed pool needs its own design (the claim gate arms each connection, `store_gate.go:1791-1850`), instead of building it here. |
| +- [ ] **Step 6: Commit**, message `console: measure gate reads under a concurrent writer; <read pool for the ungated store | read pool not needed, with numbers>`, ending with the Co-Authored-By line. |
| + |
| +### Task 17: No `over:` records left; census; review; roll and check |
| + |
| +**Files:** |
| +- Modify: `internal/console/testdata/perf-budgets.txt` |
| +- Create (by the tool): the census overlay and `docs/superpowers/notes/census-proposal-console-perf-2.md` |
| + |
| +- [ ] **Step 1: The file holds no `over:` records.** `grep -c ' over:' internal/console/testdata/perf-budgets.txt` prints `0`. Any record left is a `skip:`, `deferred:` or `calls <n>:` line with a reason; a `calls` record names the call and why no cache can hold it. |
| +- [ ] **Step 2: The walk passes with `CI=1`** in under 10 s: `CI=1 go test ./internal/console/ -run TestConsoleScreensMeetTheBudget -count=1 -v`. Compare its printed per-screen S3 counts with plan 1's `over:` lines (plan 1's commit message or its walk output): every screen's warm count is now 0 or its recorded allowance, so net S3 requests per page view went down. Update the row in `.amadan/test-weights.tsv`. |
| +- [ ] **Step 3: Census card**, as plan 1 Task 11 Step 1 (`NAME=console-perf-2`), CLAIMS naming each changed unit: cached reads of the same keys, no read added; `internal/provision` gains `ListRecordHosts`, a listing the unit already made. Approval by a reviewer of the other model family, recorded on #280. |
| +- [ ] **Step 4: Local gate** (`gofmt -l .`, `go vet ./...`, `go build ./...`, both cross-compiles, `go test ./internal/console/ -run 'TestView|TestPart|TestWrite' -race -count=1`), push, describe, wait for CI, squash, re-run CI, merge with `-expect`. |
| +- [ ] **Step 5: Roll and check** (after merge; ask Paul before the flagship console): dev boxes, dev console, check, flagship boxes, flagship console. On flagship (spec §2.6): the four pages from spec "Why" show `Server-Timing: app` under 150 ms on a second view; a browser's time to first byte drops by about as much as `app` does; the first view of an app after the console restart arrives within 150 ms with placeholders; after a day, the Console speed table shows every screen's p95 under 150 ms. Check the S3 request line in Cost Explorer a week later against the week before. Post the numbers to the branch's amadan discussion. |
| + |
| +--- |
| + |
| +## Self-review |
| + |
| +- **Spec coverage.** §2.4 C, row by row: account manifest (Task 2), `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 15), read your own writes with re-read in the POST and invalidate on failure (Task 8; end to end on promote in Task 10), 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 (Task 7; Logs itself 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. |
| +- **Names used from plan 1:** `perf.SpanContext` (loads deliberately do not use it: they run off the request), `Server.PerfGroups` (Task 15 keeps the Console speed table outside the parts), `newPerfFixture`, `perfTargets`, `perfTarget`, `perfQuiesce`, `perfLatency` (`Calls`, `Enable`; this plan adds `Keys`, `ResetKeys`, `SetFail`, `OnPut`), `latencyStore`, `loadPerfBudgets`, `Assemble(ctx, …)` (Task 9 adds the `core` parameter), `Versions(ctx, …)`. |
diff --git a/docs/superpowers/plans/2026-10-25-console-ux-nav.md b/docs/superpowers/plans/2026-10-25-console-ux-nav.md| new file mode 100644 |
| index 000000000..d0bf9b8c8 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-10-25-console-ux-nav.md |
| @@ -0,0 +1,440 @@ |
| +# Console navigation and layout (Part 1) Implementation Plan |
| + |
| +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. |
| + |
| +**Goal:** One-level app tab bar, a single Releases page, a Running tab that names itself and has one tidy toolbar, a settings sidebar that holds Placement and "Errors and analytics", and the small consistency fixes of spec 1.6, all in the console's existing style. |
| + |
| +**Architecture:** Template and handler changes inside `internal/console`. Old URLs become gated 303 redirects through one helper (`appRedirect`) that runs the same session and membership gate as the page, so a non-member still gets the byte-identical 404. CSS stays inline in `templates/layout.html`; one new `.toolbar` rule replaces `form.listctl`, the `#logs-filter` stacked-label rules and the ad hoc `form.small` filter rows. Every new or changed string comes from one copy deck, reviewed by a Luna pass before any template changes. |
| + |
| +**Tech Stack:** Go 1.26, `html/template` (embedded `templates/*.html`), `net/http` mux patterns, the console test fixture (`newConsoleFixture`, `newBrowser`, `get`, `postForm`, `assertNonMember404` in `server_test.go`), headless Chromium for the visual check. |
| + |
| +**Spec:** `docs/superpowers/specs/2026-10-25-console-ux-perf-design.md`, Part 1 (sections 1.1 to 1.4 and 1.6). Section 1.5 is out of scope (see Global Constraints). Part 2 has its own plan. |
| + |
| +## Global Constraints |
| + |
| +- **Scope.** Spec 1.1, 1.2, 1.3, 1.4, 1.6 only. Section 1.5 (operator nav for `/fleet*`) is replaced by a separate Rastrillo redesign: do not plan or touch it. Do not restyle any `/fleet*` operator template or any economics template: `fleet.html`, `store_approvals.html`, `metrics.html`, `economics.html`, `economics_accounts.html`, `architecture.html`, `fleetdetail.html` stay byte-identical. That drops the store "Decline" button and the economics accounts toolbar from 1.6. The account pages `/a/{sqid}/fleet` and `/a/{sqid}/fleet/byo` are not operator pages; only `fleet_byo.html`'s one copy row (NAV-C16) changes there. |
| +- **Look.** The console's overall look stays the same. These are structure and consistency fixes using the existing variables (`--accent`, `--rule`, `--bad`, `--ink`, `--muted`, `--bg`, `--accent-soft`); new CSS uses only those, so dark mode keeps working. |
| +- **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. |
| +- **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.** Part 2's plan runs in parallel and edits `handleAppInstances`, `handleAppSettings`/`populateAppSettings` and `handleAppReleases`. Keep Part 1's edits to those functions to the lines this plan names, and put new logic in named helpers so the two branches merge cleanly. Do not touch `instances.Report`, `Versions`, `assembleChannels`, caching or timing. |
| +- **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. |
| +- **Commits.** One commit per task, on branch `console-ux-perf`. Every message ends with `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`. Never `git checkout -- <file>` in this worktree. Per Paul (2026-10-23), open one amadan task per plan task on the branch and advance it as the task closes. |
| +- **Scratch.** Under a directory made with `mktemp -d "$TMPDIR/…"`, removed by its exact path at the end. Never delete by pattern or glob. Nothing started (Chromium, test servers) outlives the task. |
| + |
| +## Review Focus |
| + |
| +1. **A form posted from a page loaded before the change** carries `back=deployments`. It must land on `/releases` (directly, not through a 404). Pinned in Task 3: `TestReleaseBackTabOnlyAcceptsLocalDestinations` maps `deployments` to `releases`. |
| +2. **A non-member or unknown account opening an old URL** (`/deployments`, `/pipeline`, `/settings/advanced`) must get the byte-identical 404, not a 303 that confirms the app exists. Pinned in Tasks 3 and 6 with `assertNonMember404` on each old URL. |
| +3. **The release listing fails** (bucket hiccup) on the merged page. Live now must still render with its Roll back and instance links; only the Versions part says it could not list. Pinned in Task 3: `TestReleasesLiveNowSurvivesListingFailure`. |
| +4. **A plain member opens Settings, Placement.** They must see where the app runs but get no Move form; on Running they no longer see Placement at all. Pinned in Task 5: `TestAppSettingsPlacementSection` (member half). |
| +5. **A filtered Running list** (`?health=Asleep` or a search): "All" must show the app's whole count, not the filtered count, and clicking it must clear only the health filter. Pinned in Task 4: `TestInstancePageAllCountIsUnfiltered` plus the `All <n>` assertion in `TestRunningTabHeadingAndToolbar`. |
| + |
| +--- |
| + |
| +## File Structure |
| + |
| +| File | Responsibility | Tasks | |
| +|---|---|---| |
| +| `docs/superpowers/plans/2026-10-25-console-ux-nav-copy.md` | The copy deck (create) | 1 | |
| +| `docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-UX-NAV.md` | Luna's brief (create) | 1 | |
| +| `docs/superpowers/plans/LUNA-COPY-REVIEW-CONSOLE-UX-NAV.md` | Luna's answer, unedited (create) | 1 | |
| +| `internal/console/approved_nav_copy_test.go` | Deck gate and `navCopyBuilt` (create) | 1, then each task adds ids | |
| +| `internal/console/appnav_test.go` | Tab bar tests and `appTabLabels`, `cssBlock` helpers (create) | 2, 4, 8 | |
| +| `internal/console/navsnapshot_test.go` | Opt-in HTML snapshots for the visual check (create) | 2 | |
| +| `internal/console/appredirect.go` | `appRedirect` gated 303 helper (create) | 3 | |
| +| `internal/console/templates/appnav.html` | Nine tabs; `lognav` deleted | 2 | |
| +| `internal/console/templates/app_releases.html` | The single Releases page | 3 | |
| +| `internal/console/templates/app_deployments.html` | Deleted | 3 | |
| +| `internal/console/deployments.go` | `deploymentsCopy`, `liveNowTargets`, `releaseBackTab`, `VersionsCapped` | 3 | |
| +| `internal/console/templates/app_instances.html`, `app_instance.html`, `account_review.html`, `fleet_byo.html` | Running heading, toolbar, leftovers | 4, 5 | |
| +| `internal/console/browserrestart.go`, `listquery.go` | `AppButton`, `AllCount` | 4 | |
| +| `internal/console/templates/layout.html` | `.toolbar`, `.btn-secondary`, `.sectionhead`, fold summaries, header wrap | 3, 4, 6, 8 | |
| +| `internal/console/templates/app_logs.html`, `app_errors.html`, `app_availability.html`, `app_analytics.html` | Toolbar, hint links | 6, 7 | |
| +| `internal/console/appsettings.go`, `server.go` (`handleAppSettings`, `setAppSettingsSection`), `fleets.go` (`handleAppPlace`), `controlplane.go`, `pipelinepage.go` | Settings sections and redirects | 5, 7 | |
| +| `internal/console/templates/app_settings.html` | Placement, Errors and analytics, Advanced folded | 5, 7 | |
| +| `internal/console/templates/apps.html`, `trash.html`, `newaccount.html`, `account_settings.html` | Page heads, danger style, settings rows | 8 | |
| + |
| +--- |
| + |
| +### Task 1: Copy deck, Luna review and the deck gate |
| + |
| +**Files:** |
| +- Create: `docs/superpowers/plans/2026-10-25-console-ux-nav-copy.md` |
| +- Create: `docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-UX-NAV.md` |
| +- Create: `docs/superpowers/plans/LUNA-COPY-REVIEW-CONSOLE-UX-NAV.md` (Luna's output) |
| +- Create: `internal/console/approved_nav_copy_test.go` |
| + |
| +**Interfaces:** |
| +- Produces: the deck, one Markdown table with columns `| id | where | old | new | checked by | status |`. `where` is a path relative to `internal/console/` plus a short location note in parentheses. `new` is `(removed)` for a string that goes. `checked by` is `gate` (a plain string the gate finds literally) or the name of the owning task's test. `status` is `pending`, then `approved` or `removed`. |
| +- Produces: `var navCopyBuilt = map[string]bool{}` in `approved_nav_copy_test.go`. Each later task adds the ids it applies. |
| +- Produces: `func parseNavCopyDeck(t *testing.T) []navCopyRow` with `type navCopyRow struct{ ID, Where, Old, New, CheckedBy, Status string }`. |
| + |
| +- [ ] **Step 1: Write the deck** with these rows (proposed text, before Luna). `<n>`, `<app>`, `<name>` are placeholders; HTML shown is the markup the string sits in. |
| + |
| +| id | where | old | new | checked by | |
| +|---|---|---|---|---| |
| +| NAV-C01 | deployments.go (`deploymentsCopy.Title`: tab label, Overview tile heading, every "Managed on" pointer) | Deployments / Release history | Releases | TestAppTabBarIsOneLevel | |
| +| NAV-C02 | templates/appnav.html (tab 5, was a Logs sub-tab) | Errors | Errors | TestAppTabBarIsOneLevel | |
| +| NAV-C03 | templates/appnav.html (tab 6, was a Logs sub-tab) | Availability | Availability | TestAppTabBarIsOneLevel | |
| +| NAV-C04 | templates/appnav.html (tab 7, was a Logs sub-tab) | Analytics | Analytics | TestAppTabBarIsOneLevel | |
| +| NAV-C10 | templates/app_instances.html (heading) | Instances | Running | TestRunningTabHeadingAndToolbar | |
| +| NAV-C11 | browserrestart.go (`AppButton`, Running heading row) | Restart | Restart app | gate | |
| +| NAV-C12 | templates/app_instances.html (health links) | All | All `<n>` | TestRunningTabHeadingAndToolbar | |
| +| NAV-C13 | templates/app_instance.html (back link) | Instances | Running | TestRunningLeftoversNameTheTab | |
| +| NAV-C14 | templates/account_review.html (banner link) | Instances | Running | TestRunningLeftoversNameTheTab | |
| +| NAV-C15 | templates/app_settings.html (General, Account, no-instances link) | Instances | Running | TestRunningLeftoversNameTheTab | |
| +| NAV-C16 | templates/fleet_byo.html ("Then") | The box appears on your fleet page within minutes — it self-reports on a heartbeat cadence, not instantly. From there, place an app on it with `carlos apps place` or from the app's Instances tab. | The box appears on your fleet page within minutes. It reports in on a heartbeat, so not instantly. From there, place an app on it with `carlos apps place`, or in the app's Settings under Placement. | TestRunningLeftoversNameTheTab | |
| +| NAV-C21 | templates/app_releases.html (callout heading) | (new) | What's next | gate | |
| +| NAV-C22 | templates/app_releases.html (section heading) | (new) | Live now | gate | |
| +| NAV-C23 | deployments.go (`Target`, Live now column) | Target version | Should run | TestReleasesPageOrder | |
| +| NAV-C24 | deployments.go (`Observed`, Live now column) | Observed versions | Running | TestReleasesPageOrder | |
| +| NAV-C25 | deployments.go (`NoTarget`) | No target published | Nothing published yet | gate | |
| +| NAV-C26 | deployments.go (`NoChannels`, Live now empty state) | Open Release history for the commands to publish your first version. | Nothing is live yet. Ship your first version with the commands under Versions. | gate | |
| +| NAV-C27 | deployments.go (`Instances`, link text in the Instances cell) | View instances | (removed: the count itself links to Running) | TestReleasesPageOrder | |
| +| NAV-C28 | templates/app_releases.html (under Live now; replaces the "Rolling back" section) | Puts the previous build back in front of everyone straight away — rollbacks skip the safety delay. You'll be asked to confirm, and told which build it lands on. | Roll back puts the previous build back straight away and skips the safety delay. You are asked to confirm first, and told which build it lands on. | gate | |
| +| NAV-C29 | templates/app_releases.html (section heading) | All versions (`<n>`) | Versions | TestReleasesTab | |
| +| NAV-C30 | templates/app_releases.html (under Versions, only when capped) | (new) | Showing the newest `<n>`. For older versions, run `carlos releases --app <app>`. | TestReleasesVersionsCapPointer | |
| +| NAV-C31 | templates/app_releases.html (fold) | Release pipeline — channels, test versions, and the promotion ladder | Channels and the promotion ladder | gate | |
| +| NAV-C32 | templates/app_releases.html (fold; was a heading, and part of "Test versions and rolling back") | Canaries | Canaries | TestReleasesPageOrder | |
| +| NAV-C33 | templates/app_releases.html (fold; was a heading) | Tags | Tags | TestReleasesPageOrder | |
| +| NAV-C34 | templates/app_releases.html (one-channel fold, and the "Rolling back" heading) | Test versions and rolling back / Rolling back | (removed) | TestOneChannelAppKeepsCanariesAndRollback | |
| +| NAV-C36 | templates/app_overview.html (safety delay, unreadable) | Safety delay: this app's setting can't be read right now, so the delay stays on. Repair it on the Release history tab. | Safety delay: this app's setting can't be read right now, so the delay stays on. Repair it on the Releases tab. | TestNoLinkPointsAtDeployments | |
| +| NAV-C37 | templates/app_overview.html (safety delay, on) | Safety delay: **on** — new versions wait before going live. Managed on Release history. | Safety delay: **on**. New versions wait before going live. Managed on Releases. | TestNoLinkPointsAtDeployments | |
| +| NAV-C38 | templates/app_overview.html (safety delay, off, with nudge) | Safety delay: off — new versions go live as soon as they're promoted. This app looks like it's serving real users — consider turning it on, on Release history. | Safety delay: off. New versions go live as soon as they're promoted. This app looks like it's serving real users. Consider turning it on, on Releases. | TestNoLinkPointsAtDeployments | |
| +| NAV-C39 | templates/app_settings.html (Delete, production note) | It is marked as production right now, which blocks deletion — turn the safety delay off on the Release history tab first. | It is marked as production right now, which blocks deletion. Turn the safety delay off on the Releases tab first. | TestNoLinkPointsAtDeployments | |
| +| NAV-C40 | server.go (`setAppSettingsSection`) | (new) | Placement | TestAppSettingsSectionRoutes | |
| +| NAV-C41 | server.go (`setAppSettingsSection`) | (new) | Errors and analytics | TestAppSettingsSectionRoutes | |
| +| NAV-C42 | server.go (`setAppSettingsSection`) | Advanced | (removed) | TestAppSettingsSectionRoutes | |
| +| NAV-C43 | templates/app_errors.html (help line) | The level is set on the Settings tab. | The level is set in `<a>`Settings, under Errors and analytics`</a>`. | TestTelemetryHintsLinkTheSection | |
| +| NAV-C44 | templates/app_analytics.html (analytics off) | Turn it on for this app or for the whole account on the `<a>`Settings`</a>` tab. | Turn it on for this app in `<a>`Settings, under Errors and analytics`</a>`, or for the whole account in the account's `<a>`Settings`</a>`. | TestTelemetryHintsLinkTheSection | |
| +| NAV-C50 | server.go (`appLogsCopy.Level` field, set in `handleAppLogs`; the Logs level label) | All levels (label repeating its own first option) | Level | TestLogsToolbar | |
| +| NAV-C60 | templates/apps.html (eyebrow) | (new) | Account · `<name>` | TestPageHeadsOnAccountPages | |
| +| NAV-C61 | templates/apps.html (h1 when the account has apps) | `<name>` | Apps | TestPageHeadsOnAccountPages | |
| +| NAV-C62 | templates/trash.html (eyebrow) | (new) | Account · `<name>` | TestPageHeadsOnAccountPages | |
| +| NAV-C63 | templates/newaccount.html (eyebrow) | (new) | Accounts | TestPageHeadsOnAccountPages | |
| +| NAV-C64 | templates/trash.html (row button) | Delete “`<app>`” permanently | Delete permanently | TestTrashDeleteSitsInItsRow | |
| +| NAV-C65 | templates/trash.html (heading) | Delete now | (removed; its paragraph stays, above the table) | TestTrashDeleteSitsInItsRow | |
| +| NAV-C66 | templates/newaccount.html (help paragraph) | Names are deliberately not unique — two accounts may both be called “blog”. Identity is the short id in the URL, so there is nothing to squat. You will be its first owner, and you can invite teammates from the account's page. | Names are deliberately not unique. Two accounts may both be called “blog”. Identity is the short id in the URL, so there is nothing to squat. You will be its first owner, and you can invite teammates from the account's Team page. | gate | |
| + |
| +Header text: what the deck is, the column rules above, that redirects carry no flash (none is added), and that strings moved unchanged (the Placement section's sentences, the Errors and Analytics settings blocks, the Control plane card, the canary and tag contents) are not rows. |
| + |
| +- [ ] **Step 2: Write the Luna brief** in the shape of `LUNA-COPY-BRIEF-ROOTFS.md`: Paul delegated the review; read the deck and the spec's Part 1; house rules (no em dashes, full stop and a new sentence; plain words; neutral names; keep placeholders, `<a>` boundaries and backticked commands exactly; do not change facts; NAV-C26 and NAV-C28 must not use the words "Promote", "edge" or "ladder", because one-channel apps hide that vocabulary; tab and section labels stay short nouns); flag anything not human text. Also ask one question: should the Logs filter keep visible labels beside each control (the plan's default) or stack them; answer in the flags list. Output: changes table `ID | current | new | why`, flags list, one count line. |
| + |
| +- [ ] **Step 3: Run the Luna pass.** Put the command in a script under a scratch dir and run it with the Bash sandbox disabled (codex writes under `~/.codex`): |
| + |
| +```bash |
| +codex exec -m gpt-5.6-luna -c model_reasoning_effort="medium" -s read-only \ |
| + -c 'sandbox_permissions=["disk-full-read-access"]' \ |
| + -C /home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-ux-perf \ |
| + -o docs/superpowers/plans/LUNA-COPY-REVIEW-CONSOLE-UX-NAV.md \ |
| + "Read docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-UX-NAV.md and follow it." </dev/null |
| +``` |
| + |
| +Expected: the review file exists with a changes table. Check the startup header does not say `reasoning effort: none`. |
| + |
| +- [ ] **Step 4: Apply Luna's changes** to the `new` column verbatim, set every row `approved` or `removed`, and add the line "Approved 2026-10-25 by delegation: Luna pass (LUNA-COPY-REVIEW-CONSOLE-UX-NAV.md)." Rows Luna flags as fact conflicts go to Paul before Task 2 starts; the rest of the plan waits only on those rows. |
| + |
| +- [ ] **Step 5: Write the gate test** `TestNavCopyDeckIsApprovedAndApplied` in `approved_nav_copy_test.go`: |
| + - `parseNavCopyDeck` reads `../../docs/superpowers/plans/2026-10-25-console-ux-nav-copy.md`; fails if fewer than 40 rows parse. |
| + - Every row's status is `approved` or `removed`; none is `pending`. |
| + - No `new` cell contains `—` (U+2014). |
| + - For each row with `CheckedBy == "gate"` and `navCopyBuilt[ID]`: the file named by the first token of `Where` contains `New` after collapsing runs of whitespace to one space in both. |
| + - For each row in `navCopyBuilt` whose `CheckedBy` is not `gate`: that test function exists in some `internal/console/*_test.go` file (scan the sources for `func <name>(`). |
| + |
| +- [ ] **Step 6: Run it.** `go test ./internal/console/ -run '^TestNavCopyDeckIsApprovedAndApplied$' -count=1`. Expected: PASS with `navCopyBuilt` empty. Then set one status cell to `pending` temporarily, confirm it FAILS, and set it back. |
| + |
| +- [ ] **Step 7: Commit** the deck, brief, review and test: `git commit -m "Console nav copy deck, Luna-reviewed, and its gate"` (message ends with the Co-Authored-By line). |
| + |
| +--- |
| + |
| +### Task 2: One-level app tab bar |
| + |
| +**Files:** |
| +- Modify: `internal/console/templates/appnav.html:13-30` (nine tabs; delete the `lognav` define) |
| +- Modify: `internal/console/templates/app_logs.html:5`, `app_errors.html:5`, `app_availability.html:5`, `app_analytics.html:5` (drop `{{template "lognav" .}}`) |
| +- Modify: `internal/console/templates/app_deployments.html:7-10`, `app_releases.html:5-8` (drop the Deployments sub-tab bars) |
| +- Modify: `internal/console/deployments.go:23-31` (`Title: "Releases"`, per NAV-C01; keep `History` for now, Task 3 removes it) |
| +- Create: `internal/console/appnav_test.go`, `internal/console/navsnapshot_test.go` |
| +- Modify: `internal/console/server_test.go:522` (`TestReleasesTab`), `internal/console/deployments_test.go:45` (both assert the old Deployments `aria-current`) |
| + |
| +**Interfaces:** |
| +- Produces: `func appTabLabels(t *testing.T, body string) (labels []string, current string)` in `appnav_test.go`. It cuts `<nav class="tabs" aria-label="App sections">` to the next `</nav>` and returns each `<a>`'s text in order plus the one carrying `aria-current="page"` (fails the test on zero or two). |
| +- Produces: `TestNavSnapshots`, skipped unless `CONSOLE_SNAPSHOT_DIR` is set. It signs in on `newConsoleFixture`, adds route `web-1.example.com` (`App: "kass", Account: fx.sqid, Kind: "instance", Status: "ready"`), and writes the body of each GET to `$CONSOLE_SNAPSHOT_DIR/<name>.html`: `overview` `/apps/kass`, `running` `/apps/kass/instances`, `releases` `/apps/kass/releases`, `logs`, `errors`, `availability`, `analytics`, `activity`, `settings` `/apps/kass/settings`, `placement` `/apps/kass/settings/placement`, `apps` `/`, `trash` `/trash`, `account-settings` `/settings`. A non-200 page is written anyway. |
| +- Tab `ActiveTab` keys (unchanged, set by `appPage`): `overview`, `instances`, `releases`, `logs`, `errors`, `availability`, `analytics`, `activity`, `settings`. Releases tab href is `{{.Nav}}/apps/{{.AppName}}/releases`. |
| + |
| +- [ ] **Step 1: Write the failing test** `TestAppTabBarIsOneLevel` in `appnav_test.go` (fixture `newConsoleFixture`, `signInPaul`): |
| + |
| +```go |
| +want := []string{"Overview", "Running", "Releases", "Logs", "Errors", "Availability", "Analytics", "Activity", "Settings"} |
| +for path, current := range map[string]string{ |
| + "/apps/kass": "Overview", "/apps/kass/instances": "Running", "/apps/kass/releases": "Releases", |
| + "/apps/kass/logs": "Logs", "/apps/kass/errors": "Errors", "/apps/kass/availability": "Availability", |
| + "/apps/kass/analytics": "Analytics", "/apps/kass/activity": "Activity", |
| + "/apps/kass/settings": "Settings", "/apps/kass/settings/domains": "Settings", |
| +} { |
| + status, _, body := get(t, c, fx.u(path)) |
| + // status == 200 |
| + labels, cur := appTabLabels(t, body) |
| + // reflect.DeepEqual(labels, want); cur == current |
| + // strings.Count(body, `class="tabs"`) == 1 (no sub-tab bar) |
| + // !strings.Contains(body, `aria-label="Logs"`) |
| + // strings.Contains(body, `href="`+fx.path("/apps/kass/releases")+`" `) // the Releases tab |
| +} |
| +``` |
| + |
| +- [ ] **Step 2: Run it.** `go test ./internal/console/ -run '^TestAppTabBarIsOneLevel$' -count=1`. Expected: FAIL, labels are the six-tab list. |
| +- [ ] **Step 3: Implement.** Rewrite the `tabs` nav in `appnav.html` to nine `<a>` elements, one `eq .ActiveTab` per tab, Releases linking `/releases`. Delete `{{define "lognav"}}` and every `{{template "lognav" .}}`. Delete both `<nav class="tabs" aria-label="{{.DeploymentsCopy.Title}}">` blocks. Set `deploymentsCopy.Title` to the approved NAV-C01 text. |
| +- [ ] **Step 4: Update the two old assertions:** `server_test.go:522` and `deployments_test.go:45` now look for `/apps/kass/releases" aria-current="page">` on `/releases`; on `/deployments` drop the `aria-current` expectation (Task 3 turns that URL into a redirect). |
| +- [ ] **Step 5: Write `TestNavSnapshots`** per the Interfaces block. Add NAV-C01 to C04 to `navCopyBuilt`. |
| +- [ ] **Step 6: Run** `go test ./internal/console/ -run 'TestAppTabBarIsOneLevel|TestReleasesTab|TestDeploymentRoutesAndHistory|TestNavCopyDeck|TestNavSnapshots' -count=1`. Expected: PASS (snapshots SKIP). |
| +- [ ] **Step 7: Visual check, tab bar.** |
| + |
| +```bash |
| +SNAP=$(mktemp -d "$TMPDIR/console-nav-snap.XXXXXX") |
| +CONSOLE_SNAPSHOT_DIR="$SNAP" go test ./internal/console/ -run '^TestNavSnapshots$' -count=1 |
| +for p in overview logs; do for w in 1280 390; do |
| + chromium --headless=new --no-sandbox --disable-gpu --hide-scrollbars \ |
| + --user-data-dir="$SNAP/profile" --window-size=$w,900 \ |
| + --screenshot="$SNAP/$p-$w.png" "file://$SNAP/$p.html" |
| +done; done |
| +``` |
| + |
| +Open each PNG with the Read tool. Pass: nine tabs in order with Overview (or Logs) underlined; no second tab row on Logs; at 390 px the tab bar wraps onto two or three lines with nothing cut off. Leave `$SNAP` for later tasks' checks or remove it with `rm -r -- "$SNAP"`. |
| +- [ ] **Step 8: Commit** `appnav.html`, the four tab templates, both deployment templates, `deployments.go`, the tests: `git commit -m "Console: one-level app tab bar with Errors, Availability and Analytics as tabs"`. |
| + |
| +--- |
| + |
| +### Task 3: Releases as one page; /deployments redirects |
| + |
| +**Files:** |
| +- Create: `internal/console/appredirect.go` |
| +- Modify: `internal/console/server.go:1527` (register `s.appRedirect("/releases")` for `GET /a/{sqid}/apps/{app}/deployments`), `server.go:3587-3644` (`handleAppReleases`), `server.go:3965` (activity channel link to `/releases`) |
| +- Modify: `internal/console/deployments.go` (copy struct, `liveNowTargets`, `releaseBackTab`, `VersionsCapped`, `VersionsCap`) |
| +- Modify: `internal/console/templates/app_releases.html` (whole page body; `canaries`, `apptags` defines keep their contents; delete `solorollback`) |
| +- 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` |
| + |
| +**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. |
| +- Produces: `func liveNowTargets(view *AppView, targets []deploymentTarget) []deploymentTarget` in `deployments.go`. For `view.OneChannelPipeline()` it keeps only targets whose `Channel` is declared in `view.Pipeline.Channels`; otherwise it returns `targets` unchanged. |
| +- Produces: `func (p page) VersionsCapped() bool` (true when `len(p.Versions) >= versionsCap`) and `func (p page) VersionsCap() int`. |
| +- Changes: `deploymentsCopyStrings` becomes `struct{ Title, NoTarget, Target, Observed, NoChannels string }` (History and Instances removed). `releaseBackTab` returns `"releases"` for both `"releases"` and `"deployments"`. |
| +- Page shape (ids are the test's anchors), multi-channel app: |
| + 1. `{{with .ReleaseSummary}}{{if .NextVersion}}<section class="banner" id="whats-next">` with `<h2>` NAV-C21, `CandidateText`, and the existing Make-live form or owner note, unchanged. The old observed-deployment paragraphs (`StatusCopy.ObservedLabel` and friends) are dropped: Live now shows the same per channel. |
| + 2. `{{template "pending" .}}` |
| + 3. `<section id="live-now">` with `<h2>` NAV-C22, the old Deployments table over `liveNowTargets`: columns Channel, NAV-C23, NAV-C24, Instances (the count is `<a href="…/instances?channel=<ch>">{{.Total}}</a>`), and the row's Roll back form (condition and fields verbatim from `app_deployments.html:22-26`, with `back` = `releases`). Then NAV-C28 as `<p class="small">` when `.CanPromote` and Live now has rows. Empty state NAV-C26. |
| + 4. `<section id="versions">` with `<h2>` NAV-C29, the retention line, the versions table (no `<details>`), NAV-C30 when `.VersionsCapped`, or the existing "Nothing shipped yet" block. |
| + 5. `<details class="reveal" id="channels-ladder">` summary NAV-C31: `{{template "ladder" .}}`, `<h2>Channels</h2>` and the Channels table **without** its Roll back column (the empty `<th></th>` and the rollback `<td>` go), its two `small` notes. |
| + 6. `<details class="reveal" id="canaries"><summary>` wrapping the `canaries` template's `<h2>Canaries</h2>`; the rest of the template follows inside the details. |
| + 7. `{{if .Tags}}<details class="reveal" id="tags"><summary>` wrapping `apptags`' `<h2>Tags</h2>`. |
| +- One-channel app (`.Detail.OneChannelPipeline`): the same order, minus item 5; the Live now table has no Channel column; the one-channel hint paragraph links `/settings/pipeline`. |
| + |
| +- [ ] **Step 1: Write the failing tests** in `deployments_test.go`: |
| + - `TestReleasesPageOrder`: `newConsoleFixture`; `shipVersion(t, fx, "kass", "v3")`; `seedChannel(t, fx, "kass", "beta", "v3")`; `seedChannel(t, fx, "kass", "stable", "v2")`; publish and `release.EnsureTag` a `0.5.0-1` release as `server_test.go:2262-2278` does. GET `/apps/kass/releases` as Paul. Assert the indexes of `id="whats-next"`, `id="live-now"`, `id="versions"`, `id="channels-ladder"`, `id="canaries"`, `id="tags"` are all found and strictly increasing; `<details class="reveal" id="channels-ladder">`, `id="canaries">`, `id="tags">` appear without ` open`; the Live now section (from `id="live-now"` to `id="versions"`) contains the approved NAV-C23 and NAV-C24 headers and `href="`+fx.path("/apps/kass/instances?channel=stable")+`"`, and not the string `View instances`. |
| + - `TestReleasesPageHasOneRollBack`: same setup. `_, main, _ := strings.Cut(body, "<main>")`; `strings.Count(main, ">Roll back</button>") == 1` and that index lies between `id="live-now"` and `id="versions"`; `strings.Count(main, "/rollback\"") == 1`; that form carries `name="back" value="releases"`. |
| + - `TestDeploymentsRedirectsToReleases`: GET `/apps/kass/deployments` gives `303` and Location `fx.path("/apps/kass/releases")`; `assertNonMember404(t, fx, "/apps/kass/deployments")`. |
| + - `TestReleasesLiveNowSurvivesListingFailure` (replaces `TestDeploymentsDoNotDependOnReleaseListing`, which is deleted): `fx.srv.cfg.Releases = listFailStore{fx.rel}`; GET `/releases` is 200, contains "Could not list this app", `id="live-now"`, and `/apps/kass/instances?channel=stable`. |
| + - `TestReleasesVersionsCapPointer`: with the fixture's two versions the body lacks the NAV-C30 opening words; after `shipVersion` of `v10` through `v30` (21 more) it contains them and `carlos releases --app kass`. |
| + - `TestNoLinkPointsAtDeployments`: GET each of the nine tab URLs from Task 2's table; none contains `/deployments"`; `/apps/kass` contains the approved NAV-C01 text inside the Releases tile's `<h2>`. |
| + - `TestLiveNowTargetsHidesUndeclaredChannelsOnOneChannelApps` (unit): `AppView{Pipeline: &release.Pipeline{Channels: []release.PipelineChannel{{Name: "edge"}}}}` with targets `edge`, `canary/rc1` keeps only `edge`; a nil pipeline keeps both. |
| + - Update `TestReleaseBackTabOnlyAcceptsLocalDestinations`: want `"releases"` for both `"releases"` and `"deployments"`, `""` for the rest. |
| + - Rewrite `TestDeploymentRoutesAndHistory` to read `/releases` only: it contains `/apps/kass/releases#version-v1`, `/apps/kass/instances?channel=stable` and `id="version-v1"`. |
| +- [ ] **Step 2: Update existing assertions:** `TestReleasesTab`: `"All versions ("` becomes `<h2>` + NAV-C29 text + `</h2>`; keep `<h2>Channels</h2>`, `<h2>Canaries</h2>` and the `back=releases` count of 4. `TestOneChannelAppHidesChannelVocabulary`: `aria-label="Release status"` becomes `id="live-now"`. `TestOneChannelAppKeepsCanariesAndRollback`: add `strings.Count(main, ">Roll back</button>") == 1`. Claim tables: fixture reason `claimRead("redirects to the releases page")`; probe `claimRedirectRead("/a/bab/apps/kass/deployments", http.StatusSeeOther, "/a/bab/apps/kass/releases")`. |
| +- [ ] **Step 3: Run** `go test ./internal/console/ -run 'TestReleases|TestDeployment|TestNoLinkPointsAtDeployments|TestLiveNowTargets|TestReleaseBackTab|TestOneChannelApp|TestChannelsTableAndPipelineCardAgreeOnBakeWindow|TestReleaseSummaryStripRenders' -count=1`. Expected: the new tests FAIL. |
| +- [ ] **Step 4: Implement** per the Interfaces block. In `handleAppReleases` 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 command plus `go test ./internal/console/ -run 'TestAppTabBarIsOneLevel|TestNavCopyDeck|TestActivity|TestOverview' -count=1` and `nice -n 19 go test ./internal/console/ -run '^TestClaimConsoleMutationInvariant$' -count=1`. Expected: PASS. Add NAV-C21 to C39 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"`. |
| + |
| +--- |
| + |
| +### Task 4: Running heading, Restart app and the shared toolbar |
| + |
| +**Files:** |
| +- Modify: `internal/console/templates/app_instances.html:6-30` |
| +- Modify: `internal/console/browserrestart.go:15-31` (`AppButton`) |
| +- Modify: `internal/console/listquery.go:124-150` (`AllCount`) |
| +- Modify: `internal/console/templates/layout.html:56-58` (replace `form.listctl` with `.toolbar`; add `.btn-secondary`, `.sectionhead`) |
| +- Modify: `internal/console/templates/app_instance.html:5`, `account_review.html:7`, `app_settings.html:202`, `fleet_byo.html:75-77` (NAV-C13 to C16) |
| +- Test: `internal/console/appnav_test.go`, `listquery_test.go`, `server_test.go:1236,2114` |
| + |
| +**Interfaces:** |
| +- Produces: `BrowserRestartCopy.AppButton string`, approved NAV-C11. `Button` stays "Restart" for the per-instance button. |
| +- Produces: `instancePage.AllCount int`, the number of rows before any filter (`len(rows)` in `pageInstanceRows`). |
| +- Produces (Task 6 uses): CSS class `toolbar` on a `<form>`, with rules |
| + `.toolbar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0 0 0.6rem; }`, |
| + `.toolbar input, .toolbar select, .toolbar button { height: 2rem; margin: 0; }`, |
| + `.toolbar label { display: inline-flex; align-items: center; gap: 0.35rem; }`. |
| + Buttons in a toolbar carry `class="btn-sm"`. |
| +- Produces: `.btn-secondary { background: transparent; color: var(--accent); border: 1px solid var(--rule); }` with `:hover { background: var(--accent-soft); }`, and `.sectionhead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }` with `.sectionhead h2 { margin: 0; }`. |
| +- Produces: `func cssBlock(t *testing.T, body, selector string) string` in `appnav_test.go`: the declarations of the first rule in the page's `<style>` whose selector list equals `selector` exactly; fails if none. |
| +- Markup: `<div class="sectionhead"><h2>Running</h2>{{if .CanRestartApp}}<form … class="inline"><button type="submit" class="btn-sm btn-secondary">{{.BrowserRestartCopy.AppButton}}</button></form>{{end}}</div>`, then `<form method="get" class="toolbar">` holding, in order, the search input, the visually-hidden channel label and select, the checkbox label, `<button type="submit" class="btn-sm">Filter</button>`. Health links: `All {{.InstancePage.AllCount}}`. |
| + |
| +- [ ] **Step 1: Write the failing tests.** |
| + - `TestRunningTabHeadingAndToolbar` (`appnav_test.go`): `newConsoleFixture`; `fx.addRoute` of `web-1.example.com` and `web-2.example.com` (`App: "kass"`, `Account: fx.sqid`, `Kind: "instance"`, `Status: "ready"`). GET `/apps/kass/instances` as Paul. Assert: contains `<h2>Running</h2>`, not `<h2>Instances</h2>`; `class="btn-sm btn-secondary">` + NAV-C11 + `</button>` appears after `<div class="sectionhead">` and before `<form method="get" class="toolbar">`; the toolbar form (cut to its `</form>`) contains `type="search"`, `name="channel"`, `type="checkbox"`, and `<button type="submit" class="btn-sm">Filter</button>`; the health line contains `>All ` followed by the total route count for kass, read from the page's own row count (`strings.Count(body, `class="instance-address"`)`) on an unfiltered GET. |
| + - `TestToolbarStyle`: `cssBlock(t, body, ".toolbar")` contains `display: flex`, `align-items: center`, `flex-wrap: wrap`; `cssBlock(t, body, ".toolbar input, .toolbar select, .toolbar button")` contains `height: 2rem`; the body has no `form.listctl` rule. |
| + - `TestInstancePageAllCountIsUnfiltered` (`listquery_test.go`): three `InstanceRow`s with `HealthWord` `Serving`, `Asleep`, `Asleep`; `pageInstanceRows(rows, instanceQuery{Health: "Asleep"}, 50)` gives `AllCount == 3` and `Total == 2`; with `instanceQuery{Q: "nomatch"}` gives `AllCount == 3`, `Total == 0`. |
| + - `TestRunningLeftoversNameTheTab`: render `accountreviewbanner` through `templates.ExecuteTemplate` with `page{Nav: "/a/bab", AppName: "shop", AccountReview: AccountReview{NoInstances: true}}` and assert `/apps/shop/instances">` + NAV-C14 + `</a>`; GET `/a/<sqid>/fleet/byo` contains NAV-C16 (whitespace-normalised) and not `Instances tab`; after adding the `web-1.example.com` route as above, GET `/apps/kass/instances/web-1.example.com` contains `>` + NAV-C13 + `</a>`. |
| + - Update `server_test.go:1236` and `:2114` from `<h2>Instances</h2>` to `<h2>Running</h2>`. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestRunningTab|TestToolbarStyle|TestInstancePageAllCount|TestRunningLeftovers|TestAppInstances|TestInstancesTab|TestBrowser' -count=1`. Expected: new tests FAIL. |
| +- [ ] **Step 3: Implement** per Interfaces; apply NAV-C10 to C16 verbatim. The Placement section on this page is untouched here (Task 5 moves it). |
| +- [ ] **Step 4: Run** the Step 2 command plus `-run 'TestPageInstanceRows|TestNavCopyDeck|TestAppInstancesPlacement'`. Expected: PASS. Add NAV-C10 to C16 to `navCopyBuilt`. |
| +- [ ] **Step 5: Visual check.** Snapshot `running` at 1280 and 390. Pass: "Running" with "Restart app" at the right end of the same row, outlined, smaller than a primary button; search, select, checkbox and Filter on one line with equal heights and the checkbox text on the controls' centre line; at 390 px the toolbar wraps and Restart app drops under the heading without overflow. |
| +- [ ] **Step 6: Commit:** `git commit -m "Console: Running tab heading, Restart app and one toolbar row"`. |
| + |
| +--- |
| + |
| +### Task 5: Placement moves to Settings |
| + |
| +**Files:** |
| +- Modify: `internal/console/appsettings.go:56-66` (add `"placement"`) |
| +- 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` |
| + |
| +**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). |
| +- Settings section `placement`: `{{if eq .SettingsSection "placement"}}<h2>Placement</h2>` followed by the old block from `app_instances.html:62-79` verbatim (statement, owner-only Move form posting `{{.Base}}/apps/{{.AppName}}/place`, the data-does-not-move note, the could-not-read line). |
| +- `handleAppPlace`'s `back` redirects to `appSettingsURL(acct.Sqid, app, "placement")`. Its gate order and the `renderClaimAccepted` path are unchanged. |
| +- The region line (`id="app-region-line"`) stays on Running, directly under the toolbar block: it is about where new instances start. *(My call.)* |
| + |
| +- [ ] **Step 1: Rename and retarget the tests in `fleets_test.go`:** |
| + - `TestAppPlacePageMovesAndClears`: both `loc` checks want `fx.path("/apps/titogo/settings/placement")`; the flash GETs read that URL. |
| + - `TestAppInstancesPlacementSection` becomes `TestAppSettingsPlacementSection`: the owner and member GETs read `/apps/titogo/settings/placement` with the same `want` list and member assertions; add that the owner's `/apps/titogo/instances` contains neither `<h2>Placement</h2>` nor `fx.path("/apps/titogo/place")`. |
| + - `TestAppInstancesPlacementShowsFleet` becomes `TestAppSettingsPlacementShowsFleet` on `/settings/placement`. |
| +- [ ] **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 5: Commit:** `git commit -m "Console: Placement moves from Running to Settings"`. |
| + |
| +--- |
| + |
| +### Task 6: The toolbar on Logs, Errors, Availability and Analytics |
| + |
| +**Files:** |
| +- Modify: `internal/console/templates/app_logs.html:9-49`, `app_errors.html:9-35`, `app_availability.html:9-19`, `app_analytics.html:15-24` |
| +- Modify: `internal/console/server.go:2177` (`type appLogsCopy` gains `Level string`) and `server.go:3753-3757` (the literal in `handleAppLogs` sets it) |
| +- Modify: `internal/console/templates/layout.html:198-201` (delete the four `#logs-filter` rules; the toolbar rules cover it) |
| +- Test: `internal/console/appnav_test.go`, `apilogs_test.go:311` |
| + |
| +**Interfaces:** |
| +- Consumes: `.toolbar` from Task 4. |
| +- Produces: `appLogsCopy.Level string` (NAV-C50), used as the level `<label>` text; `AllLevels` stays as the first option. |
| +- Each of the four forms becomes `<form method="get" class="toolbar" …>` (Logs keeps `id="logs-filter"` and every `data-*` attribute); labels stay inline beside their control unless Luna's flags answer said stack them, in which case keep the `#logs-filter` rules and only add the class; every submit or button in these forms gets `class="btn-sm"` (Logs' Follow and Pause buttons too, keeping their ids and `hidden`). |
| + |
| +- [ ] **Step 1: Write the failing test** `TestLogsToolbar` in `appnav_test.go`: for `/apps/kass/logs`, `/errors`, `/availability`, `/analytics`, the body contains `class="toolbar"` on the filter form and no `<form method="get" class="small"`; every `<button` inside that form (cut to `</form>`) has `class="btn-sm"`. On Logs: `id="logs-filter"` and `data-url=` survive; the label text before `<select name="level">` is the approved NAV-C50, and `{{.LogCopy.AllLevels}}` appears once, as the first option. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestLogsToolbar|TestAppLogs|TestLogsPage|TestAppErrors|TestAppAvailability|TestAppAnalytics' -count=1`. Expected: `TestLogsToolbar` FAIL. |
| +- [ ] **Step 3: Implement** per Interfaces. Keep `apilogs_test.go:311`'s "All levels" check (the option still says it). |
| +- [ ] **Step 4: Run** the Step 2 command. Expected: PASS. Add NAV-C50 to `navCopyBuilt`. |
| +- [ ] **Step 5: Visual check.** Snapshot `logs` and `errors` at 1280 and 390. Pass: one line of equal-height controls at 1280; clean wrapping at 390; the log terminal still below. |
| +- [ ] **Step 6: Commit:** `git commit -m "Console: one toolbar pattern on Logs, Errors, Availability and Analytics"`. |
| + |
| +--- |
| + |
| +### Task 7: Settings sidebar, Errors and analytics, Advanced folded, /pipeline redirect |
| + |
| +**Files:** |
| +- Modify: `internal/console/appsettings.go:56-66` (sections map: add `"errors-analytics"`, remove `"advanced"`) |
| +- Modify: `internal/console/server.go:3980-4024` (`handleAppSettings`, `setAppSettingsSection`), `server.go:1561` (GET `/pipeline` registers `s.appRedirect("/settings/pipeline")`) |
| +- Modify: `internal/console/pipelinepage.go:213-222` (delete `handlePipelineSettings`; keep `handlePipelineSettingsPage` and the POST) |
| +- Modify: `internal/console/controlplane.go:81,223,280` (`"advanced"` becomes `"general"`) |
| +- 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` |
| + |
| +**Interfaces:** |
| +- Consumes: `appRedirect` (Task 3). |
| +- Sidebar order and keys: `general` General, `domains` Domains, `placement` Placement, `pipeline` Release pipeline, `environments` Environments, `storage` Storage, `email` Email, `features` Feature flags, `errors-analytics` NAV-C41, `delete` Delete. *(URL key `errors-analytics` is my call.)* |
| +- `handleAppSettings`: before `appPage`, `if r.PathValue("section") == "advanced" { s.appRedirect("/settings")(w, r); return }`. `populateAppSettings` is unchanged (it already resolves the telemetry the moved blocks read). |
| +- `appSettingsURL(acct, app, "general")` (already `/settings`) is where the control-plane refusal and both control-plane POSTs point. |
| + |
| +- [ ] **Step 1: Write the failing tests** in `appsettings_sections_test.go`: |
| + - Rewrite `TestAppSettingsSectionRoutes`: each of `general`, `domains`, `placement`, `environments`, `storage`, `email`, `features`, `errors-analytics`, `delete`, `pipeline` answers 200 on `/apps/titogo/settings/<s>`. From `<nav class="settings-nav"` to `</nav>` the link texts are exactly the ten labels in the order above; `Advanced` is absent. GET `/settings/advanced` gives 303 with Location `fx.path("/apps/titogo/settings")`; `assertNonMember404` on `/apps/titogo/settings/advanced` and `/apps/titogo/settings/domains`. |
| + - `TestErrorsAndAnalyticsSection`: owner GET `/settings` contains neither `/apps/titogo/errors/level"` nor `/apps/titogo/analytics/setting"`, and contains `/apps/titogo/control-plane/set"`; GET `/settings/errors-analytics` contains both form actions, `<h2>Errors</h2>` and `<h2>Analytics</h2>`. |
| + - `TestTelemetryHintsLinkTheSection`: `/apps/titogo/errors` contains `/apps/titogo/settings/errors-analytics"`; `/apps/titogo/analytics` (analytics off by default) contains the same href and the account settings href `/settings"` inside the NAV-C44 sentence. |
| + - `TestPipelineSettingsCanonicalSectionURL`: the legacy GET `/apps/titogo/pipeline` gives 303 with Location `fx.path("/apps/titogo/settings/pipeline")`; the POST half is unchanged; add `assertNonMember404(t, fx, "/apps/titogo/pipeline")`. |
| + - `controlplane_test.go`: every `/settings/advanced` expectation becomes the `/settings` URL. Where the test reads the refusal text, match `"/a/bab/apps/<app>/settings)"` (the message's closing parenthesis), so a leftover `/settings/advanced` fails; `loc` checks at 450 and 495 want `fx.path("/apps/titogo/settings")`; page reads at 346, 359, 442 GET `/settings`. |
| + - Claim tables: probe for `GET …/pipeline` becomes `claimRedirectRead("/a/bab/apps/titogo/pipeline", http.StatusSeeOther, "/a/bab/apps/titogo/settings/pipeline")`, fixture reason `claimRead("redirects to the pipeline settings section")`; the `settings/{section}` probe reads `/a/bab/apps/titogo/settings/general` for `/apps/titogo/control-plane/set`. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestAppSettings|TestErrorsAndAnalyticsSection|TestTelemetryHints|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"`. |
| + |
| +--- |
| + |
| +### Task 8: Page heads, danger buttons, account settings rows, help text |
| + |
| +**Files:** |
| +- Modify: `internal/console/templates/apps.html:78-100`, `trash.html`, `newaccount.html`, `account_settings.html:146,170,178,191,199,217-220` |
| +- Test: `internal/console/appnav_test.go`, `deletion_test.go` |
| + |
| +**Interfaces:** |
| +- Page head markup is the existing `.pagehead` (`<div class="pagehead"><p class="eyebrow">…</p><h1>…</h1>[<p class="lede">…</p>]</div>`), as `team.html` uses it. Apps: eyebrow NAV-C60, h1 NAV-C61 when there are apps; the empty state keeps "Welcome to …" as its h1 inside the same head. Trash: eyebrow NAV-C62, h1 "Trash". New account: eyebrow NAV-C63, h1 "New account", the existing lede moves inside. Flash banners stay above the head, as on app pages. |
| +- Trash rows: the last cell holds the Restore form, then (owners only) the delete form `class="settings-row"` with the visually-hidden label, the confirm input and `<button type="submit" class="btn-sm btn-danger">` NAV-C64. The "Delete now" paragraph sits above the table for owners; its h2 goes. |
| +- Account settings: the four `class="signin"` forms become `class="settings-row"`; their buttons get `btn-sm`; "Delete account" gets `btn-sm btn-danger`. |
| + |
| +- [ ] **Step 1: Write the failing tests:** |
| + - `TestPageHeadsOnAccountPages` (`appnav_test.go`): GET `/` (kass exists) has `<div class="pagehead">` before `<h1>` + NAV-C61 + `</h1>` and contains the NAV-C60 eyebrow with the account name; GET `/trash` (via `trashPageFixture`) has the pagehead before `<h1>Trash</h1>`; GET `fx.ts.URL+"/accounts/new"` has the pagehead, the NAV-C63 eyebrow, `<h1>New account</h1>` and NAV-C66 (whitespace-normalised). |
| + - `TestTrashDeleteSitsInItsRow` (`deletion_test.go`): owner GET `/trash`; the `<tr>` that contains `<td>kass</td>` (cut to `</tr>`) contains `/trash/restore"`, `/trash/delete"` and `class="btn-sm btn-danger">` + NAV-C64; the body has no `<h2>Delete now</h2>`. A plain member's trash page has no `/trash/delete"` (reuse the member setup from `deletion_test.go:320-335`). |
| + - `TestAccountSettingsFormsUseSettingsRow`: `fx.st.CreateAccount(42, "cdef", "shop", "paul@keymail.dev", time.Now())`; GET `/a/cdef/settings` as Paul; `_, main, _ := strings.Cut(body, "<main>")`; `main` has no `class="signin"`; contains `<form class="settings-row" method="post" action="/a/cdef/delete">` (match the attribute order the template ends up with) and `class="btn-sm btn-danger">Delete account</button>`. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestPageHeads|TestTrash|TestAccountSettings|TestCreateAppPage|TestNewAccount' -count=1`. Expected: new tests FAIL. |
| +- [ ] **Step 3: Implement** per Interfaces; apply NAV-C60 to C66 verbatim. |
| +- [ ] **Step 4: Run** the Step 2 command plus `-run 'TestDeletion|TestRestore|TestPurge|TestNavCopyDeck'`. Expected: PASS. Add NAV-C60 to C66 to `navCopyBuilt`. |
| +- [ ] **Step 5: Commit:** `git commit -m "Console: page heads, one danger style, settings rows on account settings"`. |
| + |
| +--- |
| + |
| +### Task 9: Header at 390 px, final visual pass and gate |
| + |
| +**Files:** |
| +- Modify: `internal/console/templates/layout.html:64-74` (`header`, `header nav`, `header .addr`) |
| +- Test: `internal/console/appnav_test.go` |
| + |
| +**Interfaces:** |
| +- CSS: `header { … flex-wrap: wrap; row-gap: 0.5rem; }`; `header nav { … flex-wrap: wrap; gap: 0.5rem 1rem; }`; `header .addr { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }` (keeps the full address in `title`). Declarations already on those rules stay. |
| + |
| +- [ ] **Step 1: Write the failing test** `TestHeaderWrapsOnNarrowScreens`: on any signed-in page, `cssBlock(t, body, "header")` and `cssBlock(t, body, "header nav")` both contain `flex-wrap: wrap`; `cssBlock(t, body, "header .addr")` contains `text-overflow: ellipsis`. |
| +- [ ] **Step 2: Run** `go test ./internal/console/ -run '^TestHeaderWrapsOnNarrowScreens$' -count=1`. Expected: FAIL. |
| +- [ ] **Step 3: Implement** the three rules. |
| +- [ ] **Step 4: Run** it. Expected: PASS. |
| +- [ ] **Step 5: Full visual pass.** Run Task 2 Step 7's commands for every snapshot name at 1280 and 390. Pass, at 390: the header wraps (switcher, then Apps · Fleet · Team · Settings, then the address and Sign out) with nothing past the right edge; the tab bar wraps; the Running toolbar, Logs toolbar and settings sidebar wrap or scroll as before. At 1280: no layout change from before this branch beyond the items this plan names. Then `rm -r -- "$SNAP"`. |
| +- [ ] **Step 6: Branch gate.** |
| + |
| +```bash |
| +gofmt -l internal/console # prints nothing |
| +go vet ./internal/console/ |
| +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' -count=1 |
| +nice -n 19 go test ./internal/console/ -run '^TestClaimConsoleMutationInvariant$' -count=1 |
| +``` |
| + |
| +Expected: all clean and PASS. Confirm `navCopyBuilt` holds every deck id. |
| +- [ ] **Step 7: Commit:** `git commit -m "Console: header wraps at 390 px"`. |
| + |
| +--- |
| + |
| +## 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). |
| +- **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 |
| + |
| +1. The region line ("New instances start in …") stays on Running; only the placement statement and Move form move. |
| +2. The fleet BYO guide points at Settings, Placement, not "Running", because the Move form now lives there. |
| +3. The folded Channels table loses its Roll back column, so Live now's is the only one ("only Roll back" outranks "contents unchanged"). |
| +4. The old observed-deployment summary paragraph on Releases is dropped; Live now shows the same facts per channel. |
| +5. One-channel apps: Live now hides the Channel column and undeclared channels (canaries), keeping the vocabulary rule. |
| +6. "Link to older versions" is a CLI pointer (`carlos releases --app <app>`): no console page lists more than 20, and adding one is outside Part 1. |
| +7. Pending changes render between What's next and Live now. |
| +8. Fold summaries wrap the existing `<h2>Canaries</h2>` and `<h2>Tags</h2>`, so the headings stay and are not repeated. |
| +9. The settings key for Errors and analytics is `errors-analytics`. |
| +10. Redirects are silent (no flash) and drop the query string. |
| +11. Availability gets the toolbar too, though the spec lists only Running, Logs, Errors and Analytics. |
| +12. Page heads cover Apps, Trash and New account; auth and interstitial pages (`message`, `check`, `picker`, `cli_approve`, `email_link`, `stepup_email`) are left alone. |
| +13. The "View instances" link text goes; the Instances count is the link. |
diff --git a/docs/superpowers/specs/2026-10-25-console-ux-perf-design.md b/docs/superpowers/specs/2026-10-25-console-ux-perf-design.md| index d38454da6..b005c5e88 100644 |
| --- a/docs/superpowers/specs/2026-10-25-console-ux-perf-design.md |
| +++ b/docs/superpowers/specs/2026-10-25-console-ux-perf-design.md |
| @@ -1,6 +1,6 @@ |
| # Console round: app navigation and a 150 ms page budget |
| -Status: design, awaiting Paul's approval. Branch `console-ux-perf`. |
| +Status: Parts 1 and 2 approved by Paul 2026-10-25 ("console users: stick to the plan"); Part 3 (operator /fleet on the Rastrillo design system) in design. Branch `console-ux-perf`. |
| ## Why |
| @@ -124,14 +124,12 @@ Storage · Email · Feature flags · Errors and analytics · Delete.** |
| - Each section is built on its own (see 2.4); opening General no longer |
| pays for Domains or Environments. |
| -### 1.5 Operator pages get a nav |
| +### 1.5 Operator pages: moved to Part 3 |
| -`/fleet`, `/fleet/store`, `/fleet/metrics`, `/fleet/economics`, |
| -`/fleet/economics/accounts`, `/fleet/architecture` share one tab bar: |
| -**Status · Storage requests · Metrics · Economics · Architecture** |
| -(labels go through copy review). Today metrics and economics are linked |
| -from nowhere. *(My call, from finding 5; Paul saw it in the findings but |
| -not as a mockup.)* |
| +The `/fleet*` operator pages are redesigned on the Rastrillo design system |
| +in Part 3 (Paul, 2026-10-25: "me as an operator looking at the /fleet |
| +screens: Rastrillo design system"), so they get no interim tab bar here |
| +and 1.6 doesn't touch them. The customer console keeps its current look. |
| ### 1.6 Consistency fixes |