carlos / platform Public

plans: P2a Opus review round 2 (NOT READY, 1 P1 in C1 again)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev e5c1e098a909f9bff33834f1e5d0cb212aae4e19 parent 38d39c8
1 file changed, +119 −0
  • docs/superpowers/plans/REVIEW-REGION-HA-P2-R2.md +119 −0
diff --git a/docs/superpowers/plans/REVIEW-REGION-HA-P2-R2.md b/docs/superpowers/plans/REVIEW-REGION-HA-P2-R2.md
new file mode 100644
index 000000000..90b6da8ae
--- /dev/null
+++ b/docs/superpowers/plans/REVIEW-REGION-HA-P2-R2.md
@@ -0,0 +1,119 @@
+# Review: region HA P2a plan, round 2 (rev 2 at 38d39c8e, code at origin/main 65420a4d)
+
+I read the plan, the round-1 review and the brief, and checked the cited code. None of the plan's code files changed between the branch base 79d9d6a2 and 65420a4d. Every citation I spot-checked (about 35) lands on the line the plan claims. I ran no tests or builds, edited nothing and spawned no agents.
+
+## Round-1 dispositions
+
+- **P1-1 (C1): partly resolved.** The list, detail page, single GET, CLI table/JSON and retry door now share one observation. One reader of the list's `rollout` is left out, `carlos deploy`'s watch, and the new nil-rollout projection breaks it. Carried forward as P1-A.
+- **P2-1 (C1): resolved.** `At`, the stale-holder hazard and clock-boundary tests were added. The hazard has a new problem with no time limit (P2-C).
+- **P2-2 (C1, C6): resolved.** The single GET gets the fields and its cold read is budgeted. `--json`, its decoder and D1 are planned, and the root census is acknowledged.
+- **P2-3 (C3): resolved.** The F1 and HAData predicates are exact and address-backed records are excluded. F1 now goes too far for rootfs residents (P2-F).
+- **P2-4 (C3): resolved.** The deliberate cut is F5/409. The temporary failure is F3/503 with "try again".
+- **P2-5 (C3, C4): resolved.** F4 is dropped.
+- **P2-6 (C3): resolved.** All four tests are listed with new setup and expectations, and the static-move ruling is applied.
+- **P2-7 (C2): resolved** for `domainGuidance`/`domainRecords`: configured mode offers A records only. A separate DNS-guidance door is missed (P2-E).
+- **P2-8 (C3): resolved.** The home data wiring check is in Task 5 Step 2 and the switch-on gate.
+- **P2-9 (C3): resolved.** No-op records are filtered before the HA preflight and their region write is skipped.
+
+**Stopping rule:** C1 had a P1 in round 1 (P1-1) and has one again here (P1-A). The plan's own rule says two consecutive rounds against the same invariant stop fixes and need Paul's refuse, cut or central-enforcement choice.
+
+## P1
+
+**P1-A. Task 1: the HA projection gives sleeping HA hosts no `rollout`, so `carlos deploy` URL-polls and wakes them. (C1; also C6, since it creates wake traffic)**
+- **Task:** 1, Steps 3 and 5. The plan never mentions `deploywatch.go`.
+- **Problem:** For HA records, rev 2 makes `rollout` nil whenever the observation is asleep, unknown or conflict (plan line 130, line 134 "unknown/conflict/asleep must not expose a different rollout.box"). The deploy watch decides how to follow each host from exactly that field and from `rollout_incomplete`. The plan also says to "skip legacy status warming/join on all-HA lists" (line 138) but never says where `rollout_incomplete` then comes from.
+- **Evidence:**
+ - `deploywatch.go:422-437` `legacyOnly`: if the list is complete and no target has a followable report, the watch falls back to `watchVersion` (`:303,314`), which polls every target's URL.
+ - `apply` `:515-520`: a listed host with nil `rollout` on a complete list becomes `modeURL`. The code's own comment at `:467` says URL polling "would wake it if it is asleep".
+ - On main, a sleeping adopter's report (`Installed`=ver, `Awake` false) makes `classifyRollout` return `rolloutAsleep` (`:188-189`), a final state reached without waking anything.
+- **Failure scenario:** `carlos deploy` on an app whose born-HA hosts are asleep (the normal state for hibernating hosts). The list returns them with no `rollout` and no `rollout_incomplete`. `legacyOnly` is true, `watchVersion` polls every host, and every sleeping HA host in the region wakes on every deploy. Released CLIs behave the same, so this can't be fixed on the CLI side alone. Unknown or conflict hosts take the same path.
+- **Fix:**
+ - For a born-HA asleep observation, return a box-less rollout projection: `Box` "", `Awake` false, `Serving` "", `Installed` only when every fresh adopter agrees (otherwise empty, so the host stays pending) and `SchedulerIdle` only when all of them are idle. `classifyRollout` then gives "asleep" without naming any box.
+ - For unknown or conflict, set `rollout_incomplete: true` on the list, so old and new CLIs keep the host undecided and never poll it.
+ - Define `rollout_incomplete` for all-HA lists from the observation's completeness.
+ - Add `deploywatch_test` cases (all asleep, mixed, unknown) asserting zero URL polls. Bring `deploywatch.go` into Task 1 and the root census if `groupByBox` needs to handle `Box` "".
+
+## P2
+
+**P2-A. Task 1: held or failed HA hosts lose "Failed", the hold row and retry. (C1, copy)**
+- **Problem:** The observation table has no held or down state. Retry uses only an awake candidate's rollout, and unknown, conflict and asleep get the "existing refusal".
+- **Evidence:**
+ - A host held down after a failed build reports `Awake = serving != ""`, which is false (`internal/rollout/status.go:59,104,119,131`).
+ - Main's remote health turns `rep.down` into "failed" (`apiinstances.go:507`), and `fleetHealth` does the same (`:581`).
+ - Retry requires `HeldBy` (`instancepage.go:43-45`, `apiretry.go:91`). Its refusal sentence `apiRetryNotHeld` says the host "is not held back by a failed build".
+- **Failure scenario:** A born-HA host is held down after a failed build. The console shows Asleep, not Failed. The detail page has no hold row, `instances list` gives no retry hint, and `carlos instances retry` answers 409 "not held". The user can't recover through the door built for this case.
+- **Fix:**
+ - Pick retry and hold candidates by `HeldBy` across tenant- and lifetime-checked fresh reports, not by awake.
+ - With exactly one holding book, sign the grant for that book. With several, or with incomplete evidence, refuse with a new copy ID and write nothing.
+ - Carry `down` into the asleep health word ("failed").
+ - Add the copy to the deck and fix `TestHAAwakeBoxRetryUsesObservation`, which assumes the held reporter is awake.
+
+**P2-B. Task 1: HA records the activator doesn't own are permanently "unknown". (C1)**
+- **Evidence:**
+ - The rollout report covers only `Managed` routes (`internal/rollout/policy.go:162-170`), and `ActivatorOwned` means instance kind and (hibernating or has a runtime) (`internal/registry/runtime.go:30-31`). `remoteinstances.go:408-410` already says never-sleeping instances aren't covered.
+ - Main stamps address-backed instances HA (`seedmove.go:47-48`), and the plan keeps that stamp (line 83). Non-hibernating HA sockets created before P2a also exist.
+- **Failure scenario:** Such a record never has a matching rollout entry, so the observation is always unknown. Its row loses main's metrics-based health and shows "Cannot confirm the awake box" for ever.
+- **Fix:** Use the observation only for HA records that are activator-owned. Keep main's health and rows for the rest, and test both.
+
+**P2-C. Task 1: the stale-holder hazard has no time limit beyond the 24-hour listing horizon. (C1)**
+- **Evidence:**
+ - Status objects are dropped from the listing only after 24 hours without a write (`internal/status/fleet.go:241-258`).
+ - Group boxes publish under a per-instance key (`internal/hostactors/private.go:15-20`), so each replacement leaves the dead box's object behind. I found no code that deletes it; `hostops/mutation_classifier.go:52` only classifies the family as deletable.
+ - Spec §6.7: a box that loses its lease latches the loss and stops the instance.
+- **Failure scenario:** After any failover or box replacement (exactly what G1/G2 drill), the dead holder's last report says awake. The host shows unknown for up to a day, even with one fresh awake holder.
+- **Fix:** Limit the hazard with a cited bound: a stale report counts only until the spec's lease-loss stop bound has passed since its generation. Add a "stale holder older than the bound plus one fresh holder means awake" test. Or accept up to 24 hours of unknown explicitly in A3/A5 and in the drill.
+
+**P2-D. Task 1: the join's other per-host fields are undefined for HA records. (C1, C6)**
+- **Problem:** The list still takes `staged_version`, `upstreams`, `db_bytes`, `egress`, `update_report` and `config_refusal` from whichever box was read last (`apiinstances.go:1326-1340`, `refusalFor` `:716-733`). The detail page's Updates section reads `join.update` (`instancepage.go:302`), and its comment promises one reading with Installed/Serving.
+- **Failure scenario:** On an all-HA list, where the legacy join is skipped, these fields vanish. On a mixed list they come from an arbitrary box. The same host answers differently depending on its neighbours.
+- **Fix:** Specify each field for HA records (from the selected candidate, from complete evidence, or cleared) and test both list shapes.
+
+**P2-E. Task 2: the placements door still tells users to point DNS at member box IPs. (C2)**
+- **Evidence:**
+ - `apiplacements.go:155,195` list each serving box's EIP.
+ - The regional domain guidance (`:395`, RD-44) and `domains_cli.go:56-58` call these "the addresses to point DNS at".
+ - Task 2 changes only `dnsTargets`/`edgeIPs`.
+- **Failure scenario:** In configured mode, a regional or single-mode domain in an HA region is pointed at member EIPs. Those disappear when the box is replaced, and the domain stops resolving to a server.
+- **Fix:** In configured mode, show the configured ingress for HA-active regions in the placements read and its readiness, or mark member addresses as not for DNS. Otherwise refuse regional placements into HA regions until P3. Add this door to Task 2's tests and copy deck.
+
+**P2-F. Task 3: F1 refuses resident rootfs instances in HA regions, and no ruling covers that. (C3)**
+- **Evidence:**
+ - The F1 predicate has no `Runtime` clause.
+ - P1a row 3.3 lets rootfs instances run "even on a single-tenant deployment whose home is an HA region" (`rootfs_test.go:585-587`). `shouldStampHA` excludes runtimes.
+ - Rootfs routes hold an activator lease (`registry/runtime.go:40-45`), so §6.1's reason ("has no lease") doesn't apply.
+ - The plan rewrites `TestRootfsCreateIsNeverBornHA` to expect the refusal, but the cut isn't in the Rulings table or the switch-on notes.
+- **Fix:** Add `rec.Runtime == ""` to F1, or get a controller ruling and record the effect at switch-on.
+
+**P2-G. Task 5: the dev drill's prerequisites aren't stated. (Witnesses, C3)**
+- **Problem:** Step 2 needs a disposable home, unpooled HA create to succeed, so dev's home must be in `CONSOLE_HA_REGIONS`. The plan doesn't say what the current setting is.
+- Turning it on makes every unpooled dev home create born-HA and subject to F1/F2/F3, including rootfs residents (see P2-F).
+- The named pair is `hapair`. The deployment notes record it as a pool, so F5 refuses any new HA host there.
+- **Fix:** State the current dev setting. Name the drill host (the existing pooled host, or a new home host). Put any `CONSOLE_HA_REGIONS` change, its blast radius and its rollback on the approval card.
+
+## P3 (follow-up list)
+
+- **Task 1 Step 5:** the test pattern `TestInstancesRollout` matches nothing. The existing tests in `instances_rollout_test.go` are `TestInstalledAndServingCells`, `TestRolloutReason` and `TestRolloutWireShape`. Add the deploy-watch tests too.
+- **Task 1:** a new HA record that no box has adopted yet shows unknown. Main shows "Setting up" when the read is complete and no box has seen the host (`apiinstances.go:488-492`, `remoteinstances.go:472`). Keep that word.
+- **Task 3 budget:** after the whole-prefix check finds `instances/<host>/` empty, the existing rail's 10 level LISTs on the same prefix add nothing. Keep only the `moves/` half (saves 10 LISTs).
+- **Task 4:** `offlineBeginChecks` parses the body after `offlineClaimEvidence` (`apiinstancemove_offline.go:520-528`). Running the helper "before claim evidence" means reordering, which changes which refusal comes first. Say so, or run it after `readJSON`.
+- **Task 2:** configured mode drops every IP the fold finds, including other non-HA regions' edges in a multi-region deployment. State that, or limit the suppression to the HA region.
+- **Task 2/5:** `PLATFORM_EDGE_IPS` is shared with the agent's DNS check and the console's proxy trust (`cmd/console/main.go:1333-1337`, `authcli.go:1210`). Phrase the pre-check as "every listed IP is public ingress", not "remove the platform box's EIP", since today that IP may be the ingress.
+
+## Door inventory (C3)
+
+No create, move or import door is missed:
+- **Create:** the instance create door (plain, `--from` and import begin), standalone sidecar and first-domain static create.
+- **Move:** offline stage/start, the older and Phase-1 move requests, and `apps place` (including its claim path, whose check comes after the new preflight).
+- **Import:** begin, upload and stopped. Commit and abort stay open for operations already started.
+- **Region writes:** the only direct region write is `fleets.go:955`.
+
+Every refusal comes before a write. Nothing in P2a depends on P1b-3a, so stopping rule 4 holds.
+
+## Budget (C6)
+
+- The arithmetic in the budget table checks out.
+- The pageBoxReports cache is per console process, so it doesn't grow with users or tabs.
+- Retry moves from a per-request read to the cache, which is up to 60 seconds older. That's harmless, because an outdated epoch is rejected by the box.
+- No new per-box polling. The one new background-like load is P1-A's wake traffic.
+
+**NOT READY**
\ No newline at end of file