carlos / platform Public

nearest-region-b: whole-branch review brief (offline activation, Paul's cut)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev db2ebc63621dfaa7a5d1365becc9b2831abab6f8 parent 42773c2
1 file changed, +125 −0
  • docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-b-branch.md +125 −0

CI passed — run details

diff --git a/docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-b-branch.md b/docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-b-branch.md
new file mode 100644
index 000000000..0bea8acc2
--- /dev/null
+++ b/docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-b-branch.md
@@ -0,0 +1,125 @@
+# Review brief: nearest-region never-reuse, merge B whole branch (offline activation), round 1 of 3
+
+Repo carlos/platform, branch `nearest-region-b`, at the commit named in your prompt (the brief's own commit; review the code there).
+Under review: the diff `origin/main...HEAD` (merge base `4dc5902d4f244a3de346b258660950472df9b07a`; merge A, 70d3767, is already on main).
+Authorities, on main: the spec `docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md`, the plan
+`docs/superpowers/plans/2026-10-26-nearest-region-never-reuse.md`, the approved copy
+`docs/superpowers/notes/copy/nearest-region-never-reuse.md`. On this branch: the spec's §3b paragraph and the
+plan's "Rework" section, which record Paul's cut below, and the approved copy
+`docs/superpowers/notes/copy/nearest-region-never-reuse-b.md` (including the appended rework list).
+
+You are an independent reviewer. Read the document, then the code it
+names, and check every claim against that code.
+
+## Round history, and what this round is
+
+Merge B was first built with a live activation window (activating mode, a drain, an in-process counter).
+Its per-task Astra rounds were all NOT READY and kept finding interleavings of one cause, the mode checked in
+one place and acted on in another: Task 5 r1-r3 (the drain; budget spent), Task 6 r1-r2 and Task 7 r1-r2 (each
+stopped by stopping rule 2), Task 8 r1, Task 10 r1. Findings: `docs/superpowers/notes/reviews/ASTRA-FINDINGS-nearest-region-b-*.md`.
+
+**Paul's cut (recorded on amadan discussion #404, 2026-10-26): activation and invalidation run offline, with the
+console stopped. The live window is removed.** This is the one whole-branch review of the reworked branch, a new
+round for the parts that changed. Earlier findings against the window, the drain, the activating mode or the
+online invalidate/import doors are moot unless the same fault survives in the offline design; say so if it does.
+
+## Fixed: do not re-argue
+
+- The offline-activation design itself (Paul's cut). Report only mechanisms that fail to honour it.
+- Kept from before the cut: merge A's marking; S1-S4; the `apps place` cut; `carlos accounts migrate` refusing
+ data-kind copies once the history exists (S6) and refusing below the floor; the start-up gate; a fleet's target
+ set fixed once recorded; static and service records exempt (`Record.DataKind()`); three modes (incomplete,
+ active, invalidated). Pools are no separate target: their boxes reach the roster through edges files.
+- One console process per deployment, and a region or fleet added after completion taking no new instances until
+ the history is completed again: both are stated limits (README, "Two limits"), not defects.
+- The roll-script floor (Task 12) and Task 11 are out of this merge.
+- Approved copy is applied verbatim; do not rewrite strings. Report a string only if it states something the
+ code does not do.
+
+## What to check
+
+1. **The serve lock.** `cmd/console/servelock_unix.go`, `servelock_windows.go`, `main.go` (`serve()`), `hostsused.go`.
+ `console serve` takes an exclusive non-blocking flock on `<CONSOLE_DB>.serve.lock` before it opens the database or
+ serves, and holds it for the process's life (the file cannot be collected or closed early). `roster`, `activate`
+ and `invalidate` take the same lock, derived from the same path, or refuse. Can the console start, or an offline
+ verb write, while the other holds it? Does the Windows build compile and refuse safely?
+2. **Activate's refusals and order.** `internal/console/hostsused_activate.go`. It refuses on any pending
+ `host_allocations` or `record_retirements` row, any unfinished move or seed, a roster changed since it was taken
+ (target names and each region's and fleet's targets, compared in full), a missing, failed or unmappable listing
+ for any target that is not a closed fleet, or claims or Phase 1 on. Only then it marks, writes the floor, then the
+ active mode. A failure partway must leave the mode incomplete and a re-run safe. Is any data-kind host that
+ exists in the database, a bucket or on a box left unmarked when activation succeeds?
+3. **Listing mappers.** `internal/provision/hostsused_map.go` and `internal/layout/hostsused.go` against the spec's
+ list of sources (replica prefix as configured, `moves/`, `moves/@offline/`, `seeds/`; flat `<host>.db*` and
+ `<host>`, nested and hashed `InstanceID`, `.offline-moves/<host>`). Anything that maps to no host must refuse, not
+ pass silently.
+4. **The start-up gate.** `internal/console/hostsused.go` (`LoadHostsMode`, `hostsCached`), `hostsused_tripwire.go`,
+ `regionconfig.go`, `regioncandidates.go`. Until the tripwire passes, every data-kind create door refuses (S5) and
+ `appRegionsOn` is false; no door reads the mode without the verified flag.
+5. **Admission and marking.** `apiinstances.go`, `apisidecars.go`, `apicli.go`, `fleets.go`, `lifetimes_create.go`,
+ `lifetimes_recovery.go`. Every data-kind create marks its host create-only before the record exists; a used host
+ is refused (S1/S2); S3 and S4 refuse unexamined regions and fleets and closed fleets; a fleet's recorded target
+ set does not change. Is there any door that creates a data-kind record without passing `admitDataCreate`, or a
+ path (recovery, import, move, seed) that can recreate a used host?
+6. **Invalidation.** The in-process latch taken under the admission lock before paging, `persistInvalidation`
+ retrying a failed write, `recoveryMark`, and the offline `invalidate` verb. After invalidation, does any create
+ still pass?
+7. **`WriteRecord`.** `internal/provision/hostsused.go` `checkKindUnchanged`: an in-place kind change is refused on
+ the final bytes, decoding the kind as `DecodeRecord` does.
+8. **`carlos accounts migrate`.** `accounts.go`, `accounts_hostsused.go`: the floor is read before the registry
+ opens; once the history exists no data-kind record is written at an absent destination on any path.
+9. **Removed surfaces.** The window files are deleted; `apiinstanceseed.go`, `apiinstanceimport.go`,
+ `apiinstancemove.go`, `apiinstancemove_offline.go` equal main; the closed-route inventories
+ (`claim-routes.txt`, `svcroutes_test.go`) match the routes that exist; `carlos system hosts-used` offers only
+ `status`.
+10. **Docs.** The README section "The hostname history", the spec's §3b and the plan's Rework section match the code.
+11. **Tests.** The new tests would fail without the implementation and drive the real wiring (the console's doors,
+ `runHostsUsed`, the record step as `runAccountsMigrate` runs it), not fixtures that bypass it.
+
+## Census
+
+This review also gives the census verdict AGENTS.md ("The census: the reviewer decides") requires. Under C2
+(7c9e9d6) the reviewer decides every class; nothing goes to Paul. Card:
+`docs/superpowers/notes/census-proposal-nearest-region-b.md`. Give a verdict, approve or reject with a finding, for:
+
+1. the unit `accounts.go` `runAccountsMigrate` (change: body), against its recorded disposition and basis on the card;
+2. each re-pinned envelope: `.`, `internal/layout`, `internal/provision` (read every changed function in the
+ package and what it reaches);
+3. the record-write census overlay `nearestRegionBWriteCensusInventory` (`internal/provision/nearest_region_b_census_test.go`,
+ used by `plan9_b8_census_test.go`) and the console authority site added in
+ `internal/console/testdata/claim-authority-sites.txt` (`cmd/console/hostsused.go`, `runHostsUsed`, `os.Open(*listingsPath)`).
+
+Reject only with a concrete finding: root opening, running, querying or following something new from a path or
+input a tenant, an app or a box agent can create, write or name; or a weakened check, refusal, validation,
+argument or environment the basis relies on. Cite lines. End the census part with APPROVE (all) or REJECT (listed).
+
+## Severity
+
+- **P1**: unsafe, would not compile, a test fails, or it would not work.
+ Blocks merge.
+- **P2**: wrong or missing. Fixed without reopening this review. (The
+ census, and review of any newly changed security, root, termination
+ or production-storage behaviour, still check the fix; see AGENTS.md,
+ "Stopping rules".)
+- **P3**: clarity or polish. Goes on a follow-up list; never a reason for
+ another round.
+
+A P1 states its failure scenario and the evidence (file:line). Do not
+raise a P2 to P1 to keep the review open.
+
+## Output
+
+Findings ranked P1, P2, P3. Each gives the section or task, the problem,
+the evidence (file:line, verified), the failure scenario, a concrete
+fix and the invariant or trust boundary it breaks (that is its fault
+family). End with exactly one verdict:
+
+- **READY**: no P1 and no P2.
+- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another
+ round.
+- **NOT READY**: one or more P1s, listed.
+
+Then the census verdict, APPROVE or REJECT, as above.
+
+Do not edit files. Do not spawn Anthropic-model reviewers or subagents of
+your own. Do not run the full test suites.