carlos / platform Public

region HA: departed boxes' duties recover unattended (P1b-3b T)

Slice T of the P1b-3b plan (docs/superpowers/plans/2026-11-03-region-ha-p1b3b-duties.md, rev 4). A terminated box's durable timers and due wakes are recovered by a surviving box without visitor traffic. Native-sidecar HA (slice S, B6) and the 5B drill are deferred.

- B1: one local duty gate (DecideDuty, AcquireHAForDuty restriction-only) before token, RunPick and exec on every producer.
- B2: AdoptHost: atomic wake import, ordinary acquire after strict expiry, unclean self-marker release verified by readback.
- B3: one SQS termination consumer per box, N-HA16 durable termination proof (data bucket, lock region, acquire-only), verified box-identity history, inventory and edge departure tick.
- B4: full zero-match rescan before completion; group refs delete only the exact edges ETag, fixed refs never delete edges (operator removes them; hourly page); queue ack only after durable completion.
- B5: I6 simulation on production predicates (3000 seeds; 26 mutations caught, 9 model-only mapped to unit tests), production wiring and root lifecycle witnesses (root runner PASS).
- Unbound or unverifiable owner identity falls back to the live-EC2 takeover check (P1b-1 behaviour) with alarms.

Interface for P3a: armHADepartures returns hadeparture.Lifecycle {Started(), Done(), Running(), Stop(ctx)}. Started closes after the first successful SQS Receive (empty counts), within 30 s when healthy, and never waits on inventory or coverage. Done closes after cancellation joins all work. Gate admission on Started, not Running (Running is true while startup retries). runAgent holds the lifecycle locally; P3a must pass it out.

