carlos / platform Public

plans: P1b-3a Opus review round 1 (NOT READY, 3 P1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev d27de8c2b35c0307bfab279ca63973721db56596 parent 0cd04be
1 file changed, +124 −0
  • docs/superpowers/plans/REVIEW-REGION-HA-P1B3-R1.md +124 −0

Intent

Human

<task-notification> <task-id>ad3489321e79458ec</task-id> <tool-use-id>toolu_01RAD3zGAWwupJTi8aVP6RC7</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/aab63774-dfe6-44a4-9cd9-230e6f4c3d13/tasks/ad3489321e79458ec.output</output-file> <status>completed</status> <summary>Agent "Release agent: cut v0.33.3" 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>v0.33.4 published, waiting for GO. I've promoted nothing and touched no box, console, flagship or Tito. - **Tag:** v0.33.4 (tag object 93ca6264). - **Cut from:** 5887f944, which is 3a (44d810d0), the spec note (581e648e) and the rootfs HOME fix. Main CI passed on it at 11:40Z, and main hadn't moved when I tagged. - **Release:** [https://github.com/carlosframework/releases/releases/tag/v0.33.4](https://github.com/carlosframework/releases/releases/tag/v0.33.4). It is marked Latest. The signature verifies, `sha256sum -c` passes and the sums match what I built. - **Tap:** homebrew-tap PR #80 is merged, and the four hashes match the sums. - **apt:** v0.33.4-1 is promoted to `canary/apt`, which is the apt site, not a box channel. The served arm64 deb matches the signed sum (87f33068), and the live Packages file lists 0.33.4. - **Notes:** v0.33.3's notes plus the one HOME line, in your wording. Luna reviewed the new line only and approved it with no changes. The deb sentence is unchanged from v0.33.3. - **Builds:** the linux-arm64 binary has sha 86b1952b and the console has sha 42905b15. - **v0.33.3:** it stays published and is not rolled. The `canary/apt` pointer now reads v0.33.4. At 13:50Z I resume as follows: - Message platform-86 first. - Promote canary (sophie) and stable back to back. Dennis then rolls with leo. - Check the boxes and roll the dev console. - Run the HOME check on box-1, reading only the HOME line of shop's web process, then message platform-cf with the result. The pre-roll baseline from this morning is in `/home/paulca/.cache/release-v0.33.3/tmp/`, in `pre-dev.txt`, `pre-global.txt` and `sophie-console-pre.txt`. It should be re-read just before the roll. Log: `/home/paulca/.cache/release-v0.33.4/roll-log.md`.</result> <usage><subagent_tokens>131957</subagent_tokens><tool_uses>12</tool_uses><duration_ms>854235</duration_ms></usage> </task-notification>

Attributed to this commit: 10.3 g CO₂e (1,243,683 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-p1b3-placement, 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/plans/REVIEW-REGION-HA-P1B3-R1.md b/docs/superpowers/plans/REVIEW-REGION-HA-P1B3-R1.md
new file mode 100644
index 000000000..20c430be4
--- /dev/null
+++ b/docs/superpowers/plans/REVIEW-REGION-HA-P1B3-R1.md
@@ -0,0 +1,124 @@
+# Review: region HA P1b-3a plan, round 1
+
+**Plan:** `docs/superpowers/plans/2026-11-01-region-ha-p1b3-placement.md` at 0cd04be9, checked against the code at 44d810d0.
+
+**What holds up:**
+- **One writer.** `lease.AcquireHA` is still the only authority. The plan's placement never writes a lock and never skips the acquire. Races between a cached view and an acquire end at the conditional PUT.
+- **Publication budget.** Every claim checks out:
+ - `gateCopy.Headroom = nil` is at `host/edgesfile.go:945`, so `apps` stays outside the change gate.
+ - The timed pass forces a write with headroom (`edgesfile.go:962`).
+ - `putReplacing` makes 3 attempts (`snapshot_loop.go:221`), and the change index makes 4 (`changeindex.go:31,130`).
+ - The fold is one LIST plus one GET per file (`homemap.go:456`).
+ - A first wake adds one LIST (`ha.go:100`).
+- **Mixed-version roll.** It is safe: old receivers handle hops as P1b-2 does, and old files carry no `apps`, which reads as 0.
+
+None of the findings below break the single-writer invariant. The P1s are liveness regressions against main, plus one switch-contract violation.
+
+## P1
+
+### P1-1. An expired lease is sent to the H4 choice, which defeats same-box recovery
+- **Task:** 3 (ForwardTarget order), with the Task 2 contract.
+- **Problem:** The plan routes "absent lock, unclean marker or expired owner" to H4 (plan lines 84 and 193). Only the owner's own box can take its expired lease, using the emptiness proof. Any other box needs proof the owner was terminated, which a live box never gives.
+- **Evidence:**
+ - `hafresh/acquire.go:72-118`: DecideAcquire takes an expired lock only for the same instance id with `SameBoxEmpty`. For another box it returns `ReasonOtherExpired` unless the owner is confirmed terminated.
+ - `activator/haforward.go:146-156`: `otherHolder` returns "" for an expired lease.
+ - `haforward.go:196-209` with `activator.go:6132-6150`: a refused acquire on a hop is answered `X-Carlos-Holder: none`.
+ - `haforward.go:170-171`: `NoteForward` drops the entry on "none".
+- **Failure scenario:**
+ 1. leo's agent crashes while holding a request-only host, then restarts. The lease expires (LeaseTTL 15 min, `lease/lease.go:40`).
+ 2. sophie is the roomiest box.
+ 3. A request at leo goes to H4, which picks sophie. leo forwards it. sophie's acquire is refused ("another box's expired lease"), so the answer is "none" and a 503.
+ 4. A request at sophie with nothing cached also goes to H4, chooses itself, and is refused locally.
+ 5. The host never recovers from requests. On main, leo serves the request itself, runs the same-box proof and wakes the host (spec §6.4, §9.6).
+- **Fix:**
+ - An expired HA owner that is this box: local acquire.
+ - An expired owner that is a serving peer: forward to that owner, regardless of headroom. Only it can recover without a termination.
+ - Use H4 only when the owner is not in the serving set.
+ - Add a witness (crash, restart, the peer is the H4 choice, requests at both boxes, the host recovers on the owner) and a sim mutation `placement-ignores-expired-owner`.
+- **Invariant broken:** §9.6 same-box recovery and I4 liveness; sim I5 ("never stranded").
+
+### P1-2. A box with `CARLOS_REGION_HA` off refuses every born-HA cold wake
+- **Task:** 2/3.
+- **Problem:** Under N-HA7 and §19, every box honours `ha:true` "whatever its own switch", and `CARLOS_REGION_HA` gates P1b only. The plan requires self evidence: capability `region-ha-1`, fresh headroom and the self in the serving set (plan lines 78 and 80). A zero snapshot must refuse (line 187). The plan never checks the box's own switch.
+- **Evidence:**
+ - `host/edgesfile.go:197-202`: `region-ha-1` is published only when the switch is on.
+ - `host/headroom.go:13-16`: no headroom without that capability.
+ - `edge/forwardha.go:147-156`: `frontForwardHA` gates on `rt.HA`, not on the switch.
+ - `edge/homemap.go:362`: the edge already reads the switch (`regionHAFromEnv`).
+- **Failure scenario:** P1b is backed out on sophie and leo by unsetting `CARLOS_REGION_HA`, or any box with born-HA rows runs with the switch off. The self file is not serving and there are no serving peers, so `ChooseColdWake` returns false. Every asleep born-HA request then gets a 503 with C1. Main and P1a wake the host locally. The documented rollback therefore takes HA hosts down.
+- **Fix:** With the switch off, skip placement and keep P1b-2 behaviour: a holder probe, then serve here. Add a test for a switch-off box with a born-HA route.
+- **Invariant broken:** N-HA7 and the §19 switch contract. HA behaviour must never depend on P1b being on.
+
+### P1-3. An unreachable placement target is never excluded, so a down box blocks cold wakes for up to about 15 minutes
+- **Task:** 2/3.
+- **Problem:** On a dial failure the plan answers 503 with "no second choice" (line 86). Its "Expired placement suspect with free read clears/rechooses" (line 190) recomputes from the same fold, so it reaches the same box again. A box's edges file stays fresh for up to 15 minutes after its last write.
+- **Evidence:**
+ - `boxchoice/policy.go:27`: MaxEdgesAge is 15 minutes.
+ - Nothing deletes an edges file on shutdown or death. The only writer is `host/edgesfile.go:974`, and deletion is 3b's B4.
+ - Graceful shutdown writes clean markers naming the box (spec §9.8, last bullet).
+ - Budget row: plan line 105.
+- **Failure scenario:**
+ 1. leo is stopped, hung or terminated, or is mid-restart during a roll.
+ 2. Every host leo released has a clean marker naming leo, and leo's file is still fresh. sophie forwards each one to leo, the dial fails, the visitor gets a 503 and the box is suspect for 10 s. This repeats for up to ~15.5 minutes.
+ 3. The same happens to never-woken or unclean hosts for which leo is the roomiest or app-free choice.
+ 4. Main wakes all of them on sophie at once: a marker take or a create, with no lease held by leo.
+- **Fix:**
+ - Keep placement suspicion per box reference: a bounded map, 10 s, renewed on each failed dial, cleared by any answer from that box.
+ - Remove suspect references from Serving, including the releaser preference, before choosing.
+ - The failing request may still 503 (no fallback within the same request). The next one chooses among the remaining boxes. This is safe because a placement target holds no lease.
+ - Witness: kill the chosen box's listener; within 10 s the next request wakes the host on the survivor, with at most one dial per 10 s.
+- **Invariant broken:** I4 failover, and a liveness regression against main. §9.8 expects a dial failure to lead to recovery, not a 15-minute blackout.
+
+## P2
+
+### P2-1. A new host has a 503 window because self adoption is read from the fold
+- **Task:** 2.
+- **Problem:** The plan requires every candidate, self included, to publish `role:home` for `rt.Host` in the cached fold (line 80). The fold trails the local registry: the edges pass runs after a registry change (2 s watch, `edgesfile.go:1201-1222`), then the index bump, then each box's 30 s poll (`homemap.go:126,392`).
+- **Failure scenario:** A born-HA host is created and its first request arrives within roughly 30-60 seconds. No folded file lists it yet, so the visitor gets a 503 with C1. Main wakes it locally. Task 5A step 3 ("fresh never-woken host") will hit this.
+- **Fix:** Treat self as adopting through the request's local route; `frontForwardHA` only runs with one. Require the fold listing only for peers. Add a test.
+- **Invariant broken:** A20 spirit (an existing host is refused while a compatible box, this one, exists).
+
+### P2-2. The budget table misses the drop after a refused placement forward
+- **Task:** 3/4.
+- **Problem:** "None/headerless 503 drops observation" (line 191). After a refused receiver acquire, every later request re-reads the lock at ingress (1 GET) and the receiver reads it again (1 GET). The row "Refused target acquire 1G, 0P" (line 106) leaves out the ingress re-read. Under main, the 10 s negative entry stays and only the local acquire reads.
+- **Evidence:** `activator/haforward.go:170-176`.
+- **Failure scenario:** A host behind an expired, unconfirmed lease of a hung box (minutes), a leftover legacy lock, or leftover data costs 2 GETs per visitor request.
+- **Fix:** For Placement forwards, keep the negative observation to its original 10 s on "none" or headerless 503, since no holder was named. Add the row and counters to TestColdPlacementRequestBudget.
+- **Invariant broken:** Budget exactness. No new per-request S3 amplification.
+
+### P2-3. The agent wiring has no witness the plan accepts
+- **Tasks:** 1, 3, 4.
+- **Problem:** Line 205 says "AST-presence checks are not acceptance". But `RunAgent` cannot be called from a test, and the existing precedent for the agent half is syntactic (`host/haforward_wiring_test.go:15-19,21-39`; `hatakeover_wiring_test.go:20-37`). So the `setHAAwakeApps` registration (Task 1) and `wireHAPlacement` (Task 3) in `agent.go` have no executable witness. The no-capacity page is fixture-only in 5A step 3.
+- **Fix:**
+ - One arming function, called once from `runAgent` and also by the witness.
+ - Explicitly accept a P1b-2-style single-call syntactic check for the agent half.
+ - In 5A step 1, read `apps` from both live files.
+
+### P2-4. The copy deck is incomplete
+- **Task:** Copy deck.
+- **Problem:** `PageOperator(ctx, level, subject, body)` (`host/alertsink.go:137`) needs a subject as well as a body. The plan forbids unreviewed subjects (line 192), but HA3-C2 is a single string. The destinations are also wrong:
+ - C1 is answered in `edge/forwardha.go` (`frontForwardHA`, line 147), not in `wakeplacement.go`.
+ - C2 is sent by `internal/host/haplacement.go`, not `internal/activator/haplacement.go`.
+- **Fix:** Add a C2 subject row and correct both destinations before the Luna pass.
+
+## P3
+
+1. **Task 1:** It adds `Apps` to the console's `edgesfile.PlacementView` and `Snapshot.BoxChoice` (`edgesfile/snapshot.go:72,280`), which nothing in 3a reads. That adds census surface. Drop it or justify it.
+2. **Task 2:** `Candidate.BoxID` must come from the edges `box` label, not `box_id`, which can be an instance id for group boxes (`host/edgesfile.go:337-343`). Otherwise `boxInView` misses, and the plan answers that miss with a 503. Add a test fixture where `box` differs from `box_id`.
+3. **Task 2:** New typed fields in edge's `edgesFileView` decode strictly. A type mismatch in any of them fails the whole file (`homemap.go:730-743`), which stops forwards to that box. Decode placement fields tolerantly (RawMessage or a second decode).
+4. **Task 2:** Self freshness comes from the fold. If an index bump is lost and no peer writes, the own file can look stale until the 30-minute backstop (`release/changewatch.go:17`), and the box refuses all cold wakes. Consider using the publisher's last successful write time for self.
+5. **Task 5A:**
+ - There is no ingress decision log. The drill has to compute the production choice by hand from the snapshots. Add a throttled log line per placement decision, with its reason.
+ - The pre-check does not confirm that both boxes meet the 15% memory and 10% disk thresholds. Step 2's "first kept local" fails if the releaser is ineligible.
+ - The source for "API counts" is not stated.
+6. **Citations that are off:**
+ - `forwardha.go:173,210`: `frontForwardHA` is at 147 and `forwardHA` at 180.
+ - `haforward.go:73` is a closing brace: `holderReaderFor` is at 67 and `ForwardTarget` at 108.
+ - `boxchoice.go:29` is mid-struct: `Headroom` starts at 27.
+ - `sim/regionha/invariants_test.go:9` is blank: the doc starts at 10.
+
+## Verdict
+
+**NOT READY.** The three P1s are changes to the Task 2/3 contract (ForwardTarget order, the switch gate, per-box placement suspicion). Each needs a named witness, and two need sim mutations.
+
+I made no edits. I ran no tests: the default `GOCACHE` is read-only inside this sandbox, so even `go list` failed. Every finding above comes from reading the code at the cited lines.
\ No newline at end of file