carlos / platform Public

docs: region HA runbook fixes from branch review round 1

P1-1: box records are create-only and the bucket policy
BoxRecordsAreNeverDeleted refuses their deletion for every principal,
so a recreated fixed box cannot take over its old reference's record.
The runbook now has a recreated fixed box take a new reference, keep
the old identity entry until the old departure finishes, and remove the
old edges file to finish it.

P2-1: systemd keeps quotes inside a value; it is a sourcing shell that
strips the JSON's double quotes without the single quotes.
P2-2: SSM parameter scoping is an explicit Deny, so an added Allow
cannot get past it; copy with an operator credential, or widen
ssm_parameter_arn / turn scoping off for the copy.
P2-3: the identity map also lives in the region's SSM parameter for
group boxes.

Also adds the branch's P3 follow-up list.

Invariant: a box reference belongs to one instance for good.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 4ab867021dc98679881e7e9988e01cfabbb177e8 parent a11be10
2 files changed, +36 −23
  • docs/region-ha-runbook.md +17 −23
  • docs/superpowers/notes/region-ha-followups-p3.md +19 −0

CI cancelled — superseded by a newer push — run details

Intent

Human

<task-notification> <task-id>bb8g4hf4j</task-id> <tool-use-id>toolu_01W3tRP6jBFoJnqQ3jxVFD9H</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/acef84d4-5254-488e-9bf2-166a4d113752/tasks/bb8g4hf4j.output</output-file> <status>completed</status> <summary>Background command "Wait for Astra item 5 fix" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>a835cdd9ae252e521</task-id> <tool-use-id>toolu_015aReABDNh18TSxrTKPbTR9</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/acef84d4-5254-488e-9bf2-166a4d113752/tasks/a835cdd9ae252e521.output</output-file> <status>completed</status> <summary>Agent "Opus review item 5" 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>**Verdict: READY.** In round 2 the fix in a11be108 resolves all four round-1 findings and raises no new P1 or P2. **Round-1 findings:** - **P1-1 (one host's TLS failure failed other hosts' forwards to the same box): resolved.** The dial gate is TCP-only again (`forwardha.go:338-340`). Each request now does its own handshake after the gate, and a handshake error is never shared with waiters or kept as a standing failure. - **P3-1 (artificial `queued` witness): resolved.** The witness now times out a real second request queued behind a held connect. - **P3-2 (loosened paused-peer burst assertion): resolved.** The strict check is back, and all four requests now report unreachable in every variant. - **P3-3 (import grouping): resolved.** **Checks on the fix:** - **Deadline and lifetime:** the handshake ignores the visitor's cancel but keeps the original dial deadline (`forwardha.go:347`). Queue, TCP and TLS together still fit in the same 2 s as before, so the handshake can't outlive the request by more than that. It adds no goroutine. - **Isolation:** a TLS failure updates only its own request's observation (`forwardha.go:355`). - **R7:** a visitor hang-up can't produce a handshake error. The `tls` subtest covers this: the visitor cancels during the TCP connect, and the handshake that fails afterwards still reaches `NoteForward`. - **The P1-1 witness:** it really runs two hosts against one address. It shows the handshake for host A is under way, then that B gets a 200 while A is held, and that a fresh B connection succeeds within 2 s after A fails. **New findings (both P3):** - **P3-4:** the witness's "B's peer not suspect" checks pass only because B's success note lands before A's failure note. A is a holder forward, and N-HA15 turns its failure into a placement mark on the whole box. The ordering held in 30 repeat runs. A comment should say so. The transport assertions are the real proof and don't depend on this. - **P3-5:** time a request spends queued behind a healthy connect still comes out of its handshake budget. That predates item 5. The only change is that it can now also produce the late unreachable note after a cancel. One effect to be aware of, though not a finding: placement suspicion is per box by design (N-HA12, and N-HA15's remap). A real TLS failure for one host therefore still keeps that box out of placement for all hosts for 10 s. The result is a local wake, not a 503, and it is covered by the fixed rulings. **Tests:** the targeted edge tests pass, the two new witnesses pass under `-race`, and the P1-1 witness passed 30 repeat runs. I edited no tracked files and created no scratch files. Findings are in `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-followups/.superpowers/sdd/2026-11-03-region-ha-followups/review-item5-r2.md`.</result> <usage><subagent_tokens>119268</subagent_tokens><tool_uses>8</tool_uses><duration_ms>184443</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>a48df02ff2b789122</task-id> <tool-use-id>toolu_01KLysXXBtExtNdTpvrDSoP7</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/acef84d4-5254-488e-9bf2-166a4d113752/tasks/a48df02ff2b789122.output</output-file> <status>completed</status> <summary>Agent "Opus census review" 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>**Overall: APPROVED.** I gave 17 verdicts, all approvals: 6 changed units (3 body, 3 sites) and 5 envelopes. There are no new dispositions, nothing is escalated, and there are no P1 or P2 findings. I left three P3 notes. The review is at `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-followups/.superpowers/sdd/2026-11-03-region-ha-followups/census-review-opus.md`. That is the only file I wrote. `git status` is still clean, I committed nothing, and I used no scratch files. **Census card:** `make census-card` at tip `a11be108` reports the census as clean with seal `cfb026f1…c387`, which matches the card's target seal. All six claims match their units, and each claim describes the diff accurately. **What the branch changes for root:** - **Everything runs in the agent, not root.** The changed code runs only in `carlos agent`, which runs as `User=carlos` (`carlos-edge.service:19,28`). - **No new file access, exec or SQL.** The two new reads in `departureIdentities.Proof` reuse the existing registry identity lookup, which runs a fixed parameterized `SELECT`. - **The one change to takeover authority is a tightening.** The live EC2 fallback in `bindTerminationProof` used to run on any lookup error. It now runs only on `ErrProofUnbound` (`lease/termination_proof.go:66`). That error is returned in one place, and only when the pair, ref-only and iid-only lookups all come back cleanly as not found (`hadeparture_identity.go:202-209`). Any other error refuses. - **New outbound effects are bounded.** A refused departure finalizer pages at most once per host per hour, on its own 5-second context. The edge's TLS handshake can now finish after a request is cancelled, but only within the original dial deadline. **P3 notes:** 1. **Replaced fixed boxes (fails closed).** If a fixed box is replaced in place (same ref, new iid), the takeover is now refused and paged. On main it fell back to the live EC2 check. This is intended (commit `93f01b57`), but worth knowing before a dev drill that replaces a fixed box. 2. **Alert routing.** The retained-edges page subject is no longer the literal `ha_departure_edges_retained`. It is now prose, and only the journal notice still carries the code. Any alert filter matching the old subject will stop matching, so check routing before the roll. 3. **Edge routing only.** When a dial to an address fails, every request queued behind it has its observation marked failed. If such a request was also cancelled, it reports `ForwardUnreachable` once. The existing `NoteForward` still makes every suspicion and generation decision, and root cannot reach this code.</result> <usage><subagent_tokens>96792</subagent_tokens><tool_uses>23</tool_uses><duration_ms>189748</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>a9553afa820de5bfb</task-id> <tool-use-id>toolu_01Vfa5mR2pPQeWfHsJCU2QF5</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/acef84d4-5254-488e-9bf2-166a4d113752/tasks/a9553afa820de5bfb.output</output-file> <status>completed</status> <summary>Agent "Opus whole-branch review" 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>**Verdict: NOT READY.** The code is sound: the targeted tests pass and the census check reports clean. What blocks the merge is one step in the new runbook that can't be carried out on any deployment built from the standard bucket module, dev included. Findings are in `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-followups/.superpowers/sdd/2026-11-03-region-ha-followups/branch-review-r1.md`. **P1** - **P1-1:** In the recreated-box section, step 5 tells the operator to delete the old `control/boxes/&lt;box&gt;.json`. The bucket policy statement `BoxRecordsAreNeverDeleted` denies that delete to every principal (`infra/modules/deployment-buckets/main.tf:172-200`), so the delete fails. The new box can then never publish its record or be verified, and the old departure pages every hour indefinitely. The edges section's "a same-reference replacement finishes on its own" advice leads to the same dead end. Suggested fix: a recreated fixed box takes a new reference. Otherwise, reusing a reference needs a ruling to lift that policy statement. **P2** - **P2-1:** The runbook says systemd strips the double quotes from an unquoted identity map. It doesn't: `man systemd.exec` on systemd 257 says quotes inside a value are kept. A shell sourcing the file is what strips them. - **P2-2:** The SSM "temporary grant" step can't work. The role carries an explicit Deny on everything outside `ssm_parameter_arn`, and an explicit Deny overrides any Allow you add. The step has to widen `ssm_parameter_arn` or turn `scope_ssm_parameter_reads` off for the duration. - **P2-3:** Step 3 updates `CARLOS_HA_FIXED_BOX_IDENTITIES` on fixed boxes only. Group boxes build host.env from the SSM parameters, so the parameter and the group boxes need updating too. A group box with the stale map refuses to verify the new box. **P3** - **P3-1:** A binding made by the identity walk has no observation, and item 1 now treats that as "bound", so it refuses. That blocks the visitor's EC2 fallback on a box that never saw the peer alive. Boxes that did see it can still take over. - **P3-2:** "Without the setting, a box binds only itself" overstates it. Group boxes and fixed peers that are already bound stay bound. - **P3-3:** The character-set rule is enforced only by `host-env write`, not when a hand-written host.env is read. - **P3-4:** The steps should quote the exact `publish-record` systemd-run command and name the departure log line an operator searches for. - **P3-5:** The permission notice mentions "read and delete edges files", but the same fault also comes from opening the bucket and from indexing the deletion. - **P3-6:** The census basis on record names the retained page's subject as `ha_departure_edges_retained`; it is now prose. The appended claim covers it; flagged for the census reviewer. The cross-item check found no steady-state hourly page and no takeover regression in G1's dev setup (two fixed boxes with the identity map set). Everything is nil-safe with `CARLOS_REGION_HA` off.</result> <usage><subagent_tokens>161002</subagent_tokens><tool_uses>45</tool_uses><duration_ms>458215</duration_ms></usage> </task-notification>