Dormant unless CARLOS_REGION_HA=1; the consumer needs CARLOS_TERMINATION_QUEUE_URL (host.env), and fixed boxes use CARLOS_HA_FIXED_BOX_IDENTITIES. Reviews: Opus per task B1-B4 and whole branch (READY); census census-ruling-region-ha-p1b3b-t approved by Opus on #280 at 767eafbc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from region-ha-p1b3b-duties into main.
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 9b8b2c507cf8fc854f684b1c40b8c4b5d68d7eaf parent 0c2ab2e
124 files changed, +17,147 −564
  • docs/superpowers/notes/census-proposal-region-ha-p1b3b-t.md +148 −0
  • docs/superpowers/notes/census-region-ha-p1b3b-t-claims.md +110 −0
  • docs/superpowers/plans/2026-11-03-region-ha-p1b3b-duties.md +447 −0
  • docs/superpowers/plans/REVIEW-BRIEF-REGION-HA-P1B3B-R1.md +27 −0
  • docs/superpowers/plans/REVIEW-BRIEF-REGION-HA-P1B3B-R2.md +30 −0
  • docs/superpowers/plans/REVIEW-REGION-HA-P1B3B-R1.md +87 −0
  • docs/superpowers/plans/REVIEW-REGION-HA-P1B3B-R2.md +72 −0
  • docs/superpowers/plans/REVIEW-REGION-HA-P1B3B-R3.md +56 −0
  • go.mod +1 −0
  • go.sum +2 −0
  • internal/activator/activator.go +36 −5
  • internal/activator/backend_exec.go +11 −0
  • internal/activator/haadopt.go +412 −0
  • internal/activator/haadopt_test.go +761 −0
  • internal/activator/haduties.go +426 −0
  • internal/activator/haduties_test.go +493 −0
  • internal/activator/haforward.go +5 −0
  • internal/activator/harelease.go +1 −0
  • internal/activator/hasuspect_test.go +22 −0
  • internal/activator/hatakeover.go +23 −8
  • internal/activator/hawake.go +45 −2
  • internal/activator/termination_credentials_test.go +42 −0
  • internal/activator/termination_proof_test.go +116 −0
  • internal/awsterminations/queue.go +155 −0
  • internal/awsterminations/queue_test.go +102 −0
  • internal/boxchoice/coldwake.go +1 −0
  • internal/edge/edge.go +2 −1
  • internal/edge/hadepartures.go +38 −0
  • internal/edge/hadepartures_test.go +71 −0
  • internal/edge/homemap.go +18 −4
  • internal/edge/wakeplacement.go +11 −1
  • internal/hadeparture/consumer.go +240 −0
  • internal/hadeparture/consumer_test.go +375 −0
  • internal/hadeparture/types.go +52 −0
  • internal/host/agent.go +38 −1
  • internal/host/egress_source_test.go +3 −0
  • internal/host/hadeparture_credentials_test.go +37 −0
  • internal/host/hadeparture_identity.go +404 −0
  • internal/host/hadeparture_identity_test.go +188 −0
  • internal/host/hadepartures.go +546 −0
  • internal/host/hadepartures_fix_test.go +554 −0
  • internal/host/hadepartures_harness_test.go +74 −0
  • internal/host/hadepartures_metrics.go +73 −0
  • internal/host/hadepartures_metrics_test.go +74 −0
  • internal/host/hadepartures_production_test.go +410 −0
  • internal/host/hadepartures_rebind_test.go +490 −0
  • internal/host/hadepartures_retained_test.go +341 −0
  • internal/host/hadepartures_root_linux_test.go +455 −0
  • internal/host/hadepartures_scan.go +549 −0
  • internal/host/hadepartures_scan_test.go +801 −0
  • internal/host/hadepartures_test.go +88 −0
  • internal/host/hadepartures_wiring.go +228 −0
  • internal/host/hadepartures_wiring_test.go +622 −0
  • internal/host/haduties_wiring_test.go +226 −0
  • internal/host/haplacement_root_linux_test.go +19 −2
  • internal/host/metrics_loop.go +15 −8
  • internal/host/runrelay_linux_test.go +37 −0
  • internal/host/runs.go +48 −1
  • internal/host/schedule_wiring.go +13 −1
  • internal/hostenv/hostenv.go +36 −6
  • internal/hostenv/write_linux_test.go +61 −0
  • internal/hostfiles/wake.go +53 −28
  • internal/hostfiles/wake_test.go +99 −3
  • internal/lease/ha.go +37 −4
  • internal/lease/ha_test.go +26 −0
  • internal/lease/haduty_test.go +112 −0
  • internal/lease/termination_binding_test.go +31 −0
  • internal/lease/termination_proof.go +108 −0
  • internal/lease/termination_proof_test.go +277 −0
  • internal/metrics/sample.go +19 −3
  • internal/objstore/termination_credentials_test.go +62 −0
  • internal/provision/departure_inventory.go +114 −0
  • internal/provision/departure_inventory_test.go +119 −0
  • internal/provision/plan9_b8_census_test.go +1 −1
  • internal/provision/reconcile.go +18 −7
  • internal/provision/recordview.go +2 −0
  • internal/provision/recordview_store.go +17 −7
  • internal/provision/region_ha_departure_census_test.go +25 −0
  • internal/provision/sidecar_reconcile.go +16 −4
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-region-ha-p1b3b-t.tsv +237 −0
  • internal/registry/claimreview_test.go +3 −0
  • internal/registry/forward_writers_test.go +7 −1
  • internal/registry/ha_adoption_phase_test.go +23 −0
  • internal/registry/ha_departures.go +337 −0
  • internal/registry/ha_duties.go +167 −0
  • internal/registry/ha_duties_test.go +393 −0
  • internal/registry/ha_identity_history.go +107 −0
  • internal/registry/ha_identity_history_test.go +89 −0
  • internal/registry/ha_journal.go +552 −0
  • internal/registry/ha_journal_test.go +352 −0
  • internal/registry/ha_scan.go +124 −0
  • internal/registry/ha_test.go +3 −0
  • internal/registry/hold_test.go +3 −0
  • internal/registry/importjournal_test.go +6 −0
  • internal/registry/registry.go +4 −1
  • internal/registry/registry_test.go +12 −0
  • internal/registry/remote.go +1 −1
  • internal/registry/remote_dispatch.go +126 −95
  • internal/registry/timers.go +17 −0
  • internal/release/conditional_delete.go +55 −0
  • internal/release/conditional_delete_test.go +89 −0
  • internal/release/openers_test.go +1 −0
  • internal/schedule/cron.go +3 −165
  • internal/schedule/haduties_test.go +127 −0
  • internal/schedule/mingap.go +1 −64
  • internal/schedule/runner.go +38 −1
  • internal/schedule/spec.go +10 −124
  • internal/sim/regionha/duties_model_test.go +701 −0
  • internal/sim/regionha/duties_test.go +28 −0
  • internal/sim/regionha/duty_boundaries_test.go +219 −0
  • internal/sim/regionha/mutate-startup.sh +28 −0
  • internal/sim/regionha/mutate.sh +37 −4
  • internal/sim/regionha/mutation_evidence_test.go +39 −0
  • internal/sim/regionha/rules_test.go +35 −0
  • internal/sim/regionha/witness_test.go +41 −1
  • internal/sim/regionha/world_test.go +2 −0
  • internal/termfence/confirm.go +22 −6
  • internal/termfence/confirm_test.go +14 −4
  • internal/termfence/termination_proof.go +348 −0
  • internal/termfence/termination_proof_test.go +372 −0
  • internal/timerspec/cron.go +169 −0
  • internal/timerspec/mingap.go +66 −0
  • internal/timerspec/spec.go +134 −0

