carlos / platform Public

spec rev 3: region HA without claims, Paul's N-HA4 and N-HA5

N-HA4: N-box offline moves and seed import join the series. Section 14
designs them under the release-marker model: the source sealed from S3
alone (clean marker plus tombstone), the region as target through a
staging marker that forces promotion before any keep, duties, keys and
rollback, and seed import as a region-target landing with its journal
in S3. Plans P1-P6 and gates G1-G5; no carloku.com region retires its
old box before G5.

N-HA5: app files sync every 10 s on the continuous class, the H6 trio
at about 1 s; budgets updated.

A22: a box whose own S3 access has failed for 3 minutes answers
unhealthy, guarded by a peer probe showing S3 working and by
one-at-a-time per region; the alarm and runbook remain the backstop.
No open questions remain.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 1c3599a3438e516b81ab4b6a8f47d70f2d56b267 parent 3da0497
1 file changed, +143 −99
  • docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md +143 −99

CI failed — run details

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 ea42ef253..2a690cefd 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,13 +1,19 @@
# Region HA without claims: N-box regions behind a load balancer
-Design, 2026-10-26, **rev 2**. Branch `design-region-ha-no-claims`, cut from `origin/main` at ddf3b929. Status: draft for Astra round 2. Nothing here is built.
+Design, 2026-10-26, **rev 3**. Branch `design-region-ha-no-claims`, cut from `origin/main` at ddf3b929. Status: draft for Astra round 2. Nothing here is built.
+
+**Rev 3** folds in Paul's two answers of 2026-10-26:
+- **N-HA4:** N-box offline moves and seed import join this series. §14 is now their design, and the gates in §19 hold back each old box's retirement until both work.
+- **N-HA5:** the files sync cadence (§8.2, §18).
+
+It also replaces the operator runbook for a box that is alive but has lost S3 with an automatic, peer-guarded health answer (A22, §9.5). No open questions remain.
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 gives claims-cleanup step R3 its exact deletion list. New plans start from this document.
Line citations are to this worktree unless they name a module path.
**Rev 2** answers Astra round 1 (`docs/superpowers/notes/reviews/ASTRA-FINDINGS-region-ha-no-claims-r1.md`, 66721809, NOT READY, cited **astra-1.N**) and a builder check (cited **builder-N**), with the coordinator's dispositions. Its central change is that a local copy is kept only on positive proof: a release marker in the lease object (§5). Rev 1's checksum comparison is cut. Rev 2 also cuts scope:
-- moves into and out of HA regions, and seed imports, are refused (§14);
+- moves into and out of HA regions, and seed imports, were refused (rev 3 designs them in §14);
- same-box takeover (rev 1's A16) is dropped;
- the write fence (rev 1's A11) is dropped, because no other box can now acquire while the owner may still run.
@@ -24,7 +30,7 @@ Line citations are to this worktree unless they name a module path.
| astra-1.9 timeline omits backoffs and the boot grace | Accepted. Backoffs follow holder identity; grace kept separate; new test. | §7.2, §9.8, §10, §21 |
| astra-1.10 forwarded requests cannot take over | Accepted. The receiving box takes over locally; cross-region views defined. | §4.3, §6.4 |
| astra-1.11 records carrying `Unit` are adopted | Accepted. Unit, platform and non-hibernating socket records are excluded from serving boxes. | §6.1 |
-| astra-1.12 relaxing offline moves is unsafe | Accepted. Moves involving HA regions are refused. | §14 |
+| astra-1.12 relaxing offline moves is unsafe | Accepted. Rev 2 refused them. Rev 3 gives N-box moves a full contract: an S3 seal, a region target, and promotion before any keep. | §14 |
| astra-1.13 rollback uses a terminated box | Accepted. The old box is stopped, and terminated after acceptance. | §13 |
| astra-1.14 #199 not closed | Accepted. The marker carries the lifetime; reused names with leftovers are refused. | §5.3, §11 |
| astra-1.15 backfill cannot acquire a held lease | Accepted. Publish through the live handle; readiness is publication success. | §8.4 |
@@ -39,13 +45,7 @@ Line citations are to this worktree unless they name a module path.
Part 1 of two: **a region's load balancer keeps serving when one box is killed.** The target is carloku.com's regions (IE, UK, US, AU), dev first. Each region runs a fixed-size group of N boxes, N ≥ 2, behind one Network Load Balancer. When a box is terminated, its instances come back on the others within a few minutes. A stream-class database loses about the last second of writes; other classes lose more (§5.5).
-Out of scope:
-- part 2: stateless replicas of one app across boxes;
-- autoscaling beyond a fixed-size group;
-- cross-region failover (#251);
-- live moves, which are parked;
-- offline moves and seed imports touching an HA region (refused, §14);
-- Kubernetes or k0s. Considered and rejected: two boxes cannot run an HA control plane, and it would replace the box runtime and change the self-hosted product.
+Out of scope: part 2 (stateless replicas of one app across boxes), autoscaling beyond a fixed-size group, cross-region failover (#251), and live moves, which are parked. Kubernetes or k0s was considered and rejected: two boxes cannot run an HA control plane, and it would replace the box runtime and change the self-hosted product.
## 2. Rulings
@@ -68,6 +68,8 @@ These stand from spec 1 and spec 2.
| N-HA1 | HA is built **without claims**. The Litestream S3 lease is the only single-writer guard. |
| N-HA2 | Replaces H25. Once every instance's DB and files are in S3, the old box joins the load balancer as an ordinary member. Its instances are slept one at a time and wake on the group boxes. The old box is removed once empty. IE's platform box stays outside the group. |
| N-HA3 | Failover is "a few minutes, lower is better", met **without shortening every lease**. Once EC2 confirms a box is terminated, a survivor takes over its leases at once. |
+| N-HA4 | N-box offline moves and seed import join this plan series. Dev and the first test region may go HA with both refused. No carloku.com region retires its old box until both work in N-box regions. |
+| N-HA5 | App files on the continuous (top-plan) class sync every 10 s. `instance.key`, `report.token` and `<host>.env` sync at about 1 s. |
### 2.2 Author's calls
@@ -96,6 +98,7 @@ Each is the author's or the coordinator's. Paul can overturn any of them.
| A19 | The old box drains before the EIP cut-over, and is then stopped, not terminated, until acceptance. | Rollback inside the window just starts it again. |
| A20 | The no-capacity refusal applies at create only. A wake of an existing instance is never refused for headroom: drain and platform ingress always forward to a serving peer. | An existing instance down is worse than an overfull box. |
| A21 | Each box redirects traffic it sends to its own region's ingress addresses to its local edge. | NLB hairpin connections fail when the client IP is preserved. |
+| A22 | A box whose own S3 access has failed for 3 minutes answers unhealthy, so its group replaces it. It does so only while a peer's private probe shows S3 working for that peer, and while no other box of the region is already unhealthy for S3. | It replaces an operator runbook. The peer guard keeps a regional S3 outage from churning the group. |
## 3. Model
@@ -122,8 +125,7 @@ For any region r, a box's **view(r)** is the set of boxes whose edges file is no
### 4.4 Box roles
- **The object.** `control/box-roles/<ref>.json` (`{role, by, at}`) holds `serve`, `drain` or `platform`; absent means `serve`. A region default, `control/box-roles/@region-<code>.json`, covers boxes with no object of their own, so a replacement launched during a rollback takes the region's role.
-- **Who writes it.** Only an operator, through `carlos system box role <ref|@region-code> <role>` and its console door. These replace plan 2a's `system_roles.go` and `internal/console/apiboxroles.go`.
-- **How boxes read it.** `ChangeScope` gains `control/box-roles` (`internal/release/changeindex.go:53-76`). A box reads its own and its region's object at start, and whenever that scope moves.
+- **Writing and reading.** Only an operator writes it, through `carlos system box role <ref|@region-code> <role>` and its console door, which replace plan 2a's `system_roles.go` and `internal/console/apiboxroles.go`. `ChangeScope` gains `control/box-roles` (`internal/release/changeindex.go:53-76`). A box reads its own and its region's object at start and whenever that scope moves.
- **Publication.** A box publishes its effective role, and `drained: true` once a drain is complete (§13), in new additive edges fields. Readers that do not know the fields treat the box as `serve`.
## 5. Local copies: the release marker
@@ -303,11 +305,7 @@ If the adopter dies part way, the source is still there, and the next adopter re
### 8.1 What is there
-- **App files:** the files directory, `<instance dir>/<host>/` (`internal/layout/plan.go:196`).
-- **The H6 trio:** `instance.key`, `report.token` and `<host>.env`, plus the wake state.
-- **Not synced:** `<host>-sidecar.env` and `<host>.config.env`, which are rendered from the bucket on every box.
-
-Today nothing claim-free publishes files. `hostfiles.Run` has no production caller.
+App files live in `<instance dir>/<host>/` (`internal/layout/plan.go:196`). The H6 trio is `instance.key`, `report.token` and `<host>.env`, synced with the wake state. `<host>-sidecar.env` and `<host>.config.env` are rendered from the bucket on every box, so they are not synced. Today nothing claim-free publishes files: `hostfiles.Run` has no production caller.
### 8.2 The mechanism
@@ -315,9 +313,9 @@ The location is the host's hibernate prefix (`activator.go:138-150`) plus `files
- **At wake:** §5.3 keeps the tree or restores it into a clean directory, platform files first, before any key mint or app start.
- **While awake:**
- - continuous plan: `hostfiles.Run` (`internal/hostfiles/run.go:22,44`) at the cadence of §22 Q2;
- - snapshot plan: a full publish every `files_snapshot_interval` (15 minutes by default) when a local digest says the tree changed;
- - the H6 trio and the wake state: continuous on every plan.
+ - continuous plan: `hostfiles.Run` (`internal/hostfiles/run.go:22,44`), with its deadline set to 10 s for app files (N-HA5);
+ - snapshot plan: a full publish every `files_snapshot_interval` (15 minutes by default), when a local digest says the tree changed;
+ - the H6 trio (`instance.key`, `report.token`, `<host>.env`) and the wake state: a 1 s deadline on every plan (N-HA5).
- **At sleep:** a final publish, then the release (§5.2).
### 8.3 The setting
@@ -364,7 +362,8 @@ On an HA box, the lease package's acquire reads first: one GET of `lock.json` wi
| Held and unexpired | A held answer naming the owner (§6.2). |
| Expired, owner is this box's instance id | Conditional PUT. This is today's same-box recovery after an agent crash, which waits out the TTL. |
| Expired or unexpired, owner confirmed terminated (§9.2) | Conditional PUT: the takeover. |
-| Anything else | Refused: another box's expired lease, an old-format owner, or a tombstone. |
+| A lifted tombstone, or a staging marker (§14) | Conditional PUT. Never keep the local copy; promote any staging first. |
+| Anything else | Refused: another box's expired lease, an old-format owner, or a live tombstone. |
The refused cases keep the instance down until its owner is terminated or the owner itself re-takes the lease. **Expiry alone never lets another box acquire.** That holds for a stopped agent whose app processes still run, a frozen process, and a box that has lost S3.
@@ -379,7 +378,16 @@ The refused cases keep the instance down until its owner is terminated or the ow
A hung box's instances wait for the group to replace it. That takes 2 to 5 minutes once the box is past its boot grace, and the grace remainder plus that inside it (§9.8).
-A box that is alive but has lost S3 keeps its instances down until someone terminates it. Its health stays 200 by design, because a shared dependency must never terminate boxes (S2 §6). The suspect-holder alarm (§20) fires after 10 minutes. The runbook step is to terminate that instance in its group, which H1 counts as death. This is an accepted, stated limit.
+**A box that is alive but has lost S3 (A22).** Its leases are stuck, because its renewals fail but no other box may take them until it is terminated. So it reports itself unhealthy and lets its group replace it. A shared outage must still never churn the group (S2 §6), so it does this only when all of these hold:
+- **Its own S3 is failing.** For 3 minutes, every request it made to the data bucket or the deployment bucket failed on transport, a 5xx or a timeout. A 412 or 404 is an answer, not a failure. The serial GET every 2 s (AGENTS.md) gives the deployment bucket a steady signal, and lease renewals give the data bucket one.
+- **A peer shows S3 working.** At least one serving peer answers a private probe on the backhaul listener, signed like a hop, with a successful request to each bucket within its last 2 minutes. A peer with no recent data-bucket request is not evidence.
+- **No other box is already unhealthy for S3.** No probed peer reports that it is. On a tie, the lower reference goes first.
+
+Then:
+- the probe runs once a minute, and only while the box's own condition holds, so the steady state costs nothing;
+- if no peer can give evidence, as in a regional outage or an idle two-box region, the box stays healthy, and the suspect-holder alarm (§20) remains the backstop, with a runbook step to terminate it.
+
+Its instances are back in about 3 minutes plus the hung-box time.
### 9.6 Same-box takeover: dropped (astra-1.3)
@@ -407,6 +415,7 @@ These are estimates; dev measures each one (§21).
| Worst case, event lost | the next request's dial failure confirms at once; with no requests, view ageing (15 min) | the same |
- **A hang inside the boot grace.** The group's grace period suppresses replacement after the box is in service (AWS documents this), so the box is down for the rest of the grace plus the hung-box time. The grace is kept as short as the measured boot (§10), and it is reported apart from the serving bound.
+- **A box that has lost S3 (A22)** is back in about 5 to 8 minutes: 3 minutes to detect, then the hung-box time. That needs a peer to give evidence; otherwise it is the alarm and the runbook.
- **A graceful termination** needs no takeover: the shutdown sleeps every instance and writes markers (`activator.go:5186-5194`).
## 10. Load balancer health
@@ -417,7 +426,7 @@ Keep `internal/lbhealth`, with its six conditions (`internal/lbhealth/lbhealth.g
- **Cleared** first in shutdown (`activator.go:5190`).
- A `drain` box stays healthy until it is removed, because it forwards. The `platform` box is not a target.
- **The boot grace** is the measured boot time plus a small margin, starting at 8 minutes, since there is no enrolment. It is kept separate from the serving failure bound.
-- **Not added:** S3 reachability (S2 §6).
+- **Added as a seventh condition:** "not failing on S3 under the peer guard" (§9.5). Plain S3 reachability is still not a condition (S2 §6).
## 11. Placement inputs, capacity and create refusals
@@ -442,13 +451,8 @@ Today the module makes one `aws_instance` and one `aws_eip` (`main.tf:536-587`).
### 12.2 IAM
-- **Box role:**
- - SSM `GetParameter` and `GetParametersByPath` on `/carlos/<deployment>/<region>/*` and `/shared/*`, with `kms:Decrypt` under the `ViaService` and `PARAMETER_ARN` conditions;
- - the existing SSM Deny kept;
- - an explicit HA statement for `ec2:DescribeInstances`;
- - no Auto Scaling, ELB or EC2 write right.
-- **Console:** nothing new.
-- **Operator seeding:** `ssm:PutParameter` and the KMS actions (S2 §5 step 2).
+- **Box role:** SSM reads on `/carlos/<deployment>/<region>/*` and `/shared/*`, with `kms:Decrypt` under the `ViaService` and `PARAMETER_ARN` conditions; the existing SSM Deny; an explicit HA statement for `ec2:DescribeInstances`. No Auto Scaling, ELB or EC2 write right.
+- **Console:** nothing new. **Operator seeding:** `ssm:PutParameter` and the KMS actions (S2 §5 step 2).
### 12.3 Boot
@@ -469,15 +473,7 @@ So each box installs an nftables output rule that redirects TCP 80 and 443 desti
- **The platform box** (IE, H24) stays in fixed mode with its own new EIP for the relay and MX. S2 §6's steps apply. It is not a target.
- **The cut-over** costs a few minutes per region (S2 §9 step 3), announced, and measured on dev.
-- **The provider boundary.** The core assumes one object store with conditional writes, N hosts running `carlos`, and DNS. The AWS adapters are:
- - the termination oracle and event source;
- - box identity, and the instance id in the owner;
- - the private address;
- - the group and load balancer, in tofu only;
- - the CloudWatch metric;
- - the hairpin addresses.
-
- Without the termination oracle, another box can never take a dead box's leases: its instances stay down until an operator restores the box. So off AWS an HA region is refused until a provider adapter exists, which is consistent with H26.
+- **The provider boundary.** The core assumes one object store with conditional writes, N hosts running `carlos`, and DNS. The AWS adapters are the termination oracle and event source, box identity (the instance id in the owner), the private address, the group and load balancer (tofu only), the CloudWatch metric and the hairpin addresses. Without a termination oracle another box can never take a dead box's leases, so off AWS an HA region is refused until a provider adapter exists, consistent with H26.
## 13. Retiring the old box (N-HA2)
@@ -491,6 +487,7 @@ This is the sequence for UK, US and AU; IE differs in step 5.
- no old-format lock (§9.4);
- no non-hibernating socket instance (§6.1).
4. The group is built, healthy behind zone B's address, and rehearsed there, including the hairpin check.
+5. Gate G5 holds (§19): N-box offline moves and seed import work, so the region is never left unable to move or import (N-HA4).
**Steps:**
1. **Join.** Register the old box in the target groups as an ordinary member.
@@ -516,18 +513,74 @@ Its local copies are older than the markers in S3, so each wake there restores.
**Cost.** During the window there is one extra box, stopped after step 4. Each region adds a load balancer (about $20 a month before traffic) and EIPs for its extra zones.
-## 14. Moves and seed imports in HA regions (placeholder)
+## 14. Offline moves and seed import in N-box regions (N-HA4)
+
+**Until plans P4 and P5 ship (§19),** the offline-move door refuses any move whose source or destination region is HA, and the seed-import door refuses an HA region. Both refusals come up front and name the region. Rev 1's relaxed predicates stay withdrawn (astra-1.12).
+
+This section is the spec-level contract. P4 and P5 hold the detail. Today's single-box path (`internal/host/movesoffline*.go`) stays for non-HA regions, so a move between an HA and a non-HA region uses the HA rules on its HA side only.
+
+### 14.1 Source: stop and seal from S3
+
+1. **Stop.**
+ - If the instance is awake, its lease holder sleeps it gracefully, which writes a clean release marker (§5.2).
+ - The move then writes its tombstone, `moved:<id>` (`internal/lease/tombstone.go`), by a conditional PUT over that marker's ETag. The same applies over an absent lock, or over a lease whose owner §9.2 has confirmed terminated. A live holder is never tombstoned; the move waits for the stop.
+ - Every box of the source region reports that it does not serve the host, as the per-box reports do today.
+2. **Seal from S3 alone.** A clean marker means the final database sync, files publish and wake-state export all reached S3 before it was written (§5.2). So the seal is three things, all already in S3, and no box is a sealer:
+ - the replica up to the marker's `txid`;
+ - the files manifest `files_gen`, which carries the H6 trio and the wake state;
+ - the marker's lifetime.
+
+ No box-local data is ever trusted. Today's sealer checkpoint (`internal/host/movesoffline_seal.go:398-408`) and its local archive of files and env do not run on an HA source.
+
+ With `clean: false`, an absent marker, or a terminated owner, the seal is S3 as it stands. Writes that never reached S3 are lost, as in a failover (H3, §5.5), and the move's report says so.
+3. **Box selection** (`internal/console/apiinstancemove_offline.go:1024-1049`). On an HA source it becomes region-level:
+ - every box in the source region's view has reported the stop;
+ - the lock is the move's tombstone.
+
+ "Local data on more than one box" and the sealer choice go, because local data no longer decides anything. The stager is the HRW box over the move id among the source region's serving boxes. It is re-chosen if it leaves the view, and its copy is idempotent.
+
+### 14.2 Target: the region
-In this release the offline-move door refuses any move whose source or destination region is HA, and the seed-import door refuses an HA region. Both refusals come up front, with a message naming the region (astra-1.12). Rev 1's relaxed predicates are withdrawn.
+1. **Stage.** The stager copies the replica and the files objects named by the sealed manifest to the destination region's staging prefix. It then writes a **staging marker** into the destination's `lock.json` with `If-None-Match` or `If-Match`: `{owner: "staged/v1;move=<id>", expires_at: 1970-01-01T00:00:00Z, carlos_staged: {move, lifetime, txid, files_gen}}`. It refuses to overwrite anything but an absent lock, a lifted tombstone, or its own staging marker.
+2. **Land.** No box is chosen. The destination's console door requires at least one serving box with the offline-stage capability. The first serving box to wake the host runs the HA acquire (§9.4), sees the staging marker, and promotes the staging before anything else: it never keeps a local copy, then restores the database and files into a clean tree.
-Whether N-box moves and imports join this plan series is Paul's question (§22 Q1). If they do, they need their own source selection, files and timers, landing and promotion order, and rollback contract (astra-1.12).
+ This fixes the promotion order: today the warm-cache return (`internal/activator/backend_exec.go:819-820`) runs before the promotion (`:833-851`). On HA boxes, the keep decision is reached only from a clean release marker naming this box, so a staging marker always reaches promotion first. Non-HA boxes keep today's single-target path.
+3. **Duties and timers.** The wake state travels in the manifest and is imported at the first wake. Until then the host has no holder and no releaser, so its HRW box owns its duties (§7.1) and wakes it for its first due time.
+
+ On the source, each box drops the host's duties when it finds the tombstone at its next acquire, or when the move reports "gone". The source's duty-file entries go at that point.
+4. **Keys.** `<host>.env` is restored from the staged manifest before any launch. Because a manifest exists, no box mints a key or token (§7.3). The key survives the move.
+
+### 14.3 Rollback and failure cases
+
+**Rollback** depends on how far the move got:
+- **Before land:** delete the destination staging and its staging marker (conditional on the marker's ETag), then lift the source tombstone (`LiftTombstone`). The HA acquire table treats a lifted tombstone as "acquire and restore, never keep" (§9.4).
+- **After open in the destination:** a move back.
+
+**Failure cases:**
+
+| Failure | What happens |
+|---|---|
+| The stager dies | It is re-chosen, and the copy resumes. |
+| The landing box dies after promotion, before release | §9's takeover. The staging marker is gone, so the box restores from the promoted replica. |
+| A destination box holds a leftover copy | It never matches a staging marker or a release marker naming it, so it is set aside. |
+| The source holder is hung | The move waits for its termination (§9.4), and the console shows why. |
+
+### 14.4 Seed import through the same path
+
+Today an import swaps the seed in beside the legacy row on one box, and keeps its journal and rollback there (`internal/console/seedfloor.go:25-29`). In an HA region, an import becomes a region-target landing whose source is the uploaded seed:
+1. stop and tombstone, as in §14.1;
+2. copy the current replica and manifest to `imports/<id>/previous/` in S3;
+3. stage the seed as the new replica;
+4. replace the tombstone with a staging marker (§14.2), by a conditional PUT on the tombstone's ETag.
+
+The first waker promotes the seed. The journal is the import record in the console's store plus those S3 prefixes, so no box holds state the import needs. Rollback stages `previous/` back the same way. Seeds that are not imports already land under the lease on whichever box wakes.
## 15. S2 §8's single-box rows, restated
| Row | Status | Answer |
|---|---|---|
| Move door and `selectMoveBoxes` (`internal/console/apiinstancemove.go:687-713`, `boxselect.go:78-140`, `internal/host/movesphase1.go:502-518`) | Dropped | Phase 1 is deleted by R4a. Offline moves: §14. |
-| Seed import (`internal/console/seedfloor.go:25-29`, `:88-89`) | Refused | §14. |
+| Seed import (`internal/console/seedfloor.go:25-29`, `:88-89`) | Rebuilt | Region-target import with an S3 journal (§14.4); refused until P5. |
| `CheckOneBoxRegion` (`internal/hostfence/onebox.go:12-35`) | Dropped | Its callers are claim-only, deleted by R6. |
| Warm cache (`activator.go:2302-2311`, `backend_exec.go:819-820`) | Built | §5. |
| Hosts unique to one box (`internal/console/apiinstances.go:523-527`) | Rewrite | Show the box whose snapshot reports the host awake, or none. |
@@ -542,23 +595,11 @@ Whether N-box moves and imports join this plan series is Paul's question (§22 Q
### 16.1 Kept
-- `internal/lbhealth`; `internal/edge/lbhealth.go`; `privateDial` and `dialAddress`; `internal/edgesfile/private.go`;
-- `awsaddr.go` and `boxaddress.go`; `headroom.go`; `internal/boxid`; `boxrecord.go`; `boxreference.go` and `GroupBoxReference`;
-- `internal/boxchoice`;
-- `internal/termfence`, with `Box` cut to `{Ref, Cloud}`;
-- `internal/hostfiles`;
-- `internal/hostenv`, minus the claim keys;
-- `installchannel.go`, minus its guard;
-- the termination rule and queue;
-- plan 2a's approved no-capacity copy.
+`internal/lbhealth`, `internal/edge/lbhealth.go`, `privateDial` and `dialAddress`, `internal/edgesfile/private.go`, `awsaddr.go`, `boxaddress.go`, `headroom.go`, `internal/boxid`, `boxrecord.go`, `boxreference.go` with `GroupBoxReference`, `internal/boxchoice`, `internal/termfence` (with `Box` cut to `{Ref, Cloud}`), `internal/hostfiles`, `internal/hostenv` (minus the claim keys), `installchannel.go` (minus its guard), the termination rule and queue, and plan 2a's approved no-capacity copy.
### 16.2 Rewritten
-- The `SetHosting` caller becomes the latch (§10).
-- The address source moves out of `edgesclaims.go`.
-- The role door (§4.4).
-- `nocapacity.go` and `regioncapacity.go`, and where the metric starts (§11).
-- `boxselect.go` keeps `liveEdges` and `verifiedRoster`.
+The `SetHosting` caller becomes the latch (§10). The address source moves out of `edgesclaims.go`. The role door (§4.4). `nocapacity.go`, `regioncapacity.go` and where the metric starts (§11). `boxselect.go` keeps `liveEdges` and `verifiedRoster`.
### 16.3 Handed to R3 for deletion
@@ -572,13 +613,11 @@ Whether N-box moves and imports join this plan series is Paul's question (§22 Q
### 16.4 Amendments to the cleanup plan
-- R3 keeps `termfence`, `boxrecord.go`, `install-channel`, `CARLOS_REGION_HA`, `privateDial` and `edge/lbhealth.go`.
-- R4a keeps `boxchoice`.
-- Changes to root verbs and units need a census card and an approval (AGENTS.md).
+R3 keeps `termfence`, `boxrecord.go`, `install-channel`, `CARLOS_REGION_HA`, `privateDial` and `edge/lbhealth.go`. R4a keeps `boxchoice`. Changes to root verbs and units need a census card and an approval (AGENTS.md).
## 17. Interactions
-- **Moves and seed imports:** refused in HA regions (§14).
+- **Moves and seed imports:** §14. The self-serve moves branches (`origin/self-serve-moves-2` to `-4`) build on the HA path for HA regions.
- **Nearest region and #199** (`origin/design-nearest-region-199`, rev 2): §5.3 closes the local-copy half with the lifetime in the marker. §11 refuses reused names with S3 leftovers in HA regions, including `files/0/` and the lock.
- **Static sites; the edge asset cache; rootfs apps (#366):** unchanged, except that a box materializes images on its first wake there.
- **`db pull`/`db query --at` and the cross-region db forward:** they read the replica, so any box of the region serves them.
@@ -591,11 +630,9 @@ Whether N-box moves and imports join this plan series is Paul's question (§22 Q
S3 prices: LIST and PUT $0.005 per 1,000; GET $0.0004 per 1,000; DELETE free.
**Steady state, per box per hour.**
-- **S3:** unchanged, at about 3,300 to 3,500 today.
-- **Edges files:** the timed pass is unchanged, and due changes no longer touch edges files.
-- **Duty files:** at most 60 PUTs.
-- **SQS:** 180 long-poll receives (about $0.05 a month).
-- **EC2:** describes only on suspicion, at most one per instance per 10 seconds.
+- **S3:** unchanged, at about 3,300 to 3,500 today. The edges timed pass is unchanged; duty files add at most 60 PUTs.
+- **SQS:** 180 long-poll receives (about $0.05 a month). **EC2:** describes only on suspicion, at most one per instance per 10 seconds.
+- **Peer probes (A22):** none in steady state; one private request a minute per peer while a box's own S3 is failing.
- **The lease TTL** is unchanged (N-HA3).
**Reader amplification** comes only from writes that bump `control/edges`: the timed passes, box start and stop, role changes, and the deletion of a dead box's file. Each makes every box in the deployment re-read at its next 30-second poll: one LIST per 1,000 keys, plus one GET per edges file (`homemap.go:456-491`). Readers coalesce, so the bound is 120 × (1 + B) requests per box per hour, for B boxes in the deployment. The timed passes already reach it today, so this spec adds none.
@@ -612,26 +649,34 @@ S3 prices: LIST and PUT $0.005 per 1,000; GET $0.0004 per 1,000; DELETE free.
| Takeover | 1 GET + 1 PUT + 1 describe |
| Termination or drain transfer | 2 GETs + 1 PUT + 2 DELETEs |
| Awake hour, snapshot plan | at most 4 publishes, none when unchanged |
-| Awake hour, continuous plan | up to 2 PUTs per write interval per file being written (§22 Q2) |
+| Awake hour, continuous plan | up to 720 PUTs per app file being rewritten (2 per 10 s), about $2.60 a month per such file. The H6 trio: up to 2 PUTs a second while written, which is rare |
**Example.** 10,000 sleep-and-wake cycles a day on HA boxes add 10,000 GETs and 10,000 PUTs: about $0.054 a day.
## 19. Switches and rollout
-**Switches.**
-- **Box:** `CARLOS_REGION_HA` gates the HA acquire, markers, restores, forwarding, duties, files sync, the latch, the hairpin redirect, headroom, the identity record and the private dial.
-- **Unconditional:** the owner format.
-- **Console:** `CARLOS_REGION_METRICS` (exists), `CONSOLE_REGION_INGRESS` (new), the role door, the readiness door and the HA refusals.
-- **App:** `files_durability` and `files_snapshot_interval`.
+**Switches.** On the box, `CARLOS_REGION_HA` gates everything in P1; only the owner format is unconditional. On the console: `CARLOS_REGION_METRICS` (exists), `CONSOLE_REGION_INGRESS` (new), and the role, readiness and refusal doors. Per app: `files_durability` and `files_snapshot_interval`.
+
+**Plans.**
-**Order.**
-0. R3 (§16.3) lands.
-1. **The HA release.** Roll it dev boxes, dev console, check, flagship boxes, flagship console.
-2. **Dev's IE region** already has two boxes (`platform-infrastructure/dev/region-ie-b.tf`). Turn `CARLOS_REGION_HA` on for both together, before anything else, as the first N=2 test.
-3. **Each flagship old box** turns it on in turn; readiness then has to go green.
-4. **Per region:** infrastructure (§12) and retirement (§13). Dev, then UK, US, AU, and IE last.
+| Plan | Scope |
+|---|---|
+| P1 | Box core: owner format, HA acquire, release marker and keep rule (§5), forwarding (§6), duties and keys (§7), files sync (§8), takeover (§9), latch and A22 (§10), hairpin (§12.4), roles. |
+| P2 | Console: role and readiness doors, capacity metric, create refusals (§11), ingress list, the S2 §8 rewrites (§15). |
+| P3 | Infrastructure and boot (§12): group mode, boot script, IAM, alarms. |
+| P4 | N-box offline moves (§14.1 to §14.3), with the self-serve moves owner. |
+| P5 | Region-target seed import (§14.4), with the seeded-instances owner. |
+| P6 | Retirement (§13): runbook, drills, rollback rehearsal. |
+
+**Gates.** Each release rolls dev boxes, dev console, check, flagship boxes, flagship console. R3 (§16.3) lands before P1.
-The terminate, hang and S3-loss drills run on dev first (§21).
+| Gate | Allows | Needs |
+|---|---|---|
+| G1 | `CARLOS_REGION_HA` on dev's two IE boxes (`platform-infrastructure/dev/region-ie-b.tf`), together, as the first N=2 test | P1 and P2 released; moves and imports refused |
+| G2 | A dev group region (P3) | G1; the terminate, hang, hang-after-first-service and S3-loss drills timed (§21) |
+| G3 | The first test region goes HA: the switch on its old box, then its group joins | G2; readiness green; moves and imports may still be refused (N-HA4) |
+| G4 | Other carloku.com regions go HA, one at a time: UK, US, AU, then IE | G3 accepted for seven days |
+| G5 | Any carloku.com region retires its old box (§13) | P4 and P5 shipped and rehearsed on dev's N-box region, moves in and out and an import with rollback (N-HA4); P6 rehearsed on dev |
## 20. Observability and alerts
@@ -639,7 +684,8 @@ The terminate, hang and S3-loss drills run on dev first (§21).
- `EligibleBoxes < box_count` for 25 minutes, missing as breaching; `GroupInServiceInstances < desired`.
- The termination queue's `ApproximateAgeOfOldestMessage` over 10 minutes.
- **Takeovers and transfers:** a metric and a log line each, with the host, the dead box, the instance id and the latency.
-- **Suspect holders:** any host refused for over 10 minutes for a lease whose owner is not confirmed dead. The runbook says terminate that box in its group (§9.5).
+- **Suspect holders:** any host refused for over 10 minutes for a lease whose owner is not confirmed dead. That is the backstop when A22's peer guard has no evidence; the runbook says terminate that box in its group (§9.5).
+- **S3-unhealthy boxes (A22):** each one, with the peer evidence it used.
- **Local copies set aside,** by reason: no marker, another box, a different lifetime, an identity change, a digest change, or `clean: false`.
- **Files:** the oldest unpublished change over 5 minutes, or over two intervals on the snapshot plan; failed backfills.
- **Clock:** a chrony offset over 1 s on any box.
@@ -652,13 +698,9 @@ The terminate, hang and S3-loss drills run on dev first (§21).
A seeded, invariant-based simulation, `internal/sim/regionha`, test only.
-**It models:**
-- 2 to 5 boxes, each with local DB and files state and a release record;
-- one S3 with conditional writes, per-host replica chains, `lock.json` with markers, and duty files;
-- EC2's state machine, the group's reaction and its grace period;
-- a lossy termination queue.
+**It models** 2 to 5 boxes, each with local DB and files state and a release record; one S3 with conditional writes, per-host replica chains, `lock.json` with markers, and duty files; EC2's state machine, the group's reaction and its grace period; and a lossy termination queue.
-**Actions:** requests, sleeps, kills, hangs, a hang just after the first healthy service, one box losing S3, agent crashes, concurrent cold wakes, drains, membership changes, recreated hostnames, and clock offsets up to the bound.
+**Actions:** requests, sleeps, kills, hangs, a hang just after the first healthy service, one box losing S3, a regional S3 outage, agent crashes, concurrent cold wakes, drains, membership changes, recreated hostnames, offline moves and imports (with aborts and stager deaths), and clock offsets up to the bound.
**Invariants:**
- **I1, single writer.** Every replica or manifest write came from the lease holder of the moment, and no two writes for one host share a transaction id.
@@ -669,6 +711,8 @@ A seeded, invariant-based simulation, `internal/sim/regionha`, test only.
- **I6, duties.** Every tick and due wake is delivered at least once while some serving box exists, and no transferred duty is lost when the adopter dies part way.
- **I7, one key.** No host's instance key is minted twice.
- **I8, lifetimes.** No copy is reused across lifetimes.
+- **I9, moves.** A landed instance holds exactly the sealed `txid` and manifest, and no box keeps a local copy past a staging marker.
+- **I10, no churn.** A regional S3 outage makes no box unhealthy; at most one box per region is unhealthy for S3 at a time.
**Mutation checks.** Each of these must make the sweep fail:
- keep a copy without the marker;
@@ -676,28 +720,28 @@ A seeded, invariant-based simulation, `internal/sim/regionha`, test only.
- accept `shutting-down`;
- delete the source duty file before the adopter's PUT succeeds;
- mint before the restore;
-- let a forwarded request be forwarded again.
+- let a forwarded request be forwarded again;
+- keep a local copy before promoting staging;
+- report S3-unhealthy without peer evidence.
One 3,000-seed sweep per revision, run serially at nice 19.
### 21.2 Other tests
- **Unit tests:**
- - the marker: its JSON is accepted by litestream's decoder and read as expired by `LockState` and `leaseFree`;
- - each keep and restore reason of §5.3;
- - the acquire table of §9.4;
- - termination verification; the duty-file merge; HRW; the latch; the hairpin rule's generation.
-- **Against MinIO:** the HA acquire, the marker PUT, and the takeover.
+ - the marker: litestream's decoder accepts its JSON, and `LockState` and `leaseFree` read it as expired;
+ - every keep and restore reason (§5.3), the acquire table (§9.4), and staging and lifted-tombstone rows;
+ - termination verification, the duty-file merge, HRW, the latch, A22's guard, and the hairpin rule.
+- **Against MinIO:** the HA acquire, the marker PUT, the takeover, the tombstone and staging-marker writes.
- **Dev drills, each timed:**
- terminate a box, measuring committed-write loss per replication class;
- - hang one (`SIGSTOP` the agent; separately, black-hole its health port), including once just after its first healthy service;
- - black-hole S3 for one box, then the runbook terminate;
+ - hang one (`SIGSTOP` the agent, or black-hole its health port), including just after its first healthy service;
+ - black-hole S3 for one box (A22 replaces it), and for every box (none is replaced);
- concurrent cold wakes;
- - drain, stop and the rollback restart;
- - the EIP cut-over;
- - the hairpin from the agent, a tenant and a sidecar.
+ - offline moves in and out of the N-box region, an import with rollback, and an abort at each phase;
+ - drain, stop, rollback restart, and the EIP cut-over;
+ - the hairpin, from the agent, a tenant and a sidecar.
## 22. Open questions for Paul
-1. **Do N-box offline moves and seed imports join this plan series?** They are refused in HA regions until they have their own contract (§14). *Recommendation:* a separate spec after the first HA region is accepted, since neither is needed to meet the failover goal.
-2. **How fast should continuous files sync be?** S1 §5.6's one-second deadline costs up to two PUTs per second for each file an app keeps rewriting: about $26 a month per such file. *Recommendation:* 10 seconds for app files on the top plan (about $2.60 a month at worst, a 10-second loss window), and 1 second for the H6 trio, which are small and rarely written.
+None. Paul's rulings N-HA4 and N-HA5 answered rev 2's two questions.