carlos / platform Public

console perf: copy record and Luna pass for the Console speed table

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev aca05929687962c2b8e80b81b6eb2b6c1fc83d44 parent 2fb5639
4 files changed, +271 −0
  • approved_console_perf_copy_test.go +150 −0
  • docs/superpowers/plans/2026-10-25-console-perf-copy.md +58 −0
  • docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-PERF.md +55 −0
  • docs/superpowers/plans/LUNA-COPY-REVIEW-CONSOLE-PERF.md +8 −0
diff --git a/approved_console_perf_copy_test.go b/approved_console_perf_copy_test.go
new file mode 100644
index 000000000..1732bd2d3
--- /dev/null
+++ b/approved_console_perf_copy_test.go
@@ -0,0 +1,150 @@
+// approved_console_perf_copy_test.go
+package main
+
+import (
+ "os"
+ "regexp"
+ "strconv"
+ "strings"
+ "testing"
+)
+
+// The copy gate of the console perf plans (spec 2026-10-25, Part 2). The
+// record is docs/superpowers/plans/2026-10-25-console-perf-copy.md. It reuses
+// the moves gate's helpers (parseCopyTable, checkMovesInventory,
+// checkMovesNoEmDash, checkRunBuilt, checkRunApplied), exactly as the edge
+// asset cache gate does, so the parser, the em dash rule and the "text is in
+// the file" match are the record formats' already.
+//
+// - TestConsolePerfCopyInventory: the record names exactly
+// consolePerfCopyIDs, and no row holds an em dash;
+// - TestConsolePerfCopyBuiltRowsAreApprovedAndPresent: an id in
+// consolePerfCopyBuilt is an approved row, and its text is in the file it
+// names. No pending string reaches code or templates.
+const consolePerfCopyRecordPath = "docs/superpowers/plans/2026-10-25-console-perf-copy.md"
+
+var consolePerfCopyIDPattern = regexp.MustCompile(`^CPF-[0-9]+$`)
+
+// consolePerfCopyIDs is the record's inventory, pinned: CPF-1 to CPF-11 (plan
+// 1). Plan 2 adds its rows from CPF-20 and extends this list.
+var consolePerfCopyIDs = func() []string {
+ ids := make([]string, 0, 11)
+ for i := 1; i <= 11; i++ {
+ ids = append(ids, "CPF-"+strconv.Itoa(i))
+ }
+ return ids
+}()
+
+// consolePerfCopyBuilt is every row whose text the code or templates carry.
+// The task that writes a row's text adds its entry here in the same commit,
+// once the row is approved. An entry is "CPF-n", checked in the row's first
+// file, or "CPF-n@<path>", checked in that file. The record's file cell is
+// metadata and is never edited for this. Empty until the task that renders
+// the table.
+var consolePerfCopyBuilt = []string{}
+
+// consolePerfBuiltRows turns built entries into the rows to check: one per
+// entry, its file replaced by the entry's "@path" if it has one, and the
+// record's \n and \t (a cell holds one line) turned into the real characters.
+// It also reports an entry named twice, and (checkRunBuilt) an id with no row
+// or a row that is not approved.
+func consolePerfBuiltRows(rows []copyRow, entries []string) ([]copyRow, []string) {
+ byID := map[string]copyRow{}
+ for _, r := range rows {
+ byID[r.ID] = r
+ }
+ var out []copyRow
+ var problems []string
+ var ids []string
+ seenEntry, seenID := map[string]bool{}, map[string]bool{}
+ for _, e := range entries {
+ if seenEntry[e] {
+ problems = append(problems, "consolePerfCopyBuilt names "+e+" twice")
+ continue
+ }
+ seenEntry[e] = true
+ id, path, at := strings.Cut(e, "@")
+ if !seenID[id] {
+ seenID[id] = true
+ ids = append(ids, id)
+ }
+ r, ok := byID[id]
+ if !ok {
+ continue // checkRunBuilt reports it
+ }
+ if at {
+ r.File = path
+ }
+ r.Text = strings.ReplaceAll(r.Text, `\n`, "\n")
+ r.Text = strings.ReplaceAll(r.Text, `\t`, "\t")
+ out = append(out, r)
+ }
+ return out, append(problems, checkRunBuilt(rows, ids)...)
+}
+
+// checkConsolePerfBuilt is every problem with the built entries: not
+// approved, no row, named twice, or the text absent from the entry's file
+// under root.
+func checkConsolePerfBuilt(rows []copyRow, entries []string, root string) []string {
+ built, problems := consolePerfBuiltRows(rows, entries)
+ return append(problems, checkRunApplied(built, root)...)
+}
+
+func mustParseConsolePerfCopyRecord(t *testing.T) []copyRow {
+ t.Helper()
+ raw, err := os.ReadFile(consolePerfCopyRecordPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ rows, err := parseCopyTable(string(raw), consolePerfCopyRecordPath, consolePerfCopyIDPattern, "a CPF-<n>")
+ if err != nil {
+ t.Fatal(err)
+ }
+ return rows
+}
+
+func TestConsolePerfCopyInventory(t *testing.T) {
+ rows := mustParseConsolePerfCopyRecord(t)
+ reportAll(t, checkMovesInventory(rows, consolePerfCopyIDs))
+ reportAll(t, checkMovesNoEmDash(rows))
+}
+
+func TestConsolePerfCopyBuiltRowsAreApprovedAndPresent(t *testing.T) {
+ reportAll(t, checkConsolePerfBuilt(mustParseConsolePerfCopyRecord(t), consolePerfCopyBuilt, "."))
+}
+
+// The gate itself: a pending row, a missing row and a repeated entry are
+// refused, and an "@path" entry is checked in that file.
+func TestConsolePerfCopyGateRefusesWhatItShould(t *testing.T) {
+ dir := t.TempDir()
+ if err := os.WriteFile(dir+"/has.html", []byte("<h2>Console speed</h2>\n"), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ rows := []copyRow{
+ {ID: "T-1", File: "has.html", Text: "Console speed", Status: "approved"},
+ {ID: "T-2", File: "has.html", Text: "Something else", Status: "approved"},
+ {ID: "T-3", File: "has.html", Text: "Console speed", Status: "pending"},
+ }
+ cases := []struct {
+ name string
+ entries []string
+ want string // "" passes; else a substring of the one problem
+ }{
+ {"text in the file passes", []string{"T-1"}, ""},
+ {"text absent fails", []string{"T-2"}, "T-2:"},
+ {"a pending row", []string{"T-3"}, "T-3 is built but pending"},
+ {"an id with no row", []string{"T-9"}, "no row for"},
+ {"an entry named twice", []string{"T-1", "T-1"}, "twice"},
+ }
+ for _, c := range cases {
+ t.Run(c.name, func(t *testing.T) {
+ got := checkConsolePerfBuilt(rows, c.entries, dir)
+ switch {
+ case c.want == "" && len(got) != 0:
+ t.Errorf("problems = %q, want none", got)
+ case c.want != "" && (len(got) != 1 || !strings.Contains(got[0], c.want)):
+ t.Errorf("problems = %q, want one containing %q", got, c.want)
+ }
+ })
+ }
+}
diff --git a/docs/superpowers/plans/2026-10-25-console-perf-copy.md b/docs/superpowers/plans/2026-10-25-console-perf-copy.md
new file mode 100644
index 000000000..00a2965cc
--- /dev/null
+++ b/docs/superpowers/plans/2026-10-25-console-perf-copy.md
@@ -0,0 +1,58 @@
+# Console perf: copy record
+
+Every user-facing string plan 1 of the console perf work writes (spec
+`2026-10-25-console-ux-perf-design.md`, Part 2): the Console speed table on
+the operator-only metrics page and the S3 requests line. The gate is
+`approved_console_perf_copy_test.go` at the repo root. It reuses the moves
+gate's parser, so the format is the moves record's: one table per heading,
+columns id, file, text, status.
+
+The rules:
+
+- A row is `pending` until it is approved. For this record Paul delegated the
+ review to Luna (2026-10-25). Luna's text is applied here verbatim and the
+ row becomes `approved`, with the note "approved by delegation to Luna,
+ 2026-10-25". Rows Luna flags go to Paul.
+- No pending string reaches code or docs. The task that writes a row's text
+ adds its id to `consolePerfCopyBuilt` in the gate in the same commit, and
+ from then on the gate fails unless the row is `approved` and its text is in
+ the file it names.
+- In a Go file the text is one string literal, or one `fmt.Sprintf` format,
+ equal to the row with a format verb where the row has a `<placeholder>`. In
+ a template the text is in the file as written, with the placeholder
+ replaced by the template's own action.
+- A row names one file, the one the gate searches.
+- A table cell holds one line.
+- No em dashes. A full stop and a new sentence instead, continuing in lower
+ case.
+- Human text only. Log lines, route patterns, header names and JSON keys are
+ not copy and have no row.
+- Ids are not renumbered. Plan 2 adds rows from CPF-20.
+
+Luna's review is `LUNA-COPY-REVIEW-CONSOLE-PERF.md` (2 rows changed, none
+flagged, 9 left alone). Every row below is approved by delegation to Luna,
+2026-10-25.
+
+Placeholders: `<n>` a whole number. In CPF-9 it is a time in whole
+milliseconds.
+
+## Console speed table (plan 1)
+
+| id | file | text | status |
+|---|---|---|---|
+| CPF-1 | internal/console/templates/metrics.html | Console speed | approved |
+| CPF-2 | internal/console/templates/metrics.html | How long the console took to send the first byte of each page over its last 2,048 requests. Pages should answer within 150 ms. | approved |
+| CPF-3 | internal/console/templates/metrics.html | Route | approved |
+| CPF-4 | internal/console/templates/metrics.html | Requests | approved |
+| CPF-5 | internal/console/templates/metrics.html | Over 150 ms | approved |
+| CPF-6 | internal/console/templates/metrics.html | p50 | approved |
+| CPF-7 | internal/console/templates/metrics.html | p95 | approved |
+| CPF-8 | internal/console/templates/metrics.html | No requests measured since the console started. | approved |
+| CPF-9 | internal/console/perfspeed.go | <n> ms | approved |
+
+## S3 requests (plan 1)
+
+| id | file | text | status |
+|---|---|---|---|
+| CPF-10 | internal/console/templates/metrics.html | S3 requests | approved |
+| CPF-11 | internal/console/templates/metrics.html | The console has made <n> S3 requests that no page request caused since it started. | approved |
diff --git a/docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-PERF.md b/docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-PERF.md
new file mode 100644
index 000000000..5ad36eece
--- /dev/null
+++ b/docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-PERF.md
@@ -0,0 +1,55 @@
+# Copy review brief: the Console speed table (delegated by Paul, 2026-10-25)
+
+Paul delegated copy review for plan copy to you. You are the copy editor; your
+edits will be applied as approved copy.
+
+Read `docs/superpowers/plans/2026-10-25-console-perf-copy.md` (11 rows, ids
+CPF-1 to CPF-11). The draft text in each row is yours to change. The ids and
+files are fixed.
+
+## Where the strings appear
+
+The operator-only metrics page of the console (`metrics.html`). Only people who
+run the platform see it. They know what a first byte, a percentile and an S3
+request are, but the words should still be plain.
+
+- CPF-1 and CPF-2: the heading and the one-sentence explanation of a new
+ table placed under the existing box metrics. The table shows how fast the
+ console starts answering each page. 2,048 is the number of recent requests
+ the console remembers. 150 ms is the budget a page should meet.
+- CPF-3 to CPF-7: the column headings. Route is the page's name, Requests is
+ how many requests were measured, Over 150 ms is how many took longer than the
+ budget, p50 and p95 are the median and 95th percentile times.
+- CPF-8: shown instead of the table when nothing has been measured yet.
+- CPF-9: how one time in a cell is written, `<n> ms`. `<n>` is a whole number
+ of milliseconds.
+- CPF-10 and CPF-11: a separate line under the table. CPF-10 is its label.
+ CPF-11 is the sentence beside it. It counts S3 requests the console made
+ that no page request caused (background work), since the console started.
+ `<n>` is a whole number.
+
+## House rules (Paul's, all binding)
+
+- No em dashes, ever. Use a full stop and a new sentence, and keep the new
+ sentence lower case if the surrounding strings do that. Headings and labels
+ here are in sentence case with a capital first letter, as drafted. Keep that
+ style across the rows unless a row reads better otherwise.
+- Plain words. No jargon a reader would not know. Short.
+- Human text only. If a string is not human text (a log line, a route pattern,
+ a header name, a JSON key), flag it rather than edit it.
+- Neutral names only (shop, example.com). Never a tenant's name.
+- Keep every placeholder exactly (`<n>`).
+- Do not change meaning or the facts a string states (2,048 requests, 150 ms,
+ "since the console started"). If a fact looks wrong or conflicts with
+ another row, flag it, don't rewrite it.
+- Keep CPF-6 and CPF-7 as column headings readers can scan. If you change
+ them, say why.
+
+## Output
+
+Markdown, in this shape:
+
+1. A table of changes only: `id | current | new | why` (a few words in why).
+ Leave unchanged rows out.
+2. A list of flagged rows: `id | problem`.
+3. One line of counts: how many rows you changed, flagged and left alone.
diff --git a/docs/superpowers/plans/LUNA-COPY-REVIEW-CONSOLE-PERF.md b/docs/superpowers/plans/LUNA-COPY-REVIEW-CONSOLE-PERF.md
new file mode 100644
index 000000000..a8d582ab9
--- /dev/null
+++ b/docs/superpowers/plans/LUNA-COPY-REVIEW-CONSOLE-PERF.md
@@ -0,0 +1,8 @@
+| id | current | new | why |
+|---|---|---|---|
+| CPF-2 | 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. | How long the console took to send the first byte of each page over its last 2,048 requests. Pages should answer within 150 ms. | Smoother grammar |
+| CPF-11 | S3 requests made outside any page request since the console started: `<n>`. | The console has made `<n>` S3 requests that no page request caused since it started. | Complete, clearer sentence |
+
+Flagged rows: None.
+
+2 changed, 0 flagged, 9 left alone.
\ No newline at end of file