CI passed — run details

docs/superpowers/notes/census-proposal-region-ha-p1b3b-t.md

Loading diff…

docs/superpowers/notes/census-region-ha-p1b3b-t-claims.md

Loading diff…

docs/superpowers/plans/2026-11-03-region-ha-p1b3b-duties.md

Loading diff…

docs/superpowers/plans/REVIEW-BRIEF-REGION-HA-P1B3B-R1.md

Loading diff…

docs/superpowers/plans/REVIEW-BRIEF-REGION-HA-P1B3B-R2.md

Loading diff…

docs/superpowers/plans/REVIEW-REGION-HA-P1B3B-R1.md

Loading diff…

docs/superpowers/plans/REVIEW-REGION-HA-P1B3B-R2.md

Loading diff…

docs/superpowers/plans/REVIEW-REGION-HA-P1B3B-R3.md

Loading diff…

go.mod

Loading diff…

go.sum

Loading diff…

internal/activator/activator.go

Loading diff…

internal/activator/backend_exec.go

Loading diff…

internal/activator/haadopt.go

Loading diff…

internal/activator/haadopt_test.go

Loading diff…

internal/activator/haduties.go

Loading diff…

internal/activator/haduties_test.go

Loading diff…

internal/activator/haforward.go

Loading diff…

internal/activator/harelease.go

Loading diff…

internal/activator/hasuspect_test.go

Loading diff…

internal/activator/hatakeover.go

Loading diff…

internal/activator/hawake.go

Loading diff…

internal/activator/termination_credentials_test.go

Loading diff…

internal/activator/termination_proof_test.go

Loading diff…

internal/awsterminations/queue.go

Loading diff…

internal/awsterminations/queue_test.go

Loading diff…

internal/boxchoice/coldwake.go

Loading diff…

internal/edge/edge.go

Loading diff…

internal/edge/hadepartures.go

Loading diff…

internal/edge/hadepartures_test.go

Loading diff…

internal/edge/homemap.go

Loading diff…

internal/edge/wakeplacement.go

Loading diff…

internal/hadeparture/consumer.go

Loading diff…

internal/hadeparture/consumer_test.go

Loading diff…

internal/hadeparture/types.go

Loading diff…

internal/host/agent.go

Loading diff…

internal/host/egress_source_test.go

Loading diff…

internal/host/hadeparture_credentials_test.go

Loading diff…

internal/host/hadeparture_identity.go

Loading diff…

internal/host/hadeparture_identity_test.go

Loading diff…

internal/host/hadepartures.go

Loading diff…

internal/host/hadepartures_fix_test.go

Loading diff…

internal/host/hadepartures_harness_test.go

Loading diff…

internal/host/hadepartures_metrics.go

Loading diff…

internal/host/hadepartures_metrics_test.go

Loading diff…

internal/host/hadepartures_production_test.go

Loading diff…

internal/host/hadepartures_rebind_test.go

Loading diff…

internal/host/hadepartures_retained_test.go

Loading diff…

internal/host/hadepartures_root_linux_test.go

Loading diff…

internal/host/hadepartures_scan.go

Loading diff…

internal/host/hadepartures_scan_test.go

Loading diff…

