carlos / platform Public

ha departures: mark the one page only after delivery

Astra round 1: a failed or interrupted SNS delivery used up the single
page, and an older registry server ignoring the Once flag could write a
false marker. The page-once path now uses its own journal op,
retry_hint_once (an older server refuses it and the controller keeps the
hourly retry), and a separate hint_paged op writes "<code> paged" only
after PageIdentity succeeds. Undelivered claims retry under the global
hourly bound. Census overlay ha-departure-evidence.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev aed96da98f917f28254493a5ba06cb0e94b77e25 parent 0638bb7
6 files changed, +156 −54
  • docs/superpowers/notes/census-proposal-ha-departure-evidence.md +26 −0
  • internal/host/hadepartures.go +14 −5
  • internal/host/hadepartures_no_observation_test.go +40 −8
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv +13 −0
  • internal/registry/ha_journal.go +62 −41

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-Va3wOM
.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/s3 v1.105.0
go: downloading golang.org/x/sys v0.49.0
go: downloading github.com/aws/aws-sdk-go-v2/service/costexplorer v1.67.5
go: downloading github.com/aws/smithy-go v1.28.1
go: downloading github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.68.0
go: downloading golang.org/x/crypto v0.58.0
go: downloading github.com/benbjohnson/litestream v0.5.14
go: downloading golang.org/x/net v0.62.0
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/aws/aws-sdk-go-v2/service/sts v1.45.6
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/pierrec/lz4/v4 v4.1.22
go: downloading github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.38
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/pion/transport/v4 v4.0.2
go: downloading github.com/pion/dtls/v3 v3.1.4
go: downloading github.com/cespare/xxhash/v2 v2.3.0
go: downloading github.com/prometheus/common v0.45.0
go: downloading google.golang.org/protobuf v1.36.10
go: downloading github.com/prometheus/client_model v0.5.0
go: downloading github.com/prometheus/procfs v0.12.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/wlynxg/anet v0.0.5
go: downloading golang.org/x/text v0.43.0
go: downloading modernc.org/sqlite v1.55.0
go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
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 github.com/pierrec/lz4/v4 v4.1.22
go: downloading modernc.org/libc v1.74.1
go: downloading modernc.org/libc v1.74.1
go: downloading modernc.org/memory v1.11.0
go: downloading github.com/google/uuid v1.6.0
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec

amadan: job cancelled — a newer push superseded it

Intent

Human

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

diff --git a/docs/superpowers/notes/census-proposal-ha-departure-evidence.md b/docs/superpowers/notes/census-proposal-ha-departure-evidence.md
new file mode 100644
index 000000000..ca320c936
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-ha-departure-evidence.md
@@ -0,0 +1,26 @@
+# Census approval: ha-departure-evidence
+
+Ruling `census-ruling-ha-departure-evidence`. The independent reviewer approves or rejects every change below, 2 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `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. |
+| `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. |
+
+Envelopes re-pinned: `internal/host`, `internal/registry`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/host/hadepartures.go` `Controller.step`: legacy, task accepted-legacy. Basis: 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.
+- `internal/registry/ha_journal.go` `Registry.haJournal`: legacy, task accepted-legacy. Basis: 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.
+
+New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
+
+- 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: `b2f039a12bb284c9a36b391339e25e3f77ec94a3d4e38389ec9ef75261d7873f` → `818b5c40f261f18576c3ad4f0fbc7ad1e316cef86b515aa487f23852b5eb6bcf`.
+
+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/host/hadepartures.go b/internal/host/hadepartures.go
index c1d97b03f..2e53072d9 100644
--- a/internal/host/hadepartures.go
+++ b/internal/host/hadepartures.go
@@ -450,13 +450,18 @@ func (c *Controller) step(ctx context.Context) error {
}
continue
}
- retry := c.cfg.Registry.RetryPendingTermination
+ onceCode := ""
+ var page bool
if once {
- retry = c.cfg.Registry.RetryPendingTerminationOnce
+ // An older registry server refuses the op; keep its hourly retry.
+ if page, e = c.cfg.Registry.RetryPendingTerminationOnce(ctx, h, c.now(), code); e == nil {
+ onceCode = code
+ }
}
- page, e := retry(ctx, h, c.now(), code)
- if e != nil {
- return e
+ if onceCode == "" {
+ if page, e = c.cfg.Registry.RetryPendingTermination(ctx, h, c.now(), code); e != nil {
+ return e
+ }
}
if page {
count, e := c.cfg.Registry.PendingTerminationCount(ctx)
@@ -471,6 +476,10 @@ func (c *Controller) step(ctx context.Context) error {
if c.cfg.PageIdentity != nil {
if e = c.cfg.PageIdentity(ctx, h, code); e != nil {
c.logf("ha_departure_page code=failed iid=%s error=%v", h.IID, e)
+ } else if onceCode != "" {
+ if e = c.cfg.Registry.MarkPendingTerminationPaged(ctx, h, onceCode); e != nil {
+ return e
+ }
}
}
}
diff --git a/internal/host/hadepartures_no_observation_test.go b/internal/host/hadepartures_no_observation_test.go
index 56d708da8..cb53ab63b 100644
--- a/internal/host/hadepartures_no_observation_test.go
+++ b/internal/host/hadepartures_no_observation_test.go
@@ -2,6 +2,7 @@ package host
import (
"context"
+ "errors"
"strings"
"testing"
"time"
@@ -49,7 +50,13 @@ func TestDeparturePendingWithoutObservationPagesOnce(t *testing.T) {
codes = append(codes, code)
return nil
}
- x.c.cfg.PageIdentity = page
+ // The first delivery fails; the page is retried within the hourly bound
+ // and stops only once one is delivered.
+ failed := 0
+ x.c.cfg.PageIdentity = func(ctx context.Context, p registry.HAPendingTermination, code string) error {
+ failed++
+ return errors.New("sns down")
+ }
run := func(c *Controller, d time.Duration) {
t.Helper()
end := x.now.Add(d)
@@ -59,6 +66,11 @@ func TestDeparturePendingWithoutObservationPagesOnce(t *testing.T) {
}
}
}
+ run(x.c, 59*time.Minute)
+ if failed != 1 {
+ t.Fatalf("failed deliveries=%d, want 1 inside the hour", failed)
+ }
+ x.c.cfg.PageIdentity = page
run(x.c, 3*time.Hour)
// Restart: a fresh controller on the same journal.
restarted := &Controller{cfg: x.c.cfg}
@@ -67,7 +79,7 @@ func TestDeparturePendingWithoutObservationPagesOnce(t *testing.T) {
t.Fatalf("pages=%q, want exactly one evidence_no_observation page", codes)
}
hints, err := x.r.PendingTerminations(t.Context(), x.now.Add(time.Hour), 32)
- if err != nil || len(hints) != 1 || hints[0].IID != iid || hints[0].LastError != "evidence_no_observation" {
+ if err != nil || len(hints) != 1 || hints[0].IID != iid || hints[0].LastError != "evidence_no_observation paged" {
t.Fatalf("hint must stay pending with its reason: %+v %v", hints, err)
}
rows, err := x.r.PendingDepartures(t.Context(), x.now.Add(24*time.Hour), 32)
@@ -81,13 +93,14 @@ func TestDeparturePendingWithoutObservationPagesOnce(t *testing.T) {
}
}
-func TestPendingTerminationOnceRetriesWhenGloballyThrottled(t *testing.T) {
+func TestPendingTerminationOnceRetriesUntilDelivered(t *testing.T) {
r, err := registry.Open(t.TempDir() + "/registry.db")
if err != nil {
t.Fatal(err)
}
defer r.Close()
ctx, at := t.Context(), time.Now()
+ const code = "evidence_no_observation"
a := registry.HAPendingTermination{Account: "111122223333", Region: "eu-west-1", IID: "i-1123456789abcdef0", ReceivedAt: at}
b := a
b.IID = "i-2123456789abcdef0"
@@ -99,14 +112,33 @@ func TestPendingTerminationOnceRetriesWhenGloballyThrottled(t *testing.T) {
if page, e := r.RetryPendingTermination(ctx, a, at, "evidence"); e != nil || !page {
t.Fatal("first page", page, e)
}
- // The global hourly bound withholds b's page; it must not be lost.
- if page, e := r.RetryPendingTerminationOnce(ctx, b, at.Add(time.Minute), "evidence_no_observation"); e != nil || page {
+ // An older server's ordinary retry writes the bare code while the global
+ // bound withholds the page; that must not read as delivered.
+ if page, e := r.RetryPendingTermination(ctx, b, at.Add(time.Minute), code); e != nil || page {
+ t.Fatal("throttled ordinary page", page, e)
+ }
+ if page, e := r.RetryPendingTerminationOnce(ctx, b, at.Add(2*time.Minute), code); e != nil || page {
t.Fatal("throttled page", page, e)
}
- if page, e := r.RetryPendingTerminationOnce(ctx, b, at.Add(time.Hour+time.Minute), "evidence_no_observation"); e != nil || !page {
- t.Fatal("withheld page never sent", page, e)
+ // Claimed but never marked (delivery failed, or the process stopped):
+ // claimed again after the hourly bound, not every pass.
+ if page, e := r.RetryPendingTerminationOnce(ctx, b, at.Add(time.Hour+time.Minute), code); e != nil || !page {
+ t.Fatal("withheld page never claimed", page, e)
}
- if page, e := r.RetryPendingTerminationOnce(ctx, b, at.Add(3*time.Hour), "evidence_no_observation"); e != nil || page {
+ if page, e := r.RetryPendingTerminationOnce(ctx, b, at.Add(time.Hour+2*time.Minute), code); e != nil || page {
+ t.Fatal("undelivered page reclaimed inside the hour", page, e)
+ }
+ if page, e := r.RetryPendingTerminationOnce(ctx, b, at.Add(2*time.Hour+2*time.Minute), code); e != nil || !page {
+ t.Fatal("undelivered page not retried", page, e)
+ }
+ if err = r.MarkPendingTerminationPaged(ctx, b, code); err != nil {
+ t.Fatal(err)
+ }
+ if page, e := r.RetryPendingTerminationOnce(ctx, b, at.Add(5*time.Hour), code); e != nil || page {
t.Fatal("paged twice", page, e)
}
+ hints, err := r.PendingTerminations(ctx, at.Add(6*time.Hour), 32)
+ if err != nil || len(hints) != 2 {
+ t.Fatal(hints, err)
+ }
}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index dc67c94ce..4cf0568b5 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -277,3 +277,4 @@ plan14-root-reads-headers-security-allowlist.tsv f959a3626e83650aaad1880eecc3fed
plan14-root-reads-stateless-scale-1-memory-env.tsv 47ebd73418bcbe1bdf9cf34a2b94e3393a1279aea58f9ee0aca3f0cfe42b9132
plan14-root-reads-group-revoke-readback-1255.tsv 47ebd73418bcbe1bdf9cf34a2b94e3393a1279aea58f9ee0aca3f0cfe42b9132
plan14-root-reads-precert-dns01-1293.tsv b2f039a12bb284c9a36b391339e25e3f77ec94a3d4e38389ec9ef75261d7873f
+plan14-root-reads-ha-departure-evidence.tsv 818b5c40f261f18576c3ad4f0fbc7ad1e316cef86b515aa487f23852b5eb6bcf
diff --git a/internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv b/internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv
new file mode 100644
index 000000000..6753ab2f7
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv
@@ -0,0 +1,13 @@
+# Census overlay ha-departure-evidence, written by census-propose (#369). census-ruling-ha-departure-evidence, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-ha-departure-evidence.md.
+# 0 body, 2 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 2 new dispositions: 0 reads re-frozen at their disposition with the claim, 2 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+@legacy de5290a2011654dd25871ee9b7dfbb95045989f5b944dc01f1165095dc1ebf24 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
+@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 62d62e395fe09b5233aa5a33b508678a158c373d3c1da530f5dad05af1890587 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. file:Walk@2717,registry:Body@1979,registry:IID@2554,registry:IID@2971,registry:IID@3757,registry:IID@3790,registry:IID@4736,registry:IID@4894,registry:Key@2081,registry:Key@2317,registry:LastBlocked@2872,registry:NextAttempt@6456,registry:NextAttempt@6481,registry:ReceivedAt@2300,registry:ReceivedAt@3688,whole:HADeparture@6346,whole:HADeparture@6432,whole:HADeparture@6456,whole:HADeparture@6519,whole:HADeparture@6526,whole:HADeparture@6734,whole:HADeparture@7702,whole:HADeparture@8025,whole:HAPendingTermination@2495,whole:HAPendingTermination@2912,whole:HAPendingTermination@3599,whole:HAPendingTermination@3882,whole:HAPendingTermination@4110,whole:HAPendingTermination@4251,whole:HAPendingTermination@4812,whole:HAPendingTermination@4995,whole:HAPendingTermination@5566,whole:HATerminationInbox@1939 23e9712dcf7767ed2657a16736a9214d153ca614039a5674207c9ed29cd377f1
+@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
+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. file:Walk@2717,registry:Body@1979,registry:IID@2554,registry:IID@2971,registry:IID@3757,registry:IID@3790,registry:IID@4736,registry:IID@4894,registry:Key@2081,registry:Key@2317,registry:LastBlocked@2872,registry:NextAttempt@6456,registry:NextAttempt@6481,registry:ReceivedAt@2300,registry:ReceivedAt@3688,whole:HADeparture@6346,whole:HADeparture@6432,whole:HADeparture@6456,whole:HADeparture@6519,whole:HADeparture@6526,whole:HADeparture@6734,whole:HADeparture@7702,whole:HADeparture@8025,whole:HAPendingTermination@2495,whole:HAPendingTermination@2912,whole:HAPendingTermination@3599,whole:HAPendingTermination@3882,whole:HAPendingTermination@4110,whole:HAPendingTermination@4251,whole:HAPendingTermination@4812,whole:HAPendingTermination@4995,whole:HAPendingTermination@5566,whole:HATerminationInbox@1939 23e9712dcf7767ed2657a16736a9214d153ca614039a5674207c9ed29cd377f1
+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
+@coverage internal/host 24eb7bac37c5c2c95eb112e3ac343885377fd8f3c0c48798150bd279b22ec78f
+@coverage internal/registry aafbb8b28884b13ccc7d81bd049e5f53e2a512c3e40fc21f9b64fd6fb9f512f9
diff --git a/internal/registry/ha_journal.go b/internal/registry/ha_journal.go
index f800a3cd8..bf647f2cf 100644
--- a/internal/registry/ha_journal.go
+++ b/internal/registry/ha_journal.go
@@ -7,6 +7,7 @@ import (
"encoding/json"
"errors"
"fmt"
+ "strings"
"time"
"github.com/carlosframework/platform/internal/hadeparture"
@@ -52,7 +53,6 @@ type haJournalRequest struct {
At, Next time.Time
Limit int
Page bool
- Once bool
Departure HADeparture
Identity HABoxIdentity
Walk HAIdentityWalk
@@ -118,14 +118,27 @@ func (r *Registry) RetryPendingTermination(ctx context.Context, h HAPendingTermi
// RetryPendingTerminationOnce is RetryPendingTermination for a state that
// paging again cannot change (a bound identity this box never observed). It
-// pages at most once per hint and code: the code is persisted in last_error
-// only when the page is claimed, so restarts do not re-page, and a page
-// withheld by the global hourly bound is retried later.
+// claims a page under the global hourly bound unless MarkPendingTerminationPaged
+// already recorded a delivered page for this hint and code. A claimed page
+// that fails or is interrupted before the mark is claimed again later.
+// It is its own op: an older registry server refuses it rather than running
+// the ordinary retry, and the caller falls back to that retry.
func (r *Registry) RetryPendingTerminationOnce(ctx context.Context, h HAPendingTermination, at time.Time, code string) (bool, error) {
- out, err := r.haJournal(ctx, haJournalRequest{Op: "retry_hint", Hint: h, At: at, Code: code, Once: true})
+ out, err := r.haJournal(ctx, haJournalRequest{Op: "retry_hint_once", Hint: h, At: at, Code: code})
return out.Found, err
}
+// MarkPendingTerminationPaged records that the page RetryPendingTerminationOnce
+// claimed for code was delivered.
+func (r *Registry) MarkPendingTerminationPaged(ctx context.Context, h HAPendingTermination, code string) error {
+ _, err := r.haJournal(ctx, haJournalRequest{Op: "hint_paged", Hint: h, Code: code})
+ return err
+}
+
+// pagedHintCode is the last_error of a hint whose page-once code was
+// delivered. Ordinary codes never contain a space-separated "paged".
+func pagedHintCode(code string) string { return code + " 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
@@ -292,42 +305,6 @@ func (r *Registry) haJournal(ctx context.Context, q haJournalRequest) (out haJou
return out, e
}
defer tx.Rollback()
- if q.Once {
- if q.Code == "" {
- return out, ErrHAJournal
- }
- var last string
- if e = tx.QueryRowContext(ctx, `SELECT last_error FROM ha_pending_terminations WHERE account=? AND region=? AND iid=?`, h.Account, h.Region, h.IID).Scan(&last); e != nil {
- if errors.Is(e, sql.ErrNoRows) {
- return out, nil
- }
- return out, e
- }
- code := last
- if last != q.Code {
- 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
- }
- n, e := res.RowsAffected()
- if e != nil {
- return out, e
- }
- if out.Found = n == 1; out.Found {
- code = 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), code, 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)), code, h.Account, h.Region, h.IID)
- }
- if e != nil {
- return out, e
- }
- err = tx.Commit()
- break
- }
res, e := tx.ExecContext(ctx, `UPDATE ha_pending_terminations SET last_page=? WHERE account=? AND region=? AND iid=? AND (last_page=0 OR last_page<=?)`, journalTime(q.At), h.Account, h.Region, h.IID, journalTime(q.At.Add(-time.Hour)))
if e != nil {
return out, e
@@ -352,6 +329,50 @@ func (r *Registry) haJournal(ctx context.Context, q haJournalRequest) (out haJou
return out, e
}
err = tx.Commit()
+ case "retry_hint_once":
+ h := q.Hint
+ if q.Code == "" || strings.Contains(q.Code, " ") {
+ return out, ErrHAJournal
+ }
+ tx, e := r.beginClaimTransaction(ctx, true)
+ if e != nil {
+ return out, e
+ }
+ defer tx.Rollback()
+ var last string
+ if e = tx.QueryRowContext(ctx, `SELECT last_error FROM ha_pending_terminations WHERE account=? AND region=? AND iid=?`, h.Account, h.Region, h.IID).Scan(&last); e != nil {
+ if errors.Is(e, sql.ErrNoRows) {
+ return out, nil
+ }
+ return out, e
+ }
+ if last != pagedHintCode(q.Code) {
+ 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
+ }
+ n, e := res.RowsAffected()
+ if e != nil {
+ return out, e
+ }
+ out.Found = n == 1
+ 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)
+ } 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)
+ }
+ if e != nil {
+ return out, e
+ }
+ err = tx.Commit()
+ case "hint_paged":
+ h := q.Hint
+ 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)
case "reobserve":
tx, e := r.beginClaimTransaction(ctx, true)
if e != nil {