carlos / platform Public

spec §25: round 3 P2 fixes; four P1s with options for Paul (§25.14)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 00572890a7ee9bcb69d8c2f963bc03ded5b9d676 parent acfd525
1 file changed, +23 −10
  • docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md +23 −10

CI cancelled — superseded by a newer push — run details

Intent

Human

<task-notification> <task-id>bnl66qoh2</task-id> <tool-use-id>toolu_01KJqVVyveMDXkkosDaXKSuv</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/283be278-5c6a-4a71-a8d6-b3d32c668985/tasks/bnl66qoh2.output</output-file> <status>completed</status> <summary>Background command "Wait for Astra round 3" completed (exit code 0)</summary> </task-notification>

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 faa442da6..01a562c91 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.6** (§25 held requests during a planned handover, 2026-11-08, for Paul's approval; rev 6.5 added §7.5 DR-5): 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.6** (§25 held requests during a planned handover, 2026-11-08, for Paul's approval; Astra rounds 1-3 spent, round 3 left 4 P1s with proposed cuts in §25.14; rev 6.5 added §7.5 DR-5): 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.
@@ -1086,14 +1086,14 @@ The roll tool runs a new root verb, `carlos system group-maintenance drain`, ove
1. **Withdraw, acknowledged.** A publishes a box-level drain state in its edges file, and from then on places nothing on itself. The field withdraws placement only. Name authority, admission and holder reachability are unchanged, so A keeps answering as a holder and a forwarder (R2.9). Placement reads it as local-denied (`internal/edge/wakeplacement.go:36-42`), and that includes §6.3 rule 1, so a clean marker naming A no longer sends a wake to A. The builder fixes the field with a reader table under §24's rule.
- A timer does not prove that peers folded the change (R2.9). So A sends a signed `/.carlos/ha-drain` hop to every live box of the deployment that views its region, fixed forwarders and other regions included. Each receiver refreshes its fold of A's edges file at once, which is one normal fold read, and answers whether it now sees A draining. A asks again every 5 s. The drain goes on only once every such box has acknowledged. A box that cannot be reached, or does not acknowledge within 2 minutes, makes the drain fail (failures, below).
+ A timer does not prove that peers folded the change (R2.9). So A sends a signed `/.carlos/ha-drain` hop to every live box of the deployment that views its region, fixed forwarders and other regions included. Each receiver refreshes its fold of A's edges file at once, which is one normal fold read, and answers whether it now sees A draining. A asks again every 5 s. Each request names the drain transaction and the generation of A's edges file. A receiver that has already folded that generation answers from memory with no new read, so each receiver costs one fold read per round however often it is asked (R3.9). The drain goes on only once every such box has acknowledged. A box that cannot be reached, or does not acknowledge within 2 minutes, makes the drain fail (failures, below).
2. **Quiesce (H5).** A closes its local start gate for tenant leases. It then settles everything that crossed the gate before it closed: wakes that are restoring, acquires waiting on their conditional PUT, and lost-lease recovery workers. Each either ends awake, and is then moved in step 3, or fails. Pending stops and marker obligations are kept and settled (§5.2). Nothing is cancelled in a way that would drop a writer proof.
3. **Move each awake host H,** up to 4 at a time, busiest first:
1. *Hold.* From now `MoveState(H)` is `holding` (§25.5).
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), or the HRW box for an always-on worker (A10). 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). `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).
+ 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. **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).
@@ -1131,7 +1131,7 @@ A marked held-stream request is classified the same way. While H is held its mar
| Held requests per box | 1,024 | the same |
| Whole-body copy on C | 64 KiB | not replayable |
-**Silence is not suspicion.** Today a connected holder that sends no headers within 3 s is made suspect (`internal/edge/forwardha.go:332`), and a suspect holder's next requests are refused (`forwardha.go:222`). A held hop is silent by design, so no box makes a box in the drain state suspect for silence. A connection failure still counts, as today.
+**Silence.** Today a connected holder that sends no headers within 3 s is noted `ForwardSilent` (`internal/edge/forwardha.go:332`). That marks the entry silent, not suspect: it costs one lock re-read and does not refuse later requests (`internal/activator/hacache.go:264-289`, `:478-484`, pinned by `hasuspect_test.go:672-725`). A held hop is silent by design, so no box takes that re-read or any placement suspicion for silence from a box in the drain state. All other silent, suspect and unreachable behaviour is unchanged (R3.7).
**The headers.** `X-Carlos-Handover` is honoured only on an answer to a hop sent over the verified forward or backhaul transport. It is stripped from app responses at the tenant boundary, beside `X-Carlos-Holder` (`stripAppHolder`, `forwardha.go:118-128`). Only the platform sets `X-Carlos-Replayable`, and it is removed from inbound client requests.
@@ -1165,16 +1165,16 @@ The take is a new hop endpoint on every HA box, `/.carlos/ha-take`, signed with
- wakes H, and answers once H is awake or the wake has failed, within the wake wait bound;
- answers with the owner it read or wrote in `lock.json`: itself, another box (held), or none.
-A take is a forwarded wake without a visitor, and it authorizes nothing the acquire table does not already allow. A box advertises it with an additive edges field, `ha_take: 1`.
+Both control paths, `/.carlos/ha-take` and `/.carlos/ha-drain`, are reserved on every ingress: a client request for either is refused at the front door and never forwarded. Each carries its own signature over the method, path, body, drain transaction and timestamp, as probe-burst notices do (`internal/edge/burst_notice.go:499-529`). The ordinary hop signature is not enough, because it binds only host and time (`internal/edge/mesh.go:188-190`). Bodies are bounded at 4 KiB (R3.8). A take is a forwarded wake without a visitor, and it authorizes nothing the acquire table does not already allow. A box advertises it with an additive edges field, `ha_take: 1`.
### 25.8 What clients see
-- **Zero errors** for every request whose first attempt reaches A. That covers requests through the NLB before Standby, from a peer whose cache names A (the normal in-region case), or through a fixed forwarder in the region. The body must be empty or at most 64 KiB, unless the request reached A directly. The pause is the rest of H's in-flight work (up to 10 s, usually milliseconds), plus the release (about 1 to 3 s), plus the successor's acquire and restore. The target is under 5 s for a small host.
+- **Zero errors** for every request whose first attempt reaches A. That covers requests through the NLB before Standby, from a peer whose cache names A (the normal in-region case), or through a fixed forwarder in the region. The body must be empty, or have a known length of at most 64 KiB and be copied whole before the first send (H2). An unknown-length body, however small, is not replayable. A request that reached A directly streams its body and has no size limit. The condition is the attempt number on arrival at A and the body's framing, on every ingress path, not the client's region (R3.6). The pause is the rest of H's in-flight work (up to 10 s, usually milliseconds), plus the release (about 1 to 3 s), plus the successor's acquire and restore. The target is under 5 s for a small host.
- **Today's 503 with `Retry-After: 10`,** only in the seconds that host is moving, for:
- - a hop whose body is over 64 KiB;
- - a request whose first attempt went to another box that named A, as most cross-region requests do (H3);
+ - 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);
- 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.
+- **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).
- **An unplanned death:** today's behaviour, unchanged.
### 25.9 The floor
@@ -1193,7 +1193,7 @@ A drain is only safe when every box that may send A a request understands the ne
- **Steady state:** unchanged. Nothing polls. `ha_take` rides the existing edges publication.
- **Per drain:**
- two edges mutations (the drain state, then `drained`), each with its change-index update and §18's reader amplification;
- - two acknowledgement rounds, each costing one fold read per live box (one LIST plus one GET per edges file, as at any fold);
+ - two acknowledgement rounds, each costing one fold read per live box (one LIST plus one GET per edges file, as at any fold). A failed fold read is retried at the 5 s cadence, so the worst case is 24 fold reads per box per round. The change-index fold that the publication triggers anyway is separate;
- the tool's lock check: one LIST of the region's locks plus one GET per HA host.
- **Per host moved:** the marker PUT, as at any sleep, plus the successor's acquire (1 GET + 1 PUT) and restore, which the host's next wake would have cost anyway.
- **Example:** replacing all 4 members of a region with 200 awake hosts, some moved twice, costs about 300 markers and acquires, 8 edges mutations, 8 acknowledgement rounds over 6 boxes, and 4 lock sweeps of 500 hosts. That is about $0.01 in S3 requests, plus the restore GETs.
@@ -1283,3 +1283,16 @@ W1 to W4 passing on a release at the floor is what retires the DR-4 rule.
- **Q1. Surge replacement.** `replace` drains and terminates first, so capacity is N - 1 for a few minutes. Launching first needs a second N-HA14 exception: maximum and desired up by one for the transaction. Recommendation: drain first for now.
- **Q2. The narrowed guarantee (§25.8).** Zero errors covers in-region traffic and bodies up to 64 KiB. Cross-region requests that first reach another box, and hops with larger bodies, keep today's 503 for the seconds a host moves. Closing those gaps needs either a third, handover-only attempt (an exception to I4) or a bounded body spool on every forwarding box. Both drew P1s twice in review. Recommendation: accept the narrower guarantee now and measure W5.
- **Q3. Drain time.** Two acknowledgement rounds, about 5 s per host at 4 at a time, and up to 60 s of connection drain make about 3 to 4 minutes for 40 awake hosts. Recommendation: accept.
+
+### 25.14 Round 3 (final): four P1s for Paul
+
+Astra round 3 (`~/.cache/region-ha-held/ASTRA-R3.md`) was NOT READY, with 4 P1s and 5 P2s. The P2s are applied above (R3.5 to R3.9; R3.7 corrected a false claim about silent holders). The review budget is spent, so there is no round 4 (stopping rule 1). Each P1 below has the smallest cut that removes it, and a recommendation. None is applied yet. **Paul rules, and the build starts only after.**
+
+| P1 | The defect | Options | Recommendation |
+|---|---|---|---|
+| R3.1 | H5 certifies a snapshot. A request a peer chose earlier can still reach A's open listener after the report. And if the agent restarts after the tool's last check, the new incarnation is not draining and can acquire while the provider call is in flight. | (a) **Retained fence:** a root-owned fence bound to the transaction id, kept across agent restarts, that refuses every tenant start until the tool returns the member or cancels. For replace and remove, the tool stops the edge under that fence, then proves the process gone, before the provider call. For roll, the restarted agent starts behind the fence. (b) Cut: the zero-error claim covers holds only, and the action may cut a request that arrives after the report. | (a). It is small: one fence file read at the start gate, plus a stop under maintenance the tool already orchestrates. |
+| R3.2 | `MoveState` is read once. A request that read "none" just before the move started is neither held nor counted as in flight, so it can be refused when it reaches the stopping host. The front-door hook also runs before the final route is chosen (alias, metadata and gate-login routes). | (a) **Admission tickets:** `MoveState` registers a ticket under the same lock that starts holding, and the move waits for outstanding tickets (within the 10 s drain) before it stops the app. The hook runs on the host's primary identity after route resolution, and keeps name, door and regional checks. (b) Cut: keep DR-4 lock-free maintenance for members with live tenant traffic until (a) exists. | (a). It is the barrier H1 needed. Option (b) gives up the goal. |
+| R3.3 | The full-duplex answer covers only the replayable handover answer. A non-replayable upload is held unread, then refused through an ordinary `http.Error`, which can block on draining a slow body past every bound. | Refuse non-replayable hops at once, before queueing, and send every handover exit (success, refusal, cap, timeout, loss, failed move) through one bounded full-duplex response path with connection close. | Accept. It also shortens the error for those requests. |
+| R3.4 | `taken` is dropped after 30 s. A peer that still caches A for a host that moved early sends its first attempt to A, and A, closed to starts, refuses before it finds the new holder. Within the 30 s, the remembered holder may also have slept, with a third box now holding. | (a) Keep the redirect for the **whole drain**, until `drained` is acknowledged and peers have dropped A. Each redirect answer is checked by one coalesced lock read on A (at most one per host per 5 s): it names the current owner, or the placement choice when the lock is a marker, which a hop receiver may acquire (§6.4). (b) Cut: no redirect after the take. Post-take stale hops get today's answer, which in practice means most in-region traffic for a host moved early. | (a). The lock reads are bounded per drain and per host, and run only on the draining box. |
+
+If Paul takes the four recommendations, they become §25 r4 as refusals and barriers, with no fourth review round. The branch review of the build and its census cards are where they are checked next. That is how rev 5 of this spec was settled on 2026-10-26.