plan: CLI registry step 1 (words)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+213
−0
docs/superpowers/plans/2026-11-09-cli-registry-words.md+213 −0
CI cancelled — superseded by a newer push — run details
Intent
Attributed to this commit: 40.4 g CO₂e (4,379,243 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on cli-registry-words, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/superpowers/plans/2026-11-09-cli-registry-words.md b/docs/superpowers/plans/2026-11-09-cli-registry-words.md| new file mode 100644 |
| index 000000000..6eb2bb495 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-11-09-cli-registry-words.md |
| @@ -0,0 +1,213 @@ |
| +# CLI registry step 1 (words) 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 word the `carlos` binary dispatches on is a `clireg` node, `main()` dispatches from one tree, the parity guard covers every dispatched path, and every existing invocation behaves byte for byte as before. |
| + |
| +**Architecture:** A new stdlib-only package `internal/clireg` holds the node type, the walk (`Dispatch`) and `Validate`. Package main assembles the tree in `commands.go` from its own dispatchers and subtrees exported by `internal/host`, `internal/hostenv`, `internal/ops`, `internal/edge`, `internal/vet`, `internal/instanceexec`, `internal/dbreads` and `internal/cgroup`. Leaves wrap today's handlers unchanged (`clireg.RawArgs`); argument declarations come in steps 2-6. A golden corpus recorded from the merge base's binary and replayed against the branch is the compatibility gate. |
| + |
| +**Tech Stack:** Go standard library, existing test helpers (`platform.SharedCarlosForTest`), `internal/parity`, `internal/docsite`. |
| + |
| +**Spec:** `docs/superpowers/specs/2026-11-09-cli-registry-design.md` rev 5 (approved by Paul 2026-11-09). Evidence: `docs/superpowers/notes/2026-11-09-cli-dispatch-audit.md` (audit A and B, line numbers against fd68e4ee; re-check each against the tree before relying on it). |
| + |
| +## Global Constraints |
| + |
| +- Byte-for-byte: stdout, stderr and exit code of every invocation unchanged (spec Goals). No tightening in this step: the corpus file must replay with zero differences. |
| +- `internal/clireg` imports only the standard library and `internal/cliflag`. |
| +- A0: no leaf dispatches on a word. Every word that selects code is a node, except the box plumbing dispatchers in A0 (`system guard-exec`, `system group-maintenance`, `system files`, `system host-env`, `system named-units`), which stay one raw leaf each. |
| +- No `init`-time tree: `commandRoot()` (`sync.Once`) is first called after `rootaws.ScrubEnvironment()` (A8). `Validate` runs only in tests. |
| +- `cgroup.RunShimIfRequested()` stays `main`'s first statement with its `shimHooked` store (A9). |
| +- Census: every file in the root binary's scope that changes is listed in the CLAIMS file in Task 9 (class: argument routing). |
| +- Tests: changed packages only, with `-run`, locally; CI runs the full suite. Root-package tests and anything binding sockets run with the Bash sandbox off and `TMPDIR=/tmp/g GOTMPDIR=/tmp/g GOFLAGS=-buildvcs=false` (`mkdir -p /tmp/g` first). Never set `GOCACHE`. |
| +- Copy: no user-facing string changes in this step. AGENTS.md text added in Task 8 is agent-facing (no copy review). |
| +- Commit subjects under 80 characters; end each message with `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`. |
| + |
| +## Review Focus |
| + |
| +1. `carlos` with an alias spelling of a subcommand (`canary list`, `config destinations rm`) must behave as the primary: the corpus's alias cases (Task 3) pin it. |
| +2. A default branch fed an unknown word (`instances foo`, `canary ./site`, `move --host h status`) must reach the same handler with the same args: Task 3 generates an unknown-word case for every branch. |
| +3. `system router ...` forms, including `system router` alone and `system router router`, must print today's messages: Task 7 adds them to the corpus explicitly. |
| +4. Handlers that `return` from `main()` before the update hint today must still skip it: Task 2's hint test runs every `NoUpdateHint` path. |
| +5. A test that calls an old dispatcher directly (`RunFleets`, `runDomains`, `RunApps`, `runDB`, `runSystem`, `runCanary`, `moveMain`) must keep passing unchanged: each conversion task keeps the function as a one-line wrapper over `clireg.Dispatch(subtree, args)` and runs that file's tests. |
| + |
| +--- |
| + |
| +### Task 1: `internal/clireg` core (Astra per-task review) |
| + |
| +**Files:** |
| +- Create: `internal/clireg/clireg.go`, `internal/clireg/dispatch.go`, `internal/clireg/validate.go` |
| +- Test: `internal/clireg/dispatch_test.go`, `internal/clireg/validate_test.go` |
| + |
| +**Interfaces:** |
| +- Produces (every later task uses these exact names): |
| + |
| +```go |
| +type On uint8 |
| +const (OnAbsent On = 1 << iota; OnFlag; OnWord) |
| + |
| +type Audience string |
| +const (Customer Audience = "customer"; Operator = "operator"; BoxLocal = "box-local"; Internal = "internal") |
| + |
| +type Golden struct { |
| + Skip string // non-empty: no corpus cases for this node; the reason |
| + SkipBare string // non-empty: no bare case (daemons, prompts); the reason |
| +} |
| + |
| +type Node struct { |
| + Name string |
| + Aliases []string |
| + Summary string |
| + Children []*Node |
| + Default string // a child's name, or "" when DefaultLeaf is set or there is no default |
| + DefaultLeaf *Node // unnamed default leaf; its ID is the branch's ID |
| + DefaultOn On |
| + Fallback func(args, consumed []string) |
| + OnError func(path []string, err error) |
| + Run func(inv *Invocation) error |
| + Transparent bool |
| + When func() bool |
| + NoUpdateHint bool |
| + Audience Audience |
| + Golden Golden |
| +} |
| + |
| +type Invocation struct { |
| + Path []string // IDs' words as typed in canonical form (aliases resolved) |
| + Raw []string // every argument after the last consumed word, unchanged |
| +} |
| + |
| +func RawArgs(f func(args []string)) func(*Invocation) error // calls f(inv.Raw), returns nil |
| +func RawArgsErr(f func(args []string) error) func(*Invocation) error // calls f(inv.Raw) |
| +func Dispatch(root *Node, args []string) []*Node // the path it ran, root first |
| +func Validate(root *Node) []error |
| +type Entry struct { ID string; Node *Node; Default bool } |
| +func Runnable(root *Node) []Entry // every leaf and every unnamed default, depth first, transparent nodes skipped |
| +func ID(path []*Node) string // words joined with single spaces, root excluded |
| +``` |
| + |
| +- [ ] **Step 1: Write the failing walk tests** in `dispatch_test.go`, one table test `TestDispatchWalk` over a fixture tree `apps{set, list(alias ls)}`, `instances{create; DefaultLeaf list; DefaultOn absent|flag|word}`, `canary{deploy, ls(alias list); Default "deploy"; DefaultOn absent|flag|word}`, `config{destinations{add, list; Default "list"; DefaultOn absent|flag}}`, `system{router(Transparent), update; Fallback records}`, `ops{host(When toggled), litestream; Fallback records}`. Each row asserts the leaf reached, its `inv.Raw` and `inv.Path`, or the fallback's `(args, consumed)`: |
| + - `apps set x --y` → `apps set`, Raw `[x --y]` |
| + - `apps ls -a b` → `apps list`, Raw `[-a b]` |
| + - `instances` / `instances --x` / `instances foo bar` → default, Raw `[]` / `[--x]` / `[foo bar]` |
| + - `canary ./site` → `canary deploy`, Raw `[./site]`; `canary list` → `canary ls` |
| + - `config destinations zzz` → fallback `args [zzz]`, `consumed [config destinations]` |
| + - `config destinations --global` → `config destinations list`, Raw `[--global]` |
| + - `system router update -y` → `system update`, Raw `[-y]`, consumed includes `router` |
| + - `system router` → fallback `args []`, consumed `[system router]`; `system router router` → fallback `args [router]`, consumed `[system router]` |
| + - `ops host resolve` with `When` false → fallback `args [host resolve]`; with `When` true → `ops host` leaf |
| + - `apps zz` → apps fallback `args [zz]` |
| +- [ ] **Step 2: Write `TestDispatchOnError`**: a leaf under a branch with `OnError` returning `errors.New("e")` calls `OnError([]string{"auth","login"}, err)` once; nested branches use the nearest `OnError`. |
| +- [ ] **Step 3: Run** `go test ./internal/clireg/ -run 'TestDispatch' -v` → FAIL (package missing). |
| +- [ ] **Step 4: Implement `Dispatch`** per spec A2: at a branch, match `args[0]` against non-transparent children's names and aliases whose `When` is nil or true, then transparent children (each transparent child at most once per branch level; consumed records the word); no match → `Default`/`DefaultLeaf` if `DefaultOn` admits (`OnAbsent` when `len(args)==0`, `OnFlag` when `args[0]` starts with `-`, `OnWord` otherwise), else `Fallback(args, consumed)`. At a leaf, call `Run(&Invocation{Path, Raw: args})`; on non-nil error call the nearest `OnError` on the path; with none, panic (Validate forbids it statically only where it can; this is the runtime backstop). Return the path. |
| +- [ ] **Step 5: Run** the walk tests → PASS. |
| +- [ ] **Step 6: Write `TestValidate`** with one negative fixture per rule in spec A8, each asserting the returned error names the node ID: branch with `Run`; node with neither; duplicate name; alias equal to a sibling's name; duplicate alias; `Default` naming no child; `Default` set with `DefaultOn == 0`; `DefaultLeaf` and `Default` both set; branch with no default and no `Fallback`; `Audience: internal` on a word without `__` prefix; empty `Audience` on a leaf; `Transparent` node with children or `Run`. And one positive fixture (the walk fixture) returning no errors. |
| +- [ ] **Step 7: Implement `Validate`, `Runnable`, `ID`**; run `go test ./internal/clireg/ -v` → PASS; `go vet ./internal/clireg/`. |
| +- [ ] **Step 8: Commit** `clireg: node tree, walk and Validate (CLI registry step 1)`. |
| + |
| +### Task 2: `main()` from the tree, early phase, help, update hint |
| + |
| +**Files:** |
| +- Create: `commands.go` (the root: `commandRoot() *clireg.Node`), `commands_test.go` |
| +- Modify: `main.go:25-245` (the switch and if-chains go), `update.go:67,116` (`noHintVerbs` deleted; `maybeUpdateHint(path []*clireg.Node)`), `internal/cgroup/shim.go:39-50` (the map), `canary_test.go:~285-310`, `update_test.go:~83` |
| +- Test: `commands_test.go`, `internal/cgroup/shim_test.go` (add one test) |
| + |
| +**Interfaces:** |
| +- Consumes: Task 1. |
| +- Produces: `commandRoot() *clireg.Node` (package main); `cgroup.Shims map[string]func([]string) int`; `maybeUpdateHint(path []*clireg.Node)`; every top-level command as a node. In this task every top-level command that has subcommands is a single leaf `Run: clireg.RawArgs(oldDispatcher)` with `Audience` set (Tasks 4-7 replace each with its subtree); top-level leaves that are true leaves (`ship`, `deploy`, `promote`, `restart`, `run`, `logs`, ...) are final here. |
| + |
| +- [ ] **Step 1: Write `TestCommandTreeIsValid`** in `commands_test.go`: `clireg.Validate(commandRoot())` returns no errors. And `TestTopLevelWordsUnchanged`: the set of top-level names and aliases of `commandRoot()` equals exactly today's words (the `switch cmd` cases, the four `__` words before it, `cgroup.ShimVerb`, `cgroup.ProbeVerb`), written out as a literal list in the test. |
| +- [ ] **Step 2: Write `TestUpdateHintSkippedPerPath`**: for each of `edge agent adopt bootstrap add remove route ops status vet release-keygen version help update system`, `__demo-snapshot`, `__registry-child`, the path `Dispatch` would return has a node with `NoUpdateHint`; for `ship` and `apps list` it has none. Leave `channels resign`, `channels digests`, `releases retention` and `releases authorize` out here: Task 5 adds them when those subtrees exist. |
| +- [ ] **Step 3: Run** `go test . -run 'TestCommandTree|TestTopLevelWords|TestUpdateHint' ` → FAIL. |
| +- [ ] **Step 4: Implement** `cgroup.Shims` (keys `ShimVerb`, `ProbeVerb`; the probe wrapped as `func([]string) int { return runProbe() }`) and make `RunShimIfRequested` dispatch from it; add `TestShimsMapIsTheSwitch` in `internal/cgroup` asserting the map's keys equal `{ShimVerb, ProbeVerb}`. In package main, the two shim words are `Internal` leaves whose `Run` panics ("dispatched by cgroup before main"), built by ranging `cgroup.Shims`. |
| +- [ ] **Step 5: Implement `commandRoot()`** with: root `Fallback` = `usage(os.Stderr); os.Exit(2)`; `help` leaf (aliases `-h`, `--help`; `Audience: Customer`; `Run` prints `usage(os.Stdout)`); `version` branch with child `target` and `DefaultLeaf` printing the build id, `DefaultOn: OnAbsent|OnFlag|OnWord` (spec A3); `channels` and `releases` as leaves wrapping today's inline main.go bodies moved into functions `runChannelsTop(args)` and `runReleasesTop(args)` (Task 5 splits them); the `__demo-snapshot`, `__registry-child`, `__rootfs-check-probe`, `__rootfs-check-prepare` leaves (`Audience: Internal`, bodies moved verbatim from main.go; the two `os.Exit` ones keep exiting); `NoUpdateHint` on today's `noHintVerbs` words plus `__demo-snapshot` and `__registry-child`. |
| +- [ ] **Step 6: Rewrite `main()`**: `runtime.KeepAlive(...)`, `cgroup.RunShimIfRequested()`, `rootaws.ScrubEnvironment()`, `log.SetOutput(newErrorWriter(os.Stderr))`, the bare-`carlos` check unchanged, `path := clireg.Dispatch(commandRoot(), os.Args[1:])`, `maybeUpdateHint(path)`. `maybeUpdateHint` returns at once when any node on the path has `NoUpdateHint`; the rest of its body is unchanged. |
| +- [ ] **Step 7: Rewrite `TestCanaryIsDispatchedNotStubbed`** (`canary_test.go`) to look `canary` up in `commandRoot()` and assert it is runnable (Task 5 tightens it to "a branch with a `deploy` default"); move `canary_test.go:307`'s `noHintVerbs` read and `update_test.go:83`'s `maybeUpdateHint("ship")` to the path form. |
| +- [ ] **Step 8: Run** `go build . && go test . -run 'TestCommandTree|TestTopLevelWords|TestUpdateHint|TestCanary|TestUpdate' && go test ./internal/cgroup/` → PASS. |
| +- [ ] **Step 9: Commit** `cli: main dispatches from the command tree`. |
| + |
| +### Task 3: The golden corpus (Astra per-task review) |
| + |
| +**Files:** |
| +- Create: `clireg_golden_test.go`, `testdata/clireg-golden.jsonl` |
| +- Test: same file |
| + |
| +**Interfaces:** |
| +- Consumes: `commandRoot()`, `clireg.Runnable`, `Node.Golden`, `platform.SharedCarlosForTest` (via `sharedCarlos(t)`). |
| +- Produces: `TestCLIGolden` with flags `-record` (bool) and `-base` (commit), and the corpus file. Each later task re-records (`go test . -run '^TestCLIGolden$' -record -base $BASE`, where `BASE` is this branch's fork point, `git merge-base origin/main HEAD` at Task 3 time, written into the plan ledger) and must show no changed line for cases that existed before. |
| + |
| +One JSON object per line: `{"case":"<id> | <kind>","argv":[...],"env":{...},"exit":N,"stdout":"...","stderr":"..."}`, sorted by `case`. (Spec E2 names `.tsv`; JSON lines is used because outputs span lines. Marked call.) |
| + |
| +- [ ] **Step 1: Write the case generator** `goldenCases(root *clireg.Node) []goldenCase`: for every branch (by `clireg.Runnable`'s parents plus every node with children): bare (unless `Golden.SkipBare`), `help`, `-h`, `--help`, `zz-unknown`, `--zz-unknown-flag`; for every leaf and unnamed default: `-h`, `--zz-unknown-flag`; for every alias, the same cases with the alias spelling; for every transparent word, the parent's cases prefixed with it, plus the word alone and twice; for every `When` node, its cases with the switch on and off (`CARLOS_HOST_CLAIM=1` for `ops host`). Nodes with `Golden.Skip` produce one `skipped: <reason>` line instead. |
| +- [ ] **Step 2: Write the runner**: each case runs the binary with an empty environment plus exactly `PATH`, `HOME` and working directory (a fresh directory under `t.TempDir()`), `TMPDIR`, `LANG=C`, `HTTP_PROXY=HTTPS_PROXY=http://127.0.0.1:9` and the case's own variables; stdin empty, no terminal; 10-second limit, and exceeding it fails the test naming the case. Normalise stdout/stderr: strip `^\d{4}/\d\d/\d\d \d\d:\d\d:\d\d ` at each line start, replace the case's directory with `$DIR`. Run at most 8 cases at once. |
| +- [ ] **Step 3: Write `TestCLIGolden`**: with `-record`, build `-base` with `git archive <base> | tar -x -C <dir under $TMPDIR>` then `go build -o <dir>/carlos .` there (remove the dir after), run every case, write the file; without it, run every case against `sharedCarlos(t)` and report each case whose line differs (case, field, want, got), plus cases in the file the tree no longer generates and cases the tree generates that the file lacks. `testing.Short()` skips. |
| +- [ ] **Step 4: Verify it can fail**: record from the fork point, then run replay against a binary with one deliberate change (`usage` text edited) and see the failure name the cases; revert. |
| +- [ ] **Step 5: Mark `Golden` skips** on the nodes whose bare form starts a daemon or touches the box (`edge`, `agent`, `adopt`, `bootstrap`, `instance-control`, `instance-exec`, `instance-exit`, `instance-stop`, `instance-probe`, `relay serve` when it exists, `system apply` and other root leaves when they exist, the shim words, `__` plumbing): `SkipBare` where `-h` and an unknown flag are still safe, `Skip` only where even those are not. Each with its reason. |
| +- [ ] **Step 6: Record and replay**: record at `BASE`, replay → PASS with zero differences. Commit the file. |
| +- [ ] **Step 7: Commit** `cli: golden corpus recorded from the base binary`. |
| + |
| +### Tasks 4-7: Subtrees, by area |
| + |
| +Each of Tasks 4-7 does the same thing for its list of dispatchers, following that dispatcher's rows in the audit: |
| + |
| +1. In the dispatcher's package, write `<name>Command() *clireg.Node` (package main: unexported; other packages: exported, e.g. `host.SystemCommands() []*clireg.Node`) declaring every word the dispatcher (and its nested dispatchers) switches on: names, aliases (one child with an alias, spec A5), `Default`/`DefaultLeaf` and `DefaultOn` copied from today's behaviour, `Fallback` = today's `default:` arm moved verbatim (help words included), `OnError` = the parent's error mapping where one exists (spec B1 "Errors": `RunAuth`, `RunConfig`, `billing`, `devbox`, `accounts plan`), leaves `Run: clireg.RawArgs(handler)` or `RawArgsErr`, `Audience` per the parity row's status (`operator`, `box-local`, `internal`, else `customer`). |
| +2. Replace the top-level leaf from Task 2 with the subtree. Keep the old dispatcher function as a one-line wrapper `clireg.Dispatch(<name>Command(), args)` (spec A5 "Thin wrappers") when any test calls it; delete it otherwise. |
| +3. Whole-function dispatchers (`billing`, `move`, `devbox`): leaves are closures that re-prepend their word and call the old function unchanged (spec A5); the inner switch stays until its args step. |
| +4. Re-record the corpus from `BASE`: no existing line may change; new lines are the subtree's new cases. Add any explicit cases the task names. |
| +5. Run the package's existing tests (`-run` on the touched files' tests) and `TestCommandTreeIsValid`. |
| +6. Commit per dispatcher group, subject `cli: <area> words in the registry`. |
| + |
| +### Task 4: Apps, config and settings |
| + |
| +Dispatchers: `apps` (incl. `apps source`), `env`, `secrets`, `features`, `assets`, `domains`, `routes`, `route`, `gate`, `ratelimit`, `protection`, `config` (incl. `config destinations`, `DefaultLeaf`-free: named `list` default on `OnAbsent|OnFlag`, unknown word to the fallback), `accounts`, `auth`. |
| + |
| +- [ ] Steps 1-6 above for each; explicit corpus cases: `config destinations` bare, `config destinations --global`, `config destinations zz`; `auth login -h` (exit 1 today via `RunAuth`'s mapping); `apps source` bare and `apps source delete`. |
| + |
| +### Task 5: Release, instances and runtime |
| + |
| +Dispatchers: `instances` (`DefaultLeaf` = the box listing, all three `DefaultOn`; `instances import` with nested `commit`/`abort`), `sidecars`, `schedule`, `db` (help words in its fallback, exit 0 on stdout), `devbox`, `canary` (`Default: "deploy"`, all three `DefaultOn`; `ls` alias `list`, `rm` alias `delete`), `channels` (`DefaultLeaf` list; children `resign`, `digests`, both `NoUpdateHint`), `releases` (`DefaultLeaf` list; `retention`, `authorize`, both `NoUpdateHint`), `pipeline` (`Default: "show"`), `version` (from Task 2), `skills` (leaf), `move` (children `status`, `cut`, `abort`, `resolve`, `offline` with eight children from `offlineVerbs`, which is deleted and its users read `moveCommand()`'s children; `DefaultLeaf` = request on all three `DefaultOn`), `economics`, `proof`, `email` (incl. `email events` with its `push` child and default), `store` (incl. `store scan`; `enforce` is one raw leaf), `relay`, `services`, `fleets` (incl. `fleets boxes`), `ledger`, `billing`. |
| + |
| +- [ ] Steps 1-6 above for each; add `TestUpdateHintSkippedPerPath`'s `channels`/`releases` paths (Task 2 Step 2); tighten `TestCanaryIsDispatchedNotStubbed` to "branch with `Default` `deploy`"; explicit corpus cases: `instances foo`, `canary ./site`, `canary list -h`, `channels digests on -h`, `channels digests --account-id x on`, `channels digests zz --zz` (spec R3b-1), `move --host h status`, `move offline zz`, `version foo`. |
| + |
| +### Task 6: Box and host commands that are not root-run |
| + |
| +Dispatchers: `edge` (leaf, `SkipBare`), `agent`, `adopt`, `bootstrap`, `add`, `remove`, `status`, `vet` (`vet.Command()`), `update`, `instance-*` (leaves exported by `internal/instanceexec` and `internal/host`; `instance-exec`/`instance-exit` role stays a value), `ops` (children: `host` with `When: func() bool { return strings.TrimSpace(os.Getenv("CARLOS_HOST_CLAIM")) != "" }` and its child `resolve` as a raw leaf; `litestream`, `restore-verify`, `hibernate-verify` exported by `internal/ops`; `Fallback` = `boxops.Run`'s unknown-verb arm). |
| + |
| +- [ ] Steps 1-6 above; explicit corpus cases: `ops host resolve -h` with and without `CARLOS_HOST_CLAIM`, `ops zz`. |
| + |
| +### Task 7: `system` (Astra per-task review: root-run) |
| + |
| +**Files:** `system.go`, `system_demos.go`, `system_roles.go`, `system_geoip.go`, `system_managedfleets.go`, `system_seeds.go`, `system_legacy_routes.go`, `system_lifetimes.go`, `system_hostsused.go`, `system_activation.go`, and `SystemCommands()` exports in `internal/host`, `internal/hostenv`, `internal/dbreads`. |
| + |
| +- [ ] **Step 1:** One child list replaces `systemVerb`'s case list and `runSystem`'s arms (spec A6); `router` is a `Transparent` child; `Fallback` calls `systemUnknownVerbMessage` with what it needs from `(args, consumed)` (whether `router` is in `consumed`) and keeps today's help (stderr, exit 0) and unknown (stderr, exit 2) behaviour. |
| +- [ ] **Step 2:** Word-first children per the audit: `antivirus {status, enable, disable, rotate-webhook-key}` (closures passing the word to `runSystemAntivirus`), `pdf {status}`, `layout {status, migrate, revert}`, `geoip {publish, status, off}`, `managed-fleets {show, set}`, `seeds-floor {publish}`, `legacy-routes {assign}`, `lifetimes {cutover}`, `hosts-used {status}`, `box {role (raw), publish-record}`, `group {role (raw)}`, `demos {status, serving, takedown, takedown-status, reports {resolve; DefaultLeaf list on all three}}` (spec B6: each leaf runs today's manual loop; `demos`'s fallback prints `systemDemosInvalid`, exit 2, and the sole-argument help to stdout, exit 0), each with its fallback copied from today. |
| +- [ ] **Step 3:** Box plumbing kept whole (spec A0): `guard-exec`, `group-maintenance`, `files`, `host-env`, `named-units` are single leaves calling today's functions with all their arguments; `update`, `status`, `rollback`, `cancel-activation`, `apply`, `install-channel`, `runsc-ensure`, `exec-sandbox-allows-prev`, `journal-migrate`, `floor-allows-prev`, `guard-arm`, `db-worker` are leaves. |
| +- [ ] **Step 4:** Corpus: re-record from `BASE`; explicit cases `system router`, `system router router`, `system router update -h`, `system demos foo --bar`, `system demos --bar foo`, `system demos help`, `system demos help x`, `system antivirus`, `system antivirus zz`, `system guard-exec zz` with `CARLOS_RELEASE_PUBKEY` unset and with the test key the host tests use, `system apply --recover -h`. |
| +- [ ] **Step 5:** Run `go test . -run 'System|TestCommandTree|TestCLIGolden'` and the touched internal packages' tests (sandbox off, `TMPDIR=/tmp/g`); commit `cli: system words in the registry`. |
| + |
| +### Task 8: Parity projection and guard, docsite, AGENTS.md |
| + |
| +**Files:** |
| +- Create: `parity/cli.tsv`, `cli_projection_test.go` |
| +- Modify: `internal/parity/repo_test.go` (replace `TestParityCLITopLevel`), `internal/parity/rules.go` (audience check), `internal/parity/rules_test.go`, `internal/docsite/cli_test.go`, `internal/docsite/fences_test.go`, `Makefile:43-44`, `parity/parity.tsv` (rows the full coverage demands), `docs/parity.md` (regenerated), `AGENTS.md`, `parity/README.md` |
| +- Delete: `internal/docsite/cliscan.go` and its tests |
| + |
| +**Interfaces:** |
| +- Consumes: `clireg.Runnable`, `commandRoot()`. |
| +- Produces: `parity/cli.tsv`, columns `id audience effect scope tool flags enums` (step 1 writes `-` in the last five); `parity.LoadCLI(path string) ([]CLIEntry, error)` with `type CLIEntry struct { ID string; Audience string; Tool string; Flags, Enums []string; Line int }`. |
| + |
| +- [ ] **Step 1: Write `TestCLIProjection`** (package main): renders `clireg.Runnable(commandRoot())` to the format above, sorted by ID, and fails if it differs from `parity/cli.tsv`; with `-update` it writes the file. Generate it. |
| +- [ ] **Step 2: One-off check (not a test):** the projection's top-level IDs with audience other than `internal` equal today's `docsite.TopLevelCommands("main.go")` output taken at `BASE` (run it there, paste both lists into the task report). |
| +- [ ] **Step 3: Write the guard tests** in `internal/parity`: `TestParityCLIPaths` (spec D2: every non-internal projected ID is some row's CLI member, every CLI member is a projected ID or a `__` word); `TestParityCLIAudience` (spec D5: a `customer` entry appears in at least one customer-status row; an outside entry only in outside-status rows); `TestParityMCPColumn` (spec D4: each row's `mcp` column equals the comma-joined `tool` values of its CLI members' entries, `-` counting as none). Fixtures in `rules_test.go`: a leaf's row removed while its parent's row remains fails; a row naming `apps source delete` fails; the three `status` rows (`status [--instances,--layout]`, `status [--live]` as `operator`, `status [--dry-run]` as `box-local`) with an `operator` entry pass; a `customer` entry only in an `operator` row fails; an `operator` entry in a `both` row fails. |
| +- [ ] **Step 4:** Run them against the real table; add or fix rows until they pass. A new customer row's status comes from the console (find the route or record `gap` with an existing package from `parity/packages.tsv`); list every added row in the task report. |
| +- [ ] **Step 5: Docsite:** `TestCLICommandsAreDocumented` and `TestFencedCarlosCommandsAreReal` read top-level names from `parity/cli.tsv` via a small reader in `internal/docsite` (top-level = ID without a space, audience not `internal`); the scanner's non-vacuity test becomes one on the file (at least 20 names; `ship`, `promote`, `deploy`, `domains`, `logs`, `fleets` present; no `-h`, `--help`, `""`). Delete `cliscan.go`. |
| +- [ ] **Step 6:** `Makefile` `parity-doc`: `go test -run '^TestCLIProjection$$' -update . && go run ./internal/parity/cmd/parity-doc`. Run `make parity-doc`; `docs/parity.md` regenerates. |
| +- [ ] **Step 7: AGENTS.md** (beside the parity rule): "A word that selects code is a `clireg` node in `commands.go` or its package's subtree, with its `parity/parity.tsv` row in the same branch. A leaf compares arguments only to its declared enum values, flag spellings or ordinary value checks, never to a word that picks different behaviour." Same sentence, shortened, in `parity/README.md`. |
| +- [ ] **Step 8:** Run `go test ./internal/parity/ ./internal/docsite/ && go test . -run 'TestCLIProjection|TestCommandTree'` → PASS. Commit `parity: CLI coverage from the command registry`. |
| + |
| +### Task 9: Census, branch review, merge |
| + |
| +- [ ] **Step 1:** Merge `origin/main` in; re-record the corpus only if `BASE` moved (record from the new merge base and confirm zero changed lines for existing cases); full local build `go build ./... && go vet ./...`. |
| +- [ ] **Step 2:** `make census-card`; write `$TMPDIR/claims-cli-registry-words.tsv` with one line per changed unit (class: argument routing; "no root-read added; dispatch moved into the clireg tree, handlers unchanged"); `make census-propose NAME=cli-registry-words CLAIMS=$TMPDIR/claims-cli-registry-words.tsv`; commit the overlay, chain line and card. |
| +- [ ] **Step 3:** Whole-branch Astra review (brief from `REVIEW-BRIEF-TEMPLATE.md`, census card included; the reviewer gives a verdict per census unit). Record the census verdict on discussion #280 with reviewer and tip. Stopping rules apply (max three rounds; rule 2 escalates to the coordinator). |
| +- [ ] **Step 4:** Push, `amadan branch describe`, wait for `amadan ci status carlos/platform -branch cli-registry-words` passed, `git merge-base --is-ancestor origin/main HEAD` as its own command, then `amadan branch merge carlos/platform cli-registry-words -expect <full sha> -squash -message "<subject + body>"`. |
| +- [ ] **Step 5:** Report to the coordinator; hand the release note to the agent manager (`paseo send 8a3d302a-eac7-407c-b61c-f5ccc66b5544`): root-binary change, rides the next box release, no behaviour change, corpus-gated. |