plans: P1b-3b plan rev 3 (N-HA16, N-HA17)
Apply Paul's durable termination-proof and per-departure completion rulings. Remove consumer coverage/rearm gates; bound startup and rescan work. Record R2 dispositions and the one remaining final round 3.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+119
−67
docs/superpowers/plans/2026-11-03-region-ha-p1b3b-duties.md+119 −67
diff --git a/docs/superpowers/plans/2026-11-03-region-ha-p1b3b-duties.md b/docs/superpowers/plans/2026-11-03-region-ha-p1b3b-duties.md| index 6a34abb79..46df1cfc6 100644 |
| --- a/docs/superpowers/plans/2026-11-03-region-ha-p1b3b-duties.md |
| +++ b/docs/superpowers/plans/2026-11-03-region-ha-p1b3b-duties.md |
| @@ -1,4 +1,4 @@ |
| -# Region HA P1b-3b: local duties and departure recovery Implementation Plan — rev 2 |
| +# Region HA P1b-3b: local duties and departure recovery Implementation Plan — rev 3 |
| > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. This commission is planning only: no production code, reviewer dispatch, push, release or live drill. Preserve the execution method chosen by the controller. |
| @@ -12,7 +12,9 @@ |
| **Base:** worktree implementation base **9a064ebeba6fb07ecce97fdf276f8caa00d90c8a**, unchanged. Read-only main check: home-placement fix **c6304f2d**, also present at observed `origin/main` **c42baa2edaa84d4295bc14e5664ff632e2024b43**. Citations use the worktree except `internal/edge/{homemap,wakeplacement}.go`, read with `git show origin/main:<path>`; those lines are identical at c6304f2d. No rebase. New files have no invented line numbers. P1a, P1b-1, P1b-2, dead-holder backoff, P1b-3a, P2a and durability 3a are already merged. Read current code rather than the old plans' line numbers. |
| -**Status:** rev 2 answers Opus round 1 (NOT READY); this is an author revision, not a new review verdict. T has executable scope refusals; S remains separately gated. The P3 document was read with `git show origin/region-ha-p3-group:docs/superpowers/plans/2026-11-01-region-ha-p3-group.md`; its :27 and integration row “Termination-start latch / I3,A1” describe a downstream need, not authority to implement unmerged P3 code. |
| +**Status:** rev 3; R2 NOT READY, stopping rule 2, Paul ruled N-HA16/N-HA17; one final round 3. |
| + |
| +This is an author revision, not a review verdict. The P3 document was read from `origin/region-ha-p3-group`; its lifecycle dependency does not authorize implementing unmerged P3 code. |
| ## Rulings |
| @@ -20,11 +22,14 @@ |
| - **N-HA11:** each enabled box uses one small consumer on its existing EC2 termination queue, 20-second long polls, about 180 receives/hour/box. No new S3 poll. View age is the lost-event fallback. SQS is work distribution when boxes share a queue; receiving a message creates responsibility, not an invitation to discard it because HRW chose another box. |
| - **N-HA12:** retain the merged 10-second placement-suspect rule and its caller-cancellation correction. Duty suppression is separate from visitor placement; neither changes lease authority. |
| - **N-HA14:** group boxes roll only through an operator-owned ASG Standby transaction, one at a time. This plan creates no ASG, automatic replacement, drain producer or restart policy. |
| +- **N-HA15 (Paul, 2026-11-03):** P1b-3a's dead-holder backoff does one bounded lock re-read after an unreachable cached holder. Preserve it; departure duties add no visitor probe loop. |
| +- **N-HA16 (Paul, 2026-11-03):** store Describe-proven termination once per departure, bound to account, region, iid and box lifetime. Only normal HA acquire consumes it, after N-HA9 expiry; it grants no scan, import, completion, deletion, duty-start or admission authority. The object contract below replaces the ageing-evidence dependency. |
| +- **N-HA17 (Paul, 2026-11-03):** Started/cancelled are consumer lifecycle facts, independent of coverage. Completion requires a full lock rescan with no dead owner or released-marker releaser. Unsupported hosts keep that departure open and page at a bounded rate; other departures and tenants continue. |
| - **I3 / §7.4:** scan and import is the transfer mechanism. No duty objects, roster, enrollment, claim fence record, published awake set or invented drained flag. |
| - **N-HA7:** HA classification is a durable host fact. Switching off placement must not route an HA duty through legacy acquire. P1a's explicit legacy-sidecar classification stays until the separate birth-only extension below is approved and implemented. |
| - **H7:** duplicate ticks during adoption are allowed; losing a durable once-timer, repeatedly probing a live holder, or overwriting a newer registration is not. |
| -These decisions come from the merged spec/parent plan and the #421 record consulted for rev 1. Rev 2 re-read the local spec rev 6.1, parent plan and code. The home-placement correction is merged at c6304f2d; the drill must use a binary containing it. No review against its former branch is needed. |
| +Earlier decisions come from the merged spec/parent plan and the #421 record consulted for rev 1. N-HA15/N-HA16/N-HA17 come from Paul's explicit 2026-11-03 instruction for this revision and supersede conflicting rev 2 decisions. The local spec rev 6.1 and parent remain the background authority. The home-placement correction is merged at c6304f2d; the drill must use a binary containing it. No review against its former branch is needed. |
| ## Scope and slices |
| @@ -32,11 +37,11 @@ These decisions come from the merged spec/parent plan and the #421 record consul |
| **S — native-sidecar coverage and full Task 5B acceptance.** Task B6 adds birth-only HA support for native sidecars, then reuses T's gate/importer; Task 5B drills the combined result. This is separate because main deliberately classifies every sidecar as legacy (`internal/activator/hawake.go:74`), `SidecarRecord` has no HA bit (`internal/provision/sidecar.go:71`), and its legacy release cannot supply an HA releaser marker. Merely including sidecar rows in a scan cannot recover an asleep sidecar whose lock was deleted. Changing that behavior touches record creation, classification, lease/restore, secrets and workers. Do not hide it behind a fixture setting `Route.HA=true`. |
| -**T scope gate (P2-1/P2-4, I3):** `Controller.CheckCoverage(snapshot, localPolicy)` runs before Start can poll and on every new inventory generation. Refuse T if **any extant native-sidecar record in the receiver's exact placement scope** exists, regardless of pool, awake state or apparent lock absence. This deliberately rejects more than hibernating sidecars: legacy release erases the evidence needed to identify their departing releaser. Also refuse if any regional born-HA record is outside the receiver's normal reconcile eligibility (pool, placement restrictions or supported shape). The gate uses the complete pre-filter record inventory and the actual local `ReconcileConfig` policy, not edges Hosts. Incomplete inventory waits without polling. A refused receiver does not consume or ack its own queue and reports C7/C8 once per refusal generation; it cannot advertise a healthy consumer. |
| +**Per-departure coverage (N-HA17):** inventory includes all records before pool filtering. Each receiver imports only supported hosts it normally serves. A matching lock on a host outside that policy stays pending; do not widen tenancy. An unidentifiable legacy native sidecar in the departure's exact placement scope also prevents that departure's completion, even without a lock, because legacy release erased its releaser. Report the unresolved record; do not guess that absence proves recovery. A supported foreign-pool host with a valid lock naming someone else does not block completion. |
| -This chooses **full-scope receivers only**, rather than partial completion attributed to another box. On a shared-only B and shared+hapair C, with records in both pools, B refuses before receiving; C alone imports all matches, deletes evidence and acks its own queue. B's retained queue is an explicit operator/configuration issue, not an hourly scan/page loop or a claim that C acked B's queue. Fixed queues broadcast separately; a shared queue is polled only by admitted receivers. P3a's activation card must exclude/refuse B until it can cover the scope. No blanket G2 claim for heterogeneous pools. |
| +A receiver completes only after the bounded final rescan below finds zero locks naming the dead box as owner or released-marker releaser, and no unresolved record/read/legacy ambiguity. A peer may have finalized some hosts; its lock must pass the successor validation below. On distinct fixed queues, B (shared) and C (shared+hapair) both start and poll. B imports its subset; C can import both; B can then verify zero matches and complete its own receipt. No receiver asserts that another box acknowledged its queue. |
| -If a new record invalidates coverage after startup, finish already admitted HA-host transactions safely, retain all departure evidence, emit one refusal and stop this consumer lifecycle: clear `Running` immediately, join admitted work, then close `Done` with the coverage fault retained in status. `Started` is a historical latch and cannot be reopened. No pending departure completes or acks. Persist the refusal fingerprint across restart so an unchanged fault does not page again. Rearming requires an explicit configuration/activation action and a new complete generation passing the gate; no timer retry of an unsupported scope. Already imported instance duties continue through ordinary HA gates. S needs Paul's birth-only extension decision; it permits supported born-HA sidecars but **still refuses any legacy native sidecar** in the scope. Carry this restriction into P3a's integration/activation card. |
| +There is **no consumer-wide coverage gate, suspension or rearm state**. Record or pool changes never clear Running, close Done or reopen Started. Unsupported departures remain durable, retry on inventory/policy changes and the bounded pending-work backoff, and page at most once per departure per hour per receiver, with the last-page time persisted across restart. Rotate departure pages fairly so an unsupported host cannot stall eligible hosts, other departures or tenant work. S's born-HA sidecars can recover through the same path; existing legacy sidecars remain an explicit per-departure gap. The activation card inventories these limits without making them a consumer/admission gate. |
| Drain, group admission/latch, role writers, ASG hooks/rolls, hairpin, §6.5 retry, migration, offline moves and imports remain outside both slices. No G1/G2/G3 claim from this plan alone. P3 later owns a separate executable drain integration addendum against merged producers. |
| @@ -46,23 +51,25 @@ Drain, group admission/latch, role writers, ASG hooks/rolls, hairpin, §6.5 retr |
| | Round | Brief / findings | Verdict | Fault families / disposition | |
| |---|---|---|---| |
| -| 1 | `REVIEW-BRIEF-REGION-HA-P1B3B-R1.md`; `REVIEW-REGION-HA-P1B3B-R1.md`, Claude Opus 5.5, plan bc7eeb04, review 73406540; code 9a064ebe plus c6304f2d | **NOT READY: 2 P1, 7 P2, 7 P3** | P1-1/P1-2 are **one I3 family: duty authority after import depends on an earlier dead owner**. Rev 2 uses one adoption finalizer; P2/P3 dispositions below. Round 2 has not run. | |
| +| 1 | `REVIEW-BRIEF-REGION-HA-P1B3B-R1.md`; `REVIEW-REGION-HA-P1B3B-R1.md`, Claude Opus 5.5, plan bc7eeb04, review 73406540; code 9a064ebe plus c6304f2d | **NOT READY: 2 P1, 7 P2, 7 P3** | P1-1/P1-2 are **one I3 family: duty authority after import depends on an earlier dead owner**. Rev 2 uses one adoption finalizer; P2/P3 dispositions below. R2 found the same I3 family; N-HA16 now supplies its central invariant. | |
| +| 2 | `REVIEW-BRIEF-REGION-HA-P1B3B-R2.md`; `REVIEW-REGION-HA-P1B3B-R2.md`, Claude Opus 5.5, plan 412a67f5, brief 1ce5733a, review c118f89d; code c6304f2d | **NOT READY: 2 P1, 2 P2, 4 P3** | P1-A repeats **I3: post-import duty authority depends on ageing termination evidence**; stopping rule 2 fired. Paul chose one enforced invariant, N-HA16. P1-B is **A1/I3/I4: tenant coverage controls consumer lifecycle**; N-HA17 removes that coupling. Rev 3 dispositions below; no reviewer approval claimed. | |
| +| 3 | Not dispatched; rev 3 is the candidate | **One final round remaining** | Carry R1/R2 families and Paul's rulings; do not reset the count for T/S or this revision. | |
| -One round of this document is spent. **If round 2 finds the I3 family again, stop fixing under rule 2 and offer Paul refuse/cut/one enforced invariant; do not write a third fix.** Parent P1b-3 plan: Opus R1 NOT READY (3 P1, 4 P2, 6 P3), R2 READY AFTER FIXES (0 P1, 2 P2, 6 P3); N-HA12 closed the repeated I4 family, rev 3 final. Its B1–B5/5B decisions are inherited, not reopened. Spec, P1b-1, P1b-2 and dead-holder backoff each spent three rounds and are closed; duty-file transfer was cut after three P1 rounds. |
| +Two rounds of this document are spent. **Stopping rule 2 fired in R2. Paul has ruled N-HA16/N-HA17; this revision implements that decision, not an unapproved third attempt. One final round 3 remains.** Parent P1b-3 plan: Opus R1 NOT READY (3 P1, 4 P2, 6 P3), R2 READY AFTER FIXES (0 P1, 2 P2, 6 P3); N-HA12 closed the repeated I4 family, rev 3 final. Its B1–B5/5B decisions are inherited, not reopened. Spec, P1b-1, P1b-2 and dead-holder backoff each spent three rounds and are closed; duty-file transfer was cut after three P1 rounds. |
| A reviewer of the newly executable mechanisms must carry those counts and distinguish new findings from settled decisions. Use `docs/superpowers/reviews/REVIEW-BRIEF-TEMPLATE.md`. Stop at the first round without P1; apply P2s without another round, retaining census/new-security checks. Two rounds in one invariant/trust-boundary family stop fixes; offer the prescribed refuse/cut/central-invariant choice. A fourth round needs Paul's go. Splitting T/S does not reset review history. No reviewers or subagents run in this planning session. |
| ## Round 1 dispositions |
| -All findings below were checked against the cited code. These are rev 2 changes, not reviewer approvals. New functions live in the task's named new files; file:line anchors identify the existing behavior they must preserve or replace. B5 must run the production predicates for the I6 witnesses, including the refusal cases. The review's sidecar exclusion citation (:481–500) is stale: the checked IsSidecar refusal is at `internal/host/edgesfile.go:611`; no behavior difference was found. |
| +Historical rev 2 dispositions below are retained for the round record, not current requirements or reviewer approvals. R2 supersedes the no-durable-proof choice and the coverage/start refusals in R1 P1-1/P1-2, P2-1/P2-4 and P3-5; use the rev 3 contracts below. New functions live in the task's named new files; file:line anchors identify the existing behavior they must preserve or replace. B5 must run the production predicates for the I6 witnesses, including the refusal cases. The review's sidecar exclusion citation (:481–500) is stale: the checked IsSidecar refusal is at `internal/host/edgesfile.go:611`; no behavior difference was found. |
| | Finding | Invariant and checked code | Rev 2 disposition / task | Witness and mutation | |
| |---|---|---|---| |
| -| P1-1 + P1-2 | **One I3 family: imported duty authority must name its current owner**; I1/N-HA9, I2. `internal/termfence/confirm.go:14,38,112`; `internal/hafresh/acquire.go:79,87,112`; `internal/lease/release.go:24,87` | **Accepted together.** B2 central AdoptHost finalizer imports, ordinary-acquires after expiry, releases unclean as self and verifies before completion, for held and released hosts. No durable-cache substitute or deferred sequential-loss exception. | `TestHAAdoptAuthority`, `TestAdoptFutureDueAfterRestart` (+48h, EC2 forgets, restart clears cache; separately visitor on a previously uninvolved box), `TestAdoptSequentialDepartures` (E→D→F before wake, held/clean/unclean starts). Mutations `complete-import-without-marker`, `marker-keeps-dead-releaser`, `release-412-is-adopted`; existing `take-before-expiry` still caught. | |
| -| P2-1 | **I3: no claimed coverage of unidentifiable legacy sidecar duties**. `internal/activator/hawake.go:77`; `internal/provision/sidecar.go:71` | **Accepted by stronger refusal.** T CheckCoverage rejects any regional native-sidecar record before polling; runtime additions suspend after finishing admitted instance transactions, retain evidence, report once. S still refuses legacy sidecars. B3/B4/B6. | `TestDepartureSidecarPreflight`, partial-import/runtime insertion witness. Mutation `sidecar-absence-means-covered`. | |
| +| P1-1 + P1-2 | **One I3 family: imported duty authority must name its current owner**; I1/N-HA9, I2. `internal/termfence/confirm.go:14,38,112`; `internal/hafresh/acquire.go:79,87,112`; `internal/lease/release.go:24,87` | **Accepted together.** B2 central AdoptHost finalizer imports, ordinary-acquires after expiry, releases unclean as self and verifies before completion, for held and released hosts. Rev 2's prohibition on durable proof is superseded by N-HA16; the finalizer and sequential-departure witnesses remain. | `TestHAAdoptAuthority`, `TestAdoptFutureDueAfterRestart` (+48h, EC2 forgets, restart clears cache; separately visitor on a previously uninvolved box), `TestAdoptSequentialDepartures` (E→D→F before wake, held/clean/unclean starts). Mutations `complete-import-without-marker`, `marker-keeps-dead-releaser`, `release-412-is-adopted`; existing `take-before-expiry` still caught. | |
| +| P2-1 | **I3: no claimed coverage of unidentifiable legacy sidecar duties**. `internal/activator/hawake.go:77`; `internal/provision/sidecar.go:71` | **Superseded by N-HA17.** Rev 2 used a consumer-wide refusal; rev 3 keeps unsupported hosts pending per departure and preserves lifecycle/progress. B3/B4/B6. | `TestDepartureCoverageIsolation` replaces the rev 2 preflight witness. Retain mutation `sidecar-absence-means-covered` as a per-departure completion refusal. | |
| | P2-2 | **I3: HRW winner must actually serve the host's pool**. Main `internal/edge/wakeplacement.go:157,168`; `internal/host/edgesfile.go:327,611` | **Accepted.** T uses per-host home entries for eligibility only; census remains full records. S adds validated served_pools box metadata, not public sidecar Hosts. B1/B6. | `TestHADutyNeverWokenPool`, `TestSidecarDutyPoolProjection`. Mutation `hrw-ignores-pool`. | |
| | P2-3 | **I3: missing edges is not deployment irrelevance**. `internal/boxid/record.go:38,65`; `internal/boxid/verify.go:96,102`; `internal/console/apisystemgeoip.go:336` | **Accepted.** B3 durable verified ref↔iid cache and bounded unknown-iid immutable-record walk. Missing edges cannot prevent a known departure scan; unknown binding refuses/escalates. ETag needed only for actual deletion. | `TestDepartureIdentityWithoutEdges`, fresh-registry/partial-list variants. Mutation `missing-edges-is-irrelevant`. | |
| -| P2-4 | **I3: each receiver either covers the complete scope or refuses before work**. `infra/modules/region-host/main.tf:835,851`; `internal/provision/reconcile.go:1304` | **Accepted via refusal alternative.** B3/B4 require full local coverage; no partial receiver delegates completion by observing another box. Shared-only B does not poll; shared+hapair C finishes its own queue. Unsupported queues remain explicitly outside activation. | `TestDeparturePoolCoverage`, two queues/two pools and runtime new-pool record. Mutation `partial-scope-admitted`. | |
| +| P2-4 | **I3: no receiver claims completion over unrecovered hosts** (rev 2 chose full-scope refusal). `infra/modules/region-host/main.tf:835,851`; `internal/provision/reconcile.go:1304` | **Superseded by N-HA17.** B3/B4 permit partial receivers to work and prove completion through a full zero-match rescan. Each receiver acknowledges its own queue only. | `TestDeparturePoolCoverage`, two queues/two pools and runtime new-pool record. Replace obsolete `partial-scope-admitted` mutation with `ack-with-dead-releaser`. | |
| | P2-5 | **I2/I3: a new lease's S3 wake state outranks local advisory progress**. `internal/activator/hawake.go:738`; `internal/hostfiles/wake.go:80,107` | **Accepted.** B2 splits adoption CAS from exact atomic restore. Local revision/digest/receipt never filters new-lease restore. | `TestHAAdoptThenOrdinaryRestore` with interim-holder once-timer. Mutation `local-progress-overrides-new-lease`. | |
| | P2-6 | **I3: permission failure cannot certify completion; apply must preserve required delete authority**. `infra/modules/region-host/main.tf:693,719–728`; private `dev/region-ie.tf:27` | **Accepted.** B4 pending/one-alert/no-ack on AccessDenied. Live T/5B requires merged/released/consumed region-host-store-deny fix plus saved-plan/effective-permission evidence; no apply restoring the Deny. Reported live drift is not independently verified here. | `TestDepartureDeleteDenied`, saved-plan policy assertion at drill preparation. Mutation `delete-denied-is-complete`. | |
| | P2-7 | **I3: completion inventory must include the dead box's last host**. `internal/host/agent.go:931`; `internal/host/changeindex.go:147,167`; `internal/provision/reconcile.go:1080` | **Accepted with source freshness too.** B3/B4 wait for ordinary source refresh and full pass begun after confirmation; old cached records cannot get a fresh timestamp. | `TestDepartureInventoryAfterEvidence`, just-created held host with synced timer and unchanged index. Mutations `complete-old-inventory`, `restamp-stale-recordview`. | |
| @@ -70,10 +77,23 @@ All findings below were checked against the cited code. These are rev 2 changes, |
| | P3-2 | **Request budget includes discovery**. `internal/lease/ha.go:96`; main `internal/edge/wakeplacement.go:168` | **Taken.** Added B×N_due first-duty GET burst separately from quiet baseline. B1/B4. | `TestHADutySuppressLivePeer` and counted upgrade/first-duty workload. | |
| | P3-3 | **Bounded observation/log traffic for a nonterminated stale peer**. `internal/termfence/confirm.go:19,112` | **Taken.** 300s scanner ceiling = ≤12 Describe/h/peer; state-change log plus ≤1 reminder/h; suspect alarm retained. B3/B5. | Fake clock/counting transport with stopped/hung peer, never termination; no deletion/ack. | |
| | P3-4 | **Configuration reaches the actual fixed-box process**. `internal/hostenv/hostenv.go:70`; `internal/host/units/carlos-edge.service:18`; `infra/modules/region-host/variables.tf:47` | **Taken.** B3/5B card delivers per-box queue URL via host.env, includes rollback and restart outage; group allowlist alone is insufficient. | Config-delivery witness reads generated env and arms actual helper; record restart/admission times on built binary. ~11s outage is a reported estimate, not a new measurement. | |
| -| P3-5 | **Started is truthful, not an immediate constructor fact**. `infra/modules/region-host/main.tf:897` (Receive permission); new B3 consumer seam | **Taken.** First empty long poll may take 20s; inventory preflight adds its own wait. No zero-wait polling to satisfy P3 admission. | `TestTerminationConsumerLifecycle` keeps Started open before delayed successful empty Receive; existing `start-before-client` mutation retained. | |
| +| P3-5 | **Started is truthful, not an immediate constructor fact**. `infra/modules/region-host/main.tf:897` (Receive permission); new B3 consumer seam | **Taken.** First empty long poll may take 20s. Rev 3 removes inventory wait and specifies the ≤30s successful startup leg. No zero-wait polling to satisfy P3 admission. | `TestTerminationConsumerLifecycle` keeps Started open before delayed successful empty Receive; existing `start-before-client` mutation retained. | |
| | P3-6 | **Count shared-queue visibility redelivery**. `infra/modules/region-host/main.tf:835,837`; new B3 Receive configuration | **Taken.** 120s visibility can redeliver ~8 times during 15m expiry, plus scanning; count per-receiver journals/scans, ack only own completion. B3/B4. | Fake queue visibility expiry across multiple receivers, counted scans, no early ack. | |
| | P3-7 | **Bounded scan client construction**. `internal/lease/ha.go:169,174` | **Taken.** B4 adds reusable lock reader/client per page, keeping validation/decoding; acquire retains its existing handle path. | `TestDepartureRequestBudget` counts one scan-reader client, up to 32 classification reads per page, plus separately counted finalizer reads. | |
| +## Round 2 dispositions |
| + |
| +| Finding | Invariant / rev 3 disposition | Tasks, witnesses and mutations | |
| +|---|---|---| |
| +| P1-A | **I3: post-import duty authority survives ageing evidence.** N-HA16 is Paul's rule-2 decision. One immutable termination proof per box departure; acquire validates it only after expiry, including after restart or +48h. | B2/B3/B5: `TestTerminationProofDurability`, `TestTerminationProofBinding`, `TestTerminationProofAcquireOnly`; kill after proof PUT but before import/finalization, forget EC2 and clear caches, then recover on a fresh registry; delayed S3 recovery too. Mutations `proof-needs-live-ec2`, `proof-wrong-lifetime`, `proof-before-expiry`, `proof-authorizes-import`. | |
| +| P1-B | **A1/I3/I4: tenant records cannot control consumer lifecycle.** N-HA17 removes all consumer coverage gates. Completion requires zero dead-lock matches in a full rescan; unresolved hosts block only their departure. | B3/B4/B5: `TestDepartureCoverageIsolation`, `TestDeparturePoolCoverage`, `TestDepartureCompletionRescan`; tenant inserts/enables legacy sidecar before/after Started, hapair-only P3-like observer, two queues, two departures. Mutations `coverage-stops-consumer`, `ack-with-dead-releaser`, `blocked-departure-starves-peer`. | |
| +| P2-1 | **Lifecycle has no hidden operator state.** Rearm removed with coverage suspension; ordinary inventory/policy updates retry pending departures automatically. No new command or setting. | B3/B4: `TestDepartureCoverageIsolation` corrects pool policy after a blocked pass and completes without restart/rearm; Started stays latched. | |
| +| P2-2 | **A1: bounded startup inventory contribution.** No inventory before Started: **0 reads, 0 passes, 0 seconds**. Empty-queue successful startup is bounded at 30s under the local/queue deadlines below, including the 20s long poll. Failure leaves Started open, never a fabricated success. | B3: `TestTerminationConsumerStartupBound` holds both inventory families incomplete and the index unchanged while acknowledging a real empty Receive; timeout/cancel cases. Mutation `started-waits-for-inventory`. | |
| +| P3-1 | **Request budget includes unrelated termination churn.** Cost line taken; durable negative cache deferred to the branch follow-up below. Safe invalidation for late identity publication needs a separate design; it is not required for correctness here. | B3/B4 `TestDepartureRequestBudget` counts unrelated CI/rootrunner terminations, coalesced walks and warm identity-cache reads per receiver. No new review round for this P3. | |
| +| P3-2 | **Observability distinguishes finalization from visitor takeover.** Taken: internal acquire cause `departure-finalize` labels its logs/counters, suppresses the visitor takeover alarm only; authority predicates unchanged. | B2/B5: `TestDepartureFinalizeTelemetry` compares finalizer and visitor takeover; mutation `finalizer-counts-as-visitor`. | |
| +| P3-3 | **I2: staged bytes match the under-lease manifest.** Taken: compare the freshly read manifest's wake-entry digest to the validated staged wake-object digest, never local rows. | B2: `TestHAAdoptManifestBoundary` changes wake entry while keeping staged/local rows unchanged; mutation `reuse-staged-rows-without-manifest-digest`. | |
| +| P3-4 | **I3: successor identity is proven.** Taken: parse strict HA marker/owner, bind ref/iid through verified `ha_box_identities`, check current record lifetime and a generation strictly greater than the observed lock. | B2/B4: `TestHAAdoptSuccessorValidation` covers remote holder/releaser, forged ref, wrong iid/lifetime and equal/older generation; mutation `superseded-without-bound-successor`. | |
| + |
| ## Global Constraints |
| - **Home scope, lesson of 2026-11-03:** dev and every home region run with `CARLOS_REGION` unset. It is `provision.Reconcile`'s record scope, not the AWS region. Empty placement is a real scope and matches only empty placement; it is neither unknown nor a wildcard. Dev IE records have `region:""`; `hapair-a1` is in pool `hapair`. Never set `CARLOS_REGION=ie` to make the drill pass: that would remove home records. Test every new comparison with those values. Reuse main's `placementNull` bit: explicit JSON null is malformed, while omission and `""` are home. A separate known/present bit represents missing evidence. |
| @@ -82,7 +102,7 @@ All findings below were checked against the cited code. These are rev 2 changes, |
| - HA duties use the existing nested acquire → restore → sealed-secrets publication → start path. Adoption reads only manifest and `wake.json` data and finalizes through an ordinary acquire/unclean release; it neither restores DB/files/secrets nor starts a process. All publish-before-start and positive-proof reuse rules remain. |
| - One local import transaction and one duty-selection policy; no claim-mode activation. No dependency on `CARLOS_HOST_CLAIM` or an unmerged role/drain producer. |
| - Existing view freshness: **15 minutes**, future tolerance **1 minute**; fold tick **30 seconds**, timed publication **5–6 minutes**. The ageing callback runs even when the change index skips the host fold. No new S3 polling loop or request-time membership reads. |
| -- `Confirmer.Terminated` stays shared with acquire: positive cache **24h**, negative/error cache **10s**, one in-flight describe/iid. The old `termfence.Verify` accepts an event; do **not** use it as the new proof path. `FromEvent` is a hint parser only. |
| +- `Confirmer.Terminated` remains the live Describe verifier: positive cache **24h**, negative/error cache **10s**, one in-flight describe/iid. N-HA16 adds durable proof persistence and an acquire-only validated reader; a process cache is no longer required after the proof lands. The old `termfence.Verify` accepts an event; do **not** use it as the new proof path. `FromEvent` is a hint parser only. |
| - Startup/cancel acknowledgment describes the functioning consumer lifecycle, not queue contents, scan completion, cloud health or permission to take a lease. An empty successful receive counts; failed client construction does not. Runtime S3/SQS blips must not cause automatic replacement. |
| - Copy is a draft deck for controller → Luna, including error/notice destinations. No product string is approved here. Implementation-plan prose uses writing-pipeline's explicit plan exception; the requested draft deck is not shipped copy. |
| - Targeted checks use `nice -n 19`, `-run`, `-count=1`; keep `GOCACHE` at its default. Scratch only under `/home/paulca/t/`, remove only owned scratch. Bind local test listeners to `127.0.0.1`. No `sudo`. |
| @@ -102,7 +122,7 @@ All findings below were checked against the cited code. These are rev 2 changes, |
| | `internal/registry/timers.go:54,126,321`; `internal/registry/registry.go:1878,3236,3265`; `internal/registry/remote_dispatch.go:143` | New `ha_duties.go`, `ha_departures.go`, tests and remote dispatch parity. Add tables in registry initialization; atomic state/receipt, guarded progress, removal cleanup. | |
| | `internal/provision/reconcile.go:1068,1230,1304`; `internal/provision/sidecar_reconcile.go:190,451`; `internal/provision/lifetimeindex.go:40` | New `departure_inventory.go`: complete validated regional record snapshot before pool filtering, from existing reads; no extra list. Both record families participate. | |
| | `internal/edge/homemap.go:168,270,433,524,788,1232`; `internal/edge/wakeplacement.go:136,168` | Retain exact ETags with cached files; export immutable departure observations and 30s callback independent of fold skip. New `hadepartures.go` and tests. Empty home scope fixed in every new predicate. | |
| -| `internal/termfence/confirm.go:112`; `internal/termfence/fence.go:117`; `internal/boxid/record.go:65`; `internal/boxid/verify.go:102` | Confirmation callback after cache publication; signed identity binding without roster. New adapter tests. | |
| +| `internal/termfence/confirm.go:112`; `internal/termfence/fence.go:117`; `internal/boxid/record.go:65`; `internal/boxid/verify.go:102` | Confirmation callback after cache publication; signed identity binding without roster. New `internal/termfence/termination_proof.go` and tests for root-side persistence and acquire-only validation; include `internal/rootaws` and effective proof-prefix IAM in the census. | |
| | `internal/release/conditional_delete.go:29,94`; `internal/release/changeindex.go:125,179` | Existing conditional deletion, plus an explicitly acknowledged index completion seam; current automatic bump logs/swallow errors. | |
| | `infra/modules/region-host/main.tf:835,841,865,890`; `infra/modules/region-host/outputs.tf:41`; `internal/hostenv/hostenv.go:71` | Existing queue/rule/receive-delete-getattributes policy and queue URL output. Deliver the fixed-box queue URL through host.env; hostenv.Optional covers group SSM only. T adds no queue actions. Edges deletion depends on the separately merged/released `region-host-store-deny` module fix (`main.tf:693,723`). New `internal/awsterminations/queue.go` and adapter tests; `go.mod`/`go.sum` for SQS SDK if needed. | |
| | `internal/sim/regionha/{world_test.go,actions_test.go,rules_test.go,invariants_test.go:59,sim_test.go:27,witness_test.go:101,mutate.sh}` | Durable timer/queue model and I6, sharing production pure decisions. | |
| @@ -117,17 +137,35 @@ New provider-neutral protocol/lifecycle types live in `internal/hadeparture/{typ |
| Use `hadeparture.Scope{CloudRegion, Placement, DataBucket, SecretsKeyFP string}` plus `Known bool` on the observation containing it. `Placement:""` is valid. A `Box` carries `Ref, InstanceID, Account, RecordSHA256 string` and `Scope`. A `Departure` carries that Box, exact `EdgesKey, EdgesETag string`, `ObservedAt time.Time`, and a stable ID derived from deployment bucket + cloud account/region + ref + iid + record digest. It contains no tenant-supplied path or arbitrary object prefix. |
| -`provision.DepartureInventory.Snapshot() InventorySnapshot` returns `{Generation, Records, Complete, WalkStartedAt, SourceReadStartedAt}`. `DepartureHost` contains canonical account/app/host, kind, placement, pool, lifetime ID, record revision and HA classification. Both record families must finish successful complete scans under one generation, **before pool filtering** (`reconcile.go:1304`, `sidecar_reconcile.go:190`). Parse/read failures retain old data but clear completeness. CheckCoverage uses the same normal reconcile eligibility predicate; inventory presence never grants a local route. |
| +`provision.DepartureInventory.Snapshot() InventorySnapshot` returns `{Generation, Records, Complete, WalkStartedAt, SourceReadStartedAt}`. `DepartureHost` contains canonical account/app/host, kind, placement, pool, lifetime ID, record revision and HA classification. Both record families must finish successful complete scans under one generation, **before pool filtering** (`reconcile.go:1304`, `sidecar_reconcile.go:190`). Parse/read failures retain old data but clear completeness. Per-host adoption uses the normal reconcile eligibility predicate; inventory presence never grants a local route. Inventory does not gate consumer startup or continued operation. |
| -**Fresh inventory (P2-7, I3):** completing a departure requires the full pass **and its source bucket refresh** to have started strictly after the locally recorded successful termination confirmation time. A pass started before confirmation, or started after it over an older RecordView, cannot qualify. Wait for the next ordinary full refresh/pass (`internal/host/agent.go:931`, `internal/host/changeindex.go:147,167`); use the existing index/backstop, without a new read loop. A scoped pass or unchanged-index skip cannot restamp an old snapshot. Persist the source generation/times; after restart require a newly qualifying pass. Before completion, changed/new records invalidate the affected scan checkpoints and coverage gate; a newer incomplete generation prevents completion. This adds up to one existing backstop interval to the latency bound. |
| +**Fresh inventory (P2-7, I3):** completing a departure requires the full pass **and its source bucket refresh** to have started strictly after the locally recorded departure-evidence observation time (live confirmation, or observation of an already persisted N-HA16 proof on resume). A pass started before confirmation, or started after it over an older RecordView, cannot qualify. Wait for the next ordinary full refresh/pass (`internal/host/agent.go:931`, `internal/host/changeindex.go:147,167`); use the existing index/backstop, without a new read loop. A scoped pass or unchanged-index skip cannot restamp an old snapshot. Persist the source generation/times; after restart require a newly qualifying pass. Before completion, changed/new records invalidate the affected scan/rescan checkpoints; a newer incomplete generation prevents completion. This adds up to one existing backstop interval to the latency bound. |
| The edge exports `DepartureView{Self BoxObservation, Peers []BoxObservation, Complete bool}`; observations retain key/ETag/generation and main's `placementNull`. Keep stale files for suspicion. Store verified immutable identity bytes/digest and their ref↔iid binding in a local `ha_box_identities` table; never remove a binding when its edges file disappears. Verify `control/boxes/<ref>.json` against AWS certificates and expected account/region (`boxid/record.go:38,65`, `boxid/verify.go:96,102`). Require the independent fixed-box expected iid/cached verified binding, or the existing deterministic group-ref binding; the unsigned Record.Box alone grants nothing. Reject duplicate ref/iid assignments. Store the last valid scope/edges revision separately, with explicit known bits. This is a cache of existing immutable evidence, not an enrollment write or an S3 roster. |
| **Irrelevance (P2-3, I3):** resolve a queue iid from that durable map. For an unknown iid, perform an event-triggered, paginated `control/boxes/` walk: at most one LIST page and 32 previously unverified record GETs per ordinary callback, persist the cursor, and finish/verify every relevant record before declaring no deployment match. Coalesce unknown events onto one walk. An incomplete walk, malformed record, duplicate binding or read error cannot certify absence. Only a complete verified walk with no matching signed iid can reject the event as unrelated. A matching signed iid with unresolved ref/scope is relevant-but-unbound: retain and escalate for missing identity configuration, never ack as unrelated. Missing edges alone never means irrelevant (`internal/console/apisystemgeoip.go:336` explicitly tells operators to delete retired edges). |
| -Known bindings with missing edges still confirm and scan. Exact edges ETag is required **only if an edges object exists to delete**. After a complete adopted scan, an exact-key GET proving absence may skip deletion and proceed to acknowledged index/completion; absence alone never discharges a host. An unbound/unknown scope remains refused. Wrong event account/region/source/type/state and malformed bodies are rejected without a scan. `termfence.FromEvent` is a hint parser only; the adapter checks terminated. Bound bodies to 64 KiB; no payload field chooses bucket, URL, key or AWS region. |
| +Known bindings with missing edges still resolve evidence and scan. Exact edges ETag is required **only if an edges object exists to delete**. After a complete adopted scan, an exact-key GET proving absence may skip deletion and proceed to acknowledged index/completion; absence alone never discharges a host. An unbound/unknown scope remains refused. Wrong event account/region/source/type/state and malformed bodies are rejected without a scan. `termfence.FromEvent` is a hint parser only; the adapter checks terminated. Bound bodies to 64 KiB; no payload field chooses bucket, URL, key or AWS region. |
| + |
| +All accepted hints enter `Controller.Enqueue(ctx context.Context, box BoxObservation) error`. Enqueue verifies the binding, obtains a live confirmation and persists the N-HA16 proof (or locates the existing exact proof), then durably upserts pending work before returning success. Locating a proof schedules work only; the acquire independently validates it before any takeover. The request path reports a successful confirmation through a callback after the confirmer publishes its result and releases locks; a failed enqueue must remain retryable on subsequent positive-cache hits. Never run a scan while holding a confirmer, edge-fold or activator mutex. |
| + |
| +### Durable termination evidence (N-HA16) |
| + |
| +**Object:** in the configured deployment/data bucket, `control/terminations/v1/<account>/<cloud-region>/<iid>/<box-lifetime>.json`. `box-lifetime` is the lowercase SHA-256 of the exact verified immutable `control/boxes/<ref>.json` bytes (`RecordSHA256`); it binds this incarnation, not a reusable box name. It is distinct from each tenant host's lifetime. One departure can cover many host lifetimes, so there is no proof object per host. Derive every key component from validated cloud identity and immutable box binding, never an event-provided key or tenant prefix. |
| + |
| +**Body:** strict version-1 JSON, at most **2 KiB**, with `v`, `account`, `region`, `iid`, `box_ref`, `box_lifetime`, `identity_sha256`, `state:"terminated"`, `source:"ec2-describe"`, `confirmed_at` (UTC), and confirming box ref/iid. Reject unknown version, duplicate/missing fields, oversized body, invalid timestamps or identity mismatch. The two digest fields must agree with the verified identity bytes. Timestamp is evidence provenance, not a TTL; valid proof never expires. |
| + |
| +**Writer and ordering:** the shared trusted root-side confirmer, using the existing `rootaws` credential boundary (`internal/host/hatakeover.go:37`), writes immediately after `SameAccountTerminated` accepts the exact Describe response and the immutable identity binding has been verified. Queue events, journal rows and callback booleans cannot mint proof. Preserve the verified observation through an initial PUT failure for bounded retry while the process lives; a cache-hit retry retains the original observation/time. Persist before reporting durable departure enrollment or allowing the finalizer to rely on it. Use one create-only PUT with `If-None-Match: *`; there is exactly one successful object creation per departure across receivers. A 412 or lost PUT response requires one exact-key GET and full binding/body validation; a different confirmer/time is acceptable for the same proven incarnation, conflicting identity/state is a fault. Never overwrite it. On failure leave work pending and unacknowledged. |
| + |
| +The proof prefix must be writable only by that trusted confirmer credential, readable by HA acquire, and unwritable by tenant/app or unprivileged box-agent credentials. Audit the existing effective IAM and root credential delivery, including alternative object-write/copy routes; a JSON `source` field is not authentication. Add the narrow prefix restrictions in T if current policy is insufficient, and include their census and scoped deployment approval. No general proof-write RPC or caller-supplied termination flag. Effective-policy denial witnesses are required before activation; existing box-role access alone is not evidence that an agent cannot forge a proof. |
| -All accepted hints enter `Controller.Enqueue(ctx context.Context, box BoxObservation) error`. Enqueue confirms via the shared `Confirmer.Terminated`, verifies the binding, then durably upserts pending work before returning success. The request path reports a successful confirmation through a callback after the confirmer publishes its result and releases locks; a failed enqueue must remain retryable on subsequent positive-cache hits. Never run a scan while holding a confirmer, edge-fold or activator mutex. |
| +**Sole authority consumer:** normal HA acquire's OwnerTerminated proof adapter. After reading/classifying a held HA lock, and only when `now > ExpiresAt`, derive its owner's ref/iid, resolve the verified box binding in the current account/region, and validate the exact-key proof. Bind the acquire's current host record/lifetime separately; an old host marker/receipt cannot authorize a recreated host. The iid-only callback must close over the classified owner and verified context, not trust an arbitrary iid supplied by a caller. On a CAS retry, rebind to the newly read owner; a positive result for D must not authorize E. Keep `DecideAcquire` as the one take decision and the existing conditional lock PUT as the fence. No proof read or bypass on an unexpired/equal-expiry lock, same-box recovery, absent prefix, malformed owner or lifetime mismatch. Live Describe can supply missing proof through the writer, but not-found/stopped/shutting-down/error is never proof. Missing/corrupt/inaccessible proof without live confirmation fails closed. |
| + |
| +A proof can be observed for discovery/journal retry; only acquire may consume it as authority. It cannot certify import, local-copy reuse, a completed departure, edges deletion, a duty start or P3 admission. Finalizer and visitor/due wakes share this adapter. A new process/registry with no prior confirmation must recover after EC2 forgets by reading the object; no successful Describe, original process or positive cache is required. |
| + |
| +**Retention:** keep proof for the deployment bucket's lifetime, with no automatic TTL, completion deletion or consumed bit. Another receiver or a delayed held lock may still need it after edges deletion. One immutable object ≤2 KiB per departure; D departures retain ≤2 KiB × D body bytes plus S3 metadata. The live drill retains its proof as evidence; any later deployment teardown is separately scoped. Ordinary quiet operation adds no reads, writes or LIST. B3/B5 witnesses cover create races, 412/lost response, denied/forged writes, malformed/cross-account/region/iid/box-lifetime proof, host recreation, CAS owner change, proof persistence then scanner crash/S3 outage/restart/+48h, and acquire-only consumption with N-HA9 equality. |
| + |
| +**R2 P3-1 follow-up:** a durable cache of proven-unrelated iids is deferred on this branch. It must define invalidation for newly published immutable identity records before suppressing future discovery across restarts. T retains bounded, coalesced unknown-iid walks and the durable positive identity cache; its expected-churn cost is explicit below. This P3 does not reopen review. |
| ### The independent start/cancel acknowledgment |
| @@ -153,22 +191,24 @@ func (c *Controller) Start(ctx context.Context, |
| makeQueue func(context.Context) (Queue, error)) (Lifecycle, error) |
| ``` |
| -`Started` closes once, after journal recovery, a passing coverage gate, handler registration and the first **successful** Receive result, empty included. A first result containing messages must have each message durably recorded as received (or definitively rejected) before startup is acknowledged; confirmation/import may still be pending. Keep a bounded local received-message record keyed by message ID/body digest, without a reusable receipt handle. Failure to persist leaves Started open and the receipt unacknowledged. Queue construction failure returns an error and no started lifecycle. Initialization does not wait for a message, a drained producer, a completed scan, a tenant wake or P3 admission. A receive error before first success leaves Started open and retries with bounded backoff. Start returns a lifecycle while inventory preflight waits asynchronously, so arming before the reconcile loops cannot deadlock their startup. Running remains false and no Receive occurs until coverage passes; a definite preflight refusal is a typed start error (or terminal lifecycle error if discovered asynchronously). Start twice on the same controller returns an error, never a second consumer. With an empty queue the first success can take the full **20-second long poll**; P3 restart-to-admission measurements must include that delay plus inventory preflight. Do not reduce WaitTimeSeconds or add zero-wait polls to improve the measurement. |
| +`Started` closes once, after bounded journal initialization, handler registration and the first **successful** Receive result, empty included. Messages in that result must be durably recorded as received (or definitively rejected) first; confirmation/import may remain pending. Keep a bounded inbox keyed by message ID/body digest, without a reusable receipt handle. Queue construction/persistence failure leaves Started open; Start twice returns an error. It waits for no inventory, coverage, message arrival, drain producer, completed scan, tenant wake or P3 admission. Arm it before reconcile loops without a dependency cycle. Running describes an active receive/retry loop, including retryable errors; Started records the first successful receive. |
| -After first start, transient queue/store/describe failures keep the loop alive and the start fact latched. `Running` becomes false synchronously when Stop or parent cancellation begins; Done closes after receiver and scan work have joined. Stop is idempotent, context-bounded, and cannot acknowledge uncommitted work; a timeout reports an unfinished stop. Unexpected terminal exit also clears Running and closes Done. P3 will set its `TerminationStarted` fact only from Started while Running, then close admission before invoking Stop or reacting to Done. This plan adds no P3 import, no `lbhealth.SetHosting` call and no cloud reads to health. |
| +**Startup bound (R2 P2-2):** inventory before Started is **0 reads / 0 passes / 0 seconds**. Both record families and their change-index/backstop work run independently; even a 33-minute full-walk delay contributes zero to this acknowledgment. Replay durable pending work asynchronously in bounded pages; startup only opens/validates the journal and registers its replay worker. Set a **5s** combined deadline for that local initialization, handler setup, queue-client construction and at most one GetQueueAttributes; Receive uses the normal **20s** long poll with a **25s** request deadline including transport and durable inbox recording. Under successful dependencies this gives **≤30s from Start to Started**, with an empty queue taking up to the full 20s poll. Deadline expiry is an error, never successful startup; retries can delay eventual acknowledgment without bound during an outage. P3 must budget 30s for this leg and its first-reconcile/publish legs separately, with a failure deadline rather than assuming availability. Do not shorten the poll or add zero-wait polls. |
| + |
| +After first start, queue/store/describe errors and unsupported departures keep the loop alive and Started latched. Running becomes false synchronously on Stop or parent cancellation; Done closes only after receiver and scan work join. Stop is idempotent and context-bounded; timeout cannot claim cancellation completed or acknowledge uncommitted work. Unexpected terminal exit also clears Running and closes Done. P3 may trust Started as started and Done as cancelled/terminated; coverage never changes either fact. Its admission latch remains P3's own contract through local shutdown; this plan supplies facts, not a coverage-triggered admission reset. No P3 import, `lbhealth.SetHosting` call or cloud health read is added. |
| Use one process-owned cancellation context in `runAgent`; pass it into the new controller and bridge the existing edge shutdown signal to it. Do not copy `context.Background()` from unrelated existing loops. Wiring tests execute the same `armHADepartures` helper called by runAgent. |
| ### Persistence, import and completion |
| -Store received-message bodies, pending departures and host receipts in the existing registry DB, not a new disk path or S3 object. Cap one received body at 64 KiB and the active inbox at 1,024 rows; at the cap pause Receive until existing work drains, leaving messages on SQS. Do not evict incomplete work. New tables: |
| +Store received-message bodies, pending departures and host receipts in the existing registry DB, not a new disk path. N-HA16's single proof object is the only new S3 evidence object. Cap one received body at 64 KiB and the active inbox at 1,024 rows; at the cap durably normalize validated inbox entries into per-departure rows and release their inbox slots; pending departures do not retain inbox bodies/receipts. Never pause the consumer merely because an unsupported departure cannot complete. On actual DB capacity/persistence failure, back off without acknowledging or inventing success. Do not evict incomplete departure work. New tables: |
| - `ha_termination_inbox`: message ID/body digest/body, received time and validation state; delete after completion or definite rejection. No receipt handle persists. |
| -- `ha_departures`: departure ID, bound identity/scope/edges revision, verified evidence time, inventory generation, phase, next attempt, last error code. Phases: pending → scanning → authority_complete → edges_deleted_or_absent → indexed → complete; `scope_refused` is a suspended state, not a retry deadline. Receipt handles are ephemeral; never persist them as permanent queue identity. |
| +- `ha_departures`: departure ID, bound identity/scope/edges revision, verified evidence time, inventory generation, phase, next attempt, last error code. Phases: pending → scanning → authority_complete → edges_deleted_or_absent → indexed → complete; `blocked_host` is a per-departure pending reason with a retry deadline and persisted last-page time, never a lifecycle state. Record proof key/digest/provenance, not an authority boolean. Receipt handles are ephemeral; never persist them as permanent queue identity. |
| - `ha_departure_hosts`: departure ID + host + lifetime, lock fingerprint, manifest sequence/wake digest, status (`pending`, `wait_expiry`, `imported_pending_authority`, `acquired`, `marker_pending`, `adopted`, `superseded`, `unsupported`), retry time. A skipped pool/unknown lifetime/failed read cannot become imported. |
| - `ha_duties`: host + lifetime, owner basis (`local-holder`, `local-release`, `adopted`), departure ID, wake digest/sequence, registry revision and suppression holder. Host retirement/recreation invalidates entries; historical receipts never authorize a new lifetime. |
| -`Service.AdoptHost(ctx context.Context, rt registry.Route, req Adoption) (AdoptResult, error)` is the one entry. `Adoption` carries departure identity, expected lifetime/registry Pair, observed lock and local revision. Results are `Adopted`, `AlreadyAdopted`, `Superseded`, or `Deferred`; only the first three can discharge a matching host. An import receipt alone is not Adopted. Superseded requires a validated subsequent HA holder/releaser (local or remote, with identity, current record lifetime and later lock generation established), or complete authoritative record retirement; a staged import or absence from a stale cache is insufficient. A changed remote lock alone is not proof this local import completed; classify it from the new view on the next attempt. |
| +`Service.AdoptHost(ctx context.Context, rt registry.Route, req Adoption) (AdoptResult, error)` is the one entry. `Adoption` carries departure identity, expected lifetime/registry Pair, observed lock and local revision. Results are `Adopted`, `AlreadyAdopted`, `Superseded`, or `Deferred`; only the first three can discharge a matching host. An import receipt alone is not Adopted. Superseded requires a strict parsed HA owner or release marker (local or remote), ref/iid bound to verified `ha_box_identities`, lifetime equal to the current authoritative host record, and generation strictly greater than the observed departure lock, or complete authoritative record retirement; a staged import or absence from a stale cache is insufficient. A changed remote lock alone is not proof this local import completed; classify it from the new view on the next attempt. |
| Use existing `hostfiles.Load` and `LoadWake` at the backend's configured `filesPrefix` (`<hibernatePrefix>/files/0/`). Validate manifest version, object origin, digest, wake V/Host, replication class and every timer before writing. No wake entry means no durable wake state; a referenced missing/corrupt wake object is incomplete. A missing whole manifest on a previously held host is reported as ambiguous, not silently installed as an empty timer set. Never read sealed items or instantiate a files publisher for adoption. |
| @@ -176,15 +216,23 @@ Add `Registry.ImportHAWake(ctx context.Context, host string, expected Pair, stat |
| Advance a per-host local revision transactionally for registration/deletion, timer advancement, next_due consumption, relevant reconcile changes, successful acquire and release. Read the revision before I/O; commit only if unchanged. Serialize wake/adoption in the activator's host operation state without holding `a.mu` over I/O. An acquire begun after a scan invalidates the scan commit; an import begun during wake defers. A repeat import receipt skips row replacement but must resume unfinished authority phases; only a finalized receipt returns AlreadyAdopted. **P2-5 / I2,I3:** under a newly acquired lease, ordinary restore installs the validated S3 wake state exactly (`hawake.go:738`, `hostfiles/wake.go:80`), atomically, before delivery. No local revision, timer tombstone, receipt or digest orders local state above a manifest written by an interim holder. Non-owner old-tick advancement is advisory. Revision/receipt CAS only prevents replay of adoption I/O done without a lease. Lease-acquired restore changes the local revision and invalidates outstanding adoption I/O. Keep adoption receipts to prevent their replay; never use them to filter the new holder's authoritative restore. |
| -**One authority rule (P1-1/P1-2, I3; I1/N-HA9 and I2): an adopted host is complete only when its durable lock names the adopter as holder/releaser, or a verified successor has taken responsibility.** Enforce this in **`Service.AdoptHost` alone**, including its replay/resume path. SQL import cannot independently mark a duty adopted, and Controller.Complete accepts only the finalizer's committed result. This applies to **held locks and clean/unclean release markers**, including hosts with no due work until days later. It closes both dependence on an old EC2 cache and discovery on the adopter's later departure. |
| +**Adoption completion rule (P1-1/P1-2, I3; I1/N-HA9 and I2): an adopted host is complete only when its durable lock names the adopter as holder/releaser, or a verified successor has taken responsibility.** Enforce this in **`Service.AdoptHost` alone**, including its replay/resume path. SQL import cannot independently mark a duty adopted, and the completion rescan validates every finalizer or successor result independently. This applies to **held locks and clean/unclean release markers**, including hosts with no due work until days later. The marker makes the adopter's later departure discoverable; N-HA16 removes the evidence-age dependency before that marker can be finalized. Acquire remains the sole takeover authority. |
| 1. For a held departed lock, wait strictly past its expiry (equality is held), then re-read the lock and latest manifest/wake object and stage the atomic import as `imported_pending_authority`. Released markers match ref+iid+lifetime and need no expiry wait. No candidate duty is runnable yet. |
| -2. In the same serialized host operation, acquire through the existing `lease.AcquireHA` core (`ha.go:59,96`; `hafresh/acquire.go:79,87,112`). Use a restriction callback on every CAS round to require the matching departed identity/lifetime and observed lock revision; a changed lock is reclassified, never forcibly replaced. Confirmation comes from the shared confirmer while fresh; no relaxed proof or early take. The base marker is **self ref/self iid/current lifetime**, never the departed base. |
| -3. Under that acquired handle, revalidate/load the manifest and install its exact wake state atomically before finalization. This second validation prevents an import staged before acquisition from defeating a later authoritative publication. If an earlier staged digest still matches, avoid a second wake-object GET; still read the manifest. Start no tenant, restore no DB/file tree, publish no wake state or secrets, and claim no clean local copy. |
| +2. In the same serialized host operation, acquire through the existing `lease.AcquireHA` core (`ha.go:59,96`; `hafresh/acquire.go:79,87,112`). Use a restriction callback on every CAS round to require the matching departed identity/lifetime and observed lock revision; a changed lock is reclassified, never forcibly replaced. OwnerTerminated uses the N-HA16 acquire adapter and its durable proof; EC2 retention and in-memory confirmation no longer constrain this later finalization. No early take. The base marker is **self ref/self iid/current lifetime**, never the departed base. |
| +3. Under that acquired handle, revalidate/load the manifest and install its exact wake state atomically before finalization. This second validation prevents an import staged before acquisition from defeating a later authoritative publication. Compare the freshly read manifest's wake-entry digest with the digest of the validated staged wake-object bytes. Only equality permits reusing those bytes and avoiding a second wake GET; local staged SQL rows are not the comparison. A changed digest requires fetching and validating the new object. Start no tenant, restore no DB/file tree, publish no wake state or secrets, and claim no clean local copy. |
| 4. Immediately call `Held.Release` (`lease.go:314,324` → `release.go:28,87`), which writes the ordinary **unclean self marker**. Persist/retry existing release obligations on errors. **Release returning nil is not proof of the self marker:** its 412 path also returns nil (`release.go:24,48`). Read the lock back and require the self ref/iid/lifetime and expected acquired generation's unclean marker before committing `adopted`/local duty basis. A later valid HA holder/releaser can discharge as Superseded only after identity/lifetime/generation validation; malformed, absent or ambiguous state remains pending. No wrapper bypasses ordinary acquire/release authority. |
| 5. Persist phase transitions before effects and replay them after crashes. Death before the acquire leaves the original lock discoverable; death after acquire names this scanner; death after marker publication but before local commit also names it. Process restart uses existing same-box-empty proof/release obligations, never a fresh EC2 guess about self. A replay of an already adopted receipt must revalidate its authority status without reinstalling old timers or repeatedly acquiring a self marker. A different scanner seeing the new owner/releaser suppresses its duplicate import; if that adopter later terminates, its own departure scan imports it normally. |
| -The future duty still uses ordinary HA acquire and restore. Any box can take an unclean marker without describing the earlier dead owner (`hafresh/acquire.go:79`); unclean forbids local reuse. Both a once-timer due at +48h after a cache-clearing restart and E→D→F sequential departures before any wake are mandatory witnesses, not deferred limits. No S3 duty file, new lock wire shape or permanent termination exception is introduced. |
| +The future duty still uses ordinary HA acquire and restore. Any box can take an unclean marker without describing the earlier dead owner (`hafresh/acquire.go:79`); unclean forbids local reuse. Both a once-timer due at +48h after a cache-clearing restart and E→D→F sequential departures before any wake are mandatory witnesses, not deferred limits. No S3 duty file or new lock wire shape is introduced. N-HA16 retains termination evidence permanently; it never bypasses the ordinary acquire or its expiry rule. Label finalizer acquires with the internal cause `departure-finalize` in logs and recovery counters, excluding them from visitor-takeover alarms (`internal/activator/hatakeover.go:34`); visitor acquires retain their alarm. The cause changes telemetry only. |
| + |
| +### Completion rescan (N-HA17) |
| + |
| +After imports/finalizations, start a **new full lock rescan** over the complete pre-filter regional inventory, including hosts this receiver cannot serve. Read each canonical lock once, with the shared reader; check both HA owner and released-marker releaser for the dead ref/iid and valid host lifetime. A D match keeps the departure open, even if a local receipt says Adopted. For a previously matched host now naming a successor, require the strict binding/lifetime/later-generation checks above. A vanished previously held lock, malformed/unknown identity or lifetime, failed read, incomplete family or unresolved legacy-sidecar attribution cannot be counted as zero. An authoritative record retirement must be established explicitly. |
| + |
| +Completion requires zero D matches **and** no unresolved entries for one complete qualifying inventory generation. A record/source generation change before the completion commit invalidates its affected checkpoints; an incomplete newer generation blocks completion. The final scan starts after this receiver's finalization pass; this terminal box cannot renew a D lock, and a legitimate acquire only moves ownership forward. Rescan results cannot grant authority to any process. Persist the generation and results before edges deletion/index/ack. After restart before durable completion, require a new qualifying inventory and rescan; an already committed complete receipt can handle duplicate events locally. |
| + |
| +One worker shares **32 lock reads per 30s callback** across final scans in fair round-robin departure order; a blocked page never monopolizes it. One successful rescan costs **N GETs, 0 PUT/LIST**, with at most **32 GETs per page** and `ceil(N/32)*30s` scheduling allowance for a single active departure, plus bounded request time. With K active departures, budget at most K such page slots per departure turn; errors/generation invalidations add counted passes and 30/60/120/300s backoff, with no finite success promise under continuing faults/churn. Completion storage operations and finalizer requests are separate budget rows. Foreign-pool/unsupported D matches remain pending and page per departure under N-HA17; correcting records/policy or another eligible receiver's valid finalization is observed automatically, with no rearm door. |
| ### Duty selection |
| @@ -200,47 +248,51 @@ Suppression is keyed by host lifetime + holder ref/iid + relevant view/duty gene |
| Counts are logical API attempts, including failed CAS; instrument transport retries separately. New SQS/EC2 adapters set SDK max attempts to **1** so their retry loop is the count. S3 keeps existing adapter behavior; report actual wire retries alongside logical counters. G/P/L/D mean S3 GET/PUT/LIST/DELETE. |
| -Let N be the complete regional scan's host count, A matching/importable hosts and W manifests containing wake state (W≤A). Let U be previously unverified box references, E be event-required edges refresh reads (normally 0), Q≤A additional wake GETs when the manifest changed between staging and acquire, and k be index CAS attempts (1≤k≤4). Every adopted host, held or released, adds one acquire GET, one under-lease manifest GET, one release-verification GET and two PUTs; failed/reclassified attempts are additional. The current implementation has **four total attempts**, not five, despite §18's “four retries” wording. |
| +Let N be the complete regional scan's host count, A matching/importable hosts and W manifests containing wake state (W≤A). Let U be previously unverified box references, E be event-required edges refresh reads (normally 0), Q≤A additional wake GETs when the manifest changed between staging and acquire, F proof GET attempts (including acquire, discovery and PUT-conflict readback), and k be index CAS attempts (1≤k≤4). Every adopted host, held or released, adds one acquire GET, one under-lease manifest GET, one release-verification GET and two PUTs; failed/reclassified attempts are additional. A successful final rescan adds N GETs. One successful proof creation adds 1 PUT per departure, not per host; concurrent/failed create attempts count separately. An acquire may reuse a validated in-process proof keyed by its full identity, but restart clears that optimization. A cold uncontended held-host acquire adds one proof GET; a three-round owner-changing CAS can add three. The current implementation has **four total attempts**, not five, despite §18's “four retries” wording. |
| | Path | S3 | SQS / EC2 | |
| |---|---|---| |
| | Quiet enabled box, no pending departure; each ordinary duty/age pass with nothing eligible | **0 incremental G/P/L/D** | 1 Receive/20s ≈ **180/h**, **4,320/day**; 0 Delete, 0 Describe | |
| -| Startup, identity cache empty | U G for discovered signed records, one-time; no LIST | At most 1 GetQueueAttributes to validate the configured queue, then receives; no GetQueueUrl | |
| -| One valid termination, successful full scan | **(U+E+N+4A+W+Q)G + 2A P**, 0L for known identities | 1 delivering Receive + 1 Delete after complete; 1 Describe on cache miss, 0 on hit | |
| +| Startup, identity cache empty | U G for discovered signed records, one-time and asynchronous; **0 inventory/proof S3 reads before Started**, no LIST | At most 1 GetQueueAttributes to validate the configured queue, then receives; no GetQueueUrl | |
| +| One valid termination, import plus successful completion rescan | **(U+E+2N+4A+W+Q+F)G + (2A+1)P**, 0L for known identities; proof PUT counted once | 1 delivering Receive + 1 Delete after complete; 1 Describe on cache miss, 0 on hit | |
| | Completion, uncontended | **1D + 1G+1P** index | Message deletion above | |
| | Completion with index conflicts | **1D + kG+kP**, k≤4 | No ack until indexed or a later acknowledged retry | |
| -| Single scan pass | Uncontended: at most **224G + 64P** for 32 adopted hosts including Q=32; 192G+64P if manifests unchanged. Plus bounded identity/refresh and completion | 0 additional receives required by scanner; at most one Describe/iid/10s | |
| +| Single adoption page | Uncontended: **224G + 64P** for 32 adopted hosts including Q=32, plus ≤32 cold proof GETs = **256G + 64P**; 192G+64P before proof reads if manifests unchanged. Proof creation, identity/refresh and completion counted separately | 0 additional receives required by scanner; at most one Describe/iid/10s | |
| +| Completion rescan page | **≤32G**, 0P/L; full pass N G, repeated/invalidation/error passes counted | No Describe; no ack while dead owner/releaser or unresolved entry remains | |
| +| Durable proof persistence/read | **1P** successful creation per departure, ≤2 KiB; +1G per 412/lost response; acquire +1G per uncached exact identity; discovery GETs counted in F | Existing Describe on initial proof; **0 Describe required** after persisted proof, even +48h/fresh process | |
| | Held lock still unexpired | 1 lock G in this attempt, 0 manifest/wake G; persist deadline | No repeat describe within negative/positive cache bounds | |
| -| Resume after expiry/error, n remaining/revalidated hosts, a/w imports | **(n+4a+w+q)G + 2a P**, plus U/E and retries; worst a full formula again | Redelivery adds a Receive and eventually a Delete for its current receipt | |
| +| Resume after expiry/error, n remaining/revalidated hosts, a/w imports | **(n+4a+w+q+f)G + 2a P**, plus final N-G rescan, U/E and retries; add failed/missing proof creation separately | Redelivery adds a Receive and eventually a Delete for its current receipt | |
| | Duplicate completed event on same durable registry | 0 scan G; completion receipt checked locally | 1 Receive + 1 Delete; evidence cache hit 0 Describe | |
| | Concurrent scanner / future shared queue | Up to one full scan formula per distinct receiver, plus bounded retry/revalidation pages; journals coalesce duplicate receipts locally | 120s visibility versus up to 15m expiry permits roughly 8 deliveries before expiry alone, and more while scanning; each receiver journals, acks only on its own complete scan. No visibility extension | |
| -| Malformed/wrong-account/already proven unrelated event | 0 scan S3 | 1 Receive + 1 Delete for definitively irrelevant message; 0 Describe | |
| +| Malformed/wrong-account or unrelated within the completed discovery batch | 0 scan S3 | 1 Receive + 1 Delete for definitively irrelevant message; 0 Describe | |
| | Identity/view/inventory incomplete | No host scan; at most bounded U/E reads on work retry | No Delete; confirmation retry respects cache | |
| | Delete CAS conflict / ambiguous delete result | Failed 1D; next attempt +1G exact edges key, then repeat only after identity/revision check | No ack from conflict/error | |
| -| Ordinary duty acquire | Existing **1G + 1P** if acquired, plus ordinary restore R; absent lock adds **1L** prefix-empty proof | At most existing confirmation on expired peer | |
| +| Ordinary duty acquire | Existing **1G + 1P** if acquired, plus restore R; absent lock adds **1L** prefix-empty proof. Expired peer: +1G for uncached proof, +1P only if creating its missing proof after Describe | No Describe required with valid persisted proof; otherwise live confirmation | |
| | Duplicate duty meets live owner/releaser | **1G**, 0P, then **0** until suppression invalidation | No duty-rate describes | |
| | Unknown queue iid, complete identity lookup | `ceil(B/1000)L + U G` for B immutable box records; page retries counted; ≤1 LIST +32G/callback; no periodic walk | No Delete until complete verification proves unrelated or departure completes | |
| | First due work after upgrade, no local duty basis | Up to **B×N_due G** across B boxes, once per sleeping HA host with due work until suppression changes | Not part of the quiet baseline | |
| | Stale peer, stopped/hung but not terminated | 0 new membership S3 | Describe at 30/60/120/300s then ≤12/h/peer indefinitely (free API per spec); one state-change log, ≤1 reminder/hour/peer, existing suspect >10m alarm | |
| -| Gate, HRW, local journal/receipt, inventory projection | **0** | **0** | |
| +| Duty gate, HRW, local journal/receipt, inventory projection | **0** | **0** | |
| + |
| +R is unchanged: up to five Litestream LISTs plus extra pages per 1,000 L0 files, object GETs, manifest GET and referenced objects; sealed escrow reads/publication remain on ordinary wake. CAS acquisition retains the existing maximum three classification rounds, so gG+pP+lL with 1≤g≤3, 0≤p,l≤g, and L only for absent-prefix proof, plus separately counted proof GET/create attempts. Identity resolution adds U G when not cached; this includes validating a remote successor. Marker obligations and renewals keep their existing cost. |
| -R is unchanged: up to five Litestream LISTs plus extra pages per 1,000 L0 files, object GETs, manifest GET and referenced objects; sealed escrow reads/publication remain on ordinary wake. CAS acquisition retains the existing maximum three classification rounds, so gG+pP+lL with 1≤g≤3, 0≤p,l≤g, and L only for absent-prefix proof. Marker obligations and renewals keep their existing cost. |
| +N=500, A=W=20, Q=0, U=E=0 gives **1,100 GETs + 41 PUTs** before proof reads; with F=20 cold proof reads, **1,120 GETs + 41 PUTs = $0.000653** at §18's prices. This includes one proof creation and one final rescan, excluding completion index and ordinary wake costs. Completion adds $0.0000054 uncontended (DELETE free). A 32-host adoption page with Q=32 and 32 cold proof reads costs $0.0004224 (256 GETs +64 PUTs); its separate completion rescan page adds $0.0000128 (32 GETs). Proof creation, retries, identity and index operations are additional to those page examples. A new durable identity cache of B references adds B successful GETs once, with explicit bounded retry attempts for failures. The durable identity cache survives process restarts. No claim that failed identity reads, paginated unknown-iid discovery or conflicting adoption attempts are free. Budget and test each; the quiet known-identity path still performs no new LIST. |
| -N=500, A=W=20, Q=0 gives **600 GETs + 40 PUTs = $0.000440** at §18's prices, before evidence, completion and ordinary wake costs. Completion adds $0.0000054 uncontended (DELETE free). A full 32-host pass with Q=32 costs at most $0.0004096 (224 GETs +64 PUTs), excluding retries/evidence/completion. A new durable identity cache of B references adds B successful GETs once, with explicit bounded retry attempts for failures. The durable identity cache survives process restarts. No claim that failed identity reads, paginated unknown-iid discovery or conflicting adoption attempts are free. Budget and test each; the quiet known-identity path still performs no new LIST. |
| +**Expected unrelated churn (R2 P3-1):** for C unrelated terminations/hour, B immutable box records and J receivers on distinct queues, the uncoalesced worst case is `J*C*ceil(B/1000)` LISTs/hour plus previously unverified-record GETs and counted failed-read retries. With the durable identity cache warm, successful identity GETs are zero until records change; coalescing can reduce LIST walks. For example, C=60, B≤1000, J=2 gives ≤120 LISTs/hour ($0.0006 at §18 prices), plus receives/deletes. Restarts do not erase the positive cache; no durable-negative-cache saving is claimed. Count actual dev CI/rootrunner churn during the drill. |
| -One successful edges deletion causes the existing coalesced fold: per reader `ceil(B/1000)L+B*G`. Existing cap is `120*(ceil(B/1000)+B)` requests/hour/box. Quiet S3 baseline remains §18's **3,300–3,500/hour**, not additional allowance. SQS's ~180/h applies to empty long polls; event bursts/redeliveries add receives. Use MaxNumberOfMessages=1, WaitTimeSeconds=20, VisibilityTimeout=120 on Receive; no ChangeMessageVisibility, SendMessage or new IAM permission. Empty early responses are paced to 20s; errors back off 1,2,4,8,16,30s with bounded jitter, cancelable. Scanner retries run on the existing 30s callback with 30/60/120/300s backoff, one worker and 32 hosts/pass. Receives continue independently of long scans. |
| +One successful edges deletion causes the existing coalesced fold: per reader `ceil(B/1000)L+B*G`. Existing cap is `120*(ceil(B/1000)+B)` requests/hour/box. Quiet S3 baseline remains §18's **3,300–3,500/hour**, not additional allowance. SQS's ~180/h applies to empty long polls; event bursts/redeliveries add receives. Use MaxNumberOfMessages=1, WaitTimeSeconds=20, VisibilityTimeout=120 on Receive; no ChangeMessageVisibility, SendMessage or new SQS IAM permission. N-HA16 proof-prefix permissions are separately audited/scoped. Empty early responses are paced to 20s; errors back off 1,2,4,8,16,30s with bounded jitter, cancelable. Scanner retries run on the existing 30s callback with 30/60/120/300s backoff, one worker and 32 host slots/pass shared fairly across discovery/adoption/rescan pages and pending departures. Storage request deadlines are 5s per call; one page has a 30s work deadline and checkpoints unfinished hosts rather than blocking the next departure. Slow calls reduce throughput; the page-count latency estimates assume each page finishes within its slot. Receives continue independently of long scans. |
| -Fixed dev boxes have distinct module IAM names/queues (`platform-infrastructure/dev/region-ie.tf:9`, `region-ie-b.tf:13`); each polls its own authorized existing queue. A future shared group queue distributes messages. Do not point leo at sophie's queue and assume its existing IAM permits that. Queue URL is supplied from `termination_queue_url` into optional `CARLOS_TERMINATION_QUEUE_URL`; URL/account/region validation happens once, with no inferred URL or discovery poll. Missing URL means not started, with a notice; no IAM widening to make configuration work. Fixed boxes require the deployment release/config operator to write each queue output into root-owned mode-0600 `/etc/carlos/host.env`, then restart `carlos-edge.service` (`internal/host/units/carlos-edge.service:18`; `infra/modules/region-host/variables.tf:47` says the module does not write host.env). Adding `hostenv.Optional` only enables future group SSM delivery. Include the fixed-box config update, rollback value and restart in the approved release card; a bare restart has a reported ~11s tenant outage, to measure on the built revision, plus up to 20s first empty receive before Started. Never silently substitute a reload for env replacement. |
| +Fixed dev boxes have distinct module IAM names/queues (`platform-infrastructure/dev/region-ie.tf:9`, `region-ie-b.tf:13`); each polls its own authorized existing queue. A future shared group queue distributes messages. Do not point leo at sophie's queue and assume its existing IAM permits that. Queue URL is supplied from `termination_queue_url` into optional `CARLOS_TERMINATION_QUEUE_URL`; URL/account/region validation happens once, with no inferred URL or discovery poll. Missing URL means not started, with a notice; no IAM widening to make configuration work. Fixed boxes require the deployment release/config operator to write each queue output into root-owned mode-0600 `/etc/carlos/host.env`, then restart `carlos-edge.service` (`internal/host/units/carlos-edge.service:18`; `infra/modules/region-host/variables.tf:47` says the module does not write host.env). Adding `hostenv.Optional` only enables future group SSM delivery. Include the fixed-box config update, rollback value and restart in the approved release card; a bare restart has a reported ~11s tenant outage, to measure on the built revision, plus the ≤30s successful consumer-start leg (including a 20s first empty receive); inventory adds zero to that leg. Never silently substitute a reload for env replacement. |
| **P2-6 / completion permissions:** `host_store` exists when `store_bucket_prefix` is set (`infra/modules/region-host/main.tf:693–694`); its explicit deployment/data-bucket DeleteObject Deny (:719–728) defeats the existing Allow. Dev host_ie sets the prefix (`platform-infrastructure/dev/region-ie.tf:27`). T's live activation/5B apply is blocked until **`region-host-store-deny` is merged, released and consumed by the dev root** and the saved plan proves no reintroduction of this Deny on existing or disposable roles. Do not implement or review that unmerged design here, depend on a hand-edited live policy, or add another Allow. The card must show the resolved module revision, exact policy diff and effective edges-delete/legacy-release permissions for every affected role. If the saved plan restores the Deny, refuse the apply before requesting approval. AccessDenied during completion stays pending, preserves edges/message and emits one permission-fault alert until policy changes; no hourly page loop or false ack. |
| ## Review Focus |
| -1. **Empty home placement and pool mismatch:** Task B3 `TestDepartureHomeScopeAndPools` uses dev-shaped records and explicit-null refusals; CheckCoverage rejects partial receivers before Receive (B4 two-receiver witness). |
| +1. **Empty home placement and pool mismatch:** Task B3 `TestDepartureHomeScopeAndPools` uses dev-shaped records and explicit-null refusals; partial receivers both Receive/Started; per-departure completion waits for a zero-match rescan (B4 two-receiver witness). |
| 2. **Scanner dies after importing one host, before ack:** B4/B5 restart on a different registry and replay through real import; every durable obligation survives and no early delete occurs. |
| 3. **Replay races delivery, registration, ordinary restore or hostname recreation:** B2 adoption-CAS witnesses preserve advanced rows and refuse old lifetimes; newly acquired restore installs S3 exactly, including an interim holder's new once-timer. |
| 4. **Queue empty, construction fails, or cancellation wins startup:** B3 lifecycle tests establish exactly when Started/Running/Done change; no fake P3 boolean. |
| -5. **Held terminated owner has time left, or final wake publication lands late:** B4 waits the expiry deadline and re-reads before completion; B5 proves zero pre-expiry takes and starts, +48h delivery after restart and discovery after two sequential departures. |
| +5. **Held terminated owner has time left, or final wake publication lands late:** B4 waits the expiry deadline and re-reads before completion; B5 proves zero pre-expiry takes and starts, +48h finalization after proof persistence/restart/EC2 forgetting, future-due delivery and discovery after two sequential departures. |
| --- |
| @@ -270,13 +322,13 @@ Fixed dev boxes have distinct module IAM names/queues (`platform-infrastructure/ |
| ### Task B3: Evidence, one consumer and independent start acknowledgment [T; own review: termination] |
| -**Files:** new `internal/hadeparture/*`, `internal/awsterminations/*`, `internal/host/hadepartures.go`; new `internal/provision/departure_inventory.go`; new `internal/edge/hadepartures.go`; modify agent, hatakeover, confirmer, home-map, both reconciles, RecordView refresh provenance, hostenv allowlist and SDK module files. Include fixed-box host.env delivery in the deployment release card, not in the group-only allowlist. |
| +**Files:** new `internal/hadeparture/*`, `internal/awsterminations/*`, `internal/host/hadepartures.go`; new `internal/provision/departure_inventory.go`; new `internal/edge/hadepartures.go`; modify agent, hatakeover, confirmer, home-map, both reconciles, RecordView refresh provenance, hostenv allowlist and SDK module files. Add `internal/termfence/termination_proof.go`/tests and the acquire adapter in `internal/lease`; include any required proof-prefix IAM/root credential isolation changes and their effective-policy witnesses. `rootaws` selects credentials; it does not itself prove that the same role is inaccessible to an unprivileged agent. Verify that boundary explicitly. Include fixed-box host.env delivery in the deployment release card, not in the group-only allowlist. |
| -**Interfaces:** Lifecycle/Queue/Start/Enqueue above. `armHADepartures` takes the same confirmer installed at `agent.go:487`, registry, service, stores and immutable view/inventory callbacks; returns controller/lifecycle or a typed initialization error. Edge exposes `WithDepartureTick(func(context.Context, DepartureView))`; invoke after the existing poll on every 30s tick, including skipped/error folds. Controller exposes `CheckCoverage(InventorySnapshot, LocalPolicy) CoverageResult` with Ready/Waiting/Refused and record-bound reasons; Start and every inventory change use it. Add the durable verified-identity repository and bounded unknown-iid lookup described above. Controller exposes `Tick(context.Context, DepartureView) error`, used for age suspicion and pending retries. Tick may schedule asynchronous work but never blocks the fold on a full scan. |
| +**Interfaces:** Lifecycle/Queue/Start/Enqueue above. `armHADepartures` takes the same confirmer installed at `agent.go:487`, registry, service, stores and immutable view/inventory callbacks; returns controller/lifecycle or a typed initialization error. Edge exposes `WithDepartureTick(func(context.Context, DepartureView))`; invoke after the existing poll on every 30s tick, including skipped/error folds. Controller uses per-host `CanAdopt(DepartureHost, LocalPolicy)` and `CanCompleteDeparture(RescanResult)` predicates; neither is called to gate Start/Running/Done. Completion consumes the strict rescan, not a regional eligibility boolean. Add the durable verified-identity repository and bounded unknown-iid lookup described above. Controller exposes `Tick(context.Context, DepartureView) error`, used for age suspicion and pending retries. Tick may schedule asynchronous work but never blocks the fold on a full scan. |
| -- [ ] **Step 1: Write failing tests.** `TestTerminationConsumerLifecycle` covers successful empty receive, client/attributes failure, initial receive failure then recovery, repeated Start, cancel before first success, cancel during Receive/import, bounded Stop and unexpected exit. `TestTerminationEventEvidence` supplies event-only, wrong account/region, stopped/shutting-down/not-found, poisoned ref/iid, duplicate iid, self and invalid signatures; no scan/deletion follows. `TestDepartureHomeScopeAndPools` uses cloud eu-west-1, placement "", hapair-a1/pool hapair, plus shared/cohort1 and foreign-region records; omitted/empty placement is home, explicit null is malformed, on self and peers (main homemap.go:168,788; I3). `TestDepartureAgeOnSkippedFold` holds change-index generation constant, advances past 15m, and proves one queued confirmation on the real tick with zero extra S3 membership calls. `TestRequestConfirmationEnqueues` tests cached-positive retries after journal failure. `TestDepartureInventoryComplete` includes hidden sidecars and an out-of-pool record; incomplete family/record scans cannot certify coverage. `TestDepartureSidecarPreflight` includes an asleep legacy native sidecar with no lock, in/out of local pools, and an awake sidecar: T refuses all in the exact regional scope before Receive/Started; sidecars in another placement do not refuse. Insert one after startup: complete any already admitted instance transaction but retain edges/receipt and suspend with one C8 (hawake.go:77; I3). `TestDepartureIdentityWithoutEdges` reopens the durable verified map after edges deletion, plus an unknown iid discovered through immutable records, unrelated iid, poisoned binding and partial list; only proven unrelated gets acked without scanning (boxid/record.go:38; I3). `TestDepartureInventoryAfterEvidence` adds a just-created/woken host after the old snapshot, confirms D, then skips the index: no completion until both fresh source and full pass start after confirmation; the new host is recovered (agent.go:931, changeindex.go:147; I3). |
| +- [ ] **Step 1: Write failing tests.** `TestTerminationConsumerStartupBound` exercises the 5s+25s deadlines, no inventory reads, both families indefinitely incomplete and an unchanged index; successful empty Receive still closes Started within 30s. `TestTerminationProofDurability`, `TestTerminationProofBinding` and `TestTerminationProofAcquireOnly` execute every N-HA16 contract case, including real proof-store transports and rejected unprivileged writes. `TestTerminationConsumerLifecycle` covers successful empty receive, client/attributes failure, initial receive failure then recovery, repeated Start, cancel before first success, cancel during Receive/import, bounded Stop and unexpected exit. `TestTerminationEventEvidence` supplies event-only, wrong account/region, stopped/shutting-down/not-found, poisoned ref/iid, duplicate iid, self and invalid signatures; no scan/deletion follows. `TestDepartureHomeScopeAndPools` uses cloud eu-west-1, placement "", hapair-a1/pool hapair, plus shared/cohort1 and foreign-region records; omitted/empty placement is home, explicit null is malformed, on self and peers (main homemap.go:168,788; I3). `TestDepartureAgeOnSkippedFold` holds change-index generation constant, advances past 15m, and proves one queued confirmation on the real tick with zero extra S3 membership calls. `TestRequestConfirmationEnqueues` tests cached-positive retries after journal failure. `TestDepartureInventoryComplete` includes hidden sidecars and an out-of-pool record; incomplete family/record scans cannot certify coverage. `TestDepartureCoverageIsolation` includes asleep legacy native sidecars with no lock, in/out of local pools, and an awake sidecar, both before startup and inserted/enabled by a tenant afterward. Started/Running/Done remain lifecycle facts; supported host imports and other departures continue. Only affected departures retain evidence and page within the persisted hourly bound. Correct an eligible pool policy: pending work resumes without restart/rearm. Add a hapair-only P3-like lifecycle observer beside shared records; it starts. A foreign-placement sidecar is irrelevant to that departure. `TestDepartureIdentityWithoutEdges` reopens the durable verified map after edges deletion, plus an unknown iid discovered through immutable records, unrelated iid, poisoned binding and partial list; only proven unrelated gets acked without scanning (boxid/record.go:38; I3). `TestDepartureInventoryAfterEvidence` adds a just-created/woken host after the old snapshot, confirms D, then skips the index: no completion until both fresh source and full pass start after confirmation; the new host is recovered (agent.go:931, changeindex.go:147; I3). |
| - [ ] **Step 2: Run** `nice -n 19 go test ./internal/hadeparture ./internal/awsterminations ./internal/host ./internal/edge ./internal/termfence ./internal/provision -run 'TestTermination|TestDeparture|TestRequestConfirmation' -count=1`; expect missing consumer/callback failures. |
| -- [ ] **Step 3: Implement** the SDK method-value adapter and provider-neutral lifecycle. Receive uses the exact values/bounds in the budget; no queue per departure or visibility extension. Validate configured URL against own cloud identity and attributes; never log receipt handles. Retain existing queue policy. Persist source refresh start time separately from pass start time; export inventory completeness before filtering; preserve partial-fold evidence and ETags. On age crossing, failed holder observation or request confirmation, coalesce one journal entry per bound departure. Confirmed evidence cancels duty suppression and records counters without changing N-HA9. |
| +- [ ] **Step 3: Implement** the SDK method-value adapter and provider-neutral lifecycle. Receive uses the exact values/bounds in the budget; no queue per departure or visibility extension. Validate configured URL against own cloud identity and attributes; never log receipt handles. Retain existing queue policy. Persist source refresh start time separately from pass start time; export inventory completeness before filtering; preserve partial-fold evidence and ETags. On age crossing, failed holder observation or request confirmation, coalesce one journal entry per bound departure. Persist verified termination through the root-side proof writer before durable enrollment; the acquire alone validates it as a take proof. Confirmation may invalidate suppression but cannot grant a start. Apply bounded asynchronous replay, independent startup deadlines and per-departure fair scheduling without changing N-HA9. |
| - [ ] **Step 4: Run the same tests**, including method-value binary linking and config disabled/legacy parity. The common arm helper must be called once before service/worker/runner start and stopped by actual agent cancellation; permit one syntactic call/order check only for the uncallable runAgent wrapper, paired with executable helper tests. Test one receiver even when future P3-like lifecycle observation is attached; the observer is only a test consumer of Lifecycle, not a fake drain producer. |
| - [ ] **Step 5: Commit** `ha: consume termination hints with lifecycle acknowledgment`. |
| @@ -286,10 +338,10 @@ Fixed dev boxes have distinct module IAM names/queues (`platform-infrastructure/ |
| **Interfaces:** `Controller.ScanPass(ctx context.Context) (progress bool, err error)` runs one bounded page; `Controller.Complete(ctx context.Context, departureID string) error` performs completion phases. Add `release.DeleteIfMatchIndexed(ctx context.Context, s Store, key, etag string) error` for stores that can acknowledge both operations; unsupported stores refuse. Keep existing DeleteIfMatch semantics for other callers. Add `lease.NewLockReader(ctx, region)` with `ReadLock(ctx, bucket, prefix)` reusing one configured client per scan page; retain key validation and readView classification, no per-host client creation (`ha.go:169,174`; request-budget invariant). Use raw delete plus one explicit index bump, not the existing automatic bump plus a second bump. |
| -- [ ] **Step 1: Write failing tests.** `TestDepartureScanOwnersAndReleasers` scans all records, awake/asleep/sidecar included, matches strict HA owner or marker ref/iid/lifetime, and calls the one importer. `TestDepartureNoEarlyDelete` injects every lock/manifest/object/import/commit failure and verifies edges and receipt remain. `TestDepartureWaitsExpiry` schedules an unexpired dead-owner lock, lands a final wake publication before expiry, and proves final import uses it. `TestDepartureScannerDeath` kills scanner after one import and before each completion phase; a different live registry rescans/redelivers. `TestDepartureDeletionRace` changes the edges ETag/iid, makes Delete succeed with lost response, and fails index bump. `TestDeparturePoolCoverage` uses distinct fixed queues: B serves shared, C shared+hapair, D had both; B refuses before polling, C imports all and completes, B never retries/pages hourly. Introduce out-of-pool work during a scan: suspend without deletion/ack. `TestDepartureDeleteDenied` injects AccessDenied at conditional deletion: pending durable progress, one permission alert, no ack; recovery after permission correction does not re-import (main.tf:723; I3). `TestDepartureRequestBudget` asserts every budget row, including idle/partial/duplicate and index conflict maxima. |
| +- [ ] **Step 1: Write failing tests.** `TestDepartureScanOwnersAndReleasers` scans all records, awake/asleep/sidecar included, matches strict HA owner or marker ref/iid/lifetime, and calls the one importer. `TestDepartureNoEarlyDelete` injects every lock/manifest/object/import/commit failure and verifies edges and receipt remain. `TestDepartureWaitsExpiry` schedules an unexpired dead-owner lock, lands a final wake publication before expiry, and proves final import uses it. `TestDepartureScannerDeath` kills scanner after one import and before each completion phase; a different live registry rescans/redelivers. `TestDepartureDeletionRace` changes the edges ETag/iid, makes Delete succeed with lost response, and fails index bump. `TestDeparturePoolCoverage` uses distinct fixed queues: B serves shared, C shared+hapair, D had both; both start and poll, B imports shared work and keeps D open while hapair locks name D, C finalizes hapair work, then both rescan and acknowledge their own receipts. Introduce out-of-pool work during a scan: invalidate completion only for that departure. Add another departure with supported hosts and prove progress. `TestDepartureCompletionRescan` leaves a D-owned/released lock after an apparent import success, changes inventory mid-rescan, injects ambiguous absence and validates remote successor markers. No false completion. Count N additional reads, 32/page and fair scheduling across K departures. `TestDepartureDeleteDenied` injects AccessDenied at conditional deletion: pending durable progress, one permission alert, no ack; recovery after permission correction does not re-import (main.tf:723; I3). `TestDepartureRequestBudget` asserts every budget row, including idle/partial/duplicate and index conflict maxima. |
| - [ ] **Step 2: Run** `nice -n 19 go test ./internal/host ./internal/registry ./internal/release -run 'TestDeparture' -count=1`; expect incomplete scans currently lack durable ordering. |
| -- [ ] **Step 3: Implement** pending → scanning → authority_complete → edges_deleted_or_absent → indexed → complete. Require a passing whole-scope coverage gate and a complete inventory whose source read and full walk started after confirmation. One shared-client lock read per host for classification; matched hosts incur the additional finalizer reads/writes in the budget. Complete only Adopted/AlreadyAdopted/validated Superseded results. Changed/new records invalidate checkpoints and rerun coverage. Unknown lifetimes/read errors/malformed locks cannot conceal duties or become success. Refuse unsupported scope before more work, preserve evidence and report once; do not retry it forever or widen tenancy. No selection from public edges Hosts for the scan census. |
| -- [ ] **Step 4: Implement completion recovery.** Persist all host authority results before conditional deletion of the retained revision. If edges were already absent, require full scan completion and exact-key absence before the acknowledged index phase. On 412 re-read that exact key, revalidate identity, and rescan invalidated work; never delete a replacement file. Uncertain deletion/index results remain locally pending and unacknowledged. Retry the explicit index bump, not the scan. Do not fabricate success from swallowed errors. AccessDenied is a permission fault, alerted once and blocked pending correction. Only durable completion allows Delete of the currently received receipt; Delete failure redelivers safely. Missing edges is never proof of imports. |
| +- [ ] **Step 3: Implement** pending → scanning → authority_complete → edges_deleted_or_absent → indexed → complete. Require a complete inventory whose source read and full walk started after the locally observed departure evidence. Coverage never gates the consumer. One shared-client lock read per host for classification; matched hosts incur the additional finalizer reads/writes in the budget. After Adopted/AlreadyAdopted/validated Superseded results, run the fresh full completion rescan; require zero dead owner/releaser matches and no unresolved entries. Changed/new records invalidate checkpoints. Unknown lifetimes/read errors/malformed locks cannot conceal duties or become success. Keep unsupported hosts pending, page per departure at the persisted hourly limit, and continue eligible hosts/other departures. Never widen tenancy. No selection from public edges Hosts for the scan census. |
| +- [ ] **Step 4: Implement completion recovery.** Persist all host authority results and the successful zero-match rescan before conditional deletion of the retained revision. If edges were already absent, require full scan completion and exact-key absence before the acknowledged index phase. On 412 re-read that exact key, revalidate identity, and rescan invalidated work; never delete a replacement file. Uncertain deletion/index results remain locally pending and unacknowledged. Retry the explicit index bump, not the scan. Do not fabricate success from swallowed errors. AccessDenied is a permission fault, alerted once and blocked pending correction. Only durable completion allows Delete of the currently received receipt; Delete failure redelivers safely. Missing edges is never proof of imports. |
| - [ ] **Step 5: Run the tests**, plus two-scanner races, death between every import/acquire/release/commit phase, and restart on a different registry. Use immutable identity records even if another scanner or an operator deleted edges. A transferred host is now discoverable through its adopter's lock/marker; cover that adopter's later termination **before any wake**, alongside partial-scanner death. Test readback after release returns nil on 412. Verify one scan-reader client per page and the counted acquisition/marker/readback requests. Each completed host has recoverable S3 wake state and a named duty owner, not merely a local receipt. |
| - [ ] **Step 6: Commit** `ha: finish departure imports before removing evidence`. |
| @@ -297,13 +349,13 @@ Fixed dev boxes have distinct module IAM names/queues (`platform-infrastructure/ |
| **Files:** simulation files in the map; new `internal/host/hadepartures_root_linux_test.go`; counting transport tests; host departure log/metric wiring and `internal/host/metrics_loop.go`; implementation census artifacts only when code exists. |
| -**Interfaces:** simulation calls production DecideDuty, CheckCoverage, the adoption phase-transition guard and the production scan-match predicate extracted from B4 (`MatchesDeparture(view hafresh.View, departure Box, lifetime string) bool`). Simulation owns virtual queues/time/crash scheduling; it must not copy these decision tables or turn an import-only receipt into completion. Model EC2 forgetting after 1h, process-local confirmation expiry at 24h, restart, lock generation/marker identity and inventory source/walk timestamps. Host records transfer/confirmation counters and latency into the existing metrics flush, with no new PutMetricData loop. |
| +**Interfaces:** simulation calls production DecideDuty, CanAdopt, CanCompleteDeparture, the acquire-only proof validator, the adoption phase-transition guard and the production scan-match predicate extracted from B4 (`MatchesDeparture(view hafresh.View, departure Box, lifetime string) bool`). Simulation owns virtual queues/time/crash scheduling; it must not copy these decision tables or turn an import-only receipt into completion. Model durable proof writes, conditional conflicts and failures, EC2 forgetting after 1h, process-local confirmation expiry at 24h, restart, lock generation/marker identity and inventory source/walk timestamps. Host records transfer/confirmation counters and latency into the existing metrics flush, with no new PutMetricData loop. |
| -- [ ] **Step 1: Write failing I6 tests.** Add durable wake/timer state, registrations, due times, receipt visibility/redelivery, scanner progress and inventory/fold generations to the 2–5-box model. `TestWitnesses` includes held+released departure, scanner death, duplicate import after delivery, lost queue event with no visitors, skipped-index ageing and a timer registered immediately before death whose wake state never synced. Add the finding-specific witnesses/mutations in the disposition table: +48h due after restart and EC2 forgetting; E→D→F sequential departures while asleep; native-sidecar scope refusal; never-woken hapair exclusion; missing edges with retained identity; heterogeneous receiver refusal; interim-holder registration; delete denied; post-confirmation fresh inventory. After faults stop and a compatible live adopter/store exist, all durable work must eventually deliver within max(event/age + expiry + bounded scan/finalization pages + qualifying inventory delay, duty due time) + next runner/sweep; only the final unsynced ~1s timer may be absent. The qualifying inventory delay can reach the existing 30m backstop +10% jitter (`release/changewatch.go:17`, host/changeindex.go:175), with no new polling. State fairness assumptions, including one fully covering admitted survivor and initial confirmation before EC2 forgets; future-due work after completed adoption needs no such evidence window; never turn persistent store failure into a false pass. |
| -- [ ] **Step 2: Add mutations.** `skip-departure-scan`, `scan-owners-not-releasers`, `delete-before-import`, `ack-before-import`, `ignore-termination-event`, `skip-age-on-unchanged-index`, `replay-overwrites-delivered-timer`, `duty-ignores-owner`, `take-before-expiry`, `start-before-client`. Each must have a deterministic witness and be caught; no expected-missed exemption for I6. Add every finding-specific mutation from the disposition table and record its deterministic witness; refuse-scope mutations must fail at preflight, not pass by timing out liveness. Startup mutation is an executable wiring mutation, not a model-only boolean. |
| +- [ ] **Step 1: Write failing I6 tests.** Add durable wake/timer state, registrations, due times, receipt visibility/redelivery, scanner progress and inventory/fold generations to the 2–5-box model. `TestWitnesses` includes held+released departure, scanner death, duplicate import after delivery, lost queue event with no visitors, skipped-index ageing and a timer registered immediately before death whose wake state never synced. Add the finding-specific witnesses/mutations in the disposition table: +48h due after restart and EC2 forgetting; E→D→F sequential departures while asleep; native-sidecar per-departure blockage with independent consumer/other-tenant progress; never-woken hapair exclusion; missing edges with retained identity; heterogeneous receivers completing through a zero-match rescan; interim-holder registration; delete denied; post-confirmation fresh inventory. After faults stop and a compatible live adopter/store exist, all durable work must eventually deliver within max(event/age + expiry + bounded scan/finalization plus completion-rescan pages + qualifying inventory delay, duty due time) + next runner/sweep; only the final unsynced ~1s timer may be absent. The qualifying inventory delay can reach the existing 30m backstop +10% jitter (`release/changewatch.go:17`, host/changeindex.go:175), with no new polling. State fairness assumptions, including at least one eligible surviving adopter per supported host, fair departure scheduling and an initial N-HA16 proof persisted before all live confirmation is lost. After persistence, even delayed finalization needs no EC2 or process-cache window. Unsupported legacy-sidecar recovery is an explicit gap, never a liveness PASS; never turn persistent store failure into a false pass. |
| +- [ ] **Step 2: Add mutations.** `skip-departure-scan`, `scan-owners-not-releasers`, `delete-before-import`, `ack-before-import`, `ignore-termination-event`, `skip-age-on-unchanged-index`, `replay-overwrites-delivered-timer`, `duty-ignores-owner`, `take-before-expiry`, `start-before-client`. Each must have a deterministic witness and be caught; no expected-missed exemption for I6. Add every finding-specific mutation from the disposition table and record its deterministic witness; coverage mutations must fail assertions on per-departure pending state, independent lifecycle/progress and zero-match completion; a liveness timeout alone is insufficient. Startup mutation is an executable wiring mutation, not a model-only boolean. |
| - [ ] **Step 3: Build real witnesses.** `TestHADepartureProductionWiring` runs the actual arm helper, queue adapter boundary, shared confirmer, complete reconcile inventory, importer, runner/sweeper and counted stores. `TestHADepartureRootLifecycle` uses separate survivor processes/registries, real ExecBackend acquire/restore, nested instance control and schedule delivery. Mock only EC2/SQS transport and storage endpoints; do not mock successful acquire, AdoptHost, timer delivery or edges deletion. No visitor request is allowed to rescue a missing trigger. Prove another live registry recovers after partial scanner death and after a completed adopter later terminates while its host remains asleep. Use a virtual clock for +48h/cache-expiry witnesses; do not sleep for days. Include actual readback and 412/AccessDenied transports, stale RecordView provenance and the two fixed-queue receivers. Preserve instance key/token identity and one writer. Run through the approved rootrunner; a skipped privileged test is not PASS. |
| - [ ] **Step 4: Run once per implementation revision:** `RHASIM_SEEDS=3000 nice -n 19 go test ./internal/sim/regionha -run '^TestRegionHA$' -count=1`; build its test binary under owned `/home/paulca/t/` and run `RHASIM_PAR=1 nice -n 19 internal/sim/regionha/mutate.sh <binary> 3000 <new-rules>`. Record failing mutation seeds and witness names. Use targeted deterministic tests during fixes; no repeated full sweep without a new revision. |
| -- [ ] **Step 5: Wire §20 evidence.** Structured transfer/confirmation logs carry host, lifetime, dead ref/iid, scan ID, result and latency. Metrics carry counts/age/latency without per-host cardinality. Export oldest pending scan and consumer start/error state through the existing status/metrics path. On transient incomplete recovery, emit C3 once per departure/hour/process; unsupported coverage and permission faults instead emit once per durable fault/configuration generation, with status retained until corrected; C4 only after durable completion. Queue oldest-message >10m alarm remains part of the scoped infrastructure card, using the existing queue; do not create it from the box. Suspect-holder >10m and existing alarms remain intact. A stopped consumer before startup cannot report healthy start. |
| +- [ ] **Step 5: Wire §20 evidence.** Structured transfer/confirmation logs carry host, lifetime, dead ref/iid, scan ID, result and latency. Metrics carry counts/age/latency without per-host cardinality. Export oldest pending scan and consumer start/error state through the existing status/metrics path. For transient or unsupported-host incomplete recovery, page at most once per departure/hour/receiver with last-page time durable across restart; retain record-bound status until resolved. Permission faults emit once per durable fault/configuration generation; C4 only after durable completion. Queue oldest-message >10m alarm remains part of the scoped infrastructure card, using the existing queue; do not create it from the box. Suspect-holder >10m and existing alarms remain intact. A stopped consumer before startup cannot report healthy start. |
| - [ ] **Step 6: Obtain accepted copy and complete census**, then run build/vet/format/test once and cross-compiles. Review T's full diff against current amadan main, including all new registry/provision/release/SDK surfaces. Use the bounded review rules; no automatic extra review after P2 fixes. |
| - [ ] **Step 7: Commit** `ha: prove unattended departure duty recovery`. At implementation time only: push to amadan, describe exact scope/restrictions/tests/review, check green CI at the full tip and squash-land through `amadan branch merge -expect`; read main CI afterward. This planning commission stops at its local commit and never runs those commands. |
| @@ -313,7 +365,7 @@ Fixed dev boxes have distinct module IAM names/queues (`platform-infrastructure/ |
| **Decision proposed:** extend the existing new-record HA stamp to native sidecars created in configured HA regions, with the same empty home-scope resolution as instance creation. Add `HA bool` with `json:"ha,omitempty"` to SidecarRecord; absent remains legacy. Every actual record-creation path (create, enable/auto-create) must stamp/refuse before writes. Existing sidecars and co-spawn children do not change classification. No migration by enabling a box switch. |
| -**Interfaces:** derive the sidecar lifetime from canonical account/app/synthetic host/CreatedAt; populate the existing lifetime index and sticky route HA bit. `haLegacyRoute` retains legacy behavior for unprovisioned/unstamped sidecars, but stamped, proven native sidecars use the same HA containment/acquire/restore/release/import path as an instance. They remain `IsSidecar()`, socketless and explicitly refused at ingress. Reuse AdoptHost, including the unclean self-marker finalizer; no sidecar-specific transfer protocol. Publish the optional `served_pools` eligibility field from actual reconcile policy and require it for sidecar HRW as defined above; validate exact pool names, preserve explicit shared pool, reject malformed/unknown values. Include this additive wire schema and every reader in S's census/review. Legacy native sidecars still fail CheckCoverage. |
| +**Interfaces:** derive the sidecar lifetime from canonical account/app/synthetic host/CreatedAt; populate the existing lifetime index and sticky route HA bit. `haLegacyRoute` retains legacy behavior for unprovisioned/unstamped sidecars, but stamped, proven native sidecars use the same HA containment/acquire/restore/release/import path as an instance. They remain `IsSidecar()`, socketless and explicitly refused at ingress. Reuse AdoptHost, including the unclean self-marker finalizer; no sidecar-specific transfer protocol. Publish the optional `served_pools` eligibility field from actual reconcile policy and require it for sidecar HRW as defined above; validate exact pool names, preserve explicit shared pool, reject malformed/unknown values. Include this additive wire schema and every reader in S's census/review. Legacy native sidecars remain per-departure unresolved entries; they cannot stop a consumer. |
| - [ ] **Step 1: Write failing tests** `TestSidecarHABirthOnly` (all create paths, configured home region with record region "", absent stamp remains legacy), `TestSidecarHADutyLifecycle` (real worker acquire, wake-state publish, sleep marker, dead-releaser scan, import, due wake), `TestSidecarHARefusals` (uncontained layout/unknown lifetime/shared secrets unavailable before writes/start), and `TestSidecarNeverAdvertisedOrDialled`. Add `TestSidecarDutyPoolProjection`: a never-woken hapair sidecar excludes a shared-only box despite its winning raw HRW, empty/absent/null pool fields differ, and no synthetic public Hosts entry is published. Inherit P2a's supported shape/capacity/move/import refusals rather than bypass them through the sidecar door. |
| - [ ] **Step 2: Run targeted provision/console/activator/host tests** with `-run 'TestSidecarHA|TestSidecarNever|TestSidecarDutyPool' -count=1`; verify the existing unconditional legacy classification is the failing behavior. |
| @@ -326,12 +378,12 @@ Fixed dev boxes have distinct module IAM names/queues (`platform-infrastructure/ |
| **This task prepares a reviewable card before requesting scoped approval.** No live mutation is authorized by this plan. Never terminate sophie-knitting or leo-climbing. A process kill is not EC2 termination evidence. No drain drill until P3's real drained producer and durable completion integration are merged. |
| - [ ] **Step 1: Assemble read-only evidence and the exact card.** Private root `/home/paulca/amadan.net/carlos/platform-infrastructure/dev`, current account identity (historical #421 account **640012953448**, reverify), AWS **eu-west-1**, cloud resource IDs, both queue URLs/IAM scopes, exact third-box module/instance/profile/SG/subnet/EBS/EIP resources, and instance type/count/expiry. Name exact app/account/hosts/domains/record and data prefixes. Confirm existing dev records remain `region:""`; hapair-a1/pool hapair is an existing fixture, usable only if included in approval. Verify the merged home-placement fix is in the deployed binary. Do not change `CARLOS_REGION`. |
| -- [ ] **Step 2: Specify effects/cost/cleanup before asking.** First prove the merged/released `region-host-store-deny` dependency is consumed and the saved plan does not restore the deployment/data-bucket DeleteObject Deny on sophie/leo/C; attach effective-policy evidence for edges deletion and legacy release. Refuse an unsafe plan before approval or apply. One disposable third **fixed** box in pool hapair, exact role/resource changes from a saved whole-root plan and targeted closure, any new module-owned queue/rule/IAM resources explicitly enumerated rather than called “no infra change.” T uses existing queues; provisioning C may create its own module resources. No ASG or NLB needed. List dev-only binary roll, `CARLOS_REGION_HA=1`, each box's own queue URL, root-owned 0600 fixed-box host.env delivery and rollback (not only hostenv.Optional), console isolation, permitted restarts with ~11s reported outage and measured first-poll/admission delay, temporary records/timer writes and EC2 termination of **C's exact iid only**. No customer DNS/traffic shift. Produce a currency estimate from the selected instance/storage/IP/queue/metric/alarm prices with a numeric cap and at most **2 hours**; unresolved IDs/cost make the card non-approvable. Name the operator, cleanup owner, expiry and verification commands. S3-loss/negative-evidence tests stay local unless separately added to the card. |
| +- [ ] **Step 2: Specify effects/cost/cleanup before asking.** First prove the merged/released `region-host-store-deny` dependency is consumed and the saved plan does not restore the deployment/data-bucket DeleteObject Deny on sophie/leo/C; attach effective-policy evidence for edges deletion and legacy release. Refuse an unsafe plan before approval or apply. One disposable third **fixed** box in pool hapair, exact role/resource changes from a saved whole-root plan and targeted closure, any new module-owned queue/rule/IAM resources explicitly enumerated rather than called “no infra change.” T uses existing queues; provisioning C may create its own module resources. No ASG or NLB needed. List dev-only binary roll, `CARLOS_REGION_HA=1`, each box's own queue URL, root-owned 0600 fixed-box host.env delivery and rollback (not only hostenv.Optional), console isolation, permitted restarts with ~11s reported outage and measured first-poll/admission delay, temporary records/timer writes, the exact N-HA16 proof prefix/write/read permission changes if required, retained ≤2 KiB proof evidence, and EC2 termination of **C's exact iid only**. No customer DNS/traffic shift. Produce a currency estimate from the selected instance/storage/IP/queue/metric/alarm prices with a numeric cap and at most **2 hours**; unresolved IDs/cost make the card non-approvable. Name the operator, cleanup owner, expiry and verification commands. S3-loss/negative-evidence tests stay local unless separately added to the card. |
| - [ ] **Step 3: Ask for one scoped approval** of that concrete account/region/domain/resources/permissions/traffic/cost/duration/cleanup card. T's implementation approval or a prior dev release is not this approval. The production-infrastructure rule in AGENTS.md requires it. No repeated per-call questions within the approved scope. |
| -- [ ] **Step 4: Prepare real duties on C.** Verify exact built binary/revision, identity records, consumer Started, fresh compatible edges, nested/escrow readiness and all intended records on eligible survivors and a passing executable full-scope CheckCoverage on every activated receiver; no legacy native sidecar may be hidden by an absent lock or pool filter. On C create one held born-HA instance, one cleanly released born-HA instance, synced once-timers and next_due, plus an S-born native sidecar. Include a future-due timer to verify the adopter's unclean marker before leaving the host asleep; +48h and sequential-departure tests use the local virtual-clock/root witnesses, not an extension of the two-hour live approval. Use real worker/sleep paths. Read exact manifest/wake digests and record UTC sync acknowledgments; preserve token/key fingerprints without printing secrets. Keep all visitor probes off after setup. T's earlier restricted drill omits sidecar only under an explicit restricted acceptance label, never a full 5B PASS. |
| -- [ ] **Step 5: Terminate C through EC2 and observe unattended recovery.** Log API time, confirmed terminated state, original expiry, queue receipt, scan/import transaction, timer delivery and conditional edges deletion/index/ack. No start before expiry; for held work measure remaining TTL separately from scan/delivery latency. Normal event bound includes event/describe latency, remaining lease, a qualifying full inventory refresh (up to the existing 33m backstop bound), `ceil(N/32)*30s` scan/finalization allowance and ≤30s delivery sweep plus restore; future-due timers are measured from their due time. Do not quote the pre-fencing 1–3m estimate as a guarantee. Reader convergence after acknowledged index is about 30s. |
| +- [ ] **Step 4: Prepare real duties on C.** Verify exact built binary/revision, identity records, consumer Started, fresh compatible edges, nested/escrow readiness and all intended records on eligible survivors and a complete pre-filter inventory identifying per-departure unsupported hosts and survivors serving each intended duty; verify partial-pool receivers still start and run; no legacy native sidecar may be hidden by an absent lock or pool filter. On C create one held born-HA instance, one cleanly released born-HA instance, synced once-timers and next_due, plus an S-born native sidecar. Include a future-due timer to verify the adopter's unclean marker before leaving the host asleep; +48h and sequential-departure tests use the local virtual-clock/root witnesses, not an extension of the two-hour live approval. Use real worker/sleep paths. Read exact manifest/wake digests and record UTC sync acknowledgments; preserve token/key fingerprints without printing secrets. Keep all visitor probes off after setup. T's earlier restricted drill omits sidecar only under an explicit restricted acceptance label, never a full 5B PASS. |
| +- [ ] **Step 5: Terminate C through EC2 and observe unattended recovery.** Log API time, confirmed terminated state, successful immutable proof PUT/key/digest, original expiry, queue receipt, scan/import transaction, zero-match completion rescan, timer delivery and conditional edges deletion/index/ack. No start before expiry; for held work measure remaining TTL separately from scan/delivery latency. Normal event bound includes event/describe latency, remaining lease, a qualifying full inventory refresh (up to the existing 33m backstop bound), `2*ceil(N/32)*30s` scan/finalization plus final-rescan scheduling allowance for one active departure (multiply page wait by concurrent K under fair scheduling, add bounded I/O/retry time) and ≤30s delivery sweep plus restore; future-due timers are measured from their due time. Do not quote the pre-fencing 1–3m estimate as a guarantee. Reader convergence after acknowledged index is about 30s. |
| - [ ] **Step 6: Exercise partial scanner death safely.** Local multi-process/root witnesses already prove another-registry recovery. Keep live scope to the disposable third box; use the separate-process rootrunner witness to kill the confirming scanner after one import and resume on another survivor, without adding a fourth live box or terminating sophie/leo. Attach that exact built-revision result to the card and label the fault as local production-path coverage, not a live kill on dev. No production fault flag, fake EC2 proof or drained flag. Queue redelivery/age retry must recover remaining hosts without a visitor. |
| -- [ ] **Step 7: Prove loss bound and cleanup.** Every recorded timer/next_due due within the live window delivered; future-due timers retain a verified adopter marker and match the attached +48h local witness; only an intentionally unsynced final ~1s timer may be lost. H7 duplicate delivery is recorded, not called exactly-once. Compare the built revision's counting-transport budget report; journals cannot prove exact AWS API counts. Remove approved disposable resources and temporary records/prefixes, restore prior config through the release operator, verify sophie/leo instance IDs and `CARLOS_REGION` unchanged, consumers/pair healthy and no scratch/processes left. Keep app logs/evidence specified by the card. Report pass/fail and timings to the controller for #421; no flagship roll or G3 claim. |
| +- [ ] **Step 7: Prove loss bound and cleanup.** Every recorded timer/next_due due within the live window delivered; future-due timers retain a verified adopter marker and match the attached +48h local witness; only an intentionally unsynced final ~1s timer may be lost. H7 duplicate delivery is recorded, not called exactly-once. Compare the built revision's counting-transport budget report; journals cannot prove exact AWS API counts. Remove approved disposable resources and temporary records/prefixes, retaining C's N-HA16 proof under its stated retention contract, restore prior config through the release operator, verify sophie/leo instance IDs and `CARLOS_REGION` unchanged, consumers/pair healthy and no scratch/processes left. Keep app logs/evidence specified by the card. Report pass/fail and timings to the controller for #421; no flagship roll or G3 claim. |
| ## Drain integration hook, deliberately not wired |
| @@ -339,19 +391,19 @@ Reserve the name `EnqueueDrained` for P3's future verified drain-completion inpu |
| ## Copy deck for controller → Luna |
| -Draft source strings from rev 1, unchanged. Before implementation, revise the deck for terminal scope refusal and permission faults: C3 retry wording is only for transient failures, C7/C8 need the reconfiguration/refusal context, and C10 must not promise automatic resumption after a scope fault. Route those revisions through the controller's copy approval before product writes. No Luna invocation or approval claimed. Obtain accepted text before writing product destinations; preserve placeholders and IDs. Structured field names, metric identifiers and internal sentinel errors are not prose, but wrapping them in notices is. Inventory any additional strings discovered during implementation rather than quietly shipping them. |
| +Draft source strings from rev 1 remain unchanged and unapproved. Before implementation, revise their contexts/text for N-HA17: C7/C8 describe a blocked departure rather than consumer startup refusal; C3 must distinguish retryable failures from unsupported hosts needing correction; C10 reports cancellation and must not promise successful recovery of unsupported duties. Remove obsolete consumer rearm wording. Page limits follow the durable per-departure rate above. Route those revisions through the controller's copy approval before product writes. No Luna invocation or approval claimed. Obtain accepted text before writing product destinations; preserve placeholders and IDs. Structured field names, metric identifiers and internal sentinel errors are not prose, but wrapping them in notices is. Inventory any additional strings discovered during implementation rather than quietly shipping them. |
| | ID | Destination | Draft text | Context / constraints | |
| |---|---|---|---| |
| | HA3-C3 | `internal/host/hadepartures.go`, recovery warning body | Duties from box %s have not been recovered. The scan will retry. Check the box's wake state before removing its records. | Incomplete scan; append a sanitized cause separately. Never imply it is safe to delete. | |
| -| HA3-C3-subject | Same warning's PageOperator subject | Duties from box %s need attention | Pair with C3, warning, once/departure/hour/process. | |
| +| HA3-C3-subject | Same warning's PageOperator subject | Duties from box %s need attention | Pair with C3; once/departure/hour/receiver, persisted across restart. | |
| | HA3-C4 | `internal/host/hadepartures.go`, completion notice | Recovered duties for %d instances from box %s. | Only durable completed recovery; count hosts including native sidecars after S. Not proof every timer fired. | |
| | HA3B-C5 | Consumer startup refusal/status | Termination recovery has not started: %s. | Sanitized reason: missing queue setting, invalid identity, client or journal failure. No receipt, credential or private path. | |
| | HA3B-C6 | Consumer recovery warning | Termination recovery is retrying after a queue error. | Runtime transient; does not order restart/replacement or clear P3's latched admission. | |
| -| HA3B-C7 | Coverage refusal/status | Duties for instance %s need a box that serves pool %s. Recovery is incomplete. | Operator only; render the empty pool as “shared” without treating it as wildcard. No suggestion to change CARLOS_REGION. | |
| -| HA3B-C8 | Unsupported native-sidecar coverage | Duties for sidecar %s cannot be recovered by this version. Keep the departure records and upgrade before retrying. | T only, or legacy sidecar unsupported by S; must not promise retry alone fixes it. | |
| +| HA3B-C7 | Per-departure blocked-host status | Duties for instance %s need a box that serves pool %s. Recovery is incomplete. | Operator only; render the empty pool as “shared” without treating it as wildcard. No suggestion to change CARLOS_REGION. | |
| +| HA3B-C8 | Per-departure unsupported native sidecar | Duties for sidecar %s cannot be recovered by this version. Keep the departure records and upgrade before retrying. | T only, or legacy sidecar unsupported by S; blocks that departure, never Started/Running. Text needs revision before use; upgrading alone does not migrate a legacy sidecar. | |
| | HA3B-C9 | Startup success log | Termination recovery is running. | Emit after genuine Started acknowledgment, never constructor entry. | |
| -| HA3B-C10 | Completion after cancellation | Termination recovery has stopped. Pending recovery will resume on restart. | Emit after Done; do not emit when bounded Stop timed out. | |
| +| HA3B-C10 | Completion after cancellation | Termination recovery has stopped. Pending recovery will resume on restart. | Draft requires revision before use: Done means cancelled, not guaranteed recovery. Do not emit when bounded Stop timed out. | |
| S's console refusal copy must reuse accepted P2a wording where semantics match; new sidecar-specific strings require a supplemental deck before code. No new visitor error is needed: existing HA refusal/503 behavior remains. |
| @@ -359,17 +411,17 @@ S's console refusal copy must reuse accepted P2a wording where semantics match; |
| This Markdown plan is outside the census; generate no overlay now. Execution changes root-binary dependencies `internal/{activator,host,edge,termfence}` and also registry, provision, hostfiles, lease, release, hostenv and new adapter/core packages. Linux amd64/arm64 dependency union, whole-file envelopes and test-source changes all count. “Agent-run” is no exemption; schema and remote-dispatch changes need review. Any module/config delivery change brings its infra/unit envelope too. |
| -At each implementation slice's final diff: `make census-card`; write tab-separated CLAIMS under owned `/home/paulca/t/`; `make census-propose NAME=region-ha-p1b3b-t CLAIMS=<file>` (S uses its own branch name). Review each unit/envelope against current amadan main, including the new callback's refusal-only property, identity-to-key derivation, local transaction authority, remote registry inputs and conditional delete/index ordering. Run targeted `TestPlan14RootReadCensus|TestCensusScopeIsTheRootBinary|TestPlan14RootInputInventoryCoverage|TestCensusRebaseCarriesDispositions`; check record-write inventories for B6, with no blind digest updates. Independent cross-family reviewer decides every census class and records the tip/verdict on #280; no census unit escalates to Paul. |
| +At each implementation slice's final diff: `make census-card`; write tab-separated CLAIMS under owned `/home/paulca/t/`; `make census-propose NAME=region-ha-p1b3b-t CLAIMS=<file>` (S uses its own branch name). Review each unit/envelope against current amadan main, including the new callback's refusal-only property, identity-to-key derivation, proof-prefix writer/read trust and acquire-only use, local transaction authority, remote registry inputs and conditional delete/index ordering. Run targeted `TestPlan14RootReadCensus|TestCensusScopeIsTheRootBinary|TestPlan14RootInputInventoryCoverage|TestCensusRebaseCarriesDispositions`; check record-write inventories for B6, with no blind digest updates. Independent cross-family reviewer decides every census class and records the tip/verdict on #280; no census unit escalates to Paul. |
| The rootrunner witness must run with the built revision, not a stale `CARLOS_BIN`, and record its result/artifact. Shell-out CLI tests use `carlosTestEnv` and scratch cwd. Compile non-Linux tests and the new SDK adapter on Darwin/Windows; run linux/arm64 size check. Once those and the repo gate pass, broaden testing only for a new failure/change. A skipped witness or red package remains a defect. |
| ## Open questions for Paul and explicit limits |
| -1. **Native sidecars:** approve S's proposed **birth-only HA sidecar extension**, or defer standalone-sidecar acceptance and keep T/P3a activation restricted to scopes with no such duties? Recommendation: land the useful T slice first, then approve S; do not silently reverse P1a's legacy-sidecar rule. Full §7/5B acceptance requires S or an explicitly revised scope. |
| +1. **Native sidecars:** approve S's proposed **birth-only HA sidecar extension**, or defer standalone-sidecar recovery acceptance while T/P3a consumers still run and unresolved departures remain open? Recommendation: land the useful T slice first, then approve S; do not silently reverse P1a's legacy-sidecar rule. Full §7/5B acceptance requires S or an explicitly revised scope. |
| 2. **Switch-on slot:** reserve the next dev-only T release and restricted unattended-timer drill, then review the fully populated disposable-box card for S/5B. No resource mutation approval is requested by this planning commit. |
| -The bounded scanner-death acceptance is death before whole-scan completion, as §7.4 and the parent outline specify. Sequential departures **after** completed adoption are also required: the central finalizer makes the adopted host name its current duty owner before completion. Pool-restricted receivers and legacy-sidecar scopes refuse before polling; a later coverage violation suspends and escalates. Permanent object loss or failure to obtain the **initial** termination proof before EC2 forgets remains unresolved and must be reported, never guessed. Completed adoption must survive expired confirmation caches, agent restart and a visitor on a box that never confirmed the original owner. Drain acceptance and group-wide liveness wait for their real producers and drills. |
| +The bounded scanner-death acceptance is death before whole-scan completion, as §7.4 and the parent outline specify. Sequential departures **after** completed adoption are also required: the central finalizer makes the adopted host name its current duty owner before completion. Pool-restricted receivers start and poll; unsupported hosts keep only their departure open and page at the bounded rate. Permanent proof/object loss or failure to persist the **initial** proof before the live evidence is lost remains an explicit operator fault, never guessed. Once the N-HA16 object exists, delayed finalization and takeover survive EC2 forgetting and loss of every in-memory cache. Completed adoption must survive expired confirmation caches, agent restart and a visitor on a box that never confirmed the original owner. Drain acceptance and group-wide liveness wait for their real producers and drills. |
| ## Self-review record |
| -Coverage: §7.1–7.3 → B1/B2, with native-sidecar gap made explicit in S/B6; §7.4/I3 → B2/B4/B5; §4 identity/home scope → B3; §9/N-HA9/N-HA11 → B3/B4; §18 → counted event/pass/quiet formulas; §19 → T first visible merge and activation slot; §20 → B5 and card; §21 → I6 mutations and real process witnesses. P3 receives a provider-neutral, independent lifecycle interface with no drain dependency. Review Focus cases have named tests. Rev 2 verified the findings against worktree code and read main's placementNull correction without rebasing; the Base paragraph defines citation provenance. Round 1 remains NOT READY; no second review was run. Planning validation is file/citation/format/diff checks only; no full suites, production code, reviewers, push or live drill. |
| +Coverage: §7.1–7.3 → B1/B2, with native-sidecar gap made explicit in S/B6; §7.4/I3 → B2/B4/B5; §4 identity/home scope → B3; §9/N-HA9/N-HA11 → B3/B4; §18 → counted event/pass/quiet formulas; §19 → T first visible merge and activation slot; §20 → B5 and card; §21 → I6 mutations and real process witnesses. P3 receives a provider-neutral, independent lifecycle interface with no drain dependency. Review Focus cases have named tests. Rev 3 checked R2 against the worktree confirmer, acquire and root credential seam, retained the existing placement citations and applied Paul's N-HA15/N-HA16/N-HA17 instructions without rebasing. R2 remains NOT READY; stopping rule 2 was resolved by Paul's rulings, not by a reviewer. One final round 3 remains and was not dispatched. R2 P3-1's durable negative cache is the named follow-up; its churn cost is budgeted now. Planning validation is file/citation/format/diff checks only; no full suites, production code, reviewers, push or live drill. |