carlos / platform Public

durability 3a: escrowed trio is write-once; lease re-checked at commit; stale ledger removed

Task 4 fix round 2 (Astra re-review R1, controller rulings).

- P1-1. An escrowed instance.key or report.token is write-once: a publish
  never replaces it with other bytes (its keyed digest against the
  baseline the box holds, no request). A local copy that differs, from a
  fresh mint, a restart or a stale file, refuses the launch with an
  alert and tries to write the conflict marker; the refusal holds without
  the marker, since every later publish finds the same divergence. The
  in-memory mint provenance (minted, mintedConflict) is gone. The env
  stays editable.
- P1-2. The lease is checked again under the operation lock immediately
  before the manifest commit; lost, nothing is committed and the staged
  state is dropped. The early check stays as a cheap skip.
- Stale ledger. A commit whose ledger write fails removes the stale
  ledger, so the next restore reads the bucket; if the removal fails too,
  the ledger is untrusted for the process and a missing trio file always
  reads the bucket.

Witnesses: a divergent key refused with a failing marker write and again
after a restart; a stale differing key after a restart; the lease lost
between the baseline and the commit (nothing committed, the new holder's
manifest untouched); the stale-ledger restore with the removal working
and failing. The competing-mint witness moves to instance.key.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev c5c6474056f1d71bf5cc856849599e3bccb103ef parent 3134699
6 files changed, +319 −150
  • docs/superpowers/notes/census-durability-3a-escrow-claims.md +7 −7
  • docs/superpowers/notes/census-proposal-durability-3a-escrow.md +5 −5
  • internal/activator/escrow.go +116 −89
  • internal/activator/escrow_test.go +175 −33
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv +15 −15

Intent

Human

<task-notification> <task-id>a3ce1b31a8618f132</task-id> <tool-use-id>toolu_01FwmjZoTGd3ZsHR67YAwaAK</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/953e7524-2e06-4308-b9ce-fd1b38579971/tasks/a3ce1b31a8618f132.output</output-file> <status>completed</status> <summary>Agent "Implement Task 4: escrow for activator hosts" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE. Fix round 1 is in commit 3134699a, on top of 50601478 and 4a897404, not pushed. What changed, against the review: - **P1-2 and P1-1 (authority):** a box publishes a host's escrow, at launch or in the sweep, and mints its secrets only while it holds that host's lease. The sweep skips any host whose lease it doesn't hold, so a stale box never replaces the escrow. The old test at `escrow_test.go:734` now asserts the opposite. - **P1-1 (conflicts):** a minted secret that conflicts with the escrow refuses the launch, raises an alert and writes `.escrow/&lt;host&gt;.conflict`. Every later wake and restart refuses until an operator removes the file. The new witness covers the first refusal, a second wake and a restart. - **P1-3:** keyless evidence is shared only within one preparation; the 30 s cache and the manual cache clear in the test are gone. - **P1-4:** stamps are copied under the lock and the sweep report goes through one lock. The new race witness produced 4 races before the fix and is clean under `-race` after. - **P2-5:** the mode is chosen before any trio file check. Both fallback paths launch with a valid env and a FIFO at `instance.key`. - **P2-6:** an unchanged wake makes 0 GETs and a first mint makes exactly 1, both asserted through the real wake. - **Evidence:** I took each fix out in turn, and each matching test failed. Tests: - Escrow, HA and launch tests pass under `-race`. - The host package, census tests and cross-builds pass. - The census has 0 unclaimed units. Concerns: - **P3:** the full activator run fails only on #460 (`TestReleaseLeaseLossUnprovenLeavesTheHold`, 175 µs late), the known flake on main. - **An unrelated race:** one wide `-race` run reported a race in `TestAWorkerFallbackWithoutOwnershipSpawnsNothing`, between a test seam in `wakeplan_test.go` and a goroutine left by a `workerswap` test. No escrow code is on either stack, and it did not reproduce on its own. It is a pre-existing test-isolation race. - **Astra's ⚠️ (instance.key and report.token):** the restore runs during prepare, before the app starts, and never overwrites an existing file. rastrillo apps on CARLOS use their key file, then `CARLOS_INSTANCE_KEY`, and never mint. What remains: a key the app writes itself reaches the escrow only on the next sweep (about 30 s). If the box dies in that window, an app that mints when its file is missing would fork its key. I suggest saying so in the Task 8 docs, and a follow-up that publishes new trio files at once. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/durability-3a/.superpowers/sdd/2026-10-30-durability-step3-escrow-fence-restore/task-4-report.md</result> <usage><subagent_tokens>649766</subagent_tokens><tool_uses>41</tool_uses><duration_ms>1698601</duration_ms></usage> </task-notification>

Human

OK, keep going

Human

<task-notification> <task-id>bx27y02c9</task-id> <tool-use-id>toolu_01115XL2gfmGbdcuVmq5J1zW</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/953e7524-2e06-4308-b9ce-fd1b38579971/tasks/bx27y02c9.output</output-file> <status>completed</status> <summary>Background command "Wait for the Task 4 re-review" completed (exit code 0)</summary> </task-notification>

