carlos / platform Public

review: region HA P2b-1 branch R1 READY

claude agent, operated by paul@keymail.dev f9eadab3081e725dc6128b67fa84ecfa02fdbeb2 parent 2801311
1 file changed, +145 −0
  • docs/superpowers/reviews/REVIEW-REGION-HA-P2B1-BRANCH-R1.md +145 −0

Intent

Human

<task-notification> <task-id>a72ee70d534d26d4b</task-id> <tool-use-id>toolu_01Pv8Ncw4TcLynTpLRB6dnw4</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/de069047-3c6a-40e7-ae66-85194f066976/tasks/a72ee70d534d26d4b.output</output-file> <status>completed</status> <summary>Agent "Census review region-ha-p2b (Opus)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Overall verdict: APPROVED.** I reviewed tip 2801311063d63616478c95d042ec16b4cc1f9815 against origin/main and both items get APPROVE. **Unit `internal/host/edgesfile.go` `edgesFileWriteClaims` (authority F,J1): APPROVE.** Lines read: edgesfile.go 334-336 (the new `NamedPools []string json:"named_pools"` field) and 955-958 (`if f.NamedPools == nil { f.NamedPools = []string{} }`, placed before the gate copy). Lines 959-1000 (gate marshal, compare, `putReplacing` to `edgesFileKey(box)`) are unchanged. The only body change replaces a nil slice with an empty one on a value copied from `ident`, which the loop builds once at arm. It adds no registry, /data, release or claim read. It adds no path, exec or query, and no input a tenant, app or box agent can name. The output stays the box's own edges-file publication, and the gate logic is untouched. The one-off rewrite the card describes is real: the stored gate held `null` and now holds `[]`, so each box writes once after the upgrade. That costs one PUT per box and changes no permissions. A search of non-test Go code finds only one reader of `named_pools`: internal/console/hacapacity.go:505-514, plus nocapacity.go:66. That is the console binary, which is out of census scope. Nothing in root or the edge reads the field, so it really is "a report the console reads for create admission, not a root decision". The F,J1 disposition still fits, and the 65 read sites in the overlay are unchanged. **Envelope `internal/host` (re-pinned to a066a530…): APPROVE.** Changed non-test code is limited to edgesfile.go: - **Import:** `internal/provision` (line 22). The package already reaches it through agent.go:3644-3666 (`provisionTickConfig`). - **`edgesFileEligibility` (1069-1085):** it now keeps the `provisionTickConfig(getenv)` result and returns a third value. That value is `cfg.Pools`, kept only where an entry is non-empty and passes `provision.ValidPool` (provision.go:910, regex `^[a-z0-9-]{0,16}$` at :877), then sorted and de-duplicated. - `cfg.Pools` comes from `ParseBoxPools(getenv("CARLOS_POOLS"))` (reconcile.go:3409-3427). That function was already called at arm before this change. - `ParseBoxPools` keeps invalid tokens, logging them, and maps the shared token to "". The new filter drops both before publication, so the published list is never wider than the reconciler's own reading. - The environment is read no more often than before, and nothing new is opened. - **`edgesFileLoop` (1165, 1188):** it takes the third value at arm and puts it on the identity. This happens once, not per tick. The CARLOS_POOLS input comes from the box's own environment, which the operator sets. No tenant, app or box agent can write it. No check, refusal, validation or argument root relies on is weakened. The shared-pool and inbound answers are computed exactly as before (1075). The test-only changes need no further review: - edgesfile_test.go: expected wire bodies now include `"named_pools":[]`, and one call site discards the third return value. - movesoffline_e2e_test.go 400 and 412: the third value is threaded through. - edgesfile_pools_test.go: its golden-file write runs only behind `*updateGoldens`. - testdata/edges-p2b-golden.json: the new golden file. **Overlay and chain:** plan14-root-reads-region-ha-p2b.tsv re-freezes the unit at authority F,J1. It appends the p2b claim and keeps the same 65 sites. The chain line takes the seal 59c08916…, the value the card shows on both sides of its seal arrow. I found nothing that would justify a REJECT. The verdict still needs recording on #280 with this tip. I didn't post it because this review was read-only.</result> <usage><subagent_tokens>56437</subagent_tokens><tool_uses>5</tool_uses><duration_ms>48360</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>ad16d333b1492548f</task-id> <tool-use-id>toolu_01LhDzw4KM8X2H5xjopJJgNj</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/de069047-3c6a-40e7-ae66-85194f066976/tasks/ad16d333b1492548f.output</output-file> <status>completed</status> <summary>Agent "Whole-branch review R1 (Opus)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Verdict: READY.** I found no P1 and no P2 problems in `6209ce43..14c6a0e5`, and no deferred minor needs fixing before merge. The full review is in `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-p2b-build/.superpowers/sdd/2026-11-04-region-ha-p2b-console/branch-review-R1.md`. That was the only file I wrote; the worktree, index and branch are unchanged. **Tests I ran** (all passed; `/tmp/g` was not writable, so they used the default TMPDIR): - **Console capacity tests:** `go test ./internal/console -run 'HACapacity|HACreateCapacity|DomainPurchaseHACapacity|RegionCapacities|CapacityCloudWatch|PlacementChooserIsScoped'` (313 s). - **Console command:** `./cmd/console -run HACapacity`. - **Host publisher:** `./internal/host -run 'EdgesNamedPools|EdgesFileRawWireBody|EdgesFileEligibility'`. - **Census:** `./internal/provision -run 'TestPlan14RootReadCensus$'`. The new census overlay and its chain entry load and pass. - **Vet:** `go vet ./internal/console ./cmd/console` is clean. **What the brief asked me to check:** - **Refuse before writing (I5):** the capacity check is called in exactly three places: `apiinstances.go:2340`, `apisidecars.go:422` and `domainattach.go:235`. The domain-purchase apex reaches it through `attachDomain`. Everything before each call only reads or refuses, so no protected write happens first. The import and seeded refusals now run before the capacity check, and the armed-region 400 now runs after it, for HA regions only. Wake, enable, restart, deploy, retry and alias doors never call it. Retry-After is set on the API, browser, instance and sidecar responses. - **Unknown is never zero (I2/I4):** a create is allowed only when at least one box is verified eligible. A complete zero needs every box classified. Malformed or missing evidence, the identity cases in R7 and the null-pools case in R8 all stay unknown. A box with `accepts_inbound=false` that serves a named pool is never counted. The metric only reports complete regions. - **One bounded observer (I3):** there is one observer per console, started from serve before the claim runtime and independent of HostClaim. Timing is 60 s / 45 s / 120 s. The S3 and CloudWatch clients make one attempt each. Each prefix gets one bounded listing and the body sizes are capped. Requests never touch S3 for capacity. - **Identity:** the AWS region, data bucket and metric destination come only from the console's capacity config, never from box files. Fixed pins, the `g-` derivation and instance uniqueness are all enforced. - **Pool publication (T0):** `named_pools` comes from the same reconciler parse and is additive. No strict decoder reads edges files, so older readers are unaffected. - **Merge fix `479c4031`:** seven unnamed `doorRefusal` struct literals became named-field literals with the same values. No behaviour changes. **P3 count: 5** (follow-ups only): 1. `haJSON` has no nesting-depth limit (`hacapacity.go:59-110`). A box-written body up to 1 MiB can push the console's stack to hundreds of MB each minute. A 10000-level cap fixes it. This is ledger P3-4, and I'd fix it first. 2. A console with only `CARLOS_REGION_METRICS=cloudwatch` set and no HA regions logs C05 as "invalid for ." and keeps logging metric failures (`hacapacity_observe.go:622`, `regioncapacity.go:65`). Check flagship's environment on the release card. 3. The set of regions checked is the HA regions plus every region in the config, where the plan says HA regions only (`hacapacity.go:161-167`). An extra config region would get a metric datum. 4. On S3, a truncated edges listing is reported as `edges_list_failed` rather than `edges_list_capped` (`hacapacity_observe.go:158`). Both refuse creates; only the diagnostic code is wrong. 5. A known `serves_shared_pool=false` exclusion produces no blocker code (`hacapacity.go:503`), so diagnostics list nothing for that box. **Deferred minors:** none must be fixed before merge. Two that matter for the release card: - The extra record GETs per HA create should be disclosed on the card. - A panicking purchase attach no longer counts toward the 10-attempt alert. Jobs recover panics, so it would retry without ever alerting; concurrent workers are still safe. The later fix is to count the attempt up front and give it back on a capacity refusal. The other minors fail safe or are test or copy gaps. The review file has the per-item table.</result> <usage><subagent_tokens>232848</subagent_tokens><tool_uses>66</tool_uses><duration_ms>1089734</duration_ms></usage> </task-notification>

Attributed to this commit: 7.22 g CO₂e (853,663 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-p2b-build, 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/reviews/REVIEW-REGION-HA-P2B1-BRANCH-R1.md b/docs/superpowers/reviews/REVIEW-REGION-HA-P2B1-BRANCH-R1.md
new file mode 100644
index 000000000..64dc7dc5d
--- /dev/null
+++ b/docs/superpowers/reviews/REVIEW-REGION-HA-P2B1-BRANCH-R1.md
@@ -0,0 +1,145 @@
+# Region HA P2b-1 whole-branch review, round 1 of 3
+
+Reviewer: independent Opus reviewer. Branch `region-ha-p2b-build`, code under review
+`6209ce43..14c6a0e5` (tip 28013110 adds only the brief). Read-only; no tree changes.
+
+## What I checked and ran
+
+- Read the binding extract `p2b1-design.md`, the ledger rulings R1-R10, the approved
+ copy, and the code: `hacapacity.go`, `hacapacity_observe.go`, `regioncapacity.go`,
+ `awsregionmetric.go`, `nocapacity.go`, `hostclaimops.go`, `cmd/console/main.go`,
+ the create doors in `apiinstances.go`, `apisidecars.go`, `domainattach.go`,
+ `domainbuy.go`, the browser/API attach response paths (`apidomains.go:465-470`,
+ `appdomains.go:150-157`), and T0's `internal/host/edgesfile.go`.
+- Confirmed by diff filter that every other touched console file
+ (lifetimes*, policy*, team*, rootfs*, seed*, apiinstanceimport/seed, domain*,
+ egressfleet, fleetfloor, etc.) changes only positional `doorRefusal` literals to
+ keyed ones.
+- Focused runs (default TMPDIR; /tmp/g not writable):
+ - `go test ./internal/console -run 'HACapacity|HACreateCapacity|DomainPurchaseHACapacity|RegionCapacities|CapacityCloudWatch|PlacementChooserIsScoped'` ok (313 s).
+ - `go test ./cmd/console -run HACapacity` ok.
+ - `go test ./internal/host -run 'EdgesNamedPools|EdgesFileRawWireBody|EdgesFileEligibility'` ok.
+ - `go test ./internal/provision -run 'TestPlan14RootReadCensus$'` ok (overlay
+ `plan14-root-reads-region-ha-p2b.tsv` and chain entry load).
+ - `go vet ./internal/console ./cmd/console` clean.
+
+## Checklist results
+
+1. **I5 end to end.** `requireHACreateCapacity` has exactly three callers
+ (`apiinstances.go:2340`, `apisidecars.go:422`, `domainattach.go:235`); the
+ purchase apex reaches it through `attachDomain` (`domainbuy.go:579`). In the
+ instance door every check that precedes capacity is a read or a refusal
+ (`doorLifetime`, `environmentBindingRefusal`, `storeCeiling`, `admitDataCreate`,
+ `hostsTargetRefusal`, `checkRunningThings`, leftover rail); the first protected
+ writes (`MarkFleetBoxLabelled`, store walk, claim/lifetime/record writers,
+ `createFrom`/`createImport`) all follow `:2340`. The permanent HA import and
+ seeded-placement refusals run before capacity (`:2330-2339`). The deferred
+ armed-region 400 runs after capacity only for HA regions (`:2010`, `:2345`).
+ Sidecar: capacity after duplicate/paused/shape/leftover, before
+ `beginClaimCreate`/`createSidecarMarked`. First route: after `heldElsewhere`,
+ before the claims/lifetimes/plain branch and before any pending claim write;
+ existing-route aliases return at `:176-195` without the gate, and a standing
+ first-route record skips it (`:229-237`). Retry-After is stamped on API
+ (`apidomains.go:467`), browser (`appdomains.go:156`), instance and sidecar doors.
+ No wake/enable/restart/deploy/retry path calls the helper (grep). The precedence,
+ wake, pending-proof, binding, seeded/private-storage and rootfs witnesses use the
+ real `observe` over fixture bytes, not an injected verdict.
+2. **I2/I4.** `Decide` allows only on a counted positive witness; complete-zero needs
+ every file classified (`hacapacity.go:285-307`). Malformed bodies, unknown
+ versions, null placement, missing identity/status, conflicting refs/instances,
+ unverifiable identity (R7) and missing/null pools (R8) are unknown. Known
+ exclusions are limited to validated scope facts, self-stale edges, stale status,
+ proven-invalid/unbound identity, explicit role/admitted/drained values and
+ boxchoice headroom. Pool narrowing requires `accepts_inbound=true` plus
+ `serves_shared_pool` or `named_pools` membership (`:490-518`), so an inbound=none
+ box with a named pool never admits (T0 carry). Absent headroom totals exclude via
+ `boxchoice.Placeable` (`policy.go:67-68`). Unknown pages nothing; only complete-zero
+ reaches `noRoom`. The metric emits only `Complete` regions (`regioncapacity.go:31-40`).
+3. **I3.** One observer per console via `sync.Once` (`hacapacity_observe.go:618`,
+ `regioncapacity.go:62`), started from serve before `ConfigureClaimRuntime`
+ (`main.go:649` vs `:726`) and independent of HostClaim; the nested start is gone
+ from `StartClaimRecoveryPass`. Requests only `Load()` the atomic generation. 60 s
+ ticker, 45 s deadline, 120 s expiry from pass start, failure replaces success
+ immediately (`:571-592`). S3 client and CloudWatch client use `NopRetryer` with
+ one attempt. One LIST per prefix (201 edges keys; 1000 raw status entries with
+ truncation), 1 MiB edges/status bodies, 64 KiB identity bodies, 200-key caps, 24 h
+ horizon before the cap, no second page, no `ListMod` fallback (`haStatusView`
+ hides it).
+4. **Identity binding.** Identity is verified with the configured AWS region and
+ `Config.AWSAccount`; fixed pins bind region and instance; non-pinned refs must
+ equal the exact `g-` derivation, else unbound (C11); duplicate instances across
+ refs are unknown. AWS region, data bucket and CloudWatch destination come only
+ from `CONSOLE_HA_CAPACITY_CONFIG`; a file's own `region` that disagrees is unknown,
+ never a destination.
+5. **T0.** `named_pools` comes from the same `provisionTickConfig` parse as
+ `serves_shared_pool`, filtered to nonempty `ValidPool` names, sorted, unique,
+ always an array (`edgesfile.go:953-958`, `:1073-1085`). No strict decoder reads
+ edges files, so the field is additive. Census overlay loads and passes.
+6. **Merge fix 479c4031.** Seven positional-to-keyed `doorRefusal` literals in
+ `appcopies.go` and `copiespublication.go`; identical values; no behaviour change.
+
+## Findings
+
+### P1
+
+None.
+
+### P2
+
+None.
+
+### P3 (follow-up list; never a reason for another round)
+
+- **P3-1, T1, I3 (bounded observation).** `haJSON` recurses once per nesting level
+ with no depth cap (`internal/console/hacapacity.go:59-110`); it runs before
+ `json.Unmarshal` (which caps depth at 10000) on every edges/status body up to 1 MiB
+ (`hacapacity_observe.go:240`, `:381`). A box-written body of ~1M `[` drives a
+ deep goroutine stack (hundreds of MB) in the console each minute. Fix: refuse
+ depth > 10000 in `haJSON`. This is ledger P3-4; it is the deferred minor I would
+ take first.
+- **P3-2, T2, copy/config.** A metrics-only console (`CARLOS_REGION_METRICS=cloudwatch`,
+ no `CONSOLE_HA_REGIONS`) starts the observer, fails config and logs C05 with an
+ empty list ("invalid for ."), then logs metric failures every tenth pass
+ (`hacapacity_observe.go:622-623`, `regioncapacity.go:65-69`). Previously the metric
+ only armed with `RegionHA` plus claims. Fix: skip the observer and metric when no
+ HA regions are configured, or log a distinct line. Check flagship's env on the card.
+- **P3-3, T1, D2.** The universe is `CONSOLE_HA_REGIONS` united with every config
+ region (`hacapacity.go:161-167`); the plan says exactly `CONSOLE_HA_REGIONS`. An
+ extra config region gets a metric datum (`regioncapacity.go:35`). Fix: reject
+ config regions outside `CONSOLE_HA_REGIONS`, or exclude them from the universe.
+- **P3-4, T1, diagnostics.** On S3, more than 200 edges keys returns
+ `IsTruncated=true` and is reported as `edges_list_failed`
+ (`hacapacity_observe.go:158-159`), so `edges_list_capped` (`:307-309`) only fires
+ at exactly 201 keys. Both are unknown; the dev card's cap remedy keys off the code.
+ Fix: return a typed capped error on truncation.
+- **P3-5, T1, diagnostics.** A known `serves_shared_pool=false` exclusion returns an
+ empty code (`hacapacity.go:503`), so `CreateBlockers` lists nothing for that file
+ (`:330`). Fix: return `shared_pool_excluded`.
+
+## Deferred-minor triage (ledger-minors-rulings.md)
+
+None must be fixed before merge. Reasons:
+
+| Minor | Triage |
+|---|---|
+| T0 one-off PUT per box | Stated in the census claim; keep for the card/runbook. Follow-up. |
+| T0 golden role fields via fake RoleSource | Accepted; real seam. Follow-up none. |
+| T1 P3-4 haJSON depth | Follow-up, first in line (P3-1 above). Bounded by the 1 MiB body, written by root-run box agents; no crash at that bound, but a large transient stack. |
+| T1 P3-5 unbounded shutdown wait | Follow-up. Both SDK clients honour the cancelled context; DirStore reads are local. |
+| T1 P3-6 exact-key edges reads | Follow-up. Only a non-Go writer or a hostile box emits case-variant keys; the effect needs a hostile publisher who could already lie about headroom. |
+| T1 P3-7 unknown-scope ref conflicts | Follow-up; fail-safe. |
+| T1 P3-8 empty secrets_key_fp unknown | Follow-up; fail-safe (refuses, never admits). Card: verify every HA box publishes a fingerprint. |
+| T1 P3-9 config limit constant name | Follow-up; cosmetic. |
+| T1 test gap: identity record absent | Follow-up; code path is `identity_missing` = unknown (`hacapacity_observe.go:414-416`). |
+| T1 dirPage scratch toward bound, C11 flap, empty signature excluded, DirStore subdirs | Follow-up; each fail-safe or within R7. |
+| T3 extra GETs per HA create | Follow-up; disclose on the card (`apiinstances.go:2281`, `apisidecars.go:391`, `domainattach.go:229`). Record reads, not capacity reads. |
+| T3 400 region list with nil cands | Follow-up; message completeness only in a rare app-derived case. |
+| T3 checkPlacement reads under lockAccount | Follow-up; latency only. |
+| T3 reattach tested plain-only, auth 404 not byte-compared | Follow-up test gaps. |
+| T3 claims-mode 409 behind capacity | Design-mandated; no action. |
+| T3 purchase attach panic not counted | Follow-up. Jobs recover panics (`jobs.go:234`), so a panicking attach would retry without the 10-attempt alert; the revision CAS still prevents concurrent loss. Fix later by counting up front and refunding capacity refusals. |
+| T4 copy: no alias/reattach sentence | Copy follow-up; no behaviour gap. |
+
+## Verdict
+
+**READY**