carlos / platform Public

plans: P3a Opus review round 2 (READY AFTER FIXES, 6 P2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 8f99bfffe44408a8420a94d1f50ccb012bdda232 parent 3d2f501
1 file changed, +118 −0
  • docs/superpowers/plans/REVIEW-REGION-HA-P3-R2.md +118 −0
diff --git a/docs/superpowers/plans/REVIEW-REGION-HA-P3-R2.md b/docs/superpowers/plans/REVIEW-REGION-HA-P3-R2.md
new file mode 100644
index 000000000..aed083493
--- /dev/null
+++ b/docs/superpowers/plans/REVIEW-REGION-HA-P3-R2.md
@@ -0,0 +1,118 @@
+Round 2 review of the region HA P3a plan (rev 2, `830eb8f1`), checked at branch tip `3d2f5013` against origin/main `ceee7a67`. I also read the dev root `platform-infrastructure` at HEAD `e57979d` and the memory notes on the dev drills, read-only. I edited nothing, ran no tests or tofu, did not fetch and spawned no subagents.
+
+## Round-1 dispositions
+
+| R1 finding | Status | Note |
+|---|---|---|
+| P1-1 restart → replacement (T1/I4) | **Resolved** | P3a has no Auto Scaling group, so a fixed box cannot be replaced. P3b's Standby transaction is gated on Paul's §12.1 ruling (plan :99, :343). Safety holds without it. Availability on the opted-in pair is new P2-5. |
+| P1-2 SSM path ARNs (IAM/A1) | **Resolved** | Task 4 Step 4 allows and excepts exactly [regional, regional/*, shared, shared/*], with sibling and ancestor tests. Matches `awsssm.go:62-63`. |
+| P2-1 role gate/budget (R1/B1) | **Resolved** | Uses the `ReadGate` Due/Mark API (`changewatch.go:176-238`) with the 30-minute backstop, refuses a disarmed watch, and backs off when the index is unusable. The ≤128G/h figure checks out at about 126G. |
+| P2-2 fixed opt-in switch (I4/R1/S1) | **Partly** | `CARLOS_GROUP_ADMISSION` is named and switch-off omits all P3 fields. Switch-on with `CARLOS_REGION_HA` off is undefined (P2-1 below). Metrics are not covered by the flagship-unchanged witness (P2-6). |
+| P2-3 root settings delivery (N1/S1) | **Resolved** | Hairpin is cut from P3a; a configure script delivers the settings and user_data is not touched. The ownership claim is wrong (P3-1). |
+| P2-4 home election (A1/H4) | **Resolved** | Non-admitted boxes are excluded before tie-breaking and booting files carry no home rows. Side effects on other readers are P3-3. |
+| P2-5 hairpin client address (N1) | **Resolved** | Deferred to P3b with a design: verified public address or refuse, plus a kernel witness. |
+| P2-6 #478 version rights (IAM) | **Resolved** | Group mode drops them unless an audited consumer needs them, then grants a prefix-scoped version. |
+| P2-7 dev apply safety (E1/S1) | **Partly** | The store-Deny gate (fix `55157510` confirmed unmerged), the whole-root read-plan and the saved targeted plan are all there. But the `-target` closure pulls in the fixed instances (P2-2). |
+| P2-8 JSON gate widened (E1/T1) | **Resolved** | Small gaps in P3-2. |
+| P2-9 fixed SG ownership (E1) | **Resolved** | |
+| P2-10 rollback (S1/E1) | **Partly** | Owners and order are stated. The binary restore does not stick, and failure before registration has no restore step (P2-4). |
+| R1 P3s (11) | **Resolved** | All taken. The table fix for P3-C8 is malformed (P3-5). |
+
+## P1
+
+None.
+
+## P2
+
+**P2-1. `CARLOS_GROUP_ADMISSION=1` without `CARLOS_REGION_HA=1` closes a fixed box for good**
+- **Task:** 3 (Interfaces, Step 3) and 6 Step 2.
+- **Problem:**
+ - Admission needs `len(lbhealth.Default.Failing(now))==0` (plan :139).
+ - On main, the edge points its health state at `lbhealth.Default` only when `CARLOS_REGION_HA` is true (`internal/edge/lbhealth.go:21-29`). Otherwise `e.lbHealth` is nil.
+ - The map, key, refresh, certs and edge-beat latches are all written through that pointer (`homemap.go:366-367, 426-431`; `certsync.go:948`; `edge.go:3058-3059`). So without `CARLOS_REGION_HA`, `Default` never latches anything, the six conditions never hold, and the box is never admitted.
+ - The external health path is also nil without that flag, so the NLB gets no `/.carlos/lb-health` answer at all.
+ - Task 6's configure step sets only `CARLOS_GROUP_ADMISSION`, `CARLOS_CHANGE_INDEX` and region `ie`. Task 3 defines `CARLOS_REGION_HA` only for switch-off boxes (where the flag may be "set or absent") and for group boxes.
+- **Failure:** If leo or sophie lack `CARLOS_REGION_HA`, the configure roll closes that box to every tenant, legacy ones included, until a manual rollback. Registration is refused, but the outage has already started.
+- **Fix:**
+ - Make the switch require `CARLOS_REGION_HA` to parse true. Refuse at configure time and log a startup refusal.
+ - Add `CARLOS_REGION_HA=1` to the configure step as a precondition that is verified read-only, or delivered, and list what else that flag turns on (private dial, box records, the `region-ha-1` capability, the relocate pass).
+ - Add a `TestAdmissionFixedOptIn` case for switch-on with `CARLOS_REGION_HA` off.
+- **Invariant:** I4 / S1.
+
+**P2-2. The saved `-target` plan pulls in the fixed instances, and probable user_data drift will refuse it**
+- **Task:** 6 Steps 2 and 6, and the Task 1 Step 4 gate.
+- **Problem:**
+ - P3a attachments built from `module.host_ie*.instance_id` make each fixed `aws_instance.host`, and through it the instance profile, role and SG, part of the `-target` closure.
+ - Dev `host-init.sh` changed on 2026-08-28 (`31b5159`, zram). That is after `host_ie` (`e64b784`, 08-02) and `host_ie_b` (`a34f047`, 08-23) were declared. Both instances use `user_data = file("host-init.sh")` with `user_data_replace_on_change = false` (`main.tf:545-546`).
+ - Unless the instances were replaced since, the targeted plan shows an in-place user_data update. That update stops and starts the instance, and the widened gate correctly refuses it.
+- **Failure:** P3a cannot get a passing saved plan. An operator under time pressure is then pushed toward allow-listing an instance stop/start.
+- **Fix:**
+ - Pass the fixed target IDs as literal variables, or a read-only `data "aws_instance"` lookup, so no fixed module resource enters the closure.
+ - Have the whole-root read-plan record existing fixed drift explicitly.
+ - Add a gate fixture showing user_data drift in a closure is refused.
+- **Invariant:** E1 / S1.
+
+**P2-3. The NLB's zones are not required to cover the fixed targets' AZs**
+- **Task:** 1 (ingress `zones`) and 6 Step 1.
+- **Problem:**
+ - leo and sophie sit in default-VPC subnets that EC2 picked (`subnet_id` is null, `main.tf:539-542`).
+ - NLB instance targets in an AZ the load balancer has not enabled receive no traffic, even with cross-zone on.
+ - The card records the AZs but never requires the ingress zones to include each target's AZ.
+- **Failure:** One target sits unused, so "each zone EIP serves" proves only one box. Or both sit unused and nothing is served.
+- **Fix:** Make the approval card and the root assert that the targets' AZs are a subset of the ingress zones. Check target health shows no NotInUse reason before probing.
+- **Invariant:** E1.
+
+**P2-4. The rollback's binary restore does not stick, and failure before registration has no restore step**
+- **Task:** 6 Step 2.
+- **Problem:**
+ - Dev boxes adopt from the channel on their own (`carlos agent` does hourly release adoption; v0.31.1 notes say "box-1 self-updated"). Restoring "the saved signed binary" without repointing the channel is undone within the hour.
+ - The plan says to refuse registration if admission fails. It does not say the switch-on box, which by then refuses all its tenants, gets its old host.env back straight away.
+- **Fix:**
+ - State that rollback is switch-off. `TestAdmissionFlagshipUnchanged` is the proof that this is enough.
+ - If a binary rollback is really needed, it is a channel repoint by the release owner.
+ - Add a time bound: restore the old config immediately on any box not admitted within N minutes of its configure roll, before any infrastructure change.
+- **Invariant:** S1 / E1.
+
+**P2-5. The opted-in fixed pair's restart cost and gate scope are not stated (§12.1 is not needed, but availability changes)**
+- **Task:** 3 (Interfaces) and 6 Step 2.
+- **Problem:**
+ - Once switched on, every restart of leo or sophie refuses all tenant routes, legacy dev tenants included, until the four facts and six conditions hold again. Unattended self-update is unchanged on fixed boxes (plan :88), so both boxes can close together; the NLB then fails open onto two closed boxes.
+ - sophie also serves the dev console. The gate applies "for a tenant route" without defining whether console/platform or unit-backed routes count. `carlos-app@` units started by root's adopt pass bypass the activator gate entirely.
+- **Failure:** Every dev release or self-update becomes a whole-box outage on the opted-in pair, possibly with the dev console unreachable, and the approval card does not say so.
+- **Fix:**
+ - Define the gate's scope for platform and unit-backed routes on an opted-in fixed box: exempt them, or explicitly close them with a stated reason.
+ - Stagger or hold unattended self-update on the pair for the P3a window.
+ - Measure the time from restart to admission and put it on the card.
+- **Invariant:** I4 / T1 (availability, not one-writer).
+
+**P2-6. Clock and group metrics could change switch-off and flagship boxes**
+- **Task:** 5 (Interfaces).
+- **Problem:**
+ - Task 5 extends "the existing once/minute host metrics batch with group dimensions and clock offset" (`memwatch.go`, dimensions at `:166`) but does not gate this on the switch or the group marker.
+ - `TestAdmissionFlagshipUnchanged` covers HTTP, door, tunnel, worker, timer, edges bytes and restart, but not metrics.
+- **Failure:** Flagship boxes start running `chronyc` every minute and publish new billed series (about $0.30 per series-month). On boxes without chrony this logs "unknown". Changing the dimensions on the existing datum would also leave `host_memory_low` (InstanceId only, missing=breaching, `main.tf:629-648`) without data, so it would alarm.
+- **Fix:** Emit clock and group data only on opted-in or group boxes. Keep the InstanceId datum byte-identical. Add the PutMetricData input to the flagship-unchanged witness.
+- **Invariant:** I4 / S1 (switch-off unchanged), B1.
+
+## P3
+
+- **P3-1 (Task 6 Step 2 / Task 3; N1):** The plan calls `/etc/carlos/host.env` "root-owned". On the dev pair it is `carlos:carlos 0600` (`scripts/bootstrap-box.sh:121-131`), so the configure script's owner check would fail. **Fix:** check for root or the agent user, read-only to the agent under `ProtectSystem=strict`, or chown it to root as a named, reviewed step.
+- **P3-2 (Task 1 Step 4; E1):**
+ - "Treat unknown values as refusal" would refuse every create, since new resources have after-unknown values. **Fix:** scope that rule to guarded fixed and protected resources.
+ - Fixed `aws_eip.host` (`main.tf:580-584`) is not in the guarded set. An in-place re-association would move the public address. **Fix:** guard it.
+- **P3-3 (Task 2 Step 4; A1/H4):** Booting publications drop all home and alias rows on every opted-in fixed restart. Readers beyond home election see those hosts vanish:
+ - the fleet-wide "routes always win" check (`domains/aliases.go:257-263`);
+ - wildcard parents (`homemap.go:622-628`, `wildcard.go:898`);
+ - the console's edges readers.
+
+ **Fix:** audit these consumers and add a witness for the withdrawal window.
+- **P3-4 (Task 3 Step 4; T1/I4):**
+ - The receipt has no named path. `carlos-edge` can write only `/data` and `/run/carlos` (`carlos-edge.service`, `ProtectSystem=strict`). `/run/carlos` is tmpfs and is lost on reboot, which would leave a maintenance reboot permanently closed. **Fix:** name a persistent path outside tenant trees.
+ - The new group marker can disagree with the existing `CARLOS_BOX_REFERENCE=group` line (`hostenv.go:132-141`). **Fix:** define which one wins and refuse a mismatch.
+- **P3-5 (Copy deck; A1):** The blank line at :327 splits the P3-C8 row out of the table. **Fix:** delete the blank line.
+- **P3-6 (Task 6 Step 2; S1):** If `CARLOS_CHANGE_INDEX=read` is not already set on leo or sophie, turning it on changes record walks (`host/changeindex.go:3-6, 55-74`). **Fix:** put it on the approval card and in the rollback.
+- **P3-7 (Task 3; rule 4 hygiene):** Task 3 edits `internal/edge/forwardha.go`, which the P1b-3a branch also changes (+40 lines). This is not an interface dependency. **Fix:** coordinate the same way as Task 2.
+- **P3-8 (Task 5; I1):** `chronyc -c tracking` has to work from inside the `carlos-edge` sandbox (User=carlos, `RestrictAddressFamilies`, UDP 323 or the socket). If it can't, the missing=breaching clock alarm fires forever. **Fix:** add this to the Task 6 checks.
+- **P3-9 (Task 1; E1):** The first carloku-infrastructure module bump that includes P3a's moved blocks should run the JSON gate on flagship's saved plan.
+
+**Verdict: READY AFTER FIXES**
\ No newline at end of file