carlos / platform Public

fix(hostfiles): refuse raw-secret baselines on parked publishers

Refuse inherited raw secret items before copied, prepared or continued
parked manifests can stage or publish. Share the classifier gate in
hostfiles, inventory continuation APIs in the publication guard, and
witness refusal with zero PUTs while retaining clean-baseline behavior.

Re-propose the root-read census and layer the unchanged CopyManifest
record-write site after reviewing its new pre-PUT refusal.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev ff83dee213db394ef78e8dc8b6714e3fc6b41200 parent 55e6a56
23 files changed, +554 −117
  • docs/superpowers/notes/census-durability-3a-escrow-claims.md +9 −1
  • docs/superpowers/notes/census-proposal-durability-3a-escrow.md +7 −4
  • internal/host/movesfiles.go +5 −5
  • internal/host/movesfiles_test.go +24 −16
  • internal/host/parkedrefusals_linux_test.go +1 −4
  • internal/host/rawbaseline_linux_test.go +176 −0
  • internal/host/relocationflush.go +3 −2
  • internal/host/relocationflush_wake_linux_test.go +3 −13
  • internal/host/relocationprobefiles_linux_test.go +35 −43
  • internal/hostfiles/contract.go +8 −3
  • internal/hostfiles/origins_test.go +10 −10
  • internal/hostfiles/prepared.go +5 −2
  • internal/hostfiles/prepared_test.go +5 −5
  • internal/hostfiles/rawbaseline.go +64 −0
  • internal/hostfiles/rawbaseline_test.go +100 −0
  • internal/hostfiles/seed.go +6 −0
  • internal/layout/pubclass/publication_guard_test.go +19 −1
  • internal/layout/pubclass/testdata/publication_guard/baseline.go +21 −0
  • internal/layout/pubclass/testdata/publication_guard/clean.go +15 −0
  • internal/provision/durability_3a_branchfix3_census_test.go +25 −0
  • internal/provision/plan9_b8_census_test.go +1 −1
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv +11 −6

Intent

Human

<task-notification> <task-id>b0kgzkp3b</task-id> <tool-use-id>toolu_01NVeoZNZu1b4oThYnfDsu3R</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/aab63774-dfe6-44a4-9cd9-230e6f4c3d13/tasks/b0kgzkp3b.output</output-file> <status>completed</status> <summary>Background command "Run the Astra census re-review for R3" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>b02ptovhn</task-id> <tool-use-id>toolu_01NmgsnXT1Cdye4CqfkM4Z6h</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/aab63774-dfe6-44a4-9cd9-230e6f4c3d13/tasks/b02ptovhn.output</output-file> <status>completed</status> <summary>Background command "Run whole-branch Astra review round 3" completed (exit code 0)</summary> </task-notification>

diff --git a/docs/superpowers/notes/census-durability-3a-escrow-claims.md b/docs/superpowers/notes/census-durability-3a-escrow-claims.md
index 38d25d676..9a85f1198 100644
--- a/docs/superpowers/notes/census-durability-3a-escrow-claims.md
+++ b/docs/superpowers/notes/census-durability-3a-escrow-claims.md
@@ -70,7 +70,7 @@ internal/activator/escrow.go:ExecBackend.escrowDivergence durability 3a Task 4 f
internal/host/movesfiles.go:movesFiles.Establish Durability 3a Task 5 (parked path, host claims only): a present env file (claimEnvPresent: nested via instancefs.OpenBeneathOrAbsent, flat via Lstat; the bytes are never read) refuses with pubclass.ErrSecretPath before any bucket write; the env bytes are no longer read (readClaimEnvFile deleted); with no env file the establishment proceeds and stages StagePlatformDelete(EnvItem), so a raw env item a baseline holds is dropped, never carried into the new generation; openPrepared no longer takes the env and establishedOver no longer GETs an env object. Only refuses more, and reads less.
internal/host/movesfiles.go:claimEnvPresent Durability 3a Task 5: new: whether the claim env file exists, without reading it: nested, instancefs.OpenBeneathOrAbsent beneath the instance directory (no link at any component; the descriptor closed at once); flat, os.Lstat of <data>/<host>.env (a link there counts as present, so it refuses). An undecidable answer is an error. Only feeds a refusal.
internal/host/movesfiles.go:buildPrepared Durability 3a Task 5 (parked path, CARLOS_MOVES_PHASE1 only): wantEnv refuses with pubclass.ErrSecretPath before anything is read or written; the env presence check for !wantEnv is os.Stat instead of os.ReadFile (the secret is no longer read into memory); hostfiles.RefuseSecretsAt over root.Open(".") (+file:Open, a descriptor of the os.Root it already opened, never a pathname) before NewPrepared; the walk checks pubclass.Of(...) == App before each Stage; the env file is never staged. Only refuses more, and reads less.
-internal/host/relocationflush.go:ReleaseFlushFiles.Flush Durability 3a Task 5 (parked path, host claims only): the env file's presence is decided first with instancefs.OpenBeneathOrAbsent (the bytes are never read, replacing readInstanceFile of the env): present refuses with pubclass.ErrSecretPath before the manifest is read; hostfiles.RefuseSecretsAt over the root it opened, after the tenant seam and before hostfiles.Seed; absent still stages the env item's delete. Only refuses more, and reads less. Branch fix R1 P1-2: Seed also receives FilesDirSkip for classification during the upload walk; the release flush composes its optional skip as an additional exclusion. The preflight remains; no read target or authority added.
+internal/host/relocationflush.go:ReleaseFlushFiles.Flush Durability 3a Task 5 (parked path, host claims only): the env file's presence is decided first with instancefs.OpenBeneathOrAbsent (the bytes are never read, replacing readInstanceFile of the env): present refuses with pubclass.ErrSecretPath before the manifest is read; hostfiles.RefuseSecretsAt over the root it opened, after the tenant seam and before hostfiles.Seed; absent still stages the env item's delete. Only refuses more, and reads less. Branch fix R1 P1-2: Seed also receives FilesDirSkip for classification during the upload walk; the release flush composes its optional skip as an additional exclusion. The preflight remains; no read target or authority added. Task B3: Use OpenForSeed for the same generation prefix before ExportWake and Seed. A raw-bearing manifest refuses and logs before any PUT; historical objects stay untouched. No new read target or authority.
internal/host/claimfilesseed_stage.go:filesSeedOperation.stage Durability 3a Task 5 (parked path, host claims with origins only): hostfiles.RefuseSecretsAt over the root it opened, before hostfiles.Seed: any path the classifier does not call App refuses the seed before its first write, with pubclass.ErrSecretPath. No read added; the walk is the descriptor walk Seed itself makes. Task 7 fix round 1: bind the descriptor returned through work.With once as dir; stat, RefuseSecretsAt and Seed use that same descriptor. No path, read, authority, refusal or production behavior changes; the account/host identity and descriptor lifetime are unchanged. Branch fix R1 P1-2: Seed also receives FilesDirSkip for classification during the upload walk; the release flush composes its optional skip as an additional exclusion. The preflight remains; no read target or authority added.
# Task 8: approved console copy and documentation only; no root-binary source unit changed, no root read added. Earlier Tasks 1-7 claims above remain the whole-branch proposal.
@@ -82,3 +82,11 @@ internal/host/claimfilesseed_stage.go:filesSeedOperation.stage Durability 3a Tas
# Task B2 R2 P1-3: one shared escrow gate before every sealed publication.
internal/activator/escrow.go:ExecBackend.stageEscrowReads Branch fix R2 P1-3: shared HA and non-HA write-once funnel. Checks the existing conflict marker, decodes the committed baseline, reports raw secrets, calls escrowDivergence on all candidates before any StageSealed. Trio changes refuse before any env GET. Changed platform-minted env variables refuse; an envelope that cannot open under the key/binding refuses with the existing alert and best-effort durable marker; transient GET errors refuse without a marker. Same host manifest prefix, sealed env object and local conflict path. No new authority or root read target. Fix round 2b: a stale publisher must Refresh from the same bucket manifest before divergence and StageSealed; failed refresh wraps errEscrowUnreadable. No new key or authority.
internal/hostfiles/publisher.go:Publisher.Refresh Fix round 2b: reuses Open on the publisher's existing store and manifest prefix, under the publisher mutex. A successful read and validation replaces the baseline and discards pending stages; a failure keeps the typed stale fence. No new storage path or authority.
+
+# Task B3, final review R3 P1: refuse inherited raw secret baselines.
+internal/hostfiles/seed.go:Seed Before StageWake or any tree staging, check the publisher baseline through the shared raw-secret refusal. Same caller-owned descriptor and wake snapshot; adds no read or write target and grants no authority.
+internal/hostfiles/rawbaseline.go:OpenForSeed Parked continuation opens the same store/prefix through Open, then refuses entries or platform items classified raw by pubclass.IsRawSecretItem. A typed ErrRawSecretBaseline wraps ErrSecretPath and logs the item without reading its bytes. No new storage path or authority.
+internal/hostfiles/contract.go:Publish Use OpenForSeed in place of Open; the same manifest read and CAS behavior, with raw-bearing inherited manifests refused before staging. No new read target or authority.
+# Envelope-only: internal/host/movesfiles.go:movesFiles.openPrepared uses OpenAtForSeed on the same already-verified bytes and token; prepared raw-bearing baselines refuse before staging.
+# Envelope-only: internal/hostfiles/prepared.go:NewFromCopy and internal/hostfiles/contract.go:CopyManifest call refuseRawSecretBaseline before returning a publisher or putting the copy. The shared helper reads only the supplied maps, including tombstone names. No filesystem or object reads added.
+# Envelope-only: internal/hostfiles/rawbaseline.go:OpenAtForSeed reuses OpenAt over the exact supplied bytes/token and the same shared refusal; checkedSeedBaseline returns nil on refusal. ErrRawSecretBaseline.Error and Unwrap only format the refusal and preserve the parked-path error type.
diff --git a/docs/superpowers/notes/census-proposal-durability-3a-escrow.md b/docs/superpowers/notes/census-proposal-durability-3a-escrow.md
index 593cc48ed..364dbf32f 100644
--- a/docs/superpowers/notes/census-proposal-durability-3a-escrow.md
+++ b/docs/superpowers/notes/census-proposal-durability-3a-escrow.md
@@ -1,6 +1,6 @@
# Census approval: durability-3a-escrow
-Ruling `census-ruling-durability-3a-escrow`. The independent reviewer approves or rejects every change below, 47 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, 50 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
| unit | change | read sites | what changed |
|---|---|---|---|
@@ -13,8 +13,8 @@ Ruling `census-ruling-durability-3a-escrow`. The independent reviewer approves o
| `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. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. Merge of origin/main 90c4d3aa: main's own later changes to this body are kept as main has them, under main's rulings; this branch's change is the same as above. |
| `internal/host/claimfilesseed_stage.go` `filesSeedOperation.stage` | body | unchanged (2) | Durability 3a Task 5 (parked path, host claims with origins only): hostfiles.RefuseSecretsAt over the root it opened, before hostfiles.Seed: any path the classifier does not call App refuses the seed before its first write, with pubclass.ErrSecretPath. No read added; the walk is the descriptor walk Seed itself makes. Task 7 fix round 1: bind the descriptor returned through work.With once as dir; stat, RefuseSecretsAt and Seed use that same descriptor. No path, read, authority, refusal or production behavior changes; the account/host identity and descriptor lifetime are unchanged. Branch fix R1 P1-2: Seed also receives FilesDirSkip for classification during the upload walk; the release flush composes its optional skip as an additional exclusion. The preflight remains; no read target or authority added. |
| `internal/host/movesfiles.go` `movesFiles.Establish` | body | unchanged (0) | Durability 3a Task 5 (parked path, host claims only): a present env file (claimEnvPresent: nested via instancefs.OpenBeneathOrAbsent, flat via Lstat; the bytes are never read) refuses with pubclass.ErrSecretPath before any bucket write; the env bytes are no longer read (readClaimEnvFile deleted); with no env file the establishment proceeds and stages StagePlatformDelete(EnvItem), so a raw env item a baseline holds is dropped, never carried into the new generation; openPrepared no longer takes the env and establishedOver no longer GETs an env object. Only refuses more, and reads less. |
-| `internal/host/relocationflush.go` `ReleaseFlushFiles.Flush` | body | unchanged (1) | Durability 3a Task 5 (parked path, host claims only): the env file's presence is decided first with instancefs.OpenBeneathOrAbsent (the bytes are never read, replacing readInstanceFile of the env): present refuses with pubclass.ErrSecretPath before the manifest is read; hostfiles.RefuseSecretsAt over the root it opened, after the tenant seam and before hostfiles.Seed; absent still stages the env item's delete. Only refuses more, and reads less. Branch fix R1 P1-2: Seed also receives FilesDirSkip for classification during the upload walk; the release flush composes its optional skip as an additional exclusion. The preflight remains; no read target or authority added. |
| `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. Durability 3a Task 5 fix round 1: restore() takes one more argument, checked (nil from Restore, RestoreRoot and RestoreRootBaselineShadowed), called with the manifest after checkManifest and before anything is removed, fetched or written (RestoreRootBaselineObserved passes the caller's); Restore passes nil, so its reads, opens and writes are exactly as before. |
+| `internal/hostfiles/seed.go` `Seed` | body | unchanged (0) | Before StageWake or any tree staging, check the publisher baseline through the shared raw-secret refusal. Same caller-owned descriptor and wake snapshot; adds no read or write target and grants no authority. |
| `internal/activator/backend_exec.go` `ExecBackend.Acquire` | sites | +registry:Host | durability 3a Task 4 fix round 1: after a successful acquire, records the instance lease it hands out (escrow.noteLease, memory only), so the escrow can ask whether this box holds the host's lease; the same acquire, no read added; the agent as carlos (carlos-edge.service), no root caller |
| `internal/activator/hafiles.go` `ExecBackend.newHostFiles` | sites | +whole:Route ×3 | 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. Durability 3a Task 5: also sets the publisher's noteHeld, a closure calling noteRawBaseline(host, pub) (the detector over the manifest the publisher holds, decoded from its own committed bytes); no I/O; the -registry:Host site is rt.Host read once into a local. Branch fix R2 P1-3: capture the route, paths and sealer in the HA publisher callback to the shared stageEscrowReads gate. No I/O added here. All HA passes read the same three bounded no-link local paths before invoking the callback; it refuses divergence or unreadable-key replacement before any StageSealed. |
| `internal/activator/hafiles.go` `ExecBackend.openHostFiles` | sites | +registry:Host, +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. Durability 3a Task 5: after hostfiles.Open, noteRawBaseline(rt.Host, pub), the detector over the manifest just read (hostfiles.RawAfterSealed on the decoded baseline). Reads only manifests this process already holds (no request, no file opened); calls the detector, which logs and calls ExecBackend.OnRawSecret; nothing else changes. The +registry:Host site is that call's argument. |
@@ -54,8 +54,8 @@ Recorded dispositions, which each change must still satisfy:
- `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;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): sets svc.Fleet = fleetWakeFor(os.Getenv, identity, identErr, fleetStore) from the identity it already resolves once and the deployment store the fleet loops already opened, and logs an ERROR naming the identity error when the box is on a fleet with an invalid identity. fleetWakeFor reads CARLOS_REGION and CARLOS_FLEET from the same environment. Read sites unchanged (6). Agent, not root; a platform box is unchanged.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites; merge of origin/main 6f1f6ca6: main's svc.Fleet = fleetWakeFor(...) and its invalid-identity ERROR line are kept as main has them (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (6)
- `internal/host/claimfilesseed_stage.go` `filesSeedOperation.stage`: authority, task C,J4. Basis: rev3=PROPOSED-seed; fresh private provider, real admitted tuple and origins; guarded safe source descriptor and wake snapshot; create conflicts compare bounded bytes at exact current version before commit
- `internal/host/movesfiles.go` `movesFiles.Establish`: authority, task C,J4. Basis: rev3=PROPOSED-p3;run=12;basis=agent files preparation; retains seed admitted-writer and ordinary origin proof with one C8 commit; H3 is inventory bookkeeping, C owns the enabled effect
-- `internal/host/relocationflush.go` `ReleaseFlushFiles.Flush`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=PROPOSED-seed;basis=census-ruling-FS-R6; tenant files and env are published data, never authority
- `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/hostfiles/seed.go` `Seed`: authority, task C,J4. Basis: rev3=PROPOSED-seed; already-open source directory and wake snapshot; shared staging only, unstable reads refuse; caller owns origin proof and manifest commit
- `internal/activator/backend_exec.go` `ExecBackend.Acquire`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: after the unchanged AdmitConfig gate, the lease acquire moves into acquireClassified (hawake.go, a new unit): a legacy route or a non-HA host takes the same lease.Acquire as before and maps a held lease to errLeaseHeld as before (leaseError); an HA host goes through the containment admission and lease.AcquireHA. A successful acquire marks the host acquiredHere for the process (same-box recovery). The config gate is not weakened; the same three sites, no read added
- `internal/activator/hafiles.go` `ExecBackend.newHostFiles`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: builds a hostFiles publisher for rt (its instance paths from pathsFor(rt), rt.Host, the backend's registry, the 1 s platform and 15 min snapshot cadences); +registry:Host, +whole:Route; no I/O
- `internal/activator/hafiles.go` `ExecBackend.openHostFiles`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: the entry's files publisher: refuses without a FilesStore or outside the nested layout, takes the one this wake's restore staged, else hostfiles.Open on <hibernate prefix>/files/0/ (one GET of the manifest from the hibernate bucket, the scanner's +file:Open); +registry:Host x2, +whole:Route x2; the manifest is written by the agents of the boxes that hold the host, through the same files store
@@ -114,11 +114,14 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/host/movesfiles.go:claimEnvPresent`: reads +file:Lstat; written legacy, accepted-legacy, frozen
- new `internal/host/schedule_wiring.go:scheduleHostEscrowed`: reads +whole:Route ×2; written legacy, accepted-legacy, frozen
- new `internal/hostfiles/publisher.go:Publisher.Refresh`: reads +file:Open; written legacy, accepted-legacy, frozen
+- new `internal/hostfiles/rawbaseline.go:OpenForSeed`: reads +file:Open; 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/host/relocationflush.go:ReleaseFlushFiles.Flush`: reads nothing now; retired while it reads nothing (or its row keeps no sites)
+- quiet `internal/hostfiles/contract.go:Publish`: reads nothing now; retired while it reads nothing (or its row keeps no sites)
- quiet `internal/layout/plan.go:NestedPlatformNames`: reads nothing now; retired while it reads nothing (or its row keeps no sites)
- reads `internal/host/movesfiles.go:buildPrepared`: +file:Open, -file:ReadFile, +file:Stat; keeps legacy, task accepted-legacy
-Seal: `67b54b219f990c3dcfe32c6ffb11a80a4ca3898aec060fe9f4450e21098af714` → `18f1c7991164d28cf0b16b0aa2fb2569570acf1a9a0465ddda04f8f9240320a9`.
+Seal: `67b54b219f990c3dcfe32c6ffb11a80a4ca3898aec060fe9f4450e21098af714` → `0812141114655728c5f7e4204ebe6f41fbf320e256dd68881b534ffe614353df`.
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/host/movesfiles.go b/internal/host/movesfiles.go
index e5c62354c..3a3d6f18c 100644
--- a/internal/host/movesfiles.go
+++ b/internal/host/movesfiles.go
@@ -43,8 +43,8 @@ import (
// - Establish, the reader a cold admission establishes its files manifest
// with: the newest valid manifest of the admitted predecessor chain,
// read by exact version, copied create-only into the admitted
-// generation with the raw env item and the adoption item dropped
-// (hostfiles.NewFromCopy; instance key O1'). A present env file
+// generation with the adoption item dropped (hostfiles.NewFromCopy;
+// instance key O1'). A raw-bearing baseline or a present env file
// refuses it (durability 3a: this parked path does not seal).
//
// The session-bound publisher (sequence 1 onwards under a session) stays
@@ -751,7 +751,7 @@ func (f *movesFiles) openPrepared(ctx context.Context, files release.Store, o ho
return nil, fmt.Errorf("%w: the files manifest %s is neither the prepared manifest %s nor this box's establishment of it: %v", hostbox.ErrChanged, key, pm.Version, err)
}
}
- p, err := hostfiles.OpenAt(files, prefix, cur, token)
+ p, err := hostfiles.OpenAtForSeed(files, prefix, cur, token)
if err != nil {
return nil, err
}
@@ -1161,8 +1161,8 @@ func (f *movesFiles) Establish(ctx context.Context, o hostclaim.Observed, in Cla
return err
}
}
- // No env item is carried forward: one a baseline holds (an older
- // build's) is dropped, never republished under the new generation.
+ // Raw-bearing baselines were refused before staging. Keep the env
+ // deletion alongside adoption cleanup for an absent local env.
if err := p.StagePlatformDelete(hostfiles.EnvItem); err != nil {
return err
}
diff --git a/internal/host/movesfiles_test.go b/internal/host/movesfiles_test.go
index 5a5856230..9a8239a2a 100644
--- a/internal/host/movesfiles_test.go
+++ b/internal/host/movesfiles_test.go
@@ -568,7 +568,7 @@ func TestEstablishCopiesTheNewestValidManifestByExactVersion(t *testing.T) {
if err := p.Stage(ctx, "a.txt", []byte("A"), 0o600, false); err != nil {
t.Fatal(err)
}
- if err := p.StagePlatform(ctx, hostfiles.EnvItem, []byte("K=1\n")); err != nil {
+ if err := p.StagePlatform(ctx, instancekey.AdoptionItem, []byte("K=1\n")); err != nil {
t.Fatal(err)
}
})
@@ -580,7 +580,7 @@ func TestEstablishCopiesTheNewestValidManifestByExactVersion(t *testing.T) {
t.Fatal(err)
}
// One fence for the manifest's write and the local effect. With no env
- // file on disk, the raw env item g1 carries (an older build's) is
+ // file on disk, the adoption item g1 carries is
// dropped, at the next sequence (durability 3a Task 5).
if x.workRan != 2 {
t.Fatalf("work ran %d times", x.workRan)
@@ -632,7 +632,7 @@ func TestEstablishKeepsOriginsPastAdmissionPruning(t *testing.T) {
if err := p.Stage(ctx, "a.txt", []byte("A"), 0o600, false); err != nil {
t.Fatal(err)
}
- if err := p.StagePlatform(ctx, hostfiles.EnvItem, []byte("K=1\n")); err != nil {
+ if err := p.StagePlatform(ctx, instancekey.AdoptionItem, []byte("K=1\n")); err != nil {
t.Fatal(err)
}
})
@@ -731,8 +731,8 @@ func (s *replacingStore) Get(ctx context.Context, key string) ([]byte, string, e
// durability 3a wrote it (a.txt, the wake state and a raw env item), with
// its binding journalled, no env file on disk (Establish refuses a present
// one), and the probe's observation and inputs. The establishment drops the
-// raw env item at sequence 1, so it writes, and a replay is held to that.
-func preparedFixture(t *testing.T) (*filesFixture, preparedManifest, hostclaim.Observed, ClaimLaunchInputs) {
+// adoption item at sequence 1, so it writes, and a replay is held to that.
+func preparedFixture(t *testing.T, rawItems ...string) (*filesFixture, preparedManifest, hostclaim.Observed, ClaimLaunchInputs) {
t.Helper()
x := newFilesFixture(t)
ctx := context.Background()
@@ -744,12 +744,23 @@ func preparedFixture(t *testing.T) (*filesFixture, preparedManifest, hostclaim.O
if err := p.Stage(ctx, "a.txt", []byte("A"), 0o640); err != nil {
t.Fatal(err)
}
- if err := p.StagePlatform(ctx, hostfiles.EnvItem, []byte("K=1\n")); err != nil {
+ if err := p.StagePlatform(ctx, instancekey.AdoptionItem, []byte(`{"v":2}`)); err != nil {
t.Fatal(err)
}
if err := p.StagePlatform(ctx, hostfiles.WakeItem, mustJSON(t, hostfiles.WakeState{V: 1, Host: filesHost, Timers: []hostfiles.WakeTimer{}})); err != nil {
t.Fatal(err)
}
+ for _, name := range rawItems {
+ var err error
+ if name == hostfiles.EnvItem {
+ err = p.StagePlatform(ctx, name, []byte("historical"))
+ } else {
+ err = p.Stage(ctx, name, []byte("historical"), 0600)
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
_, raw, version, err := p.Commit(ctx)
if err != nil {
t.Fatal(err)
@@ -791,7 +802,7 @@ func TestEstablishPublishesOnlyOverTheBytesItChecked(t *testing.T) {
// A prepared replay is accepted only as exactly what this establishment
// would have written (fix round 2 finding 6, fix round 3; durability 3a
// Task 5): from the prepared baseline and the establishment's own
-// operations, the raw env item an older build prepared dropped at the
+// operations, the prepared adoption item dropped at the
// sequence after the prepared one, the manifest at that sequence, the
// carried set the admitted one, the entries and other platform items
// unchanged, no adoption item. Nothing is taken from the replay's own
@@ -1466,11 +1477,11 @@ func TestPreparedReplayOrdersOriginsLikeTheCarriedSet(t *testing.T) {
x.bucket.Put("data", oldObj, []byte("O"))
newObj := movesFilesPrefix(filesLoc, "mv1") + "objects/0000000000000000-" + sha([]byte("A"))
x.bucket.Put("data", newObj, []byte("A"))
- envObj := movesFilesPrefix(filesLoc, "mv1") + "objects/0000000000000000-" + sha([]byte("K=1\n"))
- x.bucket.Put("data", envObj, []byte("K=1\n"))
+ adoptionObj := movesFilesPrefix(filesLoc, "mv1") + "objects/0000000000000000-" + sha([]byte("K=1\n"))
+ x.bucket.Put("data", adoptionObj, []byte("K=1\n"))
prepared := hostfiles.Manifest{V: hostfiles.ManifestVersion, Seq: 0,
Entries: map[string]hostfiles.Entry{"a.txt": {Object: newObj, SHA256: sha([]byte("A")), Size: 1, Mode: 0o600, Seq: 0}, "old.txt": {Object: oldObj, SHA256: sha([]byte("O")), Size: 1, Mode: 0o600, Seq: 1}},
- Platform: map[string]hostfiles.Entry{hostfiles.EnvItem: {Object: envObj, SHA256: sha([]byte("K=1\n")), Size: 4, Mode: 0o600, Seq: 0}},
+ Platform: map[string]hostfiles.Entry{instancekey.AdoptionItem: {Object: adoptionObj, SHA256: sha([]byte("K=1\n")), Size: 4, Mode: 0o600, Seq: 0}},
Origins: []string{movesFilesPrefix(filesLoc, "mv1-old"), movesFilesPrefix(filesLoc, "mv1")}}
raw := mustJSON(t, prepared)
key := hostfiles.ManifestKey(movesFilesPrefix(filesLoc, "mv1"))
@@ -1501,17 +1512,14 @@ func TestPreparedReplayOrdersOriginsLikeTheCarriedSet(t *testing.T) {
// The instance key rule (O1'), as durability 3a Task 5 leaves it: with no
// env file on disk, the manifest Establish leaves carries neither the raw
-// env item nor the adoption item its baseline held, and the local
+// env item nor the adoption item its clean baseline held, and the local
// adoption record is removed under the start's work. Establish never
// writes the env file. A work that refuses leaves everything as it was.
// (A present env file refuses: TestEstablishRefusesAPresentEnvBeforeAnyWrite.)
-func TestEstablishDropsTheRawEnvAndTheAdoptionItem(t *testing.T) {
+func TestEstablishDropsTheAdoptionItemFromCleanBaseline(t *testing.T) {
x := newFilesFixture(t)
ctx := context.Background()
x.publish("g1", func(p *hostfiles.Publisher) {
- if err := p.StagePlatform(ctx, hostfiles.EnvItem, []byte("K=old\n")); err != nil {
- t.Fatal(err)
- }
if err := p.StagePlatform(ctx, instancekey.AdoptionItem, []byte(`{"v":2}`)); err != nil {
t.Fatal(err)
}
@@ -1685,7 +1693,7 @@ func TestEstablishOnThePreparedGenerationContinuesFromSequenceZero(t *testing.T)
t.Fatalf("the binding's version %q is not the manifest's exact version %q", pm.Version, x.bucket.LatestID("data", pm.Key))
}
// The first attempt crashes after the commit, before the local effect:
- // the manifest (which drops the older build's raw env item) is fenced
+ // the manifest (which drops the prepared adoption item) is fenced
// by one With, the local effect is the second, which refuses.
x.workErr, x.workErrAt = errors.New("crash after the commit"), 2
if err := x.f.Establish(ctx, o, in, x); err == nil {
diff --git a/internal/host/parkedrefusals_linux_test.go b/internal/host/parkedrefusals_linux_test.go
index a46491840..6d943bf4e 100644
--- a/internal/host/parkedrefusals_linux_test.go
+++ b/internal/host/parkedrefusals_linux_test.go
@@ -97,14 +97,11 @@ func TestPreparedManifestRefusesSecretsBeforeAnyWrite(t *testing.T) {
// A claim's establishment (host claims): a present env file refuses
// before any bucket write, and leaves the adoption record alone. With no
-// env file it establishes, and drops the raw env item the baseline held.
+// env file it establishes. A clean baseline lets that check stand alone.
func TestEstablishRefusesAPresentEnvBeforeAnyWrite(t *testing.T) {
ctx := context.Background()
x := newFilesFixture(t)
x.publish("g1", func(p *hostfiles.Publisher) {
- if err := p.StagePlatform(ctx, hostfiles.EnvItem, []byte("K=old\n")); err != nil {
- t.Fatal(err)
- }
if err := p.StagePlatform(ctx, instancekey.AdoptionItem, []byte(`{"v":2}`)); err != nil {
t.Fatal(err)
}
diff --git a/internal/host/rawbaseline_linux_test.go b/internal/host/rawbaseline_linux_test.go
new file mode 100644
index 000000000..d8ec94138
--- /dev/null
+++ b/internal/host/rawbaseline_linux_test.go
@@ -0,0 +1,176 @@
+//go:build linux
+
+package host
+
+import (
+ "bytes"
+ "context"
+ "errors"
+ "log"
+ "path/filepath"
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/hostclaim"
+ "github.com/carlosframework/platform/internal/hostfiles"
+ "github.com/carlosframework/platform/internal/layout/pubclass"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+type baselinePUTStore struct {
+ release.Store
+ puts int
+}
+
+func (s *baselinePUTStore) Put(ctx context.Context, key string, body []byte, match string) (string, error) {
+ s.puts++
+ return s.Store.Put(ctx, key, body, match)
+}
+
+func baselineLog(t *testing.T) *bytes.Buffer {
+ t.Helper()
+ var out bytes.Buffer
+ old := log.Writer()
+ log.SetOutput(&out)
+ t.Cleanup(func() { log.SetOutput(old) })
+ return &out
+}
+
+func TestEstablishRefusesRawSecretBaselineBeforeAnyPUT(t *testing.T) {
+ for _, name := range []string{"instance.key", "report.token", hostfiles.EnvItem, "tenant.txt"} {
+ t.Run(name, func(t *testing.T) {
+ x := newFilesFixture(t)
+ x.publish("g1", func(p *hostfiles.Publisher) {
+ var err error
+ if name == hostfiles.EnvItem {
+ err = p.StagePlatform(t.Context(), name, []byte("historical"))
+ } else {
+ err = p.Stage(t.Context(), name, []byte("historical"), 0600, false)
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ })
+ prefix := movesFilesPrefix(filesLoc, "g1")
+ before, _, err := x.files.Get(t.Context(), hostfiles.ManifestKey(prefix))
+ if err != nil {
+ t.Fatal(err)
+ }
+ o := x.observe(servingObserved("g2", "g1:uk:@root:uk", "g2:uk:g1:uk"), "g1", "g2")
+ store := &baselinePUTStore{Store: x.files}
+ x.f.Files = store
+ out := baselineLog(t)
+ err = x.f.Establish(t.Context(), o, launchInputs("g2"), x)
+ if name == "tenant.txt" {
+ if err != nil || store.puts == 0 {
+ t.Fatalf("clean baseline: puts=%d err=%v", store.puts, err)
+ }
+ return
+ }
+ if !errors.Is(err, pubclass.ErrSecretPath) {
+ t.Errorf("raw baseline admitted: %v", err)
+ }
+ if store.puts != 0 {
+ t.Errorf("refusal made %d PUTs", store.puts)
+ }
+ if !strings.Contains(out.String(), name) {
+ t.Errorf("no operator log for %s: %s", name, out)
+ }
+ after, _, err := x.files.Get(t.Context(), hostfiles.ManifestKey(prefix))
+ if err != nil || !bytes.Equal(before, after) {
+ t.Fatalf("historical manifest changed: %v", err)
+ }
+ if _, found := x.manifest("g2"); found {
+ t.Error("refusal committed a successor")
+ }
+ })
+ }
+}
+
+func TestReleaseFlushRefusesRawSecretBaselineBeforeAnyPUT(t *testing.T) {
+ for _, name := range []string{"report.token", "instance.key", hostfiles.EnvItem, "tenant.txt"} {
+ t.Run(name, func(t *testing.T) {
+ const host = "shop.example"
+ store := &baselinePUTStore{Store: release.NewDirStore(t.TempDir())}
+ const prefix = "instances/shop.example/inc/files/g-g6/"
+ p, err := hostfiles.Open(t.Context(), store, prefix)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if name == hostfiles.EnvItem {
+ err = p.StagePlatform(t.Context(), name, []byte("historical"))
+ } else {
+ err = p.Stage(t.Context(), name, []byte("historical"), 0600, false)
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err = p.Commit(t.Context()); err != nil {
+ t.Fatal(err)
+ }
+ before, _, err := store.Get(t.Context(), hostfiles.ManifestKey(prefix))
+ if err != nil {
+ t.Fatal(err)
+ }
+ store.puts = 0
+ reg, err := registry.Open(filepath.Join(t.TempDir(), "registry.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { reg.Close() })
+ if err = reg.Upsert(registry.Route{Host: host, Kind: "service", Addr: "10.0.0.1:3000", Status: "ready", Hibernate: true}); err != nil {
+ t.Fatal(err)
+ }
+ dir, envDir := t.TempDir(), t.TempDir()
+ mkTree(t, dir, map[string]string{"tenant.txt": "current"})
+ flush := ReleaseFlushFiles{Data: store, Registry: reg, FilesDir: func(string) string { return dir }, EnvPath: func(string) string { return filepath.Join(envDir, host+".env") }}
+ obs := hostclaim.Observed{Host: host, Claim: &hostclaim.Claim{Host: host, Holder: &hostclaim.Holder{Location: "instances/" + host + "/inc", Generation: "g6"}}}
+ out := baselineLog(t)
+ _, err = flush.Flush(t.Context(), obs)
+ if name == "tenant.txt" {
+ if err != nil || store.puts == 0 {
+ t.Fatalf("clean baseline: puts=%d err=%v", store.puts, err)
+ }
+ return
+ }
+ if !errors.Is(err, pubclass.ErrSecretPath) {
+ t.Errorf("raw baseline admitted: %v", err)
+ }
+ if store.puts != 0 {
+ t.Errorf("refusal made %d PUTs", store.puts)
+ }
+ if !strings.Contains(out.String(), name) {
+ t.Errorf("no operator log for %s: %s", name, out)
+ }
+ after, _, err := store.Get(t.Context(), hostfiles.ManifestKey(prefix))
+ if err != nil || !bytes.Equal(before, after) {
+ t.Fatalf("historical manifest changed: %v", err)
+ }
+ })
+ }
+}
+
+func TestPreparedEstablishRefusesRawSecretBaselineBeforeAnyPUT(t *testing.T) {
+ for _, name := range []string{"instance.key", "report.token", hostfiles.EnvItem} {
+ t.Run(name, func(t *testing.T) {
+ x, pm, obs, in := preparedFixture(t, name)
+ store := &baselinePUTStore{Store: x.files}
+ x.f.Files = store
+ out := baselineLog(t)
+ err := x.f.Establish(t.Context(), obs, in, x)
+ if !errors.Is(err, pubclass.ErrSecretPath) {
+ t.Errorf("raw prepared baseline admitted: %v", err)
+ }
+ if store.puts != 0 {
+ t.Errorf("refusal made %d PUTs", store.puts)
+ }
+ if !strings.Contains(out.String(), name) {
+ t.Errorf("no operator log for %s: %s", name, out)
+ }
+ if x.bucket.LatestID("data", pm.Key) != pm.Version {
+ t.Error("historical prepared manifest replaced")
+ }
+ })
+ }
+}
diff --git a/internal/host/relocationflush.go b/internal/host/relocationflush.go
index 36c1e7a64..241e42797 100644
--- a/internal/host/relocationflush.go
+++ b/internal/host/relocationflush.go
@@ -32,7 +32,8 @@ import (
// never carries a secret raw. A present env file, and a files directory
// holding any path the classifier does not call App (the trio at its
// root), refuse the flush before its first write, with an error wrapping
-// pubclass.ErrSecretPath.
+// pubclass.ErrSecretPath. A raw-bearing baseline is refused by OpenForSeed
+// before wake state or files can be staged.
type ReleaseFlushFiles struct {
Data release.Store
Registry *registry.Registry
@@ -78,7 +79,7 @@ func (f ReleaseFlushFiles) Flush(ctx context.Context, obs hostclaim.Observed) (i
ef.Close()
return 0, fmt.Errorf("%w: the release flush of %s would carry its env file %s raw; the claim path does not seal", pubclass.ErrSecretPath, obs.Host, envPath)
}
- p, err := hostfiles.Open(ctx, f.Data, moves.GenerationFilesPrefix(h.Location, h.Generation))
+ p, err := hostfiles.OpenForSeed(ctx, f.Data, moves.GenerationFilesPrefix(h.Location, h.Generation))
if err != nil {
return 0, err
}
diff --git a/internal/host/relocationflush_wake_linux_test.go b/internal/host/relocationflush_wake_linux_test.go
index 722b0254f..968a80d59 100644
--- a/internal/host/relocationflush_wake_linux_test.go
+++ b/internal/host/relocationflush_wake_linux_test.go
@@ -19,8 +19,8 @@ import (
// The release flush opens the files directory and looks for the env file
// through instancefs (openat2), so this test is Linux's. It carries the
// last wake state and files, and never an env item: with no env file on
-// disk (a present one refuses, durability 3a Task 5), the raw env item an
-// older release's flush left in the manifest is dropped.
+// disk (a present one refuses, durability 3a Task 5), a clean manifest
+// continues with the final wake state. Raw-bearing baselines refuse.
func TestReleaseFlushFilesCarriesTheLastWakeState(t *testing.T) {
ctx := context.Background()
data := release.NewDirStore(t.TempDir())
@@ -38,16 +38,6 @@ func TestReleaseFlushFilesCarriesTheLastWakeState(t *testing.T) {
t.Fatal(err)
}
prefix := "instances/" + host + "/inc/files/g-g6/"
- older, err := hostfiles.Open(ctx, data, prefix)
- if err != nil {
- t.Fatal(err)
- }
- if err := older.StagePlatform(ctx, hostfiles.EnvItem, []byte("KEY=v\n")); err != nil {
- t.Fatal(err)
- }
- if _, err := older.Commit(ctx); err != nil {
- t.Fatal(err)
- }
f := ReleaseFlushFiles{Data: data, Registry: reg, FilesDir: func(string) string { return dir }, EnvPath: func(h string) string { return filepath.Join(envDir, h+".env") }}
obs := hostclaim.Observed{Host: host, Claim: &hostclaim.Claim{Host: host, Holder: &hostclaim.Holder{Location: "instances/" + host + "/inc", Generation: "g6"}}}
first, err := f.Flush(ctx, obs)
@@ -80,7 +70,7 @@ func TestReleaseFlushFilesCarriesTheLastWakeState(t *testing.T) {
t.Fatalf("wake state: %+v %v %v", ws, ok, err)
}
if env, err := hostfiles.ReadPlatform(ctx, data, prefix, m, hostfiles.EnvItem, nil); !errors.Is(err, os.ErrNotExist) {
- t.Fatalf("the older flush's raw env item was carried: %q %v", env, err)
+ t.Fatalf("the clean flush gained a raw env item: %q %v", env, err)
}
// Nothing changed: the same sequence, still the final state.
again, err := f.Flush(ctx, obs)
diff --git a/internal/host/relocationprobefiles_linux_test.go b/internal/host/relocationprobefiles_linux_test.go
index 86bf3e504..0bcd06e6a 100644
--- a/internal/host/relocationprobefiles_linux_test.go
+++ b/internal/host/relocationprobefiles_linux_test.go
@@ -253,15 +253,10 @@ func (f *probeFilesFixture) established() (hostfiles.Manifest, preparedManifest)
const firstProbeEnv = installEnv + "CARLOS_INSTANCE_KEY=minted-by-the-launch-source\n"
-// Merge round 6, findings 2 and 3: relocation's first probe of a host with
-// a database establishes its files manifest through main's real C8
-// provider. The provider reads the env file the launch source minted into
-// the nested instance directory (never a stale flat <host>.env), and
-// reads P's prepared manifest by the binding relocation's install
-// journalled (no moves op journal exists), replacing it by compare-and-
-// swap: P's entries carried, the env file's bytes on disk, the sequence-0
-// version still readable at the exact version the install bound.
-func TestRelocationFirstProbeEstablishesThroughTheC8Provider(t *testing.T) {
+// The real C8 provider verifies the relocation's journalled prepared binding,
+// then refuses its raw-bearing baseline. Neither the historical sequence-0
+// manifest nor the stale flat env file may be substituted or changed.
+func TestRelocationFirstProbeRefusesRawBaselineThroughTheC8Provider(t *testing.T) {
f := newProbeFilesFixture(t, buildOptions{DB: true, Files: map[string]string{"public/index.html": "<h1>shop</h1>"}, Platform: map[string]string{hostfiles.EnvItem: installEnv, hostfiles.WakeItem: installWake()}})
stale := filepath.Join(f.r.DataDir, buildHost+".env")
if err := os.WriteFile(stale, []byte("STALE=flat\n"), 0o600); err != nil {
@@ -271,48 +266,46 @@ func TestRelocationFirstProbeEstablishesThroughTheC8Provider(t *testing.T) {
t.Fatalf("a moves op journal exists for P: %v", err)
}
in, err := f.probe("")
- if err != nil {
- t.Fatalf("the first probe: %v", err)
+ var rawBaseline *hostfiles.ErrRawSecretBaseline
+ if !errors.As(err, &rawBaseline) {
+ t.Fatalf("the first probe did not refuse its raw baseline: %v", err)
}
if !in.Prepared || in.Empty {
t.Fatalf("prepared=%v empty=%v", in.Prepared, in.Empty)
}
m, pm := f.established()
- // No env item: P's raw one (an older build's) is dropped, and the stale
- // flat <host>.env is never read (durability 3a Task 5).
- if e, has := m.Platform[hostfiles.EnvItem]; has {
- t.Fatalf("the manifest carries an env item %+v (stale flat %s)", e, hostfilesSum([]byte("STALE=flat\n")))
+ // The refusal leaves P and its historical raw env item untouched.
+ if e, has := m.Platform[hostfiles.EnvItem]; !has || e.SHA256 != hostfilesSum([]byte(installEnv)) {
+ t.Fatalf("the refusal changed the historical env item %+v (stale flat %s)", e, hostfilesSum([]byte("STALE=flat\n")))
}
- if _, ok := m.Entries["public/index.html"]; !ok || m.Seq == 0 {
- t.Fatalf("P's entries were not carried into the establishment: %+v", m)
+ if _, ok := m.Entries["public/index.html"]; !ok || m.Seq != 0 {
+ t.Fatalf("the refusal changed P's entries or sequence: %+v", m)
}
exact, err := f.bucket.GetVersion(t.Context(), "data", pm.Key, pm.Version)
if err != nil || hostfilesSum(exact) != pm.SHA256 {
t.Fatalf("the prepared version the install bound: %v", err)
}
- // A retry of the same establishment finds its own revision.
- if err := f.inputs.FilesManifest.Establish(t.Context(), f.read(), in, passWork{}); err != nil {
+ // A retry refuses the same historical baseline.
+ if err := f.inputs.FilesManifest.Establish(t.Context(), f.read(), in, passWork{}); !errors.As(err, &rawBaseline) {
t.Fatalf("a retry of the establishment: %v", err)
}
}
-// Merge round 6, finding 4: an empty database still consumes P's files.
-// The relocation's first probe of a host whose pin evidences an empty
-// database (in.Empty) establishes from P's prepared manifest, which
-// relocation always builds, by compare-and-swap over it: no create-only
-// commit collides with it, and P's files and platform items are carried.
-func TestRelocationEmptyDatabaseProbeConsumesPsFiles(t *testing.T) {
+// An empty database still selects P's prepared files baseline. Its raw env
+// refuses publication even though the database has nothing to restore.
+func TestRelocationEmptyDatabaseProbeRefusesRawBaseline(t *testing.T) {
f := newProbeFilesFixture(t, buildOptions{DB: false, Files: map[string]string{"uploads/a.txt": "kept"}, Platform: map[string]string{hostfiles.EnvItem: installEnv, hostfiles.WakeItem: installWake()}})
in, err := f.probe("")
- if err != nil {
- t.Fatalf("the empty database's first probe: %v", err)
+ var rawBaseline *hostfiles.ErrRawSecretBaseline
+ if !errors.As(err, &rawBaseline) {
+ t.Fatalf("the empty database's first probe did not refuse its raw baseline: %v", err)
}
if !in.Empty || in.Prepared {
t.Fatalf("prepared=%v empty=%v", in.Prepared, in.Empty)
}
m, _ := f.established()
- if _, ok := m.Entries["uploads/a.txt"]; !ok || m.Platform[hostfiles.WakeItem].SHA256 == "" || m.Platform[hostfiles.EnvItem].SHA256 != "" {
- t.Fatalf("P's files were not consumed: %+v", m)
+ if _, ok := m.Entries["uploads/a.txt"]; !ok || m.Platform[hostfiles.WakeItem].SHA256 == "" || m.Platform[hostfiles.EnvItem].SHA256 == "" || m.Seq != 0 {
+ t.Fatalf("the refusal changed P's historical files: %+v", m)
}
}
@@ -383,20 +376,17 @@ func TestRelocationPreparedBindingIsRelocationsOwn(t *testing.T) {
if err := j.Commit(f.r.DataDir); err != nil {
t.Fatal(err)
}
- if _, err := f.probe(""); err != nil {
- t.Fatalf("the relocation's own binding: %v", err)
+ var rawBaseline *hostfiles.ErrRawSecretBaseline
+ if _, err := f.probe(""); !errors.As(err, &rawBaseline) {
+ t.Fatalf("the relocation's own binding did not reach the raw-baseline refusal: %v", err)
}
})
}
-// Merge round 7: a replacement target keeps P and its prepared authority
-// at P's build stamp while it installs under a new install stamp (at
-// installed, or in probing before P's first admission). Its first probe
-// establishes P's files through the real provider: P's manifest bound at
-// the build stamp, its own receipt and install journal at the new one.
-// The replacement's install journal records P's build stamp in its
-// files_manifest step and its own stamp as the journal's install stamp.
-func TestRelocationReplacementProbeEstablishesPsFiles(t *testing.T) {
+// A replacement verifies P's original build stamp and its own newer install
+// stamp before refusing P's raw-bearing baseline. The refusal leaves the
+// prepared manifest and the replacement's install journal untouched.
+func TestRelocationReplacementProbeRefusesRawBaseline(t *testing.T) {
opts := buildOptions{DB: true, Files: map[string]string{"public/index.html": "<h1>shop</h1>"}, Platform: map[string]string{hostfiles.EnvItem: installEnv, hostfiles.WakeItem: installWake()}}
for _, phase := range []string{hostclaim.PhaseInstalled, hostclaim.PhaseRelocatingProbing} {
t.Run("replaced at "+phase, func(t *testing.T) {
@@ -406,11 +396,12 @@ func TestRelocationReplacementProbeEstablishesPsFiles(t *testing.T) {
if f.receipt.InstallStamp != c.Holder.Stamp || f.receipt.InstallStamp == auth.InstallStamp {
t.Fatalf("the replacement's receipt %+v is not at its own install stamp %d", f.receipt, c.Holder.Stamp)
}
- if _, err := f.probe(""); err != nil {
- t.Fatalf("the replacement's first probe: %v", err)
+ var rawBaseline *hostfiles.ErrRawSecretBaseline
+ if _, err := f.probe(""); !errors.As(err, &rawBaseline) {
+ t.Fatalf("the replacement's first probe did not refuse its raw baseline: %v", err)
}
m, pm := f.established()
- if pm.Stamp != auth.InstallStamp || m.Platform[hostfiles.EnvItem].SHA256 != "" || m.Entries["public/index.html"].SHA256 == "" {
+ if pm.Stamp != auth.InstallStamp || m.Platform[hostfiles.EnvItem].SHA256 == "" || m.Seq != 0 || m.Entries["public/index.html"].SHA256 == "" {
t.Fatalf("binding %+v (build stamp %d), manifest %+v", pm, auth.InstallStamp, m)
}
path, _ := relocationInstallPath(f.r.DataDir, "rel-1")
@@ -535,7 +526,8 @@ func TestRelocationReplacementActivationRefuses(t *testing.T) {
}
t.Run("probing after P opened", func(t *testing.T) {
f := newReplacedProbeFilesFixture(t, opts, hostclaim.PhaseRelocatingProbing)
- if _, err := f.probe(""); err != nil {
+ var rawBaseline *hostfiles.ErrRawSecretBaseline
+ if _, err := f.probe(""); !errors.As(err, &rawBaseline) {
t.Fatal(err)
}
if !hostclaim.PreparedOpened(f.read().Claim) {
diff --git a/internal/hostfiles/contract.go b/internal/hostfiles/contract.go
index b08b2fcd5..52629abe3 100644
--- a/internal/hostfiles/contract.go
+++ b/internal/hostfiles/contract.go
@@ -33,7 +33,8 @@ var ErrSourceMoved = errors.New("hostfiles: the source manifest is not at the ex
// Restore (nil or empty: fromPrefix alone). A source built by earlier
// copies references earlier generations, so its caller passes the chain
// its pin admits. Every entry is validated before anything is written; an
-// absent source is os.ErrNotExist, never an empty copy.
+// absent source is os.ErrNotExist, never an empty copy. A raw-secret-bearing
+// source is ErrRawSecretBaseline, refused before the target is written.
//
// expectSeq, when not 0, is the source revision the caller admitted. A
// source at any other Seq is ErrSourceMoved and nothing is written, on a
@@ -75,6 +76,9 @@ func CopyManifest(ctx context.Context, s release.Store, fromPrefix, toPrefix str
if err := checkManifest(m, origins); err != nil {
return Manifest{}, err
}
+ if err := refuseRawSecretBaseline(fromPrefix, m); err != nil {
+ return Manifest{}, err
+ }
body, err := json.Marshal(m)
if err != nil {
return Manifest{}, fmt.Errorf("hostfiles: marshal manifest: %w", err)
@@ -113,14 +117,15 @@ func CopyManifest(ctx context.Context, s release.Store, fromPrefix, toPrefix str
// again. Objects uploaded by a refused attempt are referenced by no
// manifest.
//
+// A raw-bearing baseline is ErrRawSecretBaseline before any staging.
// A prefix that already has a manifest is continued, not replaced: a
// repeat with nothing changed returns the same sequence number. Another
// writer's manifest appearing between Open and Commit is ErrSuperseded.
// Platform items (wake state, an env file) are not part of this call; a
-// caller that needs them in the same revision uses Open, StagePlatform,
+// caller that needs them in the same revision uses OpenForSeed, StagePlatform,
// SyncDir and Commit itself.
func Publish(ctx context.Context, s release.Store, prefix, dir string, skip func(rel string, isDir bool) bool) (int64, SyncStats, error) {
- p, err := Open(ctx, s, prefix)
+ p, err := OpenForSeed(ctx, s, prefix)
if err != nil {
return 0, SyncStats{}, err
}
diff --git a/internal/hostfiles/origins_test.go b/internal/hostfiles/origins_test.go
index 95efbecab..1f8779bdd 100644
--- a/internal/hostfiles/origins_test.go
+++ b/internal/hostfiles/origins_test.go
@@ -31,7 +31,7 @@ const pfx2 = "instances/shop.test/abc/files/g2/"
func publishG1(t *testing.T, s release.Store) {
t.Helper()
p := open(t, s)
- stage(t, p, "instance.key", "k1")
+ stage(t, p, "tenant.key", "k1")
stage(t, p, "uploads/a/b.txt", "hello")
if err := p.StagePlatform(context.Background(), "env", []byte("A=1")); err != nil {
t.Fatal(err)
@@ -49,7 +49,7 @@ func TestEntriesCarryTheirOriginQualifiedObjectKey(t *testing.T) {
if m.V != 2 {
t.Fatalf("manifest version = %d, want 2", m.V)
}
- e := m.Entries["instance.key"]
+ e := m.Entries["tenant.key"]
if want := pfx + objectKey(e.Seq, e.SHA256); e.Object != want {
t.Fatalf("object = %q, want %q", e.Object, want)
}
@@ -76,7 +76,7 @@ func TestACopiedManifestRestoresTheSameBytesWithoutCopyingObjects(t *testing.T)
if _, _, err := Restore(ctx, s, pfx2, dir, []string{pfx, pfx2}); err != nil {
t.Fatal(err)
}
- if read(t, dir, "instance.key") != "k1" || read(t, dir, "uploads/a/b.txt") != "hello" {
+ if read(t, dir, "tenant.key") != "k1" || read(t, dir, "uploads/a/b.txt") != "hello" {
t.Fatal("restored the wrong bytes")
}
got, err := ReadPlatform(ctx, s, pfx2, m, "env", []string{pfx, pfx2})
@@ -90,20 +90,20 @@ func TestACopiedManifestRestoresTheSameBytesWithoutCopyingObjects(t *testing.T)
if err != nil {
t.Fatal(err)
}
- stage(t, p, "instance.key", "k1")
+ stage(t, p, "tenant.key", "k1")
stage(t, p, "uploads/a/b.txt", "changed")
if seq := commit(t, p); seq != src.Seq+1 {
t.Fatalf("seq = %d, want %d", seq, src.Seq+1)
}
m2, _, _ := Load(ctx, s, pfx2)
- if !strings.HasPrefix(m2.Entries["instance.key"].Object, pfx) || !strings.HasPrefix(m2.Entries["uploads/a/b.txt"].Object, pfx2) {
+ if !strings.HasPrefix(m2.Entries["tenant.key"].Object, pfx) || !strings.HasPrefix(m2.Entries["uploads/a/b.txt"].Object, pfx2) {
t.Fatalf("entries = %+v", m2.Entries)
}
dir2 := t.TempDir()
if _, _, err := Restore(ctx, s, pfx2, dir2, []string{pfx, pfx2}); err != nil {
t.Fatal(err)
}
- if read(t, dir2, "instance.key") != "k1" || read(t, dir2, "uploads/a/b.txt") != "changed" {
+ if read(t, dir2, "tenant.key") != "k1" || read(t, dir2, "uploads/a/b.txt") != "changed" {
t.Fatal("restored the wrong bytes after the second generation published")
}
// The source generation is untouched.
@@ -124,13 +124,13 @@ func TestRestoreRefusesAnEntryOutsideTheAllowedOriginsAndTouchesNothing(t *testi
"another generation only": {"instances/shop.test/abc/files/g0/", pfx2},
} {
dir := t.TempDir()
- if err := os.WriteFile(filepath.Join(dir, "instance.key"), []byte("before"), 0o600); err != nil {
+ if err := os.WriteFile(filepath.Join(dir, "tenant.key"), []byte("before"), 0o600); err != nil {
t.Fatal(err)
}
if _, _, err := Restore(ctx, s, pfx2, dir, origins); err == nil || !strings.Contains(err.Error(), "origin") {
t.Fatalf("%s: Restore err = %v, want an origin refusal", name, err)
}
- if read(t, dir, "instance.key") != "before" {
+ if read(t, dir, "tenant.key") != "before" {
t.Fatalf("%s: Restore wrote before refusing", name)
}
if _, err := os.Stat(filepath.Join(dir, "uploads")); !os.IsNotExist(err) {
@@ -272,7 +272,7 @@ func TestCopyManifestRefusesAMissingOrInvalidSourceAndWritesNothing(t *testing.T
func TestPublishCommitsTheDirectoryAsOneRevision(t *testing.T) {
ctx, s, src := context.Background(), release.NewDirStore(t.TempDir()), t.TempDir()
- writeFile(t, src, "instance.key", "k1")
+ writeFile(t, src, "tenant.key", "k1")
writeFile(t, src, "uploads/a.txt", "a")
writeFile(t, src, "skip/me", "x")
skip := func(rel string, isDir bool) bool { return rel == "skip" }
@@ -288,7 +288,7 @@ func TestPublishCommitsTheDirectoryAsOneRevision(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if m.Seq != seq || read(t, dir, "instance.key") != "k1" || read(t, dir, "uploads/a.txt") != "a" {
+ if m.Seq != seq || read(t, dir, "tenant.key") != "k1" || read(t, dir, "uploads/a.txt") != "a" {
t.Fatalf("m = %+v", m)
}
if _, ok := m.Entries["skip/me"]; ok {
diff --git a/internal/hostfiles/prepared.go b/internal/hostfiles/prepared.go
index 495f9bd0b..d8d8d079b 100644
--- a/internal/hostfiles/prepared.go
+++ b/internal/hostfiles/prepared.go
@@ -225,8 +225,8 @@ func (p *Prepared) Commit(ctx context.Context) (Manifest, []byte, string, error)
// create-only, so a repeat reads its own bytes back and another manifest
// at the prefix is ErrSuperseded, never replaced. It is CopyManifest with
// the caller's own changes in the same revision: a cold admission's
-// establishment stages the env file and drops the adoption item before it
-// commits (claim §6.2a P6-D3; instance key O1').
+// establishment drops the adoption item before it commits (claim §6.2a
+// P6-D3; instance key O1'). A raw-secret-bearing base is ErrRawSecretBaseline.
//
// origins are the prefixes base's entries may reference (nil or empty:
// prefix alone). base is validated before anything is written.
@@ -247,6 +247,9 @@ func NewFromCopy(s release.Store, prefix string, base Manifest, origins []string
if err := checkManifest(base, origins); err != nil {
return nil, err
}
+ if err := refuseRawSecretBaseline(prefix, base); err != nil {
+ return nil, err
+ }
man := Manifest{V: ManifestVersion, Seq: base.Seq, Entries: map[string]Entry{}, Platform: map[string]Entry{}, Origins: append([]string(nil), base.Origins...)}
for k, e := range base.Entries {
man.Entries[k] = e
diff --git a/internal/hostfiles/prepared_test.go b/internal/hostfiles/prepared_test.go
index 68a72d2ef..e17642fd7 100644
--- a/internal/hostfiles/prepared_test.go
+++ b/internal/hostfiles/prepared_test.go
@@ -328,7 +328,7 @@ func TestNewFromCopyContinuesTheSequenceCreateOnly(t *testing.T) {
ctx, s := context.Background(), release.NewDirStore(t.TempDir())
src := open(t, s)
stage(t, src, "a.txt", "A")
- if err := src.StagePlatform(ctx, EnvItem, []byte("E")); err != nil {
+ if err := src.StagePlatform(ctx, WakeItem, []byte("E")); err != nil {
t.Fatal(err)
}
if err := src.StagePlatform(ctx, "instance-key-adoption.json", []byte("{}")); err != nil {
@@ -347,7 +347,7 @@ func TestNewFromCopyContinuesTheSequenceCreateOnly(t *testing.T) {
if err != nil {
return 0, err
}
- if err := p.StagePlatform(ctx, EnvItem, []byte("E2")); err != nil {
+ if err := p.StagePlatform(ctx, WakeItem, []byte("E2")); err != nil {
return 0, err
}
if err := p.StagePlatformDelete("instance-key-adoption.json"); err != nil {
@@ -360,7 +360,7 @@ func TestNewFromCopyContinuesTheSequenceCreateOnly(t *testing.T) {
t.Fatal(err)
}
if seq != 5 {
- t.Fatalf("seq %d, want 5 (3 copied, the env, the delete)", seq)
+ t.Fatalf("seq %d, want 5 (3 copied, the wake item, the delete)", seq)
}
m, found, err := Load(ctx, s, to)
if err != nil || !found {
@@ -369,8 +369,8 @@ func TestNewFromCopyContinuesTheSequenceCreateOnly(t *testing.T) {
if m.Entries["a.txt"].Object != base.Entries["a.txt"].Object {
t.Fatalf("the copy renamed an object: %+v", m.Entries["a.txt"])
}
- if e := m.Platform[EnvItem]; e.SHA256 != sum([]byte("E2")) || !strings.HasPrefix(e.Object, to+"objects/") {
- t.Fatalf("env: %+v", e)
+ if e := m.Platform[WakeItem]; e.SHA256 != sum([]byte("E2")) || !strings.HasPrefix(e.Object, to+"objects/") {
+ t.Fatalf("wake: %+v", e)
}
if _, ok := m.Platform["instance-key-adoption.json"]; ok {
t.Fatal("the adoption item was carried")
diff --git a/internal/hostfiles/rawbaseline.go b/internal/hostfiles/rawbaseline.go
new file mode 100644
index 000000000..0aa924bdf
--- /dev/null
+++ b/internal/hostfiles/rawbaseline.go
@@ -0,0 +1,64 @@
+package hostfiles
+
+import (
+ "context"
+ "fmt"
+ "log"
+ "sort"
+
+ "github.com/carlosframework/platform/internal/layout/pubclass"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// ErrRawSecretBaseline refuses inherited plaintext on a parked publisher.
+// Historical manifests and their objects are left untouched.
+type ErrRawSecretBaseline struct{ Prefix, Item string }
+
+func (e *ErrRawSecretBaseline) Error() string {
+ return fmt.Sprintf("%v: the files manifest of %s would carry %s raw; the claim path does not seal", pubclass.ErrSecretPath, e.Prefix, e.Item)
+}
+func (e *ErrRawSecretBaseline) Unwrap() error { return pubclass.ErrSecretPath }
+
+// refuseRawSecretBaseline is shared by copies and parked continuations.
+// Even a tombstone at a raw secret name is refused, so no such item is inherited.
+func refuseRawSecretBaseline(prefix string, m Manifest) error {
+ var raw []string
+ for name := range m.Entries {
+ if pubclass.IsRawSecretItem(pubclass.FilesDirEntries(), name) {
+ raw = append(raw, name)
+ }
+ }
+ for name := range m.Platform {
+ if pubclass.IsRawSecretItem(pubclass.PlatformItems(), name) {
+ raw = append(raw, name)
+ }
+ }
+ if len(raw) == 0 {
+ return nil
+ }
+ sort.Strings(raw)
+ err := &ErrRawSecretBaseline{Prefix: prefix, Item: raw[0]}
+ log.Print(err)
+ return err
+}
+
+func checkedSeedBaseline(p *Publisher, err error) (*Publisher, error) {
+ if err != nil {
+ return nil, err
+ }
+ if err := refuseRawSecretBaseline(p.prefix, p.man); err != nil {
+ return nil, err
+ }
+ return p, nil
+}
+
+// OpenForSeed refuses a raw-bearing baseline before any staging can begin.
+// Active sealing publishers use Open so they can migrate legacy manifests.
+func OpenForSeed(ctx context.Context, s release.Store, prefix string) (*Publisher, error) {
+ return checkedSeedBaseline(Open(ctx, s, prefix))
+}
+
+// OpenAtForSeed checks the exact bytes and CAS token a prepared replay verified.
+func OpenAtForSeed(s release.Store, prefix string, body []byte, etag string) (*Publisher, error) {
+ return checkedSeedBaseline(OpenAt(s, prefix, body, etag))
+}
diff --git a/internal/hostfiles/rawbaseline_test.go b/internal/hostfiles/rawbaseline_test.go
new file mode 100644
index 000000000..6cdff3916
--- /dev/null
+++ b/internal/hostfiles/rawbaseline_test.go
@@ -0,0 +1,100 @@
+package hostfiles
+
+import (
+ "context"
+ "errors"
+ "os"
+ "reflect"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/layout/pubclass"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+type baselinePUTStore struct {
+ release.Store
+ puts int
+}
+
+func (s *baselinePUTStore) Put(ctx context.Context, key string, body []byte, match string) (string, error) {
+ s.puts++
+ return s.Store.Put(ctx, key, body, match)
+}
+
+func TestCopyAndSeedRefuseRawSecretBaselines(t *testing.T) {
+ for _, name := range []string{"instance.key", "report.token", EnvItem, "tenant.txt"} {
+ t.Run(name, func(t *testing.T) {
+ s := &baselinePUTStore{Store: release.NewDirStore(t.TempDir())}
+ p := open(t, s)
+ if name == EnvItem {
+ if err := p.StagePlatform(t.Context(), name, []byte("historical")); err != nil {
+ t.Fatal(err)
+ }
+ } else {
+ stage(t, p, name, "historical")
+ }
+ commit(t, p)
+ m, _, err := Load(t.Context(), s, pfx)
+ if err != nil {
+ t.Fatal(err)
+ }
+ root, err := os.Open(t.TempDir())
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer root.Close()
+ for label, attempt := range map[string]func() error{
+ "copy": func() error { _, err := NewFromCopy(s, pfx2, m, []string{pfx}); return err },
+ "copy manifest": func() error { _, err := CopyManifest(t.Context(), s, pfx, pfx2, 0, nil); return err },
+ "seed": func() error {
+ _, err := Seed(t.Context(), p, root, WakeState{V: 1, Host: "shop.example", Timers: []WakeTimer{}}, nil)
+ return err
+ },
+ } {
+ s.puts = 0
+ before := p.Baseline()
+ err := attempt()
+ if name == "tenant.txt" {
+ if err != nil {
+ t.Errorf("%s clean: %v", label, err)
+ }
+ continue
+ }
+ if !errors.Is(err, pubclass.ErrSecretPath) {
+ t.Errorf("%s admitted %s: %v", label, name, err)
+ }
+ var refusal *ErrRawSecretBaseline
+ if !errors.As(err, &refusal) {
+ t.Errorf("%s: untyped refusal: %v", label, err)
+ }
+ if !reflect.DeepEqual(before, p.Baseline()) || p.dirty {
+ t.Errorf("%s: refusal staged changes", label)
+ }
+ if s.puts != 0 {
+ t.Errorf("%s: %d PUTs", label, s.puts)
+ }
+ }
+ })
+ }
+}
+
+func TestRawSecretBaselineClassification(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ m Manifest
+ raw bool
+ }{
+ {"cleaned alias", Manifest{Entries: map[string]Entry{"sub/../instance.key": {}}}, true},
+ {"tombstone", Manifest{Entries: map[string]Entry{"report.token": {Deleted: true}}}, true},
+ {"platform tombstone", Manifest{Platform: map[string]Entry{EnvItem: {Deleted: true}}}, true},
+ {"nested app file", Manifest{Entries: map[string]Entry{"uploads/instance.key": {}}}, false},
+ {"sealed and marker", Manifest{Platform: map[string]Entry{CutoverItem: {}, "sealed/host.env": {}, "sealed/instance.key": {}}}, false},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ err := refuseRawSecretBaseline(pfx, tc.m)
+ if errors.Is(err, pubclass.ErrSecretPath) != tc.raw {
+ t.Fatalf("raw=%v: %v", tc.raw, err)
+ }
+ })
+ }
+}
diff --git a/internal/hostfiles/seed.go b/internal/hostfiles/seed.go
index d45c1d38b..5a9209f07 100644
--- a/internal/hostfiles/seed.go
+++ b/internal/hostfiles/seed.go
@@ -14,6 +14,12 @@ func Seed(ctx context.Context, p *Publisher, root *os.File, wake WakeState, skip
if err := ctx.Err(); err != nil {
return SyncStats{}, err
}
+ p.mu.Lock()
+ err := refuseRawSecretBaseline(p.prefix, p.man)
+ p.mu.Unlock()
+ if err != nil {
+ return SyncStats{}, err
+ }
if err := StageWake(ctx, p, wake); err != nil {
return SyncStats{}, err
}
diff --git a/internal/layout/pubclass/publication_guard_test.go b/internal/layout/pubclass/publication_guard_test.go
index 7d4e4c7eb..0acbd9d9d 100644
--- a/internal/layout/pubclass/publication_guard_test.go
+++ b/internal/layout/pubclass/publication_guard_test.go
@@ -108,7 +108,7 @@ func (g *publicationGuard) direct(u *publicationUnit, e ast.Expr) (publicationTa
return publicationTarget{}, false
}
switch name {
- case "SyncDir", "SyncDirAt", "Seed", "Publish", "Run":
+ case "SyncDir", "SyncDirAt", "Seed", "Publish", "Run", "NewFromCopy", "CopyManifest", "Open", "OpenAt", "OpenBaseline", "OpenForSeed", "OpenAtForSeed":
identity = name
default:
return publicationTarget{}, false
@@ -709,6 +709,23 @@ func (g *publicationGuard) check(u *publicationUnit, c *ast.CallExpr, target pub
}
args = args[target.offset:]
switch target.kind {
+ case "NewFromCopy", "CopyManifest", "OpenForSeed", "OpenAtForSeed":
+ // These entry points refuse inherited raw items inside hostfiles.
+ case "Open", "OpenAt", "OpenBaseline":
+ // Active escrow needs legacy baselines to seal them. Keep this
+ // inventory exact; every other continuation must refuse up front.
+ sealing := map[string][]string{
+ "stageWakeFiles": {"OpenBaseline"},
+ "stageKeptFiles": {"OpenBaseline"},
+ "openHostFiles": {"Open"},
+ "haSecretsReady": {"Open"},
+ "bucketManifest": {"Open"},
+ "openEscrowLocked": {"Open", "OpenBaseline"},
+ "escrowReread": {"Open"},
+ }
+ if u.pkg.PkgPath != publicationModule+"/internal/activator" || !slices.Contains(sealing[u.name], target.kind) {
+ g.problem(u, c, target.kind+": baseline must use a raw-secret-refusing entry point")
+ }
case "Stage":
if len(args) < 2 || !g.classified(u, c, args[1]) {
g.problem(u, c, "Stage: path has no dominating, single-assignment App classification")
@@ -887,6 +904,7 @@ func TestEveryStagingOperationIsClassified(t *testing.T) {
}
want := map[string][]string{
"clean.go": nil,
+ "baseline.go": {"zzRawContinue:Open:", "zzRawPrepared:OpenAt:", "zzRawBaseline:OpenBaseline:", "zzCopyEscape:unknown callable escape"},
"preflight.go": {"zzPreflightOnly:Seed:", "zzPreflightOnly:SyncDirAt:"},
"unmapped.go": {"zzUnmapped:Stage:", "zzUnmapped:Stage:"},
"refusalwrites.go": {"zzRefusalLoop:SyncDirAt:", "zzRefusalClosure:SyncDirAt:", "zzRefusalPointer:SyncDirAt:"},
diff --git a/internal/layout/pubclass/testdata/publication_guard/baseline.go b/internal/layout/pubclass/testdata/publication_guard/baseline.go
new file mode 100644
index 000000000..c83e88fbd
--- /dev/null
+++ b/internal/layout/pubclass/testdata/publication_guard/baseline.go
@@ -0,0 +1,21 @@
+package host
+
+import (
+ "context"
+ "github.com/carlosframework/platform/internal/hostfiles"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+func zzRawContinue(ctx context.Context, s release.Store, prefix string) (*hostfiles.Publisher, error) {
+ return hostfiles.Open(ctx, s, prefix)
+}
+
+func zzRawPrepared(s release.Store, prefix string, body []byte, token string) (*hostfiles.Publisher, error) {
+ return hostfiles.OpenAt(s, prefix, body, token)
+}
+
+func zzRawBaseline(s release.Store, prefix string, base hostfiles.Baseline) (*hostfiles.Publisher, error) {
+ return hostfiles.OpenBaseline(s, prefix, base)
+}
+
+func zzCopyEscape() any { return hostfiles.NewFromCopy }
diff --git a/internal/layout/pubclass/testdata/publication_guard/clean.go b/internal/layout/pubclass/testdata/publication_guard/clean.go
index 2e87b18f3..f2b30eaab 100644
--- a/internal/layout/pubclass/testdata/publication_guard/clean.go
+++ b/internal/layout/pubclass/testdata/publication_guard/clean.go
@@ -7,6 +7,7 @@ import (
"github.com/carlosframework/platform/internal/hostfiles"
"github.com/carlosframework/platform/internal/instancekey"
"github.com/carlosframework/platform/internal/layout/pubclass"
+ "github.com/carlosframework/platform/internal/release"
)
func zzClean(ctx context.Context, p *hostfiles.Publisher, q *hostfiles.Prepared, root *os.File, host, path string) error {
@@ -97,3 +98,17 @@ func zzCleanInventoryPath(ctx context.Context, p *hostfiles.Prepared, host, path
}
return p.Stage(ctx, x, nil, 0600)
}
+
+func zzCleanBaselines(ctx context.Context, s release.Store, prefix string, base hostfiles.Manifest, body []byte, etag string) error {
+ if _, err := hostfiles.NewFromCopy(s, prefix, base, nil); err != nil {
+ return err
+ }
+ if _, err := hostfiles.CopyManifest(ctx, s, prefix, prefix+"next/", 0, nil); err != nil {
+ return err
+ }
+ if _, err := hostfiles.OpenForSeed(ctx, s, prefix); err != nil {
+ return err
+ }
+ _, err := hostfiles.OpenAtForSeed(s, prefix, body, etag)
+ return err
+}
diff --git a/internal/provision/durability_3a_branchfix3_census_test.go b/internal/provision/durability_3a_branchfix3_census_test.go
new file mode 100644
index 000000000..d287d0776
--- /dev/null
+++ b/internal/provision/durability_3a_branchfix3_census_test.go
@@ -0,0 +1,25 @@
+package provision
+
+// B3 refuses raw-bearing baselines before CopyManifest can PUT.
+// The target key, nonrecord class and write kinds stay unchanged.
+func durability3aBranchFix3WriteCensusInventory() []censusEntry {
+ entries := append([]censusEntry(nil), durability3aBranchFix2bWriteCensusInventory()...)
+ repins := []censusEntry{
+ {"internal/hostfiles/contract.go", "CopyManifest", "nonrecord", "sel:Put", "117f1782821ba7cb7e77537cd7fb1283c4f23e6b1139afddca4a9620d0845102"},
+ }
+ for _, r := range repins {
+ found := false
+ for i, e := range entries {
+ if e.File == r.File && e.Unit == r.Unit {
+ if e.Class != r.Class || e.Kinds != r.Kinds {
+ panic("durability-3a branch fix 3 re-pin changes class or kinds of " + r.File + ":" + r.Unit)
+ }
+ entries[i], found = r, true
+ }
+ }
+ if !found {
+ panic("durability-3a branch fix 3 re-pin of an unlisted unit " + r.File + ":" + r.Unit)
+ }
+ }
+ return entries
+}
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go
index 99091c57f..627ba9f28 100644
--- a/internal/provision/plan9_b8_census_test.go
+++ b/internal/provision/plan9_b8_census_test.go
@@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) {
if len(got) < 100 {
t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root)
}
- inventory := durability3aBranchFix2bWriteCensusInventory()
+ inventory := durability3aBranchFix3WriteCensusInventory()
problems := append(censusDiff(inventory, got), censusPolicy(inventory)...)
if len(problems) > 0 {
t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n "))
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index ccd8db4f8..534468928 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -52,4 +52,4 @@ plan14-root-reads-managed-fleets-1b.tsv 7570ca617863882780c1c5a7d04430b578a297ee
plan14-root-reads-sponsor-existing-accounts.tsv 7570ca617863882780c1c5a7d04430b578a297ee4d72ca25acc1cdc5288ca283
plan14-root-reads-rootfs-apps-6.tsv c86929d08b9b2038fa103d1c7311ab2958e7100e92dc550d36daeb364affd029
plan14-root-reads-devbox-macos.tsv 67b54b219f990c3dcfe32c6ffb11a80a4ca3898aec060fe9f4450e21098af714
-plan14-root-reads-durability-3a-escrow.tsv 18f1c7991164d28cf0b16b0aa2fb2569570acf1a9a0465ddda04f8f9240320a9
+plan14-root-reads-durability-3a-escrow.tsv 0812141114655728c5f7e4204ebe6f41fbf320e256dd68881b534ffe614353df
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 c48708597..524b35f18 100644
--- a/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv
+++ b/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv
@@ -1,14 +1,13 @@
# 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.
# 11 body, 12 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
# 4 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.
-# 47 new dispositions: 1 reads re-frozen at their disposition with the claim, 45 new units frozen accepted-legacy, 1 quiet units retired while they read nothing, 0 other.
+# 50 new dispositions: 1 reads re-frozen at their disposition with the claim, 46 new units frozen accepted-legacy, 3 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 4959fc931f2d6af0dd7a80d6f75b3eef14b502750ebd38e15ba1a5fdf50f95bf internal/activator/instancekey.go ExecBackend.ensureInstanceKeyAt legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: after the unchanged replica and fenced/conflict checks, asks haMintGuard(ctx, rt) (+whole:Route) and hands the guard to ensureInstanceKey; a classification error fails with InstanceKeyFailed; a non-HA host gets a nil guard and mints exactly as before; only adds a refusal;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: asks mintGuardFor(ctx, rt) (was haMintGuard): an HA host's guard as before; an eligible host's escrowMintGuard, which on a ready box reads the bucket manifest and the sealed env item when a mint is next and refuses while the escrow holds the key, and on a box that is not ready refuses every mint; nil for any other host, which mints as before. The replica and fenced/conflict refusals are unchanged; only adds refusals Fix round 1: asks mintGuardWith(ctx, rt, !create): a launch's ensure shares its preparation's escrow read, the backfill's reads the bucket afresh; only refuses. registry:Host@598,registry:Replica@159,whole:Route@491,whole:Route@667 5605bd1a4441859415f51b50c38e959987b2524fa8ccbec7364949e7097e9770
@legacy 62f2a51b33e98d5e15741fab9c6b9bbbb96a36846290bdc71800b28ac23dee51 internal/activator/instancekey.go ensureInstanceKey legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more parameter, guard (nil for every caller but ensureInstanceKeyAt on an HA host), asked once the locked read finds no key and the bucket allows a mint, before anything is minted; its refusal returns InstanceKeyFailed with nothing written. Create-only, fail-closed and defer-on-unknown are unchanged; the one site unchanged, no read added; only adds a refusal;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: the guard is asked with InstanceKeyVar, at the same point (the locked read found no key and the bucket allowed a mint); create-only, fail-closed and defer-on-unknown unchanged; the same one site; only adds a refusal file:Stat@4816 2d53f8246ac317c066d4b804cdc251aaf60abbd4423c6b780f0cbee227203fc8
-@legacy bd27a869ea40ccecb8c4bff4b2f5eeeda93b81d2d0de2542f19af508eb5858a4 internal/host/relocationflush.go ReleaseFlushFiles.Flush legacy accepted-legacy accepted-legacy;rev3=PROPOSED-seed;basis=census-ruling-FS-R6; tenant files and env are published data, never authority;rev3=census-ruling-durability-3a-escrow;basis=Durability 3a Task 5 (parked path, host claims only): the env file's presence is decided first with instancefs.OpenBeneathOrAbsent (the bytes are never read, replacing readInstanceFile of the env): present refuses with pubclass.ErrSecretPath before the manifest is read; hostfiles.RefuseSecretsAt over the root it opened, after the tenant seam and before hostfiles.Seed; absent still stages the env item's delete. Only refuses more, and reads less. Branch fix R1 P1-2: Seed also receives FilesDirSkip for classification during the upload walk; the release flush composes its optional skip as an additional exclusion. The preflight remains; no read target or authority added. file:Open@1428 daf3181c23d5daa67552ed034f7acc9d953bc87d0103d44a3da2a397dd9858e3
@legacy e24a236954fe52e3d74ffc3a69733e88dec8bbdb5d7af50e7ddd06b993aa5188 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. Durability 3a Task 5 fix round 1: restore() takes one more argument, checked (nil from Restore, RestoreRoot and RestoreRootBaselineShadowed), called with the manifest after checkManifest and before anything is removed, fetched or written (RestoreRootBaselineObserved passes the caller's); Restore passes nil, so its reads, opens and writes are exactly as before. file:OpenRoot@219 28385093d26c704b98e5f199ec9fa045302c989188abe38d41b3439f6a151a7e
@legacy a11c7bc89fb9c0f17ab1ed9d986e3ad4331b66a3ae9d2c857b3979aac03867fd internal/activator/escrow.go ExecBackend.EscrowSweep legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new, the agent as carlos (carlos-edge.service), no root caller, from escrowLoop: classifies each row against the rows handed in (Classify), keeps eligible rows known not HA from memory (haKnown, no read), and in host order from a round-robin cursor stats each escrowed file (stampAt) and publishes the changed ones, 8 at a time, at most 256 a sweep (sweepPublish); a box without a files store or key does nothing; opens nothing outside the rows' own data directories; writes only the hibernate bucket's files/0 prefix and the ledger Fix round 1: a host whose instance lease this box does not hold (holdsLease) is skipped, and one with a conflict marker counts as failing and is not published; the report is tallied through one lock (P1-4). Durability 3a Task 5: for each lease-held candidate, the host's held publisher (st.pub under the escrow lock) is handed to noteRawBaseline. Reads only manifests this process already holds (no request, no file opened); calls the detector, which logs and calls ExecBackend.OnRawSecret; nothing else changes. The +registry:Host sites are rt.Host as the state key and the detector's argument. registry:Host@1004,registry:Host@1041,registry:Host@1131,registry:Host@1287,registry:Host@1306,registry:Host@1457,registry:Host@1990,registry:Host@2336,registry:Host@2593,registry:Host@2667,registry:Host@536,registry:Host@761,registry:Host@795,registry:Host@933,whole:Route@1188,whole:Route@1192,whole:Route@1209,whole:Route@1296,whole:Route@1315,whole:Route@1466,whole:Route@1784,whole:Route@1992,whole:Route@2222,whole:Route@2338,whole:Route@2595,whole:Route@2669,whole:Route@356,whole:Route@519,whole:Route@587,whole:Route@653,whole:Route@706 ae45fefc9292c357fdc3d4ce737a1498eea44204a2beaedf6600051280ac43d1
@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
@@ -53,6 +52,7 @@
@legacy 29ed64c9e5683c30cebe4a93f46e8c9617e31875b17e64be9ef8fb95db497e06 internal/host/movesfiles.go claimEnvPresent legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=Durability 3a Task 5: new: whether the claim env file exists, without reading it: nested, instancefs.OpenBeneathOrAbsent beneath the instance directory (no link at any component; the descriptor closed at once); flat, os.Lstat of <data>/<host>.env (a link there counts as present, so it refuses). An undecidable answer is an error. Only feeds a refusal. file:Lstat@81 99e674efa8d1bf26a59304024912fcd5b5caf2e5d80274e8def7dbb75d9362b5
@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 a76152bfa291d9fd1a1802a614f2eabc0fd52becd69bc251acc3155336e4ea0b internal/hostfiles/publisher.go Publisher.Refresh legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=Fix round 2b: reuses Open on the publisher's existing store and manifest prefix, under the publisher mutex. A successful read and validation replaces the baseline and discards pending stages; a failure keeps the typed stale fence. No new storage path or authority. file:Open@106 5ea7449c9c1d080149d48bd069cc8d923a83908fae21d50da2cb937013fae3f1
+@legacy 2663d02ef63a8265a7c78ceb47fe34e9470e7327938135b2dd0c8353d85a8f75 internal/hostfiles/rawbaseline.go OpenForSeed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=Parked continuation opens the same store/prefix through Open, then refuses entries or platform items classified raw by pubclass.IsRawSecretItem. A typed ErrRawSecretBaseline wraps ErrSecretPath and logs the item without reading its bytes. No new storage path or authority. file:Open@120 37e8598ed99527f1ba65ffda8727621a2f7264e6ed9daa0a2d9f7f1a37096e38
@legacy 3fe9f2fb4317a769c1064de405465cd5ad07f19a94d44dbd835b5e2b3bff164b 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. Branch fix R2 P1-3: wrap the existing appconfig.Open error as SealedOpenError, preserving error text and cause, so a decryption refusal leaves a conflict marker while a transient storage GET failure does not. Same fetch and envelope verification; no new read. file:Open@898 14437206baa72c952a8be716aa035b723f408384eaf6db56af16b554587e6a6d
@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 8ccceaa7c2efcec2085fe2f577bdf1d39c723af9d5fca9abf79425fec256740a internal/host/movesfiles.go buildPrepared legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;census-ruling-moves-overcap-cut-236;rev3=census-ruling-durability-3a-escrow;basis=Durability 3a Task 5 (parked path, CARLOS_MOVES_PHASE1 only): wantEnv refuses with pubclass.ErrSecretPath before anything is read or written; the env presence check for !wantEnv is os.Stat instead of os.ReadFile (the secret is no longer read into memory); hostfiles.RefuseSecretsAt over root.Open(".") (+file:Open, a descriptor of the os.Root it already opened, never a pathname) before NewPrepared; the walk checks pubclass.Of(...) == App before each Stage; the env file is never staged. Only refuses more, and reads less. file:Lstat@1275,file:Open@2772,file:OpenRoot@2377,file:Stat@1468,file:WalkDir@3263 75cf376b93c2f69f4c8d1997a0158795c7bcd6967a7742a18ca79822b8e27a2a
@@ -76,9 +76,9 @@ internal/activator/instancekey.go ExecBackend.ensureInstanceKeyAt legacy accepte
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-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): sets svc.Fleet = fleetWakeFor(os.Getenv, identity, identErr, fleetStore) from the identity it already resolves once and the deployment store the fleet loops already opened, and logs an ERROR naming the identity error when the box is on a fleet with an invalid identity. fleetWakeFor reads CARLOS_REGION and CARLOS_FLEET from the same environment. Read sites unchanged (6). Agent, not root; a platform box is unchanged.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites; merge of origin/main 6f1f6ca6: main's svc.Fleet = fleetWakeFor(...) and its invalid-identity ERROR line are kept as main has them (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (6);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. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. Merge of origin/main 90c4d3aa: main's own later changes to this body are kept as main has them, under main's rulings; this branch's change is the same as above. file:Exec@17444,file:Open@1150,file:Statfs@44013,registry:App@11199,whole:Route@11191,whole:Route@28232 9077bf263076fbdb95be61279b53fb22bb70bf720022d2dab2ca196caa8d10d1
internal/host/claimfilesseed_stage.go filesSeedOperation.stage authority C,J4 rev3=PROPOSED-seed; fresh private provider, real admitted tuple and origins; guarded safe source descriptor and wake snapshot; create conflicts compare bounded bytes at exact current version before commit;rev3=census-ruling-durability-3a-escrow;basis=Durability 3a Task 5 (parked path, host claims with origins only): hostfiles.RefuseSecretsAt over the root it opened, before hostfiles.Seed: any path the classifier does not call App refuses the seed before its first write, with pubclass.ErrSecretPath. No read added; the walk is the descriptor walk Seed itself makes. Task 7 fix round 1: bind the descriptor returned through work.With once as dir; stat, RefuseSecretsAt and Seed use that same descriptor. No path, read, authority, refusal or production behavior changes; the account/host identity and descriptor lifetime are unchanged. Branch fix R1 P1-2: Seed also receives FilesDirSkip for classification during the upload walk; the release flush composes its optional skip as an additional exclusion. The preflight remains; no read target or authority added. file:Stat@1540,file:Stat@761 15d5daee2a7bcdf768f30ed909d6e89b20b7d62466824a3232f9219a242b3cec
-internal/host/movesfiles.go movesFiles.Establish authority C,J4 rev3=PROPOSED-p3;run=12;basis=agent files preparation; retains seed admitted-writer and ordinary origin proof with one C8 commit; H3 is inventory bookkeeping, C owns the enabled effect;rev3=census-ruling-durability-3a-escrow;basis=Durability 3a Task 5 (parked path, host claims only): a present env file (claimEnvPresent: nested via instancefs.OpenBeneathOrAbsent, flat via Lstat; the bytes are never read) refuses with pubclass.ErrSecretPath before any bucket write; the env bytes are no longer read (readClaimEnvFile deleted); with no env file the establishment proceeds and stages StagePlatformDelete(EnvItem), so a raw env item a baseline holds is dropped, never carried into the new generation; openPrepared no longer takes the env and establishedOver no longer GETs an env object. Only refuses more, and reads less. df33d8996c148bf34cdb6d5a59ac73137498beab31c561d926e3d19c59856a27
-internal/host/relocationflush.go ReleaseFlushFiles.Flush legacy accepted-legacy accepted-legacy;rev3=PROPOSED-seed;basis=census-ruling-FS-R6; tenant files and env are published data, never authority;rev3=census-ruling-durability-3a-escrow;basis=Durability 3a Task 5 (parked path, host claims only): the env file's presence is decided first with instancefs.OpenBeneathOrAbsent (the bytes are never read, replacing readInstanceFile of the env): present refuses with pubclass.ErrSecretPath before the manifest is read; hostfiles.RefuseSecretsAt over the root it opened, after the tenant seam and before hostfiles.Seed; absent still stages the env item's delete. Only refuses more, and reads less. Branch fix R1 P1-2: Seed also receives FilesDirSkip for classification during the upload walk; the release flush composes its optional skip as an additional exclusion. The preflight remains; no read target or authority added. file:Open@1428 daf3181c23d5daa67552ed034f7acc9d953bc87d0103d44a3da2a397dd9858e3
+internal/host/movesfiles.go movesFiles.Establish authority C,J4 rev3=PROPOSED-p3;run=12;basis=agent files preparation; retains seed admitted-writer and ordinary origin proof with one C8 commit; H3 is inventory bookkeeping, C owns the enabled effect;rev3=census-ruling-durability-3a-escrow;basis=Durability 3a Task 5 (parked path, host claims only): a present env file (claimEnvPresent: nested via instancefs.OpenBeneathOrAbsent, flat via Lstat; the bytes are never read) refuses with pubclass.ErrSecretPath before any bucket write; the env bytes are no longer read (readClaimEnvFile deleted); with no env file the establishment proceeds and stages StagePlatformDelete(EnvItem), so a raw env item a baseline holds is dropped, never carried into the new generation; openPrepared no longer takes the env and establishedOver no longer GETs an env object. Only refuses more, and reads less. 19460e82a02513d76113a48b00cfa4e25ca1921a2d71898fb90fc8b85a93caac
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. Durability 3a Task 5 fix round 1: restore() takes one more argument, checked (nil from Restore, RestoreRoot and RestoreRootBaselineShadowed), called with the manifest after checkManifest and before anything is removed, fetched or written (RestoreRootBaselineObserved passes the caller's); Restore passes nil, so its reads, opens and writes are exactly as before. file:OpenRoot@219 28385093d26c704b98e5f199ec9fa045302c989188abe38d41b3439f6a151a7e
+internal/hostfiles/seed.go Seed authority C,J4 rev3=PROPOSED-seed; already-open source directory and wake snapshot; shared staging only, unstable reads refuse; caller owns origin proof and manifest commit;rev3=census-ruling-durability-3a-escrow;basis=Before StageWake or any tree staging, check the publisher baseline through the shared raw-secret refusal. Same caller-owned descriptor and wake snapshot; adds no read or write target and grants no authority. b576aef162bc9192d9895c6839b943b6a1f8c4ff7ce8021847432b0111d97423
internal/activator/escrow.go ExecBackend.EscrowSweep legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new, the agent as carlos (carlos-edge.service), no root caller, from escrowLoop: classifies each row against the rows handed in (Classify), keeps eligible rows known not HA from memory (haKnown, no read), and in host order from a round-robin cursor stats each escrowed file (stampAt) and publishes the changed ones, 8 at a time, at most 256 a sweep (sweepPublish); a box without a files store or key does nothing; opens nothing outside the rows' own data directories; writes only the hibernate bucket's files/0 prefix and the ledger Fix round 1: a host whose instance lease this box does not hold (holdsLease) is skipped, and one with a conflict marker counts as failing and is not published; the report is tallied through one lock (P1-4). Durability 3a Task 5: for each lease-held candidate, the host's held publisher (st.pub under the escrow lock) is handed to noteRawBaseline. Reads only manifests this process already holds (no request, no file opened); calls the detector, which logs and calls ExecBackend.OnRawSecret; nothing else changes. The +registry:Host sites are rt.Host as the state key and the detector's argument. registry:Host@1004,registry:Host@1041,registry:Host@1131,registry:Host@1287,registry:Host@1306,registry:Host@1457,registry:Host@1990,registry:Host@2336,registry:Host@2593,registry:Host@2667,registry:Host@536,registry:Host@761,registry:Host@795,registry:Host@933,whole:Route@1188,whole:Route@1192,whole:Route@1209,whole:Route@1296,whole:Route@1315,whole:Route@1466,whole:Route@1784,whole:Route@1992,whole:Route@2222,whole:Route@2338,whole:Route@2595,whole:Route@2669,whole:Route@356,whole:Route@519,whole:Route@587,whole:Route@653,whole:Route@706 ae45fefc9292c357fdc3d4ce737a1498eea44204a2beaedf6600051280ac43d1
internal/activator/escrow.go ExecBackend.SecretsEscrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: haHostNow or escrowEligible; reads only what the HA classification already reads whole:Route@123,whole:Route@198 c22d35df72f67d7222efd0b0f09d51c42275ad4a10d637598fdc8b822f6333bd
internal/activator/escrow.go ExecBackend.bucketManifest legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4 fix round 1: new: the host's files manifest in the hibernate bucket, the launch preparation's read when there is one (unless fresh), else one GET: hostfiles.Open with a sealing key (the publisher installed for the launch's publish), hostfiles.Load without; kept as the preparation's read; the agent as carlos (carlos-edge.service), no root caller Fix round 4: a manifest it reads is kept as what this process knows the bucket holds (learnBucket, the one writer of escrowState.known) and as the preparation's read; a failed read wraps errEscrowUnreadable; the same reads. Durability 3a Task 5: after learnBucket, noteRawSecrets(rt.Host, m) on the manifest just read. Reads only manifests this process already holds (no request, no file opened); calls the detector, which logs and calls ExecBackend.OnRawSecret; nothing else changes. The +registry:Host site is that call's argument. Branch fix R1 P1-3: select sealed escrow against Route.Incarnation before decrypting, restoring, minting or checking divergence: lower non-zero escrow is retired in the selected view, higher refuses, equal and zero-stamped retain behavior. Publication stamps the current lifetime atomically, drops prior-lifetime cached stamps, and never treats retired escrow as a committed successor. Same storage paths; historical objects retained. Self-review: cache only the original bucket manifest; apply incarnation selection as a per-route view at the consuming boundary, preserving evidence for an older in-flight route snapshot until a successor actually commits. Branch fix R2: remove incarnation selection and stamping per Paul's ruling; restore pre-030ce7f9 hostname-scoped escrow behavior. No read added. Same-key hostname reuse can inherit predecessor secrets; a changed key refuses. Keep the uncertain-commit and CAS-recovery read-failure refusals. file:Open@407,registry:Host@170,registry:Host@241,registry:Host@272,registry:Host@992,whole:Route@360 94dbd66072a9ba0bdef16f9b15894b93728b56abbd22512c83d4f68e1af4d85a
@@ -122,6 +122,7 @@ internal/host/escrow_loop.go escrowLoop legacy accepted-legacy accepted-legacy;r
internal/host/movesfiles.go claimEnvPresent legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=Durability 3a Task 5: new: whether the claim env file exists, without reading it: nested, instancefs.OpenBeneathOrAbsent beneath the instance directory (no link at any component; the descriptor closed at once); flat, os.Lstat of <data>/<host>.env (a link there counts as present, so it refuses). An undecidable answer is an error. Only feeds a refusal. file:Lstat@81 99e674efa8d1bf26a59304024912fcd5b5caf2e5d80274e8def7dbb75d9362b5
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/publisher.go Publisher.Refresh legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=Fix round 2b: reuses Open on the publisher's existing store and manifest prefix, under the publisher mutex. A successful read and validation replaces the baseline and discards pending stages; a failure keeps the typed stale fence. No new storage path or authority. file:Open@106 5ea7449c9c1d080149d48bd069cc8d923a83908fae21d50da2cb937013fae3f1
+internal/hostfiles/rawbaseline.go OpenForSeed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=Parked continuation opens the same store/prefix through Open, then refuses entries or platform items classified raw by pubclass.IsRawSecretItem. A typed ErrRawSecretBaseline wraps ErrSecretPath and logs the item without reading its bytes. No new storage path or authority. file:Open@120 37e8598ed99527f1ba65ffda8727621a2f7264e6ed9daa0a2d9f7f1a37096e38
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. Branch fix R2 P1-3: wrap the existing appconfig.Open error as SealedOpenError, preserving error text and cause, so a decryption refusal leaves a conflict marker while a transient storage GET failure does not. Same fetch and envelope verification; no new read. file:Open@898 14437206baa72c952a8be716aa035b723f408384eaf6db56af16b554587e6a6d
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/host/movesfiles.go buildPrepared legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;census-ruling-moves-overcap-cut-236;rev3=census-ruling-durability-3a-escrow;basis=Durability 3a Task 5 (parked path, CARLOS_MOVES_PHASE1 only): wantEnv refuses with pubclass.ErrSecretPath before anything is read or written; the env presence check for !wantEnv is os.Stat instead of os.ReadFile (the secret is no longer read into memory); hostfiles.RefuseSecretsAt over root.Open(".") (+file:Open, a descriptor of the os.Root it already opened, never a pathname) before NewPrepared; the walk checks pubclass.Of(...) == App before each Stage; the env file is never staged. Only refuses more, and reads less. file:Lstat@1275,file:Open@2772,file:OpenRoot@2377,file:Stat@1468,file:WalkDir@3263 75cf376b93c2f69f4c8d1997a0158795c7bcd6967a7742a18ca79822b8e27a2a
@@ -137,6 +138,10 @@ internal/activator/hasecrets.go ExecBackend.haSecretsReady legacy accepted-legac
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. Durability 3a Task 5: after RestoreRootBaselineShadowed, noteRawSecrets(host, rm) on the manifest just restored from. Reads only manifests this process already holds (no request, no file opened); calls the detector, which logs and calls ExecBackend.OnRawSecret; nothing else changes. Read sites unchanged. Durability 3a Task 5 fix round 1: the restore is RestoreRootBaselineObserved (the same read and restore as RestoreRootBaselineShadowed) with a checked callback, noteRawSecrets(host, m), run once the manifest is read and validated and before any entry is removed, fetched or written, so a restore that then fails still shows the detector the manifest; the later noteRawSecrets call is gone. No request, open or write added; read sites unchanged. registry:Host@97,whole:Route@1086,whole:Route@1586,whole:Route@200 ca4b8c70486f72a3bd7ede5d16c8f9fd22eee13f11d005597223a4f5ab20b405
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/host/relocationflush.go ReleaseFlushFiles.Flush
+@removed internal/host/relocationflush.go ReleaseFlushFiles.Flush H3 census-ruling-durability-3a-escrow;basis=Durability 3a Task 5 (parked path, host claims only): the env file's presence is decided first with instancefs.OpenBeneathOrAbsent (the bytes are never read, replacing readInstanceFile of the env): present refuses with pubclass.ErrSecretPath before the manifest is read; hostfiles.RefuseSecretsAt over the root it opened, after the tenant seam and before hostfiles.Seed; absent still stages the env item's delete. Only refuses more, and reads less. Branch fix R1 P1-2: Seed also receives FilesDirSkip for classification during the upload walk; the release flush composes its optional skip as an additional exclusion. The preflight remains; no read target or authority added. Task B3: Use OpenForSeed for the same generation prefix before ExportWake and Seed. A raw-bearing manifest refuses and logs before any PUT; historical objects stay untouched. No new read target or authority.
+@remove internal/hostfiles/contract.go Publish
+@removed internal/hostfiles/contract.go Publish H3 census-ruling-durability-3a-escrow;basis=Use OpenForSeed in place of Open; the same manifest read and CAS behavior, with raw-bearing inherited manifests refused before staging. No new read target or authority.
@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
@remove internal/activator/hasecrets.go ExecBackend.haScheduledToken
@@ -148,7 +153,7 @@ internal/activator/paths.go ExecBackend.pathsFor legacy accepted-legacy accepted
@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 00b08377f1580ec647ba4d95b69768946a41362836c98423012ff29281b8280d
-@coverage internal/host 941b090a234199926a9f64c927657034c3b5fb17dea1f5a18716cfe2294f55b1
-@coverage internal/hostfiles c36ed3386a51d450c9b212e84221fce1fb39dcf7b0b18c7690331fb9fdcec6f0
+@coverage internal/host 7db0a0a884919bfaef1aa0c4f82ec0103fcb2a56962f8ed084e60469f8c5dd37
+@coverage internal/hostfiles 2cd8c98a974bb0936ef4a3023d4b68369709dabc15c8c37dc25f0a893f7fd267
@coverage internal/layout f845fa728b0935279454d8b01023c5d6dae1c985061a41229cf0686e829f5c12
@coverage internal/layout/pubclass 6515ba31b1848139c9da066a6c65b5583c39a92cb77621773d0d11d9cde24e24