region HA P2b: console plan rev 1
1 file changed,
+360
−0
docs/superpowers/plans/2026-11-04-region-ha-p2b-console.md+360 −0
diff --git a/docs/superpowers/plans/2026-11-04-region-ha-p2b-console.md b/docs/superpowers/plans/2026-11-04-region-ha-p2b-console.md| new file mode 100644 |
| index 000000000..7a247c16e |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-11-04-region-ha-p2b-console.md |
| @@ -0,0 +1,360 @@ |
| +# Region HA P2b: console implementation plan |
| + |
| +> **For agentic workers:** Planning only in this session. No production edits, push, reviewer dispatch or full test suite. Execute the checkbox tasks only in a later authorized implementation session, after resolving their gates. Later slices below are requirements, not permission to implement an unmerged producer. |
| + |
| +**Goal:** On dev, a create with no eligible serving box returns the existing no-capacity answer before it writes anything. The console publishes the same regional count without claims. Operators subsequently get role read-back and honest readiness evidence. The HA awake-box display remains a separate slice because every rollout consumer must agree. |
| + |
| +**Architecture:** One console observation per minute reads existing edges publications, status reports and signed identities. Metric publication and create admission use that immutable observation. The console neither chooses a lease owner nor probes boxes. Role writes use P3a's existing control objects. Full readiness and display have explicit producer/design gates below. |
| + |
| +**Tech stack:** Go, the existing console HTTP/CLI doors, release.Store, boxid, boxchoice and the CloudWatch adapter. No new service, box poll, ASG enumeration or data-bucket permission. |
| + |
| +**Authorities:** `docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md`, rev 6.1, especially §§4.4, 10–12, 15, 18–19; AGENTS.md; discussion #421 as supplied in `/home/paulca/.cache/region-ha-p2b/d421.md`; P2's two deferred-outline sections in `docs/superpowers/plans/2026-11-01-region-ha-p2-console.md`. |
| + |
| +**Citation base:** **016599d5b97c04b2fc5e807b834fdf38e2c7a35e**, the checked-out `origin/main`. All existing-code file:line citations below refer to that tree. Proposed files, settings, helpers and response additions are explicitly marked proposed and have no invented source lines. The released `v0.34.0` decoder/watch was also inspected for compatibility; it is not an implementation dependency. |
| + |
| +**Status:** rev 1, no review yet; the display slice carries P2's two C1 rounds and N-HA13. This draft settles no open choice for Paul by implication. Its finish line is one local planning commit and the requested DRAFT-DONE file. |
| + |
| +## Rulings and decisions |
| + |
| +| Authority / invariant | Consequence | |
| +|---|---| |
| +| N-HA1, N-HA3, N-HA9 / I1 | The Litestream lease remains writer authority. No shorter lease, early takeover, lock reader in the console, or claim activation. | |
| +| N-HA2, N-HA4, N-HA7 / I1, I5 | Born-HA only. Preserve immutable stamps after switch-off and all move/import refusals. No migration, retirement or new data-proof authority. | |
| +| N-HA5, N-HA6 / I1 | No publication/capture cadence changes or new recovery/loss-window promise. | |
| +| N-HA8, N-HA10, N-HA12, N-HA15 / I1 | Existing forwarding, billing and recovery stay unchanged. Create capacity never gates existing-host wakes, retries, timers or restarts. | |
| +| N-HA11, N-HA16, N-HA17 / I6 | Use the merged departure lifecycle truth. Started means the first successful queue receive, not constructor return, Running, completed scans, or a health guarantee. No new queue consumer. | |
| +| N-HA13 / I7 | Display is its own small design. P2a's C1 P1-1 and P1-A are retained requirements, not a fresh review budget. No isolated awake-box badge beside main's conflicting rollout. | |
| +| N-HA14 / I6 | ASG Standby rolls, replacement, launch hooks and booting group boxes remain P3b. Fixed-box admission is the only P3a admission implemented here. | |
| +| #421 controller P3a T2 final CUT, 2026-11-04 / I6 | Closed boxes keep legacy names. They refuse locally; home election and cold-wake exclusion remain. Do not reintroduce namespace withdrawal or infer readiness from a held name. Its three-round family remains closed. | |
| +| P2 controller G3 ruling / I5 | Keep non-home and pooled HA data creates refused. Lifting F5 is not trivial: main only proves the configured home data prefix, not arbitrary region/pool storage. | |
| + |
| +New author decisions, subject to the questions below: |
| + |
| +| Decision / invariant | Reason | |
| +|---|---| |
| +| D1 / I2, I3: keep a console-wide immutable observation for one minute, including failures | Request memoization alone is not process-wide sharing. A burst must neither multiply bucket reads nor keep an old successful count after an unsuccessful observation. | |
| +| D2 / I2: configure the region universe and trusted coordinates explicitly | A vanished region must still produce zero after a complete empty read. Neither surviving files nor their majority can select a CloudWatch region or data bucket. | |
| +| D3 / I2, I6: require explicit P3a admission fields for HA create eligibility | `HomeEligible` intentionally accepts old files as serving for compatibility. It cannot prove admission/readiness. Missing additions are unknown, not a positive result. Schedule box rollout before enabling this console behavior. | |
| +| D4 / I4: count all eligible serving boxes regionally, then narrow for the create's pool | A box serving a named pool is regional capacity. Requiring shared-pool membership for the metric would undercount it. Named-pool admission has no published pool-list input on this main; Q1 decides the temporary capability boundary. | |
| +| D5 / I6: readiness and completed drain remain outline work | P3a publishes role/admitted/drained, but not its local facts or health conditions, and never publishes drained=true. Q2 chooses a limited diagnostic door or waiting. | |
| +| D6 / I7: do not execute display in P2b-1 | Shared observation, failure holds, retry authority, lifetime attribution and released deploy-watch behavior need one design. A small badge does not isolate those risks. | |
| + |
| +## Named invariants |
| + |
| +| ID | Property and enforcement point | |
| +|---|---| |
| +| I1. Observation grants no runtime authority | Capacity and display never acquire, release, restore, wake, stop or transfer duties. Existing wake paths do not call the new admission helper. | |
| +| I2. Evidence is complete or unknown | One observation records source times, read completeness, verified identity and region scope. Missing, malformed, ambiguous, capped or failed evidence cannot become zero or ready. Known stale or explicitly excluded boxes count zero; unread boxes do not. | |
| +| I3. One bounded observation | One runner per console starts independently of HostClaim. Metric and every HA create door read the same generation without S3 loads on the request path. Failures obey the same one-minute budget. | |
| +| I4. Eligibility agrees | One pure console projection applies verified identity, exact home scope, data coordinates, effective role, capability, liveness and shared boxchoice headroom thresholds. Pool narrowing is a distinct final step; a regional count is not proof for a named pool. | |
| +| I5. Refuse before mutation | Auth and normal input/duplicate/permanent-refusal checks precede capacity; capacity precedes environment binding, store provisioning, lifetime/history registration, domain claim, record, audit-of-success, serial and index writes. | |
| +| I6. Desired is not applied or ready | A saved role is desired state. A fresh role report is an observation, not a current health check, acknowledgment of a particular write, completed drain, or retirement permission. Unsupported producers leave explicit blockers. | |
| +| I7. One honest HA host projection | Every display, rollout, health and retry consumer uses the same tenant/lifetime-checked evidence. Sleeping or uncertain HA hosts never enter deploy-watch URL fallback. Observation never proves lease authority. | |
| +| I8. Operator and tenant boundaries survive | Role/readiness access uses the existing operator gate. Member doors preserve service/team scope and byte-identical unauthorized 404s. Never expose another account's host data or raw storage keys. | |
| + |
| +## Merged evidence and remaining gaps |
| + |
| +The cited base includes P1b-3a `322d2447`, home-scope correction `c6304f2d`, survivor correction `16b2a0ce`, P1b-3b T `9b8b2c5`, P2a `f2810fd`, follow-ups `f18da98`, and P3a `016599d5`. P3b is not an input. |
| + |
| +| Existing seam at the citation base | What it establishes | |
| +|---|---| |
| +| `internal/boxroles/roles.go:18`, `:29`, `:38`, `:50`, `:83` | Desired serve/drain/platform objects; strict decoding; own override, regional default, then serve. Both point GETs happen even when the first fails. Booting is not a desired role. | |
| +| `internal/host/boxroles.go:41`, `:53`, `:99`, `:114`; `internal/host/boxroles_config.go:12` | Reader is opt-in through CARLOS_GROUP_ADMISSION=1 and change-index read mode. Root-owned region-config.json binds canonical region_code to exact placement, including empty home. A failed read sets local known=false and keeps the prior restriction. | |
| +| `internal/host/edgesfile.go:260`, `:954`, `:985`, `:1158`; `internal/edgesfile/admission.go:10`, `:19` | Actual wire additions are box_role, admitted, drained. Writer sets both box and box_id to its reference. HomeEligible accepts all-three-absent old files. No named-pool list or admission fact vector is published. | |
| +| `internal/host/group_admission.go:37`, `:80`, `:97`, `:112`, `:161` | Fixed admission only; group configuration refuses. Role admission/start gating exists, but EdgesRole returns drained=false, and does not publish the role reader's known bit. Role errors can therefore leave a last-role report; never call it full readiness. | |
| +| `internal/groupadmission/state.go:9`, `:47`; `internal/hadeparture/types.go:47`; `internal/hadeparture/consumer.go:162`, `:198` | Local startup facts and the actual Started acknowledgment. `internal/host/group_admission.go:123` consumes Started. | |
| +| `internal/lbhealth/lbhealth.go:154`; `internal/host/group_metrics.go:36`, `:45` | Six local conditions: hosting, forwarding map/key, certificates, edge beat, activator beat, refresh attempt. Admission/clock CloudWatch datums are region/deployment aggregate inputs, not per-box readiness reports. No console poll of that endpoint or CloudWatch reads added. | |
| +| `internal/edgesfile/snapshot.go:138`, `:161`, `:243`, `:249`, `:281` | Existing live-edges join and completeness rules. PlacementView loses null-versus-empty placement, and BoxChoice loses data-bucket coordinates. Do not use that lossy conversion as the new full predicate. | |
| +| `internal/status/fleet.go:120`, `:138`, `:217`, `:260`; `internal/console/hotreads.go:376`, `:393`; `internal/console/reqmemo.go:217` | Status cadence 5m; stale after 15m; 200 report/1MiB caps; the normal loader drops objects older than 24h. liveEdges is request-memoized, not the required minute-wide observation. | |
| +| `internal/console/boxselect.go:147`; `internal/boxid/record.go:38`, `:65`; `internal/boxid/verify.go:96`, `:102` | Reuse signed identity verification, not roster membership. AWS signature alone does not bind a chosen fixed reference; require the operator's fixed reference/iid binding too. Do not reuse the old unverified region-majority selection. | |
| +| `internal/boxchoice/policy.go:16`, `:49`, `:63`; `internal/edge/wakeplacement.go:87`, `:103` | 15% free memory, 10% free disk, edges age <=15m, future tolerance <=1m. Empty home placement is real. Apps counts affect soft spread, not EligibleBoxes; no console app-count decoder is needed for this count. | |
| +| `internal/console/regioncapacity.go:59`, `:99`, `:121`; `internal/console/hostclaimops.go:50`; `cmd/console/main.go:756` | Current metric enumerates surviving files and depends on the claim chooser/start. Both change in P2b-1. | |
| +| `internal/console/awsregionmetric.go:25`, `:30`, `:46`, `:57`; `internal/console/nocapacity.go:31`, `:38`, `:42`, `:125`, `:166` | Existing metric dimensions/adapter, approved refusal and successful-send hourly throttle. Current roomIn is inert without claims. | |
| +| `internal/console/apiinstances.go:1950`, `:2267`, `:2316`, `:2381`; `internal/console/apisidecars.go:394`, `:422`; `internal/console/domainattach.go:206`, `:227`, `:643` | Create entry points and side-effect boundaries. Include seeded dispatch and both first-domain lifetime arms, not only plain instance creation. First-domain route is home/shared static, not the app's named region. | |
| +| `internal/console/createleftovers.go:144`, `:160`; `internal/console/hacreate.go:16`, `:29` | F5 and bounded home prefix proof already merged. Keep them, including duplicate-before-leftover behavior. | |
| +| `internal/console/apiboxroles.go:84`, `:115`, `:159`; `internal/console/authcli.go:570`; `system_roles.go:35`, `:55`, `:80`; `system.go:160` | Existing doors are claim-gated signed-roster writers with default/legacy vocabulary. They are not P3a object writers. Old CLI success wording claims immediate effect and cannot be reused. | |
| + |
| +## Slices and first visible result |
| + |
| +**P2b-1, executable subject to Q1 and the release card:** Tasks T1–T4 below ship one observation, EligibleBoxes and pre-write create refusals together. Paul can see a disposable dev `carlos instances create` return the approved 503/Retry-After answer, or succeed with positive evidence, while CloudWatch shows that same observation's regional count. A structured observation identifier in internal logs ties the two together. There is no scaffolding-only first merge. |
| + |
| +**P2b-2, outline:** operator role object writer/read-back and region readiness. The write target is now merged, but full readiness/drain producers are not. Q2 selects the visible diagnostic subset or waits. Keep full-readiness work on its branch until its producer has merged and been re-read; do not use P3b's proposed fields. |
| + |
| +**P2b-3, outline and separate small design:** HA awake-box and every rollout consumer. The inventory below is its entry brief, including old-client safety. It has not received authorization to reopen the closed C1 review. |
| + |
| +Switch-on slot proposed for P2b-1: **the first dev-only release after its reviewed implementation merge, target 2026-11-06**, after the fixed-pair P3a release/admission drill and Q1 resolution. Q3 must supply the actual release owner/window before implementation lands. If unavailable, leave implementation on its branch. The planning commit has no runtime switch. Later slices each need their own dated slot before landing; they do not ride this date by default. |
| + |
| +#421 records dev v0.34.0 with CARLOS_REGION_HA enabled on sophie-knitting and leo-climbing, and CONSOLE_HA_REGIONS=ie enabled on the console. It records P3a as merged but not released. Revalidate at card preparation; do not reuse P2a's historical assumption that HARegions is unset. P2b alone proves neither G1 completion nor G2/G3, and never G5 retirement readiness. |
| + |
| +## P2b-1 design |
| + |
| +### Trusted coordinates and scope (I2, I4) |
| + |
| +Proposed console-only setting **CONSOLE_HA_CAPACITY_CONFIG** is a bounded JSON document delivered with the console configuration, not fetched from edges or an app. Its proposed schema has v=1, a regions map keyed by canonical placement code, and fixed_boxes keyed by exact reference. Each region supplies aws_region, data_bucket and data_bucket_region. Each fixed binding supplies region_code and instance_id. Existing Config.AWSAccount and expectedSecretsFP remain the account and deployment key authorities. Reject duplicate/unknown/null fields, empty coordinates, invalid names, duplicate instance bindings and unsupported versions before switching on. Bound the document to 64KiB and 200 fixed references; exceeding a bound is an explicit configuration error. |
| + |
| +The region universe is exactly CONSOLE_HA_REGIONS, with every entry requiring coordinates. It persists when all boxes vanish. The home region is CONSOLE_HOME_REGION; its wire/record placement remains `""`, while all other region codes match exactly. Omitted or empty placement is home; explicit null is malformed. Never set CARLOS_REGION=ie on the dev home boxes or console. The console's raw CARLOS_REGION stays empty for its existing home data proof. |
| + |
| +An HA-enabled console with missing/invalid capacity configuration returns temporary evidence refusals for affected creates and emits no unprovable metric, rather than disabling the safety check. Parser validation must pass on the exact proposed configuration before rolling. Non-HA creates keep main's behavior. Configuration loads once; changing it requires the normal console restart/card. |
| + |
| +Fixed pins bind identity, not membership: a listed pin without live evidence counts nothing. For a g- reference, the exact existing derivation is `g-` plus the first 20 hex digits of SHA-256(`carlos-box-ref-v1|account|instance`), at `internal/host/boxreference.go:91`. Validate it without EC2/group enumeration. P3a still cannot admit such a box; no test may manufacture group admission as production capability. Fixed boxes recreated on a new iid require a new reference, as #421's f18da98 correction states. |
| + |
| +### Observation and freshness (I2, I3) |
| + |
| +Proposed `internal/console/hacapacity.go` owns the pure projection; `hacapacity_observe.go` owns I/O and the immutable cache. Start one runner from console serve, immediately then on the existing one-minute capacity interval, whenever configured HA regions or the CloudWatch adapter need it. Move the nested metric start out of StartClaimRecoveryPass. Do not run either producer from NewServer. A cancellable console lifetime owns the runner; one in-flight pass, bounded to 45 seconds. Requests never start or retry a load. Before the first successful observation they get evidence unavailable. |
| + |
| +Each pass lists control/edges/ and status/boxes/ once with the existing bounded PageLister interface (`internal/release/store.go:389`, `:1074`). Ask for 201 keys per prefix: at most 200 accepted; 201 means incomplete, not a silently truncated census. Use bounded body reads with 1MiB maximum per edges/status object, 64KiB per identity record and the existing status decoder. Read all accepted status keys, including old ones: the ordinary 24-hour horizon must not turn a known stale counterpart into missing evidence. A console-local store view can expose that one preloaded list to LoadBoxesComplete without ModLister or another S3 LIST. Keep this exception local to capacity; display's existing horizon is unchanged. Tests pin actual low-level requests, not just wrapper method calls. |
| + |
| +Retain raw presence/type information for placement, admission and eligibility fields alongside the existing PlacementView. Validate the key's reference, Box and BoxID agree, version is understood, status label is unique, and status Metrics.InstanceID agrees with the verified identity. JoinLive remains the baseline for missing/stale counterpart handling. Verify each distinct candidate reference once per observation through boxid.Load/Verifier.Enroll, with expected account/AWS region, fixed pin or derived g- reference, and a uniqueness check across proven instance IDs. No cross-observation identity cache is necessary in this slice; its GETs are budgeted every minute. |
| + |
| +Record observation start/completion, each edges generation, each status generation, completeness and machine-readable blocker codes. Keep generation times unchanged. Reads are not an atomic S3 snapshot: counts describe the bounded observation, not reserved capacity. On use, recompute time predicates from the retained timestamps; do not freeze a stale answer as fresh. At age >=60s from pass start, the observation is unavailable. Canceled waiters do not cancel a shared load; failed/timed-out passes replace successful evidence with unknown, never stale success. |
| + |
| +An unreadable LIST or unassignable malformed key can affect every region, so all those datapoints are omitted. A failure provably scoped to a validated region omits that region only. A missing status counterpart, missing identity or unknown protocol is incomplete. An identity conclusively failing verification is excluded and diagnosed; it is never admitted by falling back to a label. Conflicting reference/instance evidence makes the affected set incomplete. A complete empty deployment is zero for every configured region. Complete stale publications are zero, including after 24 hours; no deletion or terminal EC2 conclusion follows. |
| + |
| +### Eligibility (I2, I4, I6) |
| + |
| +For each configured region, use one complete observation. A counted box needs matching verified AWS identity, exact placement, configured data bucket/region, expected nonempty secrets fingerprint, region-ha-1 capability, hibernation configuration, fresh status and edges, and explicit valid admission fields. Require box_role=serve, admitted=true, drained=false, and no legacy draining flag. Apply boxchoice.Placeable with its existing thresholds after forming candidates; do not pass serve as an old roster role (ExcludeRoles expects the empty default). Reject negative/inconsistent totals before the arithmetic. Apps is not required. |
| + |
| +First exclude a positively stale, validly joined report; it need not satisfy current admission-field coverage to count zero. Treat explicit booting/drain/platform/not-admitted/drained and well-formed insufficient or absent totals as known exclusions. Missing admission additions, malformed booleans/numbers, unknown roles and future timestamps beyond one minute are unknown evidence. Status uses BoxStale's 15-minute bar plus rejection of zero/far-future times. Edges use HeadroomFresh. The one-minute cache age is separate from both 15-minute producer bounds. |
| + |
| +Regional EligibleBoxes is the unique union of these boxes, independent of pool. Shared-pool creates additionally require explicit serves_shared_pool=true and accepts_inbound=true. A named-pool create needs evidence that the box serves that pool; `serves_shared_pool=false` supplies no such evidence. Main has no pool-list producer. Pending Q1, its provisional result is evidence unavailable, without a no-capacity page or regional zero. Never derive pool membership from an existing host list or broaden the pool. |
| + |
| +These are last-published eligibility observations. P3a's admitted latch does not mean all six health conditions still hold now; the console cannot see a later local known=false. Neither the metric nor an admitted create promises full health. Q2 and P2b-2 own that missing diagnostic evidence. This is not permission to ignore a published restriction. |
| + |
| +### Create boundary (I5, I8) |
| + |
| +Proposed helper `requireHACreateCapacity` takes the normalized region/pool and reads the observation only. It returns allow, complete-zero, or unknown. Complete-zero uses noRoom, approved copy and Retry-After 60. Unknown returns 503 with C04 and Retry-After 60, sends no capacity page and does not publish a zero. A positive count permits main's subsequent checks; it never picks or stamps a box. Retain the existing hourly successful-send throttle and its send-failure release semantics. |
| + |
| +| Door | Required ordering and regression witnesses | |
| +|---|---| |
| +| Instance, plain and --from | Keep auth, duplicate response, input/shape, F5 and other permanent rails before capacity. Run capacity before createFrom/createImport dispatch or any binding/store/lifetime writer. For active HA regions, defer the old armed-region 400 until the HA check can answer 503. Imported creates keep their existing HA refusal; capacity cannot make an import legal. Cover home `""` and explicit home normalization, static, address, resident rootfs and binary shapes. | |
| +| Standalone sidecar | Check the same effective region and manifest Pool before beginClaimCreate/createSidecarMarked. Keep duplicate/paused/shape responses and HA stamping unchanged. Q1 explicitly governs the newly unavailable named-pool case; do not hide it as a sidecar implementation detail. | |
| +| First-domain route | Run before the branch at domainattach.go:227, covering claims, lifetimes and plain paths, and before pending proof/claim writes. The prospective static record is home/shared. Existing-route aliases, reattachments that write no first route, wildcard/catch-all aliases and ordinary domain verification do not acquire a new capacity requirement. Both browser and API responses carry Retry-After. | |
| +| Non-create work | No new helper in wake, enable of an existing record, restart, deploy, retry, timer/run pickup, domain alias attach, move cleanup or import cleanup. Preserve their existing gates. | |
| + |
| +Do not leave the early claims-based roomIn as an alternative HA policy. Route active-HA create callers to the new helper and retain any still-supported claims-only behavior outside this path. Record-read memoization may avoid duplicate GETs, but never delay capacity until the claimed executor or lifetime has already been created. |
| + |
| +## Executable tasks for P2b-1 |
| + |
| +These task commits stay on one implementation branch until the visible slice is complete. Each test name below is proposed unless identified as existing. Production-wired means real parsers, stores, middleware and handler/runner entry points with a local counted transport; no live AWS mutation is necessary. |
| + |
| +### Task T1: Build the bounded observation [own review: cache and security boundary] |
| + |
| +**Files:** new `internal/console/{hacapacity.go,hacapacity_observe.go,hacapacity_test.go,hacapacity_observe_test.go}`; `internal/console/server.go`; `cmd/console/{main.go,main_test.go}`. Existing `hotreads.go`, `reqmemo.go`, `boxselect.go` are reference seams, not permission to change other readers' semantics. |
| + |
| +- [ ] **Step 1:** Add failing `TestHACapacityConfiguredUniverse`, `TestHACapacityIdentityAndScope`, `TestHACapacityUnknownIsNotZero`, `TestHACapacityBudget`. Use actual serialized P3a edges bytes and signed identity fixture keys. Include omitted/empty/null placement, missing versus stale status, stale reports older than 24h, absent region, duplicate iid/ref, copied identity, wrong account/region/bucket/fingerprint, unknown versions and exact age/headroom boundaries. |
| +- [ ] **Step 2:** Implement the strict console configuration and bounded observation described above. Require PageLister; unsupported stores give unknown. Reuse the status parser with the capacity-specific bounded listing. Do not change box publication or add a roster reader. Test 200/201 keys and oversize bodies at the low-level release.Store transport. |
| +- [ ] **Step 3:** Exercise the real runner with a controllable clock: concurrent reads use one generation, timeout/error replaces success, canceled readers cannot poison others, expiry blocks requests, shutdown ends the runner, and a second start does not create another loop. Count the initial pass separately from 60 steady-state passes/hour. Through an actual failing S3 transport, prove the dedicated observer client makes one wire attempt, with no hidden SDK retries. |
| +- [ ] **Step 4:** Run `nice -n 19 go test ./internal/console ./cmd/console -run 'TestHACapacity' -count=1`. Commit `ha: observe verified regional capacity without claims` after the risk-sized review. No standalone merge. |
| + |
| +### Task T2: Wire the metric to console start [whole-branch review] |
| + |
| +**Files:** `internal/console/{regioncapacity.go,regioncapacity_test.go,awsregionmetric.go,hostclaimops.go}`; `cmd/console/main.go`; T1's observer. |
| + |
| +- [ ] **Step 1:** Add `TestHACapacityStartsWithoutClaims` through the real serve/start seam with HostClaim=false, RegionHA=false, HARegions populated and CARLOS_REGION_METRICS=cloudwatch. Assert one loop; moving the existing nested start is part of the test. With metrics unset, admission observation still runs; with no HA configuration and no metric request, it does not. |
| +- [ ] **Step 2:** Rewrite publishCapacity/regionCapacities around the configured universe and I4 projection, removing their dependency on ExecutorChooser. Preserve Carlos/Region, EligibleBoxes, Count, Region=canonical code, timestamp and one call per region to that configured AWS region. All-zero and partial-region results are explicit cases. Wrong file-controlled AWS region must never redirect a request. |
| +- [ ] **Step 3:** Use the actual CloudWatch adapter against a loopback HTTP transport. Assert request bodies and destination-region client selection, including one failed region beside a successful one. Keep failure/recovery logging bounded; count no GetMetricData, EC2, SQS or ELB calls. A failed PutMetricData makes one wire attempt and waits until the next tick. |
| +- [ ] **Step 4:** Run `nice -n 19 go test ./internal/console ./cmd/console -run 'TestHACapacity|TestRegionCap|TestCapacity' -count=1`. Commit `ha: publish regional capacity from console start`. |
| + |
| +### Task T3: Refuse creates before side effects [own review: security and production storage] |
| + |
| +**Files:** `internal/console/{nocapacity.go,nocapacity_test.go,apiinstances.go,apisidecars.go,domainattach.go}`; new `internal/console/hacreatecapacity_test.go`; relevant existing create, domain, sidecar and writer-census tests. |
| + |
| +- [ ] **Step 1:** Add `TestHACreateCapacityDoors` through registered authenticated HTTP handlers, including browser first-domain attach. Run shared-pool allow/zero/unknown for every door and each lifetime/claims setting that the door supports. Verify status/body/header, not just a helper error. Named pools exercise the approved Q1 choice; until then they remain an explicit failing acceptance gate. |
| +- [ ] **Step 2:** Place the single helper at the pre-write boundaries above. Where existing early roomIn/placement checks precede final input checks, split read-only validation from the mutation phase rather than adding a second predicate. Preserve duplicate, F1/F5 and import refusals, and successful non-HA behavior. Do not stamp sidecars HA. |
| +- [ ] **Step 3:** Count all protected stores and local writes: environment bundles/bindings, private-storage adapter calls, history/lifetime slots, records, claims, serial, change index and success audit. Zero/unknown must leave all untouched. Use real local registry/DirStore state plus the existing private-storage transport seam; a test that only asserts no CreateRecord call is insufficient. Include --from, private storage, pending DNS proof and first-domain lifetime paths. |
| +- [ ] **Step 4:** Add `TestHACreateCapacitySharesObservation` for simultaneous instance/sidecar/domain requests and a metric pass. They consume the same observation and add zero S3 reads. Add `TestHACreateCapacityPageThrottle` covering concurrent zeros, send failure and process restart. Add `TestHACapacityDoesNotGateExistingWake` through the existing edge/activator production fixture with no capacity, preserving its normal HA acquire path. |
| +- [ ] **Step 5:** Run `nice -n 19 go test ./internal/console -run 'TestHACreateCapacity|TestHACapacity|TestNoCapacity|TestHAP2|TestHACreate|TestHAImport' -count=1` and the package containing the existing-wake witness. Check the relevant console record-write inventories. Commit `ha: gate new creates on shared capacity evidence`. |
| + |
| +### Task T4: Deliver the visible slice and close its gate [whole-branch review; scoped live card] |
| + |
| +**Files:** test additions above; execution-time docs in `docs/site/cli.md` and `docs/region-ha-runbook.md`; any census artifacts required by the actual diff. This drafting commission writes none of those files. |
| + |
| +- [ ] **Step 1:** Approve the executable copy rows below before product/docs writes. Document 503/Retry-After, incomplete evidence versus known zero, Q1's chosen named-pool behavior, retained F5 and the create-only boundary. Do not claim readiness or completed drain. |
| +- [ ] **Step 2:** Prepare the dev card below, including exact proposed capacity config and Q3's release window. Verify signatures, fixed pins, home bucket/region/fingerprint and all opt-in publications using read-only evidence. A missing prerequisite blocks the roll, not a new producer designed on an unmerged branch. |
| +- [ ] **Step 3:** Complete local production-wired checks and mutation witnesses: deleting the shared helper call from each door, treating unknown as zero, accepting missing admission fields and restoring the nested HostClaim start must each fail a witness. Run the whole-branch review within the budget and census checks on its final diff. No repetitive review of low-risk tasks. |
| +- [ ] **Step 4:** In implementation only, run the repo build/vet/test/format gate once, plus required cross-compiles. Push and describe on amadan, verify green CI on the exact tip, squash-merge with -expect, then read main CI. The scheduled dev release and card make the create result visible; archive measured counters and cleanup evidence. This planning session does none of those actions. |
| + |
| +## P2b-2: role and readiness outline (I6, I8) |
| + |
| +Use a distinct proposed versioned API for the new object writer and read-back. The exact new routes belong to the executable P2b-2 design. Keep the old roster endpoints unavailable in claims-off HA mode: a released CLI would otherwise accept a save and falsely print that the role is applied. New CLI code must not fall back to the roster writer on 404. The command becomes `carlos system box role <ref|@region-code> <serve|drain|platform>`. Add API-backed read-back and `carlos system region readiness <region>` in this slice; these read commands/endpoints are proposed, not available on the citation base. Keep `publish-record` dispatch intact. Remove misleading group/default/legacy guidance in `system.go`, `system_roles.go` and `docs/site/cli.md`; reject obsolete syntax with R12, never translate legacy to drain silently. Keep old claim-only routes from writing the new object by accident. |
| + |
| +The write has these requirements: |
| + |
| +- Authenticate a person through apiSystemRoller (`internal/console/apisystemupdate.go:144`) before target reads; service credentials remain excluded. Browser additions, if any, retain session → CSRF → owner → fresh-auth order. No new browser writer is required. |
| +- Validate with boxroles.Key/Decode. Target an exact independently verified ref or a configured @region-code. No display-label lookup, enrolment, group scan, wildcard or caller-supplied S3 key. A default can be set for a configured region with no live box, so replacements inherit it. An exact-ref write requires usable identity evidence; distinguish unknown evidence from an unknown target. |
| +- Read the exact desired object and its ETag, then one conditional PUT of `{role,by,at}`. The server supplies by/at. If the role is unchanged, preserve the prior record and write nothing. A CAS conflict returns 409 with no overwrite/retry. Use the existing scope bump, already recognized by release.ChangeScope; do not double-bump. A successful object save remains saved if the automatic index bump later logs failure. Do not tell the user nothing changed in that case. |
| +- Read-back distinguishes saved desired state, own/default/implicit source, last reported effective role, admitted/drained values, publication time/age, observation age, and missing blockers. A 200 save is not “now applied”; reuse of the old `boxRoleLine` would lie. Handle the role-save response lost in transit by exact-object read-back before any repeat mutation. Local observation invalidation may mark pending immediately but must not trigger another full observation inside the minute. |
| +- Extend the one observation with B own-role GETs plus R default GETs, deduplicated. Decode both even when an override exists: main's boxroles.Read fails closed if either read/record fails. A fresh override serve legitimately wins over a drain default. Equality between desired and published role is only observed agreement; no exact role-write receipt exists, and clock comparison cannot create one. |
| + |
| +Readiness reports the region's eligibility and per-box evidence source/timestamps, desired/effective roles, and independent unavailable blockers. Empty, stale or missing evidence is never ready. With this main it must explicitly report unavailable for current startup facts, current six-condition health, role-reader knowledge and completed drain. Do not reconstruct these from an aggregate CloudWatch Admitted datum, the presence of route names, an empty host map, a nil blocker slice, or a saved role. |
| + |
| +**Producer gate:** main's local facts are EnvLoaded, Reconciled, RolePublished and TerminationStarted. Full readiness also needs current hosting, forwarding map/key, certs, edge and activator heartbeat, refresh evidence, plus drained completion/duty-transfer truth. P3a provides no remote report for these. Drain currently restricts starts; it does not implement §13's graceful sleep/scan completion. P3b's launch completion, Standby, booting-name protection and group health are later dependencies, not fields to add here. Q2 can authorize an explicitly incomplete diagnostic door now; otherwise wait for a separate box-side publication/drain slice to merge. It must ride existing status/edges cadence, with no new box poll, before executable P2b-2 tasks are written. |
| + |
| +Own reviews apply to the operator writer, security/identity changes, any cache extension and root CLI changes. Production-wired witnesses must drive the actual P3a role reader from the console-written DirStore object, publish its actual edges body, and read it back through the new door. Include default/override precedence, malformed default despite override, write conflict, saved-but-unobserved, old CLI/new server and new CLI/old server, and all unauthorized principals. No fixture may invent drained=true as proof that P3a drains. |
| + |
| +## P2b-3: HA display design entry brief (I7) |
| + |
| +This slice remains outline-only. It changes observed presentation, not runtime authority. Scope by immutable rec.HA even when HARegions is later unset. Determine actual activator ownership first: address-backed HA records and pre-existing non-hibernating sockets may have no rollout report and must retain their applicable metrics/health paths. A fresh timestamp after CreatedAt is the existing lifetime fence, not a published incarnation ID: `internal/status/snapshot.go:370` has no such ID. A stronger proof needs a separately merged producer, not an invented field. |
| + |
| +### Consumer inventory at 016599d5 |
| + |
| +| Consumer | Existing anchors and obligation | |
| +|---|---| |
| +| Shared joins / report cache | `internal/console/apiinstances.go:938`, `:978`, `:1133`; `internal/console/remoteinstances.go:162`, `:259`, `:337`. Replace last-read/newest-report selection for applicable HA hosts with one projection. Keep record/tenant fences and completeness; one platform status load per observation, not per host/tab. | |
| +| List API, counts, filters, pagination | `internal/console/apiinstances.go:394`, `:563`, `:1309`, `:1326`, `:1369`. Compute health, count and filter from the same projection as the returned row. rollout_incomplete applies to unknown/conflicting HA rows even in an all-HA list. | |
| +| Single GET / placement | `internal/console/apiinstances.go:1385`, `:1425`; `internal/console/instancesplacement.go:48`. Single GET currently has served_by only, not the list's health/rollout. Add only explicit agreed observation fields; do not mistake every adopter for the awake box or silently expand to a full list row. | |
| +| Local and remote app detail/list | `internal/console/instancepage.go:298`, `:302`; `internal/console/remoteinstances.go:417`, `:581`; `internal/console/overview.go:123`, `:303`, `:359`; `internal/console/templates/app_instance.html:19`. Local platform rows cannot override a remote awake reporter. Preserve Setting up for complete evidence with no adoption, and Unknown when evidence is incomplete. | |
| +| Hold, Failed, retry presentation | `internal/console/instancepage.go:43`, `:52`, `:81`, `:115`. A held/down host may be asleep. Keep hold text, Failed health and recovery independently of awake selection. | |
| +| Retry grant | `internal/console/apiretry.go:82`, `:110`, `:167`. Select fresh tenant/lifetime-checked HeldBy/book/epoch evidence, not the uniquely awake box. Ambiguity/incompleteness produces zero grant and serial writes. This task needs its own security review. | |
| +| Other per-host fields | `internal/console/apiinstances.go:180`, `:205`, `:231`, `:241`, `:248`, `:263`, `:715`, `:857`, `:883`. The later design must assign a source/clear/aggregate rule for staged_version, upstreams, db_bytes, update_report, config_refusal and egress, plus detail Updates, Installed, Serving and worker states. Do not carry fields from another box beside the chosen rollout. | |
| +| CLI decoder and table | `apimode.go:3463`, `:3512`; `instances_cli.go:573`, `:583`, `:596`, `:696`. State whether each addition reaches table or JSON. Main has no instances list --json flag; adding it needs help/docs/decoder/truncation/omission tests, not an assumed existing switch. | |
| +| Deploy watch, first decision | `deploywatch.go:96`, `:172`, `:201`, `:278`, `:303`, `:422`. A complete list with nil rollout can satisfy legacyOnly and URL-poll sleeping hosts. A new CLI-only fix is insufficient. | |
| +| Deploy watch, later decisions/grouping | `deploywatch.go:477`, `:525`. Unknown/all-asleep/mixed/held transitions must never change an HA host into modeURL. Empty awake-box attribution must not break grouping, Installed or SchedulerIdle decisions. | |
| +| Released clients | v0.34.0's watchInstanceList/legacyOnly/apply/groupByBox and apiRollout retain these same fallback rules. Preserve a wire answer those clients can safely interpret; verify supported older releases too before switch-on. Older servers may omit new fields. No unsupported capability may decode as healthy/asleep by zero value. | |
| + |
| +The separate design must settle these requirements together: |
| + |
| +1. One valid awake reporter may win over sleeping adopters only with complete applicable evidence. Multiple awake/transient reporters, wrong tenant/lifetime, unread reports or unsupported coverage are unknown. Neither sorting labels nor taking the latest timestamp resolves a conflict. |
| +2. An all-asleep answer claims no awake box. Define agreement on Installed, scheduler-idle and hold state before a rollout is considered final. A nil rollout on a complete HA list is unsafe for old deploy watches. Supply a compatible safe server projection or block the slice; never fix only the new CLI. Assert zero URL requests, including fallback from a later refresh. |
| +3. Keep status generation, normal 5m cadence, 15m freshness and console-cache age distinct. No report is not asleep. Freshness checks use both future bounds and valid generation semantics. |
| +4. Stale dead-holder keys can remain inside the 24h listing horizon. The later design must prove a shorter exclusion bound from merged lease-loss/stop behavior and clock witnesses, or obtain Q4's explicit acceptance of the loss in display availability. This draft claims neither a stop bound nor a free 24h blackout. |
| +5. Source every ancillary field consistently; all-HA versus mixed lists must not change the result or trigger a hidden second loader. Existing unrelated non-HA rows retain main behavior. Cover health on both console-local and remote routes. |
| + |
| +Use the real `TestInstalledAndServingCells`, `TestRolloutReason`, `TestRolloutWireShape` in `instances_rollout_test.go:15`, `:36`, `:77`, plus the actual deploywatch tests, notably `TestWatchRolloutDarkBoxNeverPollsOverHTTP`, `TestWatchRolloutMixedFleetPollsOnlyTheUnreported`, `TestWatchRolloutWithNoReportsIsTheOldWatch`, and `TestWatchRolloutIncompleteJoinIsNotNoReports`. Add an HTTP integration witness feeding real console list JSON to the released/current decoders and watches with a counted URL transport. A permutation test over report order and local/remote placement must yield identical HA answers. Removing rollout_incomplete or returning nil for known sleep must make the zero-poll witness fail. |
| + |
| +P2b-3 adds no independent polling loop. Its later design must connect page/list/detail/single-GET/retry reads to a shared source generation and count fleet-specific reads separately. It must carry a complete copy/field decision table and the inherited review history before execution. |
| + |
| +## Request and cost budget (I3) |
| + |
| +G/P/L/D mean S3 GET/PUT/LIST/DELETE API attempts. Spec §18 pins G at **$0.0004/1,000**, P/L at **$0.005/1,000**, D free. All numbers below are incremental capacity/role/display work, not the unchanged reads and writes of a successful create. Failed requests count. Configure the new console observation store and CloudWatch client for one SDK attempt per operation: their retry is the next minute. The later role writer must use the same one-attempt policy for its object and index calls; the index's bounded application-level CAS attempts remain counted below. Keep this client policy local to the new paths, without changing other console or box clients. For these new paths logical counts therefore equal wire-attempt bounds. Existing box fan-out rows are application-call counts; record their deployed SDK multiplier separately in the card. No operation is called free because it fails. |
| + |
| +Let E be accepted edges keys, H accepted status keys including old ones, B distinct identity refs needing verification (B<=E), R configured HA regions and C console processes. The new capacity listing uses one bounded request per prefix, including empty prefixes. A 201st key yields incomplete immediately for that prefix, without a next page or success claim. For the accepted <=200-key universe there is no hidden pagination. If a later design raises that bound, price every page and the terminal empty page required by start-after listing. Existing unbounded main readers are not relabeled as this budget. |
| + |
| +| Path/event | Incremental logical requests and effect | |
| +|---|---| |
| +| P2b-1 accepted observation, once/minute/console | **2L + (E+H+B)G; 0P/0D.** One GET per accepted body and verified ref; no desired-role GET in P2b-1. Empty prefixes still cost 2L and return zero for configured regions. | |
| +| Unreadable/capped observation | At most that bound for started calls; a failed first LIST costs its attempt. No request-time retry. Omit affected metric points, refuse creates, no page. At most one subsequent scheduled attempt per minute. | |
| +| Metric tick | **0 additional S3; up to R PutMetricData calls**, one datum/region at standard resolution. Incomplete regions omitted. No GetMetricData, EC2 Describe, SQS, ELB, ASG or SSM calls. | |
| +| Each create admission / retrying a refused create | **0G/0P/0L/0D, 0 AWS control calls** from capacity. Auth, validation and existing prefix proof remain separately charged. Refusal writes no protected state; complete zero may send the existing throttled operator alert. No additional alert from an unknown observation or metric alone. | |
| +| P2b-2 observation extension | **+(B+R)G** for own/default desired objects, including known absence; 0P/L/D. Deduplicate defaults, not their error semantics. Read-back/diagnostic requests use this observation for effective state. | |
| +| Role exact-object read-back | **1G** for desired object/ETag when requested live; effective evidence from observation, **0 extra status loads**. Unknown target may also need one identity GET if no usable verified observation exists; do not reload the fleet. Region-default target verification is configuration-only. | |
| +| Role no-op | **1G**, plus at most that one target identity GET. No role PUT, audit of change or index bump. | |
| +| Role changed, successful conditional write | Precondition **1G**, role **1P**, index **kG+kP**, k<=4 total attempts (`internal/release/changeindex.go:31`, `:129`). Add optional explicit read-back **1G** and cold target verification **1G**. Normal warm save 2G+2P; fully counted maximum with both extras **7G+5P**. | |
| +| Role CAS conflict / write uncertainty | One attempted role P plus its precondition G; conflict does not bump. Return conflict, no automatic rewrite. An uncertain response can require **1G** exact read-back; a retry is a new explicit event. Already-saved/index-failed is not rolled back or reported unchanged. | |
| +| Box reader fan-out of a role change | Existing scope watch: **2G per opted-in box per observed change**, even own-role override/default absence or first-read failure. Startup also 2G; retry backoff 5s, doubling to 60s, then 2G/minute on sustained failure (`internal/host/boxroles.go:91`). Existing watch/backstop reads are not new P2b polls. | |
| +| Effective role edges mutation | Existing replacing write/index (`internal/host/snapshot_loop.go:221`): normal **2G+2P**, upper successful bound **7G+7P** (up to 3 object CAS attempts plus up to 4 index attempts); failures/retries charged again. No forced publication merely because an operator reads a row. | |
| +| Each resulting edges reader fold | For N deployment edges keys, per affected reader **ceil(N/1000)L+N G**, at least 1L for empty prefix. Coalesced existing bound **120 folds/hour/box**; multiply by all readers. Role reads cost no all-role LIST. | |
| +| P2b-3 display | No execution budget approved yet. Required envelope: **0 added S3 on a warm shared observation**, one **ceil(H/1000)L+H G** status load on a cold shared refresh if it cannot reuse P2b-1; at least 1L when empty. It must become one shared refresh, not one per row/tab or a second per-minute loop. Existing fleet-prefix lists/GETs and record reads remain charged separately. No lock, EC2 or HTTP-health/host-URL probes. | |
| + |
| +For a 30-day month, steady-state passes are **43,200 per console**, plus one initial pass at startup and one after each restart. P2b-1 S3 cost is: |
| + |
| +`C * 43,200 * (2 * $0.000005 + (E+H+B) * $0.0000004)`. |
| + |
| +For a two-box, one-region console with E=H=B=2: **86,400 L + 259,200 G = $0.53568/month/console**. A three-box deployment is **$0.58752/month/console**. The fixed cost of the two deployment-wide lists is **$0.432/month/console**; the variable portion for region r is **$0.01728*(E_r+H_r+B_r)/month/console**. Do not charge the shared LIST twice when attributing costs to regions. P2b-2 adds **$0.01728*(B+R)/month/console**, or **$0.05184** for two boxes/one region. Bounds charge a fresh identity verification every minute, with no speculative cache saving. |
| + |
| +CloudWatch adds **43,200 PutMetricData requests/region/month/console** and one regional EligibleBoxes time series, plus startup/restart sends. The pinned spec supplies no CloudWatch request/custom-metric tariff. Its dollar line is therefore `43,200*C*regional request price + one time-series price/region`, not $0 and not an invented pinned rate. The release card must record the account's actual tariff/free allowance and resulting total before arming. Multiple consoles multiply API requests and S3 cost; the metric's dimensions do not create one new time series per console. No new EC2 Describe cost exists. |
| + |
| +Role event example, four opted-in readers and one changed effective publication: normal console save 2G+2P, readers 8G, publication 2G+2P, one fold on each reader 4L+16G. Total **28G+4P+4L = $0.0000512**, before explicit read-back, retries or coalescing savings. P3a's existing steady-state S3/SQS/clock metric workload remains outside the incremental console cost; there is **no new per-box polling workload**. |
| + |
| +## Copy deck for execution |
| + |
| +Drafts only, as expressly requested. This implementation-plan deck is not product approval. Before strings enter code, CLI help, logs or user docs, the execution controller runs copy review and applies accepted wording verbatim. Every string proposed by this revision is below; later outline details require a refreshed deck before execution. No em dashes in new copy. API blocker codes are stable machine values with these human renderings, never raw nested errors. |
| + |
| +| ID | Where | Draft or exact reuse | |
| +|---|---|---| |
| +| C01 | Create 503 | Exact reuse of noCapacityRefusal: `No box in %s has room right now. Try again in a few minutes.` | |
| +| C02 | Operator capacity page subject | Exact reuse: `No box in %s has room` | |
| +| C03 | Operator capacity page body | Exact reuse of noCapacityAlert at nocapacity.go:42, including its full/stale/role explanation. Do not rewrite it for this slice. | |
| +| C04 | Unknown evidence create 503 | `Capacity in %s could not be checked. Nothing was created. Try again in a minute.` | |
| +| C05 | Capacity configuration error, pre-roll/startup | `HA capacity configuration is invalid for %s. Check the configured region, data bucket and box identities.` | |
| +| C06 | Observer start log | `HA capacity observation started. Checking once a minute.` | |
| +| C07 | Observer failure log | `HA capacity evidence is incomplete for %s. New creates are paused there.` | |
| +| C08 | Observer recovery log | `HA capacity evidence is available again for %s.` | |
| +| C09 | Metric start/failure/recovery logs | Reuse existing regioncapacity.go:122, :134, :137 and awsregionmetric.go:63 wording; no new prose variant. | |
| +| R01 | CLI role usage | `carlos system box role <ref|@region-code> <serve|drain|platform>` | |
| +| R02 | Proposed role read-back usage | `carlos system box role <ref|@region-code>` | |
| +| R03 | Proposed readiness usage | `carlos system region readiness <region>` | |
| +| R04 | Saved desired role, CLI/API | `Saved %s as the desired role for %s. Read readiness to check what the box has reported.` | |
| +| R05 | No-op desired save | `The desired role for %s is already %s.` | |
| +| R06 | Invalid role, 400 | `Role must be serve, drain or platform.` | |
| +| R07 | Invalid target, 400 | `Use an exact box reference or @region- followed by a configured region code.` | |
| +| R08 | Unknown target, 404 after operator gate | `No verified box or configured region matches %s.` | |
| +| R09 | Target/read unavailable, 503 | `The role evidence for %s could not be read. Nothing was changed. Try again.` | |
| +| R10 | Lost role CAS, 409 | `The desired role changed while it was being saved. Nothing was changed by this request. Read it again before retrying.` | |
| +| R11 | Ambiguous role write, 503 | `The role save could not be confirmed. Read the desired role before retrying.` | |
| +| R12 | Obsolete group/default/legacy syntax | `Use system box role with a box reference or @region-code and serve, drain or platform.` | |
| +| R13 | Operator audit and role-save log | `Set the desired role of %s to %s.` | |
| +| R14 | Read-back labels, separate strings | `Box`; `Region`; `Desired role`; `Role source`; `Reported role`; `Admitted`; `Drained`; `Generated at`; `Age`; `Evidence source`; `Blockers`; `Eligible boxes` | |
| +| R15 | Role source values, separate strings | `Box override`; `Region default`; `Implicit serve` | |
| +| R16 | Readiness values, separate strings | `Ready`; `Not ready`; `Unknown`; `Pending`; `Not reported`; `Yes`; `No` | |
| +| R17 | Missing/stale source blockers | `No report is available.`; `The report is too old.`; `The report time is invalid.`; `Some evidence could not be read.` | |
| +| R18 | Identity/configuration blockers | `The box identity could not be verified.`; `The box reports different region or data settings.`; `This report version is not supported.` | |
| +| R19 | Eligibility blockers | `The box is booting.`; `The box is not admitted.`; `The box is draining.`; `The box has the platform role.`; `The box reports that it has drained.`; `The box has too little free memory or disk.` | |
| +| R20 | Missing inputs/pool blockers | `Headroom totals are not available.`; `Shared-pool hosting is not available.`; `Named-pool membership is not reported by this release.`; `Admission is not reported by this release.` | |
| +| R21 | Full readiness limitation | `Current admission checks, health checks and drain completion are not reported by this release. Full readiness cannot be confirmed.` | |
| +| R22 | Desired/effective discrepancy | `The box has not reported the desired role yet.` | |
| +| R23 | Read-back age | `Reported at %s UTC. Observed %s ago.` | |
| +| H01 | HA awake observation, later display | `Awake on %s as of %s UTC.` | |
| +| H02 | Proven asleep observation | `Asleep as of %s UTC.` | |
| +| H03 | Unknown/conflicting observation | `The current box could not be confirmed.`; `Boxes disagree about this instance. Its current state is unknown.` | |
| +| H04 | Retry ambiguous/incomplete refusal | `The failure hold could not be confirmed. No retry was requested. Try again after the reports update.` | |
| +| H05 | Display provenance/empty states | `Last reported`; `Setting up`; `Unknown`. Reuse existing latter labels where possible. | |
| +| D01 | CLI/runbook create explanation | `New creates in an HA region need a box with room. A 503 response asks you to retry after 60 seconds. Missing evidence pauses creates without reporting zero capacity. Existing instances can still wake.` | |
| +| D02 | Role/readiness docs | `A role change saves the desired role. Read it back to see the last reported role and its age. A saved drain request does not prove that instances have stopped or duties have moved.` | |
| +| D03 | Deployment docs | `Roll the boxes and 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.` | |
| +| D04 | Named-pool temporary cut, only if Q1 approves | `This release cannot check capacity for named-pool creates. Those creates return 503 until pool evidence is available. Existing pooled instances keep running.` | |
| +| D05 | Display docs | `The box and state are observations from reports. They can be delayed. A sleeping HA instance is not woken to check a deploy.` | |
| + |
| +HTTP codes/Retry-After and JSON field names are protocol, not extra prose. Preserve existing auth/duplicate/F1/F5 errors verbatim. If execution adds a new error, tooltip, help paragraph, blocker or log, it must enter this deck before writing product copy. Outline-only readiness reasons for unpublished individual facts must not be rendered as if the facts were measured. |
| + |
| +## Census and reviews |
| + |
| +This plan-only Markdown changes no root-census byte. P2b-1's intended production changes are cmd/console and internal/console, outside root scope. Confirm with `make census-card` on the implementation diff; do not assume a new shared helper is exempt. Reuse boxchoice without modifying its runtime policy. Relevant record-write censuses still apply to create/role writers even when the root census is empty. |
| + |
| +P2b-2 CLI dispatch, flags, usage and JSON decoder changes in system.go/system_roles.go are root-binary surface. Any shared boxroles/release/status/edgesfile change is also in scope. P2b-3 changes in apimode.go, instances_cli.go, deploywatch.go and linked shared packages need a card, including every changed unit and whole-file envelope. Docs prose under docs/site is not a root read, but every new command needs its CLI heading and docsite validation; flags and JSON cannot evade census by being called presentation. |
| + |
| +For an in-scope diff: create CLAIMS with tab-separated file:unit and changes/new reads; run census-propose under the actual slice name; run targeted census, scope, rebase and J4 checks; obtain an independent Opus or Fable verdict for this Codex-authored work against amadan main at the exact tip, including every unit/envelope, and record it on #280 in the authorized implementation session. The reviewer decides; do not escalate census classes to Paul. This session dispatches nobody and posts nothing. |
| + |
| +Review T1's cache/identity boundary and T3's pre-write gate separately under stopping rule 3. T2 and docs/local acceptance ride one whole-branch review. Later role authority, retry grants, root changes and new caches get risk-sized review. A final P2 fix still needs census and changed security/root/termination/storage checks inside the same budget. |
| + |
| +## Dev switch-on card and rollback |
| + |
| +Preparation is read-only. A later card names the actual AWS account/region, deployment, console service, sophie/leo identities, binary versions, exact env/config changes, disposable app/hosts, cost ceiling, traffic effect, operator, window and cleanup. #421's prior G1 approval is not approval for these additional settings or a P3a drill. |
| + |
| +1. Confirm P3a is released on every dev box before opt-in, with its own card satisfied: sophie's console route Unit=console.service, chronyc working under the edge sandbox, change-index read mode and root-owned region-config.json, termination queues/Started, and unattended self-update held during the attended window. CARLOS_GROUP_ADMISSION=1 is box-only; CARLOS_REGION_HA and queue/fixed identity configuration retain their existing box scope. The console keeps its box HA variables unset and CARLOS_REGION empty. Do not create a group or infrastructure resource for P2b-1. |
| +2. Preserve current CONSOLE_HA_REGIONS=ie unless the read-only recheck finds otherwise. Validate the exact proposed CONSOLE_HA_CAPACITY_CONFIG and existing SecretsPub/AWSAccount/home data configuration. Set CARLOS_REGION_METRICS=cloudwatch only with its existing Carlos/Region PutMetricData grant verified. Missing rights require a separate scoped card, not hidden IAM work. Preserve CONSOLE_REGION_INGRESS/PLATFORM_EDGE_IPS from the ingress owner; neither changes proxy trust. |
| +3. Resolve Q1's named-pool effect before switching the check on. List affected dev create users and expected refused operations. Positive/zero/incomplete scenarios are local production-wired witnesses first. The live card uses disposable approved names; it does not exhaust host memory, alter storage prefixes, drain a production workload or kill an edge merely to produce a zero. |
| +4. In the attended dev window, show a positive supported create and its cleanup through the CLI/API. For visible refusal, use a separately approved temporary capacity-configuration exclusion or coordinated P3a role window; name which concurrent creates are affected. Show the actual no-capacity response and zero protected writes, then restore and show recovery. Observe CloudWatch's corresponding count and transport counters. Incomplete-evidence fault injection remains local unless explicitly scoped on the card. Wakes continue through the real edge during the window. |
| +5. Record exact previous binary/config/env bytes and restore them on failure. Restoring the previous console binary removes this new gate; it is a deliberate return to the earlier weaker create checks, not proof of capacity. Stop experimental creates before rollback. Existing HA stamps are immutable and must never be cleared. Removing CARLOS_REGION_METRICS stops metric sends only; it is not an admission bypass. Restore Q1-related configuration and any approved desired-role change, then verify read-back/publication rather than assuming applied. Retire only approved throwaways through the API/CLI. Remove owned scratch and stop test processes. |
| + |
| +Role/readiness and display later get separate cards. Full readiness green, graceful drain, ASG hook/Standby and NLB/termination/hairpin drills remain with their merged producers and approved series cards. Do not report P2b-1's create drill as those gates passing. |
| + |
| +## Open questions for Paul |
| + |
| +**Q1. What should happen to named-pool creates while pool membership is not published?** This affects currently allowed standalone sidecar and other non-F5 named-pool creates; it is a new user-visible cut. Options: **(Recommended)** wait for a small box-side pool-evidence publication slice to merge before switching on P2b-1 for a deployment using those creates, then refresh only the dependent admission task against that main; this preserves the capability and adds no polling. Or explicitly accept temporary 503 evidence refusals for named-pool creates, while existing pooled instances keep their wake path. The latter lets the current executable tasks ship without inventing a producer. Do not silently bypass the pool check. F5 for pooled/non-home HA data creates remains the already-approved G3 cut either way. |
| + |
| +**Q2. Should the first role/readiness door be diagnostic-only?** **(Recommended)** ship desired-role save/read-back plus eligibility diagnostics, with full readiness unavailable and drain completion explicitly unreported until a separate runtime publication/drain slice merges. This makes actual P3a behavior visible without claiming §10/§13 completion. Or wait to ship all of P2b-2 until those producers exist. This is a staged capability cut from the full requested readiness door, not a declaration that the spec is complete. A drain request must remain visibly pending; it cannot become permission to stop a box. |
| + |
| +**Q3. Which dev release/window owns switch-on?** **(Recommended)** reserve the first dev-only release after implementation merge, target 2026-11-06, after P3a fixed-pair admission and the selected Q1 prerequisite, with an attended create/metric drill. Or choose a later named date and keep implementation on its branch until that slot exists. The current dev HA settings remain as recorded; no live changes are authorized by this draft. |
| + |
| +**Q4. What display availability limit is acceptable if old reporter conflicts cannot yet be bounded?** **(Recommended)** require the separate display design to establish a shorter bound using a cited merged stop guarantee or a separately merged evidence producer before switch-on. Or explicitly accept an unknown awake-box display for up to the 24-hour status horizon after failover, with H03 copy, while runtime recovery proceeds normally. The second option cuts visible availability and must not be chosen silently. Neither option permits URL polling to settle uncertainty. |
| + |
| +**Q5. What review scope is authorized for the separate display design?** **(Recommended)** authorize one explicitly scoped review of the new merged-input design, carrying P2's two C1 P1 rounds, the closed third P2a round and N-HA13; stop at no P1 and bring any repeated-family blocker back without another fix. Or keep display as this outline until Paul schedules it. Renaming to P2b-3 is not authorization for a fourth P2 round. |
| + |
| +## Round history and stopping rules |
| + |
| +**rev 1, no review yet; the display slice carries P2's two C1 rounds and N-HA13.** |
| + |
| +| Inherited review | History and disposition | |
| +|---|---| |
| +| P2 R1, Opus, 2026-11-01 | NOT READY, 1 P1/9 P2/11 P3. P1-1: honest display/shared observation C1. Requirements carried above. | |
| +| P2 R2, Opus, 2026-11-01 | NOT READY, 1 P1/7 P2/6 P3. P1-A repeats C1 through sleeping-host URL fallback. N-HA13 cuts display; no third family fix. | |
| +| P2 R3, Opus, 2026-11-01 | READY AFTER FIXES, 0 P1/1 P2/7 P3. P2a rev 4 applies fixes; review CLOSED, 3 of 3 used. No automatic fourth round for an outline split. | |
| +| P3a T2 namespace withdrawal | F1/F2, N1, then R2-1/R2-2. Final controller CUT under Paul's delegation. Closed; no P2b repair of that family. | |
| +| This drafting commission | No independent review, producer change, test suite or deployment claimed. Author source/budget checks are not a review round. | |
| + |
| +Future briefs use `docs/superpowers/reviews/REVIEW-BRIEF-TEMPLATE.md` and carry this history. The controller must scope capacity/role review as the newly executable merged-input slice, not reopen P2a. Stop at the first no-P1 round, apply P2s without reopening, list P3s as follow-ups. A fourth round needs Paul's scoped go. Two consecutive findings against one invariant stop fixes and require his refuse/cut/central-enforcement choice. Q5 gates display review. |
| + |
| +One implementation session owns one slice and ends at its merge. At three days or three compactions, hand off and stop. At 24h without a merge, or a stopping-rule trigger, report the blocker, last two rounds and recommended cut to Paul and on the authorized branch discussion; repeat every further 24h. Splitting this document does not reset the clock or rounds. This plan's requested local drafting work ends at its commit; no branch post or HANDOFF.md is written. |
| + |
| +Draft verification: re-read cited merged code, check no proposed interface is claimed to exist, verify budget arithmetic and all required sections, run `git diff --check`, stage only this plan, and use the requested author and a subject shorter than 80 characters. Runtime tests and live acceptance remain unchecked implementation tasks. |