carlos / platform Public

ha departures: a delivered page marker is only cleared by removal

Astra round 3: a transient identity-read failure sent the hint down the
ordinary retry, which overwrote the "<code> paged" marker and re-armed
the page. Paul chose option 1 (2026-11-22): every last_error write on
ha_pending_terminations goes through one CASE expression that keeps a
paged marker, and retry_hint_once treats any marker as delivered. Only
removing the hint clears it. Guard test runs every op sequence from a
marked hint. Census re-proposed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 4d20b18aa8b12cb8c048675aa834a8de322ac3b9 parent 5dde031
5 files changed, +126 −12
  • docs/superpowers/notes/census-proposal-ha-departure-evidence.md +2 −2
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv +3 −3
  • internal/registry/ha_journal.go +14 −6
  • internal/registry/ha_journal_test.go +106 −0

CI cancelled — superseded by a newer push — run details

CI log
=== gate ===
go: downloading go1.26.10 (linux/arm64)
go version go1.26.10 linux/arm64
opentofu: arm64, tofu 1.13.9, aws 6.73.0, archive 2.8.1
  tofu: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/tofu_1.13.9_linux_arm64.tar.gz
  tofu: downloaded, digest verified
  aws: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-aws_6.73.0_linux_arm64.zip
  aws: downloaded, digest verified
  archive: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-archive_2.8.1_linux_arm64.zip
  archive: downloaded, digest verified
  installed in /tmp/carlos-opentofu-t0VbYS
.amadan/test-gate.sh
go: downloading github.com/aws/aws-sdk-go-v2 v1.44.0
go: downloading github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.68.0
go: downloading github.com/aws/aws-sdk-go-v2/service/costexplorer v1.67.5
go: downloading github.com/aws/aws-sdk-go-v2/service/s3 v1.105.0
go: downloading github.com/aws/smithy-go v1.28.1
go: downloading github.com/benbjohnson/litestream v0.5.14
go: downloading github.com/superfly/ltx v0.5.1
go: downloading modernc.org/sqlite v1.55.0
go: downloading golang.org/x/net v0.62.0
go: downloading github.com/aws/aws-sdk-go-v2/config v1.32.6
go: downloading github.com/aws/aws-sdk-go-v2/service/sns v1.43.0
go: downloading github.com/aws/aws-sdk-go-v2/service/acm v1.45.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ec2 v1.324.0
go: downloading github.com/aws/aws-sdk-go-v2/service/iam v1.58.2
go: downloading github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi v1.37.0
go: downloading github.com/aws/aws-sdk-go-v2/service/route53 v1.64.1
go: downloading github.com/aws/aws-sdk-go-v2/service/sts v1.45.6
go: downloading golang.org/x/sys v0.49.0
go: downloading golang.org/x/crypto v0.58.0
go: downloading github.com/aws/aws-sdk-go-v2/credentials v1.19.6
go: downloading github.com/pion/logging v0.2.4
go: downloading github.com/pion/stun/v3 v3.1.5
go: downloading github.com/pion/turn/v4 v4.1.4
go: downloading github.com/aws/aws-sdk-go-v2/service/sesv2 v1.66.6
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.40
go: downloading github.com/aws/aws-sdk-go-v2/service/signin v1.0.4
go: downloading github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.38
go: downloading github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.40
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.23
go: downloading github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.31
go: downloading github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.40
go: downloading golang.org/x/text v0.43.0
go: downloading github.com/prometheus/client_golang v1.17.0
go: downloading github.com/lmittmann/tint v1.1.3
go: downloading github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.20.18
go: downloading github.com/pion/transport/v4 v4.0.2
go: downloading github.com/pion/dtls/v3 v3.1.4
go: downloading github.com/pion/randutil v0.1.0
go: downloading github.com/prometheus/client_model v0.5.0
go: downloading github.com/prometheus/common v0.45.0
go: downloading google.golang.org/protobuf v1.36.10
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/prometheus/procfs v0.12.0
go: downloading github.com/cespare/xxhash/v2 v2.3.0
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading github.com/pion/dtls/v3 v3.1.4
go: downloading github.com/pion/transport/v4 v4.0.2
go: downloading github.com/prometheus/client_model v0.5.0
go: downloading github.com/prometheus/procfs v0.12.0
go: downloading github.com/wlynxg/anet v0.0.5
go: downloading github.com/wlynxg/anet v0.0.5
go: downloading modernc.org/libc v1.74.1
go: downloading modernc.org/libc v1.74.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/dustin/go-humanize v1.0.1

amadan: job cancelled — a newer push superseded it

Intent

Human

<task-notification> <task-id>bvg5ev63k</task-id> <tool-use-id>toolu_013zXzoKFSgPd1i7mrk5Aqfz</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/70d5e8d6-dd7c-4158-81af-7774784da3d3/tasks/bvg5ev63k.output</output-file> <status>completed</status> <summary>Background command "Run Astra review round 3 in the background" completed (exit code 0)</summary> </task-notification>

Human

<paseo-system version="1" kind="agent-message" source-agent-id="8a3d302a-eac7-407c-b61c-f5ccc66b5544" message-id="74644fb0-f51d-47ef-96c3-c7a4ced63d89"> From 8a3d302: Paul says option 1 is fine (2026-11-22, in the HA session): enforce the invariant in one place (the ordinary retry_hint write never replaces a last_error ending in &quot; paged&quot;; only hint removal clears it), with the guard test over every op sequence. One scoped Astra check of that diff (round 4, approved by Paul). If it raises another P1 in the same family, stop and tell me rather than fixing again. Then CI, merge, SHA to me. </paseo-system>

diff --git a/docs/superpowers/notes/census-proposal-ha-departure-evidence.md b/docs/superpowers/notes/census-proposal-ha-departure-evidence.md
index d0d43febb..1aab8793b 100644
--- a/docs/superpowers/notes/census-proposal-ha-departure-evidence.md
+++ b/docs/superpowers/notes/census-proposal-ha-departure-evidence.md
@@ -6,7 +6,7 @@ Ruling `census-ruling-ha-departure-evidence`. The independent reviewer approves
|---|---|---|---|
| `internal/host/hadepartures.go` `Controller.step` | sites | +whole:HAPendingTermination ×2 | A pending hint whose bound identity has an unknown or placement-null observation gets code evidence_no_observation: no enqueue, no enrollment, no completion or takeover authority. It claims a page through the new retry_hint_once op (falling back to the ordinary hourly retry if the server refuses it) and marks the hint paged only after PageIdentity succeeds. Reads only the local journal. Round 2: the page-once claim falls back to the ordinary hourly retry only on ErrHAJournal (an older server's refusal); any other journal error fails the pass so a delivered marker is never overwritten. No new read or authority. |
| `internal/host/hadepartures_wiring.go` `armHADepartures` | sites | -registry:Account, -registry:IID, -registry:Region | The PageIdentity closure moved to the named pageDeparturePending; same fields read, now there instead of here. |
-| `internal/registry/ha_journal.go` `Registry.haJournal` | sites | +file:QueryRowContext, +registry:Account ×4, +registry:At ×5, +registry:Code ×8, +registry:Found ×2, +registry:Hint ×2, +registry:IID ×4, +registry:Region ×4, +registry:sql, +whole:HAPendingTermination ×2, +whole:haJournalResponse ×8 | New ops retry_hint_once (reads the hint's own last_error, claims the existing global hourly page slot, writes next_attempt/last_page/last_error) and hint_paged (sets last_error to code plus paged when it still equals code). Same tables, same transaction helper, no new authority. |
+| `internal/registry/ha_journal.go` `Registry.haJournal` | sites | +file:QueryRowContext, +registry:Account ×4, +registry:At ×5, +registry:Code ×7, +registry:Found ×2, +registry:Hint ×2, +registry:IID ×4, +registry:Region ×4, +registry:sql, +whole:HAPendingTermination ×2, +whole:haJournalResponse ×8 | New ops retry_hint_once (reads the hint's own last_error, claims the existing global hourly page slot, writes next_attempt/last_page/last_error) and hint_paged (sets last_error to code plus paged when it still equals code). Same tables, same transaction helper, no new authority. Round 4 (Paul's option 1): every last_error write on ha_pending_terminations goes through hintLastError, a CASE that keeps a value ending in ' paged'; retry_hint_once treats any paged marker as delivered. Only hint removal clears it. No new table, read or authority. |
Envelopes re-pinned: `internal/alerting`, `internal/host`, `internal/registry`.
@@ -24,6 +24,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/registry/ha_journal.go:Registry.MarkPendingTerminationPaged`: reads +whole:HAPendingTermination ×2; written legacy, accepted-legacy, frozen
- new `internal/registry/ha_journal.go:Registry.RetryPendingTerminationOnce`: reads +registry:Found, +whole:HAPendingTermination ×2; written legacy, accepted-legacy, frozen
-Seal: `9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0` → `9b0747c10be3a45d8c9c3db1f69992a87714f999c8fbb666b910bccd3ce2be74`.
+Seal: `9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0` → `924ffc4037d32d7b46af1e373bad1476fc7305833fc6c06d50d5c8c3ab5ac177`.
Overlay: `internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 2d4ba440c..7ba03ddc7 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -278,4 +278,4 @@ plan14-root-reads-stateless-scale-1-memory-env.tsv 47ebd73418bcbe1bdf9cf34a2b94e
plan14-root-reads-group-revoke-readback-1255.tsv 47ebd73418bcbe1bdf9cf34a2b94e3393a1279aea58f9ee0aca3f0cfe42b9132
plan14-root-reads-precert-dns01-1293.tsv b2f039a12bb284c9a36b391339e25e3f77ec94a3d4e38389ec9ef75261d7873f
plan14-root-reads-fleet-client-address-1348.tsv 9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0
-plan14-root-reads-ha-departure-evidence.tsv 9b0747c10be3a45d8c9c3db1f69992a87714f999c8fbb666b910bccd3ce2be74
+plan14-root-reads-ha-departure-evidence.tsv 924ffc4037d32d7b46af1e373bad1476fc7305833fc6c06d50d5c8c3ab5ac177
diff --git a/internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv b/internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv
index 17ee88d60..f3a9f8e57 100644
--- a/internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv
+++ b/internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv
@@ -6,13 +6,13 @@
@legacy c7456932708add3564c8741b2a12a3bd09b44e04c8559c21ff2e80cd822770fa internal/registry/ha_journal.go Registry.RetryPendingTerminationOnce legacy accepted-legacy accepted-legacy;rev3=census-ruling-ha-departure-evidence;basis=New wrapper over the retry_hint_once op; local journal only. registry:Found@243,whole:HAPendingTermination@205,whole:HAPendingTermination@211 61ae470c9b622b0dfd3906278bb4b121b22a43c0ab98712738a0685dbbedb311
@legacy 52359355fb8d18758e59719e063e0b2cfe280803e380db963edacb255103f98c internal/host/hadepartures.go Controller.step legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: resolve bound same-scope identities, persist validated termination proof before enrollment, and replay bounded pending work outside consumer/fold locks. Existing regional data client and shared cache; inventory only restricts completion, never lifecycle. B3 fix r1: Describe before proof access on suspicion paths. Normalize validated legacy inbox entries in atomic transactions, process bounded per-iid pending pages, and persist hourly escalation. Delete unrelated rows only after complete applicable walks and guarded received timestamps. Acquire/completion authority unchanged. B4: Count unresolved durable hints for the globally throttled summary and call the bounded scanner outside the fold. Acknowledge unrelated hints only after complete applicable discovery; complete departure acknowledgment reads durable state. B4 fix r3: Include refused fixed-box replacements in the existing structured receiver summary, sharing its persisted hourly page claim with pending hints. Read only local refusal state and registry page state; no additional cloud request or completion authority.;rev3=census-ruling-region-ha-p3b;basis=Register admitted departure work and cancel/join it during closure before existing confirmation/import processing. Existing 23 read sites and lease/termination proofs remain; no new root input or takeover permission.;rev3=census-ruling-region-ha-g2-fixes;basis=Include identity and underlying paging errors in existing failure logs; new IID field read only, no new external read or termination authority.;rev3=census-ruling-region-ha-dr5;basis=DR-5: scans every due departure per step (at most 8), reading departure rows from the local journal (PendingDepartures) to detect progress; same ScanPass per departure, no new remote read.;rev3=census-ruling-ha-departure-evidence;basis=A pending hint whose bound identity has an unknown or placement-null observation gets code evidence_no_observation: no enqueue, no enrollment, no completion or takeover authority. It claims a page through the new retry_hint_once op (falling back to the ordinary hourly retry if the server refuses it) and marks the hint paged only after PageIdentity succeeds. Reads only the local journal. Round 2: the page-once claim falls back to the ordinary hourly retry only on ErrHAJournal (an older server's refusal); any other journal error fails the pass so a delivered marker is never overwritten. No new read or authority. file:Walk@2717,registry:Body@1979,registry:IID@2554,registry:IID@2971,registry:IID@3757,registry:IID@3790,registry:IID@4924,registry:IID@5082,registry:Key@2081,registry:Key@2317,registry:LastBlocked@2872,registry:NextAttempt@6644,registry:NextAttempt@6669,registry:ReceivedAt@2300,registry:ReceivedAt@3688,whole:HADeparture@6534,whole:HADeparture@6620,whole:HADeparture@6644,whole:HADeparture@6707,whole:HADeparture@6714,whole:HADeparture@6922,whole:HADeparture@7890,whole:HADeparture@8213,whole:HAPendingTermination@2495,whole:HAPendingTermination@2912,whole:HAPendingTermination@3599,whole:HAPendingTermination@3882,whole:HAPendingTermination@4221,whole:HAPendingTermination@4439,whole:HAPendingTermination@5000,whole:HAPendingTermination@5183,whole:HAPendingTermination@5754,whole:HATerminationInbox@1939 a0a56594ece2c190821bec285c58f2cd19dfb104f449e32b84682f9082a161cc
@legacy e81e3f0875a853dae915a7a0f630c00f06057284f45a2df1df522230bb37359d internal/host/hadepartures_wiring.go armHADepartures legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3 fix r1: Install proof adapter, adoption identity and suspicion callbacks before asynchronous startup. Lazily retry the same deployment/data clients; lifetime callback reads only the current host through ExecBackend.TerminationLifetime. Add bounded structured paging for unresolved per-iid records. No new bucket, tenant input path or acquire bypass. B4: Wire the shared lock reader and existing AdoptHost entry. Read local route, Pair and duty revision only after authoritative inventory eligibility; bind its record lifetime and refuse missing/mismatched local routes. No route synthesis or pool widening. B5: Publish the armed controller to the existing metrics sampler. No new loop, remote source or process authority.;rev3=census-ruling-region-ha-followups;basis=Inject the existing PageOperator function into the backend when HA departures are armed; no new read or paging transport.;rev3=census-ruling-region-ha-p3b;basis=Require group admission/BeginWork callbacks and pass them into the sole departure consumer, including the production adoption closure. Same store, identity and registry reads; consumer Started remains a lifecycle fact, not duty authority.;rev3=census-ruling-region-ha-p1b3b-s;basis=Carry the actual provisionTickConfig pools and inbound posture into CanAdopt; stamped sidecars use the existing production adopter. Legacy unresolved paging remains. No wider tenancy or new remote source.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: wires the controller's RequestInventory hook to the agent's early-backstop signal. No new store, read or loop.;rev3=census-ruling-ha-1192;basis=wires DepartureConfig.TrashRetired: release.TrashRetired over a.OpenStore (the deployment bucket) with the box's CARLOS_RELEASE_PUBKEY via provisionTickConfig, the same marker and flag reads the reconcile already makes;rev3=census-ruling-ha-departure-evidence;basis=The PageIdentity closure moved to the named pageDeparturePending; same fields read, now there instead of here. registry:Account@7677,registry:App@7704,registry:Incarnation@7864,registry:Pool@7723,registry:Region@7744,registry:Revision@8099,registry:Revision@8496,registry:ServingSeq@7892,whole:DutyState@8218,whole:Pair@8081,whole:Pair@8474,whole:Pair@8480,whole:Route@7664,whole:Route@8373 51fdc51482fb21d4dde67a4fd9b4200be97ddc6f79189e4141d6d1ddae26285d
-@legacy 5fe23589bbdc7284705ca00509168de124ef3eb23dcfa7e0ecbcff6b2cd4e535 internal/registry/ha_journal.go Registry.haJournal legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: read/write bounded termination inbox, pending departures, verified identity cache and retry/cursor state in the existing SQLite registry with remote parity. No reusable receipt, arbitrary path, import/completion/start authority; retries and page times survive replay. B3 fix r1: Add atomic compact hint enrollment, bounded due reads, received-time guarded removal and hourly page claims. Retain old inbox APIs for migration, no queue receipt or authority bit. All reads/writes stay in the existing SQLite registry with remote parity. B4: Extend the existing registry journal/schema/RPC with scan state, guarded completion phases, durable bounded retry count and one receiver-wide identity summary claim/count. All state stays in the existing database; no queue receipt is persisted and no import/start authority is granted by an inbox entry. B4 fix r2: Delegate existing identity RPC operations to historical storage helpers. Remote interface unchanged; historical ref/iid lookups retain the old binding and ref-only lookups return the latest incarnation. B4 fix r3: Inventory-only waiting resets RetryCount like scan/pending and retains the caller 30-second schedule. Add an atomic claim against the existing singleton identity-page row, shared with retry_hint. Existing database and HAJournal RPC only; no filesystem path or identity authority added. B5: Stream pending departure bodies from the existing registry to count all incomplete rows and find oldest enrollment, including delayed retries. Additive enrollment timestamp retains age when evidence is reobserved. No new path or execution input.;rev3=census-ruling-ha-departure-evidence;basis=New ops retry_hint_once (reads the hint's own last_error, claims the existing global hourly page slot, writes next_attempt/last_page/last_error) and hint_paged (sets last_error to code plus paged when it still equals code). Same tables, same transaction helper, no new authority. file:QueryContext@10790,file:QueryContext@2354,file:QueryContext@291,file:QueryContext@8926,file:QueryRowContext@11660,file:QueryRowContext@1271,file:QueryRowContext@13545,file:QueryRowContext@4616,file:QueryRowContext@6283,file:QueryRowContext@7125,file:QueryRowContext@8203,file:QueryRowContext@8403,file:Walk@13181,file:Walk@13204,file:Walk@13225,file:Walk@13245,file:Walk@13318,file:Walk@13741,registry:Account@1498,registry:Account@1978,registry:Account@2744,registry:Account@3169,registry:Account@3537,registry:Account@4279,registry:Account@4729,registry:Account@5505,registry:Account@5724,registry:Account@6096,registry:At@10977,registry:At@1098,registry:At@1117,registry:At@12106,registry:At@12609,registry:At@12634,registry:At@2571,registry:At@3530,registry:At@3577,registry:At@3918,registry:At@3937,registry:At@4244,registry:At@5082,registry:At@5101,registry:At@5453,registry:At@5492,registry:At@5691,registry:At@6517,registry:At@6534,registry:At@6675,registry:At@7337,registry:At@7721,registry:At@7938,registry:At@866,registry:At@8748,registry:At@8767,registry:At@9116,registry:Body@7900,registry:Body@8059,registry:Body@8728,registry:Body@9309,registry:Code@11872,registry:Code@11900,registry:Code@11920,registry:Code@11943,registry:Code@12935,registry:Code@4271,registry:Code@4404,registry:Code@4437,registry:Code@4890,registry:Code@5266,registry:Code@5852,registry:Code@5885,registry:Code@6087,registry:Code@6124,registry:Code@9774,registry:Count@1352,registry:Count@623,registry:Departure@9812,registry:Departures@11437,registry:Departures@11461,registry:EnrolledAt@652,registry:EnrolledAt@6599,registry:EnrolledAt@6626,registry:EnrolledAt@9989,registry:Found@1208,registry:Found@12770,registry:Found@13101,registry:Found@3705,registry:Found@4072,registry:Found@5237,registry:Found@5282,registry:Found@7817,registry:HAJournal@225,registry:Hint@1482,registry:Hint@3034,registry:Hint@3251,registry:Hint@4392,registry:Hint@5840,registry:Hints@2950,registry:Hints@2969,registry:ID@11729,registry:ID@12398,registry:ID@12616,registry:ID@12943,registry:ID@13140,registry:ID@6374,registry:ID@6896,registry:ID@7222,registry:ID@7703,registry:ID@7862,registry:ID@7880,registry:ID@8048,registry:ID@8722,registry:IID@1566,registry:IID@1585,registry:IID@1999,registry:IID@2767,registry:IID@3190,registry:IID@3558,registry:IID@4300,registry:IID@4750,registry:IID@5526,registry:IID@5745,registry:IID@6117,registry:Identity@13055,registry:Identity@13087,registry:Inbox@9460,registry:Inbox@9479,registry:InventoryGeneration@6682,registry:Key@10532,registry:Key@10627,registry:Key@13146,registry:Key@2098,registry:Key@2193,registry:Key@9283,registry:Key@9616,registry:Key@9782,registry:Keys@13181,registry:Keys@13245,registry:LastError@10068,registry:LastError@11344,registry:LastError@2794,registry:LastError@9332,registry:LastPage@10041,registry:LastPage@11403,registry:LastPage@2916,registry:Limit@10715,registry:Limit@10730,registry:Limit@10984,registry:Limit@2279,registry:Limit@2294,registry:Limit@2578,registry:Limit@8851,registry:Limit@8866,registry:Limit@9123,registry:MessageID@9293,registry:Next@12162,registry:Next@12177,registry:Next@12926,registry:Next@9765,registry:NextAttempt@10087,registry:NextAttempt@10478,registry:NextAttempt@11366,registry:NextAttempt@2879,registry:NextAttempt@9421,registry:Offset@13204,registry:Offset@13225,registry:Oldest@718,registry:Oldest@759,registry:Oldest@785,registry:Op@254,registry:Page@12448,registry:Phase@10019,registry:Phase@11325,registry:Phase@6711,registry:ProofDigest@9888,registry:ProofKey@9868,registry:ReceivedAt@1599,registry:ReceivedAt@2018,registry:ReceivedAt@2045,registry:ReceivedAt@2845,registry:ReceivedAt@3209,registry:ReceivedAt@9385,registry:Region@1522,registry:Region@1544,registry:Region@1989,registry:Region@2756,registry:Region@3180,registry:Region@3548,registry:Region@4290,registry:Region@4740,registry:Region@5516,registry:Region@5735,registry:Region@6107,registry:RetryCount@11971,registry:RetryCount@12125,registry:RetryCount@12201,registry:RetryCount@12220,registry:Summary@623,registry:Summary@718,registry:Summary@759,registry:Summary@785,registry:Walk@13181,registry:Walk@13204,registry:Walk@13225,registry:Walk@13245,registry:Walk@13318,registry:Walk@13741,registry:remote@111,registry:remote@142,registry:sql@10790,registry:sql@1271,registry:sql@13374,registry:sql@13545,registry:sql@2354,registry:sql@291,registry:sql@3052,registry:sql@5943,registry:sql@8926,registry:sql@926,registry:sql@9545,registry:sql@9655,whole:HABoxIdentity@13057,whole:HABoxIdentity@13091,whole:HADeparture@10142,whole:HADeparture@11284,whole:HADeparture@11441,whole:HADeparture@11465,whole:HADeparture@11477,whole:HADeparture@11831,whole:HADeparture@12270,whole:HADeparture@582,whole:HADeparture@6476,whole:HADeparture@6756,whole:HADeparture@9814,whole:HADepartureSummary@627,whole:HADepartureSummary@722,whole:HADepartureSummary@763,whole:HADepartureSummary@789,whole:HAIdentityWalk@13183,whole:HAIdentityWalk@13206,whole:HAIdentityWalk@13227,whole:HAIdentityWalk@13247,whole:HAIdentityWalk@13320,whole:HAIdentityWalk@13745,whole:HAPendingTermination@1484,whole:HAPendingTermination@2954,whole:HAPendingTermination@2973,whole:HAPendingTermination@2980,whole:HAPendingTermination@3036,whole:HAPendingTermination@3253,whole:HAPendingTermination@4394,whole:HAPendingTermination@5842,whole:HATerminationInbox@9464,whole:HATerminationInbox@9483,whole:HATerminationInbox@9490,whole:haJournalRequest@1458,whole:haJournalRequest@196,whole:haJournalRequest@207,whole:haJournalResponse@10171,whole:haJournalResponse@10254,whole:haJournalResponse@10516,whole:haJournalResponse@10657,whole:haJournalResponse@10755,whole:haJournalResponse@11019,whole:haJournalResponse@11240,whole:haJournalResponse@11310,whole:haJournalResponse@11600,whole:haJournalResponse@1166,whole:haJournalResponse@11769,whole:haJournalResponse@11856,whole:haJournalResponse@12301,whole:haJournalResponse@1236,whole:haJournalResponse@12427,whole:haJournalResponse@12685,whole:haJournalResponse@12755,whole:haJournalResponse@12971,whole:haJournalResponse@13270,whole:haJournalResponse@13352,whole:haJournalResponse@13679,whole:haJournalResponse@1372,whole:haJournalResponse@13774,whole:haJournalResponse@13803,whole:haJournalResponse@1633,whole:haJournalResponse@1727,whole:haJournalResponse@2082,whole:haJournalResponse@2223,whole:haJournalResponse@230,whole:haJournalResponse@2319,whole:haJournalResponse@2613,whole:haJournalResponse@2830,whole:haJournalResponse@3330,whole:haJournalResponse@3626,whole:haJournalResponse@3692,whole:haJournalResponse@3988,whole:haJournalResponse@399,whole:haJournalResponse@4057,whole:haJournalResponse@4329,whole:haJournalResponse@4462,whole:haJournalResponse@4556,whole:haJournalResponse@4828,whole:haJournalResponse@4852,whole:haJournalResponse@5152,whole:haJournalResponse@518,whole:haJournalResponse@5222,whole:haJournalResponse@5782,whole:haJournalResponse@5910,whole:haJournalResponse@608,whole:haJournalResponse@6223,whole:haJournalResponse@6414,whole:haJournalResponse@6501,whole:haJournalResponse@6572,whole:haJournalResponse@6785,whole:haJournalResponse@6924,whole:haJournalResponse@7050,whole:haJournalResponse@7309,whole:haJournalResponse@7362,whole:haJournalResponse@7784,whole:haJournalResponse@7964,whole:haJournalResponse@8144,whole:haJournalResponse@8325,whole:haJournalResponse@8365,whole:haJournalResponse@8507,whole:haJournalResponse@8569,whole:haJournalResponse@8800,whole:haJournalResponse@8891,whole:haJournalResponse@892,whole:haJournalResponse@9158,whole:haJournalResponse@9370,whole:haJournalResponse@9965,whole:remoteClient@113,whole:remoteClient@144 a80082cbe79d8f9f5f0cf09d6d83b7bbf169c14fed3a694cca4a26845d1cd36e
+@legacy 553b3b7b25d3fc8499898859aacb060c8613a5387a825251e40c82e779c6428b internal/registry/ha_journal.go Registry.haJournal legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: read/write bounded termination inbox, pending departures, verified identity cache and retry/cursor state in the existing SQLite registry with remote parity. No reusable receipt, arbitrary path, import/completion/start authority; retries and page times survive replay. B3 fix r1: Add atomic compact hint enrollment, bounded due reads, received-time guarded removal and hourly page claims. Retain old inbox APIs for migration, no queue receipt or authority bit. All reads/writes stay in the existing SQLite registry with remote parity. B4: Extend the existing registry journal/schema/RPC with scan state, guarded completion phases, durable bounded retry count and one receiver-wide identity summary claim/count. All state stays in the existing database; no queue receipt is persisted and no import/start authority is granted by an inbox entry. B4 fix r2: Delegate existing identity RPC operations to historical storage helpers. Remote interface unchanged; historical ref/iid lookups retain the old binding and ref-only lookups return the latest incarnation. B4 fix r3: Inventory-only waiting resets RetryCount like scan/pending and retains the caller 30-second schedule. Add an atomic claim against the existing singleton identity-page row, shared with retry_hint. Existing database and HAJournal RPC only; no filesystem path or identity authority added. B5: Stream pending departure bodies from the existing registry to count all incomplete rows and find oldest enrollment, including delayed retries. Additive enrollment timestamp retains age when evidence is reobserved. No new path or execution input.;rev3=census-ruling-ha-departure-evidence;basis=New ops retry_hint_once (reads the hint's own last_error, claims the existing global hourly page slot, writes next_attempt/last_page/last_error) and hint_paged (sets last_error to code plus paged when it still equals code). Same tables, same transaction helper, no new authority. Round 4 (Paul's option 1): every last_error write on ha_pending_terminations goes through hintLastError, a CASE that keeps a value ending in ' paged'; retry_hint_once treats any paged marker as delivered. Only hint removal clears it. No new table, read or authority. file:QueryContext@10797,file:QueryContext@2354,file:QueryContext@291,file:QueryContext@8933,file:QueryRowContext@11667,file:QueryRowContext@1271,file:QueryRowContext@13552,file:QueryRowContext@4621,file:QueryRowContext@6290,file:QueryRowContext@7132,file:QueryRowContext@8210,file:QueryRowContext@8410,file:Walk@13188,file:Walk@13211,file:Walk@13232,file:Walk@13252,file:Walk@13325,file:Walk@13748,registry:Account@1498,registry:Account@1978,registry:Account@2744,registry:Account@3169,registry:Account@3537,registry:Account@4284,registry:Account@4734,registry:Account@5502,registry:Account@5726,registry:Account@6103,registry:At@1098,registry:At@10984,registry:At@1117,registry:At@12113,registry:At@12616,registry:At@12641,registry:At@2571,registry:At@3530,registry:At@3577,registry:At@3918,registry:At@3937,registry:At@4249,registry:At@5074,registry:At@5093,registry:At@5450,registry:At@5489,registry:At@5693,registry:At@6524,registry:At@6541,registry:At@6682,registry:At@7344,registry:At@7728,registry:At@7945,registry:At@866,registry:At@8755,registry:At@8774,registry:At@9123,registry:Body@7907,registry:Body@8066,registry:Body@8735,registry:Body@9316,registry:Code@11879,registry:Code@11907,registry:Code@11927,registry:Code@11950,registry:Code@12942,registry:Code@4276,registry:Code@4409,registry:Code@4442,registry:Code@5258,registry:Code@5854,registry:Code@5887,registry:Code@6094,registry:Code@6131,registry:Code@9781,registry:Count@1352,registry:Count@623,registry:Departure@9819,registry:Departures@11444,registry:Departures@11468,registry:EnrolledAt@652,registry:EnrolledAt@6606,registry:EnrolledAt@6633,registry:EnrolledAt@9996,registry:Found@1208,registry:Found@12777,registry:Found@13108,registry:Found@3705,registry:Found@4072,registry:Found@5229,registry:Found@5274,registry:Found@7824,registry:HAJournal@225,registry:Hint@1482,registry:Hint@3034,registry:Hint@3251,registry:Hint@4397,registry:Hint@5842,registry:Hints@2950,registry:Hints@2969,registry:ID@11736,registry:ID@12405,registry:ID@12623,registry:ID@12950,registry:ID@13147,registry:ID@6381,registry:ID@6903,registry:ID@7229,registry:ID@7710,registry:ID@7869,registry:ID@7887,registry:ID@8055,registry:ID@8729,registry:IID@1566,registry:IID@1585,registry:IID@1999,registry:IID@2767,registry:IID@3190,registry:IID@3558,registry:IID@4305,registry:IID@4755,registry:IID@5523,registry:IID@5747,registry:IID@6124,registry:Identity@13062,registry:Identity@13094,registry:Inbox@9467,registry:Inbox@9486,registry:InventoryGeneration@6689,registry:Key@10539,registry:Key@10634,registry:Key@13153,registry:Key@2098,registry:Key@2193,registry:Key@9290,registry:Key@9623,registry:Key@9789,registry:Keys@13188,registry:Keys@13252,registry:LastError@10075,registry:LastError@11351,registry:LastError@2794,registry:LastError@9339,registry:LastPage@10048,registry:LastPage@11410,registry:LastPage@2916,registry:Limit@10722,registry:Limit@10737,registry:Limit@10991,registry:Limit@2279,registry:Limit@2294,registry:Limit@2578,registry:Limit@8858,registry:Limit@8873,registry:Limit@9130,registry:MessageID@9300,registry:Next@12169,registry:Next@12184,registry:Next@12933,registry:Next@9772,registry:NextAttempt@10094,registry:NextAttempt@10485,registry:NextAttempt@11373,registry:NextAttempt@2879,registry:NextAttempt@9428,registry:Offset@13211,registry:Offset@13232,registry:Oldest@718,registry:Oldest@759,registry:Oldest@785,registry:Op@254,registry:Page@12455,registry:Phase@10026,registry:Phase@11332,registry:Phase@6718,registry:ProofDigest@9895,registry:ProofKey@9875,registry:ReceivedAt@1599,registry:ReceivedAt@2018,registry:ReceivedAt@2045,registry:ReceivedAt@2845,registry:ReceivedAt@3209,registry:ReceivedAt@9392,registry:Region@1522,registry:Region@1544,registry:Region@1989,registry:Region@2756,registry:Region@3180,registry:Region@3548,registry:Region@4295,registry:Region@4745,registry:Region@5513,registry:Region@5737,registry:Region@6114,registry:RetryCount@11978,registry:RetryCount@12132,registry:RetryCount@12208,registry:RetryCount@12227,registry:Summary@623,registry:Summary@718,registry:Summary@759,registry:Summary@785,registry:Walk@13188,registry:Walk@13211,registry:Walk@13232,registry:Walk@13252,registry:Walk@13325,registry:Walk@13748,registry:remote@111,registry:remote@142,registry:sql@10797,registry:sql@1271,registry:sql@13381,registry:sql@13552,registry:sql@2354,registry:sql@291,registry:sql@3052,registry:sql@5945,registry:sql@8933,registry:sql@926,registry:sql@9552,registry:sql@9662,whole:HABoxIdentity@13064,whole:HABoxIdentity@13098,whole:HADeparture@10149,whole:HADeparture@11291,whole:HADeparture@11448,whole:HADeparture@11472,whole:HADeparture@11484,whole:HADeparture@11838,whole:HADeparture@12277,whole:HADeparture@582,whole:HADeparture@6483,whole:HADeparture@6763,whole:HADeparture@9821,whole:HADepartureSummary@627,whole:HADepartureSummary@722,whole:HADepartureSummary@763,whole:HADepartureSummary@789,whole:HAIdentityWalk@13190,whole:HAIdentityWalk@13213,whole:HAIdentityWalk@13234,whole:HAIdentityWalk@13254,whole:HAIdentityWalk@13327,whole:HAIdentityWalk@13752,whole:HAPendingTermination@1484,whole:HAPendingTermination@2954,whole:HAPendingTermination@2973,whole:HAPendingTermination@2980,whole:HAPendingTermination@3036,whole:HAPendingTermination@3253,whole:HAPendingTermination@4399,whole:HAPendingTermination@5844,whole:HATerminationInbox@9471,whole:HATerminationInbox@9490,whole:HATerminationInbox@9497,whole:haJournalRequest@1458,whole:haJournalRequest@196,whole:haJournalRequest@207,whole:haJournalResponse@10178,whole:haJournalResponse@10261,whole:haJournalResponse@10523,whole:haJournalResponse@10664,whole:haJournalResponse@10762,whole:haJournalResponse@11026,whole:haJournalResponse@11247,whole:haJournalResponse@11317,whole:haJournalResponse@11607,whole:haJournalResponse@1166,whole:haJournalResponse@11776,whole:haJournalResponse@11863,whole:haJournalResponse@12308,whole:haJournalResponse@1236,whole:haJournalResponse@12434,whole:haJournalResponse@12692,whole:haJournalResponse@12762,whole:haJournalResponse@12978,whole:haJournalResponse@13277,whole:haJournalResponse@13359,whole:haJournalResponse@13686,whole:haJournalResponse@1372,whole:haJournalResponse@13781,whole:haJournalResponse@13810,whole:haJournalResponse@1633,whole:haJournalResponse@1727,whole:haJournalResponse@2082,whole:haJournalResponse@2223,whole:haJournalResponse@230,whole:haJournalResponse@2319,whole:haJournalResponse@2613,whole:haJournalResponse@2830,whole:haJournalResponse@3330,whole:haJournalResponse@3626,whole:haJournalResponse@3692,whole:haJournalResponse@3988,whole:haJournalResponse@399,whole:haJournalResponse@4057,whole:haJournalResponse@4334,whole:haJournalResponse@4467,whole:haJournalResponse@4561,whole:haJournalResponse@4833,whole:haJournalResponse@4857,whole:haJournalResponse@5144,whole:haJournalResponse@518,whole:haJournalResponse@5214,whole:haJournalResponse@5784,whole:haJournalResponse@5912,whole:haJournalResponse@608,whole:haJournalResponse@6230,whole:haJournalResponse@6421,whole:haJournalResponse@6508,whole:haJournalResponse@6579,whole:haJournalResponse@6792,whole:haJournalResponse@6931,whole:haJournalResponse@7057,whole:haJournalResponse@7316,whole:haJournalResponse@7369,whole:haJournalResponse@7791,whole:haJournalResponse@7971,whole:haJournalResponse@8151,whole:haJournalResponse@8332,whole:haJournalResponse@8372,whole:haJournalResponse@8514,whole:haJournalResponse@8576,whole:haJournalResponse@8807,whole:haJournalResponse@8898,whole:haJournalResponse@892,whole:haJournalResponse@9165,whole:haJournalResponse@9377,whole:haJournalResponse@9972,whole:remoteClient@113,whole:remoteClient@144 934b49e5a287e9a69de5db021f074f7999d12bc149bf890e620f4abe58a24fe9
internal/host/hadepartures_wiring.go pageDeparturePending legacy accepted-legacy accepted-legacy;rev3=census-ruling-ha-departure-evidence;basis=The former PageIdentity closure, now paging through alerting.PageDelivered, which returns ErrNoSink when no sink is armed so the page-once mark is not written without delivery. Same fields, same sinks. registry:Account@241,registry:IID@262,registry:Region@252 7b32a2e3d55fcda0a6d5fa2f3f670e3d5e1d0c33a17af25629952135ae1237b2
internal/registry/ha_journal.go Registry.MarkPendingTerminationPaged legacy accepted-legacy accepted-legacy;rev3=census-ruling-ha-departure-evidence;basis=New wrapper over the hint_paged op; local journal only. whole:HAPendingTermination@176,whole:HAPendingTermination@182 d45e190a96beaf27eeadc9800ac113e51cedb36a3a395d0a67128911d60cc6bc
internal/registry/ha_journal.go Registry.RetryPendingTerminationOnce legacy accepted-legacy accepted-legacy;rev3=census-ruling-ha-departure-evidence;basis=New wrapper over the retry_hint_once op; local journal only. registry:Found@243,whole:HAPendingTermination@205,whole:HAPendingTermination@211 61ae470c9b622b0dfd3906278bb4b121b22a43c0ab98712738a0685dbbedb311
internal/host/hadepartures.go Controller.step legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: resolve bound same-scope identities, persist validated termination proof before enrollment, and replay bounded pending work outside consumer/fold locks. Existing regional data client and shared cache; inventory only restricts completion, never lifecycle. B3 fix r1: Describe before proof access on suspicion paths. Normalize validated legacy inbox entries in atomic transactions, process bounded per-iid pending pages, and persist hourly escalation. Delete unrelated rows only after complete applicable walks and guarded received timestamps. Acquire/completion authority unchanged. B4: Count unresolved durable hints for the globally throttled summary and call the bounded scanner outside the fold. Acknowledge unrelated hints only after complete applicable discovery; complete departure acknowledgment reads durable state. B4 fix r3: Include refused fixed-box replacements in the existing structured receiver summary, sharing its persisted hourly page claim with pending hints. Read only local refusal state and registry page state; no additional cloud request or completion authority.;rev3=census-ruling-region-ha-p3b;basis=Register admitted departure work and cancel/join it during closure before existing confirmation/import processing. Existing 23 read sites and lease/termination proofs remain; no new root input or takeover permission.;rev3=census-ruling-region-ha-g2-fixes;basis=Include identity and underlying paging errors in existing failure logs; new IID field read only, no new external read or termination authority.;rev3=census-ruling-region-ha-dr5;basis=DR-5: scans every due departure per step (at most 8), reading departure rows from the local journal (PendingDepartures) to detect progress; same ScanPass per departure, no new remote read.;rev3=census-ruling-ha-departure-evidence;basis=A pending hint whose bound identity has an unknown or placement-null observation gets code evidence_no_observation: no enqueue, no enrollment, no completion or takeover authority. It claims a page through the new retry_hint_once op (falling back to the ordinary hourly retry if the server refuses it) and marks the hint paged only after PageIdentity succeeds. Reads only the local journal. Round 2: the page-once claim falls back to the ordinary hourly retry only on ErrHAJournal (an older server's refusal); any other journal error fails the pass so a delivered marker is never overwritten. No new read or authority. file:Walk@2717,registry:Body@1979,registry:IID@2554,registry:IID@2971,registry:IID@3757,registry:IID@3790,registry:IID@4924,registry:IID@5082,registry:Key@2081,registry:Key@2317,registry:LastBlocked@2872,registry:NextAttempt@6644,registry:NextAttempt@6669,registry:ReceivedAt@2300,registry:ReceivedAt@3688,whole:HADeparture@6534,whole:HADeparture@6620,whole:HADeparture@6644,whole:HADeparture@6707,whole:HADeparture@6714,whole:HADeparture@6922,whole:HADeparture@7890,whole:HADeparture@8213,whole:HAPendingTermination@2495,whole:HAPendingTermination@2912,whole:HAPendingTermination@3599,whole:HAPendingTermination@3882,whole:HAPendingTermination@4221,whole:HAPendingTermination@4439,whole:HAPendingTermination@5000,whole:HAPendingTermination@5183,whole:HAPendingTermination@5754,whole:HATerminationInbox@1939 a0a56594ece2c190821bec285c58f2cd19dfb104f449e32b84682f9082a161cc
internal/host/hadepartures_wiring.go armHADepartures legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3 fix r1: Install proof adapter, adoption identity and suspicion callbacks before asynchronous startup. Lazily retry the same deployment/data clients; lifetime callback reads only the current host through ExecBackend.TerminationLifetime. Add bounded structured paging for unresolved per-iid records. No new bucket, tenant input path or acquire bypass. B4: Wire the shared lock reader and existing AdoptHost entry. Read local route, Pair and duty revision only after authoritative inventory eligibility; bind its record lifetime and refuse missing/mismatched local routes. No route synthesis or pool widening. B5: Publish the armed controller to the existing metrics sampler. No new loop, remote source or process authority.;rev3=census-ruling-region-ha-followups;basis=Inject the existing PageOperator function into the backend when HA departures are armed; no new read or paging transport.;rev3=census-ruling-region-ha-p3b;basis=Require group admission/BeginWork callbacks and pass them into the sole departure consumer, including the production adoption closure. Same store, identity and registry reads; consumer Started remains a lifecycle fact, not duty authority.;rev3=census-ruling-region-ha-p1b3b-s;basis=Carry the actual provisionTickConfig pools and inbound posture into CanAdopt; stamped sidecars use the existing production adopter. Legacy unresolved paging remains. No wider tenancy or new remote source.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: wires the controller's RequestInventory hook to the agent's early-backstop signal. No new store, read or loop.;rev3=census-ruling-ha-1192;basis=wires DepartureConfig.TrashRetired: release.TrashRetired over a.OpenStore (the deployment bucket) with the box's CARLOS_RELEASE_PUBKEY via provisionTickConfig, the same marker and flag reads the reconcile already makes;rev3=census-ruling-ha-departure-evidence;basis=The PageIdentity closure moved to the named pageDeparturePending; same fields read, now there instead of here. registry:Account@7677,registry:App@7704,registry:Incarnation@7864,registry:Pool@7723,registry:Region@7744,registry:Revision@8099,registry:Revision@8496,registry:ServingSeq@7892,whole:DutyState@8218,whole:Pair@8081,whole:Pair@8474,whole:Pair@8480,whole:Route@7664,whole:Route@8373 51fdc51482fb21d4dde67a4fd9b4200be97ddc6f79189e4141d6d1ddae26285d
-internal/registry/ha_journal.go Registry.haJournal legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: read/write bounded termination inbox, pending departures, verified identity cache and retry/cursor state in the existing SQLite registry with remote parity. No reusable receipt, arbitrary path, import/completion/start authority; retries and page times survive replay. B3 fix r1: Add atomic compact hint enrollment, bounded due reads, received-time guarded removal and hourly page claims. Retain old inbox APIs for migration, no queue receipt or authority bit. All reads/writes stay in the existing SQLite registry with remote parity. B4: Extend the existing registry journal/schema/RPC with scan state, guarded completion phases, durable bounded retry count and one receiver-wide identity summary claim/count. All state stays in the existing database; no queue receipt is persisted and no import/start authority is granted by an inbox entry. B4 fix r2: Delegate existing identity RPC operations to historical storage helpers. Remote interface unchanged; historical ref/iid lookups retain the old binding and ref-only lookups return the latest incarnation. B4 fix r3: Inventory-only waiting resets RetryCount like scan/pending and retains the caller 30-second schedule. Add an atomic claim against the existing singleton identity-page row, shared with retry_hint. Existing database and HAJournal RPC only; no filesystem path or identity authority added. B5: Stream pending departure bodies from the existing registry to count all incomplete rows and find oldest enrollment, including delayed retries. Additive enrollment timestamp retains age when evidence is reobserved. No new path or execution input.;rev3=census-ruling-ha-departure-evidence;basis=New ops retry_hint_once (reads the hint's own last_error, claims the existing global hourly page slot, writes next_attempt/last_page/last_error) and hint_paged (sets last_error to code plus paged when it still equals code). Same tables, same transaction helper, no new authority. file:QueryContext@10790,file:QueryContext@2354,file:QueryContext@291,file:QueryContext@8926,file:QueryRowContext@11660,file:QueryRowContext@1271,file:QueryRowContext@13545,file:QueryRowContext@4616,file:QueryRowContext@6283,file:QueryRowContext@7125,file:QueryRowContext@8203,file:QueryRowContext@8403,file:Walk@13181,file:Walk@13204,file:Walk@13225,file:Walk@13245,file:Walk@13318,file:Walk@13741,registry:Account@1498,registry:Account@1978,registry:Account@2744,registry:Account@3169,registry:Account@3537,registry:Account@4279,registry:Account@4729,registry:Account@5505,registry:Account@5724,registry:Account@6096,registry:At@10977,registry:At@1098,registry:At@1117,registry:At@12106,registry:At@12609,registry:At@12634,registry:At@2571,registry:At@3530,registry:At@3577,registry:At@3918,registry:At@3937,registry:At@4244,registry:At@5082,registry:At@5101,registry:At@5453,registry:At@5492,registry:At@5691,registry:At@6517,registry:At@6534,registry:At@6675,registry:At@7337,registry:At@7721,registry:At@7938,registry:At@866,registry:At@8748,registry:At@8767,registry:At@9116,registry:Body@7900,registry:Body@8059,registry:Body@8728,registry:Body@9309,registry:Code@11872,registry:Code@11900,registry:Code@11920,registry:Code@11943,registry:Code@12935,registry:Code@4271,registry:Code@4404,registry:Code@4437,registry:Code@4890,registry:Code@5266,registry:Code@5852,registry:Code@5885,registry:Code@6087,registry:Code@6124,registry:Code@9774,registry:Count@1352,registry:Count@623,registry:Departure@9812,registry:Departures@11437,registry:Departures@11461,registry:EnrolledAt@652,registry:EnrolledAt@6599,registry:EnrolledAt@6626,registry:EnrolledAt@9989,registry:Found@1208,registry:Found@12770,registry:Found@13101,registry:Found@3705,registry:Found@4072,registry:Found@5237,registry:Found@5282,registry:Found@7817,registry:HAJournal@225,registry:Hint@1482,registry:Hint@3034,registry:Hint@3251,registry:Hint@4392,registry:Hint@5840,registry:Hints@2950,registry:Hints@2969,registry:ID@11729,registry:ID@12398,registry:ID@12616,registry:ID@12943,registry:ID@13140,registry:ID@6374,registry:ID@6896,registry:ID@7222,registry:ID@7703,registry:ID@7862,registry:ID@7880,registry:ID@8048,registry:ID@8722,registry:IID@1566,registry:IID@1585,registry:IID@1999,registry:IID@2767,registry:IID@3190,registry:IID@3558,registry:IID@4300,registry:IID@4750,registry:IID@5526,registry:IID@5745,registry:IID@6117,registry:Identity@13055,registry:Identity@13087,registry:Inbox@9460,registry:Inbox@9479,registry:InventoryGeneration@6682,registry:Key@10532,registry:Key@10627,registry:Key@13146,registry:Key@2098,registry:Key@2193,registry:Key@9283,registry:Key@9616,registry:Key@9782,registry:Keys@13181,registry:Keys@13245,registry:LastError@10068,registry:LastError@11344,registry:LastError@2794,registry:LastError@9332,registry:LastPage@10041,registry:LastPage@11403,registry:LastPage@2916,registry:Limit@10715,registry:Limit@10730,registry:Limit@10984,registry:Limit@2279,registry:Limit@2294,registry:Limit@2578,registry:Limit@8851,registry:Limit@8866,registry:Limit@9123,registry:MessageID@9293,registry:Next@12162,registry:Next@12177,registry:Next@12926,registry:Next@9765,registry:NextAttempt@10087,registry:NextAttempt@10478,registry:NextAttempt@11366,registry:NextAttempt@2879,registry:NextAttempt@9421,registry:Offset@13204,registry:Offset@13225,registry:Oldest@718,registry:Oldest@759,registry:Oldest@785,registry:Op@254,registry:Page@12448,registry:Phase@10019,registry:Phase@11325,registry:Phase@6711,registry:ProofDigest@9888,registry:ProofKey@9868,registry:ReceivedAt@1599,registry:ReceivedAt@2018,registry:ReceivedAt@2045,registry:ReceivedAt@2845,registry:ReceivedAt@3209,registry:ReceivedAt@9385,registry:Region@1522,registry:Region@1544,registry:Region@1989,registry:Region@2756,registry:Region@3180,registry:Region@3548,registry:Region@4290,registry:Region@4740,registry:Region@5516,registry:Region@5735,registry:Region@6107,registry:RetryCount@11971,registry:RetryCount@12125,registry:RetryCount@12201,registry:RetryCount@12220,registry:Summary@623,registry:Summary@718,registry:Summary@759,registry:Summary@785,registry:Walk@13181,registry:Walk@13204,registry:Walk@13225,registry:Walk@13245,registry:Walk@13318,registry:Walk@13741,registry:remote@111,registry:remote@142,registry:sql@10790,registry:sql@1271,registry:sql@13374,registry:sql@13545,registry:sql@2354,registry:sql@291,registry:sql@3052,registry:sql@5943,registry:sql@8926,registry:sql@926,registry:sql@9545,registry:sql@9655,whole:HABoxIdentity@13057,whole:HABoxIdentity@13091,whole:HADeparture@10142,whole:HADeparture@11284,whole:HADeparture@11441,whole:HADeparture@11465,whole:HADeparture@11477,whole:HADeparture@11831,whole:HADeparture@12270,whole:HADeparture@582,whole:HADeparture@6476,whole:HADeparture@6756,whole:HADeparture@9814,whole:HADepartureSummary@627,whole:HADepartureSummary@722,whole:HADepartureSummary@763,whole:HADepartureSummary@789,whole:HAIdentityWalk@13183,whole:HAIdentityWalk@13206,whole:HAIdentityWalk@13227,whole:HAIdentityWalk@13247,whole:HAIdentityWalk@13320,whole:HAIdentityWalk@13745,whole:HAPendingTermination@1484,whole:HAPendingTermination@2954,whole:HAPendingTermination@2973,whole:HAPendingTermination@2980,whole:HAPendingTermination@3036,whole:HAPendingTermination@3253,whole:HAPendingTermination@4394,whole:HAPendingTermination@5842,whole:HATerminationInbox@9464,whole:HATerminationInbox@9483,whole:HATerminationInbox@9490,whole:haJournalRequest@1458,whole:haJournalRequest@196,whole:haJournalRequest@207,whole:haJournalResponse@10171,whole:haJournalResponse@10254,whole:haJournalResponse@10516,whole:haJournalResponse@10657,whole:haJournalResponse@10755,whole:haJournalResponse@11019,whole:haJournalResponse@11240,whole:haJournalResponse@11310,whole:haJournalResponse@11600,whole:haJournalResponse@1166,whole:haJournalResponse@11769,whole:haJournalResponse@11856,whole:haJournalResponse@12301,whole:haJournalResponse@1236,whole:haJournalResponse@12427,whole:haJournalResponse@12685,whole:haJournalResponse@12755,whole:haJournalResponse@12971,whole:haJournalResponse@13270,whole:haJournalResponse@13352,whole:haJournalResponse@13679,whole:haJournalResponse@1372,whole:haJournalResponse@13774,whole:haJournalResponse@13803,whole:haJournalResponse@1633,whole:haJournalResponse@1727,whole:haJournalResponse@2082,whole:haJournalResponse@2223,whole:haJournalResponse@230,whole:haJournalResponse@2319,whole:haJournalResponse@2613,whole:haJournalResponse@2830,whole:haJournalResponse@3330,whole:haJournalResponse@3626,whole:haJournalResponse@3692,whole:haJournalResponse@3988,whole:haJournalResponse@399,whole:haJournalResponse@4057,whole:haJournalResponse@4329,whole:haJournalResponse@4462,whole:haJournalResponse@4556,whole:haJournalResponse@4828,whole:haJournalResponse@4852,whole:haJournalResponse@5152,whole:haJournalResponse@518,whole:haJournalResponse@5222,whole:haJournalResponse@5782,whole:haJournalResponse@5910,whole:haJournalResponse@608,whole:haJournalResponse@6223,whole:haJournalResponse@6414,whole:haJournalResponse@6501,whole:haJournalResponse@6572,whole:haJournalResponse@6785,whole:haJournalResponse@6924,whole:haJournalResponse@7050,whole:haJournalResponse@7309,whole:haJournalResponse@7362,whole:haJournalResponse@7784,whole:haJournalResponse@7964,whole:haJournalResponse@8144,whole:haJournalResponse@8325,whole:haJournalResponse@8365,whole:haJournalResponse@8507,whole:haJournalResponse@8569,whole:haJournalResponse@8800,whole:haJournalResponse@8891,whole:haJournalResponse@892,whole:haJournalResponse@9158,whole:haJournalResponse@9370,whole:haJournalResponse@9965,whole:remoteClient@113,whole:remoteClient@144 a80082cbe79d8f9f5f0cf09d6d83b7bbf169c14fed3a694cca4a26845d1cd36e
+internal/registry/ha_journal.go Registry.haJournal legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: read/write bounded termination inbox, pending departures, verified identity cache and retry/cursor state in the existing SQLite registry with remote parity. No reusable receipt, arbitrary path, import/completion/start authority; retries and page times survive replay. B3 fix r1: Add atomic compact hint enrollment, bounded due reads, received-time guarded removal and hourly page claims. Retain old inbox APIs for migration, no queue receipt or authority bit. All reads/writes stay in the existing SQLite registry with remote parity. B4: Extend the existing registry journal/schema/RPC with scan state, guarded completion phases, durable bounded retry count and one receiver-wide identity summary claim/count. All state stays in the existing database; no queue receipt is persisted and no import/start authority is granted by an inbox entry. B4 fix r2: Delegate existing identity RPC operations to historical storage helpers. Remote interface unchanged; historical ref/iid lookups retain the old binding and ref-only lookups return the latest incarnation. B4 fix r3: Inventory-only waiting resets RetryCount like scan/pending and retains the caller 30-second schedule. Add an atomic claim against the existing singleton identity-page row, shared with retry_hint. Existing database and HAJournal RPC only; no filesystem path or identity authority added. B5: Stream pending departure bodies from the existing registry to count all incomplete rows and find oldest enrollment, including delayed retries. Additive enrollment timestamp retains age when evidence is reobserved. No new path or execution input.;rev3=census-ruling-ha-departure-evidence;basis=New ops retry_hint_once (reads the hint's own last_error, claims the existing global hourly page slot, writes next_attempt/last_page/last_error) and hint_paged (sets last_error to code plus paged when it still equals code). Same tables, same transaction helper, no new authority. Round 4 (Paul's option 1): every last_error write on ha_pending_terminations goes through hintLastError, a CASE that keeps a value ending in ' paged'; retry_hint_once treats any paged marker as delivered. Only hint removal clears it. No new table, read or authority. file:QueryContext@10797,file:QueryContext@2354,file:QueryContext@291,file:QueryContext@8933,file:QueryRowContext@11667,file:QueryRowContext@1271,file:QueryRowContext@13552,file:QueryRowContext@4621,file:QueryRowContext@6290,file:QueryRowContext@7132,file:QueryRowContext@8210,file:QueryRowContext@8410,file:Walk@13188,file:Walk@13211,file:Walk@13232,file:Walk@13252,file:Walk@13325,file:Walk@13748,registry:Account@1498,registry:Account@1978,registry:Account@2744,registry:Account@3169,registry:Account@3537,registry:Account@4284,registry:Account@4734,registry:Account@5502,registry:Account@5726,registry:Account@6103,registry:At@1098,registry:At@10984,registry:At@1117,registry:At@12113,registry:At@12616,registry:At@12641,registry:At@2571,registry:At@3530,registry:At@3577,registry:At@3918,registry:At@3937,registry:At@4249,registry:At@5074,registry:At@5093,registry:At@5450,registry:At@5489,registry:At@5693,registry:At@6524,registry:At@6541,registry:At@6682,registry:At@7344,registry:At@7728,registry:At@7945,registry:At@866,registry:At@8755,registry:At@8774,registry:At@9123,registry:Body@7907,registry:Body@8066,registry:Body@8735,registry:Body@9316,registry:Code@11879,registry:Code@11907,registry:Code@11927,registry:Code@11950,registry:Code@12942,registry:Code@4276,registry:Code@4409,registry:Code@4442,registry:Code@5258,registry:Code@5854,registry:Code@5887,registry:Code@6094,registry:Code@6131,registry:Code@9781,registry:Count@1352,registry:Count@623,registry:Departure@9819,registry:Departures@11444,registry:Departures@11468,registry:EnrolledAt@652,registry:EnrolledAt@6606,registry:EnrolledAt@6633,registry:EnrolledAt@9996,registry:Found@1208,registry:Found@12777,registry:Found@13108,registry:Found@3705,registry:Found@4072,registry:Found@5229,registry:Found@5274,registry:Found@7824,registry:HAJournal@225,registry:Hint@1482,registry:Hint@3034,registry:Hint@3251,registry:Hint@4397,registry:Hint@5842,registry:Hints@2950,registry:Hints@2969,registry:ID@11736,registry:ID@12405,registry:ID@12623,registry:ID@12950,registry:ID@13147,registry:ID@6381,registry:ID@6903,registry:ID@7229,registry:ID@7710,registry:ID@7869,registry:ID@7887,registry:ID@8055,registry:ID@8729,registry:IID@1566,registry:IID@1585,registry:IID@1999,registry:IID@2767,registry:IID@3190,registry:IID@3558,registry:IID@4305,registry:IID@4755,registry:IID@5523,registry:IID@5747,registry:IID@6124,registry:Identity@13062,registry:Identity@13094,registry:Inbox@9467,registry:Inbox@9486,registry:InventoryGeneration@6689,registry:Key@10539,registry:Key@10634,registry:Key@13153,registry:Key@2098,registry:Key@2193,registry:Key@9290,registry:Key@9623,registry:Key@9789,registry:Keys@13188,registry:Keys@13252,registry:LastError@10075,registry:LastError@11351,registry:LastError@2794,registry:LastError@9339,registry:LastPage@10048,registry:LastPage@11410,registry:LastPage@2916,registry:Limit@10722,registry:Limit@10737,registry:Limit@10991,registry:Limit@2279,registry:Limit@2294,registry:Limit@2578,registry:Limit@8858,registry:Limit@8873,registry:Limit@9130,registry:MessageID@9300,registry:Next@12169,registry:Next@12184,registry:Next@12933,registry:Next@9772,registry:NextAttempt@10094,registry:NextAttempt@10485,registry:NextAttempt@11373,registry:NextAttempt@2879,registry:NextAttempt@9428,registry:Offset@13211,registry:Offset@13232,registry:Oldest@718,registry:Oldest@759,registry:Oldest@785,registry:Op@254,registry:Page@12455,registry:Phase@10026,registry:Phase@11332,registry:Phase@6718,registry:ProofDigest@9895,registry:ProofKey@9875,registry:ReceivedAt@1599,registry:ReceivedAt@2018,registry:ReceivedAt@2045,registry:ReceivedAt@2845,registry:ReceivedAt@3209,registry:ReceivedAt@9392,registry:Region@1522,registry:Region@1544,registry:Region@1989,registry:Region@2756,registry:Region@3180,registry:Region@3548,registry:Region@4295,registry:Region@4745,registry:Region@5513,registry:Region@5737,registry:Region@6114,registry:RetryCount@11978,registry:RetryCount@12132,registry:RetryCount@12208,registry:RetryCount@12227,registry:Summary@623,registry:Summary@718,registry:Summary@759,registry:Summary@785,registry:Walk@13188,registry:Walk@13211,registry:Walk@13232,registry:Walk@13252,registry:Walk@13325,registry:Walk@13748,registry:remote@111,registry:remote@142,registry:sql@10797,registry:sql@1271,registry:sql@13381,registry:sql@13552,registry:sql@2354,registry:sql@291,registry:sql@3052,registry:sql@5945,registry:sql@8933,registry:sql@926,registry:sql@9552,registry:sql@9662,whole:HABoxIdentity@13064,whole:HABoxIdentity@13098,whole:HADeparture@10149,whole:HADeparture@11291,whole:HADeparture@11448,whole:HADeparture@11472,whole:HADeparture@11484,whole:HADeparture@11838,whole:HADeparture@12277,whole:HADeparture@582,whole:HADeparture@6483,whole:HADeparture@6763,whole:HADeparture@9821,whole:HADepartureSummary@627,whole:HADepartureSummary@722,whole:HADepartureSummary@763,whole:HADepartureSummary@789,whole:HAIdentityWalk@13190,whole:HAIdentityWalk@13213,whole:HAIdentityWalk@13234,whole:HAIdentityWalk@13254,whole:HAIdentityWalk@13327,whole:HAIdentityWalk@13752,whole:HAPendingTermination@1484,whole:HAPendingTermination@2954,whole:HAPendingTermination@2973,whole:HAPendingTermination@2980,whole:HAPendingTermination@3036,whole:HAPendingTermination@3253,whole:HAPendingTermination@4399,whole:HAPendingTermination@5844,whole:HATerminationInbox@9471,whole:HATerminationInbox@9490,whole:HATerminationInbox@9497,whole:haJournalRequest@1458,whole:haJournalRequest@196,whole:haJournalRequest@207,whole:haJournalResponse@10178,whole:haJournalResponse@10261,whole:haJournalResponse@10523,whole:haJournalResponse@10664,whole:haJournalResponse@10762,whole:haJournalResponse@11026,whole:haJournalResponse@11247,whole:haJournalResponse@11317,whole:haJournalResponse@11607,whole:haJournalResponse@1166,whole:haJournalResponse@11776,whole:haJournalResponse@11863,whole:haJournalResponse@12308,whole:haJournalResponse@1236,whole:haJournalResponse@12434,whole:haJournalResponse@12692,whole:haJournalResponse@12762,whole:haJournalResponse@12978,whole:haJournalResponse@13277,whole:haJournalResponse@13359,whole:haJournalResponse@13686,whole:haJournalResponse@1372,whole:haJournalResponse@13781,whole:haJournalResponse@13810,whole:haJournalResponse@1633,whole:haJournalResponse@1727,whole:haJournalResponse@2082,whole:haJournalResponse@2223,whole:haJournalResponse@230,whole:haJournalResponse@2319,whole:haJournalResponse@2613,whole:haJournalResponse@2830,whole:haJournalResponse@3330,whole:haJournalResponse@3626,whole:haJournalResponse@3692,whole:haJournalResponse@3988,whole:haJournalResponse@399,whole:haJournalResponse@4057,whole:haJournalResponse@4334,whole:haJournalResponse@4467,whole:haJournalResponse@4561,whole:haJournalResponse@4833,whole:haJournalResponse@4857,whole:haJournalResponse@5144,whole:haJournalResponse@518,whole:haJournalResponse@5214,whole:haJournalResponse@5784,whole:haJournalResponse@5912,whole:haJournalResponse@608,whole:haJournalResponse@6230,whole:haJournalResponse@6421,whole:haJournalResponse@6508,whole:haJournalResponse@6579,whole:haJournalResponse@6792,whole:haJournalResponse@6931,whole:haJournalResponse@7057,whole:haJournalResponse@7316,whole:haJournalResponse@7369,whole:haJournalResponse@7791,whole:haJournalResponse@7971,whole:haJournalResponse@8151,whole:haJournalResponse@8332,whole:haJournalResponse@8372,whole:haJournalResponse@8514,whole:haJournalResponse@8576,whole:haJournalResponse@8807,whole:haJournalResponse@8898,whole:haJournalResponse@892,whole:haJournalResponse@9165,whole:haJournalResponse@9377,whole:haJournalResponse@9972,whole:remoteClient@113,whole:remoteClient@144 934b49e5a287e9a69de5db021f074f7999d12bc149bf890e620f4abe58a24fe9
@coverage internal/alerting cec9c6b025b0b6e2082549827a7cde27ee55820d035b05b60d90dd1746953b31
@coverage internal/host 0741f6152c9070524f77a05467dde38a7cc2053ec0e1c181a11968f5f1298159
-@coverage internal/registry aafbb8b28884b13ccc7d81bd049e5f53e2a512c3e40fc21f9b64fd6fb9f512f9
+@coverage internal/registry 9b3c36f8d5a45335efcf4305d70859f1d1459fd6a1f37768de47626f41920b92
diff --git a/internal/registry/ha_journal.go b/internal/registry/ha_journal.go
index bf647f2cf..c458e3914 100644
--- a/internal/registry/ha_journal.go
+++ b/internal/registry/ha_journal.go
@@ -136,9 +136,17 @@ func (r *Registry) MarkPendingTerminationPaged(ctx context.Context, h HAPendingT
}
// pagedHintCode is the last_error of a hint whose page-once code was
-// delivered. Ordinary codes never contain a space-separated "paged".
+// delivered. Ordinary codes never contain a space.
+//
+// Invariant: once a hint's last_error carries the " paged" suffix, no write
+// replaces it; only removing the hint clears it. hintLastError is the one
+// expression every last_error write goes through.
func pagedHintCode(code string) string { return code + " paged" }
+const hintLastError = `last_error=CASE WHEN last_error LIKE '% paged' THEN last_error ELSE ? END`
+
+func hintPaged(lastError string) bool { return strings.HasSuffix(lastError, " paged") }
+
func (r *Registry) ClaimHAIdentityPage(ctx context.Context, at time.Time) (bool, error) {
out, err := r.haJournal(ctx, haJournalRequest{Op: "identity_page", At: at})
return out.Found, err
@@ -325,7 +333,7 @@ func (r *Registry) haJournal(ctx context.Context, q haJournalRequest) (out haJou
}
out.Found = n == 1
}
- if _, e = tx.ExecContext(ctx, `UPDATE ha_pending_terminations SET next_attempt=?,last_error=? WHERE account=? AND region=? AND iid=?`, journalTime(q.At.Add(30*time.Second)), q.Code, h.Account, h.Region, h.IID); e != nil {
+ if _, e = tx.ExecContext(ctx, `UPDATE ha_pending_terminations SET next_attempt=?,`+hintLastError+` WHERE account=? AND region=? AND iid=?`, journalTime(q.At.Add(30*time.Second)), q.Code, h.Account, h.Region, h.IID); e != nil {
return out, e
}
err = tx.Commit()
@@ -346,7 +354,7 @@ func (r *Registry) haJournal(ctx context.Context, q haJournalRequest) (out haJou
}
return out, e
}
- if last != pagedHintCode(q.Code) {
+ if !hintPaged(last) {
res, e := tx.ExecContext(ctx, `INSERT INTO ha_identity_pages(id,last_page) VALUES(1,?) ON CONFLICT(id) DO UPDATE SET last_page=excluded.last_page WHERE last_page<=?`, journalTime(q.At), journalTime(q.At.Add(-time.Hour)))
if e != nil {
return out, e
@@ -359,9 +367,9 @@ func (r *Registry) haJournal(ctx context.Context, q haJournalRequest) (out haJou
last = q.Code
}
if out.Found {
- _, e = tx.ExecContext(ctx, `UPDATE ha_pending_terminations SET next_attempt=?,last_page=?,last_error=? WHERE account=? AND region=? AND iid=?`, journalTime(q.At.Add(30*time.Second)), journalTime(q.At), last, h.Account, h.Region, h.IID)
+ _, e = tx.ExecContext(ctx, `UPDATE ha_pending_terminations SET next_attempt=?,last_page=?,`+hintLastError+` WHERE account=? AND region=? AND iid=?`, journalTime(q.At.Add(30*time.Second)), journalTime(q.At), last, h.Account, h.Region, h.IID)
} else {
- _, e = tx.ExecContext(ctx, `UPDATE ha_pending_terminations SET next_attempt=?,last_error=? WHERE account=? AND region=? AND iid=?`, journalTime(q.At.Add(30*time.Second)), last, h.Account, h.Region, h.IID)
+ _, e = tx.ExecContext(ctx, `UPDATE ha_pending_terminations SET next_attempt=?,`+hintLastError+` WHERE account=? AND region=? AND iid=?`, journalTime(q.At.Add(30*time.Second)), last, h.Account, h.Region, h.IID)
}
if e != nil {
return out, e
@@ -372,7 +380,7 @@ func (r *Registry) haJournal(ctx context.Context, q haJournalRequest) (out haJou
if q.Code == "" || strings.Contains(q.Code, " ") {
return out, ErrHAJournal
}
- _, err = r.sql.ExecContext(ctx, `UPDATE ha_pending_terminations SET last_error=? WHERE account=? AND region=? AND iid=? AND last_error=?`, pagedHintCode(q.Code), h.Account, h.Region, h.IID, q.Code)
+ _, err = r.sql.ExecContext(ctx, `UPDATE ha_pending_terminations SET `+hintLastError+` WHERE account=? AND region=? AND iid=? AND last_error=?`, pagedHintCode(q.Code), h.Account, h.Region, h.IID, q.Code)
case "reobserve":
tx, e := r.beginClaimTransaction(ctx, true)
if e != nil {
diff --git a/internal/registry/ha_journal_test.go b/internal/registry/ha_journal_test.go
index dc2fda409..8709ea05b 100644
--- a/internal/registry/ha_journal_test.go
+++ b/internal/registry/ha_journal_test.go
@@ -361,3 +361,109 @@ func TestPendingTerminationOnceRefusalIsErrHAJournal(t *testing.T) {
t.Fatal("unknown op", err)
}
}
+
+// Guard for the paged-marker invariant (hintLastError): after a page-once
+// code is delivered and marked, no sequence of journal writes on the hint
+// replaces the marker or claims that page again; only removal clears it.
+// Every sequence of up to two writes from the full op set runs (the property
+// is inductive: each op from each reachable marked state), each step
+// an hour apart so every hourly window is open.
+func TestPendingTerminationPagedMarkerSurvivesEveryOpSequence(t *testing.T) {
+ const once = "evidence_no_observation"
+ h := HAPendingTermination{Account: "111122223333", Region: "eu-west-1", IID: "i-1123456789abcdef0"}
+ type op struct {
+ name string
+ run func(r *Registry, at time.Time) (paged bool, err error)
+ }
+ retry := func(code string) op {
+ return op{"retry:" + code, func(r *Registry, at time.Time) (bool, error) {
+ _, err := r.RetryPendingTermination(t.Context(), h, at, code)
+ return false, err
+ }}
+ }
+ ops := []op{
+ retry("evidence"), retry("identity_unbound"), retry(once),
+ {"once", func(r *Registry, at time.Time) (bool, error) {
+ return r.RetryPendingTerminationOnce(t.Context(), h, at, once)
+ }},
+ {"once:other", func(r *Registry, at time.Time) (bool, error) {
+ return r.RetryPendingTerminationOnce(t.Context(), h, at, "evidence_other")
+ }},
+ {"mark", func(r *Registry, _ time.Time) (bool, error) {
+ return false, r.MarkPendingTerminationPaged(t.Context(), h, once)
+ }},
+ {"mark:other", func(r *Registry, _ time.Time) (bool, error) {
+ return false, r.MarkPendingTerminationPaged(t.Context(), h, "evidence_other")
+ }},
+ {"park", func(r *Registry, at time.Time) (bool, error) {
+ p := h
+ p.ReceivedAt = at
+ return false, r.ParkTermination(t.Context(), p, "")
+ }},
+ {"remove:old", func(r *Registry, _ time.Time) (bool, error) {
+ p := h
+ p.ReceivedAt = time.Unix(1, 0)
+ return false, r.RemovePendingTermination(t.Context(), p)
+ }},
+ }
+ r, _ := adoptRegistry(t)
+ start := time.Now().Add(-24 * time.Hour)
+ var seq []int
+ var walk func(depth int)
+ sequences := 0
+ walk = func(depth int) {
+ if depth > 0 {
+ sequences++
+ if _, err := r.sql.Exec(`DELETE FROM ha_pending_terminations; DELETE FROM ha_identity_pages`); err != nil {
+ t.Fatal(err)
+ }
+ p := h
+ p.ReceivedAt = start
+ if err := r.ParkTermination(t.Context(), p, ""); err != nil {
+ t.Fatal(err)
+ }
+ if page, err := r.RetryPendingTerminationOnce(t.Context(), h, start, once); err != nil || !page {
+ t.Fatal("setup claim", page, err)
+ }
+ if err := r.MarkPendingTerminationPaged(t.Context(), h, once); err != nil {
+ t.Fatal(err)
+ }
+ at := start
+ var names []string
+ for _, i := range seq {
+ at = at.Add(time.Hour + time.Minute)
+ names = append(names, ops[i].name)
+ paged, err := ops[i].run(r, at)
+ if err != nil {
+ t.Fatalf("%v: %v", names, err)
+ }
+ if paged {
+ t.Fatalf("%v: delivered page claimed again", names)
+ }
+ hints, err := r.PendingTerminations(t.Context(), at.Add(24*time.Hour), 32)
+ if err != nil || len(hints) != 1 || hints[0].LastError != pagedHintCode(once) {
+ t.Fatalf("%v: marker lost: %+v %v", names, hints, err)
+ }
+ }
+ }
+ if depth == 2 {
+ return
+ }
+ for i := range ops {
+ seq = append(seq, i)
+ walk(depth + 1)
+ seq = seq[:len(seq)-1]
+ }
+ }
+ walk(0)
+ if sequences != 9+81 {
+ t.Fatalf("sequences=%d", sequences)
+ }
+ // Removal is the one way out.
+ if err := r.RemovePendingTermination(t.Context(), HAPendingTermination{Account: h.Account, Region: h.Region, IID: h.IID, ReceivedAt: time.Now().Add(48 * time.Hour)}); err != nil {
+ t.Fatal(err)
+ }
+ if hints, err := r.PendingTerminations(t.Context(), time.Now().Add(72*time.Hour), 32); err != nil || len(hints) != 0 {
+ t.Fatal(hints, err)
+ }
+}