carlos / platform Public

region HA G3-B10: spec addendum and plan

Born HA only in a named HA pool in scoped regions; proof against the
region's data bucket outside home.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude 0f11bf89cac9f7fedd245bd5092ffa605bd13e81 parent ddbc029
2 files changed, +96 −1
  • docs/superpowers/plans/2026-11-05-region-ha-g3-b10.md +70 −0
  • docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md +26 −1
diff --git a/docs/superpowers/plans/2026-11-05-region-ha-g3-b10.md b/docs/superpowers/plans/2026-11-05-region-ha-g3-b10.md
new file mode 100644
index 000000000..0b2339d6b
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-05-region-ha-g3-b10.md
@@ -0,0 +1,70 @@
+# Region HA G3-B10: born HA only in a named HA pool
+
+Plan, 2026-11-05. Spec: `2026-10-26-region-ha-without-claims-design.md` §23 (addendum B10). Branch `region-ha-g3-b10` from origin/main ddbc0297. Review budget: one Astra review of addendum and plan, at most three rounds; Opus task and branch reviews, at most three rounds (stopping rules). Ledger: `.superpowers/sdd/2026-11-05-region-ha-g3-b10/`.
+
+**Finish line.** A console on this branch, given `CONSOLE_HA_REGIONS=us` and a capacity config whose `us` entry has `"ha_pools":["ha"]`, creates a born-HA instance in app pool `ha` in `us` (proof against the configured US data bucket), creates a plain US instance exactly as with `us` not listed, and still refuses moves and imports touching `us`. Dev's config (no `ha_pools`) behaves as on main. No release, apply or drill.
+
+## Rulings
+
+| # | Ruling |
+|---|---|
+| R1 | Paul 2026-11-05: only named-HA-pool creates are born HA in a scoped region; plain creates stay legacy; no customer notice. |
+| R2 | Controller: the scope lives in `CONSOLE_HA_CAPACITY_CONFIG` (`regions.<code>.ha_pools`), the document that already names the region's data bucket. No new env var. |
+| R3 | Controller: create-path gates move to `haCreate(region, pool)`; transfer gates (moves, seed `--from`, import, placement changes, `haTransferRegion`, `refuseHAImport`, `apiplacements.go`) stay on `haRegion` (N-HA4). |
+| R4 | Controller: the non-home proof is two bounded LISTs (one key each) of whole prefixes, not the LTX level walk: stricter, and the console holds no litestream client for remote buckets. |
+| R5 | Controller: new or changed refusal sentences name regions by label (`offlinePlace`), not code. The no-room sentence (`nocapacity.go`) is in a touched file, so its "ie" is fixed too. One Luna pass, applied verbatim. |
+
+## Task 1: config and the predicate
+
+Files: `internal/console/hacapacity.go`, `internal/console/seedmove.go`, `internal/console/server.go`.
+
+- [ ] `haCoordinates` gains `HAPools []string \`json:"ha_pools,omitempty"\``; `haOnlyFields` for a region allows `ha_pools`. Present means: a JSON array, non-empty, each entry matches the pool-name rule the manifest uses for `Pool` (find it; do not invent one), distinct, never the shared pool (`""` or `@shared`). Anything else: `errHACapacity`. Absent: unscoped. `null` is already refused by `haJSON`.
+- [ ] Server start (`New` or where config is first read) parses `cfg.HACapacityConfig` once with `parseHACapacityConfig(raw, cfg.HARegions, cfg.HomeRegion)` and keeps `map[region code]pools` for scoped regions. Parse failure or empty raw: no scoped regions (log once). The observer's own parse is unchanged.
+- [ ] `func (s *Server) haCreate(region, pool string) bool`: `haRegion(region)` and (region unscoped or `pool` in its list). The home region `""` is looked up by `cfg.HomeRegion`, as `haRegion` does.
+- [ ] `shouldStampHA` uses `haCreate(rec.Region, rec.Pool)`.
+- [ ] Unit tests: parser accepts/refuses `ha_pools` shapes (absent, `[]`, duplicate, shared, bad name, non-array, case-variant key); `haCreate` matrix (unscoped home, scoped us with `ha`/""/other pool, non-HA region).
+
+## Task 2: create-path gates
+
+Files: `internal/console/apiinstances.go`, `hacreate.go`, `nocapacity.go`, `apisidecars.go`, `domainattach.go`.
+
+- [ ] Switch to `haCreate(region, <pool>)`, pool = `m.Pool` or `rec.Pool` as the line already has: `apiinstances.go` app-derived eligibility (~1839), `checkPlacement`'s `roomIn` skip (~1957), the placement order (~2010, ~2345), the HA duplicate read (~2281); `haCreateShapeRefusal` (F1, uses `rec.Pool`); `requireHACreateCapacity` (its `pool` argument); `apisidecars.go` `rec.HA` (~369) and the duplicate read (~418); `domainattach.go` `haRegion("")` (~228, pool of the record it would write, `""`).
+- [ ] Leave on `haRegion`: `seedmove.go` transfer helpers, `apiinstances.go` seeded block (~2330), `apiplacements.go`, the observer and metrics. Grep every `haRegion(` caller and list each with its class in the ledger.
+- [ ] `noCapacityRefusal` / `noRoom`: user-facing region becomes the label (`offlinePlace`); the alert and log keep the code.
+
+## Task 3: the proof outside home
+
+Files: `internal/console/createleftovers.go`, `internal/console/server.go`, `cmd/console/main.go`.
+
+- [ ] `Config.HADataStores map[string]release.Store` (region code to the region's data bucket). `cmd/console/main.go` builds one per scoped, non-home region from the parsed config (`release.NewS3StoreIn(ctx, data_bucket, data_bucket_region)`, wrapped like `seedData`). Build failure: no store for that region (creates there answer 503). Put the construction in a named function so a test drives it.
+- [ ] `leftoverReplicaRefusal`, HAData branch: F5 stays only for unscoped regions (non-home or pooled, as today). For a scoped region:
+ - home: today's proof (SeedData whole prefix, then the moves LTX walk); the pool no longer blocks authority. Authority = `HibernateBucket != ""`, `SeedData != nil`, record region equals `cfg.Region`.
+ - non-home: store = `HADataStores[region]`; nil or not a `PageLister` is 503 `unsure`. `firstHALeftover(store, <HibernatePrefix(host)>/)`, then `firstHALeftover(store, moves/<host>/)`. Either error is 503; any key is 409 naming the class (reuse `firstHALeftover`'s class; staging is "replica"). Log errors with the host, never return the bucket name.
+- [ ] Sentences: `unsure` and the F5 sentence name the region by label. F5's text is otherwise unchanged (approved copy).
+
+## Task 4: witnesses (production wiring)
+
+Files: new `internal/console/ha_pool_scope_test.go`; `cmd/console/` test for the store builder.
+
+Through the real handlers (`POST /api/cli/apps/<acct>/<app>/instances`, sidecar create), real `Server` construction, a DirStore or fake-S3 deployment store, and a counting `PageLister` fake for the US store. Config: home `ie`, `CONSOLE_HA_REGIONS=us`, capacity config with `us.ha_pools=["ha"]`, an observation allowing pool `ha` in `us`.
+- [ ] Pool `ha` in `us`: 201, record `ha:true`, region `us`, pool `ha`; the US store saw exactly `instances/<host>/` then `moves/<host>/`, limit 1 each; the home store saw nothing.
+- [ ] Unpooled in `us`: 201, `ha:false`; no HA capacity decision, no US store call; same answer and record as with `CONSOLE_HA_REGIONS` empty (compare the two responses).
+- [ ] Pool `other` in `us`: legacy, as above.
+- [ ] Leftover under `instances/<host>/` and under `moves/<host>/`: 409, zero writes (record, lifetime, store grant, index).
+- [ ] US store missing, list error: 503, zero writes.
+- [ ] Non-hibernating binary socket in pool `ha`: F1 400; unpooled: allowed as legacy.
+- [ ] Move into `us` and out of `us` of a legacy record, and seed import into `us`: still refused with the existing sentences.
+- [ ] Dev shape (`ie` home, `CONSOLE_HA_REGIONS=ie`, no `ha_pools`): existing `ha_born_test.go`, `hacreate_test.go`, `hacreatecapacity_test.go`, `sidecar_ha_test.go` pass unmodified; a pooled `ie` HAData create still gets F5.
+- [ ] Store builder test: config with `us` (bucket, region) and `ie` home yields one store for `us`, none for home, with the configured bucket and region.
+
+Run: `nice -n 19 go test ./internal/console -run 'HA|Leftover|Sidecar|Capacity|Rootfs' -count=1` and `go test ./cmd/console -run <builder test> -count=1`. `go vet ./internal/console ./cmd/console`. GOOS=darwin and windows `go build ./...`.
+
+## Task 5: copy, docs, census
+
+- [ ] Extract every new or changed user-facing sentence; one Luna pass; apply verbatim (no em dashes).
+- [ ] `docs/site/cli.md` lines that quote F5 or describe HA creates: update if the behaviour they state changed.
+- [ ] If CI's census fails, `make census-card`, CLAIMS, `make census-propose NAME=region-ha-g3-b10`; Opus approval recorded on #280.
+
+## Out of scope
+
+IAM (G3 card item 3), the release, the console drop-ins (card item 10, which gains `"ha_pools":["ha"]`), dev, moves and imports into HA regions (P4, P5), box-side changes.
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 a68f73876..adc47afa5 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.2**: 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.3** (§23 B10 addendum, 2026-11-05): 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.
@@ -781,3 +781,28 @@ One 3,000-seed sweep per revision, run serially at nice 19.
## 22. Open questions for Paul
None.
+
+## 23. Addendum B10: born HA only in a named HA pool (2026-11-05)
+
+**Ruling.** Paul, 2026-11-05 ~18:00Z (G3-B10, via agent manager 8a3d302): in a region whose HA is scoped to named pools, only creates placed in one of those pools are born HA. Every other create in that region stays legacy on the old box and works exactly as it does in a non-HA region. Customers join the pool later, by choice; nobody is placed without consent. Born-HA creation works in a non-home region.
+
+**What it replaces.**
+- N-HA7's stamp rule, for scoped regions only: `CONSOLE_HA_REGIONS` alone no longer stamps every plain instance create there. Unscoped regions (dev IE today) keep N-HA7's rule unchanged.
+- P2a's F5 cut (plan `2026-11-01-region-ha-p2-console.md`, Rulings and P2-4/C3: "non-home and pool HA data creates stay refused for G3, 409"), for scoped regions only. Unscoped regions keep F5.
+
+**The switch.** A region's entry in `CONSOLE_HA_CAPACITY_CONFIG` may carry `"ha_pools": ["<pool>", ...]`: a non-empty list of distinct named pools (not the shared pool). A region with the key is **scoped**; a region without it is **unscoped**. The console parses the document once at start for this; an invalid document leaves every HA region unscoped, which is today's fail-closed behaviour (capacity unknown, 503).
+
+**The rule, per create door (instance, standalone sidecar, domain-attach first route).** Let `haCreate(region, pool)` be: the region is in `CONSOLE_HA_REGIONS`, and either it is unscoped or `pool` is in its `ha_pools`. Every create-path HA gate asks `haCreate` instead of `haRegion`: the stamp, the binary-socket shape refusal (F1), the HA capacity decision, the HA duplicate read, the placement-check ordering, the app-derived region's eligibility, and the standalone sidecar's HA flag. A create with `haCreate` false is a legacy create, gate for gate.
+
+**The proof outside home (§11's leftover refusal).** A born-HA data create in a scoped region proves the host's prefixes empty in **that region's data bucket**, named by the config's `data_bucket` and `data_bucket_region`:
+- the home region keeps P2a's proof (home store, whole `instances/<host>/` prefix, then the `moves/<host>` LTX walk), now also for a pool in `ha_pools`;
+- a non-home region gets one bounded LIST (max one key) of `<hibernate prefix>/<host>/` and one of `moves/<host>/` in its own bucket. Any object refuses the create (409, names the class); a missing store or a failed LIST refuses with 503 before any write;
+- the console's role needs `s3:ListBucket` on that bucket for prefixes `instances/*` and `moves/*` (G3 card item 3). This build adds no IAM.
+
+The region's boxes must use the console's hibernate prefix (its activator configuration); the G3 card checks it on the US box. As in P2a, the proof reserves nothing and first wake still proves an empty prefix.
+
+**Unchanged (N-HA4).** Offline moves, seed `--from`, seed import and placement changes into or out of an HA region stay refused region-wide, scoped or not, for legacy hosts as well as HA ones.
+
+**Dev.** Dev's IE entry carries no `ha_pools`, so dev behaves exactly as today: plain home creates are born HA, pooled and non-home HA data creates get F5, and existing records (hapair-a1) keep their immutable flag.
+
+**Review budget.** One Astra review of this addendum with its plan, at most three rounds (stopping rules).