carlos / platform Public

spec: region HA §24 and §25 amendments from the held-requests build

§24 gains reader rows E10 to E13 for the drain fields (the silence rule,
the holder-cache drop, the drain acknowledgement receiver and the take
capability) and the roll tool's ha_take floor read, plus a note that the
drain state reuses the box-level draining field.

§25.4: taken lasts until drained is acknowledged; the connection drain
closes a barrier, closes every edge-held stream at an event boundary,
then cancels what still runs at 60 s. §25.8: door calls, tunnel
deliveries and regional names for a moving host are refused at once,
and a body-carrying backhaul closes the client connection on an early
answer. §25.15: the fence is /var/lib/carlos-group-fence, persistent
across reboot. The owed items are listed at the end.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 1a1c585e5de24774514281b8325538add7c23e24 parent cc8c08a
1 file changed, +25 −5
  • docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md +25 −5
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 ced37c1fd..e713f4b9b 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
@@ -1000,7 +1000,19 @@ the same rule for every box.
| C16 | Console and CLI region names | Blind: any member can name its AWS region. |
| C17 | Asset status home election | Blind, with the same member routing rules as E2. |
| C18 | Domain attach conflict check | Blind: live member routes reserve names, as H2. |
-| Scripts | Group roll and boot witness | Aware operator tools: inspect members by reference and check that a completed witness left no member files. |
+| Scripts | Group roll and boot witness | Aware operator tools: inspect members by reference and check that a completed witness left no member files. The roll tool's §25.9 floor check reads `ha_take` on every live box of the region's view, fixed forwarders included, and refuses a drain unless each says the number 1. A stale member file counts until departure removes it. |
+| E10 | Silence rule (`Edge.PeerDraining`, read by the activator's `NoteForward`; §25.5) | Blind: a box whose file says `draining` or `ha_drained` is not made silent or suspect for a held answer. Dial failures still make any box suspect. A terminated member that was draining keeps that file until departure, so only its silence is ignored. |
+| E11 | Holder-cache drop (`notePeerDrained`, §25.4 step 4) | Blind: a file that says `ha_drained` drops this box's holder-cache entries naming that box, once per publication (its `ha_drain` id, else its generation). A stale drained file drops nothing new. |
+| E12 | Drain acknowledgement receiver (`/.carlos/ha-drain`, `foldedDrain`, §25.4 step 1) | Blind: it reads the asker's own file by its exact key and answers whether its fold shows `draining` or `ha_drained` under the asked `ha_drain` transaction and id. A file that no longer matches, a stale one included, is answered as not seen. |
+| E13 | Take capability (`takeCapable`, `Edge.PeerTakes`; §25.7) | Blind: a box is asked to take only when its file says `ha_take` as the number 1. Absent, other numbers, strings and booleans mean no. A stale member file can still name a successor; the take then fails its dial, and the drain tries the next candidate or fails. |
+
+The drain state reuses the existing box-level `draining` field, so the
+placement readers already listed (E5, C1, C6, C10, H5, and db-read
+elections on the box itself) treat a draining box as withdrawn from
+placement. `ha_drained` is additive and implies `draining`; E5 reads it
+too. Neither is admission's `drained` (`box_role`, `admitted`, `drained`),
+so name authority, admission and holder reachability (E1, E2, E4, C17)
+are unchanged while a box drains.
For C11, actual fresh host publication keeps a box in the size check even
when its declared pool excludes the record. Missing or unreadable record
@@ -1093,8 +1105,8 @@ The roll tool runs a new root verb, `carlos system group-maintenance drain`, ove
2. *Finish in-flight work.* Requests already admitted to H's app get up to 10 s, today's HTTP drain bound. Then the stop proceeds as a shutdown stop does, which ends long requests, WebSockets and edge-held stream legs (#432 G5).
3. *Release.* `finishStop` writes the marker (§5.2), with the drain as its stop reason and the existing budgets.
4. *Take.* A chooses a successor B: `ChooseRoomiest` over its eligible serving set (§6.3). **Always-on workers are not taken** (build ruling, 2026-11-09): the duty rule (§7.1, A11) gives a released worker's duties to its releaser, and a take that moved them would need new authority in the duty layer, the I3 family. A drain releases each worker with a marker, which leaves no lease naming A (H5), and the worker resumes on its HRW box (A10) through the departure scan's import (§7.4) after the provider action. The report lists such workers as released. A sends B a signed take request (§25.7). B acquires and wakes H, then answers with the owner it now sees in `lock.json`. That owner is the **confirmed holder**: B, or a third box that won the marker first (§6.7).
- 5. *Release the holds* (§25.5). Edge-held SSE streams for H whose outer connection is on A are closed now, at an event boundary, so they reconnect to the new holder without waiting for the rest of the drain (R3.5). `MoveState(H)` becomes `taken(holder, lock generation)` for 30 s, and then the entry is dropped. After that, a stale hop for H is answered as by any non-holder (§6.4).
-4. **Drain the connections.** When no lease names A, it publishes `drained` and asks for the same acknowledgement as in step 1. Peers drop holder-cache entries naming A (§6.6). A then sends `Connection: close` on every response, closes idle keep-alive connections, and waits up to 60 s for the requests it is still forwarding to finish. Edge-held SSE streams still open through A are closed at an event boundary, and the browser reconnects through the NLB to another box, with `Last-Event-ID`. WebSockets and responses still running at 60 s are closed, and the report counts them.
+ 5. *Release the holds* (§25.5). Edge-held SSE streams for H whose outer connection is on A are closed now, per host, at an event boundary, so they reconnect to the new holder without waiting for the rest of the drain (R3.5). `MoveState(H)` becomes `taken(holder, lock generation)` and stays so until `drained` is acknowledged (§25.15 R3.4).
+4. **Drain the connections.** When no lease names A, it publishes `drained` and asks for the same acknowledgement as in step 1. Peers drop holder-cache entries naming A (§6.6). A then closes a barrier: a request that arrives after it gets today's 503 with `Retry-After: 10` through the bounded exit and is never forwarded. A sends `Connection: close` on every response, closes idle keep-alive connections, and closes every edge-held SSE stream still open through it at an event boundary; the browser reconnects through the NLB to another box, with `Last-Event-ID`. A then waits up to 60 s for the requests it is still forwarding to finish. WebSockets and responses still running at 60 s are cancelled and their connections closed, and the report counts them. The drain fails if they have not all ended 10 s after that.
5. **Report.** The report lists hosts moved, each one's confirmed holder, the longest hold, holds that got today's answer, unclean releases, connections closed at the bound, and the agent's incarnation. The agent keeps it until it exits, for the tool's pre-action check (H5).
**Failures.** A drain fails, and the tool refuses the provider action, when:
@@ -1174,8 +1186,10 @@ Both control paths, `/.carlos/ha-take` and `/.carlos/ha-drain`, are reserved on
- a hop whose body is over 64 KiB or of unknown length;
- a request whose first attempt went to another box that named A, on any ingress path; most cross-region requests are like this (H3);
- a cross-region request with a body (Q2: the body rule is in-region only);
+ - a call through the edge-local door (#175 P7), a tunnel delivery, or a request on a regional name for the moving host. None of these can be forwarded to another box, so A refuses them at once through the bounded exit (§25.15 R3.3) rather than holding them (build ruling, 2026-11-08);
+ - a request that arrives at A after its connection drain has begun (§25.4 step 4);
- any bound hit or failed move.
-- **Connections:** keep-alive connections are closed between requests. SSE streams reconnect with `Last-Event-ID` after the browser's retry delay. WebSockets still open through A 60 s after its leases have moved are closed, and their clients reconnect. Requests already dispatched to an app (uploads, downloads, upgrades) that run past H's 10 s drain, or past the final 60 s, are cut and never retried, because they may have reached the app (R3.5).
+- **Connections:** keep-alive connections are closed between requests. Any backhaul that carries a body closes the client's connection when the upstream answers before the client has finished sending, so the edge never drains an unbounded upload after an early answer; the client reconnects once and sees no error (build ruling, 2026-11-08). SSE streams reconnect with `Last-Event-ID` after the browser's retry delay. WebSockets still open through A 60 s after its leases have moved are closed, and their clients reconnect. Requests already dispatched to an app (uploads, downloads, upgrades) that run past H's 10 s drain, or past the final 60 s, are cut and never retried, because they may have reached the app (R3.5).
- **Always-on workers** pause from their release until the departure finishes, a few minutes. They serve no HTTP requests.
- **An unplanned death:** today's behaviour, unchanged.
@@ -1304,7 +1318,7 @@ If Paul takes the four recommendations, they become §25 r4 as refusals and barr
Paul approved all four §25.14 recommendations and Q1 to Q3 as recommended: drain first, the narrowed guarantee with W5 measured, and the drain time. There is no fourth spec round. The branch review of the build checks these. Where §25.3 to §25.7 say otherwise, this section wins.
**H5 amended: a retained start fence (R3.1).** Quiescence is a state the transaction holds, not a report it reads.
-- `drain` installs a root-owned **start fence** bound to the transaction id, under the maintenance directory the group-maintenance verbs already own. The agent's tenant start gate refuses every start while a fence is present. The agent reads the fence at start and at every start decision, so a restarted agent is fenced too. Only the tool removes the fence: at ExitStandby for roll, at cancel, or when the member is gone.
+- `drain` installs a root-owned **start fence** bound to the transaction id, at `/var/lib/carlos-group-fence/fence.json`: the directory root's and 0755, the file root's and 0644, created by the group-maintenance verbs. It is not under the maintenance directory, `/run/carlos-group-maintenance`, because that directory is root's alone (0700) and the agent, which runs as `carlos`, could not read a fence there. It is on persistent storage, not `/run`, so a member that reboots during a transaction comes back fenced (build ruling, 2026-11-09). The agent's tenant start gate refuses every start while a fence is present. The agent reads the fence at start and at every start decision, so a restarted agent is fenced too. A fence that cannot be read, is not root's or does not parse fences all the same. Only the tool removes the fence, with `drain --cancel` or `fence-clear` of the same transaction: at ExitStandby for roll, at cancel, or when the member is gone.
- **replace and remove** stop `carlos-edge.service` under the fence after the drain report, prove the edge process gone, and only then make the provider call. A peer request chosen against an old snapshot then meets a closed port, not a box that might acquire.
- **roll**'s `apply` restarts the edge behind the fence, so the restarted agent can acquire nothing until the tool's return step.
- The pre-action check reads the fence, the report and the stopped edge. A fence of another transaction refuses.
@@ -1314,3 +1328,9 @@ Paul approved all four §25.14 recommendations and Q1 to Q3 as recommended: drai
**One bounded exit path (R3.3).** Every handover exit goes through one response function: success, refusal, cap, timeout, lost lease and failed move. It enables full duplex before writing, flushes headers, and closes the connection after the reply, so no exit waits for an unread body. A hop for a moving host that is not replayable, or is a second attempt, is answered at once through that function. It is never queued.
**The redirect lasts the whole drain (R3.4).** `taken(holder, gen)` is kept per host lifetime until `drained` is acknowledged, not for 30 s. Before A answers a hop from it, A checks the lock with one coalesced read, at most one per host per 5 s. The answer names the current owner, or, when the lock is a release marker, A's placement choice, which a hop receiver may acquire from the marker (§6.4). Anything else gets the bounded refusal. Budget: at most one lock GET per moved host per 5 s on the draining box, only while stale hops arrive.
+
+**What the build left owed (2026-11-09).** These are outside the branch and need their own steps:
+- **The operator policy.** The module code carries the new resource-scoped grants (terminate in this group only, launch-template version reads, and S3 list and get on `control/edges/` and the region's lock keys). Applying them with tofu is a step on a card Paul approves.
+- **One attended live call on dev** (§25.6) with the operator's real transport, before any window: in particular, a terminate of a Standby member without decrement must leave desired unchanged.
+- **The runbook** for `drain`, `drain --cancel`, `fence-clear` and the `replace` and `remove` transactions, on its own docs branch, through copy review.
+- **The dev witnesses** W0 to W5 (§25.10), on a release at the floor. DR-4's lock-free rule stays in every card until W1 to W4 pass.