Attributed to this commit: 16.0 g CO₂e (1,878,882 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-followups, 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/region-ha-runbook.md b/docs/region-ha-runbook.md
index e60d4e695..7b6148d4c 100644
--- a/docs/region-ha-runbook.md
+++ b/docs/region-ha-runbook.md
@@ -1,6 +1,6 @@
# Region HA operator runbook
-This page is for operators of a deployment that runs region HA (`CARLOS_REGION_HA=1`). It covers the settings a box needs and the three jobs the platform leaves to an operator. The design is in `docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md`.
+This page is for operators of a deployment that runs region HA (`CARLOS_REGION_HA=1`). It covers the settings a box needs and the jobs the platform leaves to an operator. The design is in `docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md`.
## Settings in host.env
@@ -14,48 +14,42 @@ CARLOS_HA_FIXED_BOX_IDENTITIES='{"box-a":"i-0123456789abcdef0","box-b":"i-0fedcb
- `CARLOS_TERMINATION_QUEUE_URL` is this box's own termination queue, from the region-host module's `termination_queue_url` output. Each box polls its own queue. Without it, termination recovery does not start, and the journal says so.
- `CARLOS_HA_FIXED_BOX_IDENTITIES` maps each fixed box's reference to its EC2 instance ID, as a JSON object.
- - **Wrap the value in single quotes**, as above. The JSON needs its double quotes, and single quotes preserve them for both systemd and a shell that sources the file. Without the single quotes, systemd strips the double quotes and the box refuses the setting.
+ - **Wrap the value in single quotes**, as above. This is how `carlos system host-env write` writes it. systemd removes the outer single quotes and reads the JSON as written. A shell that sources the file keeps the JSON's double quotes only because of the single quotes; without them it strips the double quotes and the value is no longer JSON.
- Only lower-case letters, digits, `{`, `}`, `"`, `:`, `,`, space and `-` are allowed. A reference is one DNS label. An instance ID is `i-` followed by 8 or 17 hexadecimal characters.
- The box's own entry must match its own instance ID, or termination recovery refuses to start (`identity_bindings`).
- - Without the setting, a box binds only itself. A peer then has no binding, and taking over its hosts after it is terminated falls back to asking EC2 directly.
+ - Without the setting, a fixed box binds only itself. A fixed peer it has not bound then has no binding, and taking over its hosts after it is terminated falls back to asking EC2 directly.
To roll back, restore the previous host.env and restart `carlos-edge.service`.
## A fixed box has been terminated: remove its edges file
-When a fixed box is terminated, a surviving box recovers its duties. It takes over the box's hosts, timers and due wakes. It does not delete the departed box's edges file (`control/edges/<box>.json`) because a fixed box's reference can be reused by its replacement, and the platform cannot tell which box an edges file belongs to.
+When a fixed box is terminated, a surviving box recovers its duties. It takes over the box's hosts, timers and due wakes. It does not delete the departed box's edges file (`control/edges/<box>.json`) because the platform cannot prove which instance of a fixed box an edges file belongs to.
Until the old edges file is removed, the departure stays open and pages once an hour (`ha_departure_edges_retained`).
-1. Check that the box is terminated in EC2 and that its replacement, if any, has not started yet.
+1. Check that the box is terminated in EC2.
2. Read the page or journal line. It names the edges file.
3. Delete that one object from the deployment bucket.
4. Within a few minutes, the surviving box sees that the file is gone, finishes the departure and stops paging.
-If a replacement box with the same reference is already running and has written a new edges file, do not delete it. The departure finishes on its own once the replacement's identity is verified (next section).
+Never give a new box the reference of a box that has left (next section).
-## A fixed box has been recreated: replace its box record
+## A fixed box has been recreated: give it a new reference
-Every box publishes a signed identity record once, at `control/boxes/<box>.json`. The record is create-only. A box never replaces another box's record. When you recreate a fixed box under the same reference, its new instance ID does not match the old record. The new box refuses to publish, and the old box's departure stays open and pages hourly until you replace the record.
+Every box publishes a signed identity record once, at `control/boxes/<box>.json`. The record is create-only, and the deployment bucket's policy (`BoxRecordsAreNeverDeleted`) refuses to delete it, for every principal. So a reference belongs to one instance for good. A new box under an old reference cannot publish its record or be verified, and the old box's departure would page every hour without end.
-Do these steps in order. If the new box publishes before the old box's departure is recorded, the departure cannot tell the two apart.
+Give a recreated fixed box a new reference instead. Do these steps in order:
-1. Before you create the new box, check that the old box's termination has been seen. A surviving box logs the departure for the old instance ID.
-2. Create the new box.
-3. Update `CARLOS_HA_FIXED_BOX_IDENTITIES` on every fixed box in the region with the new instance ID. Restart `carlos-edge.service` on one box at a time.
-4. Read the old record and note its ETag. Check that it names the old instance ID.
-5. Delete the old record, on the condition that its ETag still matches (`aws s3api delete-object --if-match <etag>`). If the condition fails, stop and read it again.
-6. On the new box, as the agent user with host.env loaded, run `carlos system box publish-record`. It prints the record it published.
-7. Check that the old departure finishes and its page stops within the hour.
+1. Check that the old box's termination has been seen. A surviving box logs the departure for the old instance ID.
+2. Create the new box under a new reference.
+3. Add the new reference and its instance ID to `CARLOS_HA_FIXED_BOX_IDENTITIES`. Keep the old box's entry until its departure has finished. Update the value on every fixed box in the region, and in the region's SSM parameter if group boxes read it from there. Restart `carlos-edge.service` on one box at a time.
+4. Remove the old box's edges file (previous section). The old departure then finishes and stops paging.
+5. Once the departure has finished, remove the old box's entry from `CARLOS_HA_FIXED_BOX_IDENTITIES` the same way. The old box record stays in the bucket. It grants nothing.
## Copying a key from a box in another region
-A region-host role with SSM parameter scoping (`scope_ssm_parameter_reads`) can read only `/carlos/*` parameters in its own region. A box in one region can no longer read a parameter in another region, for example to copy the secrets key to a new region.
+A region-host role with SSM parameter scoping (`scope_ssm_parameter_reads`) can read only `/carlos/*` parameters in its own region. A box in one region can no longer read a parameter in another region, for example to copy the secrets key to a new region. The scoping is an explicit Deny, so adding an Allow to the role does not get past it.
-To copy one:
+Copy the value with an operator credential instead of the box role. This needs no change to the role.
-1. Add a temporary grant to that box's role for the one parameter ARN it needs, through the deployment's infrastructure root, with scoped approval.
-2. Copy the value.
-3. Remove the grant, and check with an IAM policy simulation that the read is denied again.
-
-Or copy the value with an operator credential instead of the box role. This needs no grant.
+If the box role itself must read it, widen `ssm_parameter_arn` to include that one parameter, or turn `scope_ssm_parameter_reads` off, through the deployment's infrastructure root and with scoped approval. Copy the value, then put the setting back, and check with an IAM policy simulation that the read is denied again.
diff --git a/docs/superpowers/notes/region-ha-followups-p3.md b/docs/superpowers/notes/region-ha-followups-p3.md
new file mode 100644
index 000000000..9f8d49119
--- /dev/null
+++ b/docs/superpowers/notes/region-ha-followups-p3.md
@@ -0,0 +1,19 @@
+# Region HA follow-ups branch: P3 follow-up list
+
+From the per-task and branch reviews of branch region-ha-followups (2026-11-03/04). None starts a review round.
+
+- Item 1 r1 P3-1: "unbound" means no row in this box's local identity registry; the fixed-identity config and not-yet-loaded S3 box records are not consulted. State the definition above `departureIdentities.Proof`.
+- Item 1 r1 P3-2: no witness drives `AdoptHost` through a successful unbound fallback counting EC2 calls and log lines.
+- Item 1 r1 P3-3: the "context error" row of the Proof classification has no test.
+- Branch r1 P3-1: a binding made by the identity walk has no observation, so item 1 treats it as bound and refuses the visitor EC2 fallback on a box that never saw the peer alive.
+- Item 2 r1 P3-1: every finalizer page carries the reason `termination_unproven`, including lifetime changes and a proven termination whose follow-up failed. Map causes to codes.
+- Item 2 r1 P3-2: the page throttle is per box, in memory; each survivor pages hourly per host and a restart resets it.
+- Item 2 r1 P3-3: the production witness does not show the second adoption attempt reached the proof check.
+- Item 2 r1 P3-4: the `ref == ""` fallback in reportTakeover is unreachable.
+- Item 5 r1/r2 P3-4: the P1-1 witness's "B not suspect" checks rely on B's success note landing before A's failure note; comment it.
+- Item 5 r2 P3-5: time queued behind a healthy connect still comes out of the handshake budget (pre-existing).
+- Census P3-2 / branch P3-6: the retained-edges page subject is now prose, not `ha_departure_edges_retained`; check alert routing filters before the roll.
+- Branch r1 P3-3: the identity-map character set is enforced only by `carlos system host-env write`, not when a hand-written host.env is read.
+- Branch r1 P3-4: the runbook should quote the exact `publish-record` command and name the departure log line an operator searches for.
+- Branch r1 P3-5: the permission notice says "read and delete edges files"; the same fault also comes from opening the bucket and indexing the deletion.
+- Branch r1 P1-1 (fixed as docs): Ruling P17 assumed an operator could replace `control/boxes/<ref>.json`; the bucket policy `BoxRecordsAreNeverDeleted` forbids it. The runbook now says a recreated fixed box takes a new reference. If reusing a reference is ever needed, it needs a ruling to lift that policy statement.