carlos / platform Public

review briefs: nearest-region-b Task 5 round 2, Task 6 round 1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 45dbce1b4b75f890eca1988eea4dd47c28c882aa parent 416e0a8
2 files changed, +189 −0
  • docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-b-task5-R2.md +98 −0
  • docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-b-task6.md +91 −0

CI failed — run details

diff --git a/docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-b-task5-R2.md b/docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-b-task5-R2.md
new file mode 100644
index 000000000..aec715886
--- /dev/null
+++ b/docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-b-task5-R2.md
@@ -0,0 +1,98 @@
+# Review brief: nearest-region never-reuse, Task 5 (the activation window: modes, admissions, drain), round 2 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: Task 5 as of commits `58873885` and the round 1 fixes in `416e0a89` (which also carries Task 6; Task 6's import, close-fleet and complete code is reviewed separately and is out of scope here, except where it changes Task 5's drain or transitions): `internal/provision/hostsused.go` (HostsState),
+`internal/console/hostsused.go` (state, transitions, admissions), `internal/console/hostsused_window.go`
+(status, begin, cancel doors), the admission call sites in `apiinstances.go`, `apisidecars.go`,
+`apiinstancemove.go`, `apiinstancemove_offline.go`, `fleets.go` (`placeAppTarget`), `cmd/console/main.go`
+(the start-time read), the CLI verbs in `system_hostsused.go`, their tests, and census bookkeeping.
+Authorities, all on main: the spec `docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md`
+(rev 5, §3a and §4), the plan `docs/superpowers/plans/2026-10-26-nearest-region-never-reuse.md` (Task 5), the
+approved copy `docs/superpowers/notes/copy/nearest-region-never-reuse.md` (S1-S8) and, on this branch,
+`docs/superpowers/notes/copy/nearest-region-never-reuse-b.md` (approved). Merge A (Tasks 2-4) is merged
+(70d37672) and closed.
+
+You are an independent reviewer. Read the document, then the code it
+names, and check every claim against that code.
+
+## Fixed: do not re-argue
+
+- Paul's rulings in the spec, including one console process per deployment that reads `@mode` once at start.
+- An accepted deviation (coordinator, 2026-10-26; noted in spec §3a item 5): `cancel` returns to the mode
+ `begin` started from, so a window opened from invalidated goes back to invalidated.
+- Out of scope here, later tasks on this branch: the roster, import, close-fleet and complete (Task 6), the
+ examined-target refusals, recovery marking and the nearest-region switch gate (Task 7), the tripwire and
+ invalidate door (Task 8), `apps place` in active (Task 9), `accounts migrate` (Task 10), README (Task 13).
+ `HostsState` already has fields for them; their writers come later.
+- Approved strings are applied verbatim; report wording only if it misstates what the code does.
+
+## What to check
+
+1. While the window is open, every data-kind create door refuses with S8 (instance in every placement,
+ seed, import, sidecar), and every admission of new data movement refuses with S7: offline start and
+ stage, the move request (both the Phase 1 handler and the legacy one), and `placeAppTarget` (all three
+ of its callers). Exempt kinds and every other door keep working, including the offline seal, flip,
+ open, finish and abort doors and move cut and abort, which admitted moves need in order to finish.
+ Look for an admission door that is missing (any other way to start moving data, or to create a data-kind
+ record), and for any refusal that comes before the caller's gate (a non-member must still get the 404).
+2. The drain: every admitted create, move and placement is counted from admission until its handler
+ returns, on every return path; nothing admitted can persist a record or start a move without having
+ been counted; `pending_allocations`, `pending_retirements` and `unfinished_moves` cover the rest of
+ §3a item 2. Check whether a seed's detached copy, or any other work continuing after its handler
+ returns, can create or move data that none of the counts see.
+3. Mode transitions: `hostsTransition` writes the store and the process together on the held ETag; a
+ lost race or a failed write leaves no divergence that could let a create through; the start-time read
+ happens before the console serves; an unreadable mode refuses rather than defaulting.
+4. `begin` refuses under host claims or Phase 1 (C11), from active (C1) and when already open (C2);
+ `cancel` refuses with no window open (C3). Operators only; closed to every service credential.
+5. Request budget: no per-request GET; `unfinished_moves` (one listing plus a GET per record) is read
+ only by the status door and only while the window is open.
+6. The tests go through the real doors and would fail without the implementation.
+
+## Round 2
+
+Earlier rounds: round 1, `docs/superpowers/notes/reviews/ASTRA-FINDINGS-nearest-region-b-task5-r1.md`
+(two P1s, one P2). First give one line per P1 and P2 from round 1: resolved, partly, or not. Carry
+every unresolved or partly resolved finding forward at its current severity, then add new findings.
+Name the fault family beside each finding: round 1's were drain completeness (P1 1), persisted and
+in-process mode agreement (P1 2), and transition answers (P2). A second finding in the same family as a
+round 1 P1 stops the review (AGENTS.md stopping rule 2).
+
+The fixes: `unfinishedWork` counts records whose seed has not ended (not committed, refused, aborted
+or rolled-back) beside records with a move, from record state, and `complete` refuses on either;
+`hostsTransition` drops the held state on any failed write; `begin`, `cancel` and `close-fleet` answer
+the state they wrote. Witnesses: `TestDrainWaitsForUnfinishedSeed`, `TestAmbiguousModeWriteRereads`,
+`TestBeginAnswersWithoutTheRecordScan`.
+
+## 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.
+
+In round 3, a NOT READY also says whether the P1s share one cause, and
+whether refusing the case up front or cutting the feature would remove
+them.
+
+Do not edit files. Do not spawn Anthropic-model reviewers or subagents of
+your own. Do not run the full test suites.
diff --git a/docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-b-task6.md b/docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-b-task6.md
new file mode 100644
index 000000000..cc82e98e1
--- /dev/null
+++ b/docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-b-task6.md
@@ -0,0 +1,91 @@
+# Review brief: nearest-region never-reuse, Task 6 (inventory, import and complete), 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: Task 6 in commit `416e0a89`: `internal/provision/hostsused_map.go` (listing to hostnames,
+`TargetListing`), `internal/console/hostsused_inventory.go` (roster, import, close-fleet, complete),
+`internal/console/hostsused_listings.go` (listings in the control bucket), `internal/console/hostsused_store.go`
+(`LifetimeHosts`), the window's roster and status additions in `hostsused_window.go`, the CLI verbs in
+`system_hostsused.go`, and their tests. The same commit also carries Task 5's round 1 fixes, which have
+their own review; treat Task 5 as given.
+Authorities, on main: the spec `docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md`
+(rev 5, §3 and §3a), the plan `docs/superpowers/plans/2026-10-26-nearest-region-never-reuse.md` (Task 6, and
+Review Focus items 2, 4 and 5), the approved copy `docs/superpowers/notes/copy/nearest-region-never-reuse.md`;
+on this branch, the approved `docs/superpowers/notes/copy/nearest-region-never-reuse-b.md`.
+
+You are an independent reviewer. Read the document, then the code it
+names, and check every claim against that code.
+
+## Fixed: do not re-argue
+
+- Paul's rulings in the spec: deleted history and noncurrent versions are not sources (§1); regions and
+ pools cannot be closed, fleets can (§3); marks are never deleted and over-marking is the accepted cost.
+- The adapter (scan script, Task 11) and the roll-script floor (Task 12) are outside this repo's branch.
+- Out of scope, later tasks: enforcement of the examined set and closed fleets at create, and recovery
+ marking (Task 7); the tripwire (Task 8); `apps place` and `accounts migrate` (Tasks 9, 10).
+- Design choices made here, with reasons: listings live in the control bucket beside the history
+ (`control/hosts-used-window/`), not in console SQLite, so a database restore cannot drop them and no new
+ table is needed. Each fleet's listing targets are fixed in the state at `begin`. A flat box entry marks
+ every host-like prefix ending at "." or "-" (an app may name its files from its database path); a name
+ carrying one of the platform's own suffixes is read exactly, so the box's own files are nobody's.
+- The root-read census has three new units awaiting the census owner's decision on #280; do not report
+ the census as failing.
+
+## What to check
+
+1. Hazard-completeness of the sources (spec §3): every place a box could read an earlier record's data
+ for a hostname maps to that hostname, or is reported unmapped so `complete` refuses. Check the bucket
+ roots (`<replicaPrefix>/`, `moves/`, `moves/@offline/`, `seeds/`; `moves/@lanes/` skipped) against the
+ code that writes them (`activator.HibernatePrefix`, `activator.MovesPrefix`, `moves.StagingPrefix`,
+ `moves` offline keys, `seeds`), and the box shapes (flat, nested `instances/<InstanceID>`,
+ `.instances/`, hashed ids, `.offline-moves/`) against `provision.InstanceID`, `internal/layout` and the
+ offline move code. Review Focus 2 (suffix hosts stay distinct) and 5 (no normalisation; invalid shapes
+ unmapped).
+2. Source 1 reads raw keys under `apps/` whatever their app or account; only a body decoding to static or
+ service is skipped; an undecodable instance body is marked by its key; an undecodable sidecar body
+ refuses. Source 4 includes every row of the three lifetime tables, any state, any writer version.
+3. `complete` refuses exactly as the plan lists: not activating, any drain count non-zero (in-flight,
+ pending allocations and retirements, unfinished moves and seeds), a roster target with no listing and
+ not excused by a closed fleet, a failed listing, any unmapped entry, a roster change since `begin`,
+ host claims or Phase 1 on. On success it writes every mark, then the floor, then `active` with the
+ examined set; check the ordering leaves no state where `active` holds with marks missing, and that a
+ failure part-way can be retried.
+4. The roster: edges files read completely or refused; fleets and their boxes from the registry;
+ `region:<placement code>` is the vocabulary a record's Region uses; detached fleet boxes are left out.
+ Check whether any box or bucket that can hold data is missing from the roster.
+5. `import` refuses a target off the roster before storing anything; a re-import replaces; `close-fleet`
+ refuses anything but a roster fleet (C5). Operators only; closed to service credentials.
+6. Approved strings are used verbatim (C4-C11, B4-B8, A10-A13).
+7. The witnesses go through the real doors and would fail without the implementation.
+
+## 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.
+
+In round 3, a NOT READY also says whether the P1s share one cause, and
+whether refusing the case up front or cutting the feature would remove
+them.
+
+Do not edit files. Do not spawn Anthropic-model reviewers or subagents of
+your own. Do not run the full test suites.