internal/host/hadepartures_test.go

Loading diff…

internal/host/hadepartures_wiring.go

Loading diff…

internal/host/hadepartures_wiring_test.go

Loading diff…

internal/host/haduties_wiring_test.go

Loading diff…

internal/host/haplacement_root_linux_test.go

Loading diff…

internal/host/metrics_loop.go

Loading diff…

internal/host/runrelay_linux_test.go

Loading diff…

internal/host/runs.go

Loading diff…

internal/host/schedule_wiring.go

Loading diff…

internal/hostenv/hostenv.go

Loading diff…

internal/hostenv/write_linux_test.go

Loading diff…

internal/hostfiles/wake.go

Loading diff…

internal/hostfiles/wake_test.go

Loading diff…

internal/lease/ha.go

Loading diff…

internal/lease/ha_test.go

Loading diff…

internal/lease/haduty_test.go

Loading diff…

internal/lease/termination_binding_test.go

Loading diff…

internal/lease/termination_proof.go

Loading diff…

internal/lease/termination_proof_test.go

Loading diff…

internal/metrics/sample.go

Loading diff…

internal/objstore/termination_credentials_test.go

Loading diff…

internal/provision/departure_inventory.go

Loading diff…

internal/provision/departure_inventory_test.go

Loading diff…

internal/provision/plan9_b8_census_test.go

Loading diff…

internal/provision/reconcile.go

Loading diff…

internal/provision/recordview.go

Loading diff…

internal/provision/recordview_store.go

Loading diff…

internal/provision/region_ha_departure_census_test.go

Loading diff…

internal/provision/sidecar_reconcile.go

Loading diff…

internal/provision/testdata/plan14-root-reads-chain.tsv

Loading diff…

internal/provision/testdata/plan14-root-reads-region-ha-p1b3b-t.tsv

Loading diff…

internal/registry/claimreview_test.go

Loading diff…

internal/registry/forward_writers_test.go

Loading diff…

internal/registry/ha_adoption_phase_test.go

Loading diff…

internal/registry/ha_departures.go

Loading diff…

internal/registry/ha_duties.go

Loading diff…

internal/registry/ha_duties_test.go

Loading diff…

internal/registry/ha_identity_history.go

Loading diff…

internal/registry/ha_identity_history_test.go

Loading diff…

internal/registry/ha_journal.go

Loading diff…

internal/registry/ha_journal_test.go

Loading diff…

internal/registry/ha_scan.go

Loading diff…

internal/registry/ha_test.go

Loading diff…

internal/registry/hold_test.go

Loading diff…

internal/registry/importjournal_test.go

Loading diff…

internal/registry/registry.go

Loading diff…

internal/registry/registry_test.go

Loading diff…

internal/registry/remote.go

Loading diff…

internal/registry/remote_dispatch.go

Loading diff…

internal/registry/timers.go

Loading diff…

internal/release/conditional_delete.go

Loading diff…

internal/release/conditional_delete_test.go

Loading diff…

internal/release/openers_test.go

Loading diff…

internal/schedule/cron.go

Loading diff…

internal/schedule/haduties_test.go

Loading diff…

internal/schedule/mingap.go

Loading diff…

internal/schedule/runner.go

Loading diff…

internal/schedule/spec.go

Loading diff…

internal/sim/regionha/duties_model_test.go

Loading diff…

internal/sim/regionha/duties_test.go

Loading diff…

internal/sim/regionha/duty_boundaries_test.go

Loading diff…

internal/sim/regionha/mutate-startup.sh

Loading diff…

internal/sim/regionha/mutate.sh

Loading diff…

internal/sim/regionha/mutation_evidence_test.go

Loading diff…

internal/sim/regionha/rules_test.go

Loading diff…

internal/sim/regionha/witness_test.go

Loading diff…

internal/sim/regionha/world_test.go

Loading diff…

internal/termfence/confirm.go

Loading diff…

internal/termfence/confirm_test.go

Loading diff…

internal/termfence/termination_proof.go

Loading diff…

internal/termfence/termination_proof_test.go

Loading diff…

internal/timerspec/cron.go

Loading diff…

internal/timerspec/mingap.go

Loading diff…

internal/timerspec/spec.go

Loading diff…