ha: document capacity admission and pin its witnesses
docs/region-ha-runbook.md+18 −0docs/site/cli.md+12 −0
Intent
<task-notification> <task-id>b13clue38</task-id> <tool-use-id>toolu_01VViasy3fZvgebs2aGSytZk</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/de069047-3c6a-40e7-ae66-85194f066976/tasks/b13clue38.output</output-file> <status>completed</status> <summary>Background command "Wait for T3 fix round 1" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>aad01567fc6e5063a</task-id> <tool-use-id>toolu_01Vid5tLQZiSvMLP3W9u13ks</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/de069047-3c6a-40e7-ae66-85194f066976/tasks/aad01567fc6e5063a.output</output-file> <status>completed</status> <summary>Agent "Re-review T3 fix round 1 (Opus)" 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>Both findings are addressed, and the bulk `doorRefusal{Status:, Msg:}` conversion is behaviour-neutral. I found no new P1 or P2 in b3aeab32..6068881c. The two new tests pass when run alone (`-run`, `-count=1`). **Finding 1 (P2, I5 / R10): ADDRESSED.** - **Still gated:** `domainattach.go:228-238` checks capacity before any new create in an HA region. A host that already has a record skips the check, so a re-attach is not blocked. - **Typed marker:** `domainbuy.go:574-596` no longer increments Attempts before the attach. It reserves the revision with `movePurchase(..., nil)` (`:575`); that call is a compare-and-swap (`compareDomainPurchase`, `:269-282`), so concurrent passes still serialise. A refusal is recognised by the field `ref.haCapacityRetryAfter > 0` (`:581`), not by message text. - On a capacity refusal it sets Reason and leaves Attempts alone (`:582-588`), and `purchaseAlert` is skipped (`:591`). - On any other refusal it increments Attempts as before. Success increments on the move to Done (`:596`). - Total counts are unchanged; the witness confirms Attempts is 11 at Done when it was set to 10. - **Paging:** "zero" pages only through `noRoom`'s hourly throttle (`nocapacity.go:61`, `157-173`). "unknown" never pages. - **Witness:** `domainbuy_capacity_test.go:13-93` runs the real `domainPurchasePass` in an HA region for both zero and unknown, at starting Attempts of 0, 9 and 10, three passes each. Each pass checks: - no bucket writes, with records and claims unchanged (`bucketState` DeepEqual); - Reason set to the exact refusal text; - Attempts unchanged and no purchase page; - noRoom page only under zero. It then switches to positive evidence and checks the state reaches Done, Reason clears, and both apex and www get their claim and static record. **Finding 2 (P3): ADDRESSED.** - `nocapacity.go:146-152` sets Retry-After from `strconv.Itoa(ref.haCapacityRetryAfter)` and otherwise falls back to `isNoCapacityRefusal`. - The marker is set on all three capacity outcomes: zero (`:61-63`), unknown and missing-pools (`:69`). - **Byte-identical:** - The value is 60, the same as the old constant (`noCapacityRetryAfter = "60"`, `:37`). - Status (503) and Msg are untouched. The zero path's `claimResponseRefusal(noRoom)` always produces the noCapacityError refusal (`claim_response.go:21`). - The old prefix matching covered exactly the two `haCapacity*Refusal` formats (`nocapacity.go:43-44`). - `claim_response.go:31-32` (Retry-After "2", then the no-capacity 60 override) never sets the marker, so it behaves as before. - `hacreatecapacity_test.go:217-260` shows the header survives rewording of Msg, and that unmarked text no longer gets Retry-After. **Mechanical conversion: neutral.** - **How I checked:** I ran the suggested `git diff | grep | sed` stripping `Status: ` and `Msg: `, sorted the - lines and the + lines, and diffed them. 279 against 280 lines. The only differences are the struct definition (`domainattach.go:74-78`: two fields realigned, plus `haCapacityRetryAfter`). - **domainattach.go:** every one of its 121 changed lines, apart from the struct, is `"text"}` becoming `Msg: "text"}`. - **Compiler check:** `doorRefusal` is package-local, and a two-value positional literal no longer compiles against three fields. So the build proves no unconverted literal remains. **New P1/P2:** none. **Out-of-scope P3s:** - An attach that crashes or panics before returning no longer counts toward the 10-attempt alert. A pass that crashes every time could therefore retry silently forever (`domainbuy.go:574-575`). - The `TMPDIR=/tmp/g` recipe in your instructions fails in this sandbox because `/tmp` is read-only. I ran with the default `$TMPDIR`.</result> <usage><subagent_tokens>53537</subagent_tokens><tool_uses>8</tool_uses><duration_ms>90164</duration_ms></usage> </task-notification>
diff --git a/docs/region-ha-runbook.md b/docs/region-ha-runbook.md| index 5c0190a54..b31c49cff 100644 |
| --- a/docs/region-ha-runbook.md |
| +++ b/docs/region-ha-runbook.md |
| @@ -2,6 +2,24 @@ |
| 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`. |
| +## P2b-1 capacity admission |
| + |
| +New creates in an HA region need a box with room. A 503 response tells you to retry after 60 seconds. Missing evidence pauses creates. It does not report zero capacity. Existing instances can still wake. |
| + |
| +Roll the boxes. Verify their admission reports before enabling the capacity check. Keep the home placement empty. Set the configured region codes and data coordinates on the console. |
| + |
| +Named-pool creates need a serving box that reports membership of the requested pool. Older boxes do not report this evidence. If no box confirms capacity and evidence is missing, the create returns 503 because capacity is unknown. Nothing is created. Shared-pool creates use the existing shared-pool reports. |
| + |
| +- `CONSOLE_HA_CAPACITY_CONFIG`: JSON, 64 KiB maximum, 200 fixed references maximum. |
| +- `v`: `1`. |
| +- `regions`: canonical region code → `aws_region`, `data_bucket`, `data_bucket_region`. |
| +- `fixed_boxes`: exact box reference → `region_code`, `instance_id`. |
| +- `Retry-After`: `60`. |
| +- Observation interval: 60 s; pass deadline: 45 s; expiry from pass start: 120 s. |
| +- Observation limits: 200 edges, 200 recent status reports, 1000 raw status entries. |
| +- `CARLOS_REGION_METRICS=cloudwatch`. |
| +- T0 first edges publication after upgrade: 1 PUT + 1 index bump per box, once. |
| + |
| ## Settings in host.env |
| A fixed box is one you created by hand, not through Auto Scaling. It reads its region HA settings from root-owned `/etc/carlos/host.env`, mode 0600. The region-host module does not write that file. Write the lines, then restart `carlos-edge.service` on one box at a time. A restart costs about 1 to 11 seconds of held or refused requests on that box. |
diff --git a/docs/site/cli.md b/docs/site/cli.md| index a4bfa2ea2..d30871eca 100644 |
| --- a/docs/site/cli.md |
| +++ b/docs/site/cli.md |
| @@ -1020,6 +1020,10 @@ In an active high availability region, a non-hibernating binary socket create is |
| If earlier data remains for the address, the create is refused with status 409. The message names only the fixed class of data found: lock, files, replica or other. Choose another address, or ask an operator to purge the old data. If home data cannot be checked, the create is refused with status 503 before any write. Try again. A non-home or pooled high availability data create is refused with status 409 because that data cannot be checked here. Use the console's home region without a pool. |
| +New creates in an HA region need a box with room. A 503 response tells you to retry after 60 seconds. Missing evidence pauses creates. It does not report zero capacity. Existing instances can still wake. |
| + |
| +Named-pool creates need a serving box that reports membership of the requested pool. Older boxes do not report this evidence. If no box confirms capacity and evidence is missing, the create returns 503 because capacity is unknown. Nothing is created. Shared-pool creates use the existing shared-pool reports. |
| + |
| An app's instances are the places it actually runs. `carlos instances enable` |
| is the app's opt-in to provisioning, and until it is set the API refuses to |
| create anything. After that, `create`, `list`, `delete`, `set-upstreams`, |
| @@ -1265,6 +1269,10 @@ carlos sidecars create --app eleven bot-acme |
| carlos sidecars ls --app eleven |
| ``` |
| +New creates in an HA region need a box with room. A 503 response tells you to retry after 60 seconds. Missing evidence pauses creates. It does not report zero capacity. Existing instances can still wake. |
| + |
| +Named-pool creates need a serving box that reports membership of the requested pool. Older boxes do not report this evidence. If no box confirms capacity and evidence is missing, the create returns 503 because capacity is unknown. Nothing is created. Shared-pool creates use the existing shared-pool reports. |
| + |
| Sidecars hibernate by default, and a sleeping one has only two ways back up: |
| its own schedule, or `carlos sidecars wake`. Nothing can dial it awake, which |
| is the difference that matters when you are reasoning about one — an instance |
| @@ -1361,6 +1369,10 @@ or lists what is claimed. |
| carlos domains attach --app hello www.example.com |
| ``` |
| +New creates in an HA region need a box with room. A 503 response tells you to retry after 60 seconds. Missing evidence pauses creates. It does not report zero capacity. Existing instances can still wake. |
| + |
| +Named-pool creates need a serving box that reports membership of the requested pool. Older boxes do not report this evidence. If no box confirms capacity and evidence is missing, the create returns 503 because capacity is unknown. Nothing is created. Shared-pool creates use the existing shared-pool reports. |
| + |
| `--route` picks which route to point at, and you can leave it off when the app |
| has exactly one instance record. The `list` verb joins the claims to the |
| fleet's own readings sweep, so DNS state, certificate expiry and delegation |