carlos / platform Public

review brief: nearest-region-a Task 3, round 1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 780f3431ea4585a78bdd45c41bc69985e27aa8f5 parent 8d5c39e
1 file changed, +96 −0
  • docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-a-task3.md +96 −0

CI failed — run details

diff --git a/docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-a-task3.md b/docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-a-task3.md
new file mode 100644
index 000000000..4a916bd7b
--- /dev/null
+++ b/docs/superpowers/notes/reviews/CODEX-REVIEW-BRIEF-nearest-region-a-task3.md
@@ -0,0 +1,96 @@
+# Review brief: nearest-region never-reuse, Task 3 (mark in every data-kind create writer), round 1 of 3
+
+Repo carlos/platform, branch `nearest-region-a`, commit 8d5c39e3 (the brief's own commit follows it; review the code at that commit).
+Under review: commit `8d5c39e3` (`git show 8d5c39e3`), that is `internal/console/hostsused.go` (new),
+`internal/console/hostsused_writers_test.go` (new), the call sites in `apiinstances.go`,
+`apiinstanceseed.go`, `apisidecars.go`, `lifetimes_create.go` (`createRecordWithLifetimeLocked`),
+`lifetimes.go` (`lifetimeCreateRefusal`), `server.go` (one field), two existing tests whose expected
+status changed (`TestAPIInstanceStoreFailure`, `TestAPISidecarStoreFailure`), and census bookkeeping.
+Task 2 (the provision primitives it calls: `MarkHostUsed`, `ReadHostsMode`, `Record.DataKind`) was
+reviewed separately and is READY; do not re-review it.
+Authorities: the accepted spec `docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md`
+(rev 5, accepted by Paul 2026-10-26; §2 is the writer table) and the plan
+`docs/superpowers/plans/2026-10-26-nearest-region-never-reuse.md`, Task 3. Both are carried unchanged on
+this branch from `design-nearest-region-199`; treat them as fixed authorities, not unmerged work. The
+approved strings are `docs/superpowers/notes/copy/nearest-region-never-reuse.md` (S1, S2, S5, S8 used
+here). AGENTS.md on main ("Stopping rules").
+
+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: marks are create-only and never deleted; a mark followed by a failed write
+ or crash leaves the hostname refused for ever (accepted); exempt kinds are static and service; sidecars
+ always mark; attach, deploy's static first create and temporary static sites are exempt; a conflict in
+ active mode is S1 whoever wrote the mark; one console process per deployment, which reads `@mode` once.
+- This is merge A. Out of scope here, and not to be reported as missing: lifetime recovery's own marking
+ inside `allocRecordLocked` (Task 7), the activation window and admissions (Task 5), `accounts migrate`
+ (Task 10), the claims-on `hostops` writers (unreachable with claims off; spec §2), and the mode never
+ being anything but `incomplete` in production until merge B.
+- The private-storage walk and `bindEnvironmentCreate` run before the mark on purpose: the plan puts the
+ mark immediately before the persisting call, and a store walk that answers "pending approval" must not
+ burn the hostname. A store left behind by a refused create is the existing, accepted residue of
+ #412 (comment in `handleAPIInstanceCreate`).
+
+## What to check
+
+1. Every data-kind record create in `internal/console` marks before it persists anything, with lifetimes
+ off and on: instance door (all placements: plain, canary, `--region`, app region), seed (`--from`),
+ import, sidecar. Look for any create path the source-scan guard (`TestEveryCreateWriterMarksFirst`)
+ cannot see, for example a record created through another helper, package or store wrapper reachable
+ from a console door.
+2. The mark comes after the door's own record-exists read and every other refusal, so a create refused
+ for any other reason never burns its hostname. With lifetimes on, it sits after `planCreateLocked`
+ (step 2) and before `BeginAllocation`; check nothing between them can refuse.
+3. No path persists a data-kind record unmarked: a mark or mode read that fails refuses (S2) in every
+ mode; an `activating` or `invalidated` mode refuses (S8, S5). Check `hostsMode` never caches a failed
+ read and never defaults.
+4. Active mode: a conflict refuses with S1, except a create retried after its own record landed, which
+ gets the door's ordinary duplicate answer (`markBeforeCreate` reads the door's key only after a
+ conflicting mark). Check that read cannot let a create over another app's or another incarnation's
+ data through, and that a record deleted between that read and the write cannot slip a create through.
+ Two concurrent creates of one new host: exactly one may publish.
+5. Exempt creates never mark (`DataKind` false, attach first routes, temporary apps), and an exempt
+ create can never reach a data-kind record through these doors.
+6. User-visible change in `incomplete` mode: none except a bucket that cannot be written now answers 503
+ S2 instead of 502 (the plan's `TestMarkErrorRefusesInIncomplete`). Check nothing else a user sees on
+ create changed, and that no store error text reaches a response.
+7. Request budget (spec §3a, plan Global Constraints): one conditional PUT per data-kind create, one GET
+ of `@mode` per process, no per-request GET (the duplicate read only after a conflict).
+8. The witnesses go through the real doors with lifetimes off and on, and would fail without the
+ implementation (the author ran mutations removing each mark and the duplicate read; check the
+ assertions are not vacuous).
+
+## 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.