durability 3a: sealed escrow for every activator host; mint only on the bucket's word
Every exec or rootfs instance the activator launches that is not HA now escrows its env file and the trio (<host>.env, <host>/instance.key, <host>/report.token) as sealed platform items of its files manifest, the same items an HA host publishes (#477), so a box that has lost them puts the sealed copy back instead of minting new secrets. - Eligible is not ready. escrowEligible is the row's and the box's layout facts alone; escrowReady needs a files store, CARLOS_SECRETS_KEY and a sealer. An eligible host on a box that is not ready never restores, never mints (every producer and BackfillInstanceKey refuse with ErrEscrowNotReady) and never makes its first launch; with a ledger and a local env it launches and logs. - The bucket decides. mintGuard now names the variable it would mint, and mintGuardFor replaces haMintGuard: HA as before; an escrowed host's guard reads the bucket manifest and the sealed env when a mint is next and refuses while the escrow holds the variable. ensureAdminTokenFor first restores, from the bucket, each escrowed file that is missing, never over a present one. The ledger (<data>/.escrow/<host>.json) is a publication baseline only. - One capture. An escrowed launch reads its env once, publishes and acknowledges those bytes, and launches with the env parsed from them. A supersession reads the bucket and starts the preparation over once; a second one fails with an ALERT. A failed write holds only a first launch. - The sweep. escrowLoop runs Service.EscrowSweep every 30 s: stat stamps decide "unchanged" with no read (a stamp under 2 s old is not kept), a round-robin cursor, 8 publishes at once, at most 256 a sweep. Absence never deletes an escrow. - Scheduled ticks only read the token of an HA or escrowed host (scheduleHostEscrowed over SecretsEscrowed), and the activator fills it after the wake. .escrow joins layout's platform names. The rootfs test fixtures gain the files store and key every box has. Census: claims for every changed unit, the proposal re-run, and a 9B8 layer re-pinning platformNames and moving pathsFor's body to pathsAt.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/notes/census-durability-3a-escrow-claims.md+46 −1docs/superpowers/notes/census-proposal-durability-3a-escrow.md+66 −3internal/activator/admintoken.go+5 −4internal/activator/backend_exec.go+5 −1internal/activator/claim_snapshot.go+1 −1internal/activator/escrow.go+1,065 −0internal/activator/escrow_linux_test.go+103 −0internal/activator/escrow_stamp_linux.go+18 −0internal/activator/escrow_stamp_other.go+12 −0internal/activator/escrow_test.go+825 −0internal/activator/hasecrets.go+85 −53internal/activator/hasecrets_test.go+18 −4internal/activator/instancekey.go+10 −9internal/activator/paths.go+6 −0internal/activator/rootfs_ctl_harness_test.go+4 −1internal/activator/rootfs_deploy_test.go+8 −1internal/activator/rootfs_test.go+5 −2internal/host/agent.go+1 −0internal/host/escrow_loop.go+52 −0internal/host/schedule_wiring.go+13 −11internal/host/schedule_wiring_test.go+89 −0internal/layout/extras.go+3 −0internal/layout/extras_test.go+3 −2internal/provision/durability_3a_escrow_census_test.go+34 −1internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv+97 −6
Intent
<task-notification> <task-id>ae6c8669dc786cbbf</task-id> <tool-use-id>toolu_01HuAwybaGMtURBpozxFfAC3</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/953e7524-2e06-4308-b9ce-fd1b38579971/tasks/ae6c8669dc786cbbf.output</output-file> <status>completed</status> <summary>Agent "Implement Task 3: HA sealed items" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE. Fix round 1 for the Important finding (sealed precedence applied too late). Commit: 51700e8f "durability 3a: a sealed item shadows its raw entry before any fetch (#477)", a new commit on top of 45d47c7a, not pushed. Git printed the usual `packed-refs.lock` error; the commit is on the branch. Fix: the files restore now skips any live raw `instance.key` or `report.token` that has a sealed copy in the manifest, before anything is fetched. This uses a new hook in `internal/hostfiles/restore.go`; the existing restore functions pass no hook and behave as before. The publisher still continues from the manifest exactly as read. A sealed item that won't open still fails the wake, with no fallback to the raw copy. Tests: all pass. - **Regression:** with both forms present and the raw objects missing or corrupt, the restore succeeds from the sealed copies (RED before the fix). - **Wake-level refusal:** with readable raw copies present and the sealed item under the wrong key, or carrying another host's digest, the wake fails on the sealed item. Nothing launches and no secret is written or minted. - **Deletion test:** it now first checks that the first commit holds the sealed key with readable plaintext and the raw entry tombstoned. - **Hostfiles unit test** for the hook. - **Package runs:** the full activator and hostfiles packages pass, as do the census tests. gofmt is clean and the cross builds pass. Census: claims updated and census-propose re-run; nothing is left unclaimed. Concerns: none new. The review's open item (that a pre-3a binary defers rather than mints) still needs testing with an older binary. Report (fix report appended): /home/paulca/amadan.net/carlos/platform/.claude/worktrees/durability-3a/.superpowers/sdd/2026-10-30-durability-step3-escrow-fence-restore/task-3-report.md</result> <usage><subagent_tokens>266321</subagent_tokens><tool_uses>16</tool_uses><duration_ms>571144</duration_ms></usage> </task-notification>
<task-notification> <task-id>bzjshwxdl</task-id> <tool-use-id>toolu_01ESjTfhy3u3HKKsJNirsyrQ</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/953e7524-2e06-4308-b9ce-fd1b38579971/tasks/bzjshwxdl.output</output-file> <status>completed</status> <summary>Background command "Wait for the Task 3 re-review" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 7.60 g CO₂e (948,511 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 425df0ec8..1d7fe23f8 100644 |
| --- a/docs/superpowers/notes/census-durability-3a-escrow-claims.md |
| +++ b/docs/superpowers/notes/census-durability-3a-escrow-claims.md |
| @@ -5,7 +5,7 @@ |
| internal/layout/inventory.go:Inventory 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. |
| internal/layout/plan.go:NestedPlatformNames durability 3a Task 1: now a one-line wrapper for pubclass.NestedPlatformNames, which builds the same set (byte-identical, checked before and after) from pubclass.FileBases and the same instancectl/instancekey names, without nestedFiles or rawInstanceDir; it never read anything, and reads nothing now |
| internal/hostfiles/sealed.go:ReadSealed 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. |
| -internal/host/agent.go:runAgent 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. |
| +internal/host/agent.go:runAgent 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/activator/hafiles.go:ExecBackend.sealerFor 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. |
| internal/activator/hafiles.go:ExecBackend.newHostFiles 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 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. |
| @@ -14,3 +14,48 @@ internal/activator/hafiles.go:ExecBackend.stageWakeFiles durability 3a Task 3: n |
| internal/activator/hasecrets.go:ExecBackend.haSecretsReady 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/hawake.go:ExecBackend.restoreFilesClean durability 3a Task 3 (fix round 1: sealed precedence before any fetch): the restore into <host>.restore is now RestoreRootBaselineShadowed with sealedShadow(host), a pure function of the manifest already read and validated: a live raw instance.key or report.token entry whose sealed item the manifest holds is neither fetched nor written (so a missing or corrupt raw object cannot fail the wake, and a sealed item that does not open fails it with no raw fallback); every other entry is restored as before, and the baseline the wake's publisher continues from is the manifest as read. Then each sealed trio item the manifest holds (instance.key.sealed, report.token.sealed) is fetched and opened with hostfiles.ReadSealed (key, sha256, v2 envelope, binding and MAC checked) and written with instancefs.WriteAtomic (openat2 directory, no symlink, O_EXCL temp, rename, 0600) into the restore directory this function created, then that directory is synced; then the same no-replace rename. The env file comes from the sealed env item through ReadSealed when present, else from the raw env item as before, written as before. The source is still the host's files manifest in the hibernate bucket; the destinations are the same restore directory and env file; no new path is opened, followed or named from input; the sealer (sealerFor) is built only when a sealed item is present. |
| internal/hostfiles/restore.go:Restore 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/admintoken.go:ensureAdminToken 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 |
| +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: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.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.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 |
| +internal/activator/hasecrets.go:SplitBackend.haScheduledToken durability 3a Task 4: renamed to SplitBackend.escrowedScheduledToken (on this card) |
| +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.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.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 |
| +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 |
| +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.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 |
| +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 |
| +internal/activator/escrow.go:SplitBackend.EscrowSweep durability 3a Task 4: new: forwards to the exec half |
| +internal/activator/escrow.go:SplitBackend.SecretsEscrowed durability 3a Task 4: new: forwards to the exec half, else IsHA |
| +internal/activator/escrow.go:readStamped durability 3a Task 4: new: instancefs.OpenBeneathOrAbsent (openat2 beneath the row's data directory, no symlink, O_NONBLOCK, regular files only), fstat for the stamp, and at most 1 MiB read from that descriptor when the stamp moved |
| +internal/activator/escrow.go:stampAt durability 3a Task 4: new: the same open as readStamped and its fstat; reads no bytes |
diff --git a/docs/superpowers/notes/census-proposal-durability-3a-escrow.md b/docs/superpowers/notes/census-proposal-durability-3a-escrow.md| index dafb82f85..38da16364 100644 |
| --- a/docs/superpowers/notes/census-proposal-durability-3a-escrow.md |
| +++ b/docs/superpowers/notes/census-proposal-durability-3a-escrow.md |
| @@ -1,40 +1,103 @@ |
| # Census approval: durability-3a-escrow |
| -Ruling `census-ruling-durability-3a-escrow`. The independent reviewer approves or rejects every change below, 4 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, 35 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| | unit | change | read sites | what changed | |
| |---|---|---|---| |
| -| `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. | |
| +| `internal/activator/admintoken.go` `ensureAdminToken` | body | unchanged (4) | 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 | |
| +| `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` `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/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.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 | |
| | `internal/activator/hawake.go` `ExecBackend.restoreFilesClean` | sites | +whole:Route | durability 3a Task 3 (fix round 1: sealed precedence before any fetch): the restore into <host>.restore is now RestoreRootBaselineShadowed with sealedShadow(host), a pure function of the manifest already read and validated: a live raw instance.key or report.token entry whose sealed item the manifest holds is neither fetched nor written (so a missing or corrupt raw object cannot fail the wake, and a sealed item that does not open fails it with no raw fallback); every other entry is restored as before, and the baseline the wake's publisher continues from is the manifest as read. Then each sealed trio item the manifest holds (instance.key.sealed, report.token.sealed) is fetched and opened with hostfiles.ReadSealed (key, sha256, v2 envelope, binding and MAC checked) and written with instancefs.WriteAtomic (openat2 directory, no symlink, O_EXCL temp, rename, 0600) into the restore directory this function created, then that directory is synced; then the same no-replace rename. The env file comes from the sealed env item through ReadSealed when present, else from the raw env item as before, written as before. The source is still the host's files manifest in the hibernate bucket; the destinations are the same restore directory and env file; no new path is opened, followed or named from input; the sealer (sealerFor) is built only when a sealed item is present. | |
| +| `internal/activator/paths.go` `ExecBackend.pathsFor` | sites | -registry:DBPath, -registry:Host ×7, +whole:Route | 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 | |
| Envelopes re-pinned: `internal/activator`, `internal/host`, `internal/hostfiles`, `internal/layout`, `internal/layout/pubclass`. |
| +Removed units: the scan finds neither the declaration nor any of its sites. |
| + |
| +| unit | recorded disposition | basis | what changed | |
| +|---|---|---|---| |
| +| `internal/activator/hasecrets.go` `ExecBackend.haScheduledToken` | legacy, task accepted-legacy | accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: for an HA host, reads CARLOS_ADMIN_TOKEN from its env file (instancefs.ReadBeneathLimit, 1 MiB, beneath its directory without following a link) after the wake; not HA reads nothing; +whole:Route x2; the token is sent only to that same instance's tick | durability 3a Task 4: renamed to escrowedScheduledToken (on this card), the same read for HA hosts | |
| +| `internal/activator/hasecrets.go` `SplitBackend.haScheduledToken` | legacy, task accepted-legacy | accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: dispatches haScheduledToken to the row's half, else not HA; +whole:Route x2 | durability 3a Task 4: renamed to SplitBackend.escrowedScheduledToken (on this card) | |
| +| `internal/host/schedule_wiring.go` `scheduleHostHA` | legacy, task accepted-legacy | accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new (region HA P1a), the agent as carlos, from the scheduler tick's token callback (scheduleToken): reads the host's row (reg.Get) and asks svc.IsHA on it with a 10 s timeout; false with no registry or no row; for an HA host scheduleToken now only reads the existing env token ("" when none) and never mints one (EnsureAdminToken is skipped), the activator fills it after the restore (ServeScheduled); reads +whole:Route x2 (the row and the row handed to IsHA) | durability 3a Task 4: renamed to scheduleHostEscrowed (on this card), asking SecretsEscrowed instead of IsHA | |
| + |
| Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| +A removed unit's recorded disposition and basis are in its table above. For a removed unit or a retired envelope, confirm from the diff that the code is deleted and not moved: a read that moved shows on this card as a change to the unit that took it, and a unit moved whole shows as a new unit, a decision. Reject if a check, refusal or validation that root relies on goes with the deleted code and its callers' changes on this card do not account for that. |
| + |
| Recorded dispositions, which each change must still satisfy: |
| +- `internal/activator/admintoken.go` `ensureAdminToken`: legacy, task accepted-legacy. Basis: 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 |
| +- `internal/activator/claim_snapshot.go` `ExecBackend.EnsureClaimAdminToken`: legacy, task accepted-legacy. Basis: 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 |
| +- `internal/activator/hasecrets.go` `Service.fillScheduledToken`: legacy, task accepted-legacy. Basis: 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 |
| +- `internal/activator/instancekey.go` `ExecBackend.BackfillInstanceKey`: legacy, task accepted-legacy. Basis: 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 |
| +- `internal/activator/instancekey.go` `ExecBackend.ensureInstanceKeyAt`: 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 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 |
| +- `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/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 |
| - `internal/activator/hafiles.go` `ExecBackend.stageWakeFiles`: legacy, task accepted-legacy. Basis: 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 |
| +- `internal/activator/hasecrets.go` `ExecBackend.captureLaunchEnv`: legacy, task accepted-legacy. Basis: 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 |
| +- `internal/activator/hasecrets.go` `ExecBackend.ensureAdminTokenFor`: legacy, task accepted-legacy. Basis: 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 |
| +- `internal/activator/hasecrets.go` `ExecBackend.haMintGuard`: legacy, task accepted-legacy. Basis: 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 |
| - `internal/activator/hasecrets.go` `ExecBackend.haSecretsReady`: legacy, task accepted-legacy. Basis: 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 |
| +- `internal/activator/hasecrets.go` `ExecBackend.launchEnvLayer`: legacy, task accepted-legacy. Basis: 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 |
| - `internal/activator/hawake.go` `ExecBackend.restoreFilesClean`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: restores the HA host's published files into a fresh <host>.restore directory beneath the instance data dir (instancefs, no link followed), renames it into place without replacing anything, writes the manifest's env item as <host>.env (instancefs.WriteAtomic, 0600) and imports the manifest's wake state into the registry (hostfiles.ImportWake, then the class for restoredReplication); the source is the host's files manifest in the hibernate bucket, written by the agents of the boxes that held the host; every failure fails the wake; +registry:Host, +whole:Route x2 |
| +- `internal/activator/paths.go` `ExecBackend.pathsFor`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route |
| 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.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.escrowChanged`: reads +registry:Host ×2; 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 ×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 ×14, +whole:Route ×7; 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.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 ×2; 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 |
| +- new `internal/activator/escrow.go:SplitBackend.EscrowSweep`: reads +file:Exec, +whole:Route; written legacy, accepted-legacy, frozen |
| +- new `internal/activator/escrow.go:SplitBackend.SecretsEscrowed`: reads +file:Exec, +whole:Route ×2; written legacy, accepted-legacy, frozen |
| +- new `internal/activator/escrow.go:readStamped`: reads +file:ReadAll, +file:Stat; written legacy, accepted-legacy, frozen |
| +- new `internal/activator/escrow.go:stampAt`: reads +file:Stat; written legacy, accepted-legacy, frozen |
| - 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: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 |
| +- new `internal/host/schedule_wiring.go:scheduleHostEscrowed`: reads +whole:Route ×2; written legacy, accepted-legacy, frozen |
| - new `internal/hostfiles/sealed.go:ReadSealed`: reads +file:Open; written legacy, accepted-legacy, frozen |
| - 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` → `496ab302fe3dc87eb5b7f6335dce2fe2578f08cbf367451256d778b88bb1a6ae`. |
| +Seal: `eaeb153ab7a7a849edc9c6e92f2ac5c709c6e39044a647971cf1fa5ebcb660c8` → `ff7de0ee0c3c4d467e9517b579b300d3284ff900e96de78a2f3f27bed25180a0`. |
| 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/admintoken.go b/internal/activator/admintoken.go| index 1b93e2c8e..d5d068f04 100644 |
| --- a/internal/activator/admintoken.go |
| +++ b/internal/activator/admintoken.go |
| @@ -146,8 +146,9 @@ func EnsureAdminTokenBeneath(dir, name string) error { |
| // I/O primitives the read and the append use; everything else, the parse, |
| // the mode check, the shape check, the mint, is one piece of logic so the |
| // callers cannot drift. guard, when not nil, is asked once this read has |
| -// found no token, before anything is minted (an HA host's haMintGuard); |
| -// its refusal is returned and nothing is written. |
| +// found no token, before anything is minted (mintGuardFor: an HA or an |
| +// escrowed host's), with the variable it would mint; its refusal is |
| +// returned and nothing is written. |
| func ensureAdminToken(dir, name string, beneath bool, guard mintGuard) error { |
| path := filepath.Join(dir, name) |
| adminTokenMu.Lock() |
| @@ -212,10 +213,10 @@ func ensureAdminToken(dir, name string, beneath bool, guard mintGuard) error { |
| return nil |
| } |
| // The token is missing on this read, the one the mint decides from: |
| - // an HA host's mint decision is asked here, never on an earlier read |
| + // the host's mint decision is asked here, never on an earlier read |
| // (final review F2). |
| if guard != nil { |
| - if err := guard(); err != nil { |
| + if err := guard("CARLOS_ADMIN_TOKEN"); err != nil { |
| return err |
| } |
| } |
diff --git a/internal/activator/backend_exec.go b/internal/activator/backend_exec.go| index f718ceb06..1e7a3c4ae 100644 |
| --- a/internal/activator/backend_exec.go |
| +++ b/internal/activator/backend_exec.go |
| @@ -337,8 +337,12 @@ type ExecBackend struct { |
| FilesStore release.Store |
| // EscrowKey is CARLOS_SECRETS_KEY parsed: what this box seals an |
| // instance's secrets to (its public half) and opens them with. Nil: HA |
| - // publication refuses, and escrow is not ready (Task 4). |
| + // publication refuses, and escrow is not ready (escrow.go). |
| EscrowKey *ecdh.PrivateKey |
| + // escrow is every other host's sealed escrow on this box (escrow.go): |
| + // each host's publisher, sealer and file stamps, and the sweep's |
| + // cursor. |
| + escrow escrowBook |
| // Lifetimes is the box's lifetime index (provision.LifetimeIndex), |
| // filled by the reconcile pass and read by the HA classification |
| // before every wake. Nil: every provisioned instance reads its record. |
diff --git a/internal/activator/claim_snapshot.go b/internal/activator/claim_snapshot.go| index 72b8735af..ceb3ffc09 100644 |
| --- a/internal/activator/claim_snapshot.go |
| +++ b/internal/activator/claim_snapshot.go |
| @@ -105,7 +105,7 @@ func (b *ExecBackend) EnsureClaimAdminToken(ctx context.Context, rt registry.Rou |
| return hostwrite.ErrUnavailable |
| } |
| // An HA host's mint decision is inside both producers below |
| - // (haMintGuard, hasecrets.go). |
| + // (mintGuardFor, hasecrets.go). |
| paths := b.pathsFor(rt) |
| return authorize(ctx, func() error { |
| // Only a missing token is minted: one the rendered configuration |
diff --git a/internal/activator/escrow.go b/internal/activator/escrow.go| new file mode 100644 |
| index 000000000..0edf85795 |
| --- /dev/null |
| +++ b/internal/activator/escrow.go |
| @@ -0,0 +1,1065 @@ |
| +package activator |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "errors" |
| + "fmt" |
| + "io" |
| + "log" |
| + "os" |
| + "path/filepath" |
| + "sort" |
| + "strings" |
| + "sync" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/controlname" |
| + "github.com/carlosframework/platform/internal/hostfiles" |
| + "github.com/carlosframework/platform/internal/instancefs" |
| + "github.com/carlosframework/platform/internal/instancekey" |
| + "github.com/carlosframework/platform/internal/layout/pubclass" |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// Durability 3a, the escrow of every other activator host (spec §5.4, plan |
| +// 3a choices 5 to 9 and 12). A host that is not HA publishes its env file |
| +// and the trio (<host>.env, <host>/instance.key, <host>/report.token) as |
| +// sealed platform items of its files manifest, the same items an HA host |
| +// publishes, so a box that has lost them puts the sealed copy back instead |
| +// 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). An eligible host on a |
| +// box that is not ready never restores, never mints and never makes |
| +// its first launch, and its scheduled ticks only read. |
| +// - 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. |
| +// - A launch reads the env once (captureLaunchEnv), publishes and |
| +// acknowledges exactly those bytes, and launches with the env parsed |
| +// from them. |
| +// - Absence never deletes an escrow: a missing file is restored, never |
| +// published as gone. |
| +// - A failed escrow write holds a host's first launch only. |
| + |
| +// ErrEscrowNotReady refuses a restore, a mint and a first launch of an |
| +// eligible host on a box that cannot read or write its sealed copy, and of |
| +// 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)") |
| + |
| +// 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 |
| + |
| +const ( |
| + // escrowSweepCap is the most hosts one sweep publishes; the rest are |
| + // deferred and come first in the next sweep. |
| + escrowSweepCap = 256 |
| + // escrowSweepWorkers is how many publishes a sweep runs at once. |
| + escrowSweepWorkers = 8 |
| +) |
| + |
| +// escrowHooks are test seams, nil in production: afterCapture runs once a |
| +// launch has captured its env and before it publishes it; afterReread once |
| +// a superseded publish has read the bucket again, before it publishes |
| +// again. |
| +var escrowHooks struct { |
| + afterCapture func(host string) |
| + afterReread func(host string) |
| +} |
| + |
| +// writeEscrowLedger keeps base as host's ledger (a test seam). |
| +var writeEscrowLedger = writeEscrowLedgerFile |
| + |
| +// EscrowSweepReport is one sweep's outcome: hosts whose publish committed, |
| +// hosts with nothing to publish, hosts left for the next sweep by the cap, |
| +// and hosts whose publish failed, sorted. |
| +type EscrowSweepReport struct { |
| + Published, Unchanged, Deferred int |
| + Failing []string |
| +} |
| + |
| +// statStamp is what decides "unchanged" for one escrowed file without |
| +// reading it: absent, or its size, mtime, ctime and inode. |
| +type statStamp struct { |
| + absent bool |
| + size, mtime, ctime int64 |
| + ino uint64 |
| +} |
| + |
| +// 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. |
| +type escrowState struct { |
| + op sync.Mutex |
| + |
| + pub *hostfiles.Publisher |
| + seal *hostfiles.ItemSealer |
| + // stamps is each escrowed file's stamp as the publisher last staged it, |
| + // by item; an item without one is read by the next publish. |
| + stamps map[string]statStamp |
| + // minted names the secrets this box minted for the host since its env |
| + // was last escrowed: a re-read that finds another value escrowed for |
| + // one of them stops rather than publish 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 |
| +} |
| + |
| +// escrowBook is the backend's escrow state: one escrowState per host and |
| +// the sweep's round-robin cursor, under one mutex. |
| +type escrowBook struct { |
| + mu sync.Mutex |
| + hosts map[string]*escrowState |
| + cursor string |
| + // capOverride replaces escrowSweepCap when set (tests only). |
| + capOverride int |
| +} |
| + |
| +func (k *escrowBook) state(host string) *escrowState { |
| + k.mu.Lock() |
| + defer k.mu.Unlock() |
| + if k.hosts == nil { |
| + k.hosts = map[string]*escrowState{} |
| + } |
| + st := k.hosts[host] |
| + if st == nil { |
| + st = &escrowState{} |
| + k.hosts[host] = st |
| + } |
| + return st |
| +} |
| + |
| +func (k *escrowBook) with(f func()) { |
| + k.mu.Lock() |
| + defer k.mu.Unlock() |
| + f() |
| +} |
| + |
| +// install makes pub the host's publisher, with no stamps: every file is |
| +// read by the next publish. |
| +func (k *escrowBook) install(st *escrowState, pub *hostfiles.Publisher, seal *hostfiles.ItemSealer) { |
| + k.with(func() { st.pub, st.seal, st.stamps, st.fromBucket = pub, seal, nil, false }) |
| +} |
| + |
| +// drop forgets st's publisher and stamps; the host's next operation opens |
| +// from the bucket. |
| +func (k *escrowBook) drop(st *escrowState) { |
| + k.with(func() { st.pub, st.stamps, st.fromBucket = nil, nil, true }) |
| +} |
| + |
| +func (k *escrowBook) sweepCap() int { |
| + if k.capOverride > 0 { |
| + return k.capOverride |
| + } |
| + return escrowSweepCap |
| +} |
| + |
| +// pubLayout is the classifier's layout for l: only flat and nested rows |
| +// are escrowed. |
| +func pubLayout(l Layout) (pubclass.Layout, bool) { |
| + switch l { |
| + case LayoutFlat: |
| + return pubclass.Flat, true |
| + case LayoutNested: |
| + return pubclass.Nested, true |
| + } |
| + return 0, false |
| +} |
| + |
| +// escrowEligible reports whether rt's secrets are escrowed, from the row |
| +// and the box's layout facts alone (plan 3a choice 5): an exec or rootfs |
| +// instance the activator launches here, on the flat or nested layout, not |
| +// HA, not a replica, not a sidecar, not held, not unit-backed, under this |
| +// box's hibernate prefix, with a host and app a sealer can bind. An HA host |
| +// whose row does not say so is the caller's to rule out first (haHostNow). |
| +func (b *ExecBackend) escrowEligible(rt registry.Route) bool { |
| + return b.escrowEligibleAt(rt, b.pathsFor(rt).layout) |
| +} |
| + |
| +func (b *ExecBackend) escrowEligibleAt(rt registry.Route, l Layout) bool { |
| + if b.Cfg.Bucket == "" || !ActivatorManaged(rt) || rt.Unit != "" || rt.IsSidecar() || |
| + rt.HA || rt.Replica || rt.HoldOp != "" || registry.IsHold(rt.Status) || |
| + !controlname.ValidHostShape(rt.Host) || !release.ValidApp(rt.App) { |
| + return false |
| + } |
| + _, ok := pubLayout(l) |
| + return ok |
| +} |
| + |
| +// 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. |
| +func (b *ExecBackend) escrowReady(rt registry.Route) error { |
| + if b.FilesStore == nil || b.EscrowKey == nil { |
| + return ErrEscrowNotReady |
| + } |
| + if _, err := b.sealerFor(rt); err != nil { |
| + return fmt.Errorf("%w: %v", ErrEscrowNotReady, err) |
| + } |
| + return nil |
| +} |
| + |
| +// escrowLedgerPath is host's ledger: <dataDir>/.escrow/<host>.json, in a |
| +// directory of mode 0700, the file 0600. |
| +func escrowLedgerPath(dataDir, host string) string { |
| + return filepath.Join(dataDir, ".escrow", host+".json") |
| +} |
| + |
| +// writeEscrowLedgerFile keeps base, the manifest just committed, as host's |
| +// ledger, durably. |
| +func writeEscrowLedgerFile(dataDir, host string, base hostfiles.Baseline) error { |
| + if !base.Found { |
| + return errors.New("no manifest to keep") |
| + } |
| + if _, err := instancefs.EnsureDirBeneath(dataDir, ".escrow", 0o700); err != nil { |
| + return err |
| + } |
| + body, err := json.Marshal(filesBaselineFile{V: 1, ETag: base.ETag, Body: base.Body}) |
| + if err != nil { |
| + return err |
| + } |
| + return writeFileDurably(escrowLedgerPath(dataDir, host), body) |
| +} |
| + |
| +// readEscrowLedger is host's ledger; ok is false when there is none or it |
| +// cannot be read, and the caller reads the bucket instead. |
| +func readEscrowLedger(dataDir, host string) (hostfiles.Baseline, bool) { |
| + raw, err := readCappedFile(escrowLedgerPath(dataDir, host), maxBaselineBytes) |
| + if err != nil { |
| + return hostfiles.Baseline{}, false |
| + } |
| + var f filesBaselineFile |
| + if err := json.Unmarshal(raw, &f); err != nil || f.V != 1 || f.ETag == "" || len(f.Body) == 0 { |
| + return hostfiles.Baseline{}, false |
| + } |
| + return hostfiles.Baseline{Found: true, Body: f.Body, ETag: f.ETag}, true |
| +} |
| + |
| +// baselineManifest is base's manifest, empty when there is none. |
| +func baselineManifest(base hostfiles.Baseline) (hostfiles.Manifest, error) { |
| + m := hostfiles.Manifest{V: hostfiles.ManifestVersion, Entries: map[string]hostfiles.Entry{}, Platform: map[string]hostfiles.Entry{}} |
| + if !base.Found { |
| + return m, nil |
| + } |
| + if err := json.Unmarshal(base.Body, &m); err != nil { |
| + return m, fmt.Errorf("the files manifest: %w", err) |
| + } |
| + if m.Platform == nil { |
| + m.Platform = map[string]hostfiles.Entry{} |
| + } |
| + return m, nil |
| +} |
| + |
| +// escrowedIn reports whether base holds a sealed env item. |
| +func escrowedIn(base hostfiles.Baseline) bool { |
| + m, err := baselineManifest(base) |
| + if err != nil { |
| + return false |
| + } |
| + _, ok := m.Platform[hostfiles.SealedEnvItem] |
| + return ok |
| +} |
| + |
| +// ledgerEscrowed reports whether host's ledger holds a sealed env item: |
| +// this box has escrowed the host before. It decides only that a launch |
| +// may go ahead without a fresh escrow write, never a restore or a mint. |
| +func (b *ExecBackend) ledgerEscrowed(host string) bool { |
| + base, ok := readEscrowLedger(b.DataDir, host) |
| + return ok && escrowedIn(base) |
| +} |
| + |
| +// escrowStampRacy is how recent a file's change may be for its stamp not |
| +// to be trusted: a file changed again within one timestamp tick of the |
| +// read, at the same size, would keep the stamp the read took. A stamp |
| +// that recent is not kept, so the next sweep reads the file again (a local |
| +// read; the keyed digest makes an unchanged one cost no request). |
| +const escrowStampRacy = 2 * time.Second |
| + |
| +// readStamped opens rel beneath dir with no link followed and without |
| +// blocking on a FIFO (the open ReadBeneathLimitOrAbsent makes), and |
| +// stamps it. It reads the bytes, at most haEnvReadLimit, only when the |
| +// stamp is not prev. absent is decided beneath the one descriptor. keep is |
| +// false for a stamp too recent to trust (escrowStampRacy). |
| +func readStamped(dir, rel string, prev *statStamp) (st statStamp, body []byte, unchanged, keep bool, err error) { |
| + now := time.Now() |
| + f, absent, err := instancefs.OpenBeneathOrAbsent(dir, rel) |
| + if err != nil { |
| + return statStamp{}, nil, false, false, err |
| + } |
| + if absent { |
| + st = statStamp{absent: true} |
| + return st, nil, prev != nil && *prev == st, true, nil |
| + } |
| + defer f.Close() |
| + fi, err := f.Stat() |
| + if err != nil { |
| + return statStamp{}, nil, false, false, err |
| + } |
| + st = stampOf(fi) |
| + if prev != nil && *prev == st { |
| + return st, nil, true, true, nil |
| + } |
| + cutoff := now.Add(-escrowStampRacy).UnixNano() |
| + keep = st.mtime < cutoff && st.ctime < cutoff |
| + if fi.Size() > haEnvReadLimit { |
| + return statStamp{}, nil, false, false, fmt.Errorf("%w: %s over %d bytes", instancefs.ErrTooLarge, filepath.Join(dir, rel), haEnvReadLimit) |
| + } |
| + body, err = io.ReadAll(io.LimitReader(f, haEnvReadLimit+1)) |
| + if err != nil { |
| + return statStamp{}, nil, false, false, err |
| + } |
| + if len(body) > haEnvReadLimit { |
| + return statStamp{}, nil, false, false, fmt.Errorf("%w: %s over %d bytes", instancefs.ErrTooLarge, filepath.Join(dir, rel), haEnvReadLimit) |
| + } |
| + return st, body, false, keep, nil |
| +} |
| + |
| +// openEscrowLocked is st's publisher, opened when it has none: from the |
| +// ledger (no read), else from the bucket (one GET). st.op is held. |
| +func (b *ExecBackend) openEscrowLocked(ctx context.Context, rt registry.Route, st *escrowState) (*hostfiles.Publisher, *hostfiles.ItemSealer, error) { |
| + var ( |
| + pub *hostfiles.Publisher |
| + seal *hostfiles.ItemSealer |
| + fromBucket bool |
| + ) |
| + b.escrow.with(func() { pub, seal, fromBucket = st.pub, st.seal, st.fromBucket }) |
| + if pub != nil && seal != nil { |
| + return pub, seal, nil |
| + } |
| + seal, err := b.sealerFor(rt) |
| + if err != nil { |
| + return nil, nil, fmt.Errorf("%w: %v", ErrEscrowNotReady, err) |
| + } |
| + prefix := b.filesPrefix(rt.Host) |
| + if !fromBucket { |
| + if base, ok := readEscrowLedger(b.DataDir, rt.Host); ok { |
| + if p, err := hostfiles.OpenBaseline(b.FilesStore, prefix, base); err == nil { |
| + pub = p |
| + } |
| + } |
| + } |
| + if pub == nil { |
| + if pub, err = hostfiles.Open(ctx, b.FilesStore, prefix); err != nil { |
| + return nil, nil, fmt.Errorf("read the escrow: %w", err) |
| + } |
| + } |
| + b.escrow.install(st, pub, seal) |
| + return pub, seal, nil |
| +} |
| + |
| +// escrowPublish is one publish's outcome: the manifest the publisher holds |
| +// after it (committed, or as it was), whether this publish committed |
| +// anything, and whether the host has a committed escrow. |
| +type escrowPublish struct { |
| + base hostfiles.Baseline |
| + seal *hostfiles.ItemSealer |
| + committed bool |
| + exists bool |
| +} |
| + |
| +// 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. |
| +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 |
| +} |
| + |
| +func (b *ExecBackend) publishEscrowAt(ctx context.Context, rt registry.Route, p instancePaths, env []byte) (escrowPublish, error) { |
| + if err := b.escrowReady(rt); err != nil { |
| + return escrowPublish{exists: b.ledgerEscrowed(rt.Host)}, err |
| + } |
| + 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) |
| + } |
| + st := b.escrow.state(rt.Host) |
| + st.op.Lock() |
| + defer st.op.Unlock() |
| + return b.publishEscrowLocked(ctx, rt, p, lay, st, env) |
| +} |
| + |
| +// escrowRead is one escrowed file as a publish found it. |
| +type escrowRead struct { |
| + rel pubclass.SealedRel |
| + plain []byte |
| + stamp *statStamp // nil: none to keep (the launch's capture, a refusal, a stamp too recent) |
| + stage bool |
| +} |
| + |
| +func (b *ExecBackend) publishEscrowLocked(ctx context.Context, rt registry.Route, p instancePaths, lay pubclass.Layout, st *escrowState, env []byte) (escrowPublish, error) { |
| + var ( |
| + pub *hostfiles.Publisher |
| + stamps map[string]statStamp |
| + ) |
| + b.escrow.with(func() { |
| + pub = st.pub |
| + stamps = make(map[string]statStamp, len(st.stamps)) |
| + for k, v := range st.stamps { |
| + stamps[k] = v |
| + } |
| + }) |
| + // Read first: a host with nothing to stage opens nothing and makes no |
| + // request. |
| + var ( |
| + reads []escrowRead |
| + refused []error |
| + envRead bool |
| + ) |
| + for _, r := range pubclass.SealedRels(lay, rt.Host) { |
| + item := r.Item() |
| + if item == hostfiles.SealedEnvItem && env != nil { |
| + reads = append(reads, escrowRead{rel: r, plain: env, stage: true}) |
| + envRead = true |
| + continue |
| + } |
| + var prev *statStamp |
| + if s, ok := stamps[item]; ok { |
| + prev = &s |
| + } |
| + s, body, unchanged, keepStamp, err := readStamped(p.dataDir, filepath.FromSlash(r.Rel()), prev) |
| + stamp := &s |
| + if !keepStamp { |
| + stamp = nil |
| + } |
| + switch { |
| + case err != nil: |
| + // Nothing is published for this item, and no stamp is kept, so |
| + // the next sweep tries it again. |
| + refused = append(refused, fmt.Errorf("%s: %w", r.Rel(), err)) |
| + reads = append(reads, escrowRead{rel: r}) |
| + case unchanged || s.absent: |
| + // Absent stages nothing: absence never deletes an escrow. |
| + reads = append(reads, escrowRead{rel: r, stamp: stamp}) |
| + default: |
| + reads = append(reads, escrowRead{rel: r, plain: body, stamp: stamp, stage: true}) |
| + if item == hostfiles.SealedEnvItem { |
| + envRead = true |
| + } |
| + } |
| + } |
| + staging := pub != nil && pub.Dirty() |
| + for _, r := range reads { |
| + staging = staging || r.stage |
| + } |
| + // keep records what was read: an item with a stamp is the publisher's |
| + // as of that stamp; the launch's capture, or a refused item, leaves |
| + // none, so the next sweep reads it. |
| + keep := func() { |
| + b.escrow.with(func() { |
| + if st.stamps == nil { |
| + st.stamps = map[string]statStamp{} |
| + } |
| + for _, r := range reads { |
| + if r.stamp != nil { |
| + st.stamps[r.rel.Item()] = *r.stamp |
| + } else { |
| + delete(st.stamps, r.rel.Item()) |
| + } |
| + } |
| + }) |
| + } |
| + if !staging { |
| + out := escrowPublish{exists: b.ledgerEscrowed(rt.Host)} |
| + if pub != nil { |
| + out.base = pub.Baseline() |
| + out.exists = escrowedIn(out.base) |
| + } |
| + keep() |
| + return out, errors.Join(refused...) |
| + } |
| + pub, seal, err := b.openEscrowLocked(ctx, rt, st) |
| + if err != nil { |
| + return escrowPublish{exists: b.ledgerEscrowed(rt.Host)}, err |
| + } |
| + before := pub.Baseline() |
| + out := escrowPublish{base: before, seal: seal, exists: escrowedIn(before)} |
| + for _, r := range reads { |
| + if !r.stage { |
| + continue |
| + } |
| + if err := pub.StageSealed(ctx, r.rel, r.plain, seal); err != nil { |
| + return out, err |
| + } |
| + } |
| + // Any raw secret an older box published under this prefix goes in the |
| + // same commit (manifest only, no object deleted). |
| + if err := pub.DropRawSecrets(rawSecretEntries); err != nil { |
| + return out, err |
| + } |
| + if _, err := pub.Commit(ctx); err != nil { |
| + if errors.Is(err, hostfiles.ErrSuperseded) { |
| + b.escrow.drop(st) |
| + } |
| + // The stamps are not kept: the next publish reads the files again |
| + // and its commit retries what this one staged. |
| + return out, err |
| + } |
| + after := pub.Baseline() |
| + out.base, out.exists = after, escrowedIn(after) |
| + out.committed = before.ETag != after.ETag || before.Found != after.Found |
| + if envRead { |
| + b.escrow.with(func() { st.minted = nil }) |
| + } |
| + keep() |
| + if out.committed { |
| + if err := writeEscrowLedger(b.DataDir, rt.Host, after); err != nil { |
| + log.Printf("activator: %s: escrow: the ledger was not written (%v); the next escrow of the host reads the bucket", rt.Host, err) |
| + b.escrow.drop(st) |
| + } |
| + } |
| + 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. On a box that is not |
| +// ready it restores nothing and refuses, unless the host has a ledger and |
| +// its env file is here. |
| +func (b *ExecBackend) restoreEscrowIfMissing(ctx context.Context, rt registry.Route, p instancePaths) error { |
| + lay, ok := pubLayout(p.layout) |
| + if !ok { |
| + return fmt.Errorf("escrow: not restored: the row's layout is %s", p.layout) |
| + } |
| + rels := pubclass.SealedRels(lay, rt.Host) |
| + missing := map[string]bool{} |
| + 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) |
| + } |
| + if absent { |
| + missing[r.Item()] = true |
| + } else { |
| + f.Close() |
| + } |
| + } |
| + if err := b.escrowReady(rt); err != nil { |
| + switch { |
| + case missing[hostfiles.SealedEnvItem]: |
| + return fmt.Errorf("%w: the env file is missing and its escrow cannot be read here", err) |
| + case !b.ledgerEscrowed(rt.Host): |
| + return fmt.Errorf("%w: the host was never escrowed from this box, and its escrow cannot be read here", err) |
| + } |
| + 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 |
| + } |
| + if len(missing) == 0 { |
| + return nil |
| + } |
| + st := b.escrow.state(rt.Host) |
| + st.op.Lock() |
| + defer st.op.Unlock() |
| + 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 |
| + } |
| + if _, ok := m.Platform[r.Item()]; !ok { |
| + continue |
| + } |
| + plain, err := hostfiles.ReadSealed(ctx, b.FilesStore, prefix, m, r.Item(), nil, seal) |
| + if err != nil { |
| + return fmt.Errorf("%w: the escrow in the bucket does not open here: %v", ErrEscrowNotReady, err) |
| + } |
| + dir, name := p.dataDir, filepath.FromSlash(r.Rel()) |
| + if sub, base, ok := strings.Cut(r.Rel(), "/"); ok { |
| + if _, err := instancefs.EnsureDirBeneath(p.dataDir, sub, 0o700); err != nil { |
| + return fmt.Errorf("escrow: restore %s: %w", r.Rel(), err) |
| + } |
| + dir, name = filepath.Join(p.dataDir, sub), base |
| + } |
| + wrote, err := writeIfAbsent(dir, name, plain) |
| + if err != nil { |
| + return fmt.Errorf("escrow: restore %s: %w", r.Rel(), err) |
| + } |
| + if wrote { |
| + log.Printf("activator: %s: escrow: restored %s from the bucket", rt.Host, r.Rel()) |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// escrowRestoreSuffix names the temporary a restore writes before it moves |
| +// it into place. |
| +const escrowRestoreSuffix = ".escrow-restore" |
| + |
| +// writeIfAbsent writes data at name under dir, mode 0600, only if nothing |
| +// is there: a temporary written beside it is renamed with no replace, so a |
| +// file that appeared since the check is kept and the temporary dropped. |
| +func writeIfAbsent(dir, name string, data []byte) (bool, error) { |
| + tmp := "." + name + escrowRestoreSuffix |
| + if err := instancefs.WriteAtomic(dir, tmp, data, 0o600); err != nil { |
| + return false, err |
| + } |
| + if err := instancefs.RenameBetweenNoReplace(dir, tmp, dir, name); err != nil { |
| + _ = removeIfThere(dir, tmp) |
| + if errors.Is(err, os.ErrExist) { |
| + return false, nil |
| + } |
| + return false, err |
| + } |
| + return true, syncDirIfThere(dir) |
| +} |
| + |
| +// escrowMintGuard is an eligible host's mint decision. On a box that is |
| +// not ready it refuses every mint (ErrEscrowNotReady). 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 { |
| + if err := b.escrowReady(rt); err != nil { |
| + return func(name string) error { |
| + return fmt.Errorf("refusing to mint %s: %w", name, err) |
| + } |
| + } |
| + var ( |
| + once sync.Once |
| + env map[string]string |
| + verdict error |
| + ) |
| + read := func() { |
| + escrowed, found, err := b.bucketEscrowEnv(ctx, rt) |
| + switch { |
| + case err != nil: |
| + verdict = fmt.Errorf("refusing to mint: %w", err) |
| + case found: |
| + env = parseEnvBytes(escrowed) |
| + } |
| + } |
| + return func(name string) error { |
| + once.Do(read) |
| + if verdict != nil { |
| + return verdict |
| + } |
| + if env[name] != "" { |
| + return fmt.Errorf("%w: the host's escrow in the bucket holds %s and the local env file lacks it, so nothing is minted beside it", ErrInstanceKeyDeferred, name) |
| + } |
| + st := b.escrow.state(rt.Host) |
| + b.escrow.with(func() { |
| + if st.minted == nil { |
| + st.minted = map[string]bool{} |
| + } |
| + st.minted[name] = true |
| + }) |
| + return nil |
| + } |
| +} |
| + |
| +// 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 { |
| + return nil, false, nil |
| + } |
| + seal, err := b.sealerFor(rt) |
| + if err != nil { |
| + return nil, false, fmt.Errorf("%w: %v", ErrEscrowNotReady, err) |
| + } |
| + plain, err := hostfiles.ReadSealed(ctx, b.FilesStore, b.filesPrefix(rt.Host), m, hostfiles.SealedEnvItem, nil, seal) |
| + if err != nil { |
| + return nil, false, fmt.Errorf("%w: the escrow in the bucket does not open here: %v", ErrEscrowNotReady, err) |
| + } |
| + return plain, true, nil |
| +} |
| + |
| +// errEscrowWriter is the alert a second supersession raises. |
| +func errEscrowWriter(host string) error { |
| + return fmt.Errorf("ALERT: %s: escrow: another writer publishes this host's escrow", host) |
| +} |
| + |
| +// 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. |
| +func (b *ExecBackend) escrowReread(ctx context.Context, rt registry.Route, p instancePaths) error { |
| + st := b.escrow.state(rt.Host) |
| + st.op.Lock() |
| + defer st.op.Unlock() |
| + seal, err := b.sealerFor(rt) |
| + if err != nil { |
| + return fmt.Errorf("%w: %v", ErrEscrowNotReady, err) |
| + } |
| + pub, err := hostfiles.Open(ctx, b.FilesStore, b.filesPrefix(rt.Host)) |
| + if err != nil { |
| + return fmt.Errorf("escrow: read the bucket again: %w", err) |
| + } |
| + b.escrow.install(st, pub, seal) |
| + 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 |
| +} |
| + |
| +// escrowedLaunchEnv is launchEnvLayer for an eligible host: the env |
| +// 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). On a box that is not ready, a host this |
| +// box escrowed before launches on its local env, logged. |
| +func (b *ExecBackend) escrowedLaunchEnv(ctx context.Context, rt registry.Route) (map[string]string, instancekey.Layer, error) { |
| + for attempt := 0; ; attempt++ { |
| + p := b.pathsFor(rt) |
| + c, err := b.captureLaunchEnv(rt) |
| + if err != nil { |
| + return nil, instancekey.LayerNone, fmt.Errorf("secrets for %s: %w", rt.Host, err) |
| + } |
| + if escrowHooks.afterCapture != nil { |
| + escrowHooks.afterCapture(rt.Host) |
| + } |
| + if err := b.escrowReady(rt); err != nil { |
| + if !b.ledgerEscrowed(rt.Host) { |
| + return nil, instancekey.LayerNone, fmt.Errorf("secrets for %s: %w", rt.Host, err) |
| + } |
| + 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 c.env, c.layer, nil |
| + } |
| + r, err := b.publishEscrowAt(ctx, rt, p, c.own) |
| + switch { |
| + case errors.Is(err, hostfiles.ErrSuperseded): |
| + if attempt > 0 { |
| + err := errEscrowWriter(rt.Host) |
| + log.Print(err) |
| + return nil, instancekey.LayerNone, err |
| + } |
| + if err := b.escrowReread(ctx, rt, p); err != nil { |
| + return nil, instancekey.LayerNone, fmt.Errorf("secrets for %s: %w", rt.Host, err) |
| + } |
| + // The preparation again, from the restore: the bucket's copy |
| + // may be the one to launch with now. |
| + if err := b.ensureAdminTokenFor(ctx, rt, p); err != nil { |
| + return nil, instancekey.LayerNone, fmt.Errorf("admin token for %s: %w", rt.Host, err) |
| + } |
| + if _, err := b.ensureInstanceKeyFor(ctx, rt, p); err != nil { |
| + return nil, instancekey.LayerNone, fmt.Errorf("instance key for %s: %w", rt.Host, err) |
| + } |
| + continue |
| + 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: |
| + log.Printf("activator: %s: escrow: %v (launching; the next sweep escrows it again)", rt.Host, err) |
| + return c.env, c.layer, nil |
| + } |
| + m, err := baselineManifest(r.base) |
| + if err != nil { |
| + return nil, instancekey.LayerNone, fmt.Errorf("secrets for %s: %w", rt.Host, err) |
| + } |
| + if !hostfiles.SealedAcknowledged(m, hostfiles.SealedEnvItem, c.own, r.seal) { |
| + return nil, instancekey.LayerNone, fmt.Errorf("secrets for %s: the escrow does not hold the env this launch read", rt.Host) |
| + } |
| + return c.env, c.layer, nil |
| + } |
| +} |
| + |
| +// haKnown is the HA classification as far as memory answers it, no read: |
| +// known is false when only a record read could tell (a lifetime index miss |
| +// on a box with a record source). The sweep leaves such a host to its |
| +// launches, which classify it with the read. |
| +func (b *ExecBackend) haKnown(rt registry.Route) (ha, known bool) { |
| + if s, ok := b.haWakes.get(rt.Host); ok { |
| + return s.ha, true |
| + } |
| + if haLegacyRoute(rt) { |
| + return false, true |
| + } |
| + if rt.HA { |
| + return true, true |
| + } |
| + if b.Lifetimes != nil { |
| + if e, ok := b.Lifetimes.Lookup(rt.Host); ok { |
| + if e.HA { |
| + return true, true |
| + } |
| + if e.ID != "" { |
| + return false, true |
| + } |
| + } |
| + } |
| + return false, b.Cfg.Record == nil |
| +} |
| + |
| +// escrowChanged reports whether rt's escrow may need a publish: a pending |
| +// commit, no stamps, or a file whose stamp moved. It reads no file's |
| +// bytes and makes no request. |
| +func (b *ExecBackend) escrowChanged(rt registry.Route, p instancePaths, lay pubclass.Layout) bool { |
| + st := b.escrow.state(rt.Host) |
| + var ( |
| + pub *hostfiles.Publisher |
| + stamps map[string]statStamp |
| + ) |
| + b.escrow.with(func() { pub, stamps = st.pub, st.stamps }) |
| + if pub != nil && pub.Dirty() { |
| + return true |
| + } |
| + for _, r := range pubclass.SealedRels(lay, rt.Host) { |
| + prev, ok := stamps[r.Item()] |
| + if !ok { |
| + return true |
| + } |
| + s, err := stampAt(p.dataDir, filepath.FromSlash(r.Rel())) |
| + if err != nil || s != prev { |
| + return true |
| + } |
| + } |
| + return false |
| +} |
| + |
| +// stampAt is rel's stamp beneath dir, the open readStamped makes. |
| +func stampAt(dir, rel string) (statStamp, error) { |
| + f, absent, err := instancefs.OpenBeneathOrAbsent(dir, rel) |
| + if err != nil { |
| + return statStamp{}, err |
| + } |
| + if absent { |
| + return statStamp{absent: true}, nil |
| + } |
| + defer f.Close() |
| + fi, err := f.Stat() |
| + if err != nil { |
| + return statStamp{}, err |
| + } |
| + return stampOf(fi), nil |
| +} |
| + |
| +// 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. |
| +func (b *ExecBackend) EscrowSweep(ctx context.Context, rows []registry.Route) EscrowSweepReport { |
| + var rep EscrowSweepReport |
| + if b.FilesStore == nil || b.EscrowKey == nil { |
| + return rep |
| + } |
| + // The layout from the rows in hand: one registry read per sweep, not |
| + // one per row. |
| + in := b.layoutInputs() |
| + in.Peers = func() ([]registry.Route, error) { return rows, nil } |
| + type cand struct { |
| + rt registry.Route |
| + p instancePaths |
| + lay pubclass.Layout |
| + } |
| + var cands []cand |
| + seen := map[string]bool{} |
| + for _, rt := range rows { |
| + if seen[rt.Host] { |
| + continue |
| + } |
| + l, reason := Classify(rt, in) |
| + lay, ok := pubLayout(l) |
| + if !ok || !b.escrowEligibleAt(rt, l) { |
| + continue |
| + } |
| + if ha, known := b.haKnown(rt); ha || !known { |
| + continue |
| + } |
| + seen[rt.Host] = true |
| + 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 }) |
| + var cursor string |
| + b.escrow.with(func() { cursor = b.escrow.cursor }) |
| + start := sort.Search(len(cands), func(i int) bool { return cands[i].rt.Host > cursor }) |
| + order := append(append([]cand(nil), cands[start:]...), cands[:start]...) |
| + |
| + limit := b.escrow.sweepCap() |
| + sem := make(chan struct{}, escrowSweepWorkers) |
| + var ( |
| + wg sync.WaitGroup |
| + mu sync.Mutex |
| + last string |
| + sent int |
| + ) |
| + for _, c := range order { |
| + if ctx.Err() != nil { |
| + break |
| + } |
| + if !b.escrowChanged(c.rt, c.p, c.lay) { |
| + rep.Unchanged++ |
| + continue |
| + } |
| + if sent >= limit { |
| + rep.Deferred++ |
| + continue |
| + } |
| + sent++ |
| + last = c.rt.Host |
| + sem <- struct{}{} |
| + wg.Add(1) |
| + go func(c cand) { |
| + defer wg.Done() |
| + defer func() { <-sem }() |
| + 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) |
| + // 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: ") { |
| + log.Print(err) |
| + } else { |
| + logPerFile("escrow", c.rt.Host, fmt.Sprintf("activator: %s: escrow: %v (retried every sweep)", c.rt.Host, err)) |
| + } |
| + case committed: |
| + rep.Published++ |
| + default: |
| + rep.Unchanged++ |
| + } |
| + }(c) |
| + } |
| + wg.Wait() |
| + if last != "" { |
| + b.escrow.with(func() { b.escrow.cursor = last }) |
| + } |
| + sort.Strings(rep.Failing) |
| + return rep |
| +} |
| + |
| +// sweepPublish is the sweep's publish of one host: on another writer's |
| +// commit it reads the bucket, decides again, and publishes once more; a |
| +// second conflict is the alert. |
| +func (b *ExecBackend) sweepPublish(ctx context.Context, rt registry.Route, p instancePaths) (bool, error) { |
| + r, err := b.publishEscrowAt(ctx, rt, p, nil) |
| + if errors.Is(err, hostfiles.ErrSuperseded) { |
| + if err := b.escrowReread(ctx, rt, p); err != nil { |
| + return false, err |
| + } |
| + r, err = b.publishEscrowAt(ctx, rt, p, nil) |
| + if errors.Is(err, hostfiles.ErrSuperseded) { |
| + return false, errEscrowWriter(rt.Host) |
| + } |
| + } |
| + return r.committed, err |
| +} |
| + |
| +// SecretsEscrowed reports whether rt's secrets live in the bucket and are |
| +// minted only on a launch: HA, or eligible for escrow (ready or not). A |
| +// scheduled tick only reads such a host's token. |
| +func (b *ExecBackend) SecretsEscrowed(ctx context.Context, rt registry.Route) (bool, error) { |
| + ha, err := b.haHostNow(ctx, rt) |
| + if err != nil { |
| + return false, err |
| + } |
| + return ha || b.escrowEligible(rt), nil |
| +} |
| + |
| +// escrowSweeper is the Backend capability the Service's escrow sweep and |
| +// SecretsEscrowed ask (ExecBackend's; SplitBackend forwards to its exec |
| +// half). |
| +type escrowSweeper interface { |
| + EscrowSweep(ctx context.Context, rows []registry.Route) EscrowSweepReport |
| + SecretsEscrowed(ctx context.Context, rt registry.Route) (bool, error) |
| +} |
| + |
| +func (b *SplitBackend) EscrowSweep(ctx context.Context, rows []registry.Route) EscrowSweepReport { |
| + if s, ok := b.Exec.(escrowSweeper); ok { |
| + return s.EscrowSweep(ctx, rows) |
| + } |
| + return EscrowSweepReport{} |
| +} |
| + |
| +func (b *SplitBackend) SecretsEscrowed(ctx context.Context, rt registry.Route) (bool, error) { |
| + if s, ok := b.Exec.(escrowSweeper); ok { |
| + return s.SecretsEscrowed(ctx, rt) |
| + } |
| + return b.IsHA(ctx, rt) |
| +} |
| + |
| +// EscrowSweep runs the backend's escrow sweep over rows (internal/host's |
| +// escrowLoop, every EscrowEvery). A backend with no escrow does nothing. |
| +func (a *Service) EscrowSweep(ctx context.Context, rows []registry.Route) EscrowSweepReport { |
| + if a != nil { |
| + if s, ok := a.backend.(escrowSweeper); ok { |
| + return s.EscrowSweep(ctx, rows) |
| + } |
| + } |
| + return EscrowSweepReport{} |
| +} |
| + |
| +// SecretsEscrowed is the backend's SecretsEscrowed for the rest of the box |
| +// (internal/host's scheduled ticks): IsHA on a Service whose backend has |
| +// no escrow. |
| +func (a *Service) SecretsEscrowed(ctx context.Context, rt registry.Route) (bool, error) { |
| + if a != nil { |
| + if s, ok := a.backend.(escrowSweeper); ok { |
| + return s.SecretsEscrowed(ctx, rt) |
| + } |
| + } |
| + return a.IsHA(ctx, rt) |
| +} |
diff --git a/internal/activator/escrow_linux_test.go b/internal/activator/escrow_linux_test.go| new file mode 100644 |
| index 000000000..599696409 |
| --- /dev/null |
| +++ b/internal/activator/escrow_linux_test.go |
| @@ -0,0 +1,103 @@ |
| +//go:build linux |
| + |
| +package activator |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "os" |
| + "path/filepath" |
| + "syscall" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/registry" |
| +) |
| + |
| +// Review Focus 5: a tenant plants a symlink, a FIFO or a 2 GiB file at one |
| +// of the escrowed names. The sweep refuses that item without following, |
| +// blocking or reading past 1 MiB, publishes nothing for it, names the host |
| +// failing, and still escrows the rest. |
| +func TestEscrowReadRefusesLinkFIFOAndOversize(t *testing.T) { |
| + for _, tc := range []struct { |
| + name, item string |
| + plant func(t *testing.T, path string) |
| + }{ |
| + {name: "symlink at the env", item: "env.sealed", plant: func(t *testing.T, path string) { |
| + secret := filepath.Join(t.TempDir(), "litestream.env") |
| + if err := os.WriteFile(secret, []byte("AWS_SECRET=planted\n"), 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.Symlink(secret, path); err != nil { |
| + t.Fatal(err) |
| + } |
| + }}, |
| + {name: "fifo at instance.key", item: "instance.key.sealed", plant: func(t *testing.T, path string) { |
| + if err := syscall.Mkfifo(path, 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + }}, |
| + {name: "2 GiB at report.token", item: "report.token.sealed", plant: func(t *testing.T, path string) { |
| + f, err := os.Create(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer f.Close() |
| + if err := f.Truncate(2 << 30); err != nil { |
| + t.Fatal(err) |
| + } |
| + }}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + b, rt := escrowBackend(t, escrowHost) |
| + files := map[string]string{"instance.key": "ik", "report.token": "rt"} |
| + env := envA |
| + var path string |
| + switch tc.item { |
| + case "env.sealed": |
| + path, env = b.pathsFor(rt).envFile, "" |
| + case "instance.key.sealed": |
| + delete(files, "instance.key") |
| + path = filepath.Join(filesDirOf(b, rt), "instance.key") |
| + case "report.token.sealed": |
| + delete(files, "report.token") |
| + path = filepath.Join(filesDirOf(b, rt), "report.token") |
| + } |
| + if env != "" { |
| + writeEnv(t, b, rt, env) |
| + } |
| + writeFiles(t, b, rt, files) |
| + tc.plant(t, path) |
| + |
| + done := make(chan EscrowSweepReport, 1) |
| + go func() { done <- b.EscrowSweep(context.Background(), []registry.Route{rt}) }() |
| + var rep EscrowSweepReport |
| + select { |
| + case rep = <-done: |
| + case <-time.After(20 * time.Second): |
| + t.Fatal("the sweep blocked on the planted file") |
| + } |
| + if len(rep.Failing) != 1 || rep.Failing[0] != rt.Host { |
| + t.Fatalf("sweep: %+v, want the host failing", rep) |
| + } |
| + m := loadManifest(t, b, rt) |
| + if _, ok := m.Platform[tc.item]; ok { |
| + t.Fatalf("%s was published", tc.item) |
| + } |
| + // The rest is escrowed. |
| + for _, item := range []string{"env.sealed", "instance.key.sealed", "report.token.sealed"} { |
| + if item == tc.item { |
| + continue |
| + } |
| + if _, ok := m.Platform[item]; !ok { |
| + t.Errorf("%s was not escrowed beside the refused item", item) |
| + } |
| + } |
| + for key, body := range prefixObjects(t, b, rt) { |
| + if bytes.Contains(body, []byte("planted")) { |
| + t.Fatalf("%s holds the link target's bytes", key) |
| + } |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/activator/escrow_stamp_linux.go b/internal/activator/escrow_stamp_linux.go| new file mode 100644 |
| index 000000000..a98af9da8 |
| --- /dev/null |
| +++ b/internal/activator/escrow_stamp_linux.go |
| @@ -0,0 +1,18 @@ |
| +//go:build linux |
| + |
| +package activator |
| + |
| +import ( |
| + "os" |
| + "syscall" |
| +) |
| + |
| +// stampOf is an escrowed file's stamp from its fstat: size, mtime, ctime |
| +// and inode, so a rewrite, a chmod or a replacement by rename each move it. |
| +func stampOf(fi os.FileInfo) statStamp { |
| + s := statStamp{size: fi.Size(), mtime: fi.ModTime().UnixNano()} |
| + if st, ok := fi.Sys().(*syscall.Stat_t); ok { |
| + s.ino, s.ctime = st.Ino, st.Ctim.Nano() |
| + } |
| + return s |
| +} |
diff --git a/internal/activator/escrow_stamp_other.go b/internal/activator/escrow_stamp_other.go| new file mode 100644 |
| index 000000000..ee86abd48 |
| --- /dev/null |
| +++ b/internal/activator/escrow_stamp_other.go |
| @@ -0,0 +1,12 @@ |
| +//go:build !linux |
| + |
| +package activator |
| + |
| +import "os" |
| + |
| +// stampOf is an escrowed file's stamp: size and mtime only here. The |
| +// escrow's reads are Linux-only (instancefs), so nothing stamps a file on |
| +// another system. |
| +func stampOf(fi os.FileInfo) statStamp { |
| + return statStamp{size: fi.Size(), mtime: fi.ModTime().UnixNano()} |
| +} |
diff --git a/internal/activator/escrow_test.go b/internal/activator/escrow_test.go| new file mode 100644 |
| index 000000000..c5c3d71be |
| --- /dev/null |
| +++ b/internal/activator/escrow_test.go |
| @@ -0,0 +1,825 @@ |
| +package activator |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "encoding/json" |
| + "errors" |
| + "fmt" |
| + "os" |
| + "path/filepath" |
| + "strings" |
| + "sync" |
| + "sync/atomic" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/domains" |
| + "github.com/carlosframework/platform/internal/hostfiles" |
| + "github.com/carlosframework/platform/internal/instancectl" |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// Durability 3a, Task 4: the sealed escrow of every other activator host. |
| +// Every witness here runs through the production backend: the real |
| +// ExecBackend with a files store and an escrow key, the real launch |
| +// preparation (prepareKeyedAt) or the real Service wake, and the real |
| +// sweep. |
| + |
| +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. |
| +func escrowBackend(t *testing.T, host string) (*ExecBackend, registry.Route) { |
| + t.Helper() |
| + b, rt := haBackendEmptyIndex(t, host) |
| + notHA(b, host) |
| + run, err := os.MkdirTemp("", "esc") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(func() { os.RemoveAll(run) }) |
| + b.RunDirOverride = run |
| + rt.Socket = nestedRoute(b, host).Socket |
| + if err := b.Registry.Upsert(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + return b, rt |
| +} |
| + |
| +// notHA makes the deployment store's record and the lifetime index say |
| +// host is not HA. |
| +func notHA(b *ExecBackend, host string) { |
| + h := haFixOf(b) |
| + h.mu.Lock() |
| + h.records[host] = haRecord(host, false) |
| + h.mu.Unlock() |
| + b.Lifetimes.Merge(map[string]provision.Record{host: haRecord(host, false)}) |
| +} |
| + |
| +// escrowService is haService for a host that is not HA: the real Service |
| +// wake through the legacy lease, the nested start and the files store the |
| +// lease shares. |
| +func escrowService(t *testing.T, host string) *haSvc { |
| + t.Helper() |
| + s := haService(t, host) |
| + s.b.Lifetimes = &provision.LifetimeIndex{} |
| + notHA(s.b, host) |
| + 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. |
| +func restartEscrow(t *testing.T, b *ExecBackend) *ExecBackend { |
| + t.Helper() |
| + nb := testExecBackend(t) |
| + nb.Cfg = b.Cfg |
| + nb.OptDir, nb.DataDir, nb.RunDirOverride = b.OptDir, b.DataDir, b.RunDirOverride |
| + nb.FilesStore, nb.EscrowKey, nb.Registry, nb.Lifetimes = b.FilesStore, b.EscrowKey, b.Registry, b.Lifetimes |
| + nb.Control, nb.StartupSwept = b.Control, b.StartupSwept |
| + haFixtures.Store(nb, haFixOf(b)) |
| + t.Cleanup(func() { haFixtures.Delete(nb) }) |
| + return nb |
| +} |
| + |
| +// otherBox is a second box of the same deployment publishing the same |
| +// 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.DataDir = filepath.Join(t.TempDir(), "data") |
| + if err := os.MkdirAll(ob.DataDir, 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + ort := rt |
| + ort.DBPath = provision.NestedDBPath(ob.DataDir, rt.Host) |
| + return ob, ort |
| +} |
| + |
| +func envFileBytes(t *testing.T, b *ExecBackend, rt registry.Route) string { |
| + t.Helper() |
| + raw, err := os.ReadFile(b.pathsFor(rt).envFile) |
| + if errors.Is(err, os.ErrNotExist) { |
| + return "" |
| + } |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return string(raw) |
| +} |
| + |
| +// sealedItem is the plaintext of the host's sealed item in the bucket, "" |
| +// when the manifest holds none. |
| +func sealedItem(t *testing.T, b *ExecBackend, rt registry.Route, item string) string { |
| + t.Helper() |
| + ctx := context.Background() |
| + m := loadManifest(t, b, rt) |
| + if _, ok := m.Platform[item]; !ok { |
| + return "" |
| + } |
| + plain, err := hostfiles.ReadSealed(ctx, b.FilesStore, b.filesPrefix(rt.Host), m, item, nil, sealerOf(t, b, rt)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return string(plain) |
| +} |
| + |
| +func mustPublish(t *testing.T, b *ExecBackend, rt registry.Route) { |
| + t.Helper() |
| + exists, err := b.publishEscrow(context.Background(), rt, nil) |
| + if err != nil || !exists { |
| + t.Fatalf("publish: exists %v, %v", exists, err) |
| + } |
| +} |
| + |
| +// launchToken is the CARLOS_ADMIN_TOKEN of the launch file root was last |
| +// handed for rt's run role. |
| +func launchToken(t *testing.T, b *ExecBackend, rt registry.Route) string { |
| + t.Helper() |
| + raw, err := os.ReadFile(filepath.Join(b.pathsFor(rt).dataDir, instancectl.LaunchFileName(instancectl.RoleRun))) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var l instancectl.Launch |
| + if err := json.Unmarshal(raw, &l); err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, kv := range l.Env { |
| + if v, ok := strings.CutPrefix(kv, "CARLOS_ADMIN_TOKEN="); ok { |
| + return v |
| + } |
| + } |
| + return "" |
| +} |
| + |
| +// countingStore counts every request a files store is asked. |
| +type countingStore struct { |
| + release.Store |
| + gets, puts, others atomic.Int64 |
| +} |
| + |
| +func (s *countingStore) Get(ctx context.Context, key string) ([]byte, string, error) { |
| + s.gets.Add(1) |
| + return s.Store.Get(ctx, key) |
| +} |
| + |
| +func (s *countingStore) Put(ctx context.Context, key string, body []byte, ifMatch string) (string, error) { |
| + s.puts.Add(1) |
| + return s.Store.Put(ctx, key, body, ifMatch) |
| +} |
| + |
| +func (s *countingStore) List(ctx context.Context, prefix string) ([]string, error) { |
| + s.others.Add(1) |
| + return s.Store.List(ctx, prefix) |
| +} |
| + |
| +// failingPuts is a files store that refuses every write. |
| +type failingPuts struct{ release.Store } |
| + |
| +func (failingPuts) Put(context.Context, string, []byte, string) (string, error) { |
| + return "", errors.New("store unavailable") |
| +} |
| + |
| +const ( |
| + envA = "CARLOS_ADMIN_TOKEN=tok-a\nCARLOS_INSTANCE_KEY=key-a\n" |
| + envB = "CARLOS_ADMIN_TOKEN=tok-b\nCARLOS_INSTANCE_KEY=key-b\n" |
| +) |
| + |
| +// The escrow publishes the env and the trio sealed, in both layouts, and |
| +// no object under the prefix holds a secret's bytes. |
| +func TestEscrowPublishesSealedEnvAndTrio(t *testing.T) { |
| + for _, layout := range []string{"nested", "flat"} { |
| + t.Run(layout, func(t *testing.T) { |
| + b, rt := escrowBackend(t, escrowHost) |
| + if layout == "flat" { |
| + flattenRoute(t, b, &rt) |
| + if err := b.Registry.Upsert(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if !b.escrowEligible(rt) { |
| + t.Fatal("the fixture's row is not eligible") |
| + } |
| + writeEnv(t, b, rt, envA) |
| + writeFiles(t, b, rt, map[string]string{"instance.key": "ik-secret", "report.token": "rt-secret", "a.txt": "app"}) |
| + mustPublish(t, b, rt) |
| + m := loadManifest(t, b, rt) |
| + for item, want := range map[string]string{hostfiles.SealedEnvItem: envA, "instance.key.sealed": "ik-secret", "report.token.sealed": "rt-secret"} { |
| + if got := sealedItem(t, b, rt, item); got != want { |
| + t.Errorf("%s: %q, want %q", item, got, want) |
| + } |
| + } |
| + if _, ok := m.Platform[hostfiles.CutoverItem]; !ok { |
| + t.Error("no cutover marker beside the first sealed item") |
| + } |
| + if _, ok := m.Platform[hostfiles.EnvItem]; ok || len(liveEntries(m)) != 0 { |
| + t.Errorf("raw items published: platform %v, entries %v", m.Platform, liveEntries(m)) |
| + } |
| + for key, body := range prefixObjects(t, b, rt) { |
| + for _, secret := range []string{"tok-a", "key-a", "ik-secret", "rt-secret"} { |
| + if bytes.Contains(body, []byte(secret)) { |
| + t.Errorf("%s holds %s in plain", key, secret) |
| + } |
| + } |
| + } |
| + if _, err := os.Stat(escrowLedgerPath(b.DataDir, rt.Host)); err != nil { |
| + t.Errorf("no ledger after the commit: %v", err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// An unchanged host costs nothing, across a restart too: the new agent's |
| +// first sweep reads the ledger and the local files, and makes no request. |
| +func TestUnchangedEscrowMakesNoRequestAfterARestart(t *testing.T) { |
| + b, rt := escrowBackend(t, escrowHost) |
| + writeEnv(t, b, rt, envA) |
| + writeFiles(t, b, rt, map[string]string{"instance.key": "ik"}) |
| + if rep := b.EscrowSweep(context.Background(), []registry.Route{rt}); rep.Published != 1 || len(rep.Failing) != 0 { |
| + t.Fatalf("the first sweep: %+v", rep) |
| + } |
| + nb := restartEscrow(t, b) |
| + cs := &countingStore{Store: b.FilesStore} |
| + nb.FilesStore = cs |
| + for i := 0; i < 2; i++ { |
| + rep := nb.EscrowSweep(context.Background(), []registry.Route{rt}) |
| + if rep.Unchanged != 1 || rep.Published != 0 || len(rep.Failing) != 0 { |
| + t.Fatalf("sweep %d after the restart: %+v", i, rep) |
| + } |
| + } |
| + if g, p, o := cs.gets.Load(), cs.puts.Load(), cs.others.Load(); g != 0 || p != 0 || o != 0 { |
| + t.Fatalf("unchanged sweeps made %d GETs, %d PUTs, %d other requests", g, p, o) |
| + } |
| +} |
| + |
| +// Eligibility is the row's and the box's layout facts': an HA row, a |
| +// replica, a sidecar, a held row, a fenced or unit-backed row is never |
| +// escrowed, and the sweep publishes nothing for any of them. |
| +func TestEscrowEligibilitySkipsWhatItMustNot(t *testing.T) { |
| + b, base := escrowBackend(t, escrowHost) |
| + if !b.escrowEligible(base) { |
| + t.Fatal("the base row is not eligible") |
| + } |
| + writeEnv(t, b, base, envA) |
| + for _, tc := range []struct { |
| + name string |
| + change func(rt *registry.Route) |
| + fence bool |
| + }{ |
| + {name: "ha", change: func(rt *registry.Route) { rt.HA = true }}, |
| + {name: "replica", change: func(rt *registry.Route) { rt.Replica = true }}, |
| + {name: "sidecar", change: func(rt *registry.Route) { rt.Kind = "sidecar" }}, |
| + {name: "hold", change: func(rt *registry.Route) { rt.Status, rt.HoldOp = "moving", "move" }}, |
| + {name: "unit", change: func(rt *registry.Route) { rt.Backing = registry.BackingUnit }}, |
| + {name: "fenced", fence: true}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + rt := base |
| + if tc.change != nil { |
| + tc.change(&rt) |
| + } |
| + if tc.fence { |
| + b.LayoutFacts.Journal = func(string) bool { return true } |
| + t.Cleanup(func() { b.LayoutFacts.Journal = nil }) |
| + } |
| + if b.escrowEligible(rt) { |
| + t.Fatal("eligible") |
| + } |
| + if rep := b.EscrowSweep(context.Background(), []registry.Route{rt}); rep.Published+rep.Unchanged+rep.Deferred != 0 || len(rep.Failing) != 0 { |
| + t.Fatalf("the sweep visited it: %+v", rep) |
| + } |
| + if objs := prefixObjects(t, b, rt); len(objs) != 0 { |
| + t.Fatalf("published %d objects", len(objs)) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// An eligible host on a box that is not ready (no key, or no files store) |
| +// never restores, never mints and never makes its first launch, through |
| +// the real wake and the backfill. With a ledger and a complete local env it |
| +// launches. |
| +func TestNotReadyRefusesRestoreMintAndFirstLaunch(t *testing.T) { |
| + for _, gap := range []string{"no key", "no files store"} { |
| + t.Run(gap, func(t *testing.T) { |
| + ctx := context.Background() |
| + s := escrowService(t, escrowHost) |
| + writeEnv(t, s.b, s.rt, envA) |
| + mustPublish(t, s.b, s.rt) |
| + ledger := escrowLedgerPath(s.b.DataDir, s.rt.Host) |
| + kept, err := os.ReadFile(ledger) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + nb := restartEscrow(t, s.b) |
| + s.b = nb |
| + s.wire(nb) |
| + s.a = New(Config{Bucket: nb.Cfg.Bucket, Idle: time.Hour}, nb, nb.Registry) |
| + t.Cleanup(s.abandon) |
| + if gap == "no key" { |
| + nb.EscrowKey = nil |
| + } else { |
| + nb.FilesStore = nil |
| + } |
| + if err := nb.escrowReady(s.rt); !errors.Is(err, ErrEscrowNotReady) { |
| + t.Fatalf("ready: %v", err) |
| + } |
| + if ok, err := s.a.SecretsEscrowed(ctx, s.rt); !ok || err != nil { |
| + t.Fatalf("SecretsEscrowed %v, %v", ok, err) |
| + } |
| + |
| + // The env is gone and the escrow is in the bucket: no restore, no |
| + // mint, no launch. |
| + if err := os.Remove(nb.pathsFor(s.rt).envFile); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := s.wakeForTest(ctx); !errors.Is(err, ErrEscrowNotReady) { |
| + t.Fatalf("wake with the env gone: %v", err) |
| + } |
| + if exists(nb.pathsFor(s.rt).envFile) || spawns(nb) != 0 { |
| + t.Fatalf("env written %v, spawns %d", exists(nb.pathsFor(s.rt).envFile), spawns(nb)) |
| + } |
| + |
| + // No ledger: the host may have an escrow this box cannot see, so |
| + // its launch is refused even with a complete env. |
| + if err := os.Remove(ledger); err != nil { |
| + t.Fatal(err) |
| + } |
| + writeEnv(t, nb, s.rt, envA) |
| + if _, err := s.wakeForTest(ctx); !errors.Is(err, ErrEscrowNotReady) { |
| + t.Fatalf("wake with no ledger: %v", err) |
| + } |
| + |
| + // A mint is refused: the backfill writes nothing. |
| + writeEnv(t, nb, s.rt, "CARLOS_ADMIN_TOKEN=tok-a\n") |
| + if _, err := nb.BackfillInstanceKey(ctx, s.rt); !errors.Is(err, ErrEscrowNotReady) { |
| + t.Fatalf("backfill: %v", err) |
| + } |
| + if got := envFileBytes(t, nb, s.rt); got != "CARLOS_ADMIN_TOKEN=tok-a\n" { |
| + t.Fatalf("the backfill changed the env: %q", got) |
| + } |
| + |
| + // A ledger and a complete env: the launch goes ahead. |
| + if err := os.WriteFile(ledger, kept, 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + writeEnv(t, nb, s.rt, envA) |
| + e, err := s.wakeForTest(ctx) |
| + if err != nil || e == nil { |
| + t.Fatalf("wake with a ledger and a complete env: %v", err) |
| + } |
| + if got := envFileBytes(t, nb, s.rt); got != envA { |
| + t.Fatalf("env %q", got) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// The production wake mints and escrows; with <host>.env and |
| +// <host>/instance.key deleted, the next wake brings both back byte for |
| +// byte and launches with the first token. |
| +func TestEscrowSurvivesALostEnvAcrossWakes(t *testing.T) { |
| + ctx := context.Background() |
| + s := escrowService(t, escrowHost) |
| + e, err := s.wakeForTest(ctx) |
| + if err != nil { |
| + t.Fatalf("wake: %v\n%s", err, s.ctl.joined()) |
| + } |
| + env := envFileBytes(t, s.b, s.rt) |
| + tok := launchToken(t, s.b, s.rt) |
| + if tok == "" || !strings.Contains(env, "CARLOS_ADMIN_TOKEN="+tok) || !strings.Contains(env, InstanceKeyVar+"=") { |
| + t.Fatalf("the first wake: env %q, launch token %q", env, tok) |
| + } |
| + if got := sealedItem(t, s.b, s.rt, hostfiles.SealedEnvItem); got != env { |
| + t.Fatalf("escrow %q, want the launch's env %q", got, env) |
| + } |
| + // The app writes its instance.key; the sweep escrows it. |
| + writeFiles(t, s.b, s.rt, map[string]string{"instance.key": "ik-1"}) |
| + if rep := s.b.EscrowSweep(ctx, []registry.Route{s.rt}); rep.Published != 1 { |
| + t.Fatalf("sweep: %+v", rep) |
| + } |
| + s.stopForTest(e) |
| + |
| + if err := os.Remove(s.b.pathsFor(s.rt).envFile); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.Remove(filepath.Join(filesDirOf(s.b, s.rt), "instance.key")); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := s.wakeForTest(ctx); err != nil { |
| + t.Fatalf("the second wake: %v\n%s", err, s.ctl.joined()) |
| + } |
| + if got := envFileBytes(t, s.b, s.rt); got != env { |
| + t.Fatalf("restored env %q, want %q", got, env) |
| + } |
| + if got := restoredSecret(t, filepath.Join(filesDirOf(s.b, s.rt), "instance.key")); got != "ik-1" { |
| + t.Fatalf("restored instance.key %q", got) |
| + } |
| + if got := launchToken(t, s.b, s.rt); got != tok { |
| + t.Fatalf("the second launch's token %q, want the first's %q", got, tok) |
| + } |
| +} |
| + |
| +// A crash between the commit and the ledger write: the ledger still says |
| +// A, the bucket says B. A lost env comes back as B, the bucket's. |
| +func TestCrashBetweenCommitAndLedgerRestoresTheBucketVersion(t *testing.T) { |
| + b, rt := escrowBackend(t, escrowHost) |
| + writeEnv(t, b, rt, envA) |
| + mustPublish(t, b, rt) |
| + ledgerA, err := os.ReadFile(escrowLedgerPath(b.DataDir, rt.Host)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + writeEnv(t, b, rt, envB) |
| + old := writeEscrowLedger |
| + writeEscrowLedger = func(string, string, hostfiles.Baseline) error { return errors.New("disk full") } |
| + mustPublish(t, b, rt) |
| + writeEscrowLedger = old |
| + if got, _ := os.ReadFile(escrowLedgerPath(b.DataDir, rt.Host)); !bytes.Equal(got, ledgerA) { |
| + t.Fatal("the fixture's ledger moved past A") |
| + } |
| + if got := sealedItem(t, b, rt, hostfiles.SealedEnvItem); got != envB { |
| + t.Fatalf("bucket %q, want B", got) |
| + } |
| + nb := restartEscrow(t, b) |
| + if err := os.Remove(nb.pathsFor(rt).envFile); err != nil { |
| + t.Fatal(err) |
| + } |
| + env, err := nb.launchEnvForTest(rt) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if got := envFileBytes(t, nb, rt); got != envB || env["CARLOS_ADMIN_TOKEN"] != "tok-b" { |
| + t.Fatalf("restored %q (launch token %q), want B", got, env["CARLOS_ADMIN_TOKEN"]) |
| + } |
| +} |
| + |
| +// The ledger says the escrow holds no key, the bucket says it does: a |
| +// local env without one is never minted one. |
| +func TestStaleLedgerNeverAuthorizesAMint(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) |
| + writeEnv(t, b, rt, envB) |
| + old := writeEscrowLedger |
| + writeEscrowLedger = func(string, string, hostfiles.Baseline) error { return errors.New("disk full") } |
| + mustPublish(t, b, rt) |
| + writeEscrowLedger = old |
| + // The new agent's ledger is A's, which holds no key. |
| + nb := restartEscrow(t, b) |
| + 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) |
| + } |
| + if got := envFileBytes(t, nb, rt); got != "CARLOS_ADMIN_TOKEN=tok-b\n" { |
| + t.Fatalf("env %q: something was minted", got) |
| + } |
| +} |
| + |
| +// The launch publishes and acknowledges the bytes it captured, and is |
| +// handed those: a replacement after the capture is the next sweep's. |
| +func TestLaunchPublishesItsOwnCapture(t *testing.T) { |
| + b, rt := escrowBackend(t, escrowHost) |
| + writeEnv(t, b, rt, envA) |
| + escrowHooks.afterCapture = func(host string) { |
| + if host == rt.Host { |
| + writeEnv(t, b, rt, envB) |
| + } |
| + } |
| + t.Cleanup(func() { escrowHooks.afterCapture = nil }) |
| + env, err := b.launchEnvForTest(rt) |
| + escrowHooks.afterCapture = nil |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if env["CARLOS_ADMIN_TOKEN"] != "tok-a" { |
| + t.Fatalf("the launch was handed %q", env["CARLOS_ADMIN_TOKEN"]) |
| + } |
| + if got := sealedItem(t, b, rt, hostfiles.SealedEnvItem); got != envA { |
| + t.Fatalf("escrow %q, want the capture", got) |
| + } |
| + if rep := b.EscrowSweep(context.Background(), []registry.Route{rt}); rep.Published != 1 { |
| + t.Fatalf("sweep: %+v", rep) |
| + } |
| + if got := sealedItem(t, b, rt, hostfiles.SealedEnvItem); got != envB { |
| + t.Fatalf("after the sweep the escrow is %q, want B", got) |
| + } |
| +} |
| + |
| +// A restore writes only into a missing file: a local env and a local |
| +// instance.key are left as they are; a missing report.token comes back. |
| +func TestRestoreNeverOverwritesALocalEnv(t *testing.T) { |
| + b, rt := escrowBackend(t, escrowHost) |
| + writeEnv(t, b, rt, envA) |
| + writeFiles(t, b, rt, map[string]string{"instance.key": "ik-a", "report.token": "rt-a"}) |
| + mustPublish(t, b, rt) |
| + writeEnv(t, b, rt, envB) |
| + writeFiles(t, b, rt, map[string]string{"instance.key": "ik-b"}) |
| + if err := os.Remove(filepath.Join(filesDirOf(b, rt), "report.token")); err != nil { |
| + t.Fatal(err) |
| + } |
| + nb := restartEscrow(t, b) |
| + if _, err := nb.launchEnvForTest(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got := envFileBytes(t, nb, rt); got != envB { |
| + t.Fatalf("env %q, want the local B", got) |
| + } |
| + if got := readFile(t, nb, rt, "instance.key"); got != "ik-b" { |
| + t.Fatalf("instance.key %q, want the local one", got) |
| + } |
| + if got := readFile(t, nb, rt, "report.token"); got != "rt-a" { |
| + t.Fatalf("report.token %q, want the escrow's", got) |
| + } |
| +} |
| + |
| +// The escrow holds both secrets and the local env lacks them: nothing is |
| +// minted, by the launch or by the backfill. |
| +func TestNoMintWhileTheEscrowHoldsTheSecret(t *testing.T) { |
| + b, rt := escrowBackend(t, escrowHost) |
| + writeEnv(t, b, rt, envA) |
| + mustPublish(t, b, rt) |
| + writeEnv(t, b, rt, "OTHER=1\n") |
| + nb := restartEscrow(t, b) |
| + if _, err := nb.launchEnvForTest(rt); !errors.Is(err, ErrInstanceKeyDeferred) { |
| + t.Fatalf("launch: %v", err) |
| + } |
| + writeEnv(t, nb, rt, "CARLOS_ADMIN_TOKEN=tok-a\n") |
| + if _, err := nb.BackfillInstanceKey(context.Background(), rt); !errors.Is(err, ErrInstanceKeyDeferred) { |
| + t.Fatalf("backfill: %v", err) |
| + } |
| + if got := envFileBytes(t, nb, rt); got != "CARLOS_ADMIN_TOKEN=tok-a\n" { |
| + t.Fatalf("env %q: something was minted", got) |
| + } |
| +} |
| + |
| +// The escrow lacks the key: it is minted, and the launch escrows it. |
| +func TestMintAllowedWhenTheEscrowLacksTheSecret(t *testing.T) { |
| + b, rt := escrowBackend(t, escrowHost) |
| + writeEnv(t, b, rt, "CARLOS_ADMIN_TOKEN=tok-a\n") |
| + mustPublish(t, b, rt) |
| + nb := restartEscrow(t, b) |
| + env, err := nb.launchEnvForTest(rt) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + key := env[InstanceKeyVar] |
| + if key == "" || env["CARLOS_ADMIN_TOKEN"] != "tok-a" { |
| + t.Fatalf("launch env %v", env) |
| + } |
| + if got := sealedItem(t, nb, rt, hostfiles.SealedEnvItem); !strings.Contains(got, InstanceKeyVar+"="+key) { |
| + t.Fatalf("escrow %q lacks the minted key", got) |
| + } |
| +} |
| + |
| +// A failed escrow write holds the first launch only: with no ledger the |
| +// launch fails; with one it goes ahead. |
| +func TestFirstLaunchHeldWhenTheEscrowCannotBeWritten(t *testing.T) { |
| + b, rt := escrowBackend(t, escrowHost) |
| + store := b.FilesStore |
| + b.FilesStore = failingPuts{store} |
| + 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 |
| + if _, err := b.launchEnvForTest(rt); err != nil { |
| + t.Fatalf("a launch with the store back: %v", err) |
| + } |
| + nb := restartEscrow(t, b) |
| + nb.FilesStore = failingPuts{store} |
| + writeEnv(t, nb, rt, envFileBytes(t, nb, rt)+"FOO=2\n") |
| + if _, err := nb.launchEnvForTest(rt); err != nil { |
| + t.Fatalf("a later launch was held: %v", err) |
| + } |
| +} |
| + |
| +// An edited env is escrowed, and a launch after it keeps the edit. |
| +func TestEditedEnvIsEscrowedNotReverted(t *testing.T) { |
| + b, rt := escrowBackend(t, escrowHost) |
| + writeEnv(t, b, rt, envA) |
| + mustPublish(t, b, rt) |
| + edited := envA + "FOO=1\n" |
| + writeEnv(t, b, rt, edited) |
| + if rep := b.EscrowSweep(context.Background(), []registry.Route{rt}); rep.Published != 1 { |
| + t.Fatalf("sweep: %+v", rep) |
| + } |
| + if got := sealedItem(t, b, rt, hostfiles.SealedEnvItem); got != edited { |
| + t.Fatalf("escrow %q", got) |
| + } |
| + if _, err := b.launchEnvForTest(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got := envFileBytes(t, b, rt); got != edited { |
| + t.Fatalf("env reverted to %q", got) |
| + } |
| +} |
| + |
| +// Absence never deletes an escrow: the env and the trio missing (a layout |
| +// migration mid-move, say) leave every sealed item in place. |
| +func TestAbsentEnvNeverDeletesTheEscrow(t *testing.T) { |
| + b, rt := escrowBackend(t, escrowHost) |
| + writeEnv(t, b, rt, envA) |
| + writeFiles(t, b, rt, map[string]string{"instance.key": "ik"}) |
| + mustPublish(t, b, rt) |
| + if err := os.Remove(b.pathsFor(rt).envFile); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.RemoveAll(filesDirOf(b, rt)); err != nil { |
| + t.Fatal(err) |
| + } |
| + for i := 0; i < 2; i++ { |
| + if rep := b.EscrowSweep(context.Background(), []registry.Route{rt}); rep.Published != 0 || len(rep.Failing) != 0 { |
| + t.Fatalf("sweep %d: %+v", i, rep) |
| + } |
| + } |
| + if sealedItem(t, b, rt, hostfiles.SealedEnvItem) != envA || sealedItem(t, b, rt, "instance.key.sealed") != "ik" { |
| + t.Fatal("an absent file deleted its escrow") |
| + } |
| +} |
| + |
| +// 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) { |
| + ctx := context.Background() |
| + b, rt := escrowBackend(t, escrowHost) |
| + writeEnv(t, b, rt, envA) |
| + mustPublish(t, b, rt) |
| + ob, ort := otherBox(t, b, rt) |
| + writeEnv(t, ob, ort, envB) |
| + mustPublish(t, ob, ort) |
| + |
| + 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) |
| + } |
| + 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) |
| + } |
| + 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 { |
| + 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 }) |
| + writeEnv(t, b, rt, envA+"FOO=2\n") |
| + rep := b.EscrowSweep(ctx, []registry.Route{rt}) |
| + if rep.Published != 0 || len(rep.Failing) != 1 || rep.Failing[0] != rt.Host { |
| + 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) |
| + } |
| +} |
| + |
| +// latencyStore answers every request after d, and records how many were |
| +// in flight at once. |
| +type latencyStore struct { |
| + release.Store |
| + d time.Duration |
| + inflight, peak atomic.Int64 |
| + requests atomic.Int64 |
| +} |
| + |
| +func (s *latencyStore) wait() func() { |
| + s.requests.Add(1) |
| + n := s.inflight.Add(1) |
| + for { |
| + p := s.peak.Load() |
| + if n <= p || s.peak.CompareAndSwap(p, n) { |
| + break |
| + } |
| + } |
| + time.Sleep(s.d) |
| + return func() { s.inflight.Add(-1) } |
| +} |
| + |
| +func (s *latencyStore) Get(ctx context.Context, key string) ([]byte, string, error) { |
| + defer s.wait()() |
| + return s.Store.Get(ctx, key) |
| +} |
| + |
| +func (s *latencyStore) Put(ctx context.Context, key string, body []byte, ifMatch string) (string, error) { |
| + defer s.wait()() |
| + return s.Store.Put(ctx, key, body, ifMatch) |
| +} |
| + |
| +// sweepRows is n eligible rows on b, each with an env file, in the |
| +// lifetime index as not HA. |
| +func sweepRows(t *testing.T, b *ExecBackend, n int) []registry.Route { |
| + t.Helper() |
| + var rows []registry.Route |
| + recs := map[string]provision.Record{} |
| + for i := 0; i < n; i++ { |
| + host := fmt.Sprintf("h%03d.example.com", i) |
| + rt := nestedRoute(b, host) |
| + rt.Provisioned, rt.App, rt.Account, rt.Status = true, "shop", domains.Sqid(2), "ready" |
| + rows = append(rows, rt) |
| + recs[host] = haRecord(host, false) |
| + writeEnv(t, b, rt, "CARLOS_ADMIN_TOKEN=t"+host+"\n") |
| + } |
| + b.Lifetimes.Merge(recs) |
| + return rows |
| +} |
| + |
| +// The first sweep after a roll, every one of 252 hosts changed, against a |
| +// store answering in 50 ms: all 252 are published inside one 30 s sweep |
| +// period, 8 at a time. Time is scaled: the store sleeps 5 ms for each |
| +// 50 ms it stands for. |
| +func TestSweepBurstOf252MeetsTheDeadline(t *testing.T) { |
| + const scale = 10 |
| + b, _ := escrowBackend(t, escrowHost) |
| + rows := sweepRows(t, b, 252) |
| + ls := &latencyStore{Store: b.FilesStore, d: 50 * time.Millisecond / scale} |
| + b.FilesStore = ls |
| + start := time.Now() |
| + rep := b.EscrowSweep(context.Background(), rows) |
| + elapsed := time.Since(start) * scale |
| + if rep.Published != 252 || rep.Deferred != 0 || len(rep.Failing) != 0 { |
| + t.Fatalf("sweep: %+v", rep) |
| + } |
| + if elapsed >= EscrowEvery { |
| + t.Fatalf("252 publishes took %v of store time, past the %v sweep period", elapsed, EscrowEvery) |
| + } |
| + if p := ls.peak.Load(); p > escrowSweepWorkers || p < 2 { |
| + t.Fatalf("%d requests in flight at most, want 2 to %d", p, escrowSweepWorkers) |
| + } |
| + t.Logf("252 publishes, %d requests, %v of store time, %d in flight at most", ls.requests.Load(), elapsed, ls.peak.Load()) |
| +} |
| + |
| +// Hosts that change before every sweep never starve the rest: with a cap |
| +// of 4, hosts 5 to 8, changed once, are all published within two sweeps. |
| +func TestSweepNeverStarvesLaterHosts(t *testing.T) { |
| + ctx := context.Background() |
| + b, _ := escrowBackend(t, escrowHost) |
| + rows := sweepRows(t, b, 8) |
| + if rep := b.EscrowSweep(ctx, rows); rep.Published != 8 { |
| + t.Fatalf("the first sweep: %+v", rep) |
| + } |
| + b.escrow.capOverride = 4 |
| + for _, rt := range rows[4:] { |
| + writeEnv(t, b, rt, "CHANGED=once\n") |
| + } |
| + for sweep := 0; sweep < 2; sweep++ { |
| + for i, rt := range rows[:4] { |
| + writeEnv(t, b, rt, fmt.Sprintf("CHANGED=%d-%d\n", sweep, i)) |
| + } |
| + if rep := b.EscrowSweep(ctx, rows); rep.Published != 4 || rep.Deferred != 4 { |
| + t.Fatalf("sweep %d: %+v", sweep, rep) |
| + } |
| + } |
| + for _, rt := range rows[4:] { |
| + if got := sealedItem(t, b, rt, hostfiles.SealedEnvItem); got != "CHANGED=once\n" { |
| + t.Fatalf("%s starved: escrow %q", rt.Host, got) |
| + } |
| + } |
| +} |
| + |
| +// A fleet box seals to its own CARLOS_SECRETS_KEY (the fleet's): its |
| +// escrow opens with that key and not with another deployment's. |
| +func TestAFleetBoxSealsToItsOwnKey(t *testing.T) { |
| + ctx := context.Background() |
| + b, rt := escrowBackend(t, escrowHost) |
| + fleetKey, deploymentKey := testEscrowKey(t), testEscrowKey(t) |
| + b.EscrowKey = fleetKey |
| + writeEnv(t, b, rt, envA) |
| + mustPublish(t, b, rt) |
| + m := loadManifest(t, b, rt) |
| + prefix := b.filesPrefix(rt.Host) |
| + if got := sealedItem(t, b, rt, hostfiles.SealedEnvItem); got != envA { |
| + t.Fatalf("the fleet key opens %q", got) |
| + } |
| + other := restartEscrow(t, b) |
| + 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") |
| + } |
| + // A box with the other key never restores it, and refuses the launch. |
| + if err := os.Remove(other.pathsFor(rt).envFile); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := other.launchEnvForTest(rt); !errors.Is(err, ErrEscrowNotReady) || exists(other.pathsFor(rt).envFile) { |
| + t.Fatalf("launch with another key: %v; env written %v", err, exists(other.pathsFor(rt).envFile)) |
| + } |
| +} |
diff --git a/internal/activator/hasecrets.go b/internal/activator/hasecrets.go| index b3371db23..52edbd181 100644 |
| --- a/internal/activator/hasecrets.go |
| +++ b/internal/activator/hasecrets.go |
| @@ -23,7 +23,7 @@ import ( |
| // so any box that wakes the host next restores the same pair. Two rules |
| // keep them one pair: |
| // |
| -// - one mint decision (haMintGuard) inside every producer of either |
| +// - one mint decision (mintGuardFor) inside every producer of either |
| // secret, asked in its missing-secret branch at the moment it would |
| // mint (final review F2): once the host's files manifest exists, |
| // nothing is minted, whatever an earlier read of the env saw. A |
| @@ -69,32 +69,52 @@ func (b *ExecBackend) haHostNow(ctx context.Context, rt registry.Route) (bool, e |
| } |
| // mintGuard is a producer's last word before it mints a missing secret, |
| -// asked in its missing-secret branch: nil lets the mint go ahead; an error |
| -// refuses it, and nothing is written. A nil mintGuard always mints (a host |
| -// that is not HA). |
| -type mintGuard func() error |
| +// asked in its missing-secret branch with the variable it would mint |
| +// ("CARLOS_ADMIN_TOKEN" or InstanceKeyVar): nil lets the mint go ahead; an |
| +// error refuses it, and nothing is written. A nil mintGuard always mints |
| +// (a host that is neither HA nor escrowed). |
| +type mintGuard func(name string) error |
| -// haMintGuard is the one mint decision for an HA host's secrets (r2.3, |
| -// final review F2): nil for a host that is not HA. For an HA host, a |
| -// guard that refuses with ErrInstanceKeyDeferred while the host's files |
| -// manifest exists, and lets the mint go ahead only while it does not. |
| -// It never reads the env: the producer asks it only once its own read |
| -// found the secret missing. The manifest is read at most once per guard, |
| -// and only when a producer would mint (from the wake's publisher when |
| -// there is one, no request). |
| -func (b *ExecBackend) haMintGuard(ctx context.Context, rt registry.Route) (mintGuard, error) { |
| +// mintGuardFor is the one mint decision for rt's secrets. For an HA host |
| +// (r2.3, final review F2), a guard that refuses with |
| +// ErrInstanceKeyDeferred while the host's files manifest exists, and lets |
| +// the mint go ahead only while it does not, whatever the name. For an |
| +// eligible host (escrow.go): on a box that is ready, a guard that reads the |
| +// bucket's manifest when a producer would mint (never the ledger) and |
| +// refuses, wrapping ErrInstanceKeyDeferred, when the escrowed env holds |
| +// the name; on a box that is not ready, one that refuses every mint |
| +// (ErrEscrowNotReady). nil for any other host. No guard reads the env: |
| +// the producer asks it only once its own read found the secret missing. |
| +// 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) { |
| ha, err := b.haHostNow(ctx, rt) |
| if err != nil { |
| return nil, fmt.Errorf("refusing to mint: %w", err) |
| } |
| - if !ha { |
| - return nil, nil |
| + return b.mintGuardAs(ctx, rt, ha), nil |
| +} |
| + |
| +// mintGuardAs is mintGuardFor on an HA classification already made. |
| +func (b *ExecBackend) mintGuardAs(ctx context.Context, rt registry.Route, ha bool) mintGuard { |
| + switch { |
| + case ha: |
| + return b.haMintGuard(ctx, rt) |
| + case b.escrowEligible(rt): |
| + return b.escrowMintGuard(ctx, rt) |
| } |
| + return nil |
| +} |
| + |
| +// haMintGuard is an HA host's guard (mintGuardFor): it refuses while the |
| +// host's files manifest exists, read from the wake's publisher when there |
| +// is one (no request), and ignores the name. |
| +func (b *ExecBackend) haMintGuard(ctx context.Context, rt registry.Route) mintGuard { |
| var ( |
| once sync.Once |
| verdict error |
| ) |
| - return func() error { |
| + return func(string) error { |
| once.Do(func() { |
| found, err := b.haManifestFound(ctx, rt) |
| switch { |
| @@ -105,17 +125,25 @@ func (b *ExecBackend) haMintGuard(ctx context.Context, rt registry.Route) (mintG |
| } |
| }) |
| return verdict |
| - }, nil |
| + } |
| } |
| // ensureAdminTokenFor is the launch paths' admin token producer for rt on |
| -// p's layout, with the host's mint decision inside it (haMintGuard). |
| +// 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. |
| func (b *ExecBackend) ensureAdminTokenFor(ctx context.Context, rt registry.Route, p instancePaths) error { |
| - guard, err := b.haMintGuard(ctx, rt) |
| + ha, err := b.haHostNow(ctx, rt) |
| if err != nil { |
| - return err |
| + return fmt.Errorf("refusing to mint: %w", err) |
| + } |
| + if !ha && b.escrowEligible(rt) { |
| + if err := b.restoreEscrowIfMissing(ctx, rt, p); err != nil { |
| + return err |
| + } |
| } |
| - return ensureAdminToken(p.dataDir, rt.Host+".env", p.layout == LayoutNested, guard) |
| + return ensureAdminToken(p.dataDir, rt.Host+".env", p.layout == LayoutNested, b.mintGuardAs(ctx, rt, ha)) |
| } |
| // capturedEnv is a launch's env files, read once: the own file's bytes, |
| @@ -127,16 +155,14 @@ type capturedEnv struct { |
| } |
| // captureLaunchEnv reads rt's own env file and its rendered configuration |
| -// once, the way instanceEnvParts reads them (beneath on the nested |
| -// layout), and parses the launch's env from those bytes. An own file that |
| -// is absent is an error: the launch's producers have just written it. |
| +// once, beneath the row's data directory on either layout (no link |
| +// followed, no FIFO waited on, at most haEnvReadLimit), and parses the |
| +// launch's env from those bytes. An own file that is absent is an error: |
| +// the launch's producers have just written it. |
| func (b *ExecBackend) captureLaunchEnv(rt registry.Route) (capturedEnv, error) { |
| p := b.pathsFor(rt) |
| read := func(path string) ([]byte, error) { |
| - if p.layout == LayoutNested { |
| - return instancefs.ReadBeneathLimit(filepath.Dir(path), filepath.Base(path), haEnvReadLimit) |
| - } |
| - return os.ReadFile(path) |
| + return instancefs.ReadBeneathLimit(filepath.Dir(path), filepath.Base(path), haEnvReadLimit) |
| } |
| own, err := read(p.envFile) |
| if err != nil { |
| @@ -155,14 +181,18 @@ func (b *ExecBackend) captureLaunchEnv(rt registry.Route) (capturedEnv, error) { |
| // (instanceEnvLayer's answer). For an HA host the env is captured once, |
| // those bytes are published and acknowledged (haSecretsReady), and the |
| // env parsed from them is the one returned: a replacement of the file |
| -// after the read is never what the launch is handed. Any other host's is |
| -// instanceEnvLayer, unchanged. |
| +// after the read is never what the launch is handed. An eligible host's |
| +// takes the same capture into its escrow (escrowedLaunchEnv). Any other |
| +// host's is instanceEnvLayer, unchanged. |
| func (b *ExecBackend) launchEnvLayer(ctx context.Context, rt registry.Route) (map[string]string, instancekey.Layer, error) { |
| ha, err := b.haHostNow(ctx, rt) |
| if err != nil { |
| return nil, instancekey.LayerNone, fmt.Errorf("secrets for %s: %w", rt.Host, err) |
| } |
| if !ha { |
| + if b.escrowEligible(rt) { |
| + return b.escrowedLaunchEnv(ctx, rt) |
| + } |
| return b.instanceEnvLayer(rt) |
| } |
| c, err := b.captureLaunchEnv(rt) |
| @@ -301,19 +331,20 @@ func (a *Service) entryFilesFor(host string) *hostFiles { |
| return nil |
| } |
| -// haScheduledTokener is the Backend capability ServeScheduled asks after a |
| -// tick's wake (ExecBackend's; SplitBackend dispatches it). |
| -type haScheduledTokener interface { |
| - haScheduledToken(ctx context.Context, rt registry.Route) (token string, ha bool, err error) |
| +// escrowedScheduledTokener is the Backend capability ServeScheduled asks |
| +// after a tick's wake (ExecBackend's; SplitBackend dispatches it). |
| +type escrowedScheduledTokener interface { |
| + escrowedScheduledToken(ctx context.Context, rt registry.Route) (token string, escrowed bool, err error) |
| } |
| -// haScheduledToken is an HA host's CARLOS_ADMIN_TOKEN as its env file holds |
| -// it now, after the wake that restored it. ha is false, and nothing is |
| -// read, for a host that is not HA. |
| -func (b *ExecBackend) haScheduledToken(ctx context.Context, rt registry.Route) (string, bool, error) { |
| - ha, err := b.haHostNow(ctx, rt) |
| - if err != nil || !ha { |
| - return "", ha, err |
| +// escrowedScheduledToken is the CARLOS_ADMIN_TOKEN of a host whose secrets |
| +// are escrowed (HA, or eligible for escrow) as its env file holds it now, |
| +// after the wake that restored or minted it. escrowed is false, and |
| +// nothing is read, for any other host. |
| +func (b *ExecBackend) escrowedScheduledToken(ctx context.Context, rt registry.Route) (string, bool, error) { |
| + escrowed, err := b.SecretsEscrowed(ctx, rt) |
| + if err != nil || !escrowed { |
| + return "", escrowed, err |
| } |
| p := b.pathsFor(rt) |
| raw, err := instancefs.ReadBeneathLimit(filepath.Dir(p.envFile), filepath.Base(p.envFile), haEnvReadLimit) |
| @@ -327,25 +358,26 @@ func (b *ExecBackend) haScheduledToken(ctx context.Context, rt registry.Route) ( |
| return tok, true, nil |
| } |
| -func (b *SplitBackend) haScheduledToken(ctx context.Context, rt registry.Route) (string, bool, error) { |
| - if t, ok := b.pick(rt).(haScheduledTokener); ok { |
| - return t.haScheduledToken(ctx, rt) |
| +func (b *SplitBackend) escrowedScheduledToken(ctx context.Context, rt registry.Route) (string, bool, error) { |
| + if t, ok := b.pick(rt).(escrowedScheduledTokener); ok { |
| + return t.escrowedScheduledToken(ctx, rt) |
| } |
| return "", false, nil |
| } |
| -// fillScheduledToken sets a scheduled tick's bearer token for an HA host |
| -// from the env file its wake restored: the runner's own read ran before |
| -// the wake and never mints for an HA host (internal/host scheduleToken), |
| -// so it may have found none, or a stale one. Any other host's tick is left |
| -// as the runner built it. |
| +// fillScheduledToken sets a scheduled tick's bearer token for a host whose |
| +// secrets are escrowed (HA, or eligible for escrow) from the env file its |
| +// wake restored or minted: the runner's own read ran before the wake and |
| +// never mints for such a host (internal/host scheduleToken), so it may |
| +// have found none, or a stale one. Any other host's tick is left as the |
| +// runner built it. |
| func (a *Service) fillScheduledToken(r *http.Request, rt registry.Route) error { |
| - t, ok := a.backend.(haScheduledTokener) |
| + t, ok := a.backend.(escrowedScheduledTokener) |
| if !ok { |
| return nil |
| } |
| - tok, ha, err := t.haScheduledToken(r.Context(), rt) |
| - if err != nil || !ha { |
| + tok, escrowed, err := t.escrowedScheduledToken(r.Context(), rt) |
| + if err != nil || !escrowed { |
| return err |
| } |
| r.Header.Set("Authorization", "Bearer "+tok) |
diff --git a/internal/activator/hasecrets_test.go b/internal/activator/hasecrets_test.go| index fbd127ba0..ae10e4e29 100644 |
| --- a/internal/activator/hasecrets_test.go |
| +++ b/internal/activator/hasecrets_test.go |
| @@ -266,7 +266,9 @@ func TestHALaunchUsesTheEntryPublisher(t *testing.T) { |
| } |
| } |
| -// Not HA: no gate, no publish, nothing read from the files store. |
| +// Neither HA nor escrowed (a row with no app a sealer could bind): no |
| +// gate, no publish, nothing read from the files store. A host that is not |
| +// HA but is eligible is escrowed instead (escrow_test.go). |
| func TestLegacyLaunchPublishesNothing(t *testing.T) { |
| b, rt := haLaunchBackend(t, "shop.example.com") |
| h := haFixOf(b) |
| @@ -274,19 +276,24 @@ func TestLegacyLaunchPublishesNothing(t *testing.T) { |
| h.records[rt.Host] = haRecord(rt.Host, false) |
| h.mu.Unlock() |
| b.Lifetimes = nil |
| + rt.App = "" |
| + if b.escrowEligible(rt) { |
| + t.Fatal("fixture: the row is eligible for escrow") |
| + } |
| publishManifest(t, b, rt, nil, "CARLOS_INSTANCE_KEY=k1\n") |
| writeEnv(t, b, rt, "CARLOS_INSTANCE_KEY=k1\n") |
| if err := b.launchForTest(rt); err != nil || !envFileHas(t, b, rt, "CARLOS_ADMIN_TOKEN") { |
| t.Fatalf("launch: %v", err) |
| } |
| + rt.App = "shop" |
| if strings.Contains(platformEnv(t, b, rt), "CARLOS_ADMIN_TOKEN") { |
| t.Fatal("a legacy host's env was published") |
| } |
| } |
| -// G7: a tick for an HA host carries the token of the env its wake |
| -// restored, whatever the runner read before the wake; any other host's |
| -// tick is left alone. |
| +// G7: a tick for an HA or an escrowed host carries the token of the env |
| +// its wake restored, whatever the runner read before the wake; any other |
| +// host's tick is left alone. |
| func TestFillScheduledToken(t *testing.T) { |
| b, rt := haLaunchBackend(t, "shop.example.com") |
| a := New(Config{Bucket: b.Cfg.Bucket, Idle: time.Hour}, b, b.Registry) |
| @@ -300,11 +307,18 @@ func TestFillScheduledToken(t *testing.T) { |
| if err := a.fillScheduledToken(r, rt); err == nil { |
| t.Fatal("no token after the wake should fail the tick") |
| } |
| + // Not HA but escrowed: the token is filled the same way. |
| h := haFixOf(b) |
| h.mu.Lock() |
| h.records[rt.Host] = haRecord(rt.Host, false) |
| h.mu.Unlock() |
| b.Lifetimes = nil |
| + writeEnv(t, b, rt, "CARLOS_ADMIN_TOKEN=escrowed\n") |
| + if err := a.fillScheduledToken(r, rt); err != nil || r.Header.Get("Authorization") != "Bearer escrowed" { |
| + t.Fatalf("escrowed: %v, header %q", err, r.Header.Get("Authorization")) |
| + } |
| + // Neither: the runner's token is left alone. |
| + rt.App = "" |
| r.Header.Set("Authorization", "Bearer runner") |
| if err := a.fillScheduledToken(r, rt); err != nil || r.Header.Get("Authorization") != "Bearer runner" { |
| t.Fatalf("legacy: %v, header %q", err, r.Header.Get("Authorization")) |
diff --git a/internal/activator/instancekey.go b/internal/activator/instancekey.go| index 75ada0606..755e8cbe2 100644 |
| --- a/internal/activator/instancekey.go |
| +++ b/internal/activator/instancekey.go |
| @@ -264,8 +264,9 @@ func (b *ExecBackend) ensureInstanceKeyFor(ctx context.Context, rt registry.Rout |
| // The agent's backfill names the host when it logs the error, so the |
| // refusal does not. |
| func (b *ExecBackend) BackfillInstanceKey(ctx context.Context, rt registry.Route) (InstanceKeyOutcome, error) { |
| - // An HA host's key is minted only before its manifest exists |
| - // (haMintGuard, inside ensureInstanceKeyAt); the agent's backfill |
| + // An HA host's key is minted only before its manifest exists, and an |
| + // escrowed host's only while its escrow in the bucket lacks one |
| + // (mintGuardFor, inside ensureInstanceKeyAt); the agent's backfill |
| // skips HA hosts before this. |
| return b.ensureInstanceKeyAt(ctx, rt, b.pathsFor(rt), false, "backfilled") |
| } |
| @@ -274,8 +275,8 @@ func (b *ExecBackend) BackfillInstanceKey(ctx context.Context, rt registry.Route |
| // never minted; a fenced or conflicting row is refused on p, the paths the |
| // 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, for an HA host, its mint decision |
| -// (haMintGuard). |
| +// with the bucket reader for rt and the host's mint decision |
| +// (mintGuardFor: an HA host's, or an escrowed host's). |
| func (b *ExecBackend) ensureInstanceKeyAt(ctx context.Context, rt registry.Route, p instancePaths, create bool, verb string) (InstanceKeyOutcome, error) { |
| if rt.Replica { |
| return InstanceKeyReplica, nil |
| @@ -284,7 +285,7 @@ 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.haMintGuard(ctx, rt) |
| + guard, err := b.mintGuardFor(ctx, rt) |
| if err != nil { |
| return InstanceKeyFailed, err |
| } |
| @@ -434,8 +435,8 @@ type bucketVerdict struct { |
| // fail-closed and defer-on-unknown hold on every path. |
| // |
| // guard, when not nil, is asked once the locked read finds no key and the |
| -// bucket allows a mint, before anything is minted (an HA host's |
| -// haMintGuard): its refusal is returned and nothing is written. |
| +// bucket allows a mint, before anything is minted (mintGuardFor), with |
| +// InstanceKeyVar: its refusal is returned and nothing is written. |
| func ensureInstanceKey(ctx context.Context, dir, name string, beneath, create bool, configured configuredKeyReader, guard mintGuard) (InstanceKeyOutcome, error) { |
| path := filepath.Join(dir, name) |
| // Phase one, outside the lock. Nothing delivered here sets a key. The |
| @@ -515,11 +516,11 @@ func ensureInstanceKey(ctx context.Context, dir, name string, beneath, create bo |
| return InstanceKeyFailed, pre.deferral |
| } |
| } |
| - // No key on this read, the one the mint decides from: an HA host's |
| + // No key on this read, the one the mint decides from: the host's |
| // mint decision is asked here, never on an earlier read (final review |
| // F2). |
| if guard != nil { |
| - if err := guard(); err != nil { |
| + if err := guard(InstanceKeyVar); err != nil { |
| return InstanceKeyFailed, err |
| } |
| } |
diff --git a/internal/activator/paths.go b/internal/activator/paths.go| index a3901caec..c7233c30f 100644 |
| --- a/internal/activator/paths.go |
| +++ b/internal/activator/paths.go |
| @@ -32,6 +32,12 @@ func (b *ExecBackend) Layout(rt registry.Route) (Layout, string) { |
| func (b *ExecBackend) pathsFor(rt registry.Route) instancePaths { |
| l, reason := Classify(rt, b.layoutInputs()) |
| + return b.pathsAt(rt, l, reason) |
| +} |
| + |
| +// pathsAt is pathsFor on a classification already made (the escrow sweep |
| +// classifies every row against the one list it was handed). |
| +func (b *ExecBackend) pathsAt(rt registry.Route, l Layout, reason string) instancePaths { |
| p := instancePaths{layout: l, reason: reason, dataDir: b.DataDir, runDir: provision.SocketDir} |
| if l == LayoutNested { |
| p.dataDir = provision.InstanceDir(b.DataDir, rt.Host) |
diff --git a/internal/activator/rootfs_ctl_harness_test.go b/internal/activator/rootfs_ctl_harness_test.go| index 64e3c5600..943ce1c0f 100644 |
| --- a/internal/activator/rootfs_ctl_harness_test.go |
| +++ b/internal/activator/rootfs_ctl_harness_test.go |
| @@ -117,9 +117,12 @@ 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. |
| + // 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). |
| 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_deploy_test.go b/internal/activator/rootfs_deploy_test.go| index d7a3da4ce..05ef724e4 100644 |
| --- a/internal/activator/rootfs_deploy_test.go |
| +++ b/internal/activator/rootfs_deploy_test.go |
| @@ -15,6 +15,7 @@ import ( |
| "context" |
| "errors" |
| "fmt" |
| + "os" |
| "slices" |
| "strings" |
| "sync" |
| @@ -714,7 +715,13 @@ func TestConfigAttemptHandsOverWorkers(t *testing.T) { |
| } |
| before := len(ctl.callList()) |
| - writeInstanceEnv(t, lb.eb, lb.rt, "SHOP_MODE=two\n") |
| + // The configuration changes; the secrets the first launch minted (and |
| + // escrowed) stay in the file, as a config sync leaves them. |
| + own, err := os.ReadFile(lb.eb.pathsFor(lb.rt).envFile) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + writeInstanceEnv(t, lb.eb, lb.rt, strings.Replace(string(own), "SHOP_MODE=one\n", "SHOP_MODE=two\n", 1)) |
| f.rev.Add(1) |
| config := f.attempt(ModeOverlap) |
| config.StagedPath, config.Digest = at.StagedPath, at.Digest |
diff --git a/internal/activator/rootfs_test.go b/internal/activator/rootfs_test.go| index 98b077de2..93f25e586 100644 |
| --- a/internal/activator/rootfs_test.go |
| +++ b/internal/activator/rootfs_test.go |
| @@ -36,8 +36,10 @@ 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, and a fake unit that |
| -// goes inactive and empty once either stop verb is called. |
| +// 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). |
| func newRootfsBackend(t *testing.T) (*ExecBackend, *fakeControl) { |
| t.Helper() |
| ctl := &fakeControl{inv: "inv1"} |
| @@ -48,6 +50,7 @@ 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/agent.go b/internal/host/agent.go| index 01ee8f53d..49ff507fb 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -954,6 +954,7 @@ func runAgent(args []string, buildClaims ClaimFactory) { |
| nestedAtStart: nestedAtStart, |
| }, owners, alerts) |
| go configSyncLoop(reg, svc, dd, claims.Writes) |
| + go escrowLoop(agentCtx, reg, svc) |
| go configGenLoop(reg, svc, dd, claims.Writes) |
| go socketAdvisoryLoop(reg, svc) |
diff --git a/internal/host/escrow_loop.go b/internal/host/escrow_loop.go| new file mode 100644 |
| index 000000000..3ffd218df |
| --- /dev/null |
| +++ b/internal/host/escrow_loop.go |
| @@ -0,0 +1,52 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "log" |
| + "slices" |
| + "strings" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/activator" |
| + "github.com/carlosframework/platform/internal/registry" |
| +) |
| + |
| +// escrowLoop is the escrow's change detection (durability 3a, plan choice |
| +// 8): every activator.EscrowEvery it runs the activator's escrow sweep over |
| +// the registry's rows. A host whose escrowed files are unchanged costs no |
| +// read and no request; a changed one is escrowed within one period plus |
| +// the sweep's own time. It logs the hosts that fail, when that set |
| +// changes, and a sweep that deferred hosts past its cap. A box with no |
| +// activator has nothing to escrow, and the loop does not run. |
| +func escrowLoop(ctx context.Context, reg *registry.Registry, svc *activator.Service) { |
| + if reg == nil || svc == nil { |
| + return |
| + } |
| + t := time.NewTicker(activator.EscrowEvery) |
| + defer t.Stop() |
| + var failing []string |
| + for { |
| + select { |
| + case <-ctx.Done(): |
| + return |
| + case <-t.C: |
| + } |
| + rows, err := reg.List() |
| + if err != nil { |
| + log.Printf("agent: escrow: list the routes: %v", err) |
| + continue |
| + } |
| + rep := svc.EscrowSweep(ctx, rows) |
| + if rep.Deferred > 0 { |
| + log.Printf("agent: escrow: %d published, %d deferred to the next sweep (at most 256 a sweep)", rep.Published, rep.Deferred) |
| + } |
| + if !slices.Equal(rep.Failing, failing) { |
| + if len(rep.Failing) == 0 { |
| + log.Printf("agent: escrow: every host's escrow is current again") |
| + } else { |
| + log.Printf("agent: escrow: failing for %s (retried every %v)", strings.Join(rep.Failing, ", "), activator.EscrowEvery) |
| + } |
| + failing = rep.Failing |
| + } |
| + } |
| +} |
diff --git a/internal/host/schedule_wiring.go b/internal/host/schedule_wiring.go| index f5b7bacf6..177d778ba 100644 |
| --- a/internal/host/schedule_wiring.go |
| +++ b/internal/host/schedule_wiring.go |
| @@ -187,16 +187,17 @@ func scheduleToken(dd string, svc *activator.Service, reg *registry.Registry) fu |
| paths := envPathFor(dd, reg) |
| read := schedule.TokenFromEnvPaths(paths) |
| prepare := func(host string) (string, error) { |
| - // An HA host's token is minted only at its launch, behind the mint |
| - // gate, and its env may be one a restore is about to replace: the |
| - // tick only reads, "" when there is none, and the activator fills |
| - // the token from the restored env after the wake |
| - // (ServeScheduled). |
| - ha, err := scheduleHostHA(svc, reg, host) |
| + // An escrowed host's token (an HA host's, or one eligible for |
| + // escrow, on a box ready or not) is minted only at its launch, |
| + // behind the mint gate, and its env may be one a restore is about |
| + // to bring back: the tick only reads, "" when there is none, and |
| + // the activator fills the token from the restored env after the |
| + // wake (ServeScheduled). |
| + escrowed, err := scheduleHostEscrowed(svc, reg, host) |
| if err != nil { |
| return "", errors.New(activator.RedactPaths(err.Error())) |
| } |
| - if ha { |
| + if escrowed { |
| tok, err := read(host) |
| if err != nil { |
| return "", nil |
| @@ -222,9 +223,10 @@ func scheduleToken(dd string, svc *activator.Service, reg *registry.Registry) fu |
| } |
| } |
| -// scheduleHostHA is the box's HA classification of host's row |
| -// (Service.IsHA), false for a host with no row or no registry. |
| -func scheduleHostHA(svc *activator.Service, reg *registry.Registry, host string) (bool, error) { |
| +// scheduleHostEscrowed reports whether host's secrets are escrowed |
| +// (Service.SecretsEscrowed: HA, or eligible for escrow), false for a host |
| +// with no row or no registry. |
| +func scheduleHostEscrowed(svc *activator.Service, reg *registry.Registry, host string) (bool, error) { |
| if reg == nil { |
| return false, nil |
| } |
| @@ -237,7 +239,7 @@ func scheduleHostHA(svc *activator.Service, reg *registry.Registry, host string) |
| } |
| ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) |
| defer cancel() |
| - return svc.IsHA(ctx, *rt) |
| + return svc.SecretsEscrowed(ctx, *rt) |
| } |
| // envPathFor is scheduleToken's route to an instance's own env file: flat by |
diff --git a/internal/host/schedule_wiring_test.go b/internal/host/schedule_wiring_test.go| index aa221a854..e03ebf5a2 100644 |
| --- a/internal/host/schedule_wiring_test.go |
| +++ b/internal/host/schedule_wiring_test.go |
| @@ -2,16 +2,20 @@ package host |
| import ( |
| "context" |
| + "crypto/ecdh" |
| + "crypto/rand" |
| "net/http" |
| "net/http/httptest" |
| "os" |
| "path/filepath" |
| "strings" |
| "testing" |
| + "time" |
| "github.com/carlosframework/platform/internal/activator" |
| "github.com/carlosframework/platform/internal/provision" |
| "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| ) |
| // A tick's outcome is read from the handler's own answer, so the mapping from |
| @@ -237,3 +241,88 @@ func TestScheduleTokenErrorCarriesNoAbsolutePath(t *testing.T) { |
| t.Fatalf("error leaks a path: %q", err) |
| } |
| } |
| + |
| +// escrowedTickBox is the activator this box runs for an escrowed host (an |
| +// eligible exec instance, not HA, on the nested layout): the production |
| +// ExecBackend behind the SplitBackend, with a files store and, when ready, |
| +// a CARLOS_SECRETS_KEY. |
| +func escrowedTickBox(t *testing.T, dd string, reg *registry.Registry, store release.Store, key *ecdh.PrivateKey) *activator.Service { |
| + t.Helper() |
| + cfg := activator.Config{Bucket: "hib", Idle: time.Hour} |
| + eb := &activator.ExecBackend{Cfg: cfg, OptDir: t.TempDir(), DataDir: dd, FilesStore: store, EscrowKey: key, Registry: reg} |
| + return activator.New(cfg, &activator.SplitBackend{Exec: eb, Unit: &activator.UnitBackend{OptDir: t.TempDir()}}, reg) |
| +} |
| + |
| +// A scheduled tick never mints for an escrowed host, ready or not: with an |
| +// escrow in the bucket and no local env, the runner's token is "" and no |
| +// env file is created (the wake restores it, and the activator fills the |
| +// tick's token after the wake). |
| +func TestScheduledTickNeverMintsForAnEscrowedHost(t *testing.T) { |
| + const host = "shop.example.com" |
| + ctx := context.Background() |
| + dd := t.TempDir() |
| + reg, err := registry.Open(filepath.Join(t.TempDir(), "r.db")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(func() { reg.Close() }) |
| + rt := registry.Route{Host: host, Kind: "instance", Account: "bab", App: "shop", Status: "ready", Hibernate: true, |
| + DBPath: provision.NestedDBPath(dd, host), Socket: provision.NestedSocket(host)} |
| + if err := reg.Upsert(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + nested := filepath.Join(provision.InstanceDir(dd, host), host+".env") |
| + if err := os.MkdirAll(filepath.Dir(nested), 0o700); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(nested, []byte("CARLOS_ADMIN_TOKEN=escrowed\n"), 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + key, err := ecdh.P256().GenerateKey(rand.Reader) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + store := release.NewDirStore(t.TempDir()) |
| + rows, err := reg.List() |
| + 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) |
| + } |
| + if err := os.Remove(nested); err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, tc := range []struct { |
| + name string |
| + key *ecdh.PrivateKey |
| + }{{"ready", key}, {"not ready", nil}} { |
| + t.Run(tc.name, func(t *testing.T) { |
| + svc := escrowedTickBox(t, dd, reg, store, tc.key) |
| + if ok, err := svc.SecretsEscrowed(ctx, rt); !ok || err != nil { |
| + t.Fatalf("SecretsEscrowed %v, %v", ok, err) |
| + } |
| + tok, err := scheduleToken(dd, svc, reg)(host) |
| + if err != nil || tok != "" { |
| + t.Fatalf("token %q, err %v", tok, err) |
| + } |
| + if exists(nested) || exists(filepath.Join(dd, host+".env")) { |
| + t.Fatal("the tick minted an env file") |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// The agent runs the escrow sweep beside the config sync, on the agent's |
| +// own context, over the same registry and Service. |
| +func TestAgentStartsTheEscrowLoop(t *testing.T) { |
| + src, err := os.ReadFile("agent.go") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + body := string(src) |
| + loop, sync := strings.Index(body, "go escrowLoop(agentCtx, reg, svc)"), strings.Index(body, "go configSyncLoop(reg, svc, dd, claims.Writes)") |
| + if loop < 0 || sync < 0 || loop < sync { |
| + t.Fatal("the agent does not start escrowLoop beside configSyncLoop") |
| + } |
| +} |
diff --git a/internal/layout/extras.go b/internal/layout/extras.go| index e57ac220b..e70a0bfbb 100644 |
| --- a/internal/layout/extras.go |
| +++ b/internal/layout/extras.go |
| @@ -309,6 +309,9 @@ var platformNames = map[string]bool{ |
| // aside, never deletes (docs/superpowers/plans/2026-10-20-offline- |
| // operator-move.md). |
| ".offline-moves": true, |
| + // The escrow ledgers: each host's last committed files manifest |
| + // (activator escrow.go, durability 3a). |
| + ".escrow": true, |
| } |
| // UnattributedEntries lists the entries directly under dataDir that no |
diff --git a/internal/layout/extras_test.go b/internal/layout/extras_test.go| index dbd02bc4c..06fe86ee7 100644 |
| --- a/internal/layout/extras_test.go |
| +++ b/internal/layout/extras_test.go |
| @@ -85,10 +85,11 @@ func TestValidateJudgesTheJournalsExtraNames(t *testing.T) { |
| // UnattributedEntries names what no host on the box owns and the |
| // platform did not make: the shared directories a flat app with cwd / |
| -// wrote, which no move can take. |
| +// wrote, which no move can take. The escrow ledgers (.escrow) are the |
| +// platform's own. |
| func TestUnattributedEntriesSkipsHostsAndPlatformNames(t *testing.T) { |
| dd := t.TempDir() |
| - for _, name := range []string{"blobs", "registry.db", "layout", ".instances", "instances", ".offline-moves", host, host + "-blobs", "cache.tmp"} { |
| + for _, name := range []string{"blobs", "registry.db", "layout", ".instances", "instances", ".offline-moves", ".escrow", host, host + "-blobs", "cache.tmp"} { |
| if err := os.MkdirAll(filepath.Join(dd, name), 0o700); err != nil { |
| t.Fatal(err) |
| } |
diff --git a/internal/provision/durability_3a_escrow_census_test.go b/internal/provision/durability_3a_escrow_census_test.go| index 76e17e940..d8979f28d 100644 |
| --- a/internal/provision/durability_3a_escrow_census_test.go |
| +++ b/internal/provision/durability_3a_escrow_census_test.go |
| @@ -7,16 +7,49 @@ package provision |
| // b4d8db83). Reviewed by the branch author against the source; the census |
| // approval is recorded on #280 with the root-read card |
| // (docs/superpowers/notes/census-proposal-durability-3a-escrow.md). No |
| -// record write is added, moved or reclassified: |
| +// record write is added or reclassified: |
| // - internal/layout/plan.go nestedFiles (key-site), re-pinned (Task 1): |
| // it builds the same nine paths, byte for byte, through artifactPaths |
| // from pubclass.FileBases instead of listing them. The same "instances" |
| // literal, the socket's mount-visible run directory (a directory name, |
| // not a record): still key-site. |
| +// - internal/layout/extras.go var platformNames (key-site), re-pinned |
| +// (Task 4): one more platform name, ".escrow" (the escrow ledgers' |
| +// directory), so UnattributedEntries never reports it. The same |
| +// "instances" literal, a directory name: still key-site. |
| +// - internal/activator/paths.go ExecBackend.pathsFor (key-site) moved |
| +// whole to ExecBackend.pathsAt (Task 4): pathsFor now only classifies |
| +// and calls pathsAt, which holds the same body, so the escrow sweep can |
| +// hand it a classification made against the rows it was given. The same |
| +// "instances" literal (the nested run directory's name): still |
| +// key-site, under the new unit name. |
| func durability3aEscrowWriteCensusInventory() []censusEntry { |
| entries := append([]censusEntry(nil), consoleProtectionTabWriteCensusInventory()...) |
| repins := []censusEntry{ |
| {"internal/layout/plan.go", "nestedFiles", "key-site", "lit:instances", "39ac6611151b89527e86ed0ae7a61dc400ad33f6c7d5c7627119548d4353f1ef"}, |
| + {"internal/layout/extras.go", "var platformNames", "key-site", "lit:instances", "be1f540599829ff0e62deceec769e716e0ec11c575afdf8f5b66d06bb6535e4e"}, |
| + } |
| + // moves: a unit whose body moved whole under another name, keeping |
| + // its class and site kinds. |
| + moves := []struct { |
| + from string |
| + to censusEntry |
| + }{ |
| + {"ExecBackend.pathsFor", censusEntry{"internal/activator/paths.go", "ExecBackend.pathsAt", "key-site", "lit:instances", "1b6ac30aeed48d9818da84b8c8638a3931a40af3d47821afac2c90a690206f61"}}, |
| + } |
| + for _, m := range moves { |
| + found := false |
| + for i, e := range entries { |
| + if e.File == m.to.File && e.Unit == m.from { |
| + if e.Class != m.to.Class || e.Kinds != m.to.Kinds { |
| + panic("durability-3a-escrow move changes the class or kinds of " + e.File + ":" + e.Unit) |
| + } |
| + entries[i], found = m.to, true |
| + } |
| + } |
| + if !found { |
| + panic("durability-3a-escrow move of an unlisted unit " + m.to.File + ":" + m.from) |
| + } |
| } |
| for _, r := range repins { |
| found := false |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index b496906fe..8688cb8a8 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 496ab302fe3dc87eb5b7f6335dce2fe2578f08cbf367451256d778b88bb1a6ae |
| +plan14-root-reads-durability-3a-escrow.tsv ff7de0ee0c3c4d467e9517b579b300d3284ff900e96de78a2f3f27bed25180a0 |
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 1137c0749..135e6f0b4 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv |
| @@ -1,31 +1,122 @@ |
| # 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. |
| -# 2 body, 6 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| -# 4 new dispositions: 0 reads re-frozen at their disposition with the claim, 3 new units frozen accepted-legacy, 1 quiet units retired while they read nothing, 0 other. |
| +# 8 body, 11 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. |
| +# 35 new dispositions: 0 reads re-frozen at their disposition with the claim, 34 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 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 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 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 3a99a89a020dcd2d9515c44d50142d60462b47aa8f5c88899d7678fd82cbca46 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 registry:Host@823,whole:Route@115,whole:Route@375 dc67b3eb05e7fb7d907c2d1028fb8792cd2e3f416d29610601fc3b90e6534735 |
| +@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 6978a370aacf57a603e45fe277e027bde6ff8947714eac9b08754053e305223b 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 registry:Host@1118,registry:Host@1380,registry:Host@1541,registry:Host@1726,registry:Host@1847,registry:Host@2021,registry:Host@2237,registry:Host@307,registry:Host@392,registry:Host@473,registry:Host@556,registry:Host@609,registry:Host@712,registry:Host@916,whole:Route@1025,whole:Route@1283,whole:Route@1443,whole:Route@179,whole:Route@214,whole:Route@431,whole:Route@796 2d7bcc0404536ce0ff4420c91f7ec8456e05f15f7ef320ba16d95b833eb518aa |
| +@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 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 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 46e7ba0e76be7212ff3492fc03c77b4a37a024df4971462c1084cca653290a2e 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 file:Open@1454,registry:Host@1044,registry:Host@1137,registry:Host@1311,registry:Host@2541,registry:Host@267,registry:Host@783,registry:Host@941,whole:Route@1208,whole:Route@596 963e02ab77afb2b8f9c86f8022b5200134345a25d750bfd2da54f9cacd627953 |
| +@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 |
| +@legacy bdf26f4fc245cae02a36304c5d5cb13357aa52d78ea64568581710c94469e112 internal/activator/escrow.go SplitBackend.EscrowSweep legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: forwards to the exec half file:Exec@112,whole:Route@169 42c7e00f7940bfb48d0bede753f2d45b5d49d38e355affa79df1d26b1155a565 |
| +@legacy 81eeb7cdf10fa86171c6eb14b45a1a40d0853ff6e5a4d9e8017ce5efac968f59 internal/activator/escrow.go SplitBackend.SecretsEscrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: forwards to the exec half, else IsHA file:Exec@108,whole:Route@169,whole:Route@196 b82598da664c87f7fa05d0b56e32c8bc4e42f3e0145a5ab1f0fa647aa1216302 |
| +@legacy 22cce0fb6d9e55f2be7654c69641405c3cee79c3f6cde32c7c5fa31be7404304 internal/activator/escrow.go readStamped legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: instancefs.OpenBeneathOrAbsent (openat2 beneath the row's data directory, no symlink, O_NONBLOCK, regular files only), fstat for the stamp, and at most 1 MiB read from that descriptor when the stamp moved file:ReadAll@837,file:Stat@390 24ff033a621dddcf335d85da06e43b7ea7aa0f83c6530cf46d9245adec683af4 |
| +@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 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 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 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 |
| @legacy 102f291648b5ec856e25671b0886f4d7fd1c28a98fc1fea228f98fac9f66afd5 internal/activator/hawake.go ExecBackend.restoreFilesClean legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: restores the HA host's published files into a fresh <host>.restore directory beneath the instance data dir (instancefs, no link followed), renames it into place without replacing anything, writes the manifest's env item as <host>.env (instancefs.WriteAtomic, 0600) and imports the manifest's wake state into the registry (hostfiles.ImportWake, then the class for restoredReplication); the source is the host's files manifest in the hibernate bucket, written by the agents of the boxes that held the host; every failure fails the wake; +registry:Host, +whole:Route x2;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3 (fix round 1: sealed precedence before any fetch): the restore into <host>.restore is now RestoreRootBaselineShadowed with sealedShadow(host), a pure function of the manifest already read and validated: a live raw instance.key or report.token entry whose sealed item the manifest holds is neither fetched nor written (so a missing or corrupt raw object cannot fail the wake, and a sealed item that does not open fails it with no raw fallback); every other entry is restored as before, and the baseline the wake's publisher continues from is the manifest as read. Then each sealed trio item the manifest holds (instance.key.sealed, report.token.sealed) is fetched and opened with hostfiles.ReadSealed (key, sha256, v2 envelope, binding and MAC checked) and written with instancefs.WriteAtomic (openat2 directory, no symlink, O_EXCL temp, rename, 0600) into the restore directory this function created, then that directory is synced; then the same no-replace rename. The env file comes from the sealed env item through ReadSealed when present, else from the raw env item as before, written as before. The source is still the host's files manifest in the hibernate bucket; the destinations are the same restore directory and env file; no new path is opened, followed or named from input; the sealer (sealerFor) is built only when a sealed item is present. registry:Host@97,whole:Route@1348,whole:Route@200,whole:Route@848 83d2b391d70c7008c9cf17c1db3091a45626ac26050e837e38f247d1aca100b2 |
| -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. file:Exec@17224,file:Open@1150,file:Statfs@42902,registry:App@11199,whole:Route@11191,whole:Route@27157 8db44678a89e88c2f7fcec2a54b0a73ce0088786968d6dd10ca3c4b88586a591 |
| +@legacy 4e3b06c62e684994c4777083689b9313642be6bc47c477151e37d93198dbc3f6 internal/activator/paths.go ExecBackend.pathsFor legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-durability-3a-escrow;basis=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 whole:Route@129,whole:Route@89 5801150c35fef058ce1f8e7c9f334a7a89e3441fe0f63fb451f4804282e90535 |
| +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 |
| +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 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.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.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 registry:Host@823,whole:Route@115,whole:Route@375 dc67b3eb05e7fb7d907c2d1028fb8792cd2e3f416d29610601fc3b90e6534735 |
| +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 registry:Host@1118,registry:Host@1380,registry:Host@1541,registry:Host@1726,registry:Host@1847,registry:Host@2021,registry:Host@2237,registry:Host@307,registry:Host@392,registry:Host@473,registry:Host@556,registry:Host@609,registry:Host@712,registry:Host@916,whole:Route@1025,whole:Route@1283,whole:Route@1443,whole:Route@179,whole:Route@214,whole:Route@431,whole:Route@796 2d7bcc0404536ce0ff4420c91f7ec8456e05f15f7ef320ba16d95b833eb518aa |
| +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.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.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 file:Open@1454,registry:Host@1044,registry:Host@1137,registry:Host@1311,registry:Host@2541,registry:Host@267,registry:Host@783,registry:Host@941,whole:Route@1208,whole:Route@596 963e02ab77afb2b8f9c86f8022b5200134345a25d750bfd2da54f9cacd627953 |
| +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 |
| +internal/activator/escrow.go SplitBackend.EscrowSweep legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: forwards to the exec half file:Exec@112,whole:Route@169 42c7e00f7940bfb48d0bede753f2d45b5d49d38e355affa79df1d26b1155a565 |
| +internal/activator/escrow.go SplitBackend.SecretsEscrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: forwards to the exec half, else IsHA file:Exec@108,whole:Route@169,whole:Route@196 b82598da664c87f7fa05d0b56e32c8bc4e42f3e0145a5ab1f0fa647aa1216302 |
| +internal/activator/escrow.go readStamped legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: instancefs.OpenBeneathOrAbsent (openat2 beneath the row's data directory, no symlink, O_NONBLOCK, regular files only), fstat for the stamp, and at most 1 MiB read from that descriptor when the stamp moved file:ReadAll@837,file:Stat@390 24ff033a621dddcf335d85da06e43b7ea7aa0f83c6530cf46d9245adec683af4 |
| +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 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/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.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 |
| internal/activator/hawake.go ExecBackend.restoreFilesClean legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: restores the HA host's published files into a fresh <host>.restore directory beneath the instance data dir (instancefs, no link followed), renames it into place without replacing anything, writes the manifest's env item as <host>.env (instancefs.WriteAtomic, 0600) and imports the manifest's wake state into the registry (hostfiles.ImportWake, then the class for restoredReplication); the source is the host's files manifest in the hibernate bucket, written by the agents of the boxes that held the host; every failure fails the wake; +registry:Host, +whole:Route x2;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3 (fix round 1: sealed precedence before any fetch): the restore into <host>.restore is now RestoreRootBaselineShadowed with sealedShadow(host), a pure function of the manifest already read and validated: a live raw instance.key or report.token entry whose sealed item the manifest holds is neither fetched nor written (so a missing or corrupt raw object cannot fail the wake, and a sealed item that does not open fails it with no raw fallback); every other entry is restored as before, and the baseline the wake's publisher continues from is the manifest as read. Then each sealed trio item the manifest holds (instance.key.sealed, report.token.sealed) is fetched and opened with hostfiles.ReadSealed (key, sha256, v2 envelope, binding and MAC checked) and written with instancefs.WriteAtomic (openat2 directory, no symlink, O_EXCL temp, rename, 0600) into the restore directory this function created, then that directory is synced; then the same no-replace rename. The env file comes from the sealed env item through ReadSealed when present, else from the raw env item as before, written as before. The source is still the host's files manifest in the hibernate bucket; the destinations are the same restore directory and env file; no new path is opened, followed or named from input; the sealer (sealerFor) is built only when a sealed item is present. registry:Host@97,whole:Route@1348,whole:Route@200,whole:Route@848 83d2b391d70c7008c9cf17c1db3091a45626ac26050e837e38f247d1aca100b2 |
| +internal/activator/paths.go ExecBackend.pathsFor legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-durability-3a-escrow;basis=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 whole:Route@129,whole:Route@89 5801150c35fef058ce1f8e7c9f334a7a89e3441fe0f63fb451f4804282e90535 |
| @remove internal/layout/plan.go NestedPlatformNames |
| @removed internal/layout/plan.go NestedPlatformNames H3 census-ruling-durability-3a-escrow;basis=durability 3a Task 1: now a one-line wrapper for pubclass.NestedPlatformNames, which builds the same set (byte-identical, checked before and after) from pubclass.FileBases and the same instancectl/instancekey names, without nestedFiles or rawInstanceDir; it never read anything, and reads nothing now |
| -@coverage internal/activator d131bd67e2c68a385b2c17313a8a98f12732d08475dc090f937a85cb36cf1bf7 |
| -@coverage internal/host c2b42d5db1c921cb0e722d50eb8cc6d19c4977a9fae0a57d1d4a6bf9e4a55242 |
| +@remove internal/activator/hasecrets.go ExecBackend.haScheduledToken |
| +@removed internal/activator/hasecrets.go ExecBackend.haScheduledToken H3 census-ruling-durability-3a-escrow;absent;basis=durability 3a Task 4: renamed to escrowedScheduledToken (on this card), the same read for HA hosts |
| +@remove internal/activator/hasecrets.go SplitBackend.haScheduledToken |
| +@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 780c32b2769a7316dcc663f694b6385f753f01a64ca63357ef50c36f54967a4a |
| +@coverage internal/host c12e11dd2fbfb5936e5256007db85a88f96cb12f3d1c74c551ff7ec5f52f9355 |
| @coverage internal/hostfiles a0b0deb2779b183ee3f3578d1112ac5f723d930e40690a55eaaaa2644a24a9ad |
| -@coverage internal/layout 5d8b1d3bcd0b247e8088e4fb32bc26378ece37f41dc40f1d999e23913eccc9d0 |
| +@coverage internal/layout f845fa728b0935279454d8b01023c5d6dae1c985061a41229cf0686e829f5c12 |
| @coverage internal/layout/pubclass bd3938f002a5dca044378b71670e904736653d4914a8b1e06275e2b4dc79ed67 |