carlos / platform Public

plans: P1b-3a Opus review round 2 (READY AFTER FIXES, 2 P2)

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

Intent

Human

<task-notification> <task-id>afef9ba278187de2f</task-id> <tool-use-id>toolu_01P6twBjjZ2cJxzibkBKCpex</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/aab63774-dfe6-44a4-9cd9-230e6f4c3d13/tasks/afef9ba278187de2f.output</output-file> <status>completed</status> <summary>Agent "Opus review of P1b-3a plan R2" 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>**Round 1 dispositions** (checked against the code at 44d810d0; `a905f09c` changes only docs on top of it) - **P1-1 (expired owner sent to H4): resolved.** `DecidePlacement` never sends an owner-bearing lock to H4. A lock this box owns goes to the local acquire. An expired peer owner gets a Recovery hint, which falls back to the local acquire once that peer is out of view or suspect (plan lines 89-90 and 234). This matches `hafresh/acquire.go:87-106`. Witness and mutation are named. - **P1-2 (switch off refuses born-HA wakes): resolved.** The switch reaches the rule as `Enabled`, read from the parsed switch (`edge/homemap.go:162-165,362`; same parser as `host/boxrecord.go:25-28`). Off means the local acquire. Recovery and placement hints change caching only for their own kinds. Holder entries keep P1b-2's drop rules, so the off path matches main. - **P1-3 (unreachable target never excluded): resolved for dial failures.** A per-box suspect list is filtered before both the releaser preference and H4. A target that answers but cannot wake, or that is out of view, is a new gap (P2-A and P2-B below). - **P2-1 (503 window for a new host): resolved.** The serving box qualifies through its own local route; peers still need to publish the host. - **P2-2 (extra lock reads after a refusal): resolved.** The original 10 s observation is kept, with a budget row and counters. Repeat refusals cost 1 GET at the receiver and 0 at the ingress, which matches main's single local read. - **P2-3 (no witness for the agent wiring): resolved.** One arming function is called once by `runAgent` and run by the witnesses. The single-call syntactic check follows `host/haforward_wiring_test.go:15-39`. - **P2-4 (incomplete copy deck): resolved.** C2 now has a subject row (`PageOperator(ctx, level, subject, body)`, `host/alertsink.go:137`). The C1 and C2 destinations are corrected. **What holds:** - **One writer.** `lease.AcquireHA` is still the only authority (`lease/ha.go:59-128`). Placement and Recovery never write and never supply a proof. Stale views and differing views end at the conditional PUT. A verified hop is never chosen again (`edge/forwardha.go:148,184`). - **Front-door exclusions.** All new paths run inside `frontForwardHA` after its existing exclusions (`forwardha.go:148-151`): legacy hosts, regional names, doors, tunnels, static routes and verified hops. The edge starts after the activator (`host/agent.go:744-746`, then 1048) and drains before `svc.Shutdown` (`agent.go:1117-1128`). So a peer that is restarting or shutting down shows up as a dial failure, which the P1-3 fix covers. - **Budget.** All publication and fold claims check out: - headroom stays outside the change gate (`host/edgesfile.go:945`), and the timed pass forces a write (`edgesfile.go:962`); - `putReplacing` makes 3 attempts (`host/snapshot_loop.go:221-235`) and the change index makes 4 (`release/changeindex.go:31,130`); - a first wake adds one LIST (`lease/ha.go:100-108`). - **Applicability: one table, and the five cases hold.** - Switch off, self adoption and a missing view behave exactly as main. - A true-holder suspect behaves as main. - An expired owner differs from main on purpose: a Recovery hop to the owner replaces a local acquire that would have been refused without a termination proof. That is an improvement and safe. - Outcome handling sits outside the table: edge fallback by kind, `NoteForward`, and the suspect list's clear rule. Both P2s live there. - **Mixed-version roll.** It is safe: the new fields are additive and old receivers take a placement hop exactly as they take a P1b-2 hop. ## P1 None. ## P2 ### P2-A. A target that answers but cannot wake is never avoided - **Task:** 3 (suspect list, `NoteForward`), plus the Task 4 simulation. - **Problem:** - Rev 2 clears a box's suspicion on "any answer from that ref, any kind" (plan lines 103 and 238). - For Placement, an answer of "none" or a 503 with no holder header keeps the cached observation (line 237), so the next request picks the same box again. - Only a failed dial excludes a box. A box that is reachable but refuses or hangs on every wake stays the choice. - **Evidence:** - Any refusal other than a held lease is answered `X-Carlos-Holder: none` (`activator/haforward.go:207`). That covers `ErrNoSelf` (`lease/ha.go:33,70-72`), an owed marker PUT that fails (`ha.go:82-86`), and a failed generations write (`activator/generations_file.go:267-271`). - A hang after connecting answers 502 with Status 0 (`edge/forwardha.go:210-212`). - The edges loop keeps publishing a fresh file with headroom throughout (`host/edgesfile.go:1228-1231`). - **Failure scenario:** 1. leo's lease identity is incomplete (IMDS failed at boot; it retries every minute, `host/haself.go:47-74`), or leo's data volume turns read-only. 2. sophie sends every host leo released cleanly, and every host where leo is roomiest, to leo. 3. leo answers "none", so the visitor gets a 503. leo's file stays fresh, so this repeats indefinitely. 4. On main, sophie wakes all of these hosts locally. - **Fix:** for Placement only, treat "none", a headerless 503, a 502 or Status 0 from the target as a failure of that box. It becomes suspect for 10 s under the same epoch rules, and only a success or a holder-naming answer clears it. This is safe because a placement target holds no lease for that host. Add a simulation action for a peer that refuses or hangs while staying in view, plus a mutation `placement-refusal-clears-suspect`. - **Invariant:** I4 / sim I5, "placement never strands a host main would wake". This is R1 P1-3's family. ### P2-B. A Placement forward that finds the box out of view returns 503 with no recovery - **Task:** 2 (snapshot scope) and 3 (edge fallback). - **Problem:** - The candidate scope requires a dialable address but not a mirrored mesh key (plan line 97). - "No mesh key" for a chosen Placement peer answers 503 (line 105), and only Placement turns out-of-view into a 503 (line 235). - Out-of-view never marks the box suspect, because only a failed dial does (line 103). - **Evidence:** - `forwardHA` returns out-of-view when there is no key (`edge/forwardha.go:191-194`). - The keys may be nil when nothing has been minted or mirrored yet (`edge/homemap.go:1170-1180`), and a failed key read keeps the last good copy, which is nil at boot (`homemap.go:1159-1168`). - **Failure scenario:** a region-HA deployment whose mesh key was never minted, or a box whose boot key read failed. Every free wake whose H4 or releaser choice is a peer gets a 503, about half of them, and the next request picks the same peer again. On main, all of them wake locally. A peer whose file vanishes between the snapshot and `boxInView` is only a one-request blip. - **Fix:** in the snapshot projection, include peers only when a signing key is mirrored (the same value `forwardHA` checks). Also, either treat a Placement out-of-view result as a local acquire (safe, because placement is advice) or mark the box suspect. Add a test for no key with a free host. - **Invariant:** I4, the same family as R1 P1-3. ## P3 1. **Task 2/3, request-path cost.** `ForwardTarget(ctx, rt, s)` takes the snapshot eagerly, so every request to every hibernating HA route builds and deep-copies a `WakeSnapshot`, including awake-here and cached-holder hits (`haforward.go:116-121` bypass after the call). Pass a lazy function instead, or project only after the bypass and holder checks. 2. **Task 3, cache tag ambiguity.** `holderCache.placement(host,ref)` "tags choice" (line 237), but `TestPlacementCachesObservationNotChoice` says a fold change recomputes the choice. If a fold moves within the 10 s window after a successful forward, the next request can choose the local box and hit a held refusal. Main has an equivalent race, but rev 2 should say whether the tag keeps the host on the same target until the observation's deadline. 3. **Task 4, simulation shape.** `DecidePlacement` lives in `activator`, while the simulation imports only `hafresh`, and its mutations change caller inputs, never production code (`sim/regionha/rules_test.go:36-40`). State that each placement mutation alters what the model hands `DecidePlacement`, or move the pure rule into a small package. 4. **Task 3 vs spec §20.** The page is throttled once per region per hour per process, so N boxes send N pages. The spec says at most once per region per hour. Record this as an accepted deviation. 5. **Task 5A step 4, fault method.** No fault method is named. P1b-2 used `systemctl kill -s KILL carlos-edge`, which restarts in about 1 s and turns held hosts into expired-owner leases, not free hosts. Name SIGSTOP and SIGCONT for at least 10 s, or a block on the backhaul port. 6. **Citation nits.** `hacache.go:31` is the comment above the constant at 33. `homemap.go:126` is a closing parenthesis. **Note on stopping rule 2:** both P2s break R1 P1-3's invariant (I4, "placement must preserve main's recovery"), so this family has now drawn findings two rounds running. P2-A is the rev 2 fix's own "any answer clears" rule. The controller should offer Paul the rule-2 choice. I recommend the central-invariant option: "a placement target that has not woken the host is excluded for 10 s", enforced only in the suspect list and checked by sim I5. That is also the fix for both P2s. I made no edits and ran no tests. Every finding above comes from reading the code at the cited lines. **READY AFTER FIXES**</result> <usage><subagent_tokens>213555</subagent_tokens><tool_uses>53</tool_uses><duration_ms>776603</duration_ms></usage> </task-notification>

