carlos / platform Public

region HA G3-B10: answer Astra plan round 1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude f4109e35947cf3fb67a8f83b0346835577775ea1 parent 0f11bf8
2 files changed, +24 −18
  • docs/superpowers/plans/2026-11-05-region-ha-g3-b10.md +16 −10
  • docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md +8 −8

CI cancelled — superseded by a newer push — run details

Intent

Human

<task-notification> <task-id>buhnpux2j</task-id> <tool-use-id>toolu_017ttxkDHHt765uTHV7fRHBB</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/265811d8-fa99-4f28-a191-8a01ce8693ac/tasks/buhnpux2j.output</output-file> <status>completed</status> <summary>Background command "until [ -f /home/paulca/.cache/tmp/astra-b10-r1.done ]; do sleep 20; done; echo done" completed (exit code 0)</summary> </task-notification>

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
index 0b2339d6b..e34be6613 100644
--- a/docs/superpowers/plans/2026-11-05-region-ha-g3-b10.md
+++ b/docs/superpowers/plans/2026-11-05-region-ha-g3-b10.md
@@ -11,7 +11,8 @@ Plan, 2026-11-05. Spec: `2026-10-26-region-ha-without-claims-design.md` §23 (ad
| 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. |
+| R4 | Controller: a scoped region's proof (home or not) is two bounded LISTs (one key each) of whole prefixes in the config-named bucket, not the LTX level walk: stricter, one path, and the console holds no litestream client for remote buckets (Astra A2). |
+| R6 | Astra r1: A1 (prefix needs the activator config), A2 (configured bucket, also at home), A3 (`--from` unchanged), A4 (invalid config is 503, not F5), A5 (F1 by predicate) accepted. |
| 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
@@ -19,8 +20,8 @@ Plan, 2026-11-05. Spec: `2026-10-26-region-ha-without-claims-design.md` §23 (ad
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.
+- [ ] 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 plus a `haScopeInvalid` bool (true when `HARegions` is non-empty and the parse failed or raw is empty). 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. With `haScopeInvalid`, every HA region reads as unscoped (today's rule) for `haCreate`; Task 3 turns its HA data creates into 503.
- [ ] `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).
@@ -36,10 +37,12 @@ Files: `internal/console/apiinstances.go`, `hacreate.go`, `nocapacity.go`, `apis
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.
+- [ ] `Config.HADataStores map[string]release.Store` (region code to the config-named data bucket). `cmd/console/main.go` builds one per **scoped** region, home included, 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, after the existing duplicate/read-error answers:
+ - `haScopeInvalid`: 503 with the existing `haCapacityUnknownRefusal` sentence and `Retry-After: 60`, before F5 and before any LIST (A4).
+ - unscoped region: today's code unchanged (F5 for non-home or pooled; home proof).
+ - scoped region (home or not): `cfg.HibernateBucket == ""` is 503 `unsure` (A1: the prefix is unknown). Store = `HADataStores[region code]`; nil or not a `PageLister` is 503 `unsure`. `firstHALeftover(store, HibernatePrefix(cfg.HibernatePrefix, host)+"/")`, then `firstHALeftover(store, "moves/<host>/")` (use `activator.MovesPrefix`). Either error is 503; any key is 409 naming the class (reuse `firstHALeftover`'s class for the first; staging is "replica"). Log errors with the host; never return the bucket name. `SeedData` and `dbReplica` are not used on this path (A2).
+- [ ] The duplicate read at `apiinstances.go` ~2281 and `apisidecars.go` ~418 must still run for every scoped HAData create before capacity (it does when `leftoverCheckApplies` is false; check the home scoped case too).
- [ ] Sentences: `unsure` and the F5 sentence name the region by label. F5's text is otherwise unchanged (approved copy).
## Task 4: witnesses (production wiring)
@@ -47,13 +50,16 @@ Files: `internal/console/createleftovers.go`, `internal/console/server.go`, `cmd
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.
+- [ ] Pool `ha` in `us`: 201, record `ha:true`, region `us`, pool `ha`; the US store saw exactly `<prefix>/<host>/` then `moves/<host>/`, limit 1 each; the home store saw nothing.
+- [ ] Scoped home (`ie` home with `ie.ha_pools=["ha"]`, config bucket B, console `HibernateBucket`/`SeedData` A): leftovers only in B refuse 409; A is never listed (A2).
+- [ ] Activator config not loaded (`HibernateBucket` empty) with a scoped `us`: 503, no LIST, no writes (A1).
+- [ ] Invalid `CONSOLE_HA_CAPACITY_CONFIG` with `CONSOLE_HA_REGIONS=us`: pool `ha` create and plain create both 503 capacity-unknown with `Retry-After: 60`, not F5; an existing record still gets the duplicate 409 first (A4).
- [ ] 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.
+- [ ] F1 (A5): direct `haCreateShapeRefusal` predicate test with `Hibernate=false` for scoped `us` pool `ha` (refused), pool "" (nil), unscoped `ie` (refused). Through HTTP: a sidecar create in pool `ha` on a non-hibernating sidecar manifest is 400 "high availability sidecars must allow hibernation."; unpooled in `us` is not.
+- [ ] Move into `us` and out of `us` of a legacy record, and seed import into `us`: still refused with the existing sentences. Seed `--from` keeps main's behaviour (`TestSeedsRemainLegacyAndSidecarsBornHA` unchanged) (A3).
- [ ] 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.
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 adc47afa5..a1cebf78b 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
@@ -790,19 +790,19 @@ None.
- 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 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 or missing document is not "unscoped": while `CONSOLE_HA_REGIONS` is set, every create that would be HA data under either reading (an unscoped region's rule or a pool create) answers the existing capacity-unknown 503 (`Retry-After: 60`) before F5 or any proof, after the door's duplicate and read-error answers. Plain creates in that state follow today's unscoped rule.
**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 proof in a scoped region (§11's leftover refusal).** A born-HA data create in a scoped region, home or not, proves the host's prefixes empty in **the data bucket the config names for that region** (`data_bucket`, `data_bucket_region`), not in the console's own data bucket, so the proof looks where the region's boxes write:
+- one bounded LIST (max one key) of `<hibernate prefix>/<host>/` and one of `moves/<host>/`, in that bucket. Any object refuses the create (409, names the class). No store for the region, a store without bounded listing, or a failed LIST refuses with 503 before any write;
+- the hibernate prefix is the console's own, from its activator configuration. If that configuration did not load (no `HibernateBucket`), the prefix is unknown and the create answers 503 before any LIST;
+- the console's role needs `s3:ListBucket` on that bucket for prefixes `instances/*` and `moves/*` (G3 card item 3; for a scoped home region, the existing grant on its own bucket). 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.
+The region's boxes must use the console's hibernate prefix; the G3 card checks it on the US box. As in P2a, the proof reserves nothing and first wake still proves an empty prefix. Unscoped regions keep P2a's home proof and F5 unchanged.
-**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.
+**Unchanged (N-HA4).** Offline moves, 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. Seed `--from` keeps its existing rules (`seedPlacementRefusal`, never stamped), as on main.
**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).
+**Review budget.** One Astra review of this addendum with its plan, at most three rounds (stopping rules). Round 1 (A1-A5, NOT READY) is answered in this text: the scoped proof always uses the configured bucket (A2), needs the activator prefix (A1), `--from` is unchanged (A3), and an invalid config is a 503 (A4).