region HA DR-5: spec §7.5 and plan for unserved-pool departures
A departure finishes when no surviving box serves the departed box's pool; departures finish within 3 minutes of proof.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+80
−1
docs/superpowers/plans/2026-11-08-region-ha-dr5-unserved-departures.md+52 −0docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md+28 −1
CI passed — run details
diff --git a/docs/superpowers/plans/2026-11-08-region-ha-dr5-unserved-departures.md b/docs/superpowers/plans/2026-11-08-region-ha-dr5-unserved-departures.md| new file mode 100644 |
| index 000000000..8f7d5621a |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-11-08-region-ha-dr5-unserved-departures.md |
| @@ -0,0 +1,52 @@ |
| +# Plan: DR-5, departures that finish when nobody serves the pool |
| + |
| +Spec: `docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md` §7.5 (rev 6.5). |
| +Branch `fix/region-ha-dr5`, worktree `.claude/worktrees/region-ha-dr5`. Ledger and scratch: `~/.cache/region-ha-dr5/`. |
| +No release, no live boxes, no infra. |
| + |
| +## Task 1: the N6 reproduction (red first) |
| + |
| +`internal/host/hadepartures_dr5_test.go`, on the `g3Departure` harness (real `armHADepartures`, real lock fixture, real record store, real journal; only time and the queue are faked). |
| +- Two group members, both terminated and enrolled at T (proof time). Self is a fixed box with no named pools (`CARLOS_POOLS` unset). |
| +- Records in pool `ha`, HA, born on the members. Member A is the releaser of two of them (clean markers, generations as in N6). Member B holds nothing. Some shared-pool records exist too. |
| +- The departure view (`Controller.Tick`) holds self (`served_pools ["shared"]` form as published), A and B (`served_pools ["ha"]`). |
| +- Inventory rounds run only when requested, through the real `inventoryNudger` with the fake clock, and each takes 20 s of walk. Steps run every 30 s as `work` does. Churn: one record write per 30 s, as in N6. |
| +- Assert: both departures `complete`, both edges files and both status snapshots 404, both queue messages acked, all within 3 min of T; no adoption of a pool `ha` host; their locks unchanged byte for byte; no page. |
| +- Assert steering unchanged: `steering.ConvergeDeployment` on a fake Route 53 with the edges files before and after makes the same record set (no change batch after retirement). |
| +- Today: A's departure never completes (fails on the rule), and B's takes more than 3 min under this model (fails on timing). Record both numbers in the ledger. |
| + |
| +Negative cases in the same file: |
| +- a surviving peer in scope publishes `served_pools` with `ha`: A's departure stays blocked (today's behaviour); |
| +- a peer with missing or malformed `served_pools`: blocked; |
| +- an incomplete departure view: blocked; |
| +- a held, unexpired lock naming A: waits until expiry, then unserved; never before; |
| +- a host whose placement differs from self's: still blocked (rule 2); |
| +- the rescan finds an unserved host's lock changed to a new owner: successor path as today. |
| + |
| +## Task 2: the unserved rule (spec §7.5 rules 1-3) |
| + |
| +- `hadeparture.BoxObservation` gains `ServedPools []string` and `PoolsKnown bool`; `edge.homeMap.departureView` fills them from the fold's `served_pools` (`PoolEvidence.Pools()`). |
| +- `ScanPass`: when `CanAdopt` is false, test `CanAdopt` again with the policy's pools set to the host's pool. If that passes and `c.unserved(ctx, d, h)` holds, fall through to the existing expiry wait instead of blocking. After the wait, record `Result = "unserved"`, keep the visit resolved, log `ha_departure_unserved departure=… host=… pool=…`, and skip the import. |
| +- `c.unserved`: the view is complete; every peer in scope either publishes known pools without the host's pool, or resolves (`Identities.Resolve`) to a box with an enrolled departure in the journal. Self is excluded (rule 2 covers it). |
| +- Rescan: a matching host already recorded `unserved` with the same lock generation stays resolved if `c.unserved` still holds; otherwise it blocks as today. |
| +- The completion line counts only imported hosts. |
| + |
| +## Task 3: timing (spec §7.5 Timing) |
| + |
| +- `step`: call `ScanPass` until it reports no due departure, at most 8 times, within the step's context. |
| +- `inventoryNudger.request`: a request inside the 60 s spacing records `pending` and arms one timer for the end of the spacing; `begin` is unchanged, so the spacing and the three-round limit hold. Unit tests on the nudger with a fake clock. |
| +- `ScanPass`: when a clean adoption pass sets `Rescan`, the next attempt is now, not +30 s. |
| + |
| +## Task 4: gates |
| + |
| +- Targeted tests: `go test ./internal/host/ -run 'Departure|HADeparture|Nudger' -count=1`, `./internal/edge/ -run Departure`, `./internal/hadeparture/`. |
| +- Cross-compile check for darwin and windows (`internal/host` builds there). |
| +- Astra review of the branch (`codex -m gpt-6-astra -c model_reasoning_effort="high"`), at most three rounds, stop at the first round with no P1. |
| +- Census card (`make census-card`, `make census-propose`), verdict on #280. |
| +- CI green on the tip; origin/main an ancestor. |
| +- Merge under the region HA standing approval: squash with `-expect`, subject under 80 characters. |
| + |
| +## Out of scope |
| + |
| +- A new pool server scanning for unserved hosts (follow-up on #421). |
| +- Any page or operator text: the new line is a diagnostic. |
diff --git a/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md b/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md| index f2f648c3e..478be3ae4 100644 |
| --- a/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md |
| +++ b/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md |
| @@ -1,6 +1,6 @@ |
| # Region HA without claims: N-box regions behind a load balancer |
| -Design, 2026-10-26, **rev 6.4** (§9.9 T1/DR-4, 2026-11-08): rev 6 APPROVED by Paul on 2026-10-26, plus his ruling N-HA7 the same day (a scope ruling, not a redesign: §2.1, §8.4, §13, §19). Astra rounds 1 to 3 are complete, and the review budget is spent (AGENTS.md, stopping rules). Branch `design-region-ha-no-claims`, cut from `origin/main` at ddf3b929. Nothing here is built. |
| +Design, 2026-10-26, **rev 6.5** (§7.5 DR-5, 2026-11-08): rev 6 APPROVED by Paul on 2026-10-26, plus his ruling N-HA7 the same day (a scope ruling, not a redesign: §2.1, §8.4, §13, §19). Astra rounds 1 to 3 are complete, and the review budget is spent (AGENTS.md, stopping rules). Branch `design-region-ha-no-claims`, cut from `origin/main` at ddf3b929. Nothing here is built. |
| This spec supersedes every claim-dependent part of "Region HA, spec 2: two-box regions" (`2026-10-15-region-ha-two-box-regions-design.md`, rev 21, cited **S2 §n**) and of spec 1 (`2026-10-04-region-ha-box-placement-design.md`, cited **S1 §n**). §16 lists what it reuses from S2, plan 2a (6834659c) and plan 2b (b1118925), and the removals this series owns. Line citations are to this worktree unless they name a module path. |
| @@ -12,6 +12,7 @@ This spec supersedes every claim-dependent part of "Region HA, spec 2: two-box r |
| - **Rev 6** is a scope cut Paul approved on 2026-10-26. Duty handoff drew a P1 in all three rounds, so the duty-file transfer protocol is deleted, not fixed again (stopping rule 2). Duties stay in local registries, as today. One scan-and-import moves them when a box leaves (§7.4). |
| - **Rev 6.2** adds the approved N-HA14 serialized operator ASG Standby maintenance exception to §12.1 (Paul, 2026-11-01). |
| - **Rev 6.4** records T1/DR-4 planned termination: shutdown ordering, release budgets and the real-terminate witness (§9.9, 2026-11-08). |
| +- **Rev 6.5** records DR-5: a departure finishes when no surviving box serves a departed box's pool, and departures finish within 3 minutes of proof (§7.5, 2026-11-08). |
| Under stopping rule 2, the families I2, I3 and I4 drew findings two rounds running. I2 and I4 are now stated as invariants, enforced in one place and checked by the simulation (§3.1). I3 drew a P1 in all three rounds, so rev 6 cuts its transfer protocol and restates I3 over the scan alone. |
| @@ -336,6 +337,32 @@ No duty files exist, and nothing is published for transfer. The wake state (time |
| **What can be lost.** A timer registered in the last second before a crash, before its wake state synced. The edges files' existing due entries for cross-box wake routing stay as they are, but failover does not depend on them. |
| +### 7.5 A pool nobody serves any more (DR-5) |
| + |
| +**The fault.** Dev rehearsal N6 (2026-11-08) destroyed the whole UK group. The fixed box dennis serves no named pool. Both members' departures were proven, but g-428c05c1 was the last releaser of both pool `ha` locks. §7.4 finishes a departure only when every host whose lock names the dead box is adopted or superseded. dennis may not adopt a pool `ha` host, and no other box could, so the departure never finished. Its edges file and status snapshot stayed, and the scan paged every retry. Flagship has the same shape: a US group plus the fixed box adi with no HA pool. Any switch-off or aborted bring-up would leave the same residue. |
| + |
| +**The rule.** A host whose lock names the departed box is **unserved** when all of these hold, and the scanning box then records it as discharged without importing it: |
| +1. The lock is a release marker naming the departed box, clean or not, or a held lock whose expiry the scanning box has seen pass. The scan already waits for expiry before any adoption (§9.4); it waits the same way here. |
| +2. The scanning box could adopt the host if it served the host's pool: same placement, an HA record with a lifetime, an instance or a sidecar whose placement rule this box meets, and this box is not denied. Every other refusal keeps blocking, as today. |
| +3. No box that could adopt it remains. The scanning box's departure view is complete, and every box in it with the same region, placement, data bucket and secrets key fingerprint either publishes known `served_pools` without the host's pool, or has a departure enrolled in this box's journal (its termination is proven). A box whose `served_pools` is missing or malformed counts as a possible server, so it keeps the departure blocked. |
| + |
| +An unserved host gets no import, and its lock is not touched. The departure then finishes as §9.3 says: edges file, index, status snapshot (DR-2) and queue message. The scan logs one diagnostic per host (`ha_departure_unserved`). It sends no page, because the operator removed the pool's last server. |
| + |
| +**Who finalizes.** Every HA box that enrolled the departure, as today; no new role. The departure controller already runs on every HA box, holds the termination proof and does the scan. Finalizing is idempotent: the deletes are conditional, and a box that finds the edges file gone moves on. The deployment housekeeper was considered and rejected. It is one elected fixed box and would add a dependency to every departure for a case the scan rule covers. A fixed-box-only rule was rejected too: a surviving member that does not serve the pool is in the same position as dennis. |
| + |
| +**What this does not change.** |
| +- **Takeover.** No box acquires, renews or rewrites the lease of an unserved host. A later server of the pool acquires it as §9.4 says: a release marker is open to any box, and an expired lock needs the persisted termination proof (N-HA16). "Takeover only after proof and expiry" stands. |
| +- **Serving.** Nothing here makes a box serve a pool it does not serve. Requests for the host keep failing until a box serving its pool exists, as they did the moment the pool's last server left. |
| +- **Duties.** The host's scheduled duties (due wakes, timers, ticks) stay in its wake state in S3 (§7.2). They run again when a box serving the pool wakes the host, which imports the wake state at restore (§5.3). Until then they do not run; nothing could run them. A box that later starts serving the pool does not scan for unserved hosts. That is a follow-up, not part of DR-5. |
| +- **The race.** A new server of the pool that has not yet published its edges file is invisible to rule 3. The departure can then finish without it; the new server still wakes the host on its first request, and the duties wait for that wake. |
| + |
| +**Timing.** N6 also took 5 min 44 s to retire g-2d46d1d5, which had nothing to adopt; the target was 5 minutes. Three delays added up: |
| +- each 30-second step scanned one departure, so two departures took turns; |
| +- an inventory round asked for inside the 60-second spacing was dropped rather than deferred, so a departure whose evidence came 30 seconds after another's waited for a later round; |
| +- the full lock rescan after a clean adoption pass waited a further 30 seconds. |
| + |
| +DR-5 changes all three. A step scans every due departure (up to 8, within the step's budget). An inventory request inside the spacing is kept and starts when the spacing ends; the spacing and the limit of three rounds per piece of evidence stay. The rescan is due as soon as the adoption pass is saved. The bound is **3 minutes from termination proof to edges file and status snapshot gone, under record churn**, with a production-wired test of the N6 shape (whole group gone, a fixed box with no named pools, churn writes) asserting it and asserting Route 53 steering unchanged. |
| + |
| ## 8. Per-instance files (H6) |
| ### 8.1 What is there |