diff --git a/docs/superpowers/plans/REVIEW-REGION-HA-P1B3-R2.md b/docs/superpowers/plans/REVIEW-REGION-HA-P1B3-R2.md
new file mode 100644
index 000000000..2dfa4986f
--- /dev/null
+++ b/docs/superpowers/plans/REVIEW-REGION-HA-P1B3-R2.md
@@ -0,0 +1,77 @@
+# Review: region HA P1b-3a plan, round 2 (Opus)
+
+**Round 1 dispositions** (checked against the code at 44d810d0; `a905f09c` changes only docs on top of it)
+
+- **P1-1 (expired owner sent to H4): resolved.** `DecidePlacement` never sends an owner-bearing lock to H4. A lock this box owns goes to the local acquire. An expired peer owner gets a Recovery hint, which falls back to the local acquire once that peer is out of view or suspect (plan lines 89-90 and 234). This matches `hafresh/acquire.go:87-106`. Witness and mutation are named.
+- **P1-2 (switch off refuses born-HA wakes): resolved.** The switch reaches the rule as `Enabled`, read from the parsed switch (`edge/homemap.go:162-165,362`; same parser as `host/boxrecord.go:25-28`). Off means the local acquire. Recovery and placement hints change caching only for their own kinds. Holder entries keep P1b-2's drop rules, so the off path matches main.
+- **P1-3 (unreachable target never excluded): resolved for dial failures.** A per-box suspect list is filtered before both the releaser preference and H4. A target that answers but cannot wake, or that is out of view, is a new gap (P2-A and P2-B below).
+- **P2-1 (503 window for a new host): resolved.** The serving box qualifies through its own local route; peers still need to publish the host.
+- **P2-2 (extra lock reads after a refusal): resolved.** The original 10 s observation is kept, with a budget row and counters. Repeat refusals cost 1 GET at the receiver and 0 at the ingress, which matches main's single local read.
+- **P2-3 (no witness for the agent wiring): resolved.** One arming function is called once by `runAgent` and run by the witnesses. The single-call syntactic check follows `host/haforward_wiring_test.go:15-39`.
+- **P2-4 (incomplete copy deck): resolved.** C2 now has a subject row (`PageOperator(ctx, level, subject, body)`, `host/alertsink.go:137`). The C1 and C2 destinations are corrected.
+
+**What holds:**
+- **One writer.** `lease.AcquireHA` is still the only authority (`lease/ha.go:59-128`). Placement and Recovery never write and never supply a proof. Stale views and differing views end at the conditional PUT. A verified hop is never chosen again (`edge/forwardha.go:148,184`).
+- **Front-door exclusions.** All new paths run inside `frontForwardHA` after its existing exclusions (`forwardha.go:148-151`): legacy hosts, regional names, doors, tunnels, static routes and verified hops. The edge starts after the activator (`host/agent.go:744-746`, then 1048) and drains before `svc.Shutdown` (`agent.go:1117-1128`). So a peer that is restarting or shutting down shows up as a dial failure, which the P1-3 fix covers.
+- **Budget.** All publication and fold claims check out:
+ - headroom stays outside the change gate (`host/edgesfile.go:945`), and the timed pass forces a write (`edgesfile.go:962`);
+ - `putReplacing` makes 3 attempts (`host/snapshot_loop.go:221-235`) and the change index makes 4 (`release/changeindex.go:31,130`);
+ - a first wake adds one LIST (`lease/ha.go:100-108`).
+- **Applicability: one table, and the five cases hold.**
+ - Switch off, self adoption and a missing view behave exactly as main.
+ - A true-holder suspect behaves as main.
+ - An expired owner differs from main on purpose: a Recovery hop to the owner replaces a local acquire that would have been refused without a termination proof. That is an improvement and safe.
+ - Outcome handling sits outside the table: edge fallback by kind, `NoteForward`, and the suspect list's clear rule. Both P2s live there.
+- **Mixed-version roll.** It is safe: the new fields are additive and old receivers take a placement hop exactly as they take a P1b-2 hop.
+
+## P1
+
+None.
+
+## P2
+
+### P2-A. A target that answers but cannot wake is never avoided
+- **Task:** 3 (suspect list, `NoteForward`), plus the Task 4 simulation.
+- **Problem:**
+ - Rev 2 clears a box's suspicion on "any answer from that ref, any kind" (plan lines 103 and 238).
+ - For Placement, an answer of "none" or a 503 with no holder header keeps the cached observation (line 237), so the next request picks the same box again.
+ - Only a failed dial excludes a box. A box that is reachable but refuses or hangs on every wake stays the choice.
+- **Evidence:**
+ - Any refusal other than a held lease is answered `X-Carlos-Holder: none` (`activator/haforward.go:207`). That covers `ErrNoSelf` (`lease/ha.go:33,70-72`), an owed marker PUT that fails (`ha.go:82-86`), and a failed generations write (`activator/generations_file.go:267-271`).
+ - A hang after connecting answers 502 with Status 0 (`edge/forwardha.go:210-212`).
+ - The edges loop keeps publishing a fresh file with headroom throughout (`host/edgesfile.go:1228-1231`).
+- **Failure scenario:**
+ 1. leo's lease identity is incomplete (IMDS failed at boot; it retries every minute, `host/haself.go:47-74`), or leo's data volume turns read-only.
+ 2. sophie sends every host leo released cleanly, and every host where leo is roomiest, to leo.
+ 3. leo answers "none", so the visitor gets a 503. leo's file stays fresh, so this repeats indefinitely.
+ 4. On main, sophie wakes all of these hosts locally.
+- **Fix:** for Placement only, treat "none", a headerless 503, a 502 or Status 0 from the target as a failure of that box. It becomes suspect for 10 s under the same epoch rules, and only a success or a holder-naming answer clears it. This is safe because a placement target holds no lease for that host. Add a simulation action for a peer that refuses or hangs while staying in view, plus a mutation `placement-refusal-clears-suspect`.
+- **Invariant:** I4 / sim I5, "placement never strands a host main would wake". This is R1 P1-3's family.
+
+### P2-B. A Placement forward that finds the box out of view returns 503 with no recovery
+- **Task:** 2 (snapshot scope) and 3 (edge fallback).
+- **Problem:**
+ - The candidate scope requires a dialable address but not a mirrored mesh key (plan line 97).
+ - "No mesh key" for a chosen Placement peer answers 503 (line 105), and only Placement turns out-of-view into a 503 (line 235).
+ - Out-of-view never marks the box suspect, because only a failed dial does (line 103).
+- **Evidence:**
+ - `forwardHA` returns out-of-view when there is no key (`edge/forwardha.go:191-194`).
+ - The keys may be nil when nothing has been minted or mirrored yet (`edge/homemap.go:1170-1180`), and a failed key read keeps the last good copy, which is nil at boot (`homemap.go:1159-1168`).
+- **Failure scenario:** a region-HA deployment whose mesh key was never minted, or a box whose boot key read failed. Every free wake whose H4 or releaser choice is a peer gets a 503, about half of them, and the next request picks the same peer again. On main, all of them wake locally. A peer whose file vanishes between the snapshot and `boxInView` is only a one-request blip.
+- **Fix:** in the snapshot projection, include peers only when a signing key is mirrored (the same value `forwardHA` checks). Also, either treat a Placement out-of-view result as a local acquire (safe, because placement is advice) or mark the box suspect. Add a test for no key with a free host.
+- **Invariant:** I4, the same family as R1 P1-3.
+
+## P3
+
+1. **Task 2/3, request-path cost.** `ForwardTarget(ctx, rt, s)` takes the snapshot eagerly, so every request to every hibernating HA route builds and deep-copies a `WakeSnapshot`, including awake-here and cached-holder hits (`haforward.go:116-121` bypass after the call). Pass a lazy function instead, or project only after the bypass and holder checks.
+2. **Task 3, cache tag ambiguity.** `holderCache.placement(host,ref)` "tags choice" (line 237), but `TestPlacementCachesObservationNotChoice` says a fold change recomputes the choice. If a fold moves within the 10 s window after a successful forward, the next request can choose the local box and hit a held refusal. Main has an equivalent race, but rev 2 should say whether the tag keeps the host on the same target until the observation's deadline.
+3. **Task 4, simulation shape.** `DecidePlacement` lives in `activator`, while the simulation imports only `hafresh`, and its mutations change caller inputs, never production code (`sim/regionha/rules_test.go:36-40`). State that each placement mutation alters what the model hands `DecidePlacement`, or move the pure rule into a small package.
+4. **Task 3 vs spec §20.** The page is throttled once per region per hour per process, so N boxes send N pages. The spec says at most once per region per hour. Record this as an accepted deviation.
+5. **Task 5A step 4, fault method.** No fault method is named. P1b-2 used `systemctl kill -s KILL carlos-edge`, which restarts in about 1 s and turns held hosts into expired-owner leases, not free hosts. Name SIGSTOP and SIGCONT for at least 10 s, or a block on the backhaul port.
+6. **Citation nits.** `hacache.go:31` is the comment above the constant at 33. `homemap.go:126` is a closing parenthesis.
+
+**Note on stopping rule 2:** both P2s break R1 P1-3's invariant (I4, "placement must preserve main's recovery"), so this family has now drawn findings two rounds running. P2-A is the rev 2 fix's own "any answer clears" rule. The controller should offer Paul the rule-2 choice. I recommend the central-invariant option: "a placement target that has not woken the host is excluded for 10 s", enforced only in the suspect list and checked by sim I5. That is also the fix for both P2s.
+
+I made no edits and ran no tests. Every finding above comes from reading the code at the cited lines.
+
+**READY AFTER FIXES**
\ No newline at end of file