carlos / platform Public

region HA P3a: whole-branch review R1 READY, census approved

Opus round 1 of 3: 0 P1, 0 P2, 3 P3 (follow-up list). Census: all 31
changed units, 29 dispositions and 14 envelopes approved at 2c67ce56.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 7d2c3832c5cf8d118404050e385bfe7af134127a parent c9eb235
1 file changed, +177 −0
  • docs/superpowers/reviews/REVIEW-REGION-HA-P3A-BRANCH-R1.md +177 −0

CI passed — run details

Intent

Human

<task-notification> <task-id>a763aad2a29afbd4d</task-id> <tool-use-id>toolu_01F7kpyRh4gD89Pk4NFBzx4N</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/6cb8c43c-d494-478a-8f04-1067486903df/tasks/a763aad2a29afbd4d.output</output-file> <status>completed</status> <summary>Agent "Opus whole-branch review P3a R1" 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.** Round 1 of 3 found no P1 and no P2, so under stopping rule 1 the whole-branch review is closed. - **Counts:** 0 P1, 0 P2, 3 P3 (follow-up list only, not a reason for another round): - P3-1 (provider boundary, "new core imports no AWS SDK"): `internal/boxroles` imports no AWS package itself, but it pulls in the AWS S3 SDK through `internal/release` for the `Store` interface. No import test covers it, unlike `groupadmission`. - P3-2 (E1, fixed box protection): the plan gate passes a create in another module whose instance or network interface id is still unknown at plan time, for example an `aws_ec2_instance_state` fed by a data-source read deferred to apply. - P3-3 (I4/S1, refuse up front): an opted-in box with no activator config stays closed forever. It does fail closed, but the only sign is the waiting log naming the missing termination fact; there is no refusal line. - **I4/A1 checks:** every start and acquire path I found reaches the admission gate. That includes the departure importer's `AdoptHost`, which is held back through `haContained` → `nestedReady`. Health stays 503 until admission. Admission closes before shutdown, and all four startup facts come only from real successes. - **Merge from main:** `doWakeOnce` runs both the admission refusal and main's demo refusal, and none of main's new code gets around the gate. - **Switch-off:** flagship boxes see no change: same edges-file bytes, same metric input, no chronyc call, no new reads. - **Copy:** every new string matches `copy-approved.md`, with no em or en dashes. - **Census:** I approved all 31 changed units, all 29 new or re-read dispositions and all 14 re-pinned envelopes. Nothing is rejected. The two census tests pass at the tip. The verdict still needs recording on #280 (reviewer Opus, tip 2c67ce56). - **Tests run:** the targeted tests for the touched packages and the plan-gate Python tests (26) all passed. I committed nothing and changed no other files. Findings are in `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-p3/docs/superpowers/reviews/REVIEW-REGION-HA-P3A-BRANCH-R1.md`.</result> <usage><subagent_tokens>266065</subagent_tokens><tool_uses>96</tool_uses><duration_ms>758330</duration_ms></usage> </task-notification>

