durability 3a: escrow authority is the instance lease; conflicts persist; §9 budget
Task 4 fix round 1 (Astra review, controller rulings). - P1-2 and P1-1, authority. A box publishes a host's escrow, at a launch or in the sweep, and mints its secrets, only while it holds the host's instance lease: Acquire records the lease it hands out, and holdsLease asks whichever handle owns it now (the held lease, or the replicator it was handed to). The sweep skips every other host, so a stale box never replaces the escrow with its local bytes. A secret this box minted that the escrow holds with another value (checked before every publish and after a supersession) refuses the launch with an alert and persists <data>/.escrow/<host>.conflict; every later launch, mint and publish of the host, restart or not, is refused until an operator removes it. - P1-3. Keyless evidence is one preparation's (escrowPrep, begun by ensureAdminTokenFor and ended by escrowedLaunchEnv); the 30 s per-host cache is gone, and every launch reads fresh. - P1-4. The sweep copies stamp contents under the lock and tallies its report through one lock. - P2-5. The mode decides before any escrow-specific file check; a trio path that cannot be checked is not missing. - P2-6, §9. A missing trio file reads the bucket only when the ledger says it was escrowed (with no ledger, once per agent start); a missing env file and a mint read it once per preparation, shared by the restore and both producers. An unchanged wake makes no request; a first mint makes one GET. The rootfs fixtures go back to no files store (the pre-3a path): they launch without a lease. Census claims updated and the proposal re-run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/notes/census-durability-3a-escrow-claims.md+19 −15docs/superpowers/notes/census-proposal-durability-3a-escrow.md+19 −14internal/activator/backend_exec.go+32 −0internal/activator/escrow.go+426 −183internal/activator/escrow_linux_test.go+35 −0internal/activator/escrow_test.go+271 −34internal/activator/hasecrets.go+19 −8internal/activator/instancekey.go+5 −2internal/activator/rootfs_ctl_harness_test.go+1 −4internal/activator/rootfs_test.go+5 −5internal/host/schedule_wiring_test.go+17 −3internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv+41 −33
Intent
<task-notification> <task-id>a3ce1b31a8618f132</task-id> <tool-use-id>toolu_014VN3xt8ztXHABBpgf4cwdW</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. I applied the controller's readiness ruling (concern 3). Commits on durability-3a-escrow, not pushed: - 4a897404: the escrow. - 50601478: readiness now splits three ways. With a key and a files store, everything is as built. With a store and no usable key, an escrow in the bucket refuses restore, mint and a first launch; with no escrow there, the host launches and mints as before 3a, publishes nothing, and logs once. With no files store, it behaves as before 3a. Scheduled ticks stay read-only in every case. Tests: three witnesses go through the real Service wake: the keyless box with an escrow (refused, nothing minted, no launch), the keyless box with no escrow (mints, launches, publishes nothing, one GET on the next wake), and no files store (launches as before). Both new witnesses failed against 4a897404. The host suite, census and cross-builds pass, and the census shows no unclaimed units. Concerns: - One activator failure in the full run, `TestReleaseLeaseLossUnprovenLeavesTheHold`: a retry began 190 µs past its deadline under full-suite load. It is a timing check outside the escrow, and it passed 10 of 10 on its own. - Concern 1 (several boxes hold one host, and the last stale publisher wins): not built. The window closes at each host's next wake. The small rule only turns "last wins" into "first wins". The real fix (the first escrow goes to the box that holds or last held the lease) needs the lease lock, so I recommend it as a follow-up. - Concern 2 (a GET on most launches): I judge it acceptable. It is one manifest read per wake, not a poll, and skipping it would use the ledger as recovery evidence. If you want "1 GET before a first mint" exactly, a launch's guards can reuse its own restore's read; that is a one-place change. 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>527211</subagent_tokens><tool_uses>153</tool_uses><duration_ms>4286101</duration_ms></usage> </task-notification>
<task-notification> <task-id>b6a9m1ud0</task-id> <tool-use-id>toolu_014jPEdb8HEdxvpayxgFSBXo</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/953e7524-2e06-4308-b9ce-fd1b38579971/tasks/b6a9m1ud0.output</output-file> <status>completed</status> <summary>Background command "Wait for Astra's Task 4 review" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 23.1 g CO₂e (2,937,312 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 e9410ef1f..c1f4cc80c 100644 |
| --- a/docs/superpowers/notes/census-durability-3a-escrow-claims.md |
| +++ b/docs/superpowers/notes/census-durability-3a-escrow-claims.md |
| @@ -17,16 +17,16 @@ internal/activator/admintoken.go:ensureAdminToken durability 3a Task 4: the guar |
| internal/activator/claim_snapshot.go:ExecBackend.EnsureClaimAdminToken durability 3a Task 4: a comment names mintGuardFor instead of haMintGuard; the body is unchanged |
| internal/activator/hasecrets.go:Service.fillScheduledToken durability 3a Task 4: asks escrowedScheduledToken (was haScheduledToken), so an escrowed host (HA, or eligible for escrow) gets its tick's Authorization header from the env file its wake restored or minted; any other host's request is untouched; the same one site |
| internal/activator/instancekey.go:ExecBackend.BackfillInstanceKey durability 3a Task 4: comment only (the escrowed host's mint decision inside ensureInstanceKeyAt); the body is unchanged |
| -internal/activator/instancekey.go:ExecBackend.ensureInstanceKeyAt durability 3a Task 4: asks mintGuardFor(ctx, rt) (was haMintGuard): an HA host's guard as before; an eligible host's escrowMintGuard, which on a ready box reads the bucket manifest and the sealed env item when a mint is next and refuses while the escrow holds the key, and on a box that is not ready refuses every mint; nil for any other host, which mints as before. The replica and fenced/conflict refusals are unchanged; only adds refusals |
| +internal/activator/instancekey.go:ExecBackend.ensureInstanceKeyAt durability 3a Task 4: asks mintGuardFor(ctx, rt) (was haMintGuard): an HA host's guard as before; an eligible host's escrowMintGuard, which on a ready box reads the bucket manifest and the sealed env item when a mint is next and refuses while the escrow holds the key, and on a box that is not ready refuses every mint; nil for any other host, which mints as before. The replica and fenced/conflict refusals are unchanged; only adds refusals Fix round 1: asks mintGuardWith(ctx, rt, !create): a launch's ensure shares its preparation's escrow read, the backfill's reads the bucket afresh; only refuses. |
| internal/activator/instancekey.go:ensureInstanceKey durability 3a Task 4: the guard is asked with InstanceKeyVar, at the same point (the locked read found no key and the bucket allowed a mint); create-only, fail-closed and defer-on-unknown unchanged; the same one site; only adds a refusal |
| internal/activator/hasecrets.go:ExecBackend.captureLaunchEnv durability 3a Task 4: the flat arm's os.ReadFile (-file:ReadFile) is gone: both layouts read the own env file and the rendered config env with instancefs.ReadBeneathLimit beneath the row's data directory (openat2, no symlink, regular files only, 1 MiB), so an escrowed flat row's capture never follows a link at <host>.env; an absent own file is an error, an absent config is not; the agent as carlos (carlos-edge.service), no root caller; only narrows a read |
| -internal/activator/hasecrets.go:ExecBackend.ensureAdminTokenFor durability 3a Task 4: classifies the host once (haHostNow), and for a host that is not HA and is eligible for escrow first calls restoreEscrowIfMissing (a new unit on this card), then ensureAdminToken with mintGuardAs's guard; an HA host's path is as before; any other host's guard is nil as before; +whole:Route x3 (the row handed on); the agent as carlos (carlos-edge.service), no root caller |
| +internal/activator/hasecrets.go:ExecBackend.ensureAdminTokenFor durability 3a Task 4: classifies the host once (haHostNow), and for a host that is not HA and is eligible for escrow first calls restoreEscrowIfMissing (a new unit on this card), then ensureAdminToken with mintGuardAs's guard; an HA host's path is as before; any other host's guard is nil as before; +whole:Route x3 (the row handed on); the agent as carlos (carlos-edge.service), no root caller Fix round 1: begins the launch's preparation (beginPrep) before the restore, and passes fresh false to the guard. |
| internal/activator/hasecrets.go:ExecBackend.haMintGuard durability 3a Task 4: now only the HA arm of mintGuardFor: the same once-per-guard haManifestFound read and the same ErrInstanceKeyDeferred refusal, the name ignored; the HA classification moved to mintGuardFor (-whole:Route); only refuses |
| internal/activator/hasecrets.go:ExecBackend.launchEnvLayer durability 3a Task 4: for a host that is not HA and is eligible for escrow, escrowedLaunchEnv (a new unit on this card) instead of instanceEnvLayer; the HA and other paths unchanged; +whole:Route x2; the agent as carlos (carlos-edge.service), no root caller |
| internal/activator/paths.go:ExecBackend.pathsFor durability 3a Task 4: split in two: pathsFor classifies (Classify, unchanged) and hands the answer to pathsAt (new on this card), which holds the same body; the same paths for every row; the reads moved to pathsAt whole |
| internal/activator/paths.go:ExecBackend.pathsAt durability 3a Task 4: pathsFor's former body, unchanged, taking a classification already made (the escrow sweep classifies every row against the one list it was handed); reads +registry:DBPath, +registry:Host x7 exactly as pathsFor did |
| -internal/activator/hasecrets.go:ExecBackend.mintGuardFor durability 3a Task 4: new: the one mint decision, replacing haMintGuard as the entry point: classifies the host (haHostNow; an error refuses) and returns mintGuardAs; the agent as carlos (carlos-edge.service), no root caller; only refuses |
| -internal/activator/hasecrets.go:ExecBackend.mintGuardAs durability 3a Task 4: new: an HA host's haMintGuard, an eligible host's escrowMintGuard, else nil; reads nothing itself; only refuses |
| +internal/activator/hasecrets.go:ExecBackend.mintGuardFor durability 3a Task 4: new: the one mint decision, replacing haMintGuard as the entry point: classifies the host (haHostNow; an error refuses) and returns mintGuardAs; the agent as carlos (carlos-edge.service), no root caller; only refuses Fix round 1: mintGuardWith(ctx, rt, false); the classification moved there. |
| +internal/activator/hasecrets.go:ExecBackend.mintGuardAs durability 3a Task 4: new: an HA host's haMintGuard, an eligible host's escrowMintGuard, else nil; reads nothing itself; only refuses Fix round 1: passes fresh to escrowMintGuard (shared preparation read, or the bucket afresh). |
| internal/activator/hasecrets.go:ExecBackend.escrowedScheduledToken durability 3a Task 4: renamed from haScheduledToken and widened to escrowed hosts (SecretsEscrowed): reads CARLOS_ADMIN_TOKEN from the host's env file with instancefs.ReadBeneathLimit (1 MiB, no link followed) after the wake; a host that is not escrowed reads nothing; the token is sent only to that same instance's tick; the agent as carlos (carlos-edge.service), no root caller |
| internal/activator/hasecrets.go:SplitBackend.escrowedScheduledToken durability 3a Task 4: renamed from haScheduledToken: dispatches to the row's half, else not escrowed |
| internal/activator/hasecrets.go:ExecBackend.haScheduledToken durability 3a Task 4: renamed to escrowedScheduledToken (on this card), the same read for HA hosts |
| @@ -34,23 +34,22 @@ internal/activator/hasecrets.go:SplitBackend.haScheduledToken durability 3a Task |
| internal/host/schedule_wiring.go:scheduleHostHA durability 3a Task 4: renamed to scheduleHostEscrowed (on this card), asking SecretsEscrowed instead of IsHA |
| internal/host/schedule_wiring.go:scheduleHostEscrowed durability 3a Task 4: scheduleHostHA renamed: reads the host's row (reg.Get) and asks svc.SecretsEscrowed (HA, or eligible for escrow) with a 10 s timeout; false with no registry or no row; for such a host scheduleToken only reads the existing env token ("" when none) and never mints (EnsureAdminToken skipped); the agent as carlos (carlos-edge.service), no root caller |
| internal/host/escrow_loop.go:escrowLoop durability 3a Task 4: new: every activator.EscrowEvery (30 s) lists the registry and runs svc.EscrowSweep over the rows; logs failures and deferrals; returns with no registry or no Service; the agent as carlos (carlos-edge.service), no root caller |
| -internal/activator/escrow.go:ExecBackend.EscrowSweep durability 3a Task 4: new, the agent as carlos (carlos-edge.service), no root caller, from escrowLoop: classifies each row against the rows handed in (Classify), keeps eligible rows known not HA from memory (haKnown, no read), and in host order from a round-robin cursor stats each escrowed file (stampAt) and publishes the changed ones, 8 at a time, at most 256 a sweep (sweepPublish); a box without a files store or key does nothing; opens nothing outside the rows' own data directories; writes only the hibernate bucket's files/0 prefix and the ledger |
| +internal/activator/escrow.go:ExecBackend.EscrowSweep durability 3a Task 4: new, the agent as carlos (carlos-edge.service), no root caller, from escrowLoop: classifies each row against the rows handed in (Classify), keeps eligible rows known not HA from memory (haKnown, no read), and in host order from a round-robin cursor stats each escrowed file (stampAt) and publishes the changed ones, 8 at a time, at most 256 a sweep (sweepPublish); a box without a files store or key does nothing; opens nothing outside the rows' own data directories; writes only the hibernate bucket's files/0 prefix and the ledger Fix round 1: a host whose instance lease this box does not hold (holdsLease) is skipped, and one with a conflict marker counts as failing and is not published; the report is tallied through one lock (P1-4). |
| internal/activator/escrow.go:ExecBackend.SecretsEscrowed durability 3a Task 4: new: haHostNow or escrowEligible; reads only what the HA classification already reads |
| -internal/activator/escrow.go:ExecBackend.bucketEscrowEnv durability 3a Task 4: new: one hostfiles.Load of the host's files manifest in the hibernate bucket, then escrowEnvOf; the agent as carlos (carlos-edge.service), no root caller |
| internal/activator/escrow.go:ExecBackend.escrowEnvOf 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 |
| -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 |
| +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. |
| +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.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 |
| -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. |
| +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.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 |
| +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.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 |
| -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 |
| -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. |
| +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.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 |
| @@ -60,4 +59,9 @@ internal/activator/escrow.go:readStamped durability 3a Task 4: new: instancefs.O |
| internal/activator/escrow.go:stampAt durability 3a Task 4: new: the same open as readStamped and its fstat; reads no bytes |
| internal/activator/escrow.go:ExecBackend.escrowModeOf durability 3a Task 4 fix round 0 (controller readiness ruling): new: escrowNoStore when FilesStore is nil, escrowNoKey when escrowReady fails, else escrowOn; reads nothing |
| internal/activator/escrow.go:ExecBackend.escrowOff durability 3a Task 4 fix round 0: new: one log line per host per process saying escrow is off and why; reads nothing |
| -internal/activator/escrow.go:ExecBackend.keylessEscrowed durability 3a Task 4 fix round 0: new, on a box with a files store and no sealing key: hostfiles.Load of the host's files manifest in the hibernate bucket (one GET), true when it holds any sealed item or the cutover marker (manifestEscrowed); the answer is kept in memory and reused within haSecretsBudget only for refusals and launches, a mint reads again; a failed read is an error and the caller refuses; the agent as carlos (carlos-edge.service), no root caller |
| +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/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 |
diff --git a/docs/superpowers/notes/census-proposal-durability-3a-escrow.md b/docs/superpowers/notes/census-proposal-durability-3a-escrow.md| index ff26ba38e..e5bb04c6a 100644 |
| --- a/docs/superpowers/notes/census-proposal-durability-3a-escrow.md |
| +++ b/docs/superpowers/notes/census-proposal-durability-3a-escrow.md |
| @@ -1,6 +1,6 @@ |
| # Census approval: durability-3a-escrow |
| -Ruling `census-ruling-durability-3a-escrow`. The independent reviewer approves or rejects every change below, 38 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| +Ruling `census-ruling-durability-3a-escrow`. The independent reviewer approves or rejects every change below, 41 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| | unit | change | read sites | what changed | |
| |---|---|---|---| |
| @@ -8,16 +8,17 @@ Ruling `census-ruling-durability-3a-escrow`. The independent reviewer approves o |
| | `internal/activator/claim_snapshot.go` `ExecBackend.EnsureClaimAdminToken` | body | unchanged (9) | durability 3a Task 4: a comment names mintGuardFor instead of haMintGuard; the body is unchanged | |
| | `internal/activator/hasecrets.go` `Service.fillScheduledToken` | body | unchanged (1) | durability 3a Task 4: asks escrowedScheduledToken (was haScheduledToken), so an escrowed host (HA, or eligible for escrow) gets its tick's Authorization header from the env file its wake restored or minted; any other host's request is untouched; the same one site | |
| | `internal/activator/instancekey.go` `ExecBackend.BackfillInstanceKey` | body | unchanged (2) | durability 3a Task 4: comment only (the escrowed host's mint decision inside ensureInstanceKeyAt); the body is unchanged | |
| -| `internal/activator/instancekey.go` `ExecBackend.ensureInstanceKeyAt` | body | unchanged (4) | durability 3a Task 4: asks mintGuardFor(ctx, rt) (was haMintGuard): an HA host's guard as before; an eligible host's escrowMintGuard, which on a ready box reads the bucket manifest and the sealed env item when a mint is next and refuses while the escrow holds the key, and on a box that is not ready refuses every mint; nil for any other host, which mints as before. The replica and fenced/conflict refusals are unchanged; only adds refusals | |
| +| `internal/activator/instancekey.go` `ExecBackend.ensureInstanceKeyAt` | body | unchanged (4) | durability 3a Task 4: asks mintGuardFor(ctx, rt) (was haMintGuard): an HA host's guard as before; an eligible host's escrowMintGuard, which on a ready box reads the bucket manifest and the sealed env item when a mint is next and refuses while the escrow holds the key, and on a box that is not ready refuses every mint; nil for any other host, which mints as before. The replica and fenced/conflict refusals are unchanged; only adds refusals Fix round 1: asks mintGuardWith(ctx, rt, !create): a launch's ensure shares its preparation's escrow read, the backfill's reads the bucket afresh; only refuses. | |
| | `internal/activator/instancekey.go` `ensureInstanceKey` | body | unchanged (1) | durability 3a Task 4: the guard is asked with InstanceKeyVar, at the same point (the locked read found no key and the bucket allowed a mint); create-only, fail-closed and defer-on-unknown unchanged; the same one site; only adds a refusal | |
| | `internal/host/agent.go` `runAgent` | body | unchanged (6) | durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. | |
| | `internal/hostfiles/restore.go` `Restore` | body | unchanged (1) | durability 3a Task 3 fix round 1: passes nil for restore's new shadowed argument, so it fetches, writes and removes exactly what it did; the same reads. restore gains that argument (a caller's Shadowed func over the manifest it has already read and validated): a live entry it names, after the overlap rule, is skipped before any fetch and reported in RestoreStats.Shadowed. It only leaves things out; nothing new is opened, read or followed. RestoreRootBaselineShadowed is new, RestoreRootBaseline is it with nil. | |
| +| `internal/activator/backend_exec.go` `ExecBackend.Acquire` | sites | +registry:Host | 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/hafiles.go` `ExecBackend.newHostFiles` | sites | +registry:Host, +whole:Route | durability 3a Task 3: now also sets the publisher's sealer (sealerFor(rt); its error is returned and nothing is built) and its skip, pubclass.FilesDirSkip(Nested, rt.Host), a pure function of the name, so every tree pass publishes only App paths and never the trio raw. Still no I/O; the new +registry:Host and +whole:Route sites are the sealer's and the classifier's arguments. | |
| | `internal/activator/hafiles.go` `ExecBackend.openHostFiles` | sites | +whole:Route | durability 3a Task 3: asks sealerFor before hostfiles.Open, so a box without an escrow key refuses before it reads the manifest; newHostFiles's error is returned. The same manifest GET otherwise; the new +whole:Route site is sealerFor's argument. Opens nothing new. | |
| | `internal/activator/hafiles.go` `ExecBackend.stageKeptFiles` | sites | +registry:Host | durability 3a Task 3: newHostFiles now answers an error (no escrow key), which is logged and stages nothing, as an OpenBaseline failure already did. The same baseline read; nothing new opened or read. | |
| | `internal/activator/hafiles.go` `ExecBackend.stageWakeFiles` | sites | +registry:Host | durability 3a Task 3: newHostFiles now answers an error (no escrow key), which is logged and stages nothing, as an OpenBaseline failure already did. No read, as before. | |
| | `internal/activator/hasecrets.go` `ExecBackend.captureLaunchEnv` | sites | -file:ReadFile | durability 3a Task 4: the flat arm's os.ReadFile (-file:ReadFile) is gone: both layouts read the own env file and the rendered config env with instancefs.ReadBeneathLimit beneath the row's data directory (openat2, no symlink, regular files only, 1 MiB), so an escrowed flat row's capture never follows a link at <host>.env; an absent own file is an error, an absent config is not; the agent as carlos (carlos-edge.service), no root caller; only narrows a read | |
| -| `internal/activator/hasecrets.go` `ExecBackend.ensureAdminTokenFor` | sites | +whole:Route ×3 | durability 3a Task 4: classifies the host once (haHostNow), and for a host that is not HA and is eligible for escrow first calls restoreEscrowIfMissing (a new unit on this card), then ensureAdminToken with mintGuardAs's guard; an HA host's path is as before; any other host's guard is nil as before; +whole:Route x3 (the row handed on); the agent as carlos (carlos-edge.service), no root caller | |
| +| `internal/activator/hasecrets.go` `ExecBackend.ensureAdminTokenFor` | sites | +registry:Host, +whole:Route ×3 | durability 3a Task 4: classifies the host once (haHostNow), and for a host that is not HA and is eligible for escrow first calls restoreEscrowIfMissing (a new unit on this card), then ensureAdminToken with mintGuardAs's guard; an HA host's path is as before; any other host's guard is nil as before; +whole:Route x3 (the row handed on); the agent as carlos (carlos-edge.service), no root caller Fix round 1: begins the launch's preparation (beginPrep) before the restore, and passes fresh false to the guard. | |
| | `internal/activator/hasecrets.go` `ExecBackend.haMintGuard` | sites | -whole:Route | durability 3a Task 4: now only the HA arm of mintGuardFor: the same once-per-guard haManifestFound read and the same ErrInstanceKeyDeferred refusal, the name ignored; the HA classification moved to mintGuardFor (-whole:Route); only refuses | |
| | `internal/activator/hasecrets.go` `ExecBackend.haSecretsReady` | sites | +whole:Route | durability 3a Task 3: asks sealerFor before its own hostfiles.Open (a box without an escrow key fails the launch before any read), and newHostFiles's error fails the launch. envAcknowledged now compares the sealed env item's keyed digest (hostfiles.SealedAcknowledged, no read) instead of the raw env item's SHA-256. The publish it triggers stages the trio sealed: <host>.env, <host>/instance.key and <host>/report.token are each read with instancefs.ReadBeneathLimitOrAbsent beneath the instance directory (openat2, no symlink, regular files only, 1 MiB cap), the same reader the env already used, then sealed in memory; nothing else is opened. | |
| | `internal/activator/hasecrets.go` `ExecBackend.launchEnvLayer` | sites | +whole:Route ×2 | durability 3a Task 4: for a host that is not HA and is eligible for escrow, escrowedLaunchEnv (a new unit on this card) instead of instanceEnvLayer; the HA and other paths unchanged; +whole:Route x2; the agent as carlos (carlos-edge.service), no root caller | |
| @@ -48,6 +49,7 @@ Recorded dispositions, which each change must still satisfy: |
| - `internal/activator/instancekey.go` `ensureInstanceKey`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more parameter, guard (nil for every caller but ensureInstanceKeyAt on an HA host), asked once the locked read finds no key and the bucket allows a mint, before anything is minted; its refusal returns InstanceKeyFailed with nothing written. Create-only, fail-closed and defer-on-unknown are unchanged; the one site unchanged, no read added; only adds a refusal |
| - `internal/host/agent.go` `runAgent`: authority, task B,C,D,F. Basis: rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added |
| - `internal/hostfiles/restore.go` `Restore`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=merge-ruling-2;basis=Restore delegates to shared descriptor-root implementation; generic payload restoration remains legacy.;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: passes nil for restore's new baseline argument; the one site unchanged, nothing else changed |
| +- `internal/activator/backend_exec.go` `ExecBackend.Acquire`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: after the unchanged AdmitConfig gate, the lease acquire moves into acquireClassified (hawake.go, a new unit): a legacy route or a non-HA host takes the same lease.Acquire as before and maps a held lease to errLeaseHeld as before (leaseError); an HA host goes through the containment admission and lease.AcquireHA. A successful acquire marks the host acquiredHere for the process (same-box recovery). The config gate is not weakened; the same three sites, no read added |
| - `internal/activator/hafiles.go` `ExecBackend.newHostFiles`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: builds a hostFiles publisher for rt (its instance paths from pathsFor(rt), rt.Host, the backend's registry, the 1 s platform and 15 min snapshot cadences); +registry:Host, +whole:Route; no I/O |
| - `internal/activator/hafiles.go` `ExecBackend.openHostFiles`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: the entry's files publisher: refuses without a FilesStore or outside the nested layout, takes the one this wake's restore staged, else hostfiles.Open on <hibernate prefix>/files/0/ (one GET of the manifest from the hibernate bucket, the scanner's +file:Open); +registry:Host x2, +whole:Route x2; the manifest is written by the agents of the boxes that hold the host, through the same files store |
| - `internal/activator/hafiles.go` `ExecBackend.stageKeptFiles`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: on a kept wake, reads the manifest baseline the release kept beside its local record (<db>.release.files.json via readFilesBaseline, capped at 32 MiB, O_NOFOLLOW, regular files only) and stages a publisher on it only when its revision (Gen, which carries the body's SHA-256) equals the files_gen in the lock's release marker; the file is on ground the tenant can write, and anything that does not match stages nothing, so the entry re-reads the manifest from the store; it never decides the keep; +registry:Host x4, +whole:Route x2 |
| @@ -62,26 +64,28 @@ Recorded dispositions, which each change must still satisfy: |
| New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| -- new `internal/activator/escrow.go:ExecBackend.EscrowSweep`: reads +registry:Host ×9, +whole:Route ×17; written legacy, accepted-legacy, frozen |
| +- new `internal/activator/escrow.go:ExecBackend.EscrowSweep`: reads +registry:Host ×12, +whole:Route ×17; written legacy, accepted-legacy, frozen |
| - new `internal/activator/escrow.go:ExecBackend.SecretsEscrowed`: reads +whole:Route ×2; written legacy, accepted-legacy, frozen |
| -- new `internal/activator/escrow.go:ExecBackend.bucketEscrowEnv`: reads +registry:Host, +whole:Route; written legacy, accepted-legacy, frozen |
| +- 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.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, +whole:Route ×5; 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.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 ×5, +whole:Route ×2; written legacy, accepted-legacy, frozen |
| -- new `internal/activator/escrow.go:ExecBackend.escrowedLaunchEnv`: reads +registry:Host ×15, +whole:Route ×14; 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.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 +registry:Host ×2; 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 ×3, +whole:Route ×2; written legacy, accepted-legacy, frozen |
| -- new `internal/activator/escrow.go:ExecBackend.publishEscrowLocked`: reads +registry:Host ×5, +whole:Route; written legacy, accepted-legacy, frozen |
| -- new `internal/activator/escrow.go:ExecBackend.restoreEscrowIfMissing`: reads +file:Open, +registry:Host ×7, +whole:Route ×6; 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.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 |
| - new `internal/activator/escrow.go:Service.SecretsEscrowed`: reads +whole:Route ×2; written legacy, accepted-legacy, frozen |
| @@ -92,7 +96,8 @@ New dispositions, which census-propose wrote and the reviewer checks against the |
| - new `internal/activator/hafiles.go:ExecBackend.sealerFor`: reads +registry:App, +registry:Host, +whole:Route; written legacy, accepted-legacy, frozen |
| - new `internal/activator/hasecrets.go:ExecBackend.escrowedScheduledToken`: reads +whole:Route ×2; written legacy, accepted-legacy, frozen |
| - new `internal/activator/hasecrets.go:ExecBackend.mintGuardAs`: reads +whole:Route ×3; written legacy, accepted-legacy, frozen |
| -- new `internal/activator/hasecrets.go:ExecBackend.mintGuardFor`: reads +whole:Route ×2; written legacy, accepted-legacy, frozen |
| +- new `internal/activator/hasecrets.go:ExecBackend.mintGuardFor`: reads +whole:Route; written legacy, accepted-legacy, frozen |
| +- new `internal/activator/hasecrets.go:ExecBackend.mintGuardWith`: reads +whole:Route ×2; written legacy, accepted-legacy, frozen |
| - new `internal/activator/hasecrets.go:SplitBackend.escrowedScheduledToken`: reads +whole:Route ×2; written legacy, accepted-legacy, frozen |
| - new `internal/activator/paths.go:ExecBackend.pathsAt`: reads +registry:DBPath, +registry:Host ×7; written legacy, accepted-legacy, frozen |
| - new `internal/host/escrow_loop.go:escrowLoop`: reads +whole:Route; written legacy, accepted-legacy, frozen |
| @@ -101,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` → `c82fb613f735563c494d3ceb11cf6fc377f1a4b28562d71ebb0b7b128d53b422`. |
| +Seal: `eaeb153ab7a7a849edc9c6e92f2ac5c709c6e39044a647971cf1fa5ebcb660c8` → `d6c281d7e095e8e0625c6199044d67dc0da559e7b4af5fbdc1a4e032bfbb65dc`. |
| 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/backend_exec.go b/internal/activator/backend_exec.go| index 1e7a3c4ae..52da08b0d 100644 |
| --- a/internal/activator/backend_exec.go |
| +++ b/internal/activator/backend_exec.go |
| @@ -20,6 +20,7 @@ import ( |
| "sort" |
| "strings" |
| "sync" |
| + "sync/atomic" |
| "syscall" |
| "time" |
| @@ -784,6 +785,11 @@ func (b *ExecBackend) Acquire(ctx context.Context, rt registry.Route) (Lease, er |
| l, err := b.acquireClassified(ctx, rt) |
| if err == nil { |
| markAcquiredHere(b, rt.Host) |
| + // The escrow's authority (escrow.go): only the box holding the |
| + // host's lease publishes its escrow or mints its secrets. |
| + if el, ok := l.(*execLease); ok { |
| + b.escrow.noteLease(rt.Host, el) |
| + } |
| } |
| return l, err |
| } |
| @@ -806,6 +812,9 @@ func (b *ExecBackend) AdmitConfig(ctx context.Context, rt registry.Route) error |
| type execLease struct { |
| held *lease.Held |
| defaultDB string // used when the route carries no DBPath |
| + // rep is the replicator the lease was handed to (Replicate), which |
| + // owns it from then on: the escrow's lease check asks it (escrow.go). |
| + rep atomic.Pointer[lease.Replicator] |
| } |
| func (l *execLease) Replicate(ctx context.Context, dbPath string, syncInterval time.Duration) (Rep, error) { |
| @@ -816,9 +825,32 @@ func (l *execLease) Replicate(ctx context.Context, dbPath string, syncInterval t |
| if err != nil { |
| return nil, err |
| } |
| + l.rep.Store(rep) |
| return rep, nil |
| } |
| +// heldNow reports whether this lease is held now, by whichever handle owns |
| +// it: the replicator once Replicate handed it over, else the held lease. |
| +// Neither released, lost nor past its safety deadline; no request. |
| +func (l *execLease) heldNow() bool { |
| + var ( |
| + until time.Time |
| + err error |
| + ) |
| + if r := l.rep.Load(); r != nil { |
| + if err = r.Err(); err == nil { |
| + until, err = r.SafeUntil() |
| + } |
| + } else if l.held != nil { |
| + if err = l.held.Err(); err == nil { |
| + until, err = l.held.SafeUntil() |
| + } |
| + } else { |
| + return false |
| + } |
| + return err == nil && time.Now().Before(until) |
| +} |
| + |
| // The Rep execLease.Replicate hands back is lease.Held's *lease.Replicator, |
| // and SeedPlaced records a seed placed only through its SyncAndWait. Pinned |
| // here so a change to either fails the build, not every seeded wake. |
diff --git a/internal/activator/escrow.go b/internal/activator/escrow.go| index dfe058949..56d239a29 100644 |
| --- a/internal/activator/escrow.go |
| +++ b/internal/activator/escrow.go |
| @@ -31,19 +31,31 @@ import ( |
| // of minting new secrets. |
| // |
| // - Eligible is not ready. A host is eligible from its row and the box's |
| -// layout facts alone (escrowEligible). The box is ready when it has a |
| -// files store and a sealing key (escrowReady); readiness splits three |
| -// ways (escrowModeOf, the controller's ruling of 2026-10-31). With |
| -// both, everything below. With a files store and no key, the bucket is |
| -// read: an escrow there (any sealed item) means no restore, no mint |
| -// and no first launch; none there, and the host launches and mints as |
| -// before 3a, with nothing published. With no files store, as before |
| -// 3a. An eligible host's scheduled ticks only read, in every case. |
| +// layout facts alone (escrowEligible). Readiness splits three ways |
| +// (escrowModeOf, the controller's ruling of 2026-10-31). With a files |
| +// store and a sealing key, everything below. With a files store and no |
| +// key, the bucket is read: an escrow there (any sealed item) means no |
| +// restore, no mint and no first launch; none there, and the host |
| +// launches and mints as before 3a, with nothing published. With no |
| +// files store, as before 3a. An eligible host's scheduled ticks only |
| +// read, in every case. |
| +// - Authority is the host's instance lease (fix round 1, P1-1 and P1-2): |
| +// a box publishes a host's escrow, at a launch or in the sweep, and |
| +// mints its secrets, only while it holds that lease, the one its wake |
| +// acquired (Acquire records it). A box that does not serve the host |
| +// never replaces its escrow with its own local bytes. |
| // - The ledger (<data>/.escrow/<host>.json, the last committed manifest) |
| -// is a publication baseline only: it keeps an unchanged sweep at zero |
| -// requests across restarts. Before a missing file is restored, and |
| -// before a mint, the bucket is read. A publish that meets another |
| -// writer reads the bucket again and decides again, once. |
| +// is a publication baseline, never recovery or mint evidence, except |
| +// that a trio file absent here is looked for in the bucket only when |
| +// the ledger says it was escrowed (or, with no ledger, on the host's |
| +// first restore since the agent started): a file that never existed |
| +// 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. |
| // - A launch reads the env once (captureLaunchEnv), publishes and |
| // acknowledges exactly those bytes, and launches with the env parsed |
| // from them. |
| @@ -56,6 +68,10 @@ import ( |
| // one whose escrow does not open with this box's key. |
| var ErrEscrowNotReady = errors.New("activator: this box cannot read or write the instance's sealed copy (no files store or no CARLOS_SECRETS_KEY)") |
| +// errEscrowNoLease refuses an escrow publication or a mint on a box that |
| +// does not hold the host's instance lease. |
| +var errEscrowNoLease = errors.New("activator: this box does not hold the host's lease, so it neither escrows nor mints the host's secrets") |
| + |
| // EscrowEvery is the sweep's period: a change to an escrowed file is |
| // escrowed within this, plus the sweep's own time. |
| const EscrowEvery = 30 * time.Second |
| @@ -96,9 +112,20 @@ type statStamp struct { |
| ino uint64 |
| } |
| +// escrowPrep is one launch's preparation's read of the bucket: the |
| +// restore, both producers' mint decisions and the launch share it, so a |
| +// first preparation costs one manifest GET. ensureAdminTokenFor begins |
| +// one, escrowedLaunchEnv ends it, and a new launch always begins its own. |
| +type escrowPrep struct { |
| + at time.Time |
| + read bool |
| + m hostfiles.Manifest |
| + found bool |
| +} |
| + |
| // escrowState is one host's escrow on this box. op serializes the host's |
| -// operations that publish or restore, so one publisher serves them all. |
| -// Every other field is read and written under escrowBook.mu. |
| +// operations on its publisher. Every other field is read and written under |
| +// escrowBook.mu. |
| type escrowState struct { |
| op sync.Mutex |
| @@ -108,27 +135,28 @@ type escrowState struct { |
| // 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: a re-read that finds another value escrowed for |
| - // one of them stops rather than publish over it. |
| + // 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 |
| // fromBucket: the next open reads the bucket, never the ledger (the |
| // ledger could not be written after a commit). |
| fromBucket bool |
| - // keyless is the last answer, on a box with a files store and no |
| - // sealing key, to "does the bucket hold an escrow for the host" |
| - // (keylessEscrowed), and when it was read. |
| - keyless bool |
| - keylessAt time.Time |
| + // checked: this process has read the host's manifest from the bucket. |
| + checked bool |
| + // prep is the preparation in progress, nil between launches. |
| + prep *escrowPrep |
| // offLogged: this process has said once that escrow is off for the |
| // host (escrowOff). |
| offLogged bool |
| } |
| -// escrowBook is the backend's escrow state: one escrowState per host and |
| -// the sweep's round-robin cursor, under one mutex. |
| +// escrowBook is the backend's escrow state: one escrowState per host, the |
| +// instance leases this backend's Acquire handed out, and the sweep's |
| +// round-robin cursor, under one mutex. |
| type escrowBook struct { |
| mu sync.Mutex |
| hosts map[string]*escrowState |
| + leases map[string]*execLease |
| cursor string |
| // capOverride replaces escrowSweepCap when set (tests only). |
| capOverride int |
| @@ -173,6 +201,106 @@ func (k *escrowBook) sweepCap() int { |
| return escrowSweepCap |
| } |
| +// noteLease records the instance lease Acquire handed out for host; the |
| +// latest one is the one that counts. |
| +func (k *escrowBook) noteLease(host string, l *execLease) { |
| + k.with(func() { |
| + if k.leases == nil { |
| + k.leases = map[string]*execLease{} |
| + } |
| + k.leases[host] = l |
| + }) |
| +} |
| + |
| +// holdsLease reports whether this box holds host's instance lease now: the |
| +// last one its Acquire handed out is neither released, lost nor past its |
| +// safety deadline, asked of whichever handle owns it (execLease.heldNow, |
| +// the lease's own state; no request). |
| +func (b *ExecBackend) holdsLease(host string) bool { |
| + var l *execLease |
| + b.escrow.with(func() { l = b.escrow.leases[host] }) |
| + return l != nil && l.heldNow() |
| +} |
| + |
| +// beginPrep starts a launch's preparation for host: the reads it makes are |
| +// shared until endPrep or the next beginPrep. |
| +func (b *ExecBackend) beginPrep(host string) { |
| + st := b.escrow.state(host) |
| + b.escrow.with(func() { st.prep = &escrowPrep{at: time.Now()} }) |
| +} |
| + |
| +func (b *ExecBackend) endPrep(host string) { |
| + st := b.escrow.state(host) |
| + b.escrow.with(func() { st.prep = nil }) |
| +} |
| + |
| +// prepRead is the manifest the preparation in progress has read, ok false |
| +// when none has been read or none is in progress. A preparation older than |
| +// haSecretsBudget, one a launch abandoned, shares nothing. |
| +func (b *ExecBackend) prepRead(host string) (m hostfiles.Manifest, found, ok bool) { |
| + st := b.escrow.state(host) |
| + b.escrow.with(func() { |
| + p := st.prep |
| + if p != nil && p.read && time.Since(p.at) < haSecretsBudget { |
| + m, found, ok = p.m, p.found, true |
| + } |
| + }) |
| + return m, found, ok |
| +} |
| + |
| +// notePrepRead keeps m as the preparation's read, and marks the host |
| +// checked. |
| +func (b *ExecBackend) notePrepRead(host string, m hostfiles.Manifest, found bool) { |
| + st := b.escrow.state(host) |
| + b.escrow.with(func() { |
| + st.checked = true |
| + if st.prep != nil { |
| + st.prep.read, st.prep.m, st.prep.found = true, m, found |
| + } |
| + }) |
| +} |
| + |
| +// bucketManifest is rt's files manifest as the bucket holds it: the |
| +// preparation's read when there is one and fresh is false, else one GET. |
| +// With a sealing key the read opens the host's publisher on it |
| +// (hostfiles.Open), so the launch's publish continues from it with no |
| +// second read; without one it is a plain load. |
| +func (b *ExecBackend) bucketManifest(ctx context.Context, rt registry.Route, fresh bool) (hostfiles.Manifest, bool, error) { |
| + if !fresh { |
| + if m, found, ok := b.prepRead(rt.Host); ok { |
| + return m, found, nil |
| + } |
| + } |
| + prefix := b.filesPrefix(rt.Host) |
| + var ( |
| + m hostfiles.Manifest |
| + found bool |
| + ) |
| + if seal, err := b.sealerFor(rt); err == nil { |
| + st := b.escrow.state(rt.Host) |
| + st.op.Lock() |
| + pub, err := hostfiles.Open(ctx, b.FilesStore, prefix) |
| + if err != nil { |
| + st.op.Unlock() |
| + return m, false, fmt.Errorf("read the bucket for the host's escrow: %w", err) |
| + } |
| + b.escrow.install(st, pub, seal) |
| + st.op.Unlock() |
| + base := pub.Baseline() |
| + if m, err = baselineManifest(base); err != nil { |
| + return m, false, err |
| + } |
| + found = base.Found |
| + } else { |
| + var err error |
| + if m, found, err = hostfiles.Load(ctx, b.FilesStore, prefix); err != nil { |
| + return m, false, fmt.Errorf("read the bucket for the host's escrow: %w", err) |
| + } |
| + } |
| + b.notePrepRead(rt.Host, m, found) |
| + return m, found, nil |
| +} |
| + |
| // pubLayout is the classifier's layout for l: only flat and nested rows |
| // are escrowed. |
| func pubLayout(l Layout) (pubclass.Layout, bool) { |
| @@ -245,6 +373,11 @@ func (b *ExecBackend) escrowOff(rt registry.Route, why string) { |
| } |
| } |
| +const ( |
| + whyNoStore = "this box has no files store" |
| + whyNoKey = "this box has no CARLOS_SECRETS_KEY to seal with, and the bucket holds no escrow for the host" |
| +) |
| + |
| // manifestEscrowed reports whether m holds an escrow: any sealed item, or |
| // the cutover marker the first sealed commit leaves. |
| func manifestEscrowed(m hostfiles.Manifest) bool { |
| @@ -257,40 +390,23 @@ func manifestEscrowed(m hostfiles.Manifest) bool { |
| return ok |
| } |
| -// keylessEscrowed answers, on a box with a files store and no sealing key, |
| -// whether the bucket holds an escrow for rt (one GET of the manifest). A |
| -// decision that only refuses, or only launches what is already on disk, |
| -// may reuse an answer read within haSecretsBudget (one launch's |
| -// preparation, so a launch costs one GET); a mint passes fresh and reads |
| -// the bucket at that moment. A read that fails is an error: the caller |
| -// refuses. |
| -func (b *ExecBackend) keylessEscrowed(ctx context.Context, rt registry.Route, fresh bool) (bool, error) { |
| - st := b.escrow.state(rt.Host) |
| - if !fresh { |
| - var ( |
| - v bool |
| - at time.Time |
| - ) |
| - b.escrow.with(func() { v, at = st.keyless, st.keylessAt }) |
| - if !at.IsZero() && time.Since(at) < haSecretsBudget { |
| - return v, nil |
| - } |
| - } |
| - m, found, err := hostfiles.Load(ctx, b.FilesStore, b.filesPrefix(rt.Host)) |
| - if err != nil { |
| - return false, fmt.Errorf("read the bucket for the host's escrow: %w", err) |
| - } |
| - v := found && manifestEscrowed(m) |
| - b.escrow.with(func() { st.keyless, st.keylessAt = v, time.Now() }) |
| - return v, nil |
| -} |
| - |
| // escrowKeylessRefusal is the refusal on a box with no sealing key whose |
| // bucket holds an escrow for the host. |
| func escrowKeylessRefusal(err error) error { |
| return fmt.Errorf("%w: the bucket holds an escrow for the host and this box has no key to open it", err) |
| } |
| +// keylessEscrowed answers, on a box with a files store and no sealing key, |
| +// whether the bucket holds an escrow for rt: the preparation's read, or |
| +// one GET when fresh or when there is none. |
| +func (b *ExecBackend) keylessEscrowed(ctx context.Context, rt registry.Route, fresh bool) (bool, error) { |
| + m, found, err := b.bucketManifest(ctx, rt, fresh) |
| + if err != nil { |
| + return false, err |
| + } |
| + return found && manifestEscrowed(m), nil |
| +} |
| + |
| // escrowReady is nil when this box can read and write rt's sealed copy: a |
| // files store, a key, and a sealer for the row. Anything else wraps |
| // ErrEscrowNotReady. |
| @@ -310,6 +426,30 @@ func escrowLedgerPath(dataDir, host string) string { |
| return filepath.Join(dataDir, ".escrow", host+".json") |
| } |
| +// escrowConflictPath is host's conflict marker, beside its ledger. |
| +func escrowConflictPath(dataDir, host string) string { |
| + return filepath.Join(dataDir, ".escrow", host+".conflict") |
| +} |
| + |
| +// escrowConflict is the refusal while host's conflict marker exists: nil |
| +// when there is none. |
| +func (b *ExecBackend) escrowConflict(host string) error { |
| + path := escrowConflictPath(b.DataDir, host) |
| + 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) |
| +} |
| + |
| +// 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)) |
| +} |
| + |
| // writeEscrowLedgerFile keeps base, the manifest just committed, as host's |
| // ledger, durably. |
| func writeEscrowLedgerFile(dataDir, host string, base hostfiles.Baseline) error { |
| @@ -447,6 +587,7 @@ func (b *ExecBackend) openEscrowLocked(ctx context.Context, rt registry.Route, s |
| if pub, err = hostfiles.Open(ctx, b.FilesStore, prefix); err != nil { |
| return nil, nil, fmt.Errorf("read the escrow: %w", err) |
| } |
| + b.escrow.with(func() { st.checked = true }) |
| } |
| b.escrow.install(st, pub, seal) |
| return pub, seal, nil |
| @@ -464,7 +605,8 @@ type escrowPublish struct { |
| // publishEscrow stages env (bytes the caller captured; nil: read the file) |
| // and the trio read from disk, and commits. An absent file stages nothing |
| -// (choice 9). exists: the host has a committed escrow after the call. |
| +// (choice 9). exists: the host has a committed escrow after the call. Only |
| +// a box holding the host's lease publishes. |
| func (b *ExecBackend) publishEscrow(ctx context.Context, rt registry.Route, env []byte) (exists bool, err error) { |
| r, err := b.publishEscrowAt(ctx, rt, b.pathsFor(rt), env) |
| return r.exists, err |
| @@ -474,6 +616,12 @@ func (b *ExecBackend) publishEscrowAt(ctx context.Context, rt registry.Route, p |
| if err := b.escrowReady(rt); err != nil { |
| return escrowPublish{exists: b.ledgerEscrowed(rt.Host)}, err |
| } |
| + if err := b.escrowConflict(rt.Host); err != nil { |
| + return escrowPublish{exists: b.ledgerEscrowed(rt.Host)}, err |
| + } |
| + if !b.holdsLease(rt.Host) { |
| + return escrowPublish{exists: b.ledgerEscrowed(rt.Host)}, errEscrowNoLease |
| + } |
| lay, ok := pubLayout(p.layout) |
| if !ok { |
| return escrowPublish{exists: b.ledgerEscrowed(rt.Host)}, fmt.Errorf("not escrowed: the row's layout is %s", p.layout) |
| @@ -579,6 +727,13 @@ 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 { |
| + return out, err |
| + } |
| for _, r := range reads { |
| if !r.stage { |
| continue |
| @@ -616,73 +771,144 @@ func (b *ExecBackend) publishEscrowLocked(ctx context.Context, rt registry.Route |
| return out, errors.Join(refused...) |
| } |
| -// restoreEscrowIfMissing reads the bucket manifest (one GET), then writes |
| -// each sealed item whose local file is absent. A present file is never |
| -// touched. Nothing is read when no file is missing. With no files store it |
| -// does nothing (escrowNoStore). With no sealing key (escrowNoKey) it |
| -// restores nothing: it refuses when the bucket holds an escrow for the |
| -// host, unless the host has a ledger here and its env file is here, and |
| -// otherwise lets the launch go on as before 3a. |
| +// 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) |
| + } |
| + }) |
| + 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 len(conflicts) == 0 { |
| + return nil |
| + } |
| + 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) |
| + } |
| + 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) |
| + log.Print(err) |
| + return 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 |
| +// sealing key it restores nothing, refuses while the bucket holds an |
| +// escrow for the host (unless the host has a ledger here and its env file |
| +// is here), and otherwise lets the launch go on as before 3a. With a key, |
| +// a missing env file always reads the bucket; a missing trio file reads it |
| +// only when the ledger says it was escrowed, or with no ledger on the |
| +// host's first restore since the agent started, so a file that never |
| +// existed costs no request (P2-6). The read is the preparation's, which the |
| +// producers' mint decisions then share. A trio file that cannot be checked |
| +// (a link, a FIFO) is not missing: there is nothing to restore into it. |
| func (b *ExecBackend) restoreEscrowIfMissing(ctx context.Context, rt registry.Route, p instancePaths) error { |
| + if err := b.escrowConflict(rt.Host); err != nil { |
| + return err |
| + } |
| + switch b.escrowModeOf(rt) { |
| + case escrowNoStore: |
| + b.escrowOff(rt, whyNoStore) |
| + return nil |
| + case escrowNoKey: |
| + ready := b.escrowReady(rt) |
| + escrowed, err := b.keylessEscrowed(ctx, rt, false) |
| + switch { |
| + case err != nil: |
| + return fmt.Errorf("%w: %v", ready, err) |
| + case !escrowed: |
| + b.escrowOff(rt, whyNoKey) |
| + return nil |
| + } |
| + f, absent, err := instancefs.OpenBeneathOrAbsent(p.dataDir, rt.Host+".env") |
| + if err == nil && !absent { |
| + f.Close() |
| + if b.ledgerEscrowed(rt.Host) { |
| + logPerFile("escrow-not-ready", rt.Host, fmt.Sprintf("activator: %s: escrow: %v; launching on the local env this box escrowed before", rt.Host, ready)) |
| + return nil |
| + } |
| + } |
| + return escrowKeylessRefusal(ready) |
| + } |
| lay, ok := pubLayout(p.layout) |
| if !ok { |
| 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) |
| + if haveLedger { |
| + if m, err := baselineManifest(ledger); err == nil { |
| + lm = m |
| + } else { |
| + haveLedger = false |
| + } |
| + } |
| + st := b.escrow.state(rt.Host) |
| + var checked bool |
| + b.escrow.with(func() { checked = st.checked }) |
| rels := pubclass.SealedRels(lay, rt.Host) |
| missing := map[string]bool{} |
| + need := false |
| for _, r := range rels { |
| f, absent, err := instancefs.OpenBeneathOrAbsent(p.dataDir, filepath.FromSlash(r.Rel())) |
| if err != nil { |
| - return fmt.Errorf("escrow: %s: %w", r.Rel(), err) |
| + continue |
| } |
| - if absent { |
| - missing[r.Item()] = true |
| - } else { |
| + if !absent { |
| f.Close() |
| + continue |
| } |
| - } |
| - switch b.escrowModeOf(rt) { |
| - case escrowNoStore: |
| - b.escrowOff(rt, "this box has no files store") |
| - return nil |
| - case escrowNoKey: |
| - err := b.escrowReady(rt) |
| - if !missing[hostfiles.SealedEnvItem] && b.ledgerEscrowed(rt.Host) { |
| - logPerFile("escrow-not-ready", rt.Host, fmt.Sprintf("activator: %s: escrow: %v; launching on the local env this box escrowed before", rt.Host, err)) |
| - return nil |
| - } |
| - escrowed, rerr := b.keylessEscrowed(ctx, rt, false) |
| + missing[r.Item()] = true |
| switch { |
| - case rerr != nil: |
| - return fmt.Errorf("%w: %v", err, rerr) |
| - case escrowed: |
| - return escrowKeylessRefusal(err) |
| + case r.Item() == hostfiles.SealedEnvItem: |
| + need = true |
| + case haveLedger: |
| + if _, ok := lm.Platform[r.Item()]; ok { |
| + need = true |
| + } |
| + case !checked: |
| + need = true |
| } |
| - b.escrowOff(rt, "this box has no CARLOS_SECRETS_KEY to seal with, and the bucket holds no escrow for the host") |
| - return nil |
| } |
| - if len(missing) == 0 { |
| + if !need { |
| return nil |
| } |
| - st := b.escrow.state(rt.Host) |
| - st.op.Lock() |
| - defer st.op.Unlock() |
| + m, _, err := b.bucketManifest(ctx, rt, false) |
| + if err != nil { |
| + return fmt.Errorf("escrow: %w", err) |
| + } |
| seal, err := b.sealerFor(rt) |
| if err != nil { |
| return fmt.Errorf("%w: %v", ErrEscrowNotReady, err) |
| } |
| prefix := b.filesPrefix(rt.Host) |
| - // The bucket, never the ledger: a crash between a commit and its |
| - // ledger write leaves the ledger behind the bucket. |
| - pub, err := hostfiles.Open(ctx, b.FilesStore, prefix) |
| - if err != nil { |
| - return fmt.Errorf("escrow: read the bucket: %w", err) |
| - } |
| - b.escrow.install(st, pub, seal) |
| - m, err := baselineManifest(pub.Baseline()) |
| - if err != nil { |
| - return err |
| - } |
| for _, r := range rels { |
| if !missing[r.Item()] { |
| continue |
| @@ -736,29 +962,32 @@ func writeIfAbsent(dir, name string, data []byte) (bool, error) { |
| // escrowMintGuard is an eligible host's mint decision. With no files store |
| // it is nil, and the producer mints as before 3a. With no sealing key it |
| -// reads the bucket at the mint and refuses (ErrEscrowNotReady) when the |
| -// bucket holds an escrow for the host, and lets the mint go ahead when it |
| -// holds none. Otherwise it reads |
| -// the bucket's manifest when a producer would mint (never the ledger), at |
| -// most once, 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. A mint it lets go ahead is noted, so |
| -// a re-read after a supersession can tell a secret this box minted. |
| -func (b *ExecBackend) escrowMintGuard(ctx context.Context, rt registry.Route) mintGuard { |
| +// refuses (ErrEscrowNotReady) while the bucket holds an escrow for the host |
| +// and lets the mint go ahead while it holds none. With a key it refuses |
| +// every mint while the host's conflict marker exists, or while this box |
| +// does not hold the host's lease (wrapping ErrInstanceKeyDeferred: the |
| +// next launch, under the lease, mints); otherwise it reads the bucket's |
| +// manifest when a producer would mint (never the ledger), at most once, |
| +// 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. |
| +func (b *ExecBackend) escrowMintGuard(ctx context.Context, rt registry.Route, fresh bool) mintGuard { |
| switch b.escrowModeOf(rt) { |
| case escrowNoStore: |
| return nil |
| case escrowNoKey: |
| ready := b.escrowReady(rt) |
| return func(name string) error { |
| - escrowed, err := b.keylessEscrowed(ctx, rt, true) |
| + escrowed, err := b.keylessEscrowed(ctx, rt, fresh) |
| switch { |
| case err != nil: |
| return fmt.Errorf("refusing to mint %s: %w: %v", name, ready, err) |
| case escrowed: |
| return fmt.Errorf("refusing to mint %s: %w", name, escrowKeylessRefusal(ready)) |
| } |
| - b.escrowOff(rt, "this box has no CARLOS_SECRETS_KEY to seal with, and the bucket holds no escrow for the host") |
| + b.escrowOff(rt, whyNoKey) |
| return nil |
| } |
| } |
| @@ -768,11 +997,27 @@ func (b *ExecBackend) escrowMintGuard(ctx context.Context, rt registry.Route) mi |
| verdict error |
| ) |
| read := func() { |
| - escrowed, found, err := b.bucketEscrowEnv(ctx, rt) |
| + if err := b.escrowConflict(rt.Host); err != nil { |
| + verdict = err |
| + return |
| + } |
| + if !b.holdsLease(rt.Host) { |
| + verdict = fmt.Errorf("%w: %w", ErrInstanceKeyDeferred, errEscrowNoLease) |
| + return |
| + } |
| + m, found, err := b.bucketManifest(ctx, rt, fresh) |
| + if err != nil { |
| + verdict = fmt.Errorf("refusing to mint: %w", err) |
| + return |
| + } |
| + if !found { |
| + return |
| + } |
| + escrowed, ok, err := b.escrowEnvOf(ctx, rt, m) |
| switch { |
| case err != nil: |
| verdict = fmt.Errorf("refusing to mint: %w", err) |
| - case found: |
| + case ok: |
| env = parseEnvBytes(escrowed) |
| } |
| } |
| @@ -795,22 +1040,6 @@ func (b *ExecBackend) escrowMintGuard(ctx context.Context, rt registry.Route) mi |
| } |
| } |
| -// bucketEscrowEnv is rt's escrowed env as the bucket holds it now: one GET |
| -// of the manifest, and one of the sealed env item if there is one. found |
| -// is false when there is none. An item that does not open here wraps |
| -// ErrEscrowNotReady. |
| -func (b *ExecBackend) bucketEscrowEnv(ctx context.Context, rt registry.Route) ([]byte, bool, error) { |
| - prefix := b.filesPrefix(rt.Host) |
| - m, found, err := hostfiles.Load(ctx, b.FilesStore, prefix) |
| - if err != nil { |
| - return nil, false, fmt.Errorf("read the escrow in the bucket: %w", err) |
| - } |
| - if !found { |
| - return nil, false, nil |
| - } |
| - return b.escrowEnvOf(ctx, rt, m) |
| -} |
| - |
| // escrowEnvOf opens m's sealed env item, found false when m holds none. |
| func (b *ExecBackend) escrowEnvOf(ctx context.Context, rt registry.Route, m hostfiles.Manifest) ([]byte, bool, error) { |
| if _, ok := m.Platform[hostfiles.SealedEnvItem]; !ok { |
| @@ -834,9 +1063,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 a refusal when the bucket now escrows a |
| -// secret this box just minted with another value: the bucket's copy came |
| -// first, and the local file is left for an operator. |
| +// every file is read again), and the conflict check (mintedConflict) on |
| +// what it holds now. |
| func (b *ExecBackend) escrowReread(ctx context.Context, rt registry.Route, p instancePaths) error { |
| st := b.escrow.state(rt.Host) |
| st.op.Lock() |
| @@ -853,69 +1081,54 @@ func (b *ExecBackend) escrowReread(ctx context.Context, rt registry.Route, p ins |
| if escrowHooks.afterReread != nil { |
| escrowHooks.afterReread(rt.Host) |
| } |
| - var minted []string |
| - b.escrow.with(func() { |
| - for name := range st.minted { |
| - minted = append(minted, name) |
| - } |
| - }) |
| - if len(minted) == 0 { |
| - return nil |
| - } |
| m, err := baselineManifest(pub.Baseline()) |
| if err != nil { |
| return err |
| } |
| - 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) |
| - for _, name := range minted { |
| - if v := theirs[name]; v != "" && v != ours[name] { |
| - return 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", rt.Host, name, p.envFile) |
| - } |
| - } |
| - return nil |
| + return b.mintedConflict(ctx, rt, p, m) |
| } |
| -// escrowedLaunchEnv is launchEnvLayer for an eligible host: the env |
| +// escrowedLaunchEnv is launchEnvLayer for an eligible host, and the end of |
| +// its preparation. The mode decides first. With no files store, and with |
| +// no sealing key while the bucket holds no escrow (the preparation's read), |
| +// the launch is as before 3a (instanceEnvLayer). With no key and an escrow, |
| +// a host this box escrowed before launches on its local env, logged, and |
| +// any other is refused. With a key: refused while the host's conflict |
| +// marker exists or this box does not hold its lease; otherwise the env is |
| // captured once (captureLaunchEnv), those bytes published and, once the |
| // commit lands, acknowledged (SealedAcknowledged), and the env parsed from |
| // them handed back. A publish that meets another writer reads the bucket |
| // again and starts the preparation over from the restore, once; a second |
| // one fails the launch with an alert. A failed write holds only a first |
| -// launch (a host never escrowed). With no files store the launch is as |
| -// before 3a (instanceEnvLayer). With no sealing key, a host this box |
| -// escrowed before launches on its local env, logged; any other launches |
| -// as before 3a only while the bucket holds no escrow for it. |
| +// launch (a host never escrowed). |
| func (b *ExecBackend) escrowedLaunchEnv(ctx context.Context, rt registry.Route) (map[string]string, instancekey.Layer, error) { |
| + defer b.endPrep(rt.Host) |
| for attempt := 0; ; attempt++ { |
| p := b.pathsFor(rt) |
| + if err := b.escrowConflict(rt.Host); err != nil { |
| + return nil, instancekey.LayerNone, err |
| + } |
| switch b.escrowModeOf(rt) { |
| case escrowNoStore: |
| - b.escrowOff(rt, "this box has no files store") |
| + b.escrowOff(rt, whyNoStore) |
| return b.instanceEnvLayer(rt) |
| case escrowNoKey: |
| ready := b.escrowReady(rt) |
| - if b.ledgerEscrowed(rt.Host) { |
| - logPerFile("escrow-not-ready", rt.Host, fmt.Sprintf("activator: %s: escrow: %v; launching on the local env this box escrowed before", rt.Host, ready)) |
| - return b.instanceEnvLayer(rt) |
| - } |
| escrowed, err := b.keylessEscrowed(ctx, rt, false) |
| switch { |
| case err != nil: |
| return nil, instancekey.LayerNone, fmt.Errorf("secrets for %s: %w: %v", rt.Host, ready, err) |
| - case escrowed: |
| - return nil, instancekey.LayerNone, fmt.Errorf("secrets for %s: %w", rt.Host, escrowKeylessRefusal(ready)) |
| + case !escrowed: |
| + b.escrowOff(rt, whyNoKey) |
| + return b.instanceEnvLayer(rt) |
| + case b.ledgerEscrowed(rt.Host): |
| + logPerFile("escrow-not-ready", rt.Host, fmt.Sprintf("activator: %s: escrow: %v; launching on the local env this box escrowed before", rt.Host, ready)) |
| + return b.instanceEnvLayer(rt) |
| } |
| - b.escrowOff(rt, "this box has no CARLOS_SECRETS_KEY to seal with, and the bucket holds no escrow for the host") |
| - return b.instanceEnvLayer(rt) |
| + return nil, instancekey.LayerNone, fmt.Errorf("secrets for %s: %w", rt.Host, escrowKeylessRefusal(ready)) |
| + } |
| + if !b.holdsLease(rt.Host) { |
| + return nil, instancekey.LayerNone, fmt.Errorf("secrets for %s: %w", rt.Host, errEscrowNoLease) |
| } |
| c, err := b.captureLaunchEnv(rt) |
| if err != nil { |
| @@ -944,6 +1157,8 @@ func (b *ExecBackend) escrowedLaunchEnv(ctx context.Context, rt registry.Route) |
| return nil, instancekey.LayerNone, fmt.Errorf("instance key for %s: %w", rt.Host, err) |
| } |
| continue |
| + case err != nil && strings.HasPrefix(err.Error(), "ALERT: "): |
| + return nil, instancekey.LayerNone, err |
| case err != nil && !r.exists: |
| return nil, instancekey.LayerNone, fmt.Errorf("secrets for %s: escrow the host's secrets before its first launch: %w", rt.Host, err) |
| case err != nil: |
| @@ -997,7 +1212,13 @@ func (b *ExecBackend) escrowChanged(rt registry.Route, p instancePaths, lay pubc |
| pub *hostfiles.Publisher |
| stamps map[string]statStamp |
| ) |
| - b.escrow.with(func() { pub, stamps = st.pub, st.stamps }) |
| + b.escrow.with(func() { |
| + pub = st.pub |
| + stamps = make(map[string]statStamp, len(st.stamps)) |
| + for k, v := range st.stamps { |
| + stamps[k] = v |
| + } |
| + }) |
| if pub != nil && pub.Dirty() { |
| return true |
| } |
| @@ -1031,16 +1252,31 @@ func stampAt(dir, rel string) (statStamp, error) { |
| return stampOf(fi), nil |
| } |
| +// sweepTally is one sweep's report, written by the dispatcher and its |
| +// workers through one lock. |
| +type sweepTally struct { |
| + mu sync.Mutex |
| + rep EscrowSweepReport |
| +} |
| + |
| +func (s *sweepTally) add(f func(r *EscrowSweepReport)) { |
| + s.mu.Lock() |
| + defer s.mu.Unlock() |
| + f(&s.rep) |
| +} |
| + |
| // EscrowSweep publishes the escrow of every eligible host in rows whose |
| -// files changed: in host order from the host after the cursor (the last |
| -// host it published), wrapping round; a host whose stamps are unchanged |
| -// costs no read. Up to escrowSweepWorkers publishes run at once, and at |
| -// most escrowSweepCap hosts are published; the rest are deferred and come |
| -// first next time. A box that is not ready publishes nothing. |
| +// lease this box holds and whose files changed: in host order from the |
| +// host after the cursor (the last host it published), wrapping round; a |
| +// host whose stamps are unchanged costs no read. A host whose lease this |
| +// box does not hold is skipped: its local copy is not the serving one. Up |
| +// to escrowSweepWorkers publishes run at once, and at most escrowSweepCap |
| +// hosts are published; the rest are deferred and come first next time. A |
| +// box that is not ready publishes nothing. |
| func (b *ExecBackend) EscrowSweep(ctx context.Context, rows []registry.Route) EscrowSweepReport { |
| - var rep EscrowSweepReport |
| + var tally sweepTally |
| if b.FilesStore == nil || b.EscrowKey == nil { |
| - return rep |
| + return tally.rep |
| } |
| // The layout from the rows in hand: one registry read per sweep, not |
| // one per row. |
| @@ -1065,7 +1301,14 @@ func (b *ExecBackend) EscrowSweep(ctx context.Context, rows []registry.Route) Es |
| if ha, known := b.haKnown(rt); ha || !known { |
| continue |
| } |
| + if !b.holdsLease(rt.Host) { |
| + continue |
| + } |
| seen[rt.Host] = true |
| + if b.escrowConflict(rt.Host) != nil { |
| + tally.add(func(r *EscrowSweepReport) { r.Failing = append(r.Failing, rt.Host) }) |
| + continue |
| + } |
| cands = append(cands, cand{rt: rt, p: b.pathsAt(rt, l, reason), lay: lay}) |
| } |
| sort.Slice(cands, func(i, j int) bool { return cands[i].rt.Host < cands[j].rt.Host }) |
| @@ -1078,7 +1321,6 @@ func (b *ExecBackend) EscrowSweep(ctx context.Context, rows []registry.Route) Es |
| sem := make(chan struct{}, escrowSweepWorkers) |
| var ( |
| wg sync.WaitGroup |
| - mu sync.Mutex |
| last string |
| sent int |
| ) |
| @@ -1087,11 +1329,11 @@ func (b *ExecBackend) EscrowSweep(ctx context.Context, rows []registry.Route) Es |
| break |
| } |
| if !b.escrowChanged(c.rt, c.p, c.lay) { |
| - rep.Unchanged++ |
| + tally.add(func(r *EscrowSweepReport) { r.Unchanged++ }) |
| continue |
| } |
| if sent >= limit { |
| - rep.Deferred++ |
| + tally.add(func(r *EscrowSweepReport) { r.Deferred++ }) |
| continue |
| } |
| sent++ |
| @@ -1104,11 +1346,9 @@ func (b *ExecBackend) EscrowSweep(ctx context.Context, rows []registry.Route) Es |
| hctx, cancel := context.WithTimeout(ctx, haSecretsBudget) |
| defer cancel() |
| committed, err := b.sweepPublish(hctx, c.rt, c.p) |
| - mu.Lock() |
| - defer mu.Unlock() |
| switch { |
| case err != nil: |
| - rep.Failing = append(rep.Failing, c.rt.Host) |
| + tally.add(func(r *EscrowSweepReport) { r.Failing = append(r.Failing, c.rt.Host) }) |
| // A failure that repeats every sweep (a file the tenant made |
| // unreadable, say) is said once an hour; an alert every time. |
| if strings.HasPrefix(err.Error(), "ALERT: ") { |
| @@ -1117,9 +1357,9 @@ func (b *ExecBackend) EscrowSweep(ctx context.Context, rows []registry.Route) Es |
| logPerFile("escrow", c.rt.Host, fmt.Sprintf("activator: %s: escrow: %v (retried every sweep)", c.rt.Host, err)) |
| } |
| case committed: |
| - rep.Published++ |
| + tally.add(func(r *EscrowSweepReport) { r.Published++ }) |
| default: |
| - rep.Unchanged++ |
| + tally.add(func(r *EscrowSweepReport) { r.Unchanged++ }) |
| } |
| }(c) |
| } |
| @@ -1127,6 +1367,9 @@ func (b *ExecBackend) EscrowSweep(ctx context.Context, rows []registry.Route) Es |
| if last != "" { |
| b.escrow.with(func() { b.escrow.cursor = last }) |
| } |
| + tally.mu.Lock() |
| + defer tally.mu.Unlock() |
| + rep := tally.rep |
| sort.Strings(rep.Failing) |
| return rep |
| } |
diff --git a/internal/activator/escrow_linux_test.go b/internal/activator/escrow_linux_test.go| index 599696409..2f98dbd76 100644 |
| --- a/internal/activator/escrow_linux_test.go |
| +++ b/internal/activator/escrow_linux_test.go |
| @@ -101,3 +101,38 @@ func TestEscrowReadRefusesLinkFIFOAndOversize(t *testing.T) { |
| }) |
| } |
| } |
| + |
| +// P2-5: on the pre-3a paths (no sealing key and no escrow in the bucket, |
| +// or no files store), the mode decides before any escrow-specific check of |
| +// the trio: a valid env and a FIFO at <host>/instance.key launch exactly as |
| +// before 3a, through the real wake. |
| +func TestFallbackIgnoresARefusedTrioPath(t *testing.T) { |
| + for _, mode := range []string{"no key, no escrow", "no files store"} { |
| + t.Run(mode, func(t *testing.T) { |
| + s := escrowService(t, escrowHost) |
| + if mode == "no key, no escrow" { |
| + s.b.EscrowKey = nil |
| + } else { |
| + s.b.FilesStore = nil |
| + } |
| + writeEnv(t, s.b, s.rt, envA) |
| + writeFiles(t, s.b, s.rt, map[string]string{"a.txt": "app"}) |
| + if err := syscall.Mkfifo(filepath.Join(filesDirOf(s.b, s.rt), "instance.key"), 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + done := make(chan error, 1) |
| + go func() { _, err := s.wakeForTest(context.Background()); done <- err }() |
| + select { |
| + case err := <-done: |
| + if err != nil { |
| + t.Fatalf("wake: %v\n%s", err, s.ctl.joined()) |
| + } |
| + case <-time.After(20 * time.Second): |
| + t.Fatal("the wake blocked on the FIFO") |
| + } |
| + if got := launchToken(t, s.b, s.rt); got != "tok-a" { |
| + t.Fatalf("launch token %q, want the env's", got) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/activator/escrow_test.go b/internal/activator/escrow_test.go| index 306aa5f9d..55d3f9fe3 100644 |
| --- a/internal/activator/escrow_test.go |
| +++ b/internal/activator/escrow_test.go |
| @@ -17,6 +17,7 @@ import ( |
| "github.com/carlosframework/platform/internal/domains" |
| "github.com/carlosframework/platform/internal/hostfiles" |
| "github.com/carlosframework/platform/internal/instancectl" |
| + "github.com/carlosframework/platform/internal/layout/pubclass" |
| "github.com/carlosframework/platform/internal/provision" |
| "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/release" |
| @@ -33,8 +34,10 @@ const escrowHost = "shop.example.com" |
| // escrowBackend is a production-shaped ExecBackend for a host that is not |
| // HA, on the nested layout: haBackendEmptyIndex's wiring (a DirStore files |
| // store, an escrow key, the registry holding the row), with the record and |
| -// the lifetime index saying the host is not HA, and a run directory short |
| -// enough for the launch path's unix sockets. |
| +// the lifetime index saying the host is not HA, a run directory short |
| +// enough for the launch path's unix sockets, and the host's instance lease |
| +// held through the production Acquire, as a wake holds it before it |
| +// prepares. |
| func escrowBackend(t *testing.T, host string) (*ExecBackend, registry.Route) { |
| t.Helper() |
| b, rt := haBackendEmptyIndex(t, host) |
| @@ -49,6 +52,7 @@ func escrowBackend(t *testing.T, host string) (*ExecBackend, registry.Route) { |
| if err := b.Registry.Upsert(rt); err != nil { |
| t.Fatal(err) |
| } |
| + holdLease(t, b, rt) |
| return b, rt |
| } |
| @@ -73,10 +77,27 @@ func escrowService(t *testing.T, host string) *haSvc { |
| return s |
| } |
| -// restartEscrow is the agent restarted on the same box: a new backend over |
| -// the same data directory, files store, key, registry and index, with no |
| -// memory of the old one. |
| +// restartEscrow is the agent restarted on the same box: the old agent's |
| +// leases end, and a new backend over the same data directory, files store, |
| +// key, registry and index has no memory of the old one (and holds no |
| +// lease until it acquires one). |
| func restartEscrow(t *testing.T, b *ExecBackend) *ExecBackend { |
| + t.Helper() |
| + var held []*execLease |
| + b.escrow.with(func() { |
| + for _, l := range b.escrow.leases { |
| + held = append(held, l) |
| + } |
| + }) |
| + for _, l := range held { |
| + _ = l.Release(context.Background()) |
| + } |
| + return backendLike(t, b) |
| +} |
| + |
| +// backendLike is a second backend over b's data, store, key, registry and |
| +// index. |
| +func backendLike(t *testing.T, b *ExecBackend) *ExecBackend { |
| t.Helper() |
| nb := testExecBackend(t) |
| nb.Cfg = b.Cfg |
| @@ -92,7 +113,7 @@ func restartEscrow(t *testing.T, b *ExecBackend) *ExecBackend { |
| // host: its own data directory, the same files store and key. |
| func otherBox(t *testing.T, b *ExecBackend, rt registry.Route) (*ExecBackend, registry.Route) { |
| t.Helper() |
| - ob := restartEscrow(t, b) |
| + ob := backendLike(t, b) |
| ob.DataDir = filepath.Join(t.TempDir(), "data") |
| if err := os.MkdirAll(ob.DataDir, 0o755); err != nil { |
| t.Fatal(err) |
| @@ -179,11 +200,18 @@ func (s *countingStore) List(ctx context.Context, prefix string) ([]string, erro |
| return s.Store.List(ctx, prefix) |
| } |
| -// failingPuts is a files store that refuses every write. |
| -type failingPuts struct{ release.Store } |
| +// switchingPuts is a files store that refuses every write while failing |
| +// is set. |
| +type switchingPuts struct { |
| + release.Store |
| + failing atomic.Bool |
| +} |
| -func (failingPuts) Put(context.Context, string, []byte, string) (string, error) { |
| - return "", errors.New("store unavailable") |
| +func (s *switchingPuts) Put(ctx context.Context, key string, body []byte, ifMatch string) (string, error) { |
| + if s.failing.Load() { |
| + return "", errors.New("store unavailable") |
| + } |
| + return s.Store.Put(ctx, key, body, ifMatch) |
| } |
| const ( |
| @@ -245,6 +273,7 @@ func TestUnchangedEscrowMakesNoRequestAfterARestart(t *testing.T) { |
| t.Fatalf("the first sweep: %+v", rep) |
| } |
| nb := restartEscrow(t, b) |
| + holdLease(t, nb, rt) |
| cs := &countingStore{Store: b.FilesStore} |
| nb.FilesStore = cs |
| for i := 0; i < 2; i++ { |
| @@ -309,6 +338,7 @@ func TestNotReadyRefusesRestoreMintAndFirstLaunch(t *testing.T) { |
| ctx := context.Background() |
| s := escrowService(t, escrowHost) |
| writeEnv(t, s.b, s.rt, envA) |
| + holdLease(t, s.b, s.rt) |
| mustPublish(t, s.b, s.rt) |
| ledger := escrowLedgerPath(s.b.DataDir, s.rt.Host) |
| kept, err := os.ReadFile(ledger) |
| @@ -402,9 +432,6 @@ func TestNoKeyAndNoEscrowLaunchesAsBefore(t *testing.T) { |
| // The next launch, with both secrets on disk: one GET, and the token |
| // is the first launch's. |
| tok := launchToken(t, s.b, s.rt) |
| - // A new launch's preparation: the first launch's answer has aged out. |
| - st := s.b.escrow.state(s.rt.Host) |
| - s.b.escrow.with(func() { st.keylessAt = time.Time{} }) |
| before := cs.gets.Load() |
| if _, err := s.wakeForTest(ctx); err != nil { |
| t.Fatalf("the second wake: %v", err) |
| @@ -474,6 +501,10 @@ func TestEscrowSurvivesALostEnvAcrossWakes(t *testing.T) { |
| t.Fatalf("sweep: %+v", rep) |
| } |
| s.stopForTest(e) |
| + // Asleep, the host's lease is no longer this box's: the sweep leaves it. |
| + if s.b.holdsLease(s.rt.Host) { |
| + t.Fatal("the lease is still held after the stop") |
| + } |
| if err := os.Remove(s.b.pathsFor(s.rt).envFile); err != nil { |
| t.Fatal(err) |
| @@ -517,6 +548,7 @@ func TestCrashBetweenCommitAndLedgerRestoresTheBucketVersion(t *testing.T) { |
| t.Fatalf("bucket %q, want B", got) |
| } |
| nb := restartEscrow(t, b) |
| + holdLease(t, nb, rt) |
| if err := os.Remove(nb.pathsFor(rt).envFile); err != nil { |
| t.Fatal(err) |
| } |
| @@ -543,6 +575,7 @@ func TestStaleLedgerNeverAuthorizesAMint(t *testing.T) { |
| writeEscrowLedger = old |
| // The new agent's ledger is A's, which holds no key. |
| nb := restartEscrow(t, b) |
| + holdLease(t, nb, rt) |
| writeEnv(t, nb, rt, "CARLOS_ADMIN_TOKEN=tok-b\n") |
| if _, err := nb.ensureInstanceKeyFor(ctx, rt, nb.pathsFor(rt)); !errors.Is(err, ErrInstanceKeyDeferred) { |
| t.Fatalf("ensure: %v", err) |
| @@ -595,6 +628,7 @@ func TestRestoreNeverOverwritesALocalEnv(t *testing.T) { |
| t.Fatal(err) |
| } |
| nb := restartEscrow(t, b) |
| + holdLease(t, nb, rt) |
| if _, err := nb.launchEnvForTest(rt); err != nil { |
| t.Fatal(err) |
| } |
| @@ -617,6 +651,7 @@ func TestNoMintWhileTheEscrowHoldsTheSecret(t *testing.T) { |
| mustPublish(t, b, rt) |
| writeEnv(t, b, rt, "OTHER=1\n") |
| nb := restartEscrow(t, b) |
| + holdLease(t, nb, rt) |
| if _, err := nb.launchEnvForTest(rt); !errors.Is(err, ErrInstanceKeyDeferred) { |
| t.Fatalf("launch: %v", err) |
| } |
| @@ -635,6 +670,7 @@ func TestMintAllowedWhenTheEscrowLacksTheSecret(t *testing.T) { |
| writeEnv(t, b, rt, "CARLOS_ADMIN_TOKEN=tok-a\n") |
| mustPublish(t, b, rt) |
| nb := restartEscrow(t, b) |
| + holdLease(t, nb, rt) |
| env, err := nb.launchEnvForTest(rt) |
| if err != nil { |
| t.Fatal(err) |
| @@ -652,23 +688,30 @@ func TestMintAllowedWhenTheEscrowLacksTheSecret(t *testing.T) { |
| // launch fails; with one it goes ahead. |
| func TestFirstLaunchHeldWhenTheEscrowCannotBeWritten(t *testing.T) { |
| b, rt := escrowBackend(t, escrowHost) |
| - store := b.FilesStore |
| - b.FilesStore = failingPuts{store} |
| + store := &switchingPuts{Store: b.FilesStore} |
| + b.FilesStore = store |
| + store.failing.Store(true) |
| if _, err := b.launchEnvForTest(rt); err == nil { |
| t.Fatal("the first launch went ahead with no escrow") |
| } |
| if objs := prefixObjects(t, b, rt); len(objs) != 0 { |
| t.Fatalf("published %d objects", len(objs)) |
| } |
| - b.FilesStore = store |
| + store.failing.Store(false) |
| if _, err := b.launchEnvForTest(rt); err != nil { |
| t.Fatalf("a launch with the store back: %v", err) |
| } |
| + store.failing.Store(true) |
| + writeEnv(t, b, rt, envFileBytes(t, b, rt)+"FOO=2\n") |
| + if _, err := b.launchEnvForTest(rt); err != nil { |
| + t.Fatalf("a later launch was held: %v", err) |
| + } |
| + // And after a restart, from the ledger alone. |
| nb := restartEscrow(t, b) |
| - nb.FilesStore = failingPuts{store} |
| - writeEnv(t, nb, rt, envFileBytes(t, nb, rt)+"FOO=2\n") |
| + holdLease(t, nb, rt) |
| + writeEnv(t, nb, rt, envFileBytes(t, nb, rt)+"FOO=3\n") |
| if _, err := nb.launchEnvForTest(rt); err != nil { |
| - t.Fatalf("a later launch was held: %v", err) |
| + t.Fatalf("a later launch after a restart was held: %v", err) |
| } |
| } |
| @@ -716,39 +759,95 @@ func TestAbsentEnvNeverDeletesTheEscrow(t *testing.T) { |
| } |
| } |
| -// Two boxes publish one host: the stale one re-reads the bucket, decides |
| -// again and commits once; a second conflict in the same pass fails, named. |
| -func TestSupersededEscrowReopensOnce(t *testing.T) { |
| +// foreignCommit is another writer committing env as the host's sealed env |
| +// 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 { |
| + pub, err := hostfiles.Open(ctx, b.FilesStore, b.filesPrefix(rt.Host)) |
| + if err != nil { |
| + return err |
| + } |
| + seal, err := b.sealerFor(rt) |
| + if err != nil { |
| + return err |
| + } |
| + r, ok := pubclass.SealedPath(pubclass.Nested, rt.Host, rt.Host+".env") |
| + if !ok { |
| + return errors.New("no sealed path for the env") |
| + } |
| + if err := pub.StageSealed(ctx, r, []byte(env), seal); err != nil { |
| + return err |
| + } |
| + _, err = pub.Commit(ctx) |
| + return err |
| +} |
| + |
| +// P1-2: the lease is the authority. A box that does not hold the host's |
| +// lease never replaces its escrow with its own local bytes, in the sweep |
| +// or by a publish; the holder's do. |
| +func TestNonHolderNeverReplacesTheEscrow(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) |
| + // b's lease ends; another box takes it, serves the host and escrows B. |
| + b2 := restartEscrow(t, b) |
| + ob, ort := otherBox(t, b2, rt) |
| + holdLease(t, ob, ort) |
| writeEnv(t, ob, ort, envB) |
| mustPublish(t, ob, ort) |
| + // b still has its old local copy, and edits it: neither its sweep nor |
| + // a publish of it replaces the escrow. |
| + writeEnv(t, b2, rt, envA+"FOO=1\n") |
| + if rep := b2.EscrowSweep(ctx, []registry.Route{rt}); rep.Published+rep.Unchanged+rep.Deferred != 0 || len(rep.Failing) != 0 { |
| + t.Fatalf("the non-holder's sweep visited the host: %+v", rep) |
| + } |
| + if _, err := b2.publishEscrow(ctx, rt, nil); !errors.Is(err, errEscrowNoLease) { |
| + t.Fatalf("the non-holder's publish: %v", err) |
| + } |
| + if got := sealedItem(t, ob, ort, hostfiles.SealedEnvItem); got != envB { |
| + t.Fatalf("escrow %q, want the holder's B", got) |
| + } |
| + // A mint by the non-holder is refused too, and nothing is written. |
| + writeEnv(t, b2, rt, "OTHER=1\n") |
| + if _, err := b2.BackfillInstanceKey(ctx, rt); !errors.Is(err, ErrInstanceKeyDeferred) || !errors.Is(err, errEscrowNoLease) { |
| + t.Fatalf("the non-holder's backfill: %v", err) |
| + } |
| + if got := envFileBytes(t, b2, rt); got != "OTHER=1\n" { |
| + t.Fatalf("env %q: the non-holder minted", got) |
| + } |
| +} |
| + |
| +// Under the lease, a publisher whose baseline is stale (another writer |
| +// committed since) re-reads the bucket, decides again and commits once; a |
| +// second conflict in the same pass fails, named. |
| +func TestSupersededEscrowReopensOnce(t *testing.T) { |
| + ctx := context.Background() |
| + b, rt := escrowBackend(t, escrowHost) |
| + writeEnv(t, b, rt, envA) |
| + mustPublish(t, b, rt) |
| + if err := foreignCommit(ctx, b, rt, envB); err != nil { |
| + t.Fatal(err) |
| + } |
| writeEnv(t, b, rt, envA+"FOO=1\n") |
| if rep := b.EscrowSweep(ctx, []registry.Route{rt}); rep.Published != 1 || len(rep.Failing) != 0 { |
| - t.Fatalf("the stale box's sweep: %+v", rep) |
| + t.Fatalf("the holder's sweep: %+v", rep) |
| } |
| if got := sealedItem(t, b, rt, hostfiles.SealedEnvItem); got != envA+"FOO=1\n" { |
| t.Fatalf("escrow %q", got) |
| } |
| - // The other box publishes again, and again while this one re-reads. |
| - writeEnv(t, ob, ort, envB+"BAR=1\n") |
| - if rep := ob.EscrowSweep(ctx, []registry.Route{ort}); rep.Published != 1 { |
| - t.Fatalf("the other box's sweep: %+v", rep) |
| + // Another writer commits again, and again while this one re-reads. |
| + if err := foreignCommit(ctx, b, rt, envB+"BAR=1\n"); err != nil { |
| + t.Fatal(err) |
| } |
| var once sync.Once |
| escrowHooks.afterReread = func(host string) { |
| once.Do(func() { |
| - if err := os.WriteFile(ob.pathsFor(ort).envFile, []byte(envB+"BAR=2\n"), 0o600); err != nil { |
| + if err := foreignCommit(ctx, b, rt, envB+"BAR=2\n"); err != nil { |
| t.Error(err) |
| } |
| - if rep := ob.EscrowSweep(ctx, []registry.Route{ort}); rep.Published != 1 { |
| - t.Errorf("the other box's sweep during the re-read: %+v", rep) |
| - } |
| }) |
| } |
| t.Cleanup(func() { escrowHooks.afterReread = nil }) |
| @@ -758,7 +857,94 @@ func TestSupersededEscrowReopensOnce(t *testing.T) { |
| t.Fatalf("a second conflict: %+v", rep) |
| } |
| if got := sealedItem(t, b, rt, hostfiles.SealedEnvItem); got != envB+"BAR=2\n" { |
| - t.Fatalf("escrow %q, want the other box's", got) |
| + t.Fatalf("escrow %q, want the other writer's", got) |
| + } |
| +} |
| + |
| +// 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. |
| +func TestCompetingMintStaysRefusedAcrossWakesAndRestarts(t *testing.T) { |
| + ctx := context.Background() |
| + b, rt := escrowBackend(t, escrowHost) |
| + writeEnv(t, b, rt, "CARLOS_ADMIN_TOKEN=tok-a\n") |
| + mustPublish(t, b, rt) |
| + competing := "CARLOS_ADMIN_TOKEN=tok-a\n" + InstanceKeyVar + "=key-b\n" |
| + escrowHooks.afterCapture = func(host string) { |
| + if err := foreignCommit(ctx, b, rt, competing); 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) |
| + } |
| + 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 := sealedItem(t, b, rt, hostfiles.SealedEnvItem); got != competing { |
| + 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. |
| + 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. |
| + 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 { |
| + 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) |
| + 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]) |
| + } |
| +} |
| + |
| +// P2-6 (§9): through the real wake, a host's first launch, which mints both |
| +// secrets, reads the bucket's manifest exactly once, and a later launch |
| +// with nothing changed makes no request at all. |
| +func TestEscrowRequestBudget(t *testing.T) { |
| + ctx := context.Background() |
| + s := escrowService(t, escrowHost) |
| + cs := &countingStore{Store: s.b.FilesStore} |
| + s.b.FilesStore = cs |
| + e, err := s.wakeForTest(ctx) |
| + if err != nil { |
| + t.Fatalf("the first wake: %v\n%s", err, s.ctl.joined()) |
| + } |
| + if v := envValues(t, s.b, s.rt, "CARLOS_ADMIN_TOKEN", InstanceKeyVar); v[0] == "" || v[1] == "" { |
| + t.Fatalf("the first wake minted %v", v) |
| + } |
| + if g := cs.gets.Load(); g != 1 { |
| + t.Fatalf("the first mint read the bucket %d times, want 1", g) |
| + } |
| + s.stopForTest(e) |
| + gets, puts := cs.gets.Load(), cs.puts.Load() |
| + if _, err := s.wakeForTest(ctx); err != nil { |
| + t.Fatalf("the second wake: %v", err) |
| + } |
| + if g, p := cs.gets.Load()-gets, cs.puts.Load()-puts; g != 0 || p != 0 { |
| + t.Fatalf("an unchanged wake made %d GETs and %d PUTs, want none", g, p) |
| } |
| } |
| @@ -795,7 +981,7 @@ func (s *latencyStore) Put(ctx context.Context, key string, body []byte, ifMatch |
| } |
| // sweepRows is n eligible rows on b, each with an env file, in the |
| -// lifetime index as not HA. |
| +// lifetime index as not HA, each with its lease held by b. |
| func sweepRows(t *testing.T, b *ExecBackend, n int) []registry.Route { |
| t.Helper() |
| var rows []registry.Route |
| @@ -809,6 +995,9 @@ func sweepRows(t *testing.T, b *ExecBackend, n int) []registry.Route { |
| writeEnv(t, b, rt, "CARLOS_ADMIN_TOKEN=t"+host+"\n") |
| } |
| b.Lifetimes.Merge(recs) |
| + for _, rt := range rows { |
| + holdLease(t, b, rt) |
| + } |
| return rows |
| } |
| @@ -880,6 +1069,7 @@ func TestAFleetBoxSealsToItsOwnKey(t *testing.T) { |
| t.Fatalf("the fleet key opens %q", got) |
| } |
| other := restartEscrow(t, b) |
| + holdLease(t, other, rt) |
| other.EscrowKey = deploymentKey |
| if _, err := hostfiles.ReadSealed(ctx, b.FilesStore, prefix, m, hostfiles.SealedEnvItem, nil, sealerOf(t, other, rt)); err == nil { |
| t.Fatal("another key opened the fleet box's escrow") |
| @@ -892,3 +1082,50 @@ func TestAFleetBoxSealsToItsOwnKey(t *testing.T) { |
| t.Fatalf("launch with another key: %v; env written %v", err, exists(other.pathsFor(rt).envFile)) |
| } |
| } |
| + |
| +// holdLease takes rt's instance lease on b through the production Acquire, |
| +// as a wake does before it prepares, and gives it back when the test ends |
| +// or when the returned func is called. |
| +func holdLease(t *testing.T, b *ExecBackend, rt registry.Route) func() { |
| + t.Helper() |
| + l, err := b.Acquire(context.Background(), rt) |
| + if err != nil { |
| + t.Fatalf("acquire %s: %v", rt.Host, err) |
| + } |
| + var once sync.Once |
| + release := func() { once.Do(func() { _ = l.Release(context.Background()) }) } |
| + t.Cleanup(release) |
| + return release |
| +} |
| + |
| +// P1-4: the sweep's reads of a host's state and its report run beside a |
| +// launch's publish of the same host and beside its own workers, with no |
| +// data race (run under -race). |
| +func TestSweepRacesNoLaunchOrWorker(t *testing.T) { |
| + ctx := context.Background() |
| + b, rt := escrowBackend(t, escrowHost) |
| + writeEnv(t, b, rt, envA) |
| + rows := sweepRows(t, b, 8) |
| + for _, r := range rows[4:] { |
| + if err := os.Remove(b.pathsFor(r).envFile); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + rows = append(rows, rt) |
| + done := make(chan struct{}) |
| + go func() { |
| + defer close(done) |
| + for i := 0; i < 20; i++ { |
| + if _, err := b.publishEscrow(ctx, rt, []byte(fmt.Sprintf("%sN=%d\n", envA, i))); err != nil { |
| + t.Errorf("publish %d: %v", i, err) |
| + } |
| + } |
| + }() |
| + for i := 0; i < 20; i++ { |
| + rep := b.EscrowSweep(ctx, rows) |
| + if len(rep.Failing) != 0 { |
| + t.Fatalf("sweep %d: %+v", i, rep) |
| + } |
| + } |
| + <-done |
| +} |
diff --git a/internal/activator/hasecrets.go b/internal/activator/hasecrets.go| index 52edbd181..50ee43d84 100644 |
| --- a/internal/activator/hasecrets.go |
| +++ b/internal/activator/hasecrets.go |
| @@ -88,20 +88,28 @@ type mintGuard func(name string) error |
| // The manifest is read at most once per guard, and only when a producer |
| // would mint. |
| func (b *ExecBackend) mintGuardFor(ctx context.Context, rt registry.Route) (mintGuard, error) { |
| + return b.mintGuardWith(ctx, rt, false) |
| +} |
| + |
| +// mintGuardWith is mintGuardFor with the escrow's read chosen: fresh false |
| +// shares the read of the launch preparation in progress (escrowPrep); |
| +// fresh true, for a mint outside a launch (the backfill), reads the bucket |
| +// itself. |
| +func (b *ExecBackend) mintGuardWith(ctx context.Context, rt registry.Route, fresh bool) (mintGuard, error) { |
| ha, err := b.haHostNow(ctx, rt) |
| if err != nil { |
| return nil, fmt.Errorf("refusing to mint: %w", err) |
| } |
| - return b.mintGuardAs(ctx, rt, ha), nil |
| + return b.mintGuardAs(ctx, rt, ha, fresh), nil |
| } |
| -// mintGuardAs is mintGuardFor on an HA classification already made. |
| -func (b *ExecBackend) mintGuardAs(ctx context.Context, rt registry.Route, ha bool) mintGuard { |
| +// mintGuardAs is mintGuardWith on an HA classification already made. |
| +func (b *ExecBackend) mintGuardAs(ctx context.Context, rt registry.Route, ha, fresh bool) mintGuard { |
| switch { |
| case ha: |
| return b.haMintGuard(ctx, rt) |
| case b.escrowEligible(rt): |
| - return b.escrowMintGuard(ctx, rt) |
| + return b.escrowMintGuard(ctx, rt, fresh) |
| } |
| return nil |
| } |
| @@ -130,20 +138,23 @@ func (b *ExecBackend) haMintGuard(ctx context.Context, rt registry.Route) mintGu |
| // ensureAdminTokenFor is the launch paths' admin token producer for rt on |
| // p's layout, with the host's mint decision inside it (mintGuardFor). For |
| -// an eligible host it first restores, from the bucket, whichever escrowed |
| -// file is missing (restoreEscrowIfMissing): every launch path comes here |
| -// before it reads the env. |
| +// an eligible host it begins the launch's preparation (escrowPrep: the one |
| +// bucket read the restore and both producers share) and first restores, |
| +// from the bucket, whichever escrowed file is missing |
| +// (restoreEscrowIfMissing): every launch path comes here before it reads |
| +// the env. |
| func (b *ExecBackend) ensureAdminTokenFor(ctx context.Context, rt registry.Route, p instancePaths) error { |
| ha, err := b.haHostNow(ctx, rt) |
| if err != nil { |
| return fmt.Errorf("refusing to mint: %w", err) |
| } |
| if !ha && b.escrowEligible(rt) { |
| + b.beginPrep(rt.Host) |
| if err := b.restoreEscrowIfMissing(ctx, rt, p); err != nil { |
| return err |
| } |
| } |
| - return ensureAdminToken(p.dataDir, rt.Host+".env", p.layout == LayoutNested, b.mintGuardAs(ctx, rt, ha)) |
| + return ensureAdminToken(p.dataDir, rt.Host+".env", p.layout == LayoutNested, b.mintGuardAs(ctx, rt, ha, false)) |
| } |
| // capturedEnv is a launch's env files, read once: the own file's bytes, |
diff --git a/internal/activator/instancekey.go b/internal/activator/instancekey.go| index 755e8cbe2..bfd3555d2 100644 |
| --- a/internal/activator/instancekey.go |
| +++ b/internal/activator/instancekey.go |
| @@ -276,7 +276,8 @@ func (b *ExecBackend) BackfillInstanceKey(ctx context.Context, rt registry.Route |
| // mint would use, with verb naming which caller refused ("not minted", |
| // "not backfilled"); every other row is ensureInstanceKey on p's layout, |
| // with the bucket reader for rt and the host's mint decision |
| -// (mintGuardFor: an HA host's, or an escrowed host's). |
| +// (mintGuardWith: an HA host's, or an escrowed host's, which for the |
| +// backfill reads the bucket afresh). |
| func (b *ExecBackend) ensureInstanceKeyAt(ctx context.Context, rt registry.Route, p instancePaths, create bool, verb string) (InstanceKeyOutcome, error) { |
| if rt.Replica { |
| return InstanceKeyReplica, nil |
| @@ -285,7 +286,9 @@ func (b *ExecBackend) ensureInstanceKeyAt(ctx context.Context, rt registry.Route |
| case LayoutFenced, LayoutConflict: |
| return InstanceKeyFailed, fmt.Errorf("not %s: %s", verb, p.reason) |
| } |
| - guard, err := b.mintGuardFor(ctx, rt) |
| + // A launch's ensure (create) shares its preparation's read of the |
| + // escrow; the backfill's reads the bucket itself. |
| + guard, err := b.mintGuardWith(ctx, rt, !create) |
| if err != nil { |
| return InstanceKeyFailed, err |
| } |
diff --git a/internal/activator/rootfs_ctl_harness_test.go b/internal/activator/rootfs_ctl_harness_test.go| index 943ce1c0f..64e3c5600 100644 |
| --- a/internal/activator/rootfs_ctl_harness_test.go |
| +++ b/internal/activator/rootfs_ctl_harness_test.go |
| @@ -117,12 +117,9 @@ func newRootfsCtlHarness(t *testing.T) *rootfsCtlHarness { |
| } |
| // The agent's side: nestedBackend, build v1 staged as root stages a |
| - // rootfs image, with the manifest naming it for this box's platform, |
| - // and the files store and CARLOS_SECRETS_KEY every box has, so the |
| - // row's secrets are escrowed as in production (durability 3a). |
| + // rootfs image, with the manifest naming it for this box's platform. |
| unit := &fakeUnit{} |
| eb, _ := nestedBackend(t, &fakeControl{}, unit) |
| - eb.FilesStore, eb.EscrowKey = release.NewDirStore(t.TempDir()), testEscrowKey(t) |
| stageRootfsForBox(t, eb, "v1") |
| pointLive(t, eb, rootfsTestHost, release.VersionPath(eb.OptDir, rootfsTestAcct, "v1", rootfsTestApp)) |
| h.rt = rootfsRoute(eb) |
diff --git a/internal/activator/rootfs_test.go b/internal/activator/rootfs_test.go| index 93f25e586..fd06c9492 100644 |
| --- a/internal/activator/rootfs_test.go |
| +++ b/internal/activator/rootfs_test.go |
| @@ -36,10 +36,11 @@ const ( |
| // newRootfsBackend is nestedBackend with a rootfs image staged for |
| // shop.example.com (acme/shop v1, with a rootfs manifest sibling) and its |
| -// live link pointed at it, both rootfs gates passing, a fake unit that |
| -// goes inactive and empty once either stop verb is called, and the files |
| -// store and CARLOS_SECRETS_KEY every box has, so the row's secrets are |
| -// escrowed as in production (durability 3a). |
| +// live link pointed at it, both rootfs gates passing, and a fake unit that |
| +// goes inactive and empty once either stop verb is called. It has no files |
| +// store, so the row's secrets are not escrowed (durability 3a's pre-3a |
| +// path): these tests launch without a lease, and escrow_test.go covers |
| +// the escrow. |
| func newRootfsBackend(t *testing.T) (*ExecBackend, *fakeControl) { |
| t.Helper() |
| ctl := &fakeControl{inv: "inv1"} |
| @@ -50,7 +51,6 @@ func newRootfsBackend(t *testing.T) (*ExecBackend, *fakeControl) { |
| b.RootfsOK = func(context.Context) error { return nil } |
| b.RootfsPlacement = func(context.Context, registry.Route) error { return nil } |
| b.ControlGroup = func(context.Context, string) (string, error) { return "", nil } |
| - b.FilesStore, b.EscrowKey = release.NewDirStore(t.TempDir()), testEscrowKey(t) |
| stageRootfsImage(t, b, "v1", release.KindRootfs) |
| pointLive(t, b, rootfsTestHost, release.VersionPath(b.OptDir, rootfsTestAcct, "v1", rootfsTestApp)) |
| return b, ctl |
diff --git a/internal/host/schedule_wiring_test.go b/internal/host/schedule_wiring_test.go| index e03ebf5a2..12ab5d7a7 100644 |
| --- a/internal/host/schedule_wiring_test.go |
| +++ b/internal/host/schedule_wiring_test.go |
| @@ -13,6 +13,9 @@ import ( |
| "time" |
| "github.com/carlosframework/platform/internal/activator" |
| + "github.com/carlosframework/platform/internal/appconfig" |
| + "github.com/carlosframework/platform/internal/hostfiles" |
| + "github.com/carlosframework/platform/internal/layout/pubclass" |
| "github.com/carlosframework/platform/internal/provision" |
| "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/release" |
| @@ -283,12 +286,23 @@ func TestScheduledTickNeverMintsForAnEscrowedHost(t *testing.T) { |
| t.Fatal(err) |
| } |
| store := release.NewDirStore(t.TempDir()) |
| - rows, err := reg.List() |
| + // The escrow another box (the host's last lease holder) left: its env, |
| + // sealed to the deployment's key. |
| + prefix := activator.HibernatePrefix("", host) + "/files/0/" |
| + pub, err := hostfiles.Open(ctx, store, prefix) |
| if err != nil { |
| t.Fatal(err) |
| } |
| - if rep := escrowedTickBox(t, dd, reg, store, key).EscrowSweep(ctx, rows); rep.Published != 1 { |
| - t.Fatalf("the escrow was not published: %+v", rep) |
| + seal, err := hostfiles.NewItemSealer(key, appconfig.Binding{Account: release.RouteAccount(rt), App: rt.App}, host) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + r, _ := pubclass.SealedPath(pubclass.Nested, host, host+".env") |
| + if err := pub.StageSealed(ctx, r, []byte("CARLOS_ADMIN_TOKEN=escrowed\n"), seal); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := pub.Commit(ctx); err != nil { |
| + t.Fatal(err) |
| } |
| if err := os.Remove(nested); err != nil { |
| t.Fatal(err) |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 78d2ed417..f886a0f70 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 c82fb613f735563c494d3ceb11cf6fc377f1a4b28562d71ebb0b7b128d53b422 |
| +plan14-root-reads-durability-3a-escrow.tsv d6c281d7e095e8e0625c6199044d67dc0da559e7b4af5fbdc1a4e032bfbb65dc |
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 167ca71f2..743fc3c9d 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv |
| @@ -1,34 +1,36 @@ |
| # Census overlay durability-3a-escrow, written by census-propose (#369). census-ruling-durability-3a-escrow, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-durability-3a-escrow.md. |
| -# 8 body, 11 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 8 body, 12 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| # 3 removed: each unit's declaration, or each envelope's directory, is absent from the scanned tree, so its row goes, a frozen declaration is retired as absent, and an envelope is retired. |
| -# 38 new dispositions: 0 reads re-frozen at their disposition with the claim, 37 new units frozen accepted-legacy, 1 quiet units retired while they read nothing, 0 other. |
| +# 41 new dispositions: 0 reads re-frozen at their disposition with the claim, 40 new units frozen accepted-legacy, 1 quiet units retired while they read nothing, 0 other. |
| @legacy 88938980d11f4be9932058259d7d471b340ac51300691427ac51de62999b0f83 internal/activator/admintoken.go ensureAdminToken legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos (EnsureAdminToken, EnsureAdminTokenBeneath and ensureAdminTokenFor; the agent's scheduler token through EnsureAdminToken; no root caller found): one more parameter, guard (a mintGuard, nil for every caller but an HA host's ensureAdminTokenFor), asked once this locked read has found no token and before anything is minted; its refusal is returned with nothing written. The read, mode check, shape check and mint are unchanged; the same four sites, no read added; only adds a refusal;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: the guard is now asked with the variable it would mint, guard("CARLOS_ADMIN_TOKEN"), still only once this locked read found no token and before anything is minted; its refusal is returned with nothing written. The read, mode check, shape check and mint are unchanged; the same four sites; only adds a refusal file:Lstat@1864,file:OpenFile@4464,file:Read@4101,file:ReadFile@433 cf06e83cc0e322792272d3a10b6b2478cac66973acfd2ac3faf8497a2b6eb61b |
| @legacy 3b34d3f4313e6a6e9b96b37e3eee744d3574f6d523bd329f750f1cd245a0e22b internal/activator/claim_snapshot.go ExecBackend.EnsureClaimAdminToken legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, inside the claim's authorize callback: the missing-token mint is now ensureAdminTokenFor(ctx, rt, paths) instead of ensureAdminTokenAt(paths, rt.Host+".env") (deleted); both pick the beneath (instancefs) producer on the nested layout and the path one otherwise, on the same file; the new one also asks an HA host's mint decision (haMintGuard) at the moment it would mint. The separate haMintGate call of the first proposal is gone (final fix F2). Sites: -registry:Host (the rt.Host+".env" argument) and +whole:Route (rt to ensureAdminTokenFor); only adds a refusal for an HA host;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: a comment names mintGuardFor instead of haMintGuard; the body is unchanged registry:Host@2644,registry:Replica@1285,whole:Route@1363,whole:Route@2016,whole:Route@212,whole:Route@2307,whole:Route@2571,whole:Route@285,whole:Route@347 4a5935d18fe04a5f73170a32bdcb46f9996eacca5602ba108b408e2f4254fa79 |
| @legacy 27c808de21de2d81ab651428b0e177ba93a21a86a5d5d47f7901fbd768e773a6 internal/activator/hasecrets.go Service.fillScheduledToken legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: sets the tick's Authorization header from haScheduledToken for an HA host; any other host's request is untouched; +whole:Route;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: asks escrowedScheduledToken (was haScheduledToken), so an escrowed host (HA, or eligible for escrow) gets its tick's Authorization header from the env file its wake restored or minted; any other host's request is untouched; the same one site whole:Route@215 8d7bdf5e155a74ca9f667c4ebc21a4a7df571740d0f81ef5e77bc86bffd9cbe0 |
| @legacy e60987732b032e682e6d78218e85625829d80ab8767d9575efeaee130e8b9830 internal/activator/instancekey.go ExecBackend.BackfillInstanceKey legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: back to main's body bar a comment: it calls ensureInstanceKeyAt as before, and an HA host's mint decision now lives inside that producer (haMintGuard, final fix F2); the agent's backfill skips HA hosts before this (instancekeys.go); the one +whole:Route of the first proposal is gone; no read added;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: comment only (the escrowed host's mint decision inside ensureInstanceKeyAt); the body is unchanged whole:Route@385,whole:Route@400 b65f3ce46f53cc9cc6679f490ff31684bc96c5d8d86c337c3c151cb11a480a4b |
| -@legacy 85176dc4dda1720ee88bdc1f60f6d4cab2f2faedad52d6803082852f3b531284 internal/activator/instancekey.go ExecBackend.ensureInstanceKeyAt legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: after the unchanged replica and fenced/conflict checks, asks haMintGuard(ctx, rt) (+whole:Route) and hands the guard to ensureInstanceKey; a classification error fails with InstanceKeyFailed; a non-HA host gets a nil guard and mints exactly as before; only adds a refusal;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: asks mintGuardFor(ctx, rt) (was haMintGuard): an HA host's guard as before; an eligible host's escrowMintGuard, which on a ready box reads the bucket manifest and the sealed env item when a mint is next and refuses while the escrow holds the key, and on a box that is not ready refuses every mint; nil for any other host, which mints as before. The replica and fenced/conflict refusals are unchanged; only adds refusals registry:Host@468,registry:Replica@159,whole:Route@370,whole:Route@537 dc2078aa188d2ae4c0ef505b3863b8b9e450b38c0aa6be83087073824659af97 |
| +@legacy 4959fc931f2d6af0dd7a80d6f75b3eef14b502750ebd38e15ba1a5fdf50f95bf internal/activator/instancekey.go ExecBackend.ensureInstanceKeyAt legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: after the unchanged replica and fenced/conflict checks, asks haMintGuard(ctx, rt) (+whole:Route) and hands the guard to ensureInstanceKey; a classification error fails with InstanceKeyFailed; a non-HA host gets a nil guard and mints exactly as before; only adds a refusal;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: asks mintGuardFor(ctx, rt) (was haMintGuard): an HA host's guard as before; an eligible host's escrowMintGuard, which on a ready box reads the bucket manifest and the sealed env item when a mint is next and refuses while the escrow holds the key, and on a box that is not ready refuses every mint; nil for any other host, which mints as before. The replica and fenced/conflict refusals are unchanged; only adds refusals Fix round 1: asks mintGuardWith(ctx, rt, !create): a launch's ensure shares its preparation's escrow read, the backfill's reads the bucket afresh; only refuses. registry:Host@598,registry:Replica@159,whole:Route@491,whole:Route@667 5605bd1a4441859415f51b50c38e959987b2524fa8ccbec7364949e7097e9770 |
| @legacy 62f2a51b33e98d5e15741fab9c6b9bbbb96a36846290bdc71800b28ac23dee51 internal/activator/instancekey.go ensureInstanceKey legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more parameter, guard (nil for every caller but ensureInstanceKeyAt on an HA host), asked once the locked read finds no key and the bucket allows a mint, before anything is minted; its refusal returns InstanceKeyFailed with nothing written. Create-only, fail-closed and defer-on-unknown are unchanged; the one site unchanged, no read added; only adds a refusal;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: the guard is asked with InstanceKeyVar, at the same point (the locked read found no key and the bucket allowed a mint); create-only, fail-closed and defer-on-unknown unchanged; the same one site; only adds a refusal file:Stat@4816 2d53f8246ac317c066d4b804cdc251aaf60abbd4423c6b780f0cbee227203fc8 |
| @legacy 2106e0d304d6aa9b8426ae43bd49dd44a18c101e7bed4a8d496dc3cdeb94ef3a internal/hostfiles/restore.go Restore legacy accepted-legacy accepted-legacy;rev3=merge-ruling-2;basis=Restore delegates to shared descriptor-root implementation; generic payload restoration remains legacy.;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: passes nil for restore's new baseline argument; the one site unchanged, nothing else changed;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3 fix round 1: passes nil for restore's new shadowed argument, so it fetches, writes and removes exactly what it did; the same reads. restore gains that argument (a caller's Shadowed func over the manifest it has already read and validated): a live entry it names, after the overlap rule, is skipped before any fetch and reported in RestoreStats.Shadowed. It only leaves things out; nothing new is opened, read or followed. RestoreRootBaselineShadowed is new, RestoreRootBaseline is it with nil. file:OpenRoot@219 6a3b0e25de6d9ff6e644810d70a7056840e6cca7fa72db98542f990d4598fd30 |
| -@legacy 3d6a1339968412a2108292847715e8c919284defb13ebf3868d94a0f60d25e1e internal/activator/escrow.go ExecBackend.EscrowSweep legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new, the agent as carlos (carlos-edge.service), no root caller, from escrowLoop: classifies each row against the rows handed in (Classify), keeps eligible rows known not HA from memory (haKnown, no read), and in host order from a round-robin cursor stats each escrowed file (stampAt) and publishes the changed ones, 8 at a time, at most 256 a sweep (sweepPublish); a box without a files store or key does nothing; opens nothing outside the rows' own data directories; writes only the hibernate bucket's files/0 prefix and the ledger registry:Host@1062,registry:Host@1533,registry:Host@1878,registry:Host@2132,registry:Host@2206,registry:Host@535,registry:Host@748,registry:Host@892,registry:Host@911,whole:Route@1071,whole:Route@1407,whole:Route@1535,whole:Route@1765,whole:Route@1880,whole:Route@2134,whole:Route@2208,whole:Route@355,whole:Route@518,whole:Route@586,whole:Route@652,whole:Route@705,whole:Route@793,whole:Route@797,whole:Route@814,whole:Route@901,whole:Route@920 d1fd70859e6560c8587597bb3d47f18c9989a2d9746c94964fd8d5db9028f449 |
| +@legacy 64a0a282f5729c49a65c572b8af2c81c58ae0edff176220c0ddf892be8b27204 internal/activator/escrow.go ExecBackend.EscrowSweep legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new, the agent as carlos (carlos-edge.service), no root caller, from escrowLoop: classifies each row against the rows handed in (Classify), keeps eligible rows known not HA from memory (haKnown, no read), and in host order from a round-robin cursor stats each escrowed file (stampAt) and publishes the changed ones, 8 at a time, at most 256 a sweep (sweepPublish); a box without a files store or key does nothing; opens nothing outside the rows' own data directories; writes only the hibernate bucket's files/0 prefix and the ledger Fix round 1: a host whose instance lease this box does not hold (holdsLease) is skipped, and one with a conflict marker counts as failing and is not published; the report is tallied through one lock (P1-4). registry:Host@1079,registry:Host@1098,registry:Host@1249,registry:Host@1782,registry:Host@2128,registry:Host@2385,registry:Host@2459,registry:Host@536,registry:Host@761,registry:Host@795,registry:Host@833,registry:Host@923,whole:Route@1001,whole:Route@1088,whole:Route@1107,whole:Route@1258,whole:Route@1576,whole:Route@1784,whole:Route@2014,whole:Route@2130,whole:Route@2387,whole:Route@2461,whole:Route@356,whole:Route@519,whole:Route@587,whole:Route@653,whole:Route@706,whole:Route@980,whole:Route@984 c3067eb671bdbba75100a0398840a1c293fb55b777e155703169d3ae2e71ccd2 |
| @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 0ab2dd17dea3754691ac8bed21e555038c8700c717ecc9e4e3b0cd1ef53bef8f internal/activator/escrow.go ExecBackend.bucketEscrowEnv legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: one hostfiles.Load of the host's files manifest in the hibernate bucket, then escrowEnvOf; the agent as carlos (carlos-edge.service), no root caller registry:Host@127,whole:Route@358 0e1683e265e25c20e20153f95b1ab53eb4300aac67330f1d0696a8df5dccff0b |
| -@legacy e541a6308548d373f0855f95de152231cdf1127c4069030a631098239aca9447 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 registry:Host@122,registry:Host@353 3fa0f583f17ffe65a8ee334139a90a0a3c96ae40764b0ff12ab4a3e735831520 |
| +@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 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 4d61ab07852c1855e1d763b3a93f42a1f6f1a796df2f3dd3d0ba725873bbff29 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. registry:Host@1224,whole:Route@113,whole:Route@197,whole:Route@279,whole:Route@514,whole:Route@776 3e914cc96c915529e0c322572e62a5a67fc0528a06ee6514541aa492ce50be1f |
| +@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 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 3ff2ef7cd3271d7327d344768855f6f806dc4b09cad4c5ef9250b14d0ddc0770 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 file:Open@284,registry:Host@122,registry:Host@1394,registry:Host@332,registry:Host@520,registry:Host@925,whole:Route@193,whole:Route@810 81436a987e2a08d1290ebb30cfb0c63e7b42466ab2dd2a9f318697b18937b8fe |
| -@legacy b62bbc256140c64ab4f837b8ab1b5a7b39da7ca33b8c17c0a4f209c319621a4b 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. registry:Host@1188,registry:Host@1273,registry:Host@1441,registry:Host@1643,registry:Host@1905,registry:Host@2066,registry:Host@2251,registry:Host@2372,registry:Host@2546,registry:Host@2762,registry:Host@391,registry:Host@437,registry:Host@540,registry:Host@758,registry:Host@869,whole:Route@1056,whole:Route@1095,whole:Route@1321,whole:Route@1550,whole:Route@179,whole:Route@1808,whole:Route@1968,whole:Route@207,whole:Route@250,whole:Route@314,whole:Route@364,whole:Route@587,whole:Route@639,whole:Route@927 dd7eed18e97f32155348bacb8a49cf44b77963756f75254788c0a520f6f1145d |
| +@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 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 2587e3150f1a9419ddd6dec519ae86f3ea25d3af12c14f2f8cb261a0a2eac3bf internal/activator/escrow.go ExecBackend.keylessEscrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 0: new, on a box with a files store and no sealing key: hostfiles.Load of the host's files manifest in the hibernate bucket (one GET), true when it holds any sealed item or the cutover marker (manifestEscrowed); the answer is kept in memory and reused within haSecretsBudget only for refusals and launches, a mint reads again; a failed read is an error and the caller refuses; the agent as carlos (carlos-edge.service), no root caller registry:Host@128,registry:Host@396 9c404de03d0b6d4a6f8945919190309f303da2f09b87e6a77899c63300f471ea |
| -@legacy 5f8d31b1db375a8c123a14e6bba1f641e7691aaae538be3c2616707eca4b3211 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 file:Open@753,registry:Host@528,registry:Host@600,whole:Route@415 8e3c6c1f3e88b7d6681df4b8be74508386172b1a7b88c308d18511509a3af991 |
| +@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 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 05a44197ac3ebe3fb4402d2153442bf4f578be3cfbae0bbea4ea7a7aff67a4f8 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 registry:Host@223,registry:Host@331,registry:Host@428,whole:Route@157,whole:Route@508 726dfaf89eaf2a1a13a1b0492ffe4582dbc43ca816821d488d5dcca53bda6f33 |
| -@legacy 5308584fd1521a1ede129be626cb25ecebdf2cf2c3a02c0036d09e6a159ac7c8 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 registry:Host@2175,registry:Host@2439,registry:Host@3454,registry:Host@3602,registry:Host@589,whole:Route@2366 18edc91e27cadfdb73cd23e3c45b71350239c1d3f0a109a87b49e6fa2b7f8f35 |
| -@legacy a909f0d37bf1b4f77c9d218c79b454ecbbe98bcdfccc7511bebc0a8f250d03a7 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. file:Open@1662,registry:Host@1345,registry:Host@1519,registry:Host@267,registry:Host@2749,registry:Host@788,registry:Host@833,registry:Host@936,whole:Route@1012,whole:Route@1167,whole:Route@1416,whole:Route@594,whole:Route@635,whole:Route@725 e24cb07f81da9026c269ab9de76cb0d64761ba5e2a2fc5fbe1c1d73cdc600b8b |
| +@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 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 |
| @@ -38,20 +40,22 @@ |
| @legacy c245f49a65e276d889e7a0f23f4a7b1571e18d401107dd9ff5fec5c664a758a9 internal/activator/escrow.go stampAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the same open as readStamped and its fstat; reads no bytes file:Stat@240 fe3fb1c14a5391f9cedeb4e2885145766bd1349c902bc68e5e344973b87d6342 |
| @legacy 8cac704f54ddfe06f00165aec337a93f0540c990d0f353d1379c9adacb464d86 internal/activator/hafiles.go ExecBackend.sealerFor legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: new. Builds the host's hostfiles.ItemSealer from the backend's EscrowKey (the box's own CARLOS_SECRETS_KEY, set once by runAgent) and the binding {release.RouteAccount(rt), rt.App} for rt.Host (NewItemSealer validates the account, app and host shape); nil key is an error. Pure in memory: opens, reads and writes nothing. registry:App@334,registry:Host@343,whole:Route@324 0225e79c376c0bad00460a6b520b3f9f0cdf2468a0319f2370e0aa3fb6af091a |
| @legacy 3776ba6d99d1d80c0219c28ed00502edf5e94e1757b52ff79164e32707fc10ed internal/activator/hasecrets.go ExecBackend.escrowedScheduledToken legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: renamed from haScheduledToken and widened to escrowed hosts (SecretsEscrowed): reads CARLOS_ADMIN_TOKEN from the host's env file with instancefs.ReadBeneathLimit (1 MiB, no link followed) after the wake; a host that is not escrowed reads nothing; the token is sent only to that same instance's tick; the agent as carlos (carlos-edge.service), no root caller whole:Route@150,whole:Route@231 27b746b71bb8750c5016f183a244374c6a62d9bd65243a326e4765b78d2f53ef |
| -@legacy d69111be325117bd771e7e8d47817783f8425b8f2f0013808fe30bbb1847f8ec internal/activator/hasecrets.go ExecBackend.mintGuardAs legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: an HA host's haMintGuard, an eligible host's escrowMintGuard, else nil; reads nothing itself; only refuses whole:Route@143,whole:Route@170,whole:Route@207 55d8c88e3bde3ed19a376d4ebc3c1d0a8754e2773dfef8e827a8c8ca0dc8ae07 |
| -@legacy f33564476352d194269a8c8e0e01e3a5dfc3cbf1829ae0d68525bc53d1137e52 internal/activator/hasecrets.go ExecBackend.mintGuardFor legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the one mint decision, replacing haMintGuard as the entry point: classifies the host (haHostNow; an error refuses) and returns mintGuardAs; the agent as carlos (carlos-edge.service), no root caller; only refuses whole:Route@125,whole:Route@230 6649b6fff34ca16bbca2db45f20dce04445fc7939405d167341ac0e9b8584955 |
| +@legacy 2cfc4d200b4c65c1141e71c538fd077e746998e4f0bc1e8a2a7f84a80f6521f8 internal/activator/hasecrets.go ExecBackend.mintGuardAs legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: an HA host's haMintGuard, an eligible host's escrowMintGuard, else nil; reads nothing itself; only refuses Fix round 1: passes fresh to escrowMintGuard (shared preparation read, or the bucket afresh). whole:Route@150,whole:Route@177,whole:Route@214 efafd010f153c8c201a4711a25fb8b52a5aeab34dc2148d960308a4a872b5169 |
| +@legacy 376c542a31900481212564de0653fc3ed8a8ae48f87ec3faca0f0f209a50cb9f internal/activator/hasecrets.go ExecBackend.mintGuardFor legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the one mint decision, replacing haMintGuard as the entry point: classifies the host (haHostNow; an error refuses) and returns mintGuardAs; the agent as carlos (carlos-edge.service), no root caller; only refuses Fix round 1: mintGuardWith(ctx, rt, false); the classification moved there. whole:Route@125 5ada4c3f9dc1dceaf754b994c289bd16369f673760e087b51ab0d32950d28328 |
| +@legacy 17b002004c842fbe6952fcc2d3de28aec81cf205152725f34e59fc553f49d0af internal/activator/hasecrets.go ExecBackend.mintGuardWith legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 1: new: classifies the host (haHostNow; an error refuses) and returns mintGuardAs with fresh; only refuses whole:Route@138,whole:Route@243 c32deadc5f476734f4329408f50a05805916e75b63c6c77bc6f3e9e0f42c2ed2 |
| @legacy 623c58c5cf88654e04499341225382bfb6b7f07e49ca763e9ce4fbb31bfe8f7f internal/activator/hasecrets.go SplitBackend.escrowedScheduledToken legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: renamed from haScheduledToken: dispatches to the row's half, else not escrowed whole:Route@130,whole:Route@206 9a25668abc3fd7f8d4a6ea5dc39cb1b2e75f1b97a0dbfd42497c2ece607a5cce |
| @legacy 5825654920a12495d5b2468c38cd93710b069032054ea4a1b46e8e4c7677acf3 internal/activator/paths.go ExecBackend.pathsAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: pathsFor's former body, unchanged, taking a classification already made (the escrow sweep classifies every row against the one list it was handed); reads +registry:DBPath, +registry:Host x7 exactly as pathsFor did registry:DBPath@596,registry:Host@257,registry:Host@508,registry:Host@568,registry:Host@675,registry:Host@725,registry:Host@782,registry:Host@846 1b6ac30aeed48d9818da84b8c8638a3931a40af3d47821afac2c90a690206f61 |
| @legacy 957ad5d3377cd8a74a394858b4836b46d318fbaa7b3a3ac2c102c9b010f75ac4 internal/host/escrow_loop.go escrowLoop legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: every activator.EscrowEvery (30 s) lists the registry and runs svc.EscrowSweep over the rows; logs failures and deferrals; returns with no registry or no Service; the agent as carlos (carlos-edge.service), no root caller whole:Route@426 498f5efdf374f9c35ca954f845507ce3c8db25e9b766f873c3acf23ec2f7cb05 |
| @legacy 57d643b797aeddcfb4e30175e92072cd6d1cad46c442bf44ecb0f821d74ecafd internal/host/schedule_wiring.go scheduleHostEscrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: scheduleHostHA renamed: reads the host's row (reg.Get) and asks svc.SecretsEscrowed (HA, or eligible for escrow) with a 10 s timeout; false with no registry or no row; for such a host scheduleToken only reads the existing env token ("" when none) and never mints (EnsureAdminToken skipped); the agent as carlos (carlos-edge.service), no root caller whole:Route@254,whole:Route@413 1a608f98d348d9183088ff4f04742c30467a116f0071358ce479e1dff5e20eeb |
| @legacy 51297417f7d25f895c3793014740994855e599bf8731cf3295ea836820ae4f13 internal/hostfiles/sealed.go ReadSealed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 2: new. Reads one sealed platform item of a files manifest the caller already loaded: the object at exactly the key the entry names, through the existing fetch (checkEntry: origin admitted, key shape, sha256 and size verified), only for an entry marked sealed "v2". The "Open" the scanner sees is appconfig.Open, an in-memory AES-GCM decryption of the fetched bytes, not a file open: no filesystem path is opened, read or followed. It refuses a v1 envelope (appconfig.EnvelopeBound), and after opening under the caller-supplied key and (account, app) binding it checks the HMAC digest over account, app, host and item against the entry. Writes nothing. No production caller in this task; Tasks 3 and 4 call it from the activator. file:Open@898 7c2b887b6e0b45472fd8d1a63a2b78eb565c4e93c89cb329eeeaef429ab0b010 |
| @legacy 7520abf7fe01442d3fcca5cc9c46cd22346ae2ad193162ed8df7ba9371914028 internal/layout/inventory.go Inventory legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 1: new. One os.ReadDir of the host's inventory root, provision.InstanceDir(dataDir, host) nested or dataDir flat, after refusing a host that fails controlname.ValidHostShape and a layout that is neither flat nor nested; reads only the listing's names and types (DirEntry.IsDir), opens and follows nothing; flat ownership is the extras scan's own (hostEntries over knownHosts); each top-level name is classified by pubclass.Of, a pure function of the name. A missing directory is an empty inventory. No caller in this task; later tasks call it from the publisher. file:ReadDir@449 9662e465abb7f9c60e908952740384479009c9987c8a6ae65d98fb19cb3d4d7e |
| +@legacy 3548edf2cc46b90278c03f0a5dedc4ed353279e08b2e5ef1a81cca61a94b3639 internal/activator/backend_exec.go ExecBackend.Acquire legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: after the unchanged AdmitConfig gate, the lease acquire moves into acquireClassified (hawake.go, a new unit): a legacy route or a non-HA host takes the same lease.Acquire as before and maps a held lease to errLeaseHeld as before (leaseError); an HA host goes through the containment admission and lease.AcquireHA. A successful acquire marks the host acquiredHere for the process (same-box recovery). The config gate is not weakened; the same three sites, no read added;rev3=census-ruling-durability-3a-escrow;basis=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 registry:Host@1001,registry:Host@807,whole:Route@382,whole:Route@764 ff41146bbb0f1c3fac6a0f34f41540d7dbb036234f490841dca0e23d23b1c99c |
| @legacy 0aa879d05dedfa2a097504534e62f3637c77470bf70177df6f32efcc9b051965 internal/activator/hafiles.go ExecBackend.newHostFiles legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: builds a hostFiles publisher for rt (its instance paths from pathsFor(rt), rt.Host, the backend's registry, the 1 s platform and 15 min snapshot cadences); +registry:Host, +whole:Route; no I/O;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: now also sets the publisher's sealer (sealerFor(rt); its error is returned and nothing is built) and its skip, pubclass.FilesDirSkip(Nested, rt.Host), a pure function of the name, so every tree pass publishes only App paths and never the trio raw. Still no I/O; the new +registry:Host and +whole:Route sites are the sealer's and the classifier's arguments. registry:Host@228,registry:Host@313,whole:Route@128,whole:Route@217 69d03f586dc59cbc9555cc79b34d024854359b8d2a3d9ae0625ae5e8a4ad0a52 |
| @legacy 9575d7fd08d19a1422bf49b03160394ab13436e5ca4bc4259c5faa14f0362147 internal/activator/hafiles.go ExecBackend.openHostFiles legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: the entry's files publisher: refuses without a FilesStore or outside the nested layout, takes the one this wake's restore staged, else hostfiles.Open on <hibernate prefix>/files/0/ (one GET of the manifest from the hibernate bucket, the scanner's +file:Open); +registry:Host x2, +whole:Route x2; the manifest is written by the agents of the boxes that hold the host, through the same files store;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: asks sealerFor before hostfiles.Open, so a box without an escrow key refuses before it reads the manifest; newHostFiles's error is returned. The same manifest GET otherwise; the new +whole:Route site is sealerFor's argument. Opens nothing new. file:Open@521,registry:Host@342,registry:Host@569,whole:Route@198,whole:Route@469,whole:Route@640 f193b187884a24cd093cc19e08ad77be581005ac84c746cef8db52f1beb8dbe8 |
| @legacy 7150dace5e7f9f29faeb2e6a78df22881534291b9d66006194d90c769082a772 internal/activator/hafiles.go ExecBackend.stageKeptFiles legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: on a kept wake, reads the manifest baseline the release kept beside its local record (<db>.release.files.json via readFilesBaseline, capped at 32 MiB, O_NOFOLLOW, regular files only) and stages a publisher on it only when its revision (Gen, which carries the body's SHA-256) equals the files_gen in the lock's release marker; the file is on ground the tenant can write, and anything that does not match stages nothing, so the entry re-reads the manifest from the store; it never decides the keep; +registry:Host x4, +whole:Route x2;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: newHostFiles now answers an error (no escrow key), which is logged and stages nothing, as an OpenBaseline failure already did. The same baseline read; nothing new opened or read. registry:Host@254,registry:Host@344,registry:Host@508,registry:Host@627,registry:Host@673,whole:Route@151,whole:Route@560 d740082bbfda130c1b0b8e71dae3ff9804dbf36131bc659d147d3d41921674d2 |
| @legacy cdd0c029924e783aa6acc1b26a6bf4b91e038511acdd5291a7dd1ca39c81c734 internal/activator/hafiles.go ExecBackend.stageWakeFiles legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: opens a publisher on a manifest baseline the HA restore already holds (hostfiles.OpenBaseline, no read) and keeps it for the wake's entry; without a FilesStore it stages nothing; +registry:Host x3, +whole:Route;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: newHostFiles now answers an error (no escrow key), which is logged and stages nothing, as an OpenBaseline failure already did. No read, as before. registry:Host@185,registry:Host@300,registry:Host@419,registry:Host@465,whole:Route@352 2a9b49c4cdd022038db91a72126a31c4b0c7e81de038f9c57747522136aa361a |
| @legacy a6b323044a9dccb625ae9031b92980454070a102ef5ebd4ac2efc953dec64ea6 internal/activator/hasecrets.go ExecBackend.captureLaunchEnv legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new (final fix F2), the agent as carlos: reads an HA launch's own env file and its rendered config env once, the way instanceEnvParts does: on the nested layout through instancefs.ReadBeneathLimit (1 MiB, no link followed), otherwise os.ReadFile (the +file:ReadFile site; an HA host is nested by its acquire's containment admission, so this arm is the flat layout's, where the files are in the agent's own data directory); an absent own file is an error, an absent config is not; parses env and key layer from those bytes; +whole:Route;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: the flat arm's os.ReadFile (-file:ReadFile) is gone: both layouts read the own env file and the rendered config env with instancefs.ReadBeneathLimit beneath the row's data directory (openat2, no symlink, regular files only, 1 MiB), so an escrowed flat row's capture never follows a link at <host>.env; an absent own file is an error, an absent config is not; the agent as carlos (carlos-edge.service), no root caller; only narrows a read whole:Route@98 223e1b2f98aea8bb39f65573bcff0e6d05bb8cd2f55cd43670ca8ba6f1d33299 |
| -@legacy eec095b52a2f7f87129413c96c40f432f73d9466ddd3603ed119342a00e57226 internal/activator/hasecrets.go ExecBackend.ensureAdminTokenFor legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new (final fix F2), the agent as carlos: the launch paths' admin-token producer: haMintGuard(ctx, rt), then ensureAdminToken on <dataDir>/<host>.env, beneath on the nested layout and by path otherwise, with that guard; +registry:Host, +whole:Route; a non-HA host's guard is nil and the producer is the one it used before;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: classifies the host once (haHostNow), and for a host that is not HA and is eligible for escrow first calls restoreEscrowIfMissing (a new unit on this card), then ensureAdminToken with mintGuardAs's guard; an HA host's path is as before; any other host's guard is nil as before; +whole:Route x3 (the row handed on); the agent as carlos (carlos-edge.service), no root caller registry:Host@363,whole:Route@136,whole:Route@237,whole:Route@285,whole:Route@424 441f7edc805241c0ad28db809b149e94009ce82989202235e7fbe127f69932b0 |
| +@legacy 5ca337f30874aae92def93eca1e09c58a4dbc8a85e671df0b4e08fdd14dafd43 internal/activator/hasecrets.go ExecBackend.ensureAdminTokenFor legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new (final fix F2), the agent as carlos: the launch paths' admin-token producer: haMintGuard(ctx, rt), then ensureAdminToken on <dataDir>/<host>.env, beneath on the nested layout and by path otherwise, with that guard; +registry:Host, +whole:Route; a non-HA host's guard is nil and the producer is the one it used before;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: classifies the host once (haHostNow), and for a host that is not HA and is eligible for escrow first calls restoreEscrowIfMissing (a new unit on this card), then ensureAdminToken with mintGuardAs's guard; an HA host's path is as before; any other host's guard is nil as before; +whole:Route x3 (the row handed on); the agent as carlos (carlos-edge.service), no root caller Fix round 1: begins the launch's preparation (beginPrep) before the restore, and passes fresh false to the guard. registry:Host@257,registry:Host@386,whole:Route@136,whole:Route@237,whole:Route@308,whole:Route@447 581b4132ee9f3bbb900b5c467c02596502b0232575a8beacd198419469eb4e3c |
| @legacy c39b6a8c39e51f6c93ab4c36c0b3c33765a0f41cd9770e03217c0c3d3b019c63 internal/activator/hasecrets.go ExecBackend.haMintGuard legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new (final fix F2), the agent as carlos, replacing haMintGate: nil for a host that is not HA; for an HA host a guard that, asked only from a producer's missing-secret branch, reads once whether the host's files manifest exists (haManifestFound) and refuses with ErrInstanceKeyDeferred while it does (or on a read error); it never reads the env; +whole:Route x2; only refuses;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: now only the HA arm of mintGuardFor: the same once-per-guard haManifestFound read and the same ErrInstanceKeyDeferred refusal, the name ignored; the HA classification moved to mintGuardFor (-whole:Route); only refuses whole:Route@220 7218a4d3a064c04bca0bdccec25c2934974b926a5af657a156cd0ca8498b586d |
| @legacy 192df384d784a7d1ac579802fd8ad96206ff78ee8164d09ab6e8093b968602ba internal/activator/hasecrets.go ExecBackend.haSecretsReady legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: before an HA host's launch, checks that env, the bytes the launch captured (captureLaunchEnv; a new parameter, final fix F2), has the SHA-256 of the committed manifest's env item (envAcknowledged, which now reads no file); else publishes the platform items (env, trio, wake state) through the wake's, the entry's or its own publisher (hostfiles.Open, the +file:Open site: one manifest GET) and checks again, so an env replaced after the capture is committed as other bytes and fails the launch; it no longer classifies the host itself (launchEnvLayer has); every error fails the launch; +file:Open, +registry:Host x3, +whole:Route;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: asks sealerFor before its own hostfiles.Open (a box without an escrow key fails the launch before any read), and newHostFiles's error fails the launch. envAcknowledged now compares the sealed env item's keyed digest (hostfiles.SealedAcknowledged, no read) instead of the raw env item's SHA-256. The publish it triggers stages the trio sealed: <host>.env, <host>/instance.key and <host>/report.token are each read with instancefs.ReadBeneathLimitOrAbsent beneath the instance directory (openat2, no symlink, regular files only, 1 MiB cap), the same reader the env already used, then sealed in memory; nothing else is opened. file:Open@390,registry:Host@1187,registry:Host@120,registry:Host@438,whole:Route@294,whole:Route@559 4f4584786d3f90a54aa3ddc1c39ffed8a62fcfd593127f534bea787c3d9b7829 |
| @legacy 82fe6cb6c8b941f11795972ab352bc2c63c42602f18f73b275869339964498a1 internal/activator/hasecrets.go ExecBackend.launchEnvLayer legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new (final fix F2), the agent as carlos: a launch's env and key layer: classifies the host (haHostNow; an error fails the launch), instanceEnvLayer unchanged for a non-HA host; for an HA host captureLaunchEnv once, haSecretsReady over those bytes, a test seam (haLaunchHooks.afterPublish, nil in production), and returns the env parsed from the captured bytes, never a later read; +registry:Host x3 (the error messages), +whole:Route x4;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: for a host that is not HA and is eligible for escrow, escrowedLaunchEnv (a new unit on this card) instead of instanceEnvLayer; the HA and other paths unchanged; +whole:Route x2; the agent as carlos (carlos-edge.service), no root caller registry:Host@245,registry:Host@499,registry:Host@644,whole:Route@154,whole:Route@294,whole:Route@335,whole:Route@371,whole:Route@408,whole:Route@549 35a5150b24c33e81e5d536bb072c62ab55fd583187d83293e644d3599496a99a |
| @@ -61,30 +65,32 @@ internal/activator/admintoken.go ensureAdminToken legacy accepted-legacy accepte |
| internal/activator/claim_snapshot.go ExecBackend.EnsureClaimAdminToken legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, inside the claim's authorize callback: the missing-token mint is now ensureAdminTokenFor(ctx, rt, paths) instead of ensureAdminTokenAt(paths, rt.Host+".env") (deleted); both pick the beneath (instancefs) producer on the nested layout and the path one otherwise, on the same file; the new one also asks an HA host's mint decision (haMintGuard) at the moment it would mint. The separate haMintGate call of the first proposal is gone (final fix F2). Sites: -registry:Host (the rt.Host+".env" argument) and +whole:Route (rt to ensureAdminTokenFor); only adds a refusal for an HA host;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: a comment names mintGuardFor instead of haMintGuard; the body is unchanged registry:Host@2644,registry:Replica@1285,whole:Route@1363,whole:Route@2016,whole:Route@212,whole:Route@2307,whole:Route@2571,whole:Route@285,whole:Route@347 4a5935d18fe04a5f73170a32bdcb46f9996eacca5602ba108b408e2f4254fa79 |
| internal/activator/hasecrets.go Service.fillScheduledToken legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: sets the tick's Authorization header from haScheduledToken for an HA host; any other host's request is untouched; +whole:Route;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: asks escrowedScheduledToken (was haScheduledToken), so an escrowed host (HA, or eligible for escrow) gets its tick's Authorization header from the env file its wake restored or minted; any other host's request is untouched; the same one site whole:Route@215 8d7bdf5e155a74ca9f667c4ebc21a4a7df571740d0f81ef5e77bc86bffd9cbe0 |
| internal/activator/instancekey.go ExecBackend.BackfillInstanceKey legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: back to main's body bar a comment: it calls ensureInstanceKeyAt as before, and an HA host's mint decision now lives inside that producer (haMintGuard, final fix F2); the agent's backfill skips HA hosts before this (instancekeys.go); the one +whole:Route of the first proposal is gone; no read added;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: comment only (the escrowed host's mint decision inside ensureInstanceKeyAt); the body is unchanged whole:Route@385,whole:Route@400 b65f3ce46f53cc9cc6679f490ff31684bc96c5d8d86c337c3c151cb11a480a4b |
| -internal/activator/instancekey.go ExecBackend.ensureInstanceKeyAt legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: after the unchanged replica and fenced/conflict checks, asks haMintGuard(ctx, rt) (+whole:Route) and hands the guard to ensureInstanceKey; a classification error fails with InstanceKeyFailed; a non-HA host gets a nil guard and mints exactly as before; only adds a refusal;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: asks mintGuardFor(ctx, rt) (was haMintGuard): an HA host's guard as before; an eligible host's escrowMintGuard, which on a ready box reads the bucket manifest and the sealed env item when a mint is next and refuses while the escrow holds the key, and on a box that is not ready refuses every mint; nil for any other host, which mints as before. The replica and fenced/conflict refusals are unchanged; only adds refusals registry:Host@468,registry:Replica@159,whole:Route@370,whole:Route@537 dc2078aa188d2ae4c0ef505b3863b8b9e450b38c0aa6be83087073824659af97 |
| +internal/activator/instancekey.go ExecBackend.ensureInstanceKeyAt legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: after the unchanged replica and fenced/conflict checks, asks haMintGuard(ctx, rt) (+whole:Route) and hands the guard to ensureInstanceKey; a classification error fails with InstanceKeyFailed; a non-HA host gets a nil guard and mints exactly as before; only adds a refusal;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: asks mintGuardFor(ctx, rt) (was haMintGuard): an HA host's guard as before; an eligible host's escrowMintGuard, which on a ready box reads the bucket manifest and the sealed env item when a mint is next and refuses while the escrow holds the key, and on a box that is not ready refuses every mint; nil for any other host, which mints as before. The replica and fenced/conflict refusals are unchanged; only adds refusals Fix round 1: asks mintGuardWith(ctx, rt, !create): a launch's ensure shares its preparation's escrow read, the backfill's reads the bucket afresh; only refuses. registry:Host@598,registry:Replica@159,whole:Route@491,whole:Route@667 5605bd1a4441859415f51b50c38e959987b2524fa8ccbec7364949e7097e9770 |
| internal/activator/instancekey.go ensureInstanceKey legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more parameter, guard (nil for every caller but ensureInstanceKeyAt on an HA host), asked once the locked read finds no key and the bucket allows a mint, before anything is minted; its refusal returns InstanceKeyFailed with nothing written. Create-only, fail-closed and defer-on-unknown are unchanged; the one site unchanged, no read added; only adds a refusal;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: the guard is asked with InstanceKeyVar, at the same point (the locked read found no key and the bucket allowed a mint); create-only, fail-closed and defer-on-unknown unchanged; the same one site; only adds a refusal file:Stat@4816 2d53f8246ac317c066d4b804cdc251aaf60abbd4423c6b780f0cbee227203fc8 |
| internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. file:Exec@17224,file:Open@1150,file:Statfs@42938,registry:App@11199,whole:Route@11191,whole:Route@27157 468925825434ca943612360b5811e6e4ed3029822b324930118ac03c212e59e0 |
| internal/hostfiles/restore.go Restore legacy accepted-legacy accepted-legacy;rev3=merge-ruling-2;basis=Restore delegates to shared descriptor-root implementation; generic payload restoration remains legacy.;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: passes nil for restore's new baseline argument; the one site unchanged, nothing else changed;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3 fix round 1: passes nil for restore's new shadowed argument, so it fetches, writes and removes exactly what it did; the same reads. restore gains that argument (a caller's Shadowed func over the manifest it has already read and validated): a live entry it names, after the overlap rule, is skipped before any fetch and reported in RestoreStats.Shadowed. It only leaves things out; nothing new is opened, read or followed. RestoreRootBaselineShadowed is new, RestoreRootBaseline is it with nil. file:OpenRoot@219 6a3b0e25de6d9ff6e644810d70a7056840e6cca7fa72db98542f990d4598fd30 |
| -internal/activator/escrow.go ExecBackend.EscrowSweep legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new, the agent as carlos (carlos-edge.service), no root caller, from escrowLoop: classifies each row against the rows handed in (Classify), keeps eligible rows known not HA from memory (haKnown, no read), and in host order from a round-robin cursor stats each escrowed file (stampAt) and publishes the changed ones, 8 at a time, at most 256 a sweep (sweepPublish); a box without a files store or key does nothing; opens nothing outside the rows' own data directories; writes only the hibernate bucket's files/0 prefix and the ledger registry:Host@1062,registry:Host@1533,registry:Host@1878,registry:Host@2132,registry:Host@2206,registry:Host@535,registry:Host@748,registry:Host@892,registry:Host@911,whole:Route@1071,whole:Route@1407,whole:Route@1535,whole:Route@1765,whole:Route@1880,whole:Route@2134,whole:Route@2208,whole:Route@355,whole:Route@518,whole:Route@586,whole:Route@652,whole:Route@705,whole:Route@793,whole:Route@797,whole:Route@814,whole:Route@901,whole:Route@920 d1fd70859e6560c8587597bb3d47f18c9989a2d9746c94964fd8d5db9028f449 |
| +internal/activator/escrow.go ExecBackend.EscrowSweep legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new, the agent as carlos (carlos-edge.service), no root caller, from escrowLoop: classifies each row against the rows handed in (Classify), keeps eligible rows known not HA from memory (haKnown, no read), and in host order from a round-robin cursor stats each escrowed file (stampAt) and publishes the changed ones, 8 at a time, at most 256 a sweep (sweepPublish); a box without a files store or key does nothing; opens nothing outside the rows' own data directories; writes only the hibernate bucket's files/0 prefix and the ledger Fix round 1: a host whose instance lease this box does not hold (holdsLease) is skipped, and one with a conflict marker counts as failing and is not published; the report is tallied through one lock (P1-4). registry:Host@1079,registry:Host@1098,registry:Host@1249,registry:Host@1782,registry:Host@2128,registry:Host@2385,registry:Host@2459,registry:Host@536,registry:Host@761,registry:Host@795,registry:Host@833,registry:Host@923,whole:Route@1001,whole:Route@1088,whole:Route@1107,whole:Route@1258,whole:Route@1576,whole:Route@1784,whole:Route@2014,whole:Route@2130,whole:Route@2387,whole:Route@2461,whole:Route@356,whole:Route@519,whole:Route@587,whole:Route@653,whole:Route@706,whole:Route@980,whole:Route@984 c3067eb671bdbba75100a0398840a1c293fb55b777e155703169d3ae2e71ccd2 |
| 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.bucketEscrowEnv legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: one hostfiles.Load of the host's files manifest in the hibernate bucket, then escrowEnvOf; the agent as carlos (carlos-edge.service), no root caller registry:Host@127,whole:Route@358 0e1683e265e25c20e20153f95b1ab53eb4300aac67330f1d0696a8df5dccff0b |
| -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 registry:Host@122,registry:Host@353 3fa0f583f17ffe65a8ee334139a90a0a3c96ae40764b0ff12ab4a3e735831520 |
| +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.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. registry:Host@1224,whole:Route@113,whole:Route@197,whole:Route@279,whole:Route@514,whole:Route@776 3e914cc96c915529e0c322572e62a5a67fc0528a06ee6514541aa492ce50be1f |
| +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.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 file:Open@284,registry:Host@122,registry:Host@1394,registry:Host@332,registry:Host@520,registry:Host@925,whole:Route@193,whole:Route@810 81436a987e2a08d1290ebb30cfb0c63e7b42466ab2dd2a9f318697b18937b8fe |
| -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. registry:Host@1188,registry:Host@1273,registry:Host@1441,registry:Host@1643,registry:Host@1905,registry:Host@2066,registry:Host@2251,registry:Host@2372,registry:Host@2546,registry:Host@2762,registry:Host@391,registry:Host@437,registry:Host@540,registry:Host@758,registry:Host@869,whole:Route@1056,whole:Route@1095,whole:Route@1321,whole:Route@1550,whole:Route@179,whole:Route@1808,whole:Route@1968,whole:Route@207,whole:Route@250,whole:Route@314,whole:Route@364,whole:Route@587,whole:Route@639,whole:Route@927 dd7eed18e97f32155348bacb8a49cf44b77963756f75254788c0a520f6f1145d |
| +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.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 round 0: new, on a box with a files store and no sealing key: hostfiles.Load of the host's files manifest in the hibernate bucket (one GET), true when it holds any sealed item or the cutover marker (manifestEscrowed); the answer is kept in memory and reused within haSecretsBudget only for refusals and launches, a mint reads again; a failed read is an error and the caller refuses; the agent as carlos (carlos-edge.service), no root caller registry:Host@128,registry:Host@396 9c404de03d0b6d4a6f8945919190309f303da2f09b87e6a77899c63300f471ea |
| -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 file:Open@753,registry:Host@528,registry:Host@600,whole:Route@415 8e3c6c1f3e88b7d6681df4b8be74508386172b1a7b88c308d18511509a3af991 |
| +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.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 registry:Host@223,registry:Host@331,registry:Host@428,whole:Route@157,whole:Route@508 726dfaf89eaf2a1a13a1b0492ffe4582dbc43ca816821d488d5dcca53bda6f33 |
| -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 registry:Host@2175,registry:Host@2439,registry:Host@3454,registry:Host@3602,registry:Host@589,whole:Route@2366 18edc91e27cadfdb73cd23e3c45b71350239c1d3f0a109a87b49e6fa2b7f8f35 |
| -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. file:Open@1662,registry:Host@1345,registry:Host@1519,registry:Host@267,registry:Host@2749,registry:Host@788,registry:Host@833,registry:Host@936,whole:Route@1012,whole:Route@1167,whole:Route@1416,whole:Route@594,whole:Route@635,whole:Route@725 e24cb07f81da9026c269ab9de76cb0d64761ba5e2a2fc5fbe1c1d73cdc600b8b |
| +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.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 |
| @@ -94,20 +100,22 @@ internal/activator/escrow.go readStamped legacy accepted-legacy accepted-legacy; |
| internal/activator/escrow.go stampAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the same open as readStamped and its fstat; reads no bytes file:Stat@240 fe3fb1c14a5391f9cedeb4e2885145766bd1349c902bc68e5e344973b87d6342 |
| internal/activator/hafiles.go ExecBackend.sealerFor legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: new. Builds the host's hostfiles.ItemSealer from the backend's EscrowKey (the box's own CARLOS_SECRETS_KEY, set once by runAgent) and the binding {release.RouteAccount(rt), rt.App} for rt.Host (NewItemSealer validates the account, app and host shape); nil key is an error. Pure in memory: opens, reads and writes nothing. registry:App@334,registry:Host@343,whole:Route@324 0225e79c376c0bad00460a6b520b3f9f0cdf2468a0319f2370e0aa3fb6af091a |
| internal/activator/hasecrets.go ExecBackend.escrowedScheduledToken legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: renamed from haScheduledToken and widened to escrowed hosts (SecretsEscrowed): reads CARLOS_ADMIN_TOKEN from the host's env file with instancefs.ReadBeneathLimit (1 MiB, no link followed) after the wake; a host that is not escrowed reads nothing; the token is sent only to that same instance's tick; the agent as carlos (carlos-edge.service), no root caller whole:Route@150,whole:Route@231 27b746b71bb8750c5016f183a244374c6a62d9bd65243a326e4765b78d2f53ef |
| -internal/activator/hasecrets.go ExecBackend.mintGuardAs legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: an HA host's haMintGuard, an eligible host's escrowMintGuard, else nil; reads nothing itself; only refuses whole:Route@143,whole:Route@170,whole:Route@207 55d8c88e3bde3ed19a376d4ebc3c1d0a8754e2773dfef8e827a8c8ca0dc8ae07 |
| -internal/activator/hasecrets.go ExecBackend.mintGuardFor legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the one mint decision, replacing haMintGuard as the entry point: classifies the host (haHostNow; an error refuses) and returns mintGuardAs; the agent as carlos (carlos-edge.service), no root caller; only refuses whole:Route@125,whole:Route@230 6649b6fff34ca16bbca2db45f20dce04445fc7939405d167341ac0e9b8584955 |
| +internal/activator/hasecrets.go ExecBackend.mintGuardAs legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: an HA host's haMintGuard, an eligible host's escrowMintGuard, else nil; reads nothing itself; only refuses Fix round 1: passes fresh to escrowMintGuard (shared preparation read, or the bucket afresh). whole:Route@150,whole:Route@177,whole:Route@214 efafd010f153c8c201a4711a25fb8b52a5aeab34dc2148d960308a4a872b5169 |
| +internal/activator/hasecrets.go ExecBackend.mintGuardFor legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the one mint decision, replacing haMintGuard as the entry point: classifies the host (haHostNow; an error refuses) and returns mintGuardAs; the agent as carlos (carlos-edge.service), no root caller; only refuses Fix round 1: mintGuardWith(ctx, rt, false); the classification moved there. whole:Route@125 5ada4c3f9dc1dceaf754b994c289bd16369f673760e087b51ab0d32950d28328 |
| +internal/activator/hasecrets.go ExecBackend.mintGuardWith legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 1: new: classifies the host (haHostNow; an error refuses) and returns mintGuardAs with fresh; only refuses whole:Route@138,whole:Route@243 c32deadc5f476734f4329408f50a05805916e75b63c6c77bc6f3e9e0f42c2ed2 |
| internal/activator/hasecrets.go SplitBackend.escrowedScheduledToken legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: renamed from haScheduledToken: dispatches to the row's half, else not escrowed whole:Route@130,whole:Route@206 9a25668abc3fd7f8d4a6ea5dc39cb1b2e75f1b97a0dbfd42497c2ece607a5cce |
| internal/activator/paths.go ExecBackend.pathsAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: pathsFor's former body, unchanged, taking a classification already made (the escrow sweep classifies every row against the one list it was handed); reads +registry:DBPath, +registry:Host x7 exactly as pathsFor did registry:DBPath@596,registry:Host@257,registry:Host@508,registry:Host@568,registry:Host@675,registry:Host@725,registry:Host@782,registry:Host@846 1b6ac30aeed48d9818da84b8c8638a3931a40af3d47821afac2c90a690206f61 |
| internal/host/escrow_loop.go escrowLoop legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: every activator.EscrowEvery (30 s) lists the registry and runs svc.EscrowSweep over the rows; logs failures and deferrals; returns with no registry or no Service; the agent as carlos (carlos-edge.service), no root caller whole:Route@426 498f5efdf374f9c35ca954f845507ce3c8db25e9b766f873c3acf23ec2f7cb05 |
| internal/host/schedule_wiring.go scheduleHostEscrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: scheduleHostHA renamed: reads the host's row (reg.Get) and asks svc.SecretsEscrowed (HA, or eligible for escrow) with a 10 s timeout; false with no registry or no row; for such a host scheduleToken only reads the existing env token ("" when none) and never mints (EnsureAdminToken skipped); the agent as carlos (carlos-edge.service), no root caller whole:Route@254,whole:Route@413 1a608f98d348d9183088ff4f04742c30467a116f0071358ce479e1dff5e20eeb |
| internal/hostfiles/sealed.go ReadSealed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 2: new. Reads one sealed platform item of a files manifest the caller already loaded: the object at exactly the key the entry names, through the existing fetch (checkEntry: origin admitted, key shape, sha256 and size verified), only for an entry marked sealed "v2". The "Open" the scanner sees is appconfig.Open, an in-memory AES-GCM decryption of the fetched bytes, not a file open: no filesystem path is opened, read or followed. It refuses a v1 envelope (appconfig.EnvelopeBound), and after opening under the caller-supplied key and (account, app) binding it checks the HMAC digest over account, app, host and item against the entry. Writes nothing. No production caller in this task; Tasks 3 and 4 call it from the activator. file:Open@898 7c2b887b6e0b45472fd8d1a63a2b78eb565c4e93c89cb329eeeaef429ab0b010 |
| internal/layout/inventory.go Inventory legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 1: new. One os.ReadDir of the host's inventory root, provision.InstanceDir(dataDir, host) nested or dataDir flat, after refusing a host that fails controlname.ValidHostShape and a layout that is neither flat nor nested; reads only the listing's names and types (DirEntry.IsDir), opens and follows nothing; flat ownership is the extras scan's own (hostEntries over knownHosts); each top-level name is classified by pubclass.Of, a pure function of the name. A missing directory is an empty inventory. No caller in this task; later tasks call it from the publisher. file:ReadDir@449 9662e465abb7f9c60e908952740384479009c9987c8a6ae65d98fb19cb3d4d7e |
| +internal/activator/backend_exec.go ExecBackend.Acquire legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: after the unchanged AdmitConfig gate, the lease acquire moves into acquireClassified (hawake.go, a new unit): a legacy route or a non-HA host takes the same lease.Acquire as before and maps a held lease to errLeaseHeld as before (leaseError); an HA host goes through the containment admission and lease.AcquireHA. A successful acquire marks the host acquiredHere for the process (same-box recovery). The config gate is not weakened; the same three sites, no read added;rev3=census-ruling-durability-3a-escrow;basis=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 registry:Host@1001,registry:Host@807,whole:Route@382,whole:Route@764 ff41146bbb0f1c3fac6a0f34f41540d7dbb036234f490841dca0e23d23b1c99c |
| internal/activator/hafiles.go ExecBackend.newHostFiles legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: builds a hostFiles publisher for rt (its instance paths from pathsFor(rt), rt.Host, the backend's registry, the 1 s platform and 15 min snapshot cadences); +registry:Host, +whole:Route; no I/O;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: now also sets the publisher's sealer (sealerFor(rt); its error is returned and nothing is built) and its skip, pubclass.FilesDirSkip(Nested, rt.Host), a pure function of the name, so every tree pass publishes only App paths and never the trio raw. Still no I/O; the new +registry:Host and +whole:Route sites are the sealer's and the classifier's arguments. registry:Host@228,registry:Host@313,whole:Route@128,whole:Route@217 69d03f586dc59cbc9555cc79b34d024854359b8d2a3d9ae0625ae5e8a4ad0a52 |
| internal/activator/hafiles.go ExecBackend.openHostFiles legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: the entry's files publisher: refuses without a FilesStore or outside the nested layout, takes the one this wake's restore staged, else hostfiles.Open on <hibernate prefix>/files/0/ (one GET of the manifest from the hibernate bucket, the scanner's +file:Open); +registry:Host x2, +whole:Route x2; the manifest is written by the agents of the boxes that hold the host, through the same files store;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: asks sealerFor before hostfiles.Open, so a box without an escrow key refuses before it reads the manifest; newHostFiles's error is returned. The same manifest GET otherwise; the new +whole:Route site is sealerFor's argument. Opens nothing new. file:Open@521,registry:Host@342,registry:Host@569,whole:Route@198,whole:Route@469,whole:Route@640 f193b187884a24cd093cc19e08ad77be581005ac84c746cef8db52f1beb8dbe8 |
| internal/activator/hafiles.go ExecBackend.stageKeptFiles legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: on a kept wake, reads the manifest baseline the release kept beside its local record (<db>.release.files.json via readFilesBaseline, capped at 32 MiB, O_NOFOLLOW, regular files only) and stages a publisher on it only when its revision (Gen, which carries the body's SHA-256) equals the files_gen in the lock's release marker; the file is on ground the tenant can write, and anything that does not match stages nothing, so the entry re-reads the manifest from the store; it never decides the keep; +registry:Host x4, +whole:Route x2;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: newHostFiles now answers an error (no escrow key), which is logged and stages nothing, as an OpenBaseline failure already did. The same baseline read; nothing new opened or read. registry:Host@254,registry:Host@344,registry:Host@508,registry:Host@627,registry:Host@673,whole:Route@151,whole:Route@560 d740082bbfda130c1b0b8e71dae3ff9804dbf36131bc659d147d3d41921674d2 |
| internal/activator/hafiles.go ExecBackend.stageWakeFiles legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: opens a publisher on a manifest baseline the HA restore already holds (hostfiles.OpenBaseline, no read) and keeps it for the wake's entry; without a FilesStore it stages nothing; +registry:Host x3, +whole:Route;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: newHostFiles now answers an error (no escrow key), which is logged and stages nothing, as an OpenBaseline failure already did. No read, as before. registry:Host@185,registry:Host@300,registry:Host@419,registry:Host@465,whole:Route@352 2a9b49c4cdd022038db91a72126a31c4b0c7e81de038f9c57747522136aa361a |
| internal/activator/hasecrets.go ExecBackend.captureLaunchEnv legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new (final fix F2), the agent as carlos: reads an HA launch's own env file and its rendered config env once, the way instanceEnvParts does: on the nested layout through instancefs.ReadBeneathLimit (1 MiB, no link followed), otherwise os.ReadFile (the +file:ReadFile site; an HA host is nested by its acquire's containment admission, so this arm is the flat layout's, where the files are in the agent's own data directory); an absent own file is an error, an absent config is not; parses env and key layer from those bytes; +whole:Route;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: the flat arm's os.ReadFile (-file:ReadFile) is gone: both layouts read the own env file and the rendered config env with instancefs.ReadBeneathLimit beneath the row's data directory (openat2, no symlink, regular files only, 1 MiB), so an escrowed flat row's capture never follows a link at <host>.env; an absent own file is an error, an absent config is not; the agent as carlos (carlos-edge.service), no root caller; only narrows a read whole:Route@98 223e1b2f98aea8bb39f65573bcff0e6d05bb8cd2f55cd43670ca8ba6f1d33299 |
| -internal/activator/hasecrets.go ExecBackend.ensureAdminTokenFor legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new (final fix F2), the agent as carlos: the launch paths' admin-token producer: haMintGuard(ctx, rt), then ensureAdminToken on <dataDir>/<host>.env, beneath on the nested layout and by path otherwise, with that guard; +registry:Host, +whole:Route; a non-HA host's guard is nil and the producer is the one it used before;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: classifies the host once (haHostNow), and for a host that is not HA and is eligible for escrow first calls restoreEscrowIfMissing (a new unit on this card), then ensureAdminToken with mintGuardAs's guard; an HA host's path is as before; any other host's guard is nil as before; +whole:Route x3 (the row handed on); the agent as carlos (carlos-edge.service), no root caller registry:Host@363,whole:Route@136,whole:Route@237,whole:Route@285,whole:Route@424 441f7edc805241c0ad28db809b149e94009ce82989202235e7fbe127f69932b0 |
| +internal/activator/hasecrets.go ExecBackend.ensureAdminTokenFor legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new (final fix F2), the agent as carlos: the launch paths' admin-token producer: haMintGuard(ctx, rt), then ensureAdminToken on <dataDir>/<host>.env, beneath on the nested layout and by path otherwise, with that guard; +registry:Host, +whole:Route; a non-HA host's guard is nil and the producer is the one it used before;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: classifies the host once (haHostNow), and for a host that is not HA and is eligible for escrow first calls restoreEscrowIfMissing (a new unit on this card), then ensureAdminToken with mintGuardAs's guard; an HA host's path is as before; any other host's guard is nil as before; +whole:Route x3 (the row handed on); the agent as carlos (carlos-edge.service), no root caller Fix round 1: begins the launch's preparation (beginPrep) before the restore, and passes fresh false to the guard. registry:Host@257,registry:Host@386,whole:Route@136,whole:Route@237,whole:Route@308,whole:Route@447 581b4132ee9f3bbb900b5c467c02596502b0232575a8beacd198419469eb4e3c |
| internal/activator/hasecrets.go ExecBackend.haMintGuard legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new (final fix F2), the agent as carlos, replacing haMintGate: nil for a host that is not HA; for an HA host a guard that, asked only from a producer's missing-secret branch, reads once whether the host's files manifest exists (haManifestFound) and refuses with ErrInstanceKeyDeferred while it does (or on a read error); it never reads the env; +whole:Route x2; only refuses;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: now only the HA arm of mintGuardFor: the same once-per-guard haManifestFound read and the same ErrInstanceKeyDeferred refusal, the name ignored; the HA classification moved to mintGuardFor (-whole:Route); only refuses whole:Route@220 7218a4d3a064c04bca0bdccec25c2934974b926a5af657a156cd0ca8498b586d |
| internal/activator/hasecrets.go ExecBackend.haSecretsReady legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: before an HA host's launch, checks that env, the bytes the launch captured (captureLaunchEnv; a new parameter, final fix F2), has the SHA-256 of the committed manifest's env item (envAcknowledged, which now reads no file); else publishes the platform items (env, trio, wake state) through the wake's, the entry's or its own publisher (hostfiles.Open, the +file:Open site: one manifest GET) and checks again, so an env replaced after the capture is committed as other bytes and fails the launch; it no longer classifies the host itself (launchEnvLayer has); every error fails the launch; +file:Open, +registry:Host x3, +whole:Route;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: asks sealerFor before its own hostfiles.Open (a box without an escrow key fails the launch before any read), and newHostFiles's error fails the launch. envAcknowledged now compares the sealed env item's keyed digest (hostfiles.SealedAcknowledged, no read) instead of the raw env item's SHA-256. The publish it triggers stages the trio sealed: <host>.env, <host>/instance.key and <host>/report.token are each read with instancefs.ReadBeneathLimitOrAbsent beneath the instance directory (openat2, no symlink, regular files only, 1 MiB cap), the same reader the env already used, then sealed in memory; nothing else is opened. file:Open@390,registry:Host@1187,registry:Host@120,registry:Host@438,whole:Route@294,whole:Route@559 4f4584786d3f90a54aa3ddc1c39ffed8a62fcfd593127f534bea787c3d9b7829 |
| internal/activator/hasecrets.go ExecBackend.launchEnvLayer legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new (final fix F2), the agent as carlos: a launch's env and key layer: classifies the host (haHostNow; an error fails the launch), instanceEnvLayer unchanged for a non-HA host; for an HA host captureLaunchEnv once, haSecretsReady over those bytes, a test seam (haLaunchHooks.afterPublish, nil in production), and returns the env parsed from the captured bytes, never a later read; +registry:Host x3 (the error messages), +whole:Route x4;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: for a host that is not HA and is eligible for escrow, escrowedLaunchEnv (a new unit on this card) instead of instanceEnvLayer; the HA and other paths unchanged; +whole:Route x2; the agent as carlos (carlos-edge.service), no root caller registry:Host@245,registry:Host@499,registry:Host@644,whole:Route@154,whole:Route@294,whole:Route@335,whole:Route@371,whole:Route@408,whole:Route@549 35a5150b24c33e81e5d536bb072c62ab55fd583187d83293e644d3599496a99a |
| @@ -121,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 1ace39f15f5a7ed962b84164ab97c63c5fa7657ee2910392febcce0253670024 |
| +@coverage internal/activator f84a595aa5224a9cb111c29099bb06cc637021c339487f9f5bb9ca0bf8887dd3 |
| @coverage internal/host c12e11dd2fbfb5936e5256007db85a88f96cb12f3d1c74c551ff7ec5f52f9355 |
| @coverage internal/hostfiles a0b0deb2779b183ee3f3578d1112ac5f723d930e40690a55eaaaa2644a24a9ad |
| @coverage internal/layout f845fa728b0935279454d8b01023c5d6dae1c985061a41229cf0686e829f5c12 |