Attributed to this commit: 19.6 g CO₂e (2,484,933 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on durability-3a-escrow, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/docs/superpowers/notes/census-durability-3a-escrow-claims.md b/docs/superpowers/notes/census-durability-3a-escrow-claims.md
index c1f4cc80c..3394645fc 100644
--- a/docs/superpowers/notes/census-durability-3a-escrow-claims.md
+++ b/docs/superpowers/notes/census-durability-3a-escrow-claims.md
@@ -40,16 +40,16 @@ internal/activator/escrow.go:ExecBackend.escrowEnvOf durability 3a Task 4: new:
internal/activator/escrow.go:ExecBackend.escrowChanged durability 3a Task 4: new: compares each escrowed file's stamp (stampAt, beneath the row's data directory) with the last kept one; reads no bytes Fix round 1 (P1-4): the stamps are copied under the escrow mutex, entry by entry, before they are compared; the same opens, no read added.
internal/activator/escrow.go:ExecBackend.escrowEligible durability 3a Task 4: new: escrowEligibleAt on pathsFor's classification
internal/activator/escrow.go:ExecBackend.escrowEligibleAt durability 3a Task 4: new: a pure predicate over the row and a classification: ActivatorManaged, not unit, sidecar, HA, replica, held, a valid host shape and app, flat or nested, on a box with a hibernate bucket; reads only row fields
-internal/activator/escrow.go:ExecBackend.escrowMintGuard durability 3a Task 4: new: on a box that is not ready refuses every mint (ErrEscrowNotReady); otherwise, once and only when a producer would mint, bucketEscrowEnv, and refuses (ErrInstanceKeyDeferred) when the escrowed env holds the variable; a mint it allows is noted in memory; only refuses Fix round 0 (controller readiness ruling): with no files store it is nil, and the producer mints as before 3a; with a files store and no sealing key it reads the bucket manifest at the mint (keylessEscrowed, fresh) and refuses (ErrEscrowNotReady) when the bucket holds any sealed item or the cutover marker for the host, and otherwise lets the mint go ahead (logged once); only refuses. Fix round 1: with a key it refuses while the conflict marker exists or while this box does not hold the host's lease (ErrInstanceKeyDeferred); its bucket read is bucketManifest, the preparation's shared read unless fresh (the backfill); without a key its keyless read is the same, with no cache across launches (P1-3); only refuses.
+internal/activator/escrow.go:ExecBackend.escrowMintGuard durability 3a Task 4: new: on a box that is not ready refuses every mint (ErrEscrowNotReady); otherwise, once and only when a producer would mint, bucketEscrowEnv, and refuses (ErrInstanceKeyDeferred) when the escrowed env holds the variable; a mint it allows is noted in memory; only refuses Fix round 0 (controller readiness ruling): with no files store it is nil, and the producer mints as before 3a; with a files store and no sealing key it reads the bucket manifest at the mint (keylessEscrowed, fresh) and refuses (ErrEscrowNotReady) when the bucket holds any sealed item or the cutover marker for the host, and otherwise lets the mint go ahead (logged once); only refuses. Fix round 1: with a key it refuses while the conflict marker exists or while this box does not hold the host's lease (ErrInstanceKeyDeferred); its bucket read is bucketManifest, the preparation's shared read unless fresh (the backfill); without a key its keyless read is the same, with no cache across launches (P1-3); only refuses. Fix round 2: no longer notes the mints it allows in memory; only refuses.
internal/activator/escrow.go:ExecBackend.escrowReady durability 3a Task 4: new: FilesStore and EscrowKey set and sealerFor succeeds; reads nothing
-internal/activator/escrow.go:ExecBackend.escrowReread durability 3a Task 4: new, after a superseded publish: hostfiles.Open of the host's files manifest, and, when this box noted a mint, the sealed env (escrowEnvOf) and the local env file with instancefs.ReadBeneathLimitOrAbsent (1 MiB, no link followed) beneath the row's data directory, to refuse publishing over an escrowed secret of another value; the agent as carlos (carlos-edge.service), no root caller; only refuses Fix round 1: the conflict check is mintedConflict (on this card), which also persists the conflict marker.
+internal/activator/escrow.go:ExecBackend.escrowReread durability 3a Task 4: new, after a superseded publish: hostfiles.Open of the host's files manifest, and, when this box noted a mint, the sealed env (escrowEnvOf) and the local env file with instancefs.ReadBeneathLimitOrAbsent (1 MiB, no link followed) beneath the row's data directory, to refuse publishing over an escrowed secret of another value; the agent as carlos (carlos-edge.service), no root caller; only refuses Fix round 1: the conflict check is mintedConflict (on this card), which also persists the conflict marker. Fix round 2: only re-reads and installs the publisher; the conflict check is the next publish's write-once check.
internal/activator/escrow.go:ExecBackend.escrowedLaunchEnv durability 3a Task 4: new, the launch path for an eligible host: captureLaunchEnv once, publishEscrowAt over those bytes, SealedAcknowledged on the commit, and the env parsed from the captured bytes; on a supersession escrowReread and the launch preparation again (ensureAdminTokenFor, ensureInstanceKeyFor) once; a not-ready box launches only a host its ledger shows escrowed; the agent as carlos (carlos-edge.service), no root caller Fix round 0 (controller readiness ruling): before the capture, the box's mode: no files store, instanceEnvLayer exactly as before 3a (logged once); no sealing key, a host whose ledger shows it escrowed launches on instanceEnvLayer (logged), otherwise keylessEscrowed (the answer this launch's restore read, within haSecretsBudget, else one GET) refuses when the bucket holds an escrow and launches on instanceEnvLayer when it holds none; nothing is published in either. Fix round 1: ends the launch's preparation; refuses while the conflict marker exists, and with a key while this box does not hold the host's lease; an ALERT from the publish fails the launch; the keyless decision uses the preparation's read.
internal/activator/escrow.go:ExecBackend.haKnown durability 3a Task 4: new: the HA classification from memory only (haWakes, haLegacyRoute, the row's mark, the lifetime index); reads nothing
-internal/activator/escrow.go:ExecBackend.openEscrowLocked durability 3a Task 4: new: the host's publisher, from its ledger (readEscrowLedger: readCappedFile, O_NOFOLLOW, 32 MiB, under <data>/.escrow, the agent's own directory) with no request, else hostfiles.Open (one GET); the agent as carlos (carlos-edge.service), no root caller Fix round 1: marks the host checked when it reads the bucket; the same reads.
+internal/activator/escrow.go:ExecBackend.openEscrowLocked durability 3a Task 4: new: the host's publisher, from its ledger (readEscrowLedger: readCappedFile, O_NOFOLLOW, 32 MiB, under <data>/.escrow, the agent's own directory) with no request, else hostfiles.Open (one GET); the agent as carlos (carlos-edge.service), no root caller Fix round 1: marks the host checked when it reads the bucket; the same reads. Fix round 2: the ledger is read through ledgerFor (none while this process marks it untrusted); the same reads.
internal/activator/escrow.go:ExecBackend.publishEscrow durability 3a Task 4: new: publishEscrowAt on pathsFor
internal/activator/escrow.go:ExecBackend.publishEscrowAt durability 3a Task 4: new: escrowReady and the layout checked, then publishEscrowLocked under the host's lock Fix round 1: refuses while the conflict marker exists or while this box does not hold the host's lease (P1-2), before anything is read.
-internal/activator/escrow.go:ExecBackend.publishEscrowLocked durability 3a Task 4: new: reads <host>.env (unless the launch's capture is handed in), <host>/instance.key and <host>/report.token with readStamped beneath the row's data directory, seals what changed (StageSealed), DropRawSecrets of the constant raw names, commits, and writes the ledger (writeEscrowLedger: EnsureDirBeneath .escrow 0700, a 0600 temp, rename, fsync); an absent file stages nothing; a refused file publishes nothing for it; the agent as carlos (carlos-edge.service), no root caller Fix round 1: before staging, mintedConflict on the baseline it would replace, so a secret this box minted is never published over another escrowed value (P1-1).
-internal/activator/escrow.go:ExecBackend.restoreEscrowIfMissing durability 3a Task 4: new: checks each escrowed file with instancefs.OpenBeneathOrAbsent beneath the row's data directory; when one is absent, hostfiles.Open of the host's manifest, ReadSealed of each missing item, and writeIfAbsent (instancefs.WriteAtomic of a temp, then RenameBetweenNoReplace, so a present file is never replaced; EnsureDirBeneath for the files directory, 0700); on a box that is not ready it refuses unless the ledger shows the host escrowed and the env file is here; the agent as carlos (carlos-edge.service), no root caller Fix round 0 (controller readiness ruling): with no files store it does nothing (logged once); with no sealing key it restores nothing: a ledger here and an env file here go on, otherwise keylessEscrowed refuses when the bucket holds an escrow and goes on as before 3a when it holds none. Fix round 1: the conflict marker first, then the mode (P2-5): no files store, nothing; no key, the preparation's keyless read before any file check. With a key, each trio file is checked with OpenBeneathOrAbsent (a link or FIFO is not missing); the bucket is read (bucketManifest, the preparation's one GET) only for a missing env file, or a missing trio file the ledger says was escrowed, or with no ledger once per agent start (P2-6); the same writes.
+internal/activator/escrow.go:ExecBackend.publishEscrowLocked durability 3a Task 4: new: reads <host>.env (unless the launch's capture is handed in), <host>/instance.key and <host>/report.token with readStamped beneath the row's data directory, seals what changed (StageSealed), DropRawSecrets of the constant raw names, commits, and writes the ledger (writeEscrowLedger: EnsureDirBeneath .escrow 0700, a 0600 temp, rename, fsync); an absent file stages nothing; a refused file publishes nothing for it; the agent as carlos (carlos-edge.service), no root caller Fix round 1: before staging, mintedConflict on the baseline it would replace, so a secret this box minted is never published over another escrowed value (P1-1). Fix round 2 (P1-1, P1-2, stale ledger): before staging, the write-once check (escrowDivergence, keyed digests only, no request): a staged instance.key or report.token whose escrowed item has another digest refuses the publish (escrowConflictFound); then, under the operation lock just before the commit, the lease again (holdsLease): lost, nothing is committed and the staged state is dropped; after a commit the ledger through keepLedger (written, else the stale one removed with RemoveBeneath under <data>/.escrow, else marked untrusted in memory).
+internal/activator/escrow.go:ExecBackend.restoreEscrowIfMissing durability 3a Task 4: new: checks each escrowed file with instancefs.OpenBeneathOrAbsent beneath the row's data directory; when one is absent, hostfiles.Open of the host's manifest, ReadSealed of each missing item, and writeIfAbsent (instancefs.WriteAtomic of a temp, then RenameBetweenNoReplace, so a present file is never replaced; EnsureDirBeneath for the files directory, 0700); on a box that is not ready it refuses unless the ledger shows the host escrowed and the env file is here; the agent as carlos (carlos-edge.service), no root caller Fix round 0 (controller readiness ruling): with no files store it does nothing (logged once); with no sealing key it restores nothing: a ledger here and an env file here go on, otherwise keylessEscrowed refuses when the bucket holds an escrow and goes on as before 3a when it holds none. Fix round 1: the conflict marker first, then the mode (P2-5): no files store, nothing; no key, the preparation's keyless read before any file check. With a key, each trio file is checked with OpenBeneathOrAbsent (a link or FIFO is not missing); the bucket is read (bucketManifest, the preparation's one GET) only for a missing env file, or a missing trio file the ledger says was escrowed, or with no ledger once per agent start (P2-6); the same writes. Fix round 2: the ledger is read through ledgerFor, and while it is untrusted (its write and the stale ledger's removal both failed) a missing trio file always reads the bucket; the same reads and writes.
internal/activator/escrow.go:ExecBackend.sweepPublish durability 3a Task 4: new: publishEscrowAt, and on a supersession escrowReread and one more publish; a second one is the alert
internal/activator/escrow.go:Service.EscrowSweep durability 3a Task 4: new: the backend's EscrowSweep, nothing for a backend without one
internal/activator/escrow.go:Service.SecretsEscrowed durability 3a Task 4: new: the backend's SecretsEscrowed, else IsHA
@@ -62,6 +62,6 @@ internal/activator/escrow.go:ExecBackend.escrowOff durability 3a Task 4 fix roun
internal/activator/escrow.go:ExecBackend.keylessEscrowed durability 3a Task 4 fix rounds 0-1: new, on a box with a files store and no sealing key: whether the bucket holds an escrow for the host (any sealed item or the cutover marker), from bucketManifest: the read of the launch preparation in progress, or one hostfiles.Load (one GET); nothing is cached across launches (fix round 1, P1-3); a failed read is an error and the caller refuses; the agent as carlos (carlos-edge.service), no root caller
internal/activator/backend_exec.go:ExecBackend.Acquire durability 3a Task 4 fix round 1: after a successful acquire, records the instance lease it hands out (escrow.noteLease, memory only), so the escrow can ask whether this box holds the host's lease; the same acquire, no read added; the agent as carlos (carlos-edge.service), no root caller
internal/activator/escrow.go:ExecBackend.bucketManifest durability 3a Task 4 fix round 1: new: the host's files manifest in the hibernate bucket, the launch preparation's read when there is one (unless fresh), else one GET: hostfiles.Open with a sealing key (the publisher installed for the launch's publish), hostfiles.Load without; kept as the preparation's read; the agent as carlos (carlos-edge.service), no root caller
-internal/activator/escrow.go:ExecBackend.escrowConflict durability 3a Task 4 fix round 1: new: os.Lstat of <data>/.escrow/<host>.conflict, the agent's own directory; present, every launch, mint and publish of the host is refused with an alert naming the file for an operator to remove; only refuses; the agent as carlos (carlos-edge.service), no root caller
-internal/activator/escrow.go:ExecBackend.mintedConflict durability 3a Task 4 fix round 1: new: when this box minted a secret since the host's env was last escrowed, opens the manifest's sealed env (escrowEnvOf) and reads the local env file with instancefs.ReadBeneathLimitOrAbsent (1 MiB, no link followed); an escrowed value that differs persists the conflict marker (writeEscrowConflict: EnsureDirBeneath .escrow 0700, a 0600 temp, rename, fsync) and refuses with an alert; only refuses; the agent as carlos (carlos-edge.service), no root caller
+internal/activator/escrow.go:ExecBackend.escrowConflict durability 3a Task 4 fix round 1: new: os.Lstat of <data>/.escrow/<host>.conflict, the agent's own directory; present, every launch, mint and publish of the host is refused with an alert naming the file for an operator to remove; only refuses; the agent as carlos (carlos-edge.service), no root caller Fix round 2: the alert text names the divergence generally (local secrets differ from the escrow); the same Lstat.
internal/activator/hasecrets.go:ExecBackend.mintGuardWith durability 3a Task 4 fix round 1: new: classifies the host (haHostNow; an error refuses) and returns mintGuardAs with fresh; only refuses
+internal/activator/escrow.go:ExecBackend.escrowConflictFound durability 3a Task 4 fix round 2: new: the refusal for a divergent trio item: tries to write the host's conflict marker (writeEscrowMarker: EnsureDirBeneath <data>/.escrow 0700, a 0600 temp, rename, fsync), logs if it cannot, and returns the alert; the refusal holds either way, since every later publish finds the same divergence; only refuses; the agent as carlos (carlos-edge.service), no root caller
diff --git a/docs/superpowers/notes/census-proposal-durability-3a-escrow.md b/docs/superpowers/notes/census-proposal-durability-3a-escrow.md
index e5bb04c6a..c78f37c03 100644
--- a/docs/superpowers/notes/census-proposal-durability-3a-escrow.md
+++ b/docs/superpowers/notes/census-proposal-durability-3a-escrow.md
@@ -69,22 +69,22 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/activator/escrow.go:ExecBackend.bucketManifest`: reads +file:Open, +registry:Host ×4, +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.escrowChanged`: reads +registry:Host ×2; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.escrowConflict`: reads +file:Lstat; written legacy, accepted-legacy, frozen
+- new `internal/activator/escrow.go:ExecBackend.escrowConflictFound`: reads +registry:Host ×4; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.escrowEligible`: reads +whole:Route ×2; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.escrowEligibleAt`: reads +registry:App, +registry:HA, +registry:HoldOp, +registry:Host, +registry:Replica, +registry:Status, +registry:Unit, +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.escrowEnvOf`: reads +registry:Host, +whole:Route; written legacy, accepted-legacy, frozen
-- new `internal/activator/escrow.go:ExecBackend.escrowMintGuard`: reads +registry:Host ×3, +whole:Route ×6; written legacy, accepted-legacy, frozen
+- new `internal/activator/escrow.go:ExecBackend.escrowMintGuard`: reads +registry:Host ×2, +whole:Route ×6; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.escrowModeOf`: reads +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.escrowOff`: reads +registry:Host ×2; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.escrowReady`: reads +whole:Route; written legacy, accepted-legacy, frozen
-- new `internal/activator/escrow.go:ExecBackend.escrowReread`: reads +file:Open, +registry:Host ×3, +whole:Route ×2; written legacy, accepted-legacy, frozen
+- new `internal/activator/escrow.go:ExecBackend.escrowReread`: reads +file:Open, +registry:Host ×3, +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.escrowedLaunchEnv`: reads +registry:Host ×19, +whole:Route ×14; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.haKnown`: reads +registry:HA, +registry:Host ×2, +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.keylessEscrowed`: reads +whole:Route; written legacy, accepted-legacy, frozen
-- new `internal/activator/escrow.go:ExecBackend.mintedConflict`: reads +registry:Host ×6, +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.openEscrowLocked`: reads +file:Open, +registry:Host ×2, +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.publishEscrow`: reads +whole:Route ×2; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.publishEscrowAt`: reads +registry:Host ×7, +whole:Route ×2; written legacy, accepted-legacy, frozen
-- new `internal/activator/escrow.go:ExecBackend.publishEscrowLocked`: reads +registry:Host ×5, +whole:Route ×2; written legacy, accepted-legacy, frozen
+- new `internal/activator/escrow.go:ExecBackend.publishEscrowLocked`: reads +registry:Host ×6, +whole:Route ×2; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.restoreEscrowIfMissing`: reads +registry:Host ×10, +whole:Route ×7; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:ExecBackend.sweepPublish`: reads +registry:Host, +whole:Route ×3; written legacy, accepted-legacy, frozen
- new `internal/activator/escrow.go:Service.EscrowSweep`: reads +whole:Route; written legacy, accepted-legacy, frozen
@@ -106,6 +106,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/layout/inventory.go:Inventory`: reads +file:ReadDir; written legacy, accepted-legacy, frozen
- quiet `internal/layout/plan.go:NestedPlatformNames`: reads nothing now; retired while it reads nothing (or its row keeps no sites)
-Seal: `eaeb153ab7a7a849edc9c6e92f2ac5c709c6e39044a647971cf1fa5ebcb660c8` → `d6c281d7e095e8e0625c6199044d67dc0da559e7b4af5fbdc1a4e032bfbb65dc`.
+Seal: `eaeb153ab7a7a849edc9c6e92f2ac5c709c6e39044a647971cf1fa5ebcb660c8` → `303f60594ae584c6bb29263c485ef3de60d76a4bd60166134b8ad3bcd3ba6139`.
Overlay: `internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/activator/escrow.go b/internal/activator/escrow.go
index 56d239a29..70ae5a9fe 100644
--- a/internal/activator/escrow.go
+++ b/internal/activator/escrow.go
@@ -52,10 +52,12 @@ import (
// costs no request (P2-6). A missing env file, and a mint, always read
// the bucket; one launch's preparation shares that one read
// (escrowPrep).
-// - A secret this box minted that the bucket escrows with another value
-// stops the launch with an alert, and a conflict marker
-// (<data>/.escrow/<host>.conflict) refuses every later launch, restart
-// or not, until an operator removes it.
+// - An escrowed instance.key or report.token is write-once: a local copy
+// that differs from the escrow (a fresh mint, a stale file, after a
+// restart or not) stops the launch with an alert, every time it is
+// found, and a conflict marker (<data>/.escrow/<host>.conflict), when
+// it can be written, refuses every later launch until an operator
+// removes it. The env stays editable.
// - A launch reads the env once (captureLaunchEnv), publishes and
// acknowledges exactly those bytes, and launches with the env parsed
// from them.
@@ -91,11 +93,25 @@ const (
var escrowHooks struct {
afterCapture func(host string)
afterReread func(host string)
+ beforeCommit func(host string)
}
// writeEscrowLedger keeps base as host's ledger (a test seam).
var writeEscrowLedger = writeEscrowLedgerFile
+// removeEscrowLedger removes host's ledger (a test seam).
+var removeEscrowLedger = func(dataDir, host string) error {
+ return removeIfThere(filepath.Join(dataDir, ".escrow"), host+".json")
+}
+
+// writeEscrowMarker persists host's conflict marker (a test seam).
+var writeEscrowMarker = func(dataDir, host string, body []byte) error {
+ if _, err := instancefs.EnsureDirBeneath(dataDir, ".escrow", 0o700); err != nil {
+ return err
+ }
+ return writeFileDurably(escrowConflictPath(dataDir, host), body)
+}
+
// EscrowSweepReport is one sweep's outcome: hosts whose publish committed,
// hosts with nothing to publish, hosts left for the next sweep by the cap,
// and hosts whose publish failed, sorted.
@@ -134,10 +150,10 @@ type escrowState struct {
// stamps is each escrowed file's stamp as the publisher last staged it,
// by item; an item without one is read by the next publish.
stamps map[string]statStamp
- // minted names the secrets this box minted for the host since its env
- // was last escrowed: an escrow that holds another value for one of them
- // is a conflict, and nothing is published over it.
- minted map[string]bool
+ // ledgerUntrusted: a commit's ledger write failed and the stale ledger
+ // could not be removed either, so this process never reads it: it reads
+ // the bucket for the host instead.
+ ledgerUntrusted bool
// fromBucket: the next open reads the bucket, never the ledger (the
// ledger could not be written after a commit).
fromBucket bool
@@ -438,16 +454,13 @@ func (b *ExecBackend) escrowConflict(host string) error {
if _, err := os.Lstat(path); errors.Is(err, os.ErrNotExist) {
return nil
}
- return fmt.Errorf("ALERT: %s: escrow: a secret this box minted conflicts with the host's escrow in the bucket; every launch of the host on this box is refused until an operator settles the env file against the escrow and removes %s", host, path)
+ return fmt.Errorf("ALERT: %s: escrow: the host's local secrets differ from its escrow in the bucket; every launch of the host on this box is refused until an operator settles them against the escrow and removes %s", host, path)
}
// writeEscrowConflict persists host's conflict marker, durably.
func (b *ExecBackend) writeEscrowConflict(host string, names []string) error {
- if _, err := instancefs.EnsureDirBeneath(b.DataDir, ".escrow", 0o700); err != nil {
- return err
- }
body := fmt.Sprintf("host %s\nvariables %s\nat %s\n", host, strings.Join(names, " "), time.Now().UTC().Format(time.RFC3339))
- return writeFileDurably(escrowConflictPath(b.DataDir, host), []byte(body))
+ return writeEscrowMarker(b.DataDir, host, []byte(body))
}
// writeEscrowLedgerFile keeps base, the manifest just committed, as host's
@@ -505,11 +518,24 @@ func escrowedIn(base hostfiles.Baseline) bool {
return ok
}
+// ledgerFor is host's ledger as this process may use it: none while it is
+// untrusted (a commit's ledger write and the stale ledger's removal both
+// failed).
+func (b *ExecBackend) ledgerFor(host string) (hostfiles.Baseline, bool) {
+ st := b.escrow.state(host)
+ untrusted := false
+ b.escrow.with(func() { untrusted = st.ledgerUntrusted })
+ if untrusted {
+ return hostfiles.Baseline{}, false
+ }
+ return readEscrowLedger(b.DataDir, host)
+}
+
// ledgerEscrowed reports whether host's ledger holds a sealed env item:
// this box has escrowed the host before. It decides only that a launch
// may go ahead without a fresh escrow write, never a restore or a mint.
func (b *ExecBackend) ledgerEscrowed(host string) bool {
- base, ok := readEscrowLedger(b.DataDir, host)
+ base, ok := b.ledgerFor(host)
return ok && escrowedIn(base)
}
@@ -577,7 +603,7 @@ func (b *ExecBackend) openEscrowLocked(ctx context.Context, rt registry.Route, s
}
prefix := b.filesPrefix(rt.Host)
if !fromBucket {
- if base, ok := readEscrowLedger(b.DataDir, rt.Host); ok {
+ if base, ok := b.ledgerFor(rt.Host); ok {
if p, err := hostfiles.OpenBaseline(b.FilesStore, prefix, base); err == nil {
pub = p
}
@@ -657,13 +683,11 @@ func (b *ExecBackend) publishEscrowLocked(ctx context.Context, rt registry.Route
var (
reads []escrowRead
refused []error
- envRead bool
)
for _, r := range pubclass.SealedRels(lay, rt.Host) {
item := r.Item()
if item == hostfiles.SealedEnvItem && env != nil {
reads = append(reads, escrowRead{rel: r, plain: env, stage: true})
- envRead = true
continue
}
var prev *statStamp
@@ -686,9 +710,6 @@ func (b *ExecBackend) publishEscrowLocked(ctx context.Context, rt registry.Route
reads = append(reads, escrowRead{rel: r, stamp: stamp})
default:
reads = append(reads, escrowRead{rel: r, plain: body, stamp: stamp, stage: true})
- if item == hostfiles.SealedEnvItem {
- envRead = true
- }
}
}
staging := pub != nil && pub.Dirty()
@@ -727,13 +748,17 @@ func (b *ExecBackend) publishEscrowLocked(ctx context.Context, rt registry.Route
}
before := pub.Baseline()
out := escrowPublish{base: before, seal: seal, exists: escrowedIn(before)}
- // A secret this box minted, and the escrow this publish would replace
- // holds another value of it: the bucket's copy came first.
- if m, err := baselineManifest(before); err != nil {
- return out, err
- } else if err := b.mintedConflict(ctx, rt, p, m); err != nil {
+ // Write-once: an escrowed trio item is never replaced with other bytes
+ // (fix round 2, P1-1). The
+ // divergence is the evidence, so it is found again on every launch
+ // whether or not the marker could be written.
+ m, err := baselineManifest(before)
+ if err != nil {
return out, err
}
+ if diverged := b.escrowDivergence(m, reads, seal); len(diverged) > 0 {
+ return out, b.escrowConflictFound(rt, p, diverged)
+ }
for _, r := range reads {
if !r.stage {
continue
@@ -747,6 +772,20 @@ func (b *ExecBackend) publishEscrowLocked(ctx context.Context, rt registry.Route
if err := pub.DropRawSecrets(rawSecretEntries); err != nil {
return out, err
}
+ // The lease again, under the operation lock, just before the
+ // compare-and-swap (fix round 2, P1-2): a box that lost it since the
+ // early check commits nothing, and its staged state is dropped. What
+ // remains is the moment between this check and the put, in which a
+ // box that has just lost the lease could still commit an env; the trio
+ // and the env's secrets cannot change (write-once), and the new
+ // holder's next commit meets this one's CAS and decides again.
+ if escrowHooks.beforeCommit != nil {
+ escrowHooks.beforeCommit(rt.Host)
+ }
+ if !b.holdsLease(rt.Host) {
+ b.escrow.drop(st)
+ return out, errEscrowNoLease
+ }
if _, err := pub.Commit(ctx); err != nil {
if errors.Is(err, hostfiles.ErrSuperseded) {
b.escrow.drop(st)
@@ -758,65 +797,65 @@ func (b *ExecBackend) publishEscrowLocked(ctx context.Context, rt registry.Route
after := pub.Baseline()
out.base, out.exists = after, escrowedIn(after)
out.committed = before.ETag != after.ETag || before.Found != after.Found
- if envRead {
- b.escrow.with(func() { st.minted = nil })
- }
keep()
if out.committed {
- if err := writeEscrowLedger(b.DataDir, rt.Host, after); err != nil {
- log.Printf("activator: %s: escrow: the ledger was not written (%v); the next escrow of the host reads the bucket", rt.Host, err)
- b.escrow.drop(st)
- }
+ b.keepLedger(rt.Host, st, after)
}
return out, errors.Join(refused...)
}
-// mintedConflict is nil unless m escrows, for a secret this box minted
-// since the host's env was last escrowed, a value other than the one in
-// the local env file. Then it persists the host's conflict marker and
-// answers the alert: the bucket's copy came first, the local file is left
-// for an operator, and every later launch is refused until the marker is
-// removed.
-func (b *ExecBackend) mintedConflict(ctx context.Context, rt registry.Route, p instancePaths, m hostfiles.Manifest) error {
- st := b.escrow.state(rt.Host)
- var minted []string
- b.escrow.with(func() {
- for name := range st.minted {
- minted = append(minted, name)
+// escrowDivergence names the trio items this publish would replace in
+// the escrow m holds with other bytes: an escrowed instance.key or
+// report.token is write-once (fix round 2, P1-1), and its keyed digest
+// decides with no request. The env stays editable, and is not checked.
+func (b *ExecBackend) escrowDivergence(m hostfiles.Manifest, reads []escrowRead, seal *hostfiles.ItemSealer) []string {
+ var diverged []string
+ for _, r := range reads {
+ item := r.rel.Item()
+ if !r.stage || item == hostfiles.SealedEnvItem {
+ continue
}
- })
- if len(minted) == 0 {
- return nil
- }
- escrowed, found, err := b.escrowEnvOf(ctx, rt, m)
- if err != nil || !found {
- return err
- }
- local, _, err := instancefs.ReadBeneathLimitOrAbsent(p.dataDir, rt.Host+".env", haEnvReadLimit)
- if err != nil {
- return fmt.Errorf("escrow: read the env file: %w", err)
- }
- theirs, ours := parseEnvBytes(escrowed), parseEnvBytes(local)
- sort.Strings(minted)
- var conflicts []string
- for _, name := range minted {
- if v := theirs[name]; v != "" && v != ours[name] {
- conflicts = append(conflicts, name)
+ if e, ok := m.Platform[item]; ok && e.Sealed != "" && e.PlainMAC != seal.MAC(item, r.plain) {
+ diverged = append(diverged, r.rel.Rel())
}
}
- if len(conflicts) == 0 {
- return nil
- }
+ return diverged
+}
+
+// escrowConflictFound is the refusal for a divergence: an alert, and the
+// host's conflict marker written if it can be. The refusal holds whether
+// or not the marker was written, since every later launch finds the same
+// divergence.
+func (b *ExecBackend) escrowConflictFound(rt registry.Route, p instancePaths, diverged []string) error {
path := escrowConflictPath(b.DataDir, rt.Host)
- if err := b.writeEscrowConflict(rt.Host, conflicts); err != nil {
- log.Printf("activator: %s: escrow: the conflict marker %s was not written: %v", rt.Host, path, err)
+ if err := b.writeEscrowConflict(rt.Host, diverged); err != nil {
+ log.Printf("activator: %s: escrow: the conflict marker %s was not written: %v (the launch stays refused while the divergence lasts)", rt.Host, path, err)
}
- err = fmt.Errorf("ALERT: %s: escrow: the bucket escrows another %s than the one this box just minted; the bucket's copy came first, so this launch stops and %s is left for an operator; every launch of the host on this box is refused until the operator settles it and removes %s",
- rt.Host, strings.Join(conflicts, " and "), p.envFile, path)
+ err := fmt.Errorf("ALERT: %s: escrow: %s differs from the copy the host's escrow in the bucket holds, and an escrowed instance.key or report.token is never replaced; the bucket's copy came first, so this launch stops and the local file is left for an operator; every launch of the host on this box is refused until the operator settles it against the escrow and removes %s",
+ rt.Host, strings.Join(diverged, " and "), path)
log.Print(err)
return err
}
+// keepLedger writes after, the manifest just committed, as host's ledger.
+// A write that fails removes the stale ledger, so the next restore reads
+// the bucket; a removal that fails too marks the ledger untrusted for this
+// process. Either way the host's next publish opens from the bucket.
+func (b *ExecBackend) keepLedger(host string, st *escrowState, after hostfiles.Baseline) {
+ err := writeEscrowLedger(b.DataDir, host, after)
+ if err == nil {
+ b.escrow.with(func() { st.ledgerUntrusted = false })
+ return
+ }
+ b.escrow.drop(st)
+ if rerr := removeEscrowLedger(b.DataDir, host); rerr != nil {
+ b.escrow.with(func() { st.ledgerUntrusted = true })
+ log.Printf("activator: %s: escrow: the ledger was not written (%v) and the stale one could not be removed (%v); this agent reads the bucket for the host instead", host, err, rerr)
+ return
+ }
+ log.Printf("activator: %s: escrow: the ledger was not written (%v) and the stale one was removed; the host's next restore and publish read the bucket", host, err)
+}
+
// restoreEscrowIfMissing writes each escrowed file whose local copy is
// absent from the bucket's sealed item, never over a present file. The
// mode decides first (P2-5): with no files store it does nothing; with no
@@ -862,7 +901,7 @@ func (b *ExecBackend) restoreEscrowIfMissing(ctx context.Context, rt registry.Ro
return fmt.Errorf("escrow: not restored: the row's layout is %s", p.layout)
}
var lm hostfiles.Manifest
- ledger, haveLedger := readEscrowLedger(b.DataDir, rt.Host)
+ ledger, haveLedger := b.ledgerFor(rt.Host)
if haveLedger {
if m, err := baselineManifest(ledger); err == nil {
lm = m
@@ -871,8 +910,8 @@ func (b *ExecBackend) restoreEscrowIfMissing(ctx context.Context, rt registry.Ro
}
}
st := b.escrow.state(rt.Host)
- var checked bool
- b.escrow.with(func() { checked = st.checked })
+ var checked, untrusted bool
+ b.escrow.with(func() { checked, untrusted = st.checked, st.ledgerUntrusted })
rels := pubclass.SealedRels(lay, rt.Host)
missing := map[string]bool{}
need := false
@@ -887,7 +926,7 @@ func (b *ExecBackend) restoreEscrowIfMissing(ctx context.Context, rt registry.Ro
}
missing[r.Item()] = true
switch {
- case r.Item() == hostfiles.SealedEnvItem:
+ case r.Item() == hostfiles.SealedEnvItem, untrusted:
need = true
case haveLedger:
if _, ok := lm.Platform[r.Item()]; ok {
@@ -971,8 +1010,7 @@ func writeIfAbsent(dir, name string, data []byte) (bool, error) {
// and refuses, wrapping ErrInstanceKeyDeferred, when the escrowed env holds
// the variable; an escrow that does not open with this box's key refuses
// as not ready does. fresh false shares the preparation's read; a mint
-// outside a launch (the backfill) passes fresh. A mint it lets go ahead is
-// noted, so a later publish can tell a secret this box minted.
+// outside a launch (the backfill) passes fresh.
func (b *ExecBackend) escrowMintGuard(ctx context.Context, rt registry.Route, fresh bool) mintGuard {
switch b.escrowModeOf(rt) {
case escrowNoStore:
@@ -1029,13 +1067,6 @@ func (b *ExecBackend) escrowMintGuard(ctx context.Context, rt registry.Route, fr
if env[name] != "" {
return fmt.Errorf("%w: the host's escrow in the bucket holds %s and the local env file lacks it, so nothing is minted beside it", ErrInstanceKeyDeferred, name)
}
- st := b.escrow.state(rt.Host)
- b.escrow.with(func() {
- if st.minted == nil {
- st.minted = map[string]bool{}
- }
- st.minted[name] = true
- })
return nil
}
}
@@ -1063,8 +1094,8 @@ func errEscrowWriter(host string) error {
// escrowReread is a superseded publish's second look: the bucket's
// manifest read again and made the host's publisher (stamps dropped, so
-// every file is read again), and the conflict check (mintedConflict) on
-// what it holds now.
+// every file is read again). The next publish holds the local files to
+// what it holds now (escrowDivergence).
func (b *ExecBackend) escrowReread(ctx context.Context, rt registry.Route, p instancePaths) error {
st := b.escrow.state(rt.Host)
st.op.Lock()
@@ -1081,11 +1112,7 @@ func (b *ExecBackend) escrowReread(ctx context.Context, rt registry.Route, p ins
if escrowHooks.afterReread != nil {
escrowHooks.afterReread(rt.Host)
}
- m, err := baselineManifest(pub.Baseline())
- if err != nil {
- return err
- }
- return b.mintedConflict(ctx, rt, p, m)
+ return nil
}
// escrowedLaunchEnv is launchEnvLayer for an eligible host, and the end of
diff --git a/internal/activator/escrow_test.go b/internal/activator/escrow_test.go
index 55d3f9fe3..17b7f8a92 100644
--- a/internal/activator/escrow_test.go
+++ b/internal/activator/escrow_test.go
@@ -537,10 +537,13 @@ func TestCrashBetweenCommitAndLedgerRestoresTheBucketVersion(t *testing.T) {
t.Fatal(err)
}
writeEnv(t, b, rt, envB)
- old := writeEscrowLedger
- writeEscrowLedger = func(string, string, hostfiles.Baseline) error { return errors.New("disk full") }
+ // The crash: the agent dies after the commit and before it rewrites or
+ // removes the ledger.
+ oldW, oldR := writeEscrowLedger, removeEscrowLedger
+ writeEscrowLedger = func(string, string, hostfiles.Baseline) error { return errors.New("crashed") }
+ removeEscrowLedger = func(string, string) error { return errors.New("crashed") }
mustPublish(t, b, rt)
- writeEscrowLedger = old
+ writeEscrowLedger, removeEscrowLedger = oldW, oldR
if got, _ := os.ReadFile(escrowLedgerPath(b.DataDir, rt.Host)); !bytes.Equal(got, ledgerA) {
t.Fatal("the fixture's ledger moved past A")
}
@@ -623,7 +626,6 @@ func TestRestoreNeverOverwritesALocalEnv(t *testing.T) {
writeFiles(t, b, rt, map[string]string{"instance.key": "ik-a", "report.token": "rt-a"})
mustPublish(t, b, rt)
writeEnv(t, b, rt, envB)
- writeFiles(t, b, rt, map[string]string{"instance.key": "ik-b"})
if err := os.Remove(filepath.Join(filesDirOf(b, rt), "report.token")); err != nil {
t.Fatal(err)
}
@@ -635,12 +637,22 @@ func TestRestoreNeverOverwritesALocalEnv(t *testing.T) {
if got := envFileBytes(t, nb, rt); got != envB {
t.Fatalf("env %q, want the local B", got)
}
- if got := readFile(t, nb, rt, "instance.key"); got != "ik-b" {
+ if got := readFile(t, nb, rt, "instance.key"); got != "ik-a" {
t.Fatalf("instance.key %q, want the local one", got)
}
if got := readFile(t, nb, rt, "report.token"); got != "rt-a" {
t.Fatalf("report.token %q, want the escrow's", got)
}
+ // A local instance.key that differs from the escrow's is never
+ // overwritten either: the launch is refused (write-once) and the file
+ // is left for an operator.
+ writeFiles(t, nb, rt, map[string]string{"instance.key": "ik-b"})
+ if _, err := nb.launchEnvForTest(rt); err == nil || !strings.Contains(err.Error(), "ALERT: ") {
+ t.Fatalf("the launch with a differing key: %v", err)
+ }
+ if got := readFile(t, nb, rt, "instance.key"); got != "ik-b" {
+ t.Fatalf("instance.key %q, want the local one left", got)
+ }
}
// The escrow holds both secrets and the local env lacks them: nothing is
@@ -763,6 +775,12 @@ func TestAbsentEnvNeverDeletesTheEscrow(t *testing.T) {
// item, straight through the files publisher (a box that does not hold the
// lease, or an older binary): what this box's compare-and-swap meets.
func foreignCommit(ctx context.Context, b *ExecBackend, rt registry.Route, env string) error {
+ return foreignCommitItem(ctx, b, rt, rt.Host+".env", env)
+}
+
+// foreignCommitItem is foreignCommit for any sealed path (rel, relative to
+// the inventory root).
+func foreignCommitItem(ctx context.Context, b *ExecBackend, rt registry.Route, rel, body string) error {
pub, err := hostfiles.Open(ctx, b.FilesStore, b.filesPrefix(rt.Host))
if err != nil {
return err
@@ -771,11 +789,11 @@ func foreignCommit(ctx context.Context, b *ExecBackend, rt registry.Route, env s
if err != nil {
return err
}
- r, ok := pubclass.SealedPath(pubclass.Nested, rt.Host, rt.Host+".env")
+ r, ok := pubclass.SealedPath(pubclass.Nested, rt.Host, rel)
if !ok {
- return errors.New("no sealed path for the env")
+ return errors.New("no sealed path for " + rel)
}
- if err := pub.StageSealed(ctx, r, []byte(env), seal); err != nil {
+ if err := pub.StageSealed(ctx, r, []byte(body), seal); err != nil {
return err
}
_, err = pub.Commit(ctx)
@@ -861,62 +879,59 @@ func TestSupersededEscrowReopensOnce(t *testing.T) {
}
}
-// P1-1: the guard read no key, another writer escrowed key B, and this
-// box minted key A. The launch is refused with an alert and a conflict
-// marker; a second wake is refused, and so is a launch after a restart,
-// and the escrow keeps B, until an operator removes the marker.
+// P1-1: the app wrote instance.key A, and before this box escrowed it
+// another writer escrowed key B. The launch is refused with an alert and a
+// conflict marker; a second wake is refused, and so is a launch after a
+// restart, and the escrow keeps B, until an operator settles the file and
+// removes the marker.
func TestCompetingMintStaysRefusedAcrossWakesAndRestarts(t *testing.T) {
ctx := context.Background()
b, rt := escrowBackend(t, escrowHost)
- writeEnv(t, b, rt, "CARLOS_ADMIN_TOKEN=tok-a\n")
+ writeEnv(t, b, rt, envA)
mustPublish(t, b, rt)
- competing := "CARLOS_ADMIN_TOKEN=tok-a\n" + InstanceKeyVar + "=key-b\n"
+ writeFiles(t, b, rt, map[string]string{"instance.key": "ik-a"})
escrowHooks.afterCapture = func(host string) {
- if err := foreignCommit(ctx, b, rt, competing); err != nil {
+ escrowHooks.afterCapture = nil
+ if err := foreignCommitItem(ctx, b, rt, rt.Host+"/instance.key", "ik-b"); err != nil {
t.Error(err)
}
}
t.Cleanup(func() { escrowHooks.afterCapture = nil })
_, err := b.launchEnvForTest(rt)
- escrowHooks.afterCapture = nil
marker := escrowConflictPath(b.DataDir, rt.Host)
- if err == nil || !strings.Contains(err.Error(), "ALERT: ") || !strings.Contains(err.Error(), marker) {
- t.Fatalf("the first launch: %v", err)
+ if err == nil || !strings.Contains(err.Error(), "ALERT: ") || !strings.Contains(err.Error(), marker) || !exists(marker) {
+ t.Fatalf("the first launch: %v (marker %v)", err, exists(marker))
}
- minted := envValues(t, b, rt, InstanceKeyVar)[0]
- if minted == "" || minted == "key-b" || !exists(marker) {
- t.Fatalf("local key %q, marker %v", minted, exists(marker))
+ if got := readFile(t, b, rt, "instance.key"); got != "ik-a" {
+ t.Fatalf("local key %q, want A left for the operator", got)
}
- if got := sealedItem(t, b, rt, hostfiles.SealedEnvItem); got != competing {
+ if got := sealedItem(t, b, rt, "instance.key.sealed"); got != "ik-b" {
t.Fatalf("escrow %q, want the bucket's B kept", got)
}
-
- // A second wake: the local key is present, so no producer asks its
- // guard; the marker refuses it.
+ // A second wake: refused.
if _, err := b.launchEnvForTest(rt); err == nil || !strings.Contains(err.Error(), marker) {
t.Fatalf("the second launch: %v", err)
}
if rep := b.EscrowSweep(ctx, []registry.Route{rt}); rep.Published != 0 || len(rep.Failing) != 1 {
t.Fatalf("the sweep: %+v", rep)
}
- // A restart forgets what it minted; the marker does not.
+ // A restart: refused.
nb := restartEscrow(t, b)
holdLease(t, nb, rt)
if _, err := nb.launchEnvForTest(rt); err == nil || !strings.Contains(err.Error(), marker) {
t.Fatalf("the launch after a restart: %v", err)
}
- if got := sealedItem(t, nb, rt, hostfiles.SealedEnvItem); got != competing {
+ if got := sealedItem(t, nb, rt, "instance.key.sealed"); got != "ik-b" {
t.Fatalf("escrow %q, want B", got)
}
- // The operator settles the env on the escrow's key and removes the
- // marker: the launch goes ahead with B.
- writeEnv(t, nb, rt, competing)
+ // The operator settles the file on the escrow's key and removes the
+ // marker: the launch goes ahead.
+ writeFiles(t, nb, rt, map[string]string{"instance.key": "ik-b"})
if err := os.Remove(marker); err != nil {
t.Fatal(err)
}
- env, err := nb.launchEnvForTest(rt)
- if err != nil || env[InstanceKeyVar] != "key-b" {
- t.Fatalf("after the operator: %v, key %q", err, env[InstanceKeyVar])
+ if _, err := nb.launchEnvForTest(rt); err != nil {
+ t.Fatalf("after the operator: %v", err)
}
}
@@ -1129,3 +1144,130 @@ func TestSweepRacesNoLaunchOrWorker(t *testing.T) {
}
<-done
}
+
+// writeFailingMarker makes every conflict-marker write fail for the test.
+func writeFailingMarker(t *testing.T) {
+ t.Helper()
+ old := writeEscrowMarker
+ writeEscrowMarker = func(string, string, []byte) error { return errors.New("disk full") }
+ t.Cleanup(func() { writeEscrowMarker = old })
+}
+
+// P1-1 (round 2): an escrowed instance.key is write-once. A local key that
+// differs from the escrow's refuses the launch with an alert even when the
+// marker cannot be written, and a restart (no memory, no marker) refuses
+// again: the divergence itself is the evidence.
+func TestDivergentTrioRefusedWithoutAMarker(t *testing.T) {
+ b, rt := escrowBackend(t, escrowHost)
+ writeEnv(t, b, rt, envA)
+ writeFiles(t, b, rt, map[string]string{"instance.key": "ik-1"})
+ mustPublish(t, b, rt)
+ writeFailingMarker(t)
+ writeFiles(t, b, rt, map[string]string{"instance.key": "ik-2"})
+ marker := escrowConflictPath(b.DataDir, rt.Host)
+ if _, err := b.launchEnvForTest(rt); err == nil || !strings.Contains(err.Error(), "ALERT: ") {
+ t.Fatalf("the launch with a divergent key: %v", err)
+ }
+ if exists(marker) {
+ t.Fatal("fixture: the marker was written")
+ }
+ nb := restartEscrow(t, b)
+ holdLease(t, nb, rt)
+ if _, err := nb.launchEnvForTest(rt); err == nil || !strings.Contains(err.Error(), "ALERT: ") {
+ t.Fatalf("the launch after a restart: %v", err)
+ }
+ if rep := nb.EscrowSweep(context.Background(), []registry.Route{rt}); rep.Published != 0 || len(rep.Failing) != 1 {
+ t.Fatalf("the sweep: %+v", rep)
+ }
+ if got := sealedItem(t, nb, rt, "instance.key.sealed"); got != "ik-1" {
+ t.Fatalf("escrowed key %q, want the first", got)
+ }
+}
+
+// A stale local key found after a restart, with no marker ever written: the
+// launch is refused and the escrow keeps its key.
+func TestStaleDifferingKeyAfterARestartRefused(t *testing.T) {
+ b, rt := escrowBackend(t, escrowHost)
+ writeEnv(t, b, rt, envA)
+ writeFiles(t, b, rt, map[string]string{"instance.key": "ik-1"})
+ mustPublish(t, b, rt)
+ nb := restartEscrow(t, b)
+ holdLease(t, nb, rt)
+ writeFiles(t, nb, rt, map[string]string{"instance.key": "ik-stale"})
+ if _, err := nb.launchEnvForTest(rt); err == nil || !strings.Contains(err.Error(), "ALERT: ") {
+ t.Fatalf("the launch with a stale key: %v", err)
+ }
+ if got := sealedItem(t, nb, rt, "instance.key.sealed"); got != "ik-1" {
+ t.Fatalf("escrowed key %q, want the first", got)
+ }
+}
+
+// P1-2 (round 2): the lease is lost after the publish opened its baseline
+// and before it commits. Nothing is committed, and the new holder's
+// manifest is untouched.
+func TestLeaseLostBeforeCommitCommitsNothing(t *testing.T) {
+ ctx := context.Background()
+ b, rt := escrowBackend(t, escrowHost)
+ writeEnv(t, b, rt, envA)
+ mustPublish(t, b, rt)
+ ob, ort := otherBox(t, b, rt)
+ var held hostfiles.Manifest
+ escrowHooks.beforeCommit = func(host string) {
+ escrowHooks.beforeCommit = nil
+ var l *execLease
+ b.escrow.with(func() { l = b.escrow.leases[host] })
+ _ = l.Release(ctx)
+ holdLease(t, ob, ort)
+ writeEnv(t, ob, ort, envB)
+ mustPublish(t, ob, ort)
+ held = loadManifest(t, ob, ort)
+ }
+ t.Cleanup(func() { escrowHooks.beforeCommit = nil })
+ writeEnv(t, b, rt, envA+"FOO=1\n")
+ if _, err := b.publishEscrow(ctx, rt, nil); !errors.Is(err, errEscrowNoLease) {
+ t.Fatalf("the publish that lost its lease: %v", err)
+ }
+ if got := loadManifest(t, ob, ort); got.Seq != held.Seq || sealedItem(t, ob, ort, hostfiles.SealedEnvItem) != envB {
+ t.Fatalf("the new holder's manifest moved: seq %d, want %d", got.Seq, held.Seq)
+ }
+}
+
+// New Important (round 2): ledger A lacks instance.key; a later commit
+// escrows the key and its ledger write fails; after a restart with the env
+// intact and the key missing, the key is restored from the bucket. With
+// the ledger's removal failing too, this process reads the bucket for the
+// host instead of trusting it.
+func TestStaleLedgerNeverSuppressesARestore(t *testing.T) {
+ for _, removal := range []string{"removed", "removal fails"} {
+ t.Run(removal, func(t *testing.T) {
+ b, rt := escrowBackend(t, escrowHost)
+ writeEnv(t, b, rt, envA)
+ mustPublish(t, b, rt)
+ writeFiles(t, b, rt, map[string]string{"instance.key": "ik-1"})
+ oldW, oldR := writeEscrowLedger, removeEscrowLedger
+ writeEscrowLedger = func(string, string, hostfiles.Baseline) error { return errors.New("disk full") }
+ if removal == "removal fails" {
+ removeEscrowLedger = func(string, string) error { return errors.New("read-only") }
+ }
+ mustPublish(t, b, rt)
+ writeEscrowLedger, removeEscrowLedger = oldW, oldR
+ if got := sealedItem(t, b, rt, "instance.key.sealed"); got != "ik-1" {
+ t.Fatalf("fixture: escrowed key %q", got)
+ }
+ nb := b
+ if removal == "removed" {
+ nb = restartEscrow(t, b)
+ holdLease(t, nb, rt)
+ }
+ if err := os.Remove(filepath.Join(filesDirOf(nb, rt), "instance.key")); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := nb.launchEnvForTest(rt); err != nil {
+ t.Fatalf("launch: %v", err)
+ }
+ if got := readFile(t, nb, rt, "instance.key"); got != "ik-1" {
+ t.Fatalf("instance.key %q, want the escrowed one", got)
+ }
+ })
+ }
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index f886a0f70..1d7c44aa4 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -45,4 +45,4 @@ plan14-root-reads-fleet-public-routes.tsv bca6ef741a96b72767b1747789cd01b3111d61
plan14-root-reads-fleet-routes-followups.tsv 1379d066c8dd2335d95d5f6e9c7bce65ff57f00b2b287a308d9b3f47911ae5e7
plan14-root-reads-tunnel-websockets.tsv 949bc734a293366e6b2700244af5110dd6e84b5432023e991c09e806afd62483
plan14-root-reads-console-protection-tab.tsv eaeb153ab7a7a849edc9c6e92f2ac5c709c6e39044a647971cf1fa5ebcb660c8
-plan14-root-reads-durability-3a-escrow.tsv d6c281d7e095e8e0625c6199044d67dc0da559e7b4af5fbdc1a4e032bfbb65dc
+plan14-root-reads-durability-3a-escrow.tsv 303f60594ae584c6bb29263c485ef3de60d76a4bd60166134b8ad3bcd3ba6139
diff --git a/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv b/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv
index 743fc3c9d..6278dfa0c 100644
--- a/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv
+++ b/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv
@@ -13,24 +13,24 @@
@legacy 90f2d51840159dd44037a8eb60115e037f27c635d74652028b368bda6fcd35b8 internal/activator/escrow.go ExecBackend.SecretsEscrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: haHostNow or escrowEligible; reads only what the HA classification already reads whole:Route@123,whole:Route@198 c22d35df72f67d7222efd0b0f09d51c42275ad4a10d637598fdc8b822f6333bd
@legacy c7e39531f926452a19521b0399f157fa65ea04f015d2c185cee19cb585f07bab internal/activator/escrow.go ExecBackend.bucketManifest legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 1: new: the host's files manifest in the hibernate bucket, the launch preparation's read when there is one (unless fresh), else one GET: hostfiles.Open with a sealing key (the publisher installed for the launch's publish), hostfiles.Load without; kept as the preparation's read; the agent as carlos (carlos-edge.service), no root caller file:Open@408,registry:Host@170,registry:Host@241,registry:Host@370,registry:Host@954,whole:Route@329 a993cc65cd23b5568160c431ee28184109ad4375e9099a31cde921dd0e3fa379
@legacy 97fc560e1b1b84ecc13660f4bc1d364e45dfffac3607637f02db89ad52eef2b1 internal/activator/escrow.go ExecBackend.escrowChanged legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: compares each escrowed file's stamp (stampAt, beneath the row's data directory) with the last kept one; reads no bytes Fix round 1 (P1-4): the stamps are copied under the escrow mutex, entry by entry, before they are compared; the same opens, no read added. registry:Host@122,registry:Host@444 12b8759b8473bb17eca3ad8b9912ba23f522dca54f2fe1c309b619fd72a3a879
-@legacy 8cd41e2e2aa714570c4f2e09fe1d81fc1e79647a140bc6651a74cb2b702057bc internal/activator/escrow.go ExecBackend.escrowConflict legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 1: new: os.Lstat of <data>/.escrow/<host>.conflict, the agent's own directory; present, every launch, mint and publish of the host is refused with an alert naming the file for an operator to remove; only refuses; the agent as carlos (carlos-edge.service), no root caller file:Lstat@117 330ea70578fa605c174d1e0bdf89acd291631ba2b8c7144035e2fa05b404ab80
+@legacy 573f35211cf44372a958e8c843433a88bcaedbf5df7e0e007ba3ce427f3eb5cf internal/activator/escrow.go ExecBackend.escrowConflict legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 1: new: os.Lstat of <data>/.escrow/<host>.conflict, the agent's own directory; present, every launch, mint and publish of the host is refused with an alert naming the file for an operator to remove; only refuses; the agent as carlos (carlos-edge.service), no root caller Fix round 2: the alert text names the divergence generally (local secrets differ from the escrow); the same Lstat. file:Lstat@117 c3b7c49a46a5c2c9159ced89438b91dc935fd8fb7d05b71293b31082019917b8
+@legacy ebb5d5cfbce42e0f1d9bb6996bfde66ce966daff74e08ac9aec6f51f32d9d739 internal/activator/escrow.go ExecBackend.escrowConflictFound legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 2: new: the refusal for a divergent trio item: tries to write the host's conflict marker (writeEscrowMarker: EnsureDirBeneath <data>/.escrow 0700, a 0600 temp, rename, fsync), logs if it cannot, and returns the alert; the refusal holds either way, since every later publish finds the same divergence; only refuses; the agent as carlos (carlos-edge.service), no root caller registry:Host@144,registry:Host@186,registry:Host@355,registry:Host@756 907cc8d8310162c5367e385b40e1e1181249fb8c9dd1713b3f7d3fb1cf41bc47
@legacy 254a354a40269aaae37fee1c09f3fa5a46763943c83ba128748dc51e3f1a46fe internal/activator/escrow.go ExecBackend.escrowEligible legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: escrowEligibleAt on pathsFor's classification whole:Route@105,whole:Route@90 038966cd4221f6cbafe0eb80bdbf7ec69b54d36a34c0ea22a53746d2acac63fe
@legacy ea8e33b8cda7a3bf9671cfec5fbb8f90ad01be56378d7558af9520f6c25519c8 internal/activator/escrow.go ExecBackend.escrowEligibleAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: a pure predicate over the row and a classification: ActivatorManaged, not unit, sidecar, HA, replica, held, a valid host shape and app, flat or nested, on a box with a hibernate bucket; reads only row fields registry:App@295,registry:HA@163,registry:HoldOp@186,registry:Host@265,registry:Replica@172,registry:Status@221,registry:Unit@126,whole:Route@119 5df0c11ddde0ec351b062b87863396108d2fe48b7b4e390ca69daf377e0cac58
@legacy a7d3afeb8f7275c5636a65cace92ecf2e4a2d4f2fa5f3fa2278494f27ec2d2bb internal/activator/escrow.go ExecBackend.escrowEnvOf legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the sealed env item opened with hostfiles.ReadSealed under this box's key and the row's binding (sha256, v2 envelope, binding and MAC checked); found false when the manifest holds none; a failure wraps ErrEscrowNotReady registry:Host@389,whole:Route@230 dd6e1f3a3e8299303a3f9c2f89d2ec2f952dbdcb45264ac39484abc925b2e415
-@legacy 430a0f03dfbe87e31c081fcba85ccaa101663aaeef3854bb78a029fe7d2adcc8 internal/activator/escrow.go ExecBackend.escrowMintGuard legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: on a box that is not ready refuses every mint (ErrEscrowNotReady); otherwise, once and only when a producer would mint, bucketEscrowEnv, and refuses (ErrInstanceKeyDeferred) when the escrowed env holds the variable; a mint it allows is noted in memory; only refuses Fix round 0 (controller readiness ruling): with no files store it is nil, and the producer mints as before 3a; with a files store and no sealing key it reads the bucket manifest at the mint (keylessEscrowed, fresh) and refuses (ErrEscrowNotReady) when the bucket holds any sealed item or the cutover marker for the host, and otherwise lets the mint go ahead (logged once); only refuses. Fix round 1: with a key it refuses while the conflict marker exists or while this box does not hold the host's lease (ErrInstanceKeyDeferred); its bucket read is bucketManifest, the preparation's shared read unless fresh (the backfill); without a key its keyless read is the same, with no cache across launches (P1-3); only refuses. registry:Host@1512,registry:Host@683,registry:Host@756,whole:Route@1064,whole:Route@125,whole:Route@209,whole:Route@291,whole:Route@527,whole:Route@898 08e66d3bcef3ebc4186bef64c54aa16dda63ff76b73563f9f394522912e00883
+@legacy a1acc9186a4b1f7cb650320e76c3d65ed536a9b4b5b3b5c8ec04779032d8631e internal/activator/escrow.go ExecBackend.escrowMintGuard legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: on a box that is not ready refuses every mint (ErrEscrowNotReady); otherwise, once and only when a producer would mint, bucketEscrowEnv, and refuses (ErrInstanceKeyDeferred) when the escrowed env holds the variable; a mint it allows is noted in memory; only refuses Fix round 0 (controller readiness ruling): with no files store it is nil, and the producer mints as before 3a; with a files store and no sealing key it reads the bucket manifest at the mint (keylessEscrowed, fresh) and refuses (ErrEscrowNotReady) when the bucket holds any sealed item or the cutover marker for the host, and otherwise lets the mint go ahead (logged once); only refuses. Fix round 1: with a key it refuses while the conflict marker exists or while this box does not hold the host's lease (ErrInstanceKeyDeferred); its bucket read is bucketManifest, the preparation's shared read unless fresh (the backfill); without a key its keyless read is the same, with no cache across launches (P1-3); only refuses. Fix round 2: no longer notes the mints it allows in memory; only refuses. registry:Host@683,registry:Host@756,whole:Route@1064,whole:Route@125,whole:Route@209,whole:Route@291,whole:Route@527,whole:Route@898 5ba26a63e4d4f3944484f2a2257c1b43336f1ec9ed02cf56510558ccb685a310
@legacy 4936d243b2f0dfe0070b2ed97ea46ff79d868bedc54deefec132baadba1410ee internal/activator/escrow.go ExecBackend.escrowModeOf legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 0 (controller readiness ruling): new: escrowNoStore when FilesStore is nil, escrowNoKey when escrowReady fails, else escrowOn; reads nothing whole:Route@147 6bfaddec7936f24f6756c8c68547d6a7fa54dd0523db9024e2f71924a2e7ecee
@legacy 2483746d1c63202a3c641199ea442261483853bea1b112ec3f2afc4772011d26 internal/activator/escrow.go ExecBackend.escrowOff legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 0: new: one log line per host per process saying escrow is off and why; reads nothing registry:Host@309,registry:Host@87 6f3a552d5af240733241ea7befefa194706a70770e8bdc4f3c444ac48cf8f8c3
@legacy 73fa77e711e182b4777ae6346795af7d5a36c4f1c231714ff2415806bffeafff internal/activator/escrow.go ExecBackend.escrowReady legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: FilesStore and EscrowKey set and sealerFor succeeds; reads nothing whole:Route@165 fb7390d8f2ce1653619c3b365a3f804e5e1a0bb6f77210972a83453ebda42316
-@legacy b63863c23c9c402ae0a5e8d34c2ac8151592f3cd2a56fb297fcb6ecb1e234991 internal/activator/escrow.go ExecBackend.escrowReread legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new, after a superseded publish: hostfiles.Open of the host's files manifest, and, when this box noted a mint, the sealed env (escrowEnvOf) and the local env file with instancefs.ReadBeneathLimitOrAbsent (1 MiB, no link followed) beneath the row's data directory, to refuse publishing over an escrowed secret of another value; the agent as carlos (carlos-edge.service), no root caller; only refuses Fix round 1: the conflict check is mintedConflict (on this card), which also persists the conflict marker. file:Open@284,registry:Host@122,registry:Host@332,registry:Host@520,whole:Route@193,whole:Route@639 5886155c4babdda278b730266aa59100c2ee9ce0e846de7e06364c0c2464bcb8
+@legacy 7dae741d2155619f9818b21e8869d2e520e6944edc29356632228ee4240f7a28 internal/activator/escrow.go ExecBackend.escrowReread legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new, after a superseded publish: hostfiles.Open of the host's files manifest, and, when this box noted a mint, the sealed env (escrowEnvOf) and the local env file with instancefs.ReadBeneathLimitOrAbsent (1 MiB, no link followed) beneath the row's data directory, to refuse publishing over an escrowed secret of another value; the agent as carlos (carlos-edge.service), no root caller; only refuses Fix round 1: the conflict check is mintedConflict (on this card), which also persists the conflict marker. Fix round 2: only re-reads and installs the publisher; the conflict check is the next publish's write-once check. file:Open@284,registry:Host@122,registry:Host@332,registry:Host@520,whole:Route@193 9489f90533e27fa5f5b07bf4d020af586982554094b52ce10ce5d7ed17c6341a
@legacy e8606977b49dc6afb61672760923f9a1d30245d2c43adbdaf3a3ee6f77f20c30 internal/activator/escrow.go ExecBackend.escrowedLaunchEnv legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new, the launch path for an eligible host: captureLaunchEnv once, publishEscrowAt over those bytes, SealedAcknowledged on the commit, and the env parsed from the captured bytes; on a supersession escrowReread and the launch preparation again (ensureAdminTokenFor, ensureInstanceKeyFor) once; a not-ready box launches only a host its ledger shows escrowed; the agent as carlos (carlos-edge.service), no root caller Fix round 0 (controller readiness ruling): before the capture, the box's mode: no files store, instanceEnvLayer exactly as before 3a (logged once); no sealing key, a host whose ledger shows it escrowed launches on instanceEnvLayer (logged), otherwise keylessEscrowed (the answer this launch's restore read, within haSecretsBudget, else one GET) refuses when the bucket holds an escrow and launches on instanceEnvLayer when it holds none; nothing is published in either. Fix round 1: ends the launch's preparation; refuses while the conflict marker exists, and with a key while this box does not hold the host's lease; an ALERT from the publish fails the launch; the keyless decision uses the preparation's read. registry:Host@1039,registry:Host@1100,registry:Host@1182,registry:Host@1337,registry:Host@1422,registry:Host@145,registry:Host@1590,registry:Host@1792,registry:Host@2054,registry:Host@2215,registry:Host@238,registry:Host@2506,registry:Host@2627,registry:Host@2801,registry:Host@3017,registry:Host@635,registry:Host@764,registry:Host@809,registry:Host@912,whole:Route@1244,whole:Route@1470,whole:Route@1699,whole:Route@1957,whole:Route@205,whole:Route@2117,whole:Route@331,whole:Route@374,whole:Route@419,whole:Route@469,whole:Route@516,whole:Route@691,whole:Route@735,whole:Route@959 ef92b19f81ddce0d887b5fe94a6cfbac7f1a1196f55aa851875723cd2c5d15fb
@legacy aa6c1694a6bfba03769ad089b3715610848596875e636952cf981c59a1761de3 internal/activator/escrow.go ExecBackend.haKnown legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the HA classification from memory only (haWakes, haLegacyRoute, the row's mark, the lifetime index); reads nothing registry:HA@185,registry:Host@274,registry:Host@95,whole:Route@151 4ecae90469fb6eda421464ca4509db7ddf4e5180180377867d3804b95bfd0c23
@legacy 69525c0419368661b947b49ab6f3af889f98804e603f9e5fdf1fd71aa534e030 internal/activator/escrow.go ExecBackend.keylessEscrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix rounds 0-1: new, on a box with a files store and no sealing key: whether the bucket holds an escrow for the host (any sealed item or the cutover marker), from bucketManifest: the read of the launch preparation in progress, or one hostfiles.Load (one GET); nothing is cached across launches (fix round 1, P1-3); a failed read is an error and the caller refuses; the agent as carlos (carlos-edge.service), no root caller whole:Route@146 5a14a5881e81f9b401a1f8321659e75cc6165a5477db6cacc89b6c7f9e5bee08
-@legacy 32c938abaeeaa84ee628f526c7225603f95b806e1b8a4fd52853a7d28b06149d internal/activator/escrow.go ExecBackend.mintedConflict legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 1: new: when this box minted a secret since the host's env was last escrowed, opens the manifest's sealed env (escrowEnvOf) and reads the local env file with instancefs.ReadBeneathLimitOrAbsent (1 MiB, no link followed); an escrowed value that differs persists the conflict marker (writeEscrowConflict: EnsureDirBeneath .escrow 0700, a 0600 temp, rename, fsync) and refuses with an alert; only refuses; the agent as carlos (carlos-edge.service), no root caller registry:Host@1059,registry:Host@1365,registry:Host@146,registry:Host@471,registry:Host@901,registry:Host@943,whole:Route@356 354e9eff4a66adbdfa1fa1fe43b263e49a6297e8a482fcefea860faf7c2e8223
-@legacy ea7599917b8081c1267fabb1c0de1e34efc0ecd377e37595362fe6d5cc0f5db0 internal/activator/escrow.go ExecBackend.openEscrowLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the host's publisher, from its ledger (readEscrowLedger: readCappedFile, O_NOFOLLOW, 32 MiB, under <data>/.escrow, the agent's own directory) with no request, else hostfiles.Open (one GET); the agent as carlos (carlos-edge.service), no root caller Fix round 1: marks the host checked when it reads the bucket; the same reads. file:Open@753,registry:Host@528,registry:Host@600,whole:Route@415 3968bf1d21f406133b0610deb45f9f188ebfd4cd4ab63cd966dd6831e7329b2b
+@legacy 27f7faabcf195bb06977092fc016771f6142250e82275595e567c1bc379f7bc5 internal/activator/escrow.go ExecBackend.openEscrowLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the host's publisher, from its ledger (readEscrowLedger: readCappedFile, O_NOFOLLOW, 32 MiB, under <data>/.escrow, the agent's own directory) with no request, else hostfiles.Open (one GET); the agent as carlos (carlos-edge.service), no root caller Fix round 1: marks the host checked when it reads the bucket; the same reads. Fix round 2: the ledger is read through ledgerFor (none while this process marks it untrusted); the same reads. file:Open@737,registry:Host@528,registry:Host@584,whole:Route@415 363fb2c216bb47936cdeec099ba8c0ca64da23daeadd300a56427467d747e969
@legacy c7f95f454a974537377434c9993beebc3b0761e814ae369a8e1e29a5c3fc5474 internal/activator/escrow.go ExecBackend.publishEscrow legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: publishEscrowAt on pathsFor whole:Route@149,whole:Route@164 e61757f12a116ef8bf819dcad7136f810c51dfa9f7104ceb7f810efece48cc29
@legacy f6e622ed3b9e219a616ce6bf2f951b3e50c7897bd6e8a7f59ddb335fcbf8e3db internal/activator/escrow.go ExecBackend.publishEscrowAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: escrowReady and the layout checked, then publishEscrowLocked under the host's lock Fix round 1: refuses while the conflict marker exists or while this box does not hold the host's lease (P1-2), before anything is read. registry:Host@223,registry:Host@269,registry:Host@340,registry:Host@376,registry:Host@435,registry:Host@556,registry:Host@653,whole:Route@157,whole:Route@733 5e2b655605216fcaa50ddfd0511ca4ce913a8716582932a13debf22c4876f117
-@legacy 34408982faf4b2c02b663d17ac38eb019eca7922f932c177c7821d8591056deb internal/activator/escrow.go ExecBackend.publishEscrowLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: reads <host>.env (unless the launch's capture is handed in), <host>/instance.key and <host>/report.token with readStamped beneath the row's data directory, seals what changed (StageSealed), DropRawSecrets of the constant raw names, commits, and writes the ledger (writeEscrowLedger: EnsureDirBeneath .escrow 0700, a 0600 temp, rename, fsync); an absent file stages nothing; a refused file publishes nothing for it; the agent as carlos (carlos-edge.service), no root caller Fix round 1: before staging, mintedConflict on the baseline it would replace, so a secret this box minted is never published over another escrowed value (P1-1). registry:Host@2175,registry:Host@2439,registry:Host@3743,registry:Host@3891,registry:Host@589,whole:Route@2366,whole:Route@2803 b775999c5c991fc9183204b603df5487818122b618786c787377df877fcb82e5
-@legacy dcb056881fe979ea36321207af512d0ea90bf8481b4f60a3a89d8386d661e523 internal/activator/escrow.go ExecBackend.restoreEscrowIfMissing legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: checks each escrowed file with instancefs.OpenBeneathOrAbsent beneath the row's data directory; when one is absent, hostfiles.Open of the host's manifest, ReadSealed of each missing item, and writeIfAbsent (instancefs.WriteAtomic of a temp, then RenameBetweenNoReplace, so a present file is never replaced; EnsureDirBeneath for the files directory, 0700); on a box that is not ready it refuses unless the ledger shows the host escrowed and the env file is here; the agent as carlos (carlos-edge.service), no root caller Fix round 0 (controller readiness ruling): with no files store it does nothing (logged once); with no sealing key it restores nothing: a ledger here and an env file here go on, otherwise keylessEscrowed refuses when the bucket holds an escrow and goes on as before 3a when it holds none. Fix round 1: the conflict marker first, then the mode (P2-5): no files store, nothing; no key, the preparation's keyless read before any file check. With a key, each trio file is checked with OpenBeneathOrAbsent (a link or FIFO is not missing); the bucket is read (bucketManifest, the preparation's one GET) only for a missing env file, or a missing trio file the ledger says was escrowed, or with no ledger once per agent start (P2-6); the same writes. registry:Host@1083,registry:Host@1235,registry:Host@1344,registry:Host@138,registry:Host@2075,registry:Host@2943,registry:Host@571,registry:Host@652,registry:Host@698,registry:Host@801,whole:Route@1876,whole:Route@1972,whole:Route@200,whole:Route@241,whole:Route@314,whole:Route@360,whole:Route@477 191bfdc6676592a79262402b0c07b2d6effbabf61a952b7f72ab641b8f856d8c
+@legacy 647fb1daba1053f375afcd81658e42f32e38f4b9fc2bbbf3af241b982620db9c internal/activator/escrow.go ExecBackend.publishEscrowLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: reads <host>.env (unless the launch's capture is handed in), <host>/instance.key and <host>/report.token with readStamped beneath the row's data directory, seals what changed (StageSealed), DropRawSecrets of the constant raw names, commits, and writes the ledger (writeEscrowLedger: EnsureDirBeneath .escrow 0700, a 0600 temp, rename, fsync); an absent file stages nothing; a refused file publishes nothing for it; the agent as carlos (carlos-edge.service), no root caller Fix round 1: before staging, mintedConflict on the baseline it would replace, so a secret this box minted is never published over another escrowed value (P1-1). Fix round 2 (P1-1, P1-2, stale ledger): before staging, the write-once check (escrowDivergence, keyed digests only, no request): a staged instance.key or report.token whose escrowed item has another digest refuses the publish (escrowConflictFound); then, under the operation lock just before the commit, the lease again (holdsLease): lost, nothing is committed and the staged state is dropped; after a commit the ledger through keepLedger (written, else the stale one removed with RemoveBeneath under <data>/.escrow, else marked untrusted in memory). registry:Host@2078,registry:Host@2342,registry:Host@3787,registry:Host@3817,registry:Host@4329,registry:Host@574,whole:Route@2269,whole:Route@2863 bda6bd959efd0806cd0bd38ee0415ac0d28901c009d9e9ad7c92a7ffc91fe214
+@legacy 82b2ec18d808601cbfdf46d4d48b89f5a34b10026f62cae866dd327aa3b8462b internal/activator/escrow.go ExecBackend.restoreEscrowIfMissing legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: checks each escrowed file with instancefs.OpenBeneathOrAbsent beneath the row's data directory; when one is absent, hostfiles.Open of the host's manifest, ReadSealed of each missing item, and writeIfAbsent (instancefs.WriteAtomic of a temp, then RenameBetweenNoReplace, so a present file is never replaced; EnsureDirBeneath for the files directory, 0700); on a box that is not ready it refuses unless the ledger shows the host escrowed and the env file is here; the agent as carlos (carlos-edge.service), no root caller Fix round 0 (controller readiness ruling): with no files store it does nothing (logged once); with no sealing key it restores nothing: a ledger here and an env file here go on, otherwise keylessEscrowed refuses when the bucket holds an escrow and goes on as before 3a when it holds none. Fix round 1: the conflict marker first, then the mode (P2-5): no files store, nothing; no key, the preparation's keyless read before any file check. With a key, each trio file is checked with OpenBeneathOrAbsent (a link or FIFO is not missing); the bucket is read (bucketManifest, the preparation's one GET) only for a missing env file, or a missing trio file the ledger says was escrowed, or with no ledger once per agent start (P2-6); the same writes. Fix round 2: the ledger is read through ledgerFor, and while it is untrusted (its write and the stale ledger's removal both failed) a missing trio file always reads the bucket; the same reads and writes. registry:Host@1067,registry:Host@1219,registry:Host@1370,registry:Host@138,registry:Host@2112,registry:Host@2980,registry:Host@571,registry:Host@652,registry:Host@698,registry:Host@801,whole:Route@1913,whole:Route@200,whole:Route@2009,whole:Route@241,whole:Route@314,whole:Route@360,whole:Route@477 d559d3af9307a0391fd0e9353c1de1b083034a325493bcc3a214d22228ba4f9d
@legacy 7d7ae676fe3d33d027489b397a804eaa184295667ad039688aed3757f662ab9d internal/activator/escrow.go ExecBackend.sweepPublish legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: publishEscrowAt, and on a supersession escrowReread and one more publish; a second one is the alert registry:Host@404,whole:Route@142,whole:Route@232,whole:Route@312 71bfee868a2ca8e3371cfc3c628b6ab5d8730ca48fcd099e7932049fe1e12a69
@legacy c89cfff20022faa5af3e07251a620b1b63e0b42f350483a6efec4162efdd1cca internal/activator/escrow.go Service.EscrowSweep legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the backend's EscrowSweep, nothing for a backend without one whole:Route@184 8ed0ea62a9807b7c43b3576d01f096bfe366c21bcc3be040831a3f1b80d1b123
@legacy 5e6fbfb1fc889f9d7742e9275cfaac39888a93c8d33ed329ee92088fcc52167f internal/activator/escrow.go Service.SecretsEscrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the backend's SecretsEscrowed, else IsHA whole:Route@184,whole:Route@215 87261115297104155806136d4d0001c4cd3e150e5ffe91612bb5014fb7780881
@@ -73,24 +73,24 @@ internal/activator/escrow.go ExecBackend.EscrowSweep legacy accepted-legacy acce
internal/activator/escrow.go ExecBackend.SecretsEscrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: haHostNow or escrowEligible; reads only what the HA classification already reads whole:Route@123,whole:Route@198 c22d35df72f67d7222efd0b0f09d51c42275ad4a10d637598fdc8b822f6333bd
internal/activator/escrow.go ExecBackend.bucketManifest legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 1: new: the host's files manifest in the hibernate bucket, the launch preparation's read when there is one (unless fresh), else one GET: hostfiles.Open with a sealing key (the publisher installed for the launch's publish), hostfiles.Load without; kept as the preparation's read; the agent as carlos (carlos-edge.service), no root caller file:Open@408,registry:Host@170,registry:Host@241,registry:Host@370,registry:Host@954,whole:Route@329 a993cc65cd23b5568160c431ee28184109ad4375e9099a31cde921dd0e3fa379
internal/activator/escrow.go ExecBackend.escrowChanged legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: compares each escrowed file's stamp (stampAt, beneath the row's data directory) with the last kept one; reads no bytes Fix round 1 (P1-4): the stamps are copied under the escrow mutex, entry by entry, before they are compared; the same opens, no read added. registry:Host@122,registry:Host@444 12b8759b8473bb17eca3ad8b9912ba23f522dca54f2fe1c309b619fd72a3a879
-internal/activator/escrow.go ExecBackend.escrowConflict legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 1: new: os.Lstat of <data>/.escrow/<host>.conflict, the agent's own directory; present, every launch, mint and publish of the host is refused with an alert naming the file for an operator to remove; only refuses; the agent as carlos (carlos-edge.service), no root caller file:Lstat@117 330ea70578fa605c174d1e0bdf89acd291631ba2b8c7144035e2fa05b404ab80
+internal/activator/escrow.go ExecBackend.escrowConflict legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 1: new: os.Lstat of <data>/.escrow/<host>.conflict, the agent's own directory; present, every launch, mint and publish of the host is refused with an alert naming the file for an operator to remove; only refuses; the agent as carlos (carlos-edge.service), no root caller Fix round 2: the alert text names the divergence generally (local secrets differ from the escrow); the same Lstat. file:Lstat@117 c3b7c49a46a5c2c9159ced89438b91dc935fd8fb7d05b71293b31082019917b8
+internal/activator/escrow.go ExecBackend.escrowConflictFound legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 2: new: the refusal for a divergent trio item: tries to write the host's conflict marker (writeEscrowMarker: EnsureDirBeneath <data>/.escrow 0700, a 0600 temp, rename, fsync), logs if it cannot, and returns the alert; the refusal holds either way, since every later publish finds the same divergence; only refuses; the agent as carlos (carlos-edge.service), no root caller registry:Host@144,registry:Host@186,registry:Host@355,registry:Host@756 907cc8d8310162c5367e385b40e1e1181249fb8c9dd1713b3f7d3fb1cf41bc47
internal/activator/escrow.go ExecBackend.escrowEligible legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: escrowEligibleAt on pathsFor's classification whole:Route@105,whole:Route@90 038966cd4221f6cbafe0eb80bdbf7ec69b54d36a34c0ea22a53746d2acac63fe
internal/activator/escrow.go ExecBackend.escrowEligibleAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: a pure predicate over the row and a classification: ActivatorManaged, not unit, sidecar, HA, replica, held, a valid host shape and app, flat or nested, on a box with a hibernate bucket; reads only row fields registry:App@295,registry:HA@163,registry:HoldOp@186,registry:Host@265,registry:Replica@172,registry:Status@221,registry:Unit@126,whole:Route@119 5df0c11ddde0ec351b062b87863396108d2fe48b7b4e390ca69daf377e0cac58
internal/activator/escrow.go ExecBackend.escrowEnvOf legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the sealed env item opened with hostfiles.ReadSealed under this box's key and the row's binding (sha256, v2 envelope, binding and MAC checked); found false when the manifest holds none; a failure wraps ErrEscrowNotReady registry:Host@389,whole:Route@230 dd6e1f3a3e8299303a3f9c2f89d2ec2f952dbdcb45264ac39484abc925b2e415
-internal/activator/escrow.go ExecBackend.escrowMintGuard legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: on a box that is not ready refuses every mint (ErrEscrowNotReady); otherwise, once and only when a producer would mint, bucketEscrowEnv, and refuses (ErrInstanceKeyDeferred) when the escrowed env holds the variable; a mint it allows is noted in memory; only refuses Fix round 0 (controller readiness ruling): with no files store it is nil, and the producer mints as before 3a; with a files store and no sealing key it reads the bucket manifest at the mint (keylessEscrowed, fresh) and refuses (ErrEscrowNotReady) when the bucket holds any sealed item or the cutover marker for the host, and otherwise lets the mint go ahead (logged once); only refuses. Fix round 1: with a key it refuses while the conflict marker exists or while this box does not hold the host's lease (ErrInstanceKeyDeferred); its bucket read is bucketManifest, the preparation's shared read unless fresh (the backfill); without a key its keyless read is the same, with no cache across launches (P1-3); only refuses. registry:Host@1512,registry:Host@683,registry:Host@756,whole:Route@1064,whole:Route@125,whole:Route@209,whole:Route@291,whole:Route@527,whole:Route@898 08e66d3bcef3ebc4186bef64c54aa16dda63ff76b73563f9f394522912e00883
+internal/activator/escrow.go ExecBackend.escrowMintGuard legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: on a box that is not ready refuses every mint (ErrEscrowNotReady); otherwise, once and only when a producer would mint, bucketEscrowEnv, and refuses (ErrInstanceKeyDeferred) when the escrowed env holds the variable; a mint it allows is noted in memory; only refuses Fix round 0 (controller readiness ruling): with no files store it is nil, and the producer mints as before 3a; with a files store and no sealing key it reads the bucket manifest at the mint (keylessEscrowed, fresh) and refuses (ErrEscrowNotReady) when the bucket holds any sealed item or the cutover marker for the host, and otherwise lets the mint go ahead (logged once); only refuses. Fix round 1: with a key it refuses while the conflict marker exists or while this box does not hold the host's lease (ErrInstanceKeyDeferred); its bucket read is bucketManifest, the preparation's shared read unless fresh (the backfill); without a key its keyless read is the same, with no cache across launches (P1-3); only refuses. Fix round 2: no longer notes the mints it allows in memory; only refuses. registry:Host@683,registry:Host@756,whole:Route@1064,whole:Route@125,whole:Route@209,whole:Route@291,whole:Route@527,whole:Route@898 5ba26a63e4d4f3944484f2a2257c1b43336f1ec9ed02cf56510558ccb685a310
internal/activator/escrow.go ExecBackend.escrowModeOf legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 0 (controller readiness ruling): new: escrowNoStore when FilesStore is nil, escrowNoKey when escrowReady fails, else escrowOn; reads nothing whole:Route@147 6bfaddec7936f24f6756c8c68547d6a7fa54dd0523db9024e2f71924a2e7ecee
internal/activator/escrow.go ExecBackend.escrowOff legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 0: new: one log line per host per process saying escrow is off and why; reads nothing registry:Host@309,registry:Host@87 6f3a552d5af240733241ea7befefa194706a70770e8bdc4f3c444ac48cf8f8c3
internal/activator/escrow.go ExecBackend.escrowReady legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: FilesStore and EscrowKey set and sealerFor succeeds; reads nothing whole:Route@165 fb7390d8f2ce1653619c3b365a3f804e5e1a0bb6f77210972a83453ebda42316
-internal/activator/escrow.go ExecBackend.escrowReread legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new, after a superseded publish: hostfiles.Open of the host's files manifest, and, when this box noted a mint, the sealed env (escrowEnvOf) and the local env file with instancefs.ReadBeneathLimitOrAbsent (1 MiB, no link followed) beneath the row's data directory, to refuse publishing over an escrowed secret of another value; the agent as carlos (carlos-edge.service), no root caller; only refuses Fix round 1: the conflict check is mintedConflict (on this card), which also persists the conflict marker. file:Open@284,registry:Host@122,registry:Host@332,registry:Host@520,whole:Route@193,whole:Route@639 5886155c4babdda278b730266aa59100c2ee9ce0e846de7e06364c0c2464bcb8
+internal/activator/escrow.go ExecBackend.escrowReread legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new, after a superseded publish: hostfiles.Open of the host's files manifest, and, when this box noted a mint, the sealed env (escrowEnvOf) and the local env file with instancefs.ReadBeneathLimitOrAbsent (1 MiB, no link followed) beneath the row's data directory, to refuse publishing over an escrowed secret of another value; the agent as carlos (carlos-edge.service), no root caller; only refuses Fix round 1: the conflict check is mintedConflict (on this card), which also persists the conflict marker. Fix round 2: only re-reads and installs the publisher; the conflict check is the next publish's write-once check. file:Open@284,registry:Host@122,registry:Host@332,registry:Host@520,whole:Route@193 9489f90533e27fa5f5b07bf4d020af586982554094b52ce10ce5d7ed17c6341a
internal/activator/escrow.go ExecBackend.escrowedLaunchEnv legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new, the launch path for an eligible host: captureLaunchEnv once, publishEscrowAt over those bytes, SealedAcknowledged on the commit, and the env parsed from the captured bytes; on a supersession escrowReread and the launch preparation again (ensureAdminTokenFor, ensureInstanceKeyFor) once; a not-ready box launches only a host its ledger shows escrowed; the agent as carlos (carlos-edge.service), no root caller Fix round 0 (controller readiness ruling): before the capture, the box's mode: no files store, instanceEnvLayer exactly as before 3a (logged once); no sealing key, a host whose ledger shows it escrowed launches on instanceEnvLayer (logged), otherwise keylessEscrowed (the answer this launch's restore read, within haSecretsBudget, else one GET) refuses when the bucket holds an escrow and launches on instanceEnvLayer when it holds none; nothing is published in either. Fix round 1: ends the launch's preparation; refuses while the conflict marker exists, and with a key while this box does not hold the host's lease; an ALERT from the publish fails the launch; the keyless decision uses the preparation's read. registry:Host@1039,registry:Host@1100,registry:Host@1182,registry:Host@1337,registry:Host@1422,registry:Host@145,registry:Host@1590,registry:Host@1792,registry:Host@2054,registry:Host@2215,registry:Host@238,registry:Host@2506,registry:Host@2627,registry:Host@2801,registry:Host@3017,registry:Host@635,registry:Host@764,registry:Host@809,registry:Host@912,whole:Route@1244,whole:Route@1470,whole:Route@1699,whole:Route@1957,whole:Route@205,whole:Route@2117,whole:Route@331,whole:Route@374,whole:Route@419,whole:Route@469,whole:Route@516,whole:Route@691,whole:Route@735,whole:Route@959 ef92b19f81ddce0d887b5fe94a6cfbac7f1a1196f55aa851875723cd2c5d15fb
internal/activator/escrow.go ExecBackend.haKnown legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the HA classification from memory only (haWakes, haLegacyRoute, the row's mark, the lifetime index); reads nothing registry:HA@185,registry:Host@274,registry:Host@95,whole:Route@151 4ecae90469fb6eda421464ca4509db7ddf4e5180180377867d3804b95bfd0c23
internal/activator/escrow.go ExecBackend.keylessEscrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix rounds 0-1: new, on a box with a files store and no sealing key: whether the bucket holds an escrow for the host (any sealed item or the cutover marker), from bucketManifest: the read of the launch preparation in progress, or one hostfiles.Load (one GET); nothing is cached across launches (fix round 1, P1-3); a failed read is an error and the caller refuses; the agent as carlos (carlos-edge.service), no root caller whole:Route@146 5a14a5881e81f9b401a1f8321659e75cc6165a5477db6cacc89b6c7f9e5bee08
-internal/activator/escrow.go ExecBackend.mintedConflict legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 1: new: when this box minted a secret since the host's env was last escrowed, opens the manifest's sealed env (escrowEnvOf) and reads the local env file with instancefs.ReadBeneathLimitOrAbsent (1 MiB, no link followed); an escrowed value that differs persists the conflict marker (writeEscrowConflict: EnsureDirBeneath .escrow 0700, a 0600 temp, rename, fsync) and refuses with an alert; only refuses; the agent as carlos (carlos-edge.service), no root caller registry:Host@1059,registry:Host@1365,registry:Host@146,registry:Host@471,registry:Host@901,registry:Host@943,whole:Route@356 354e9eff4a66adbdfa1fa1fe43b263e49a6297e8a482fcefea860faf7c2e8223
-internal/activator/escrow.go ExecBackend.openEscrowLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the host's publisher, from its ledger (readEscrowLedger: readCappedFile, O_NOFOLLOW, 32 MiB, under <data>/.escrow, the agent's own directory) with no request, else hostfiles.Open (one GET); the agent as carlos (carlos-edge.service), no root caller Fix round 1: marks the host checked when it reads the bucket; the same reads. file:Open@753,registry:Host@528,registry:Host@600,whole:Route@415 3968bf1d21f406133b0610deb45f9f188ebfd4cd4ab63cd966dd6831e7329b2b
+internal/activator/escrow.go ExecBackend.openEscrowLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the host's publisher, from its ledger (readEscrowLedger: readCappedFile, O_NOFOLLOW, 32 MiB, under <data>/.escrow, the agent's own directory) with no request, else hostfiles.Open (one GET); the agent as carlos (carlos-edge.service), no root caller Fix round 1: marks the host checked when it reads the bucket; the same reads. Fix round 2: the ledger is read through ledgerFor (none while this process marks it untrusted); the same reads. file:Open@737,registry:Host@528,registry:Host@584,whole:Route@415 363fb2c216bb47936cdeec099ba8c0ca64da23daeadd300a56427467d747e969
internal/activator/escrow.go ExecBackend.publishEscrow legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: publishEscrowAt on pathsFor whole:Route@149,whole:Route@164 e61757f12a116ef8bf819dcad7136f810c51dfa9f7104ceb7f810efece48cc29
internal/activator/escrow.go ExecBackend.publishEscrowAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: escrowReady and the layout checked, then publishEscrowLocked under the host's lock Fix round 1: refuses while the conflict marker exists or while this box does not hold the host's lease (P1-2), before anything is read. registry:Host@223,registry:Host@269,registry:Host@340,registry:Host@376,registry:Host@435,registry:Host@556,registry:Host@653,whole:Route@157,whole:Route@733 5e2b655605216fcaa50ddfd0511ca4ce913a8716582932a13debf22c4876f117
-internal/activator/escrow.go ExecBackend.publishEscrowLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: reads <host>.env (unless the launch's capture is handed in), <host>/instance.key and <host>/report.token with readStamped beneath the row's data directory, seals what changed (StageSealed), DropRawSecrets of the constant raw names, commits, and writes the ledger (writeEscrowLedger: EnsureDirBeneath .escrow 0700, a 0600 temp, rename, fsync); an absent file stages nothing; a refused file publishes nothing for it; the agent as carlos (carlos-edge.service), no root caller Fix round 1: before staging, mintedConflict on the baseline it would replace, so a secret this box minted is never published over another escrowed value (P1-1). registry:Host@2175,registry:Host@2439,registry:Host@3743,registry:Host@3891,registry:Host@589,whole:Route@2366,whole:Route@2803 b775999c5c991fc9183204b603df5487818122b618786c787377df877fcb82e5
-internal/activator/escrow.go ExecBackend.restoreEscrowIfMissing legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: checks each escrowed file with instancefs.OpenBeneathOrAbsent beneath the row's data directory; when one is absent, hostfiles.Open of the host's manifest, ReadSealed of each missing item, and writeIfAbsent (instancefs.WriteAtomic of a temp, then RenameBetweenNoReplace, so a present file is never replaced; EnsureDirBeneath for the files directory, 0700); on a box that is not ready it refuses unless the ledger shows the host escrowed and the env file is here; the agent as carlos (carlos-edge.service), no root caller Fix round 0 (controller readiness ruling): with no files store it does nothing (logged once); with no sealing key it restores nothing: a ledger here and an env file here go on, otherwise keylessEscrowed refuses when the bucket holds an escrow and goes on as before 3a when it holds none. Fix round 1: the conflict marker first, then the mode (P2-5): no files store, nothing; no key, the preparation's keyless read before any file check. With a key, each trio file is checked with OpenBeneathOrAbsent (a link or FIFO is not missing); the bucket is read (bucketManifest, the preparation's one GET) only for a missing env file, or a missing trio file the ledger says was escrowed, or with no ledger once per agent start (P2-6); the same writes. registry:Host@1083,registry:Host@1235,registry:Host@1344,registry:Host@138,registry:Host@2075,registry:Host@2943,registry:Host@571,registry:Host@652,registry:Host@698,registry:Host@801,whole:Route@1876,whole:Route@1972,whole:Route@200,whole:Route@241,whole:Route@314,whole:Route@360,whole:Route@477 191bfdc6676592a79262402b0c07b2d6effbabf61a952b7f72ab641b8f856d8c
+internal/activator/escrow.go ExecBackend.publishEscrowLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: reads <host>.env (unless the launch's capture is handed in), <host>/instance.key and <host>/report.token with readStamped beneath the row's data directory, seals what changed (StageSealed), DropRawSecrets of the constant raw names, commits, and writes the ledger (writeEscrowLedger: EnsureDirBeneath .escrow 0700, a 0600 temp, rename, fsync); an absent file stages nothing; a refused file publishes nothing for it; the agent as carlos (carlos-edge.service), no root caller Fix round 1: before staging, mintedConflict on the baseline it would replace, so a secret this box minted is never published over another escrowed value (P1-1). Fix round 2 (P1-1, P1-2, stale ledger): before staging, the write-once check (escrowDivergence, keyed digests only, no request): a staged instance.key or report.token whose escrowed item has another digest refuses the publish (escrowConflictFound); then, under the operation lock just before the commit, the lease again (holdsLease): lost, nothing is committed and the staged state is dropped; after a commit the ledger through keepLedger (written, else the stale one removed with RemoveBeneath under <data>/.escrow, else marked untrusted in memory). registry:Host@2078,registry:Host@2342,registry:Host@3787,registry:Host@3817,registry:Host@4329,registry:Host@574,whole:Route@2269,whole:Route@2863 bda6bd959efd0806cd0bd38ee0415ac0d28901c009d9e9ad7c92a7ffc91fe214
+internal/activator/escrow.go ExecBackend.restoreEscrowIfMissing legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: checks each escrowed file with instancefs.OpenBeneathOrAbsent beneath the row's data directory; when one is absent, hostfiles.Open of the host's manifest, ReadSealed of each missing item, and writeIfAbsent (instancefs.WriteAtomic of a temp, then RenameBetweenNoReplace, so a present file is never replaced; EnsureDirBeneath for the files directory, 0700); on a box that is not ready it refuses unless the ledger shows the host escrowed and the env file is here; the agent as carlos (carlos-edge.service), no root caller Fix round 0 (controller readiness ruling): with no files store it does nothing (logged once); with no sealing key it restores nothing: a ledger here and an env file here go on, otherwise keylessEscrowed refuses when the bucket holds an escrow and goes on as before 3a when it holds none. Fix round 1: the conflict marker first, then the mode (P2-5): no files store, nothing; no key, the preparation's keyless read before any file check. With a key, each trio file is checked with OpenBeneathOrAbsent (a link or FIFO is not missing); the bucket is read (bucketManifest, the preparation's one GET) only for a missing env file, or a missing trio file the ledger says was escrowed, or with no ledger once per agent start (P2-6); the same writes. Fix round 2: the ledger is read through ledgerFor, and while it is untrusted (its write and the stale ledger's removal both failed) a missing trio file always reads the bucket; the same reads and writes. registry:Host@1067,registry:Host@1219,registry:Host@1370,registry:Host@138,registry:Host@2112,registry:Host@2980,registry:Host@571,registry:Host@652,registry:Host@698,registry:Host@801,whole:Route@1913,whole:Route@200,whole:Route@2009,whole:Route@241,whole:Route@314,whole:Route@360,whole:Route@477 d559d3af9307a0391fd0e9353c1de1b083034a325493bcc3a214d22228ba4f9d
internal/activator/escrow.go ExecBackend.sweepPublish legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: publishEscrowAt, and on a supersession escrowReread and one more publish; a second one is the alert registry:Host@404,whole:Route@142,whole:Route@232,whole:Route@312 71bfee868a2ca8e3371cfc3c628b6ab5d8730ca48fcd099e7932049fe1e12a69
internal/activator/escrow.go Service.EscrowSweep legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the backend's EscrowSweep, nothing for a backend without one whole:Route@184 8ed0ea62a9807b7c43b3576d01f096bfe366c21bcc3be040831a3f1b80d1b123
internal/activator/escrow.go Service.SecretsEscrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the backend's SecretsEscrowed, else IsHA whole:Route@184,whole:Route@215 87261115297104155806136d4d0001c4cd3e150e5ffe91612bb5014fb7780881
@@ -129,7 +129,7 @@ internal/activator/paths.go ExecBackend.pathsFor legacy accepted-legacy accepted
@removed internal/activator/hasecrets.go SplitBackend.haScheduledToken H3 census-ruling-durability-3a-escrow;absent;basis=durability 3a Task 4: renamed to SplitBackend.escrowedScheduledToken (on this card)
@remove internal/host/schedule_wiring.go scheduleHostHA
@removed internal/host/schedule_wiring.go scheduleHostHA H3 census-ruling-durability-3a-escrow;absent;basis=durability 3a Task 4: renamed to scheduleHostEscrowed (on this card), asking SecretsEscrowed instead of IsHA
-@coverage internal/activator f84a595aa5224a9cb111c29099bb06cc637021c339487f9f5bb9ca0bf8887dd3
+@coverage internal/activator c3d6b4fa629fc9ce04c1247bf0c00e068375eae523e90cd61841b1e39705e52e
@coverage internal/host c12e11dd2fbfb5936e5256007db85a88f96cb12f3d1c74c551ff7ec5f52f9355
@coverage internal/hostfiles a0b0deb2779b183ee3f3578d1112ac5f723d930e40690a55eaaaa2644a24a9ad
@coverage internal/layout f845fa728b0935279454d8b01023c5d6dae1c985061a41229cf0686e829f5c12