Attributed to this commit: 13.9 g CO₂e (1,695,097 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-p3-group, 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-P3A-BRANCH-R1.md b/docs/superpowers/reviews/REVIEW-REGION-HA-P3A-BRANCH-R1.md
new file mode 100644
index 000000000..82a5abe99
--- /dev/null
+++ b/docs/superpowers/reviews/REVIEW-REGION-HA-P3A-BRANCH-R1.md
@@ -0,0 +1,177 @@
+# Review: region HA P3a branch (whole branch + census), round 1 of 3
+
+Reviewer: Opus (implementer Astra). Tip under review `2c67ce564c7ee7b73e72c9ac72b280a578748f67`;
+diff `origin/main..2c67ce56` (merge base `f18da984`, origin/main is an ancestor). Brief
+`docs/superpowers/reviews/REVIEW-BRIEF-REGION-HA-P3A-BRANCH.md` at c9eb235a.
+
+## Verdict
+
+**READY.** 0 P1, 0 P2, 3 P3. Census: approve all 31 changed units, all 29 new or re-read
+dispositions and all 14 re-pinned envelopes; no rejects.
+
+Closed task findings and the P3 follow-ups in `task-{1,2,3}-review-opus.md` were not re-raised.
+The namespace-withdrawal cut, H4 election/cold-wake exclusion and the "closed box's names stay
+its own" ruling were taken as fixed.
+
+## What I ran
+
+- `go test ./internal/provision -run 'TestPlan14RootReadCensus$|TestCensusScopeIsTheRootBinary' -count=1`: ok.
+- `go test ./internal/groupadmission ./internal/boxroles ./internal/edgesfile ./internal/release -run 'Admission|Role|BoxRole|ChangeScope' -count=1`: ok.
+- `go test ./internal/edge ./internal/activator ./internal/host -run 'Admission|BoxRole|RolePublication|Booting|...'` and
+ `./internal/host -run 'TestPreAdmission|TestAdmission|TestGroupMetric|TestRole'` (47 named tests): all PASS.
+- `python3 -m unittest check_region_group_plan_test group_alarm_plan_test` (from `scripts/`): 26 OK.
+- `go list -deps ./internal/groupadmission ./internal/boxroles | grep aws` (see P3-1).
+- Added lines grep for U+2014/U+2013 outside Markdown: none.
+
+## Checks against the brief
+
+1. **I4/A1, admission before service.** Every tenant start path I could find reaches the gate:
+ `Service.begin` (activator.go:1725, 1757-1766), `doWakeOnce` top and before `Acquire` (2455-2461, 2776),
+ `startSidecar` (3550), `WakeWorker` (3957, 3982), `respawnWorkerLocked` (4226), `RunCmd` (cmd.go:722),
+ `startGen`/`startGenExe`, `startWorker`, and in the backend `Acquire`, `Start`, `startGenFrom`,
+ `StartSidecar`, `StartWorkerStaged`, `startSidecarUnitFrom`, `StartCmd`, the spawn hooks
+ (`admissionBefore` in both cgroup spawners) and `nestedReady`. The duty importer's `AdoptHost`
+ (haadopt.go:114) takes `lease.AcquireHAForDuty` directly, but only after `haContained` ->
+ `nestedReady` -> `tenantStartRefusal` (hawake.go:161, backend_exec.go:3018), so a pre-admission
+ departure import is Deferred. Schedules: `Skip` and the `WithDuty` wrapper (schedule_wiring.go:90-109).
+ Workers: boot pass waits on `opened` (group_admission.go:195-213). Holder header: `admissionResponse`
+ deletes it. Health: `lbHealthAnswer` answers 503 "Not ready to receive traffic." until `TenantAdmitted`
+ (edge/lbhealth.go:38), then the six `lbhealth` conditions; `Admit` itself requires `Failing()` empty
+ (group_admission.go:140). `SetHosting(true)` before `Admit` (132) is internal only; the health answer
+ stays 503 until admitted. Close before shutdown: `e.closeTenantAdmission()` at edge.go:4528/4720 before
+ drain, `Service.Shutdown` (6050), `defer admission.Close()` and agent.go:1183. Facts: EnvLoaded after a
+ successful `armBoxRoles`; Reconciled only on an error-free full pass with a complete departure inventory
+ (agent.go:2002-2004); RolePublished only from a successful booting write (`EdgesPublished`,
+ edgesfile.go:995); TerminationStarted only from `life.Started()` (group_admission.go:121-127).
+2. **Switch-off.** `RoleSource` nil -> `snapshotBoxRole` returns the file unchanged and `dueWithRole`
+ uses the same key; the three new fields are `omitempty`; `edgesChangeKey(key, ...)` is `fp` at that
+ point. `admissionMetricsFromEnv` returns before any read or chronyc when the flag is unset; memwatch
+ input is unchanged (`TestAdmissionFlagshipMetricBytes`). Worker boot pass runs immediately with a nil
+ admission. `e.tenantAdmission()` falls back to the activator, whose `TenantAdmitted` is true with nil
+ callbacks. `ExactHome`/`lookupHome` only change for a present non-dial exact entry, which a switch-off
+ fold never produces (homemap.go:876-896). No new store read on switch-off; the inventory `Snapshot()`
+ per reconcile is the known Task 3 P3-1.
+3. **R1/B1.** Own record wins, then regional, then Serve; any error (including a `booting` body) is
+ unknown, `apply(r.role,false)` closes starts (boxroles.go:66-77, roles.go:50-68). Two GETs always.
+ `ReadGate` backstop with jitter; reads ride `fastTick` (agent.go:3004), no new loop; backoff 5-60 s.
+4. **H4.** `HomeEligible` gates election (homeelect.go:187), the edge fold's dial (homemap.go:897),
+ `localDenied` (wakeplacement.go:40), `BoxChoice` and the console serving readers. A held exact entry
+ stops the star fallback and answers 503 with no holder (homemap.go:1069-1093, edge.go:2008, 4106).
+ Collision with an admitted peer: the dial target wins (`HomeBeats` on `Dial`).
+5. **E1/S1.** Gate refuses fixed updates/deletes not allow-listed, any change whose values name a fixed
+ identity except target-group attachment create/delete, guarded moves, protected EIP delete/replace,
+ ASG decreases and unknowns on guarded rows. Ingress alarms use NLB/TG ARN suffixes and the regional
+ Deployment+Region series; none names an instance id. See P3-2 for a residual unknown-value gap.
+6. **Merge.** `doWakeOnce` runs the admission refusal and then `demoWakeRefusal` (activator.go:2455-2470).
+ Demo restores (`restoreDemoLocal`) and seed placement run inside the gated wake; the demo build worker
+ needs fleet box mode and starts no tenant. Region HA follow-ups (`hatakeover`, `haadopt`) acquire only
+ behind `haContained`. Managed fleets 2a is fake-only and off.
+7. **Provider boundary.** `groupadmission` imports no AWS package, directly or transitively, and has an
+ import test. `boxroles` imports none directly but see P3-1. Cross-compile logs for the cut fix are empty.
+8. **Copy.** Every new string in code and tofu matches `copy-approved.md` verbatim; c3.start.refused and
+ c4.eip.protected are approved but unused. No em or en dashes.
+
+## Findings
+
+### P1
+
+None.
+
+### P2
+
+None.
+
+### P3
+
+**P3-1 (Task 2; fault family: P1 provider boundary / H26, "new core imports no AWS SDK").**
+`internal/boxroles/roles.go:15` imports `internal/release` for the `Store` interface, and
+`go list -deps ./internal/boxroles` pulls in `aws-sdk-go-v2/service/s3`, `aws-sdk-go-v2/config` and
+`internal/rootaws`. `groupadmission` has `TestAdmissionCoreImports`; `boxroles` has no equivalent, so the
+plan's build-time import assertion does not cover it. No failure today (it builds everywhere), but the
+"new core" is not SDK-free. Fix: give `boxroles.Read` a one-method getter
+(`Get(ctx, key) ([]byte, string, error)`), drop the `release` import, and assert
+`go list -deps` has no `aws` path for both packages.
+
+**P3-2 (Task 1; fault family: E1 fixed box protection).** `scripts/check-region-group-plan.py:346-356`
+decides `related` from known strings only; an unknown value marks a create as related only for
+`aws_eip_association` and same-module host IAM. A create in another module of a type that targets an
+instance or ENI (`aws_ec2_instance_state`, `aws_volume_attachment`, `aws_network_interface_attachment`)
+whose `instance_id` is unknown at plan time (for example fed by a deferred data-source read) passes.
+Low likelihood; the fixed id is normally known. Fix: treat `after_unknown` true at
+`instance_id`, `network_interface_id`, `role`, `allocation_id` as related on any create.
+
+**P3-3 (Task 3; fault family: I4/S1 refuse up front).** With `CARLOS_GROUP_ADMISSION=1` and no activator
+config (`cfg == nil`, agent.go:328/439), `wireAgentAdmission` never binds a Service and departures never
+arm, so the box stays closed forever. It fails closed and the throttled waiting log names
+`TerminationStarted`, but there is no configuration refusal line. Fix: refuse in `newFixedAdmission` when
+the hibernate bucket is unset, with a refusal string through the copy sweep.
+
+## Census verdicts
+
+Card `docs/superpowers/notes/census-proposal-region-ha-p3a.md`, overlay
+`internal/provision/testdata/plan14-root-reads-region-ha-p3a.tsv`, claims
+`docs/superpowers/notes/census-region-ha-p3a-claims.tsv`; seal cfb026f1... -> f44d209a..., chain line added.
+`TestPlan14RootReadCensus` and `TestCensusScopeIsTheRootBinary` pass at the tip.
+
+Common basis for the activator/edge/schedule units: each added site passes the whole Route to an
+in-memory predicate (`tenantStartRefusal`, `TenantAdmissionExempt`, `admissionRefuses`) that can only
+refuse; no file, store or socket read is added, and nil callbacks leave the body's behaviour unchanged.
+
+| unit | class | verdict | lines read |
+|---|---|---|---|
+| activator.go `Service.serveWakeError` | body | APPROVE: refusal response only, deletes holder | activator.go:6398-6407, edge/group_admission.go:24-37 |
+| activator.go `type Service` | body | APPROVE: five callback fields, set before Start | activator.go:1262-1266, host/group_admission.go:52-62 |
+| claimwake.go `Service.doClaimWake` | body | APPROVE: `ownedLocked` -> `startOwnedLocked` (adds refusal) | claimwake.go:344, activator/group_admission.go:36-41 |
+| rootfsworkers.go `installRootfsWorkerLocked` | body | APPROVE: same swap | rootfsworkers.go:372 |
+| edge.go `RunWithActivatorReady` | body | APPROVE: closes admission before drain | edge.go:4528, 4720 |
+| agent.go `fastTick` | body | APPROVE: role pass on the existing tick, existing store | agent.go:3004, host/boxroles.go:53-89 |
+| edgesfile.go `edgesFileWriteClaims` | body | APPROVE: role fields from one snapshot, forced first write, ack after success | edgesfile.go:955, 978, 994-996 |
+| activator.go `WakeWorker` | sites | APPROVE | 3957-3959, 3982-3985 |
+| activator.go `begin` | sites | APPROVE | 1725-1727, 1757-1766 |
+| activator.go `doWakeOnce` | sites | APPROVE: admission then demo refusal | 2455-2470, 2776-2778 |
+| activator.go `respawnWorkerLocked` | sites | APPROVE | 4226-4231, 4253 |
+| activator.go `startSidecar` | sites | APPROVE | 3550-3552, 3557 |
+| backend_exec.go `Acquire` | sites | APPROVE: refusal before AdmitConfig/lease | 810-812 |
+| backend_exec.go `Start` | sites | APPROVE | 2083-2086 |
+| backend_exec.go `StartSidecar` | sites | APPROVE | 3285-3288 |
+| backend_exec.go `StartWorkerStaged` | sites | APPROVE | 3424-3427 |
+| backend_exec.go `spawnInCgroupGated` | sites | APPROVE: hook wrapped, claim refusal unchanged | 563 |
+| backend_exec.go `startGenFrom` | sites | APPROVE | 2179-2182 |
+| backend_exec.go `startSidecarUnitFrom` | sites | APPROVE: refusal before root is asked | 3577-3580 |
+| backend_rootfs.go `LaunchRootfsWorker` | sites | APPROVE: context only | 497 |
+| backend_rootfs.go `StartRelease` | sites | APPROVE: context only | 177 |
+| cmd.go `RunCmd` | sites | APPROVE | cmd.go:722-724 |
+| cmdunit.go `StartCmd` | sites | APPROVE: refusal at entry and after launch write | cmdunit.go:390-393, 466-468 |
+| containment.go `spawnInCgroupAtTier` | sites | APPROVE | containment.go:247 |
+| genservice.go `startGen` / `startGenExe` | sites | APPROVE (2 units) | genservice.go:24-26, 46-48 |
+| hawake.go `haSpawnGate` | sites | APPROVE | hawake.go:421-423 |
+| workerbuild.go `startWorker` | sites | APPROVE | workerbuild.go:111-113 |
+| edge.go `ServeHTTP` | sites | APPROVE: lookup moved earlier (same inputs), refusals and held 503 only | edge.go:1969-1972, 2008-2011, 2205-2207 |
+| agent.go `runAgent` | sites | APPROVE: `reg.List` moved into the new helper, not dropped | agent.go:247-253, 599-606, 828, 955, 1183 |
+| schedule_wiring.go `newScheduleDeps` | sites | APPROVE: Skip/WithDuty only narrow | schedule_wiring.go:90-109 |
+
+New and re-read dispositions:
+
+| unit | verdict | basis |
+|---|---|---|
+| 13 `infra/modules/region-host/**` `:external` units (group_alarms.tf, ingress main/alarms/outputs/variables/versions, ingress tests and fixed-targets fixture, region-host tests) | APPROVE all 13, legacy | New NLB/TG/SG/EIP/alarm resources and plan-time tests. Nothing root reads or installs: no user_data, unit or box IAM change; the ingress module is instantiated by no root module yet; the queue alarm is `count = 0` by default. |
+| activator/group_admission.go `admissionBefore`, `admissionContext`, `tenantStartRefusal` (x2), `TenantAdmissionExempt`, `startOwnedLocked` | APPROVE all 6 | Route into in-memory callbacks; refuse only (group_admission.go:11-73). |
+| boxroles/roles.go `Read` | APPROVE | Two GETs at keys built from validated labels (`^[a-z0-9-]`, <=63/32), 4096-byte body, strict decoder (unknown, duplicate, null, trailing refused); the value only gates starts. |
+| edge/group_admission.go `admissionRefuses` | APPROVE | Refusal only, exemption is the fixed predicate. |
+| host/boxroles.go `boxRoleReader.pass` | APPROVE | Calls `Read` on the agent's existing store; unknown keeps restrictions. |
+| host/boxroles_config_linux.go `readRoleRegionConfig` | APPROVE | Fixed path, `openat2` with `RESOLVE_NO_SYMLINKS`/`NO_MAGICLINKS`, `O_NOFOLLOW`, `fstat` uid 0, regular, no g/o write, nlink 1, 4097-byte limit, strict JSON (lines 12-30). Nothing a tenant or app can write. |
+| host/group_admission.go `TenantAdmissionExempt`, `bind`, `exempt`, `runWorkerBootPassAfterAdmission` | APPROVE all 4 | `exempt` reads Route `Platform`/`Unit`/`Backing`, which only operator records and the agent set (reconcile.go:455, 569); group boxes get no exemption. The boot-pass helper is the moved `reg.List`. |
+| host/memwatch.go `memwatchLoop` (+file:CommandContext) | APPROVE | Runs only with the opt-in flag: `/usr/bin/chronyc -c tracking`, absolute path, fixed args, 1 s timeout, 4096-byte capped output, strict 14-field parse (group_metrics.go:72-128). Nothing tenant-named. |
+| activator/backend_exec.go `nestedReady` (reads +whole:Route) | APPROVE | Refusal before the control-channel check (3018-3020). |
+
+Envelopes re-pinned (every changed function read): `infra/modules/region-host`,
+`infra/modules/region-host/ingress`, `.../ingress/tests`, `.../ingress/tests/fixed-targets`,
+`.../ingress/tests/fixed-targets/tests`, `infra/modules/region-host/tests`, `internal/activator`,
+`internal/boxroles`, `internal/edge`, `internal/edgesfile`, `internal/groupadmission`, `internal/host`,
+`internal/hostenv` (adds `CARLOS_CHANGE_INDEX` and `CARLOS_GROUP_ADMISSION` to the optional host.env
+allowlist; both only arm reads or close admission), `internal/release` (`ChangeScope` maps
+`control/box-roles/*` to one scope). **APPROVE all 14.** None lets root open, run, query or follow
+anything new from a path or input a tenant, app or box agent controls, and none weakens an existing
+check.
+
+Record on #280: approve, reviewer Opus, tip `2c67ce564c7ee7b73e72c9ac72b280a578748f67`.