regional box names: implementation plan (5 tasks)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+226
−0
docs/superpowers/plans/2026-10-25-regional-box-names.md+226 −0
CI passed — run details
diff --git a/docs/superpowers/plans/2026-10-25-regional-box-names.md b/docs/superpowers/plans/2026-10-25-regional-box-names.md| new file mode 100644 |
| index 000000000..5c9b0ddaa |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-10-25-regional-box-names.md |
| @@ -0,0 +1,226 @@ |
| +# Regional Box Display Names 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:** Every shared-fleet box whose operator sets `STATUS_NAME_REGION` publishes a `name-verb-region` display name (`seamus-minding-ie`), shown on the public status page and the console fleet page next to its unchanged identity label. |
| + |
| +**Architecture:** `internal/status` owns the themed word lists and a pure `DisplayName(label, region)`. The agent resolves the region code once in `statusLoop`, carries it on `status.Probes`, and `statusTick` stamps `Box.Name` after the label is final, so fleet and group overrides are already applied. `BuildFleet`, the console's `HostRow` and both pages read the new field, and fall back to the label when it's absent. |
| + |
| +**Tech Stack:** Go (stdlib `crypto/sha256`, `encoding/binary`), `html/template`, plain JS in the embedded status page. |
| + |
| +**Spec:** `docs/superpowers/specs/2026-10-25-regional-box-names-design.md` (rev 2, approved by Paul 2026-10-25). |
| + |
| +## Global Constraints |
| + |
| +- Nothing keyed on the name. Object keys, enrollment, roster, invitations, layout intents and feed `Box` fields keep using the identity label. Don't touch `status.Label`, `metricsBoxLabel`, `BoxLabel` or `groupBoxReference`. |
| +- With `STATUS_NAME_REGION` unset, the report and `fleet.json` are byte-identical to today's (`json:"name,omitempty"`). |
| +- Valid code: `^[a-z]{2,8}$` after `strings.TrimSpace`. Anything else is invalid. Don't lowercase it. |
| +- Hash input: `sha256("carlos-box-name/v1\x00" + label)`. Name index is `binary.BigEndian.Uint32(sum[0:4]) % 40`, verb index is `binary.BigEndian.Uint32(sum[4:8]) % 40`. |
| +- Shape: `names[i] + "-" + verbs[j] + "-" + code`. An unthemed code uses `labelNames` and `labelActions`. |
| +- Every list: exactly 40 entries, `^[a-z]+$`, no duplicates within a list. |
| +- Fleet boxes (`CARLOS_FLEET` set, valid or not) never publish a name. |
| +- Copy voice for every human-read string: no em dashes. Use a full stop and continue in lower case. Word lists, the log line and the README entry go through Task 1's copy pass before any code lands them. |
| +- Local tests: only touched packages, with `-run`. Never `make test`. CI does the full run. Build, `go vet`, `gofmt` and the darwin and windows cross-compiles run locally. |
| +- Commits are made as `claude <claude~paul@keymail.dev>`, and each one ends with `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`. Each plan task has its own amadan task on the branch, advanced as it closes. |
| + |
| +## Review Focus |
| + |
| +1. **A group box before its reference resolves.** `groupStatusTick` returns early, so no report is written and no name is ever derived from the hashed label. Pinned in Task 3 (`TestGroupBoxNameFollowsItsReference`). |
| +2. **A fleet box with `STATUS_NAME_REGION` set, including an invalid fleet identity.** No name, because those reports aren't the shared fleet's. Pinned in Task 3 (`TestResolveNameRegion`, fleet rows). |
| +3. **A host.env value with quotes stripped but whitespace left (`"ie "`, `"ie\n"`).** Trim, then accept. `"IE"` and `"Ireland"` are refused with one log line. Pinned in Task 3. |
| +4. **A mixed-release fleet.** New console reading an old report: shows the label alone, unchanged. Old reader reading a new report: ignores `name`. Pinned in Task 2 (`TestBuildFleetCopiesName`) and Task 4. |
| +5. **A name that collides with another box's name in the same region.** Purely cosmetic. Both rows still show their distinct labels, and nothing dedupes or sorts by name. Pinned in Task 4 (hosts stay sorted by `Label`). |
| + |
| +--- |
| + |
| +### Task 1: Copy pass on the word lists, log line and README entry |
| + |
| +No code. This gates Tasks 2-4, because they write these strings into files. |
| + |
| +**Files:** |
| +- Create: `docs/superpowers/specs/COPY-BRIEF-REGIONAL-BOX-NAMES.md` |
| +- Create: `docs/superpowers/specs/COPY-FINDINGS-REGIONAL-BOX-NAMES.md` (Luna's answer, committed unedited) |
| +- Modify: `docs/superpowers/specs/2026-10-25-regional-box-names-design.md` ("Starter word lists" becomes "Word lists", the approved set) |
| + |
| +**Interfaces:** |
| +- Produces: the approved ie, uk, us and au name and verb lists (40 each), the approved log line and the approved README entry. Tasks 2 and 3 copy them verbatim. |
| + |
| +- [ ] **Step 1: Write the brief.** It carries the spec's word-list rules and anti-goals (no caricature, typical names across ages, no tenant or team names, no famous people, au stays away from Aboriginal and Torres Strait Islander practices, local spelling). It also carries Paul's voice rules (no em dashes, continuations in lower case) and the two strings below. Ask for a key/new/why table plus flags, and for a replacement for any word that fails a rule, so each list stays at 40. |
| + |
| + Log line draft: |
| + `agent: STATUS_NAME_REGION=%q is not a region code (2 to 8 lowercase letters), so this box shows no display name` |
| + |
| + README entry draft (it goes after the `STATUS_BOX_REGION` entry): |
| + ``` |
| + - `STATUS_NAME_REGION`: a region code (2 to 8 lowercase letters, `ie`, |
| + `uk`) that gives this box a display name such as `seamus-minding-ie` |
| + on the status page and the console. The name is for people to read. |
| + Nothing is keyed on it, and the box's label is unchanged. The code is |
| + public once set. Unset shows the label alone, as before. Fleet boxes |
| + never get a display name. |
| + ``` |
| + |
| +- [ ] **Step 2: Run Luna.** Put the command in a script file and run it with the sandbox off: |
| + `codex exec -m gpt-5.6-luna -s read-only -c 'sandbox_permissions=["disk-full-read-access"]' -o docs/superpowers/specs/COPY-FINDINGS-REGIONAL-BOX-NAMES.md "<prompt naming the brief>" </dev/null`. |
| + Expected: a findings file with a table and a flags section. |
| + |
| +- [ ] **Step 3: Apply and check.** Apply every change, rewrite the spec's lists, then run the list-hygiene check (40 per list, `^[a-z]+$`, no duplicates within a list) over the spec with the same Python one-off used in revision 1. Expected: `40 dups set() bad []` for all eight lists. Anything Luna flags as a judgement call (as opposed to a rule breach) goes to Paul before Task 2. |
| + |
| +- [ ] **Step 4: Commit.** `git add docs/superpowers/specs && git commit -m "regional box names: copy pass on word lists, log line, README entry"` |
| + |
| +### Task 2: Display names in `internal/status` |
| + |
| +**Files:** |
| +- Create: `internal/status/displayname.go` |
| +- Create: `internal/status/displayname_test.go` |
| +- Modify: `internal/status/snapshot.go` (`Box`: add `Name`. `Probes`: add `NameRegion`) |
| +- Modify: `internal/status/fleet.go` (`FleetBox`: add `Name`. `BuildFleet`: copy it) |
| +- Modify: `internal/status/contract_test.go` (allowlists) |
| + |
| +**Interfaces:** |
| +- Consumes: Task 1's lists. |
| +- Produces: |
| + - `func ValidNameRegion(code string) bool`: true only for `^[a-z]{2,8}$`. No trimming here. |
| + - `func DisplayName(label, region string) string`: returns `""` if `!ValidNameRegion(region)` or `label == ""`. |
| + - `func nameIndexes(label string) (name, verb uint32)`: unexported, so the tests can pin the hash independently of the lists. |
| + - `Box.Name string` with `json:"name,omitempty"`. |
| + - `FleetBox.Name string` with `json:"name,omitempty"`. |
| + - `Probes.NameRegion string`, holding an already-validated code or `""`. Never serialized, and `CollectBox` ignores it. |
| + |
| +- [ ] **Step 1: Write the failing tests** in `internal/status/displayname_test.go` (package `status`, internal, so it can reach `nameIndexes` and the lists): |
| + |
| + ```go |
| + func TestNameIndexesGolden(t *testing.T) { |
| + for _, c := range []struct{ label string; n, v uint32 }{ |
| + {"dennis-stenciling", 21, 19}, |
| + {"ada-stargazing", 17, 16}, |
| + {"g-0123456789abcdef0123", 39, 12}, |
| + } { |
| + n, v := nameIndexes(c.label) |
| + if n != c.n || v != c.v { t.Errorf("%s: (%d,%d), want (%d,%d)", c.label, n, v, c.n, c.v) } |
| + } |
| + } |
| + ``` |
| + Those goldens were computed outside Go from the Global Constraints formula. |
| + |
| + Also write: |
| + - `TestDisplayNameThemed`: for each of `ie`, `uk`, `us`, `au`, `DisplayName("dennis-stenciling", code) == theme.names[21]+"-"+theme.verbs[19]+"-"+code`. Matches `^[a-z]+-[a-z]+-[a-z]{2,8}$`. Calling it twice gives the same answer. |
| + - `TestDisplayNameUnthemed`: `DisplayName("ada-stargazing", "de") == labelNames[17]+"-"+labelActions[16]+"-de"`. |
| + - `TestDisplayNameRefuses`: `""` for regions `""`, `"IE"`, `"u-k"`, `"i"`, `"abcdefghi"`, `"ie "`, and for label `""`. |
| + - `TestNameListsHygiene`: every theme's two lists, plus `labelNames` and `labelActions`. Each has `len == 40`, all entries match `^[a-z]+$`, and none repeat within a list. Also asserts the theme map has exactly the keys `ie`, `uk`, `us`, `au`. |
| + |
| +- [ ] **Step 2: Run the tests to verify they fail.** |
| + Run: `go test ./internal/status -run 'TestNameIndexesGolden|TestDisplayName|TestNameListsHygiene'` |
| + Expected: FAIL, undefined `nameIndexes`, `DisplayName`. |
| + |
| +- [ ] **Step 3: Implement `internal/status/displayname.go`.** Add `type nameTheme struct{ names, verbs [40]string }` and `var nameThemes = map[string]nameTheme{"ie": …, "uk": …, "us": …, "au": …}` holding Task 1's lists verbatim, plus `ValidNameRegion`, `nameIndexes` and `DisplayName` as specified. |
| + |
| + The doc comment says three things. It's a display name only, and nothing may key on it. It's derived from the identity label, which is already public, under a domain prefix so it doesn't echo `Label`'s own hash. Clashes within a region are cosmetic. Use `regexp.MustCompile` or a byte loop for validation, whichever matches the package's habits. |
| + |
| +- [ ] **Step 4: Run the tests to verify they pass.** Same command. Expected: PASS. |
| + |
| +- [ ] **Step 5: Write the failing schema tests.** |
| + - `contract_test.go`: add `"name"` to `allowedBoxKeys[""]` and `allowedFleetKeys["boxes[]"]`. Make sure the fixtures that `TestBoxSchemaAllowlisted` and `TestFleetSchemaAllowlisted` build set a name, so the key is actually exercised. |
| + - `TestBuildFleetCopiesName`: two snapshots in a `DirStore`, one with `Name: "seamus-minding-ie"` and one written without a name (the old shape). `BuildFleet` gives `FleetBox.Name` `"seamus-minding-ie"` and `""` respectively. The marshalled fleet has no `"name"` key for the second box. |
| + - `TestCollectBoxIgnoresNameRegion`: `CollectBox` with `Probes{MachineID: "m", NameRegion: "ie"}` gives `Name == ""`, because naming happens in the host after the label is final. |
| + |
| +- [ ] **Step 6: Run them to verify they fail.** |
| + Run: `go test ./internal/status -run 'Schema|TestBuildFleetCopiesName|TestCollectBoxIgnoresNameRegion'` |
| + Expected: FAIL on the missing fields. |
| + |
| +- [ ] **Step 7: Add the fields and the `BuildFleet` copy** (`Name: b.Name` beside `Label: b.Label`). |
| + |
| +- [ ] **Step 8: Run the package's touched tests, then the build checks.** |
| + `go test ./internal/status -run 'Name|Schema|Label|BuildFleet|CollectBox'`, then `go vet ./internal/status`, `gofmt -l internal/status`, `GOOS=darwin go build ./...`, `GOOS=windows go build ./...`. |
| + Expected: PASS and no output from gofmt. |
| + |
| +- [ ] **Step 9: Commit.** `git add internal/status && git commit -m "status: regional display names (DisplayName, Box.Name, FleetBox.Name)"` |
| + |
| +### Task 3: The agent stamps the name |
| + |
| +**Files:** |
| +- Modify: `internal/host/agent.go` (`statusLoop` near `boxRegion := os.Getenv("STATUS_BOX_REGION")` and the `status.Probes{… Region: boxRegion …}` literal. `statusTick` after the `labelOverride` block) |
| +- Create: `internal/host/displayname.go` (`resolveNameRegion`) |
| +- Create: `internal/host/displayname_test.go` |
| +- Modify: `README.md` (Task 1's approved entry, after `STATUS_BOX_REGION`) |
| + |
| +**Interfaces:** |
| +- Consumes: `status.ValidNameRegion`, `status.DisplayName`, `status.Probes.NameRegion`, `status.Box.Name` (Task 2). |
| +- Produces: `func resolveNameRegion(getenv func(string) string, logf func(string, ...any)) string`. |
| + - Returns `""` when the trimmed `STATUS_NAME_REGION` is empty. |
| + - Returns `""` when `CARLOS_FLEET` is set to anything non-blank, valid fleet or not, without logging, because a fleet box is simply out of scope. |
| + - Returns `""` and calls `logf` once with Task 1's approved line when the value is invalid. |
| + - Otherwise returns the trimmed code. |
| + |
| +- [ ] **Step 1: Write the failing tests** in `internal/host/displayname_test.go`: |
| + - `TestResolveNameRegion`, table-driven, asserting the return value and the `logf` call count: |
| + |
| + | env | want | logs | |
| + | --- | --- | --- | |
| + | unset | `""` | 0 | |
| + | `"ie"` | `"ie"` | 0 | |
| + | `"ie "` | `"ie"` | 0 | |
| + | `"ie\n"` | `"ie"` | 0 | |
| + | `"IE"` | `""` | 1 | |
| + | `"Ireland"` | `""` | 1 | |
| + | `"u-k"` | `""` | 1 | |
| + | `"ie"` + `CARLOS_FLEET=acme` | `""` | 0 | |
| + | `"ie"` + `CARLOS_FLEET="bad name!"` | `""` | 0 | |
| + |
| + - `TestStatusTickStampsTheName`: `registry.Open` on a temp dir and a `release.NewDirStore`, the same setup as `host_test.go`'s status-tick test. Run `statusTick(ctx, store, reg, status.Probes{MachineID: "test-machine", NameRegion: "ie"}, true, "")`. Read back `status/boxes/<status.Label("test-machine")>.json` and require `Name == status.DisplayName(status.Label("test-machine"), "ie")` and non-empty. Read `status/fleet.json` and require the same name on the box. |
| + - `TestStatusTickNoNameRegionIsUnchanged`: the same tick with `NameRegion: ""`. The raw JSON of the box object contains no `"name"`. |
| + - `TestGroupBoxNameFollowsItsReference`: stub the group identity seam the way `boxreference_test.go` does, so the reference resolves to `g-…`. Run `groupStatusTick(…, status.Probes{MachineID: "m", NameRegion: "uk"}, false, "", groupEnv(env))`. The published key is `status/boxes/<ref>.json`, its `Name == status.DisplayName(ref, "uk")`, and that differs from `status.DisplayName(status.Label("m"), "uk")`. With the seam failing, nothing is written. That's the existing behaviour, re-asserted with `NameRegion` set. |
| + |
| +- [ ] **Step 2: Run them to verify they fail.** |
| + Run: `go test ./internal/host -run 'TestResolveNameRegion|TestStatusTickStampsTheName|TestStatusTickNoNameRegionIsUnchanged|TestGroupBoxNameFollowsItsReference'` |
| + Expected: FAIL, undefined `resolveNameRegion`, and no name on the box. |
| + |
| +- [ ] **Step 3: Implement.** |
| + - Add `resolveNameRegion` in `internal/host/displayname.go`. |
| + - In `statusLoop`, call it once beside `boxRegion` with `os.Getenv, log.Printf`, and set `NameRegion` in the `status.Probes` literal. |
| + - In `statusTick`, right after `if labelOverride != "" { box.Label = labelOverride }`, add `if p.NameRegion != "" { box.Name = status.DisplayName(box.Label, p.NameRegion) }`. Extend `statusTick`'s doc comment by one sentence saying that the name is derived after the override, so it follows the published label. |
| + - Add the README entry. |
| + |
| +- [ ] **Step 4: Run the tests to verify they pass.** The same command plus the existing status-tick and group tests: `-run 'Name|StatusTick|GroupStatus|BoxReference'`. Expected: PASS. |
| + |
| +- [ ] **Step 5: Build checks.** `go vet ./internal/host`, `gofmt -l internal/host`, `GOOS=darwin go build ./...`, `GOOS=windows go build ./...`. Expected: clean. |
| + |
| +- [ ] **Step 6: Commit.** `git add internal/host README.md && git commit -m "agent: STATUS_NAME_REGION stamps a regional display name on the status report"` |
| + |
| +### Task 4: Show it on the status page and the console fleet page |
| + |
| +**Files:** |
| +- Modify: `internal/status/assets/index.html` (`renderBoxes`, the first `td`) |
| +- Modify: `internal/status/assets/status.css` (one class) |
| +- Modify: `internal/console/view.go` (`HostRow`: add `Name`. `HostRows`: copy `b.Name`. Sorting stays by `Label`) |
| +- Modify: `internal/console/templates/fleet.html` (the Boxes table cell at `{{.Label}}` and the Hosts table cell at `{{.Label}}`) |
| +- Test: `internal/status/status_test.go`, `internal/console/view_test.go`, and the console test that renders the operator fleet page |
| + |
| +**Interfaces:** |
| +- Consumes: `status.FleetBox.Name` and `status.Box.Name` (Task 2). |
| +- Produces: `HostRow.Name string`. |
| + |
| +- [ ] **Step 1: Write the failing tests.** |
| + - `TestStatusPageRendersNameAsText` (`internal/status/status_test.go`): the embedded `index.html` builds the box cell from `b.name` with `asText`, and shows `b.label` in an element with class `box-label`. Assert on substrings: `asText(b.name)`, `"box-label"`, `asText(b.label)`. Assert `innerHTML` doesn't appear in `renderBoxes`. And `status.css` defines `.box-label`. |
| + - `TestHostRowsCarryName` (`internal/console/view_test.go`): two snapshots, `zed-x` with name `aoife-herding-ie` and `abe-y` without one. `HostRows` returns them sorted `abe-y`, `zed-x` (by label, not name), with `Name` `""` and `"aoife-herding-ie"`. |
| + - The fleet-page render test: build the page through the same template set and handler path that the existing operator fleet page tests use (find them with `grep -n "<h2>Hosts</h2>\|Fleet.Boxes" internal/console/*_test.go`, or add one beside the nearest `handleFleet` test). With a named box, both tables show `aoife-herding-ie` followed by `<span class="small">zed-x</span>`. With an unnamed box, the cell is exactly `<td>abe-y</td>` as today. |
| + |
| +- [ ] **Step 2: Run them to verify they fail.** |
| + `go test ./internal/status -run TestStatusPageRendersNameAsText` and `go test ./internal/console -run 'TestHostRowsCarryName|<the fleet page test name>'`. Expected: FAIL. |
| + |
| +- [ ] **Step 3: Implement.** |
| + - **Status page:** if `b.name` is set, the cell holds `asText(b.name)`, then a `<span class="box-label">` (created with `document.createElement`) holding `asText(b.label)`. Otherwise the cell is `asText(b.label)`, exactly as today. `.box-label { display: block; color: var(--muted); font-size: 0.85em; }`. |
| + - **Console:** `{{if .Name}}{{.Name}} <span class="small">{{.Label}}</span>{{else}}{{.Label}}{{end}}`, in both tables. `.small` is the console's existing muted treatment (see the comment in `economics_accounts.html`). Don't invent a class. Copying `b.Name` into the Boxes table's rows needs nothing, because it already ranges over `status.FleetBox`. |
| + |
| +- [ ] **Step 4: Run the tests to verify they pass.** The same commands. Expected: PASS. |
| + |
| +- [ ] **Step 5: Check it by eye.** Render the status page locally from a `DirStore` holding a named and an unnamed box. Use the package's dry-run path (`internal/status/dryrun.go`), or serve the store's `status/` directory with `python3 -m http.server --bind 127.0.0.1` from `$TMPDIR`. Check in a browser that the name sits over a muted label and the unnamed row is unchanged. Stop the server afterwards. |
| + |
| +- [ ] **Step 6: Build checks and commit.** `go vet ./internal/status ./internal/console`, `gofmt -l`, and the cross-compiles. Then `git add internal/status internal/console && git commit -m "status page and console fleet page show the regional display name"` |
| + |
| +### Task 5: Whole-branch review and hand-off |
| + |
| +- [ ] **Step 1:** Merge `origin/main` into the branch, push, and wait for CI on the tip. If `TestPlan14RootReadCensus` fails, follow AGENTS.md "The census: an approval, not a decision". Expected: green. |
| +- [ ] **Step 2:** Astra whole-branch review from a committed brief (`docs/superpowers/specs/CODEX-REVIEW-BRIEF-REGIONAL-BOX-NAMES.md`), run with `codex exec -s read-only -c model_reasoning_effort="high" …`. The findings are committed unedited as `CODEX-FINDINGS-REGIONAL-BOX-NAMES-R2.md`. Fix every accepted finding with a test. |
| +- [ ] **Step 3:** Update the branch description and handoff. Leave the merge to Paul's call: `amadan branch merge carlos/platform design-regional-box-labels -squash -expect <tip>`, never without full args. |
| +- [ ] **Step 4 (follow-up, other repos, not this branch):** `carloku-infrastructure` `scripts/bootstrap-box.sh` gains a `STATUS_NAME_REGION` argument the way `STATUS_BOX_REGION` did: ie, uk, us, au on the flagship, plus the dev root in `platform-infrastructure`. That's a separate branch in each repo, after a platform release carries this change. |