carlos / platform Public

reviews: P2a whole-branch review round 1 (Opus, READY)

No P1 or P2; six P3s on the follow-up list. Review closed under
stopping rule 1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 32baf6fdaaf938809d3756ea9b4ee9ae50fa5342 parent 6c4731c
1 file changed, +72 −0
  • docs/superpowers/reviews/region-ha-p2a-branch-review-r1.md +72 −0

CI failed — run details

diff --git a/docs/superpowers/reviews/region-ha-p2a-branch-review-r1.md b/docs/superpowers/reviews/region-ha-p2a-branch-review-r1.md
new file mode 100644
index 000000000..85f613c8f
--- /dev/null
+++ b/docs/superpowers/reviews/region-ha-p2a-branch-review-r1.md
@@ -0,0 +1,72 @@
+# Region HA P2a whole-branch review, round 1
+
+Reviewer: independent Opus reviewer, 2026-11-01. Brief: docs/superpowers/reviews/REVIEW-BRIEF-region-ha-p2a-branch.md (6c4731c8).
+Under review: b0b4164a..a991263c (Tasks 1-4). Read: the brief, plan Tasks 1-4, plan-context.md, progress.md, the four task reports, and the full review diff in passes.
+
+## Verification run
+
+- Checkout HEAD 6c4731c8 (a991263c plus the brief commit), worktree clean.
+- `nice -n 19 go test ./internal/console -run 'TestHAP2|TestHACreate|TestHAMixedMove|TestHAImportFlag|TestHAPlace|TestHATransfer|TestRegionIngress|TestConfiguredIngress|TestIngressDoesNotWidenProxyTrust|TestCreateStampsBornHA|TestStaticRecordIsNotStamped|TestRootfsCreateIsNeverBornHA|TestDomainGuidance|TestPlaceRefuses|TestMoveDoorsRefuseHA' -count=1`: ok (67 s).
+- `go test ./internal/provision -run TestPlan9B8 -count=1`: ok (record-write census with the P2a re-pins).
+- `go test ./cmd/console -run TestRegionIngress -count=1`: ok.
+- Cross-compile: `GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ./internal/console` ok; darwin/amd64 `go vet ./internal/console` ok. The root CLI imports internal/console only from e2e test files; regioningress.go and hacreate.go use only portable packages.
+
+## What I checked outside the diff (named risks)
+
+1. Production SeedData supports the bounded proof. If `firstHALeftover`'s `release.PageLister` assertion failed on the production store, every home HA create would get F3/503. `cmd/console/main.go:446-449` builds SeedData with `release.NewS3StoreIn` wrapped by `TimeS3Store`, which returns the same `*release.S3Store` (`internal/console/perfs3.go:20`). `*S3Store` asserts PageLister (`internal/release/store.go:395`), and `ListPage` with limit 1 is one ListObjectsV2 with MaxKeys=1 (`internal/release/store.go:1087-1090`). The Task 4 witness drives this exact type through a loopback S3 transport. No risk.
+2. Proxy trust. `trustsProxy` reads only `s.cfg.EdgeIPs` (`internal/console/authcli.go:1210`). `cmd/console/main.go:516` still sets EdgeIPs from `edgeIPs()`, and RegionIngress is a separate field. Nothing merges the two. No risk.
+3. Fold bypass. The only caller of `foldedEdgeIPs` is `edgeIPs` (`internal/console/server.go:1591`), which returns early in configured mode. Every guidance sink, including the app-facing `deployment` capability block (`domainstate.go:294`), catch-all views and remote instances, goes through `dnsTargets`/`edgeIPs`. The only remaining EIP emitters are the placements box rows (`apiplacements.go:158,198`), which the configured HA refusal precedes. No risk for HA regions.
+4. Startup ordering. `serve()` starts no listener before the `regionIngress` parse (`cmd/console/main.go:449`); an invalid entry calls `log.Fatal` before `NewServer`. Empty tokens such as `"1.2.3.4,,"` also fail. No fallback path exists.
+5. Pending regional claims. `configuredRegionalGuidance` overwrites `Detail` in legacy mode too (see P3-1). The PUT never writes a pending claim (`apiplacements.go:631`), and claimState returns `regionalStateDetail` for every non-pending regional claim (`domainstate.go:176-177`), so the overwrite is byte-identical to main for every claim main can write.
+6. Place walk keys. `ListRecordsStrictJudged` drops LifetimeStale records from the preflight. Those hosts are absent from `noops`, so they still take SetRecordRegion and its CAS, as on main. `SetRecordRegion`'s HA, seed and rootfs CAS still guards every changed raw region (`internal/provision/provision.go:1042-1050`), and provision.go is unchanged.
+7. Phase-1 door writes before the helper. Between `moveOperatorGate` and `haTransferRegion` (`apiinstancemove.go:586-630`) there are only refusals, `readJSON` and validation. No write.
+
+## Checklist against the brief
+
+1. **Ingress and trust.** Holds (see 2-4 above). In configured mode `edgeIPs` is PLATFORM_EDGE_IPS followed by RegionIngress, deduplicated. Steering is suppressed and only A records are offered (review diff lines 3932-3935, `view.go` domainGuidance; `server.go:1569-1572`). The parser accepts only IP literals, canonicalizes and deduplicates them, and rejects the whole value if any entry is invalid.
+2. **Placements door.** GET: `refuseConfiguredPlacements` runs after domainsGate, the byte-identical 404 and `teamClaimSnapshotInScope`, and before the snapshot or box reads (`apiplacements.go:97`). A blocked claim gets 409/I6 with no placements, member or ready payload. A read error gets 503/I7. `ErrNotExist` falls through: regional claims to the region check, single-mode claims to main's view. PUT: the guard sits in `placementsBindings` at step 3, judges only the proposed set (`rec.HA || haRegion(b.Region)`), and runs before step 4's claim read, so it reveals nothing about another owner's pending claim. It also precedes every lock, claim, index or serial write.
+3. **Creates.** F1 (`apiinstances.go:2186`) runs after ValidateShape and before env binding, seed/import dispatch and every write. It precedes the duplicate read, which the plan sets as its position (Task 2 Step 3). It is a pure shape check and is unreachable over HTTP (accepted F1 ruling), so it cannot shadow a retry's duplicate answer in practice; see P3-4. F5, F3 and F2 run inside `leftoverReplicaRefusal`, after `exists()` returns the door's own duplicate or read-failed answer and before every write. The whole-prefix proof is one `ListPage(prefix+"/", "", 1)`. Only a fixed class (lock, files, replica or other) reaches the response. Non-HA and sidecar callers keep `hostHoldsReplicaData` with both prefixes. HAData proof keeps the 10 move-staging LISTs (1G+11L).
+4. **Moves, place, imports.** `haTransferRegion` checks in the plan's order: immutable flag, normalized no-op, static, source, destination (`seedmove.go` haTransferRegion, review diff lines 3653-3671). Legacy, Phase-1, offline stage and offline start (staged start goes through `offlineBeginChecks` again) all call it after target validation and before any write. Cut, abort, resolve and import commit/abort are untouched. `placeAppTarget` checks only changed records. It skips SetRecordRegion only for hosts proven to be no-ops in the strict preflight. Hosts that newly appear take SetRecordRegion and its CAS, witnessed by the retained race test and the "skip records absent from the no-op set" mutation. `refuseHAImport` now checks `rec.HA || haRegion(rec.Region)` at begin, upload and stopped.
+5. **Gate order.** Unchanged on every touched door. All new refusals follow the existing session, CSRF, owner/member 404, team-scope and fresh-auth gates. No host, bucket, key or box detail is emitted before authorization. The F2 and F3 tests assert that keys, bodies, bucket and SDK error text are absent.
+6. **Witnesses.** `hap2_wiring_test.go` drives real `S3Store`/`TimeS3Store` instances through a loopback endpoint behind the NewServer fixture's router. It counts every physical attempt, including failed ones. The ten omission mutations (Task 4), eight (Task 1), nine (Task 3) and eight (Task 2) cover each new gate. F1's limit is the accepted predicate plus ordering guard.
+7. **Budget (C6).** No new loop. Configured DNS selection makes 0 S3 requests. Placements and list sinks read at most 8 target records per regional claim, memoized per request, with no reads for single-mode list rows. The HA create proof is 1L, replacing 10L.
+8. **Cross-compile.** Clean (see Verification run).
+
+## Findings
+
+### P1
+
+None.
+
+### P2
+
+None.
+
+### P3 (follow-up list; not a reason for another round)
+
+- **P3-1, Task 1, apidomains.go:1457 and appsettings.go:768.** `configuredRegionalGuidance` returns `regionalStateDetail` in unset-ingress mode too, overwriting `claimState`'s Detail. That is byte-identical today only because regional claims are never pending (`apiplacements.go:631`). If a pending regional claim ever exists, its "Prove you control this hostname" detail would be replaced. Fix: return `""` for detail when `len(s.cfg.RegionIngress)==0`, and keep the caller's Detail when the returned detail is empty. Family: legacy-mode preservation.
+- **P3-2, Task 1, apiplacements.go:1042.** `configuredPlacementGuidance` calls `s.edgeIPs(context.Background())`. It does no I/O, because it is reached only in configured mode, but it would detach a fold refresh from the request if it were ever called in legacy mode. Pass the caller's ctx. Family: request-bounded reads.
+- **P3-3, Task 1, regioningress.go:22.** An empty token (`"a,,b"`) produces the message " is not a valid IP address." with nothing named. Quote the token or say "an empty entry". Family: operator diagnostics.
+- **P3-4, brief vs plan, apiinstances.go:2186.** Brief item 3 says F1 runs after the door's duplicate answer, but the plan (Task 2 Step 3) places it after ValidateShape, before the duplicate read. The code follows the plan. Today this is unobservable: Hibernate=false cannot be expressed over HTTP. If a hibernate field is ever added, a retry of a pre-switch non-hibernating record would get 400 F1 instead of the duplicate 409. Note it for the API change. Family: retry/duplicate precedence.
+- **P3-5, Task 3, fleets.go:1000-1008.** Besides the deferred host-key issue, a record that was a no-op at preflight and is moved by a concurrent non-app-locked writer before the walk is now skipped instead of re-stamped. The window is one request, and the CAS guarded the main path either way. A comment is enough. Family: preflight/walk consistency.
+- **P3-6, docs, cli.md:2935.** The new `carlos move` paragraph sits before the section's opening sentence ("Moves one instance to another region."), the same placement fault as the deferred cli.md:1015 minor. Move both below their section intros. Family: docs structure.
+
+## Triage of deferred minors (progress.md)
+
+| Deferred minor | Must fix before merge? | Reason |
+|---|---|---|
+| T2 cli.md D3 third paragraph describes Task 3 refusals | No (resolved) | Task 3 has landed on this branch, so the text is now accurate. |
+| T2 cli.md:1015 D3 before section intro | No | Docs ordering only; fix with P3-6. |
+| T2 hacreate_test.go:362 ordering guard cut at next func | No | Test robustness; the guard passes and the F1 mutation was caught. |
+| T2 hacreate.go:47 `%04x/` match is S3-layout only | No | Any other layout still refuses as "other" (fail closed); add the comment. |
+| T2 drill note: live role s3:ListBucket on whole `instances/<host>/` | No (drill gate) | Fails closed as F3/503. It must be on the Task 4 Step 2 approval card. |
+| T3 fleets.go:885 no-op set keyed by body Host, walk by key host | No | Only matters for a record whose body Host differs from its key. A mismatch either takes SetRecordRegion and its CAS (fail closed) or, with a corrupt pair, skips one record's re-stamp. Keying by the listed host is a cheap follow-up. |
+| T3 seedmove.go:33 homeRegionIn vs empty HomeRegion on host-claim console | No | Host-claim mode is shelved and P2a does not run claim consoles with HA regions. Same note applies to HAData's F5 check. |
+| T3 invalid shape 400 before HA 409 | No | The plan mandates this order, and both answers refuse before writes. |
+| T3 report wording on static exemption scope | No | Report-only; the HTTP move doors' kind refusal precedes the helper. |
+
+None must be fixed before merge.
+
+## Verdict
+
+**READY**: no P1 and no P2.