carlos / platform Public

census: overlay for replicate before start (#1290)

make census-propose NAME=replica-wake-gap: nine new or changed units in
internal/lease and two in internal/activator, every read on agent-owned
paths derived from the route database. Awaits the reviewer verdict.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev f1fe437e2197ecb8ace7b5c8db9f6cfb83489bee parent 2f3e059
3 files changed, +62 −0
  • docs/superpowers/notes/census-proposal-replica-wake-gap.md +33 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-replica-wake-gap.tsv +28 −0

CI failed — run details

diff --git a/docs/superpowers/notes/census-proposal-replica-wake-gap.md b/docs/superpowers/notes/census-proposal-replica-wake-gap.md
new file mode 100644
index 000000000..2ccf144e1
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-replica-wake-gap.md
@@ -0,0 +1,33 @@
+# Census approval: replica-wake-gap
+
+Ruling `census-ruling-replica-wake-gap`. The independent reviewer approves or rejects every change below, 9 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/lease/checkpoint.go` `Held.Checkpoint` | body | unchanged (1) | Replicate before start (#1290): decides continuity (beginContinuity) before the store opens, runs startProtected (bounded first sync; a full image when continuity is unproven) before its sync, and writes the clean record after a successful close. Same database path the caller passed; no new path, input or root decision; the agent runs it as carlos. |
+| `internal/activator/activator.go` `Service.doWakeOnce` | sites | +registry:DBPath | Step 2c: before the seed and the spawn, asks the lease to ProtectStart(rt.DBPath), the route's own database path already used by Restore and retainDatabase; a refusal gives the lease back and starts nothing. Agent code (user carlos); no root call, no new store or file read here. |
+
+Envelopes re-pinned: `.`, `internal/activator`, `internal/lease`.
+
+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/lease/checkpoint.go` `Held.Checkpoint`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input
+- `internal/activator/activator.go` `Service.doWakeOnce`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-stateless-replicas-1;basis=Task 3a: The former doWake body, not deleted logic: refresh/admit/fence/layout checks remain. Select and verify the actual staged identity before serving Acquire; use canonical mode to call doStatelessWake. Keep SQLite acquire/restore/seed/marker/replicate only in the stateful arm, with the post-acquisition selection recheck and existing cleanup proofs. Fix 3a round 1 I1/I3a: admit config directly only for stateless and mark runtime ownership refusals. Stateful Acquire/Restore precede selection and pending publication; canonical mode inspection is separate, replan precedes settlement. Fix round 2 N2/N3: retain the original route/pin projection for post-lease declaration checks; reuse the unplanned capture so a live-link repoint cannot change the selected build. Stateful capture and changed-copy errors remain start failures after Acquire/Restore. A failed preliminary verification supplies no cached mode observation. No new file path or database authority. Final review C1/R26: unprojected stateful wakes capture and materialize the live link only after Acquire and Restore. Retain original route/generation/pin stateless evidence on the context across fallback, so missing stateless evidence cannot take stateful recovery inference. Known good stateful identity skips canonical declaration lookup. Existing pre-exec verification remains. R28 final fix 2: carry whether this wake has a plan in attempt-local context; no new read here; route, generation and pin stateless projection remains intact.;rev3=census-ruling-agent-start-demo-1;basis=Reads IsDemo and demo admission/capability state; chooses local lease retention, skips seed upload and sidecar selection. Existing stop and under-lease ordering retained.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: refuse tenant starts under the existing service lock before main's demoWakeRefusal, and recheck before backend Acquire. Retain main's demo refusal and all lease, restore and serialization checks. Two added whole Route uses feed the in-memory admission predicate; no new filesystem or store read.;rev3=census-ruling-stateless-replicas-2;basis=P14: after verified storage-mode selection, before clearing the projected hint or acquiring a database lease, a set row still on the stateful branch returns ErrFenced. Reads the existing route FleetBoxes field only. Verified stateless wakes take their existing branch; legacy rows remain unchanged. No new file, registry query or bucket read. merge of origin/main 9b8b2c50: retain wake-slot and HA duty logic alongside the replica stateful-start refusal; no gate removed. merge of origin/main 6be08467: Keep main demo lease, local database and KeepLocal path; never equate replication-disabled demos with stateless generations. Merge-only body/read-site change. merge of origin/main 7920cccf: Retain main tenant admission and startOwnedLocked gates alongside the replica stateful-start refusal; whole Route passed to main admission checks, no new path or store read.;rev3=census-ruling-agent-start-demo-3;basis=Route claim seeds through seed restore/admission; do not fall back to empty boot or ordinary import behavior. Census read-site delta: +registry:SeedSource, +whole:Route.;rev3=census-ruling-region-ha-g2-fixes;basis=Bound recovery Acquire by its attempt deadline; existing acquire/restore/start ordering remains; no new read.;rev3=census-ruling-g6-fence;basis=G6 F-C Task 3, the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): right after retainDatabase returns, attaches the write-fence watcher under a.mu (watchWriteFenceLocked, in memory). retainDatabase is called through a retainDB test seam that is nil in production. No read added; no root call; existing acquire, restore, publisher and cleanup order unchanged.;rev3=census-ruling-sr-followups;basis=#1061 Task 1, the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): a refused plan now returns planRefusal(host, plan) instead of the inline fmt.Errorf, the text is unchanged, and when the planner marked the plan Installing the error also matches errBuildNotInstalled (installRefusal, in memory). Same refusal at the same point before the lease, read sites unchanged, no read, file, store, bucket or root call added
+
+New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
+
+- new `internal/lease/continuity.go:Protection.pin`: reads +file:Open, +file:QueryRow ×2, +file:Stat; written legacy, accepted-legacy, frozen
+- new `internal/lease/continuity.go:currentState`: reads +file:ReadDir, +file:Stat ×2; written legacy, accepted-legacy, frozen
+- new `internal/lease/continuity.go:firstLocalL0After`: reads +file:ReadDir; written legacy, accepted-legacy, frozen
+- new `internal/lease/continuity.go:fullImage`: reads +file:Open; written legacy, accepted-legacy, frozen
+- new `internal/lease/continuity.go:isContinuous`: reads +file:ReadFile; written legacy, accepted-legacy, frozen
+- new `internal/lease/continuity.go:newestLocalL0`: reads +file:ReadDir; written legacy, accepted-legacy, frozen
+- new `internal/lease/continuity.go:recordClean`: reads +file:OpenFile; written legacy, accepted-legacy, frozen
+- new `internal/lease/continuity.go:startProtected`: reads +file:Stat; written legacy, accepted-legacy, frozen
+- reads `internal/lease/lease.go:Held.Replicate`: +file:Stat; keeps legacy, task accepted-legacy
+
+Seal: `aa2c0729fe761d6438d2e8b9ef4ef2c1a20699f5e81dded1783c9a008dfafba9` → `00d5ca32b8eea4eae2c0104a10c680b9cd86f90d2a63f34fb110c1707f5d729c`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-replica-wake-gap.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 87f1ac29c..fa2aa8b19 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -257,3 +257,4 @@ plan14-root-reads-ha-generations.tsv 5bf2d00767807be812b004a474352ec184788be3ce6
plan14-root-reads-named-units-param-114.tsv 8daea28ba9b419e8680e8eb0d44a577c68ec01e02663a878288441dc579cc9f7
plan14-root-reads-race-activator-1249.tsv 879cc401365966a2ca23962245ce9dff4b7879fe7a27b7691c3d91a4e70ff6e8
plan14-root-reads-named-units-guard-fix.tsv aa2c0729fe761d6438d2e8b9ef4ef2c1a20699f5e81dded1783c9a008dfafba9
+plan14-root-reads-replica-wake-gap.tsv 00d5ca32b8eea4eae2c0104a10c680b9cd86f90d2a63f34fb110c1707f5d729c
diff --git a/internal/provision/testdata/plan14-root-reads-replica-wake-gap.tsv b/internal/provision/testdata/plan14-root-reads-replica-wake-gap.tsv
new file mode 100644
index 000000000..99005fef7
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-replica-wake-gap.tsv
@@ -0,0 +1,28 @@
+# Census overlay replica-wake-gap, written by census-propose (#369). census-ruling-replica-wake-gap, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-replica-wake-gap.md.
+# 1 body, 1 sites, 3 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 9 new dispositions: 1 reads re-frozen at their disposition with the claim, 8 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+@legacy 88b9f7c7e9f19bc65301fb5b0a811710e34833e3e7bee18c41e405e7fc2dc2d1 internal/lease/checkpoint.go Held.Checkpoint legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-replica-wake-gap;basis=Replicate before start (#1290): decides continuity (beginContinuity) before the store opens, runs startProtected (bounded first sync; a full image when continuity is unproven) before its sync, and writes the clean record after a successful close. Same database path the caller passed; no new path, input or root decision; the agent runs it as carlos. file:Open@1016 337104180154a1e2f0f4d2126a4bb1b67862d8400431cc5e0b8920acced92b40
+@legacy 54e3d9197838d727d894422f43a9ee9fc5c8a9a2b003150db13d466f6ae85308 internal/lease/continuity.go Protection.pin legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Opens a SQLite read transaction on the route's database (agent, user carlos) after stat-ing its -wal and -shm, reading PRAGMA journal_mode and sqlite_master; creates nothing, changes no mode. The path is the activator's own route database path. No root involvement. file:Open@187,file:QueryRow@343,file:QueryRow@594,file:Stat@122 c4c63fc921746b07fd3d32d6f50efc7c629b859f2501c0ebd0cf722d5c2c2461
+@legacy d030b9502dda81d9cc9869bf6e9e8590484242b7146e15b9739c671d330f7b86 internal/lease/continuity.go currentState legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Stats the route database and its -wal, and lists the replicator's own litestream meta directory's ltx/0, to compare with the clean record. Agent-owned files; read only. file:ReadDir@437,file:Stat@242,file:Stat@67 8e967e777f5a9d0023301075cf815bd49f5f7db3abf29de9a2b9decf57076376
+@legacy 4de020698bb10e5fc4e0a8e8bcfab93b9c441d7d4d24d7105b3c71f8ffc8ed22 internal/lease/continuity.go firstLocalL0After legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Lists the replicator's own meta directory ltx/0 to find the first file this start's sync wrote. Agent-owned; read only. file:ReadDir@88 e461881156a87217f87ed2954dafe18bcc5fead639fa64269254f8fbc7b0d92a
+@legacy a432c2653799c156dc6a4ba1d625607a9e0bb0abd9b200d695e4bce3bd249025 internal/lease/continuity.go fullImage legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Opens and decodes one local L0 file the replicator just wrote, to see whether it holds every page. Agent-owned; read only; a failed read means not a full image (the safe answer: a snapshot follows). file:Open@46 09979451df76b17e8ded6b8258ef53a6d6a42243e55663fbc03cc270c276266f
+@legacy 0751d4702f97f68e190f60b9f18b23b424ddd457c435558972eb416bc55456c5 internal/lease/continuity.go isContinuous legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Reads the clean record carlos-clean.json from the replicator's own meta directory; anything unreadable is not proof of continuity (the safe answer). file:ReadFile@53 f7daf19b564808f09f2ece439b96d6271ddc2a70f1a783380c24e4cca7fd6992
+@legacy 05f14720dc83844accd94cdc76434d73a78c18aecdb28ad1851e75784d8e4332 internal/lease/continuity.go newestLocalL0 legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Lists the replicator's own meta directory ltx/0 for the newest TXID. Agent-owned; read only. file:ReadDir@61 8c9c7aa118a38ee4c3283c03deaa0c679dd0efa9c9a4738081616fc89cbc94ca
+@legacy b0ab3c5efd4d42056748db4afa5cadf70dca9468dfd6ec98ad4d4389eec2fcaa internal/lease/continuity.go recordClean legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Writes carlos-clean.json (0600, tmp then rename, fsync) in the replicator's own meta directory after a successful final sync and close. Agent-owned path derived from the route's database path. file:OpenFile@302 02ef85663928f46f0ab7fbc8e215e7f5fe162184847a3cf027200d892a833e1c
+@legacy d789c24a8394c752bd37a94c117b70c685670b4c3ad3f4a016477d1d098787bd internal/lease/continuity.go startProtected legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Stats the route database to tell a first start (no file) from an existing one; then litestream's own sync and, when continuity is unproven, a snapshot through the existing replica client. No new path or input. file:Stat@99 c56f5b768ffd6c8e7e03871fd0bb2901c13f3d575b50c4c06eed2c4a504aca46
+@legacy e0078a800a928855fb57533940fba37d4d95d125651872c2e201943ab4e5f6ac internal/lease/lease.go Held.Replicate legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: the Replicator it returns also carries the handle's ha flag, marker base and region, so an HA replicator releases through the marker only; the store setup, its five steps and the transfer are unchanged; the one site unchanged, no read added;rev3=census-ruling-g6-fence;basis=G6 F-C Task 2, the agent as carlos: for an HA lease at sync interval 0 only, wraps db.Replica.Client in the write fence's gate (fenceGate: cancels and refuses replica calls after the event, except the finalization's) before store.Open, and starts the fence goroutine (runFence) on db.WALPath(), the instance's own -wal; the Replicator gains done and fenced channels. The one site unchanged; no root read added; store setup, its steps and the transfer unchanged.;rev3=census-ruling-replica-wake-gap;basis=Adds beginContinuity before the store opens, a Stat of dbPath (no file: reset local litestream state so the first sync is a full image), and startProtected after Open; a failure closes the store and returns the error. Same dbPath, same replica client; no root decision. file:Open@1243,file:Stat@1041 dee32cbbd3175437275b82e6940a909914ec151fd0386064b562323a2672cbd5
+@legacy 1de971dac75880774de65d3d3fe8e33240e311352dc694ac9a5841a99c71eb84 internal/activator/activator.go Service.doWakeOnce legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-1;basis=Task 3a: The former doWake body, not deleted logic: refresh/admit/fence/layout checks remain. Select and verify the actual staged identity before serving Acquire; use canonical mode to call doStatelessWake. Keep SQLite acquire/restore/seed/marker/replicate only in the stateful arm, with the post-acquisition selection recheck and existing cleanup proofs. Fix 3a round 1 I1/I3a: admit config directly only for stateless and mark runtime ownership refusals. Stateful Acquire/Restore precede selection and pending publication; canonical mode inspection is separate, replan precedes settlement. Fix round 2 N2/N3: retain the original route/pin projection for post-lease declaration checks; reuse the unplanned capture so a live-link repoint cannot change the selected build. Stateful capture and changed-copy errors remain start failures after Acquire/Restore. A failed preliminary verification supplies no cached mode observation. No new file path or database authority. Final review C1/R26: unprojected stateful wakes capture and materialize the live link only after Acquire and Restore. Retain original route/generation/pin stateless evidence on the context across fallback, so missing stateless evidence cannot take stateful recovery inference. Known good stateful identity skips canonical declaration lookup. Existing pre-exec verification remains. R28 final fix 2: carry whether this wake has a plan in attempt-local context; no new read here; route, generation and pin stateless projection remains intact.;rev3=census-ruling-agent-start-demo-1;basis=Reads IsDemo and demo admission/capability state; chooses local lease retention, skips seed upload and sidecar selection. Existing stop and under-lease ordering retained.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: refuse tenant starts under the existing service lock before main's demoWakeRefusal, and recheck before backend Acquire. Retain main's demo refusal and all lease, restore and serialization checks. Two added whole Route uses feed the in-memory admission predicate; no new filesystem or store read.;rev3=census-ruling-stateless-replicas-2;basis=P14: after verified storage-mode selection, before clearing the projected hint or acquiring a database lease, a set row still on the stateful branch returns ErrFenced. Reads the existing route FleetBoxes field only. Verified stateless wakes take their existing branch; legacy rows remain unchanged. No new file, registry query or bucket read. merge of origin/main 9b8b2c50: retain wake-slot and HA duty logic alongside the replica stateful-start refusal; no gate removed. merge of origin/main 6be08467: Keep main demo lease, local database and KeepLocal path; never equate replication-disabled demos with stateless generations. Merge-only body/read-site change. merge of origin/main 7920cccf: Retain main tenant admission and startOwnedLocked gates alongside the replica stateful-start refusal; whole Route passed to main admission checks, no new path or store read.;rev3=census-ruling-agent-start-demo-3;basis=Route claim seeds through seed restore/admission; do not fall back to empty boot or ordinary import behavior. Census read-site delta: +registry:SeedSource, +whole:Route.;rev3=census-ruling-region-ha-g2-fixes;basis=Bound recovery Acquire by its attempt deadline; existing acquire/restore/start ordering remains; no new read.;rev3=census-ruling-g6-fence;basis=G6 F-C Task 3, the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): right after retainDatabase returns, attaches the write-fence watcher under a.mu (watchWriteFenceLocked, in memory). retainDatabase is called through a retainDB test seam that is nil in production. No read added; no root call; existing acquire, restore, publisher and cleanup order unchanged.;rev3=census-ruling-sr-followups;basis=#1061 Task 1, the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): a refused plan now returns planRefusal(host, plan) instead of the inline fmt.Errorf, the text is unchanged, and when the planner marked the plan Installing the error also matches errBuildNotInstalled (installRefusal, in memory). Same refusal at the same point before the lease, read sites unchanged, no read, file, store, bucket or root call added;rev3=census-ruling-replica-wake-gap;basis=Step 2c: before the seed and the spawn, asks the lease to ProtectStart(rt.DBPath), the route's own database path already used by Restore and retainDatabase; a refusal gives the lease back and starts nothing. Agent code (user carlos); no root call, no new store or file read here. registry:DBPath@2071,registry:DBPath@2087,registry:DBPath@21869,registry:DBPath@2214,registry:DBPath@2225,registry:FleetBoxes@12030,registry:GoodVersion@18320,registry:Host@1900,registry:Host@1975,registry:Host@2053,registry:Host@2205,registry:Host@2539,registry:Host@4556,registry:Host@6813,registry:Host@949,registry:Replication@16947,registry:Replication@17076,registry:Replication@17095,registry:Replication@17176,registry:Replication@34070,registry:Seed@22754,registry:SeedSource@35530,registry:Socket@2100,registry:Socket@2116,registry:Socket@2239,registry:Socket@2250,registry:Stateless@10090,registry:Stateless@10376,registry:Stateless@11748,registry:Stateless@12078,registry:Stateless@20729,registry:Stateless@9633,registry:Stateless@9724,whole:Route@10162,whole:Route@10321,whole:Route@10700,whole:Route@10798,whole:Route@10889,whole:Route@11021,whole:Route@11144,whole:Route@11198,whole:Route@11470,whole:Route@11646,whole:Route@11650,whole:Route@12437,whole:Route@12712,whole:Route@13030,whole:Route@142,whole:Route@14491,whole:Route@15168,whole:Route@16049,whole:Route@16927,whole:Route@17178,whole:Route@18523,whole:Route@19114,whole:Route@19279,whole:Route@1998,whole:Route@20215,whole:Route@21011,whole:Route@21286,whole:Route@22855,whole:Route@22926,whole:Route@2434,whole:Route@2439,whole:Route@2493,whole:Route@2499,whole:Route@25420,whole:Route@2565,whole:Route@2573,whole:Route@2629,whole:Route@27278,whole:Route@27924,whole:Route@29231,whole:Route@29385,whole:Route@29884,whole:Route@29954,whole:Route@30541,whole:Route@31626,whole:Route@32057,whole:Route@32265,whole:Route@32319,whole:Route@33248,whole:Route@333,whole:Route@33433,whole:Route@34233,whole:Route@34304,whole:Route@35022,whole:Route@35071,whole:Route@35465,whole:Route@35647,whole:Route@3591,whole:Route@3685,whole:Route@36899,whole:Route@36994,whole:Route@3752,whole:Route@37835,whole:Route@4446,whole:Route@6182,whole:Route@6441,whole:Route@6703,whole:Route@6708,whole:Route@6765,whole:Route@6771,whole:Route@6840,whole:Route@6848,whole:Route@7164,whole:Route@7225,whole:Route@729,whole:Route@7323,whole:Route@8288,whole:Route@9237,whole:Route@934,whole:Route@9461,whole:Route@9525,whole:Route@9569 642bd5c0a4c68c943d51ed920045d7e29e9f968ebe93ae2d250cf616ab85a924
+internal/lease/checkpoint.go Held.Checkpoint legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-replica-wake-gap;basis=Replicate before start (#1290): decides continuity (beginContinuity) before the store opens, runs startProtected (bounded first sync; a full image when continuity is unproven) before its sync, and writes the clean record after a successful close. Same database path the caller passed; no new path, input or root decision; the agent runs it as carlos. file:Open@1016 337104180154a1e2f0f4d2126a4bb1b67862d8400431cc5e0b8920acced92b40
+internal/lease/continuity.go Protection.pin legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Opens a SQLite read transaction on the route's database (agent, user carlos) after stat-ing its -wal and -shm, reading PRAGMA journal_mode and sqlite_master; creates nothing, changes no mode. The path is the activator's own route database path. No root involvement. file:Open@187,file:QueryRow@343,file:QueryRow@594,file:Stat@122 c4c63fc921746b07fd3d32d6f50efc7c629b859f2501c0ebd0cf722d5c2c2461
+internal/lease/continuity.go currentState legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Stats the route database and its -wal, and lists the replicator's own litestream meta directory's ltx/0, to compare with the clean record. Agent-owned files; read only. file:ReadDir@437,file:Stat@242,file:Stat@67 8e967e777f5a9d0023301075cf815bd49f5f7db3abf29de9a2b9decf57076376
+internal/lease/continuity.go firstLocalL0After legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Lists the replicator's own meta directory ltx/0 to find the first file this start's sync wrote. Agent-owned; read only. file:ReadDir@88 e461881156a87217f87ed2954dafe18bcc5fead639fa64269254f8fbc7b0d92a
+internal/lease/continuity.go fullImage legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Opens and decodes one local L0 file the replicator just wrote, to see whether it holds every page. Agent-owned; read only; a failed read means not a full image (the safe answer: a snapshot follows). file:Open@46 09979451df76b17e8ded6b8258ef53a6d6a42243e55663fbc03cc270c276266f
+internal/lease/continuity.go isContinuous legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Reads the clean record carlos-clean.json from the replicator's own meta directory; anything unreadable is not proof of continuity (the safe answer). file:ReadFile@53 f7daf19b564808f09f2ece439b96d6271ddc2a70f1a783380c24e4cca7fd6992
+internal/lease/continuity.go newestLocalL0 legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Lists the replicator's own meta directory ltx/0 for the newest TXID. Agent-owned; read only. file:ReadDir@61 8c9c7aa118a38ee4c3283c03deaa0c679dd0efa9c9a4738081616fc89cbc94ca
+internal/lease/continuity.go recordClean legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Writes carlos-clean.json (0600, tmp then rename, fsync) in the replicator's own meta directory after a successful final sync and close. Agent-owned path derived from the route's database path. file:OpenFile@302 02ef85663928f46f0ab7fbc8e215e7f5fe162184847a3cf027200d892a833e1c
+internal/lease/continuity.go startProtected legacy accepted-legacy accepted-legacy;rev3=census-ruling-replica-wake-gap;basis=Stats the route database to tell a first start (no file) from an existing one; then litestream's own sync and, when continuity is unproven, a snapshot through the existing replica client. No new path or input. file:Stat@99 c56f5b768ffd6c8e7e03871fd0bb2901c13f3d575b50c4c06eed2c4a504aca46
+internal/lease/lease.go Held.Replicate legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: the Replicator it returns also carries the handle's ha flag, marker base and region, so an HA replicator releases through the marker only; the store setup, its five steps and the transfer are unchanged; the one site unchanged, no read added;rev3=census-ruling-g6-fence;basis=G6 F-C Task 2, the agent as carlos: for an HA lease at sync interval 0 only, wraps db.Replica.Client in the write fence's gate (fenceGate: cancels and refuses replica calls after the event, except the finalization's) before store.Open, and starts the fence goroutine (runFence) on db.WALPath(), the instance's own -wal; the Replicator gains done and fenced channels. The one site unchanged; no root read added; store setup, its steps and the transfer unchanged.;rev3=census-ruling-replica-wake-gap;basis=Adds beginContinuity before the store opens, a Stat of dbPath (no file: reset local litestream state so the first sync is a full image), and startProtected after Open; a failure closes the store and returns the error. Same dbPath, same replica client; no root decision. file:Open@1243,file:Stat@1041 dee32cbbd3175437275b82e6940a909914ec151fd0386064b562323a2672cbd5
+internal/activator/activator.go Service.doWakeOnce legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-1;basis=Task 3a: The former doWake body, not deleted logic: refresh/admit/fence/layout checks remain. Select and verify the actual staged identity before serving Acquire; use canonical mode to call doStatelessWake. Keep SQLite acquire/restore/seed/marker/replicate only in the stateful arm, with the post-acquisition selection recheck and existing cleanup proofs. Fix 3a round 1 I1/I3a: admit config directly only for stateless and mark runtime ownership refusals. Stateful Acquire/Restore precede selection and pending publication; canonical mode inspection is separate, replan precedes settlement. Fix round 2 N2/N3: retain the original route/pin projection for post-lease declaration checks; reuse the unplanned capture so a live-link repoint cannot change the selected build. Stateful capture and changed-copy errors remain start failures after Acquire/Restore. A failed preliminary verification supplies no cached mode observation. No new file path or database authority. Final review C1/R26: unprojected stateful wakes capture and materialize the live link only after Acquire and Restore. Retain original route/generation/pin stateless evidence on the context across fallback, so missing stateless evidence cannot take stateful recovery inference. Known good stateful identity skips canonical declaration lookup. Existing pre-exec verification remains. R28 final fix 2: carry whether this wake has a plan in attempt-local context; no new read here; route, generation and pin stateless projection remains intact.;rev3=census-ruling-agent-start-demo-1;basis=Reads IsDemo and demo admission/capability state; chooses local lease retention, skips seed upload and sidecar selection. Existing stop and under-lease ordering retained.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: refuse tenant starts under the existing service lock before main's demoWakeRefusal, and recheck before backend Acquire. Retain main's demo refusal and all lease, restore and serialization checks. Two added whole Route uses feed the in-memory admission predicate; no new filesystem or store read.;rev3=census-ruling-stateless-replicas-2;basis=P14: after verified storage-mode selection, before clearing the projected hint or acquiring a database lease, a set row still on the stateful branch returns ErrFenced. Reads the existing route FleetBoxes field only. Verified stateless wakes take their existing branch; legacy rows remain unchanged. No new file, registry query or bucket read. merge of origin/main 9b8b2c50: retain wake-slot and HA duty logic alongside the replica stateful-start refusal; no gate removed. merge of origin/main 6be08467: Keep main demo lease, local database and KeepLocal path; never equate replication-disabled demos with stateless generations. Merge-only body/read-site change. merge of origin/main 7920cccf: Retain main tenant admission and startOwnedLocked gates alongside the replica stateful-start refusal; whole Route passed to main admission checks, no new path or store read.;rev3=census-ruling-agent-start-demo-3;basis=Route claim seeds through seed restore/admission; do not fall back to empty boot or ordinary import behavior. Census read-site delta: +registry:SeedSource, +whole:Route.;rev3=census-ruling-region-ha-g2-fixes;basis=Bound recovery Acquire by its attempt deadline; existing acquire/restore/start ordering remains; no new read.;rev3=census-ruling-g6-fence;basis=G6 F-C Task 3, the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): right after retainDatabase returns, attaches the write-fence watcher under a.mu (watchWriteFenceLocked, in memory). retainDatabase is called through a retainDB test seam that is nil in production. No read added; no root call; existing acquire, restore, publisher and cleanup order unchanged.;rev3=census-ruling-sr-followups;basis=#1061 Task 1, the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): a refused plan now returns planRefusal(host, plan) instead of the inline fmt.Errorf, the text is unchanged, and when the planner marked the plan Installing the error also matches errBuildNotInstalled (installRefusal, in memory). Same refusal at the same point before the lease, read sites unchanged, no read, file, store, bucket or root call added;rev3=census-ruling-replica-wake-gap;basis=Step 2c: before the seed and the spawn, asks the lease to ProtectStart(rt.DBPath), the route's own database path already used by Restore and retainDatabase; a refusal gives the lease back and starts nothing. Agent code (user carlos); no root call, no new store or file read here. registry:DBPath@2071,registry:DBPath@2087,registry:DBPath@21869,registry:DBPath@2214,registry:DBPath@2225,registry:FleetBoxes@12030,registry:GoodVersion@18320,registry:Host@1900,registry:Host@1975,registry:Host@2053,registry:Host@2205,registry:Host@2539,registry:Host@4556,registry:Host@6813,registry:Host@949,registry:Replication@16947,registry:Replication@17076,registry:Replication@17095,registry:Replication@17176,registry:Replication@34070,registry:Seed@22754,registry:SeedSource@35530,registry:Socket@2100,registry:Socket@2116,registry:Socket@2239,registry:Socket@2250,registry:Stateless@10090,registry:Stateless@10376,registry:Stateless@11748,registry:Stateless@12078,registry:Stateless@20729,registry:Stateless@9633,registry:Stateless@9724,whole:Route@10162,whole:Route@10321,whole:Route@10700,whole:Route@10798,whole:Route@10889,whole:Route@11021,whole:Route@11144,whole:Route@11198,whole:Route@11470,whole:Route@11646,whole:Route@11650,whole:Route@12437,whole:Route@12712,whole:Route@13030,whole:Route@142,whole:Route@14491,whole:Route@15168,whole:Route@16049,whole:Route@16927,whole:Route@17178,whole:Route@18523,whole:Route@19114,whole:Route@19279,whole:Route@1998,whole:Route@20215,whole:Route@21011,whole:Route@21286,whole:Route@22855,whole:Route@22926,whole:Route@2434,whole:Route@2439,whole:Route@2493,whole:Route@2499,whole:Route@25420,whole:Route@2565,whole:Route@2573,whole:Route@2629,whole:Route@27278,whole:Route@27924,whole:Route@29231,whole:Route@29385,whole:Route@29884,whole:Route@29954,whole:Route@30541,whole:Route@31626,whole:Route@32057,whole:Route@32265,whole:Route@32319,whole:Route@33248,whole:Route@333,whole:Route@33433,whole:Route@34233,whole:Route@34304,whole:Route@35022,whole:Route@35071,whole:Route@35465,whole:Route@35647,whole:Route@3591,whole:Route@3685,whole:Route@36899,whole:Route@36994,whole:Route@3752,whole:Route@37835,whole:Route@4446,whole:Route@6182,whole:Route@6441,whole:Route@6703,whole:Route@6708,whole:Route@6765,whole:Route@6771,whole:Route@6840,whole:Route@6848,whole:Route@7164,whole:Route@7225,whole:Route@729,whole:Route@7323,whole:Route@8288,whole:Route@9237,whole:Route@934,whole:Route@9461,whole:Route@9525,whole:Route@9569 642bd5c0a4c68c943d51ed920045d7e29e9f968ebe93ae2d250cf616ab85a924
+@coverage . afe0b4d85c5b89b9566aa31cc05214d68466bfb68c6e7cfbec79a83b2c1fcba5
+@coverage internal/activator 22a6e2f18728a2fe6d0e577d12638b742a5be22e75649b34c3ba11f1b2a3c31d
+@coverage internal/lease c61536ca0105f191666955eaa21099c74afb87ccc3836078e55003ed2290b293