carlos / platform Public

fix(hostrelocate): refuse raw pins before manifest publication

Export and reuse the hostfiles baseline refusal before retaining a relocation
pin or publishing its prepared manifest. Inventory ManifestKey consumers in
the publication guard and witness zero writes for raw pins and copies.

Re-propose the root census and re-pin CopyManifest's unchanged write class.
Targeted and race checks, census and cross-builds pass. The full host run
retains the pre-existing local lifecycle-provider failures.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev ca56d939567065c01c2f4dbf45c0ea3f54db8700 parent e6cb5af
21 files changed, +541 −102
  • docs/superpowers/notes/census-durability-3a-escrow-claims.md +6 −1
  • docs/superpowers/notes/census-proposal-durability-3a-escrow.md +2 −2
  • internal/host/movesfiles.go +4 −4
  • internal/host/relocationbuild_test.go +7 −1
  • internal/host/relocationprobefiles_linux_test.go +28 −81
  • internal/hostfiles/contract.go +1 −1
  • internal/hostfiles/prepared.go +1 −1
  • internal/hostfiles/rawbaseline.go +4 −3
  • internal/hostfiles/rawbaseline_test.go +1 −1
  • internal/hostfiles/seed.go +1 −1
  • internal/hostrelocate/pin.go +6 −0
  • internal/hostrelocate/pin_envkey_test.go +2 −0
  • internal/hostrelocate/pin_test.go +8 −0
  • internal/hostrelocate/pin_versioned_test.go +1 −0
  • internal/hostrelocate/rawbaseline_test.go +132 −0
  • internal/layout/pubclass/publication_guard_test.go +186 −1
  • internal/layout/pubclass/testdata/publication_guard/clean.go +31 −0
  • internal/layout/pubclass/testdata/publication_guard/manifestwrite.go +89 −0
  • internal/provision/durability_3a_branchfix3b_census_test.go +25 −0
  • internal/provision/plan9_b8_census_test.go +1 −1
  • internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv +5 −4

CI passed — run details

Intent

Human

<task-notification> <task-id>a5050d706a566669a</task-id> <tool-use-id>toolu_01FqPxYjoPjrSkHnN8674JYp</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/aab63774-dfe6-44a4-9cd9-230e6f4c3d13/tasks/a5050d706a566669a.output</output-file> <status>completed</status> <summary>Agent "Opus check of 3a fix round 3" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>The fix is not closed. It works for the two publishers Astra named (the claim Establish and the relocation release flush), but one other parked path still copies a raw-secret baseline into a new manifest without the refusal. The full write-up is in `.../2026-10-30-durability-step3-escrow-fence-restore/branch-fix3-check-opus.md`. I ran one focused test, `TestRelocationFirstProbeRefusesRawBaselineThroughTheC8Provider`. It passed, and its log shows the refusal naming `files/g-p1/ ... host.env`. I used the sandbox TMPDIR because `/tmp/g` is read-only in this sandbox. ## 1. Paths outside hostfiles that start from an existing manifest - **`movesfiles.go:1153`** (Establish copying the newest manifest): refused. A witness covers it. - **`movesfiles.go:754`** (prepared replay, `OpenAtForSeed`): refused. A witness covers it. - **`movesfiles.go:1109`** (empty bootstrap) and **`:295`** (`NewPrepared` from the local tree): no inherited baseline. OK. - **`claimfilesseed_stage.go:152`** (`Seed`): its publisher is already checked, and `Seed` checks again under the lock. OK. - **`relocationflush.go:82` and `:101`** (release flush via `OpenForSeed`, then `Seed`): refused. A witness covers it. - **Activator** (`Open` and `OpenBaseline` at hasecrets.go:269, hafiles.go:216/294/335, escrow.go:335/646/652/1227, plus two `Refresh` calls): these are the live sealing publishers. They are allowlisted on purpose and drop raw items in the same sealed commit. Within the ruling. - **`hostfiles.Publish`, `CopyManifest`, `Run`**: no production callers. - **Not closed: `internal/hostrelocate/pin.go:417-452` `CopyPinnedManifest`**, called from `internal/host/relocationbuild.go:106`. - The relocation build writes the new generation's prepared manifest (generation P, sequence 0) using its own JSON encode and `release.CreateExact`. That copies every pinned entry and platform item, including raw `instance.key`, `report.token` and `host.env`. - It only runs `ValidateManifest`. The guard doesn't see it because it never calls a hostfiles publisher function. - B3's own test edits (`relocationprobefiles_linux_test.go:257`, `:277-279`, `:288`, `:308`) now assert that P still holds the raw env, and call it "historical". It isn't historical: this relocation's build wrote it, before the probe refused. The focused test run confirms this. ## 2. Refusal before any PUT - **Establish (copy and prepared) and the release flush:** yes. Everything before the refusing call is a read. The witnesses count PUTs on the only store written, check the old manifest is unchanged byte for byte, check that nothing new was committed, check the operator log line, and include a clean control. - **Relocation:** no. The pin's retained copy, P's manifest, the database build, the install manifest and the restore of the env file to the target's disk all happen before the probe refuses. ## 3. Live paths Nothing live breaks. - **Operator offline move:** makes no hostfiles calls at all. - **HA publication:** only uses `Open`, `OpenBaseline`, `Refresh` and `SyncDirAt`, none of which B3 changed. - **Pre-3a HA manifests with a raw `host.env`:** unchanged on the live path. The escrow gate seals the trio. In the same commit, `DropRawSecrets` removes the `host.env` platform key and tombstones `instance.key` and `report.token`. Historical objects stay where they are, and no page fires unless the cutover marker is present. - **The same manifests on the parked paths** now refuse with `ErrRawSecretBaseline`. Before, Establish dropped the env and committed. ## 4. New problems - **Important:** the `CopyPinnedManifest` gap above. - The fix should refuse at pin time (pin.go:265-275), before the retained copy at :181. The check should be one exported function in hostfiles. - `CopyPinnedManifest` should also run that check before it writes. - The relocation tests should assert that no P manifest is written for a raw pin. - **Important:** the publication guard recognises hostfiles functions by name only. A manifest written by hand outside hostfiles with `CreateExact` or `Put` on `hostfiles.ManifestKey(...)` is never inventoried. - **Minor:** - **Tombstones are refused** (rawbaseline.go:22-37). Tombstones name no object, but `DropRawSecrets` leaves them permanently. Any lineage that went through the HA migration therefore stays blocked for parked publishers. This matches the brief ("any raw item"), but should be noted before host claims are unparked. - **Guard allowlist:** it is keyed by bare function name inside the activator, so a new free function with an allowlisted name would pass. - **`Publisher.Refresh` bypass:** it re-opens with the unchecked `Open`, and the guard doesn't inventory it. No parked path calls it today. - **Stale doc comment** at `movesfiles.go:1048-1050`: it still says the raw env is dropped. Verdict: NOT CLOSED: hostrelocate.CopyPinnedManifest (relocation build, relocationbuild.go:106) still commits P's new seq-0 manifest carrying the pinned baseline's raw instance.key/report.token/host.env items without the hostfiles refusal, and the publication guard does not inventory that manifest copy.</result> <usage><subagent_tokens>170073</subagent_tokens><tool_uses>39</tool_uses><duration_ms>360694</duration_ms></usage> </task-notification>

Human

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

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

diff --git a/docs/superpowers/notes/census-durability-3a-escrow-claims.md b/docs/superpowers/notes/census-durability-3a-escrow-claims.md
index d73a74002..f8ddc2190 100644
--- a/docs/superpowers/notes/census-durability-3a-escrow-claims.md
+++ b/docs/superpowers/notes/census-durability-3a-escrow-claims.md
@@ -84,9 +84,14 @@ internal/activator/escrow.go:ExecBackend.stageEscrowReads Branch fix R2 P1-3: sh
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/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. Task B3b: rename that same check to exported RefuseRawSecretBaseline; behavior and read sites unchanged.
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.
+
+# Task B3b, within the final R3 refusal ruling; no fourth branch review.
+# Envelope-only: internal/hostfiles/rawbaseline.go exports the existing single refusal as RefuseRawSecretBaseline; callers in contract.go, prepared.go and seed.go use the same function. It examines only supplied manifest names and logs a typed refusal. No new read target or authority.
+# Envelope-only: internal/hostrelocate/pin.go:StorePinner.filesPin calls the shared refusal after decoding the existing manifest GET and before origin/key evidence or retained/pin PUTs. CopyPinnedManifest calls it on the verified retained manifest before marshaling/writing P, including on retries. The existing source and retained GET targets are unchanged. This only removes permission to publish raw-bearing baselines; no new root read or execution input.
+# Envelope-only: internal/host/movesfiles.go corrects Establish's comment: raw-bearing baselines refuse instead of having their raw env dropped. No executable change.
diff --git a/docs/superpowers/notes/census-proposal-durability-3a-escrow.md b/docs/superpowers/notes/census-proposal-durability-3a-escrow.md
index 7e2314841..0b0aeb2df 100644
--- a/docs/superpowers/notes/census-proposal-durability-3a-escrow.md
+++ b/docs/superpowers/notes/census-proposal-durability-3a-escrow.md
@@ -14,7 +14,7 @@ Ruling `census-ruling-durability-3a-escrow`. The independent reviewer approves o
| `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/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/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. Task B3b: rename that same check to exported RefuseRawSecretBaseline; behavior and read sites unchanged. |
| `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. |
@@ -28,7 +28,7 @@ Ruling `census-ruling-durability-3a-escrow`. The independent reviewer approves o
| `internal/activator/hawake.go` `ExecBackend.restoreFilesClean` | sites | +whole:Route | durability 3a Task 3 (fix round 1: sealed precedence before any fetch): the restore into <host>.restore is now RestoreRootBaselineShadowed with sealedShadow(host), a pure function of the manifest already read and validated: a live raw instance.key or report.token entry whose sealed item the manifest holds is neither fetched nor written (so a missing or corrupt raw object cannot fail the wake, and a sealed item that does not open fails it with no raw fallback); every other entry is restored as before, and the baseline the wake's publisher continues from is the manifest as read. Then each sealed trio item the manifest holds (instance.key.sealed, report.token.sealed) is fetched and opened with hostfiles.ReadSealed (key, sha256, v2 envelope, binding and MAC checked) and written with instancefs.WriteAtomic (openat2 directory, no symlink, O_EXCL temp, rename, 0600) into the restore directory this function created, then that directory is synced; then the same no-replace rename. The env file comes from the sealed env item through ReadSealed when present, else from the raw env item as before, written as before. The source is still the host's files manifest in the hibernate bucket; the destinations are the same restore directory and env file; no new path is opened, followed or named from input; the sealer (sealerFor) is built only when a sealed item is present. 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. |
| `internal/activator/paths.go` `ExecBackend.pathsFor` | sites | -registry:DBPath, -registry:Host ×7, +whole:Route | durability 3a Task 4: split in two: pathsFor classifies (Classify, unchanged) and hands the answer to pathsAt (new on this card), which holds the same body; the same paths for every row; the reads moved to pathsAt whole |
-Envelopes re-pinned: `internal/activator`, `internal/host`, `internal/hostfiles`, `internal/layout`, `internal/layout/pubclass`.
+Envelopes re-pinned: `internal/activator`, `internal/host`, `internal/hostfiles`, `internal/hostrelocate`, `internal/layout`, `internal/layout/pubclass`.
Removed units: the scan finds neither the declaration nor any of its sites.
diff --git a/internal/host/movesfiles.go b/internal/host/movesfiles.go
index 3a3d6f18c..9ae7b5395 100644
--- a/internal/host/movesfiles.go
+++ b/internal/host/movesfiles.go
@@ -1045,10 +1045,10 @@ func emptyManifest() hostfiles.Manifest {
//
// A present env file refuses the establishment before any bucket write,
// with an error wrapping pubclass.ErrSecretPath (durability 3a: <host>.env
-// is Sealed class, and this parked path does not seal). With none, the
-// raw env item a baseline may hold and the adoption item are dropped and
-// the revision is committed (create-only for a new generation;
-// compare-and-swap on P), each bucket write fenced by
+// is Sealed class, and this parked path does not seal). A raw-bearing
+// baseline also refuses before any write. With a clean baseline, the
+// adoption item is dropped and the revision committed (create-only for a
+// new generation; compare-and-swap on P), each bucket write fenced by
// the start's selection immediately before it and bounded by the request
// limit, never under the lock the work holds (selectionStore; fix round
// 1, finding 7). Then, under work, the local adoption record is removed:
diff --git a/internal/host/relocationbuild_test.go b/internal/host/relocationbuild_test.go
index 77d3c2b1e..ed74331ec 100644
--- a/internal/host/relocationbuild_test.go
+++ b/internal/host/relocationbuild_test.go
@@ -318,7 +318,13 @@ func sealedReplica(t *testing.T, b *leasetest.VersionedBucket, prefix string) ([
}
func (f *buildFixture) build() error {
- return f.a.relocationBuild(f.cfg)(f.t.Context(), f.obs)
+ f.t.Helper()
+ err := f.a.relocationBuild(f.cfg)(f.t.Context(), f.obs)
+ var raw *hostfiles.ErrRawSecretBaseline
+ if errors.As(err, &raw) {
+ skipParkedSecretFlow(f.t, "relocation refuses the raw pinned baseline before writing P: "+err.Error())
+ }
+ return err
}
func (f *buildFixture) prefix() string {
diff --git a/internal/host/relocationprobefiles_linux_test.go b/internal/host/relocationprobefiles_linux_test.go
index 0bcd06e6a..8106d9e07 100644
--- a/internal/host/relocationprobefiles_linux_test.go
+++ b/internal/host/relocationprobefiles_linux_test.go
@@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"os"
- "path/filepath"
"strconv"
"strings"
"testing"
@@ -253,60 +252,34 @@ func (f *probeFilesFixture) established() (hostfiles.Manifest, preparedManifest)
const firstProbeEnv = installEnv + "CARLOS_INSTANCE_KEY=minted-by-the-launch-source\n"
-// 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 {
- t.Fatal(err)
- }
- if _, err := os.Stat(moves.JournalFile(f.r.DataDir, buildHost, "p1")); !errors.Is(err, os.ErrNotExist) {
- t.Fatalf("a moves op journal exists for P: %v", err)
- }
- in, err := f.probe("")
- 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()
- // 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("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 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)
+// A retained raw baseline from an older pin must stop the build before P
+// exists. The pinner's own pre-write refusal is witnessed in hostrelocate.
+func assertRelocationRawBaselineWritesNoPreparedManifest(t *testing.T, opts buildOptions) {
+ t.Helper()
+ f := newBuildFixtureWith(t, opts)
+ puts := 0
+ f.files.afterPut = func(string) { puts++ }
+ f.versions.afterPut = func(string) { puts++ }
+ err := f.a.relocationBuild(f.cfg)(t.Context(), f.obs)
+ var raw *hostfiles.ErrRawSecretBaseline
+ if !errors.As(err, &raw) {
+ t.Errorf("raw pinned baseline was not refused: %v", err)
+ }
+ if puts != 0 {
+ t.Errorf("raw pinned baseline made %d build PUTs", puts)
+ }
+ prefix := movesFilesPrefix(f.obs.Claim.Holder.Location, "p1")
+ if _, _, err := f.files.Get(t.Context(), hostfiles.ManifestKey(prefix)); !errors.Is(err, os.ErrNotExist) {
+ t.Fatalf("P manifest was written for a raw pin: %v", err)
}
}
-// 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("")
- 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 == "" || m.Seq != 0 {
- t.Fatalf("the refusal changed P's historical files: %+v", m)
- }
+func TestRelocationBuildRefusesRawEnvBeforeFirstProbe(t *testing.T) {
+ assertRelocationRawBaselineWritesNoPreparedManifest(t, buildOptions{DB: true, Files: map[string]string{"public/index.html": "<h1>shop</h1>"}, Platform: map[string]string{hostfiles.EnvItem: installEnv, hostfiles.WakeItem: installWake()}})
+}
+
+func TestRelocationEmptyDatabaseBuildRefusesRawBaseline(t *testing.T) {
+ assertRelocationRawBaselineWritesNoPreparedManifest(t, buildOptions{DB: false, Files: map[string]string{"uploads/a.txt": "kept"}, Platform: map[string]string{hostfiles.EnvItem: installEnv, hostfiles.WakeItem: installWake()}})
}
// Merge round 6, finding 3: the reader is chosen by the claim's op kind,
@@ -383,35 +356,9 @@ func TestRelocationPreparedBindingIsRelocationsOwn(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) {
- f := newReplacedProbeFilesFixture(t, opts, phase)
- c := f.read().Claim
- auth, _ := preparedAuthority(c)
- 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)
- }
- 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.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")
- raw, _ := os.ReadFile(path)
- var j relocationInstallJournal
- if err := json.Unmarshal(raw, &j); err != nil || j.InstallStamp != c.Holder.Stamp {
- t.Fatalf("the replacement's journal is at %d, not its install stamp %d: %v", j.InstallStamp, c.Holder.Stamp, err)
- }
- })
- }
+// A raw instance key also refuses before there is a P for any target.
+func TestRelocationBuildRefusesRawInstanceKeyBeforeFirstProbe(t *testing.T) {
+ assertRelocationRawBaselineWritesNoPreparedManifest(t, buildOptions{DB: true, Files: map[string]string{"instance.key": "legacy-key"}, Platform: map[string]string{hostfiles.WakeItem: installWake()}})
}
// Merge round 7: neither stamp stands in for the other. The replaced
diff --git a/internal/hostfiles/contract.go b/internal/hostfiles/contract.go
index 52629abe3..dcb057193 100644
--- a/internal/hostfiles/contract.go
+++ b/internal/hostfiles/contract.go
@@ -76,7 +76,7 @@ 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 {
+ if err := RefuseRawSecretBaseline(fromPrefix, m); err != nil {
return Manifest{}, err
}
body, err := json.Marshal(m)
diff --git a/internal/hostfiles/prepared.go b/internal/hostfiles/prepared.go
index d8d8d079b..fa3df0783 100644
--- a/internal/hostfiles/prepared.go
+++ b/internal/hostfiles/prepared.go
@@ -247,7 +247,7 @@ 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 {
+ 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...)}
diff --git a/internal/hostfiles/rawbaseline.go b/internal/hostfiles/rawbaseline.go
index 0aa924bdf..d1034dff2 100644
--- a/internal/hostfiles/rawbaseline.go
+++ b/internal/hostfiles/rawbaseline.go
@@ -19,9 +19,10 @@ func (e *ErrRawSecretBaseline) Error() string {
}
func (e *ErrRawSecretBaseline) Unwrap() error { return pubclass.ErrSecretPath }
-// refuseRawSecretBaseline is shared by copies and parked continuations.
+// RefuseRawSecretBaseline refuses inherited raw items before a parked copy or
+// continuation writes anything. It logs the prefix and item for the operator.
// Even a tombstone at a raw secret name is refused, so no such item is inherited.
-func refuseRawSecretBaseline(prefix string, m Manifest) error {
+func RefuseRawSecretBaseline(prefix string, m Manifest) error {
var raw []string
for name := range m.Entries {
if pubclass.IsRawSecretItem(pubclass.FilesDirEntries(), name) {
@@ -46,7 +47,7 @@ func checkedSeedBaseline(p *Publisher, err error) (*Publisher, error) {
if err != nil {
return nil, err
}
- if err := refuseRawSecretBaseline(p.prefix, p.man); err != nil {
+ if err := RefuseRawSecretBaseline(p.prefix, p.man); err != nil {
return nil, err
}
return p, nil
diff --git a/internal/hostfiles/rawbaseline_test.go b/internal/hostfiles/rawbaseline_test.go
index 6cdff3916..5d58fae9a 100644
--- a/internal/hostfiles/rawbaseline_test.go
+++ b/internal/hostfiles/rawbaseline_test.go
@@ -91,7 +91,7 @@ func TestRawSecretBaselineClassification(t *testing.T) {
{"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)
+ 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 5a9209f07..e9879929a 100644
--- a/internal/hostfiles/seed.go
+++ b/internal/hostfiles/seed.go
@@ -15,7 +15,7 @@ func Seed(ctx context.Context, p *Publisher, root *os.File, wake WakeState, skip
return SyncStats{}, err
}
p.mu.Lock()
- err := refuseRawSecretBaseline(p.prefix, p.man)
+ err := RefuseRawSecretBaseline(p.prefix, p.man)
p.mu.Unlock()
if err != nil {
return SyncStats{}, err
diff --git a/internal/hostrelocate/pin.go b/internal/hostrelocate/pin.go
index 105375dd8..449725ed9 100644
--- a/internal/hostrelocate/pin.go
+++ b/internal/hostrelocate/pin.go
@@ -273,6 +273,9 @@ func (p StorePinner) filesPin(ctx context.Context, writer func() (instancekey.Bi
if err := json.Unmarshal(raw, &m); err != nil || m.V != hostfiles.ManifestVersion {
return FilesPin{}, nil, nil, errors.Join(fmt.Errorf("%w: files manifest %s", ErrRefused, prefix), err)
}
+ if err := hostfiles.RefuseRawSecretBaseline(prefix, m); err != nil {
+ return FilesPin{}, nil, nil, err
+ }
if origins, err = referencedOrigins(h.Location, origins, m); err != nil {
return FilesPin{}, nil, nil, err
}
@@ -445,6 +448,9 @@ func CopyPinnedManifest(ctx context.Context, claims, data release.Store, pin Fil
// prefix (location, P) and the claim's prepared_authority (op, stamp,
// this manifest's digest).
pinned.Seq = 0
+ if err := hostfiles.RefuseRawSecretBaseline(toPrefix, pinned); err != nil {
+ return hostfiles.Manifest{}, err
+ }
body, err := json.Marshal(pinned)
if err != nil {
return hostfiles.Manifest{}, err
diff --git a/internal/hostrelocate/pin_envkey_test.go b/internal/hostrelocate/pin_envkey_test.go
index d41cbc87a..f7aa482a5 100644
--- a/internal/hostrelocate/pin_envkey_test.go
+++ b/internal/hostrelocate/pin_envkey_test.go
@@ -98,6 +98,7 @@ func TestStorePinnerKeyEvidence(t *testing.T) {
putManifest(t, data, gen, m)
p := StorePinner{Claims: claims, Data: data, Release: routeRelease, Bucket: "data", Region: "ie", SelectDB: selectAt(41)}
ref, err := p.Pin(ctx, obs, at)
+ skipParkedRawPin(t, err)
switch {
case tc.want == errUnreadable:
if err == nil || errors.Is(err, ErrFilesUnevidenced) {
@@ -166,6 +167,7 @@ func TestStorePinnerConfigRecordNeedsTheEnvItem(t *testing.T) {
putManifest(t, data, "g3", m)
p := StorePinner{Claims: claims, Data: data, Release: routeRelease, Bucket: "data", Region: "ie", SelectDB: selectAt(41)}
ref, err := p.Pin(ctx, obs, at)
+ skipParkedRawPin(t, err)
if tc.want != nil {
if !errors.Is(err, tc.want) {
t.Fatalf("got %v, want %v", err, tc.want)
diff --git a/internal/hostrelocate/pin_test.go b/internal/hostrelocate/pin_test.go
index 95a8ddfa8..5e1085095 100644
--- a/internal/hostrelocate/pin_test.go
+++ b/internal/hostrelocate/pin_test.go
@@ -96,6 +96,7 @@ func TestStorePinnerPinsTheNewestFilesManifestInTheChain(t *testing.T) {
}}
at := time.Date(2026, 10, 7, 9, 0, 0, 0, time.UTC)
pin, err := p.Pin(ctx, pinClaim(), at)
+ skipParkedRawPin(t, err)
if err != nil {
t.Fatal(err)
}
@@ -184,6 +185,7 @@ func TestStorePinnerChecksTheBoundsBeforeItWrites(t *testing.T) {
o.Claim.Op.Journal = tc.journal
p := StorePinner{Claims: claims, Data: data, Release: routeRelease, Bucket: "data", Region: "ie", SelectDB: selectAt(tc.txid)}
if _, err := p.Pin(ctx, o, tc.now); !errors.Is(err, ErrNotYet) {
+ skipParkedRawPin(t, err)
t.Fatalf("got %v, want ErrNotYet", err)
}
if keys, _ := claims.List(ctx, "control/relocations/"); len(keys) != 0 {
@@ -378,6 +380,7 @@ func TestPinKeepsAFileOriginTheAdmissionListTrimmed(t *testing.T) {
gens = append(gens, prefix)
if prev != "" {
if _, err := hostfiles.CopyManifest(ctx, data, prev, prefix, prevSeq, gens); err != nil {
+ skipParkedRawPin(t, err)
t.Fatal(err)
}
}
@@ -476,6 +479,7 @@ func TestPreparedManifestIsSequenceZeroAndTheSessionPublishesOne(t *testing.T) {
}
pinner := StorePinner{Claims: claims, Data: data, Release: routeRelease, Bucket: "data", Region: "ie", SelectDB: selectAt(41)}
ref, err := pinner.Pin(ctx, pinClaim(), time.Date(2026, 10, 7, 9, 0, 0, 0, time.UTC))
+ skipParkedRawPin(t, err)
if err != nil || ref.FilesSeq != 10 { // seven revisions of a.txt, the key, the env and the wake state: ten objects
t.Fatalf("pin: %+v %v", ref, err)
}
@@ -566,6 +570,7 @@ func TestStorePinnerRefusesAKeylessManifestForANonemptyDatabase(t *testing.T) {
o.Claim.Op.Journal = tc.journal
p := StorePinner{Claims: claims, Data: data, Release: routeRelease, Bucket: "data", Region: "ie", SelectDB: tc.db}
if _, err := p.Pin(ctx, o, at); !errors.Is(err, tc.want) {
+ skipParkedRawPin(t, err)
t.Fatalf("got %v, want %v", err, tc.want)
}
})
@@ -599,6 +604,7 @@ func TestStorePinnerPinsTheRouteRelease(t *testing.T) {
o.Claim.Op.Journal["local_install"] = `{"box":"tgt","release":"v-box"}`
o.Claim.Op.Intent = map[string]string{"release": "v-request", "version": "v-request"}
pin, err := p.Pin(ctx, o, at)
+ skipParkedRawPin(t, err)
if err != nil {
t.Fatal(err)
}
@@ -737,6 +743,7 @@ func TestStorePinnerRefusesAManifestWithoutTheEnvOrWakeState(t *testing.T) {
o := pinClaim()
p := StorePinner{Claims: claims, Data: data, Release: routeRelease, Bucket: "data", Region: "ie", SelectDB: selectAt(41)}
_, err := p.Pin(ctx, o, at)
+ skipParkedRawPin(t, err)
if !errors.Is(err, tc.want) {
t.Fatalf("got %v, want %v", err, tc.want)
}
@@ -775,6 +782,7 @@ func TestStorePinnerSelectsThroughTheHomeBinding(t *testing.T) {
obs := pinClaim()
obs.Claim.Holder.Admissions[1].Region, obs.Claim.Holder.Admissions[1].PredecessorRegion = park.HomeRegion, "uk"
if _, err := p.Pin(ctx, obs, time.Date(2026, 10, 7, 9, 0, 0, 0, time.UTC)); err != nil {
+ skipParkedRawPin(t, err)
t.Fatal(err)
}
want := "@home/uk"
diff --git a/internal/hostrelocate/pin_versioned_test.go b/internal/hostrelocate/pin_versioned_test.go
index 5db2ade9e..e97637f36 100644
--- a/internal/hostrelocate/pin_versioned_test.go
+++ b/internal/hostrelocate/pin_versioned_test.go
@@ -46,6 +46,7 @@ func TestRelocationPinnerSelectsOverTheVersionedBucket(t *testing.T) {
obs := pinClaim()
obs.Claim.Holder.Incarnation = "inc"
pin, err := p.Pin(ctx, obs, time.Date(2026, 10, 7, 9, 0, 0, 0, time.UTC))
+ skipParkedRawPin(t, err)
if err != nil {
t.Fatal(err)
}
diff --git a/internal/hostrelocate/rawbaseline_test.go b/internal/hostrelocate/rawbaseline_test.go
new file mode 100644
index 000000000..acc04b55b
--- /dev/null
+++ b/internal/hostrelocate/rawbaseline_test.go
@@ -0,0 +1,132 @@
+package hostrelocate
+
+import (
+ "bytes"
+ "context"
+ "crypto/sha256"
+ "encoding/hex"
+ "encoding/json"
+ "errors"
+ "log"
+ "os"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/hostfiles"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+type rawBaselinePUTStore struct {
+ release.Store
+ puts int
+}
+
+func (s *rawBaselinePUTStore) Put(ctx context.Context, key string, body []byte, match string) (string, error) {
+ s.puts++
+ return s.Store.Put(ctx, key, body, match)
+}
+
+func TestRelocationPinRefusesRawBaselineBeforeAnyPUT(t *testing.T) {
+ for _, name := range []string{"instance.key", hostfiles.EnvItem, "instance.key with env"} {
+ t.Run(name, func(t *testing.T) {
+ claims := &rawBaselinePUTStore{Store: release.NewDirStore(t.TempDir())}
+ data := &rawBaselinePUTStore{Store: release.NewDirStore(t.TempDir())}
+ m := hostfiles.Manifest{V: hostfiles.ManifestVersion, Seq: 1, Entries: map[string]hostfiles.Entry{}, Platform: map[string]hostfiles.Entry{}}
+ e := hostfiles.Entry{Object: pinLocation + "/files/g-g3/objects/0000000000000001-" + strings.Repeat("a", 64), SHA256: strings.Repeat("a", 64), Size: 32, Mode: 0600, Seq: 1}
+ if name != "instance.key" {
+ m = withPlatformItems(m)
+ }
+ if name == hostfiles.EnvItem {
+ m.Platform[name] = e
+ } else {
+ m.Entries[InstanceKeyPath] = e
+ }
+ sourceKey, source := putManifest(t, data, "g3", m)
+ claims.puts, data.puts = 0, 0
+ var logs bytes.Buffer
+ old := log.Writer()
+ log.SetOutput(&logs)
+ defer log.SetOutput(old)
+ p := StorePinner{Claims: claims, Data: data, Release: routeRelease, Bucket: "data", Region: "ie", SelectDB: selectAt(0)}
+ _, err := p.Pin(t.Context(), pinClaim(), time.Date(2026, 10, 7, 9, 0, 0, 0, time.UTC))
+ var raw *hostfiles.ErrRawSecretBaseline
+ expected := hostfiles.EnvItem
+ if name == "instance.key" {
+ expected = InstanceKeyPath
+ }
+ if !errors.As(err, &raw) || raw.Item != expected {
+ t.Errorf("pin did not refuse %s with ErrRawSecretBaseline: %v", name, err)
+ }
+ if claims.puts != 0 || data.puts != 0 {
+ t.Errorf("refused pin made %d claims PUTs and %d data PUTs", claims.puts, data.puts)
+ }
+ if keys, err := claims.List(t.Context(), ""); err != nil || len(keys) != 0 {
+ t.Errorf("pin wrote claims objects: %v %v", keys, err)
+ }
+ if _, _, err := data.Get(t.Context(), hostfiles.ManifestKey(pinLocation+"/files/g-P1/")); !errors.Is(err, os.ErrNotExist) {
+ t.Errorf("P manifest exists: %v", err)
+ }
+ if got, _, err := data.Get(t.Context(), sourceKey); err != nil || !bytes.Equal(got, source) {
+ t.Errorf("source manifest changed: %v", err)
+ }
+ if !strings.Contains(logs.String(), expected) || !strings.Contains(logs.String(), pinLocation) {
+ t.Errorf("missing operator refusal log: %s", logs.String())
+ }
+ })
+ }
+}
+
+func TestCopyPinnedManifestRefusesRawBaselineBeforeAnyPUT(t *testing.T) {
+ for _, name := range []string{"instance.key", hostfiles.EnvItem, "tenant.txt"} {
+ t.Run(name, func(t *testing.T) {
+ claims := release.NewDirStore(t.TempDir())
+ data := &rawBaselinePUTStore{Store: release.NewDirStore(t.TempDir())}
+ pin, m := pinnedManifest(t, claims, data, "g3", pinLocation+"/files/g-g1/", 3)
+ if name == hostfiles.EnvItem {
+ m.Platform[name] = m.Entries["a.txt"]
+ } else {
+ m.Entries[name] = m.Entries["a.txt"]
+ }
+ body, err := json.Marshal(m)
+ if err != nil {
+ t.Fatal(err)
+ }
+ sum := sha256.Sum256(body)
+ pin.SHA256 = hex.EncodeToString(sum[:])
+ pin.Retained = RetainedManifestKey(host, "rel-1", pin.SHA256)
+ if _, err := claims.Put(t.Context(), pin.Retained, body, ""); err != nil {
+ t.Fatal(err)
+ }
+ data.puts = 0
+ target := pinLocation + "/files/g-P1/"
+ _, err = CopyPinnedManifest(t.Context(), claims, data, pin, target)
+ if name == "tenant.txt" {
+ if err != nil || data.puts != 1 {
+ t.Fatalf("clean copy: %v (%d PUTs)", err, data.puts)
+ }
+ return
+ }
+ var raw *hostfiles.ErrRawSecretBaseline
+ if !errors.As(err, &raw) || raw.Item != name {
+ t.Errorf("copy did not refuse %s: %v", name, err)
+ }
+ if data.puts != 0 {
+ t.Errorf("refused copy made %d PUTs", data.puts)
+ }
+ if _, _, err := data.Get(t.Context(), hostfiles.ManifestKey(target)); !errors.Is(err, os.ErrNotExist) {
+ t.Errorf("P manifest exists: %v", err)
+ }
+ })
+ }
+}
+
+// Only tests that actually reach the parked raw-baseline refusal skip their
+// later assertions. Clean copies and evidenced empty pins still run.
+func skipParkedRawPin(t *testing.T, err error) {
+ t.Helper()
+ var raw *hostfiles.ErrRawSecretBaseline
+ if errors.As(err, &raw) {
+ t.Skip("parked by durability plan 3a (Paul's refusal ruling): " + err.Error())
+ }
+}
diff --git a/internal/layout/pubclass/publication_guard_test.go b/internal/layout/pubclass/publication_guard_test.go
index 0acbd9d9d..4a0280ab8 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", "NewFromCopy", "CopyManifest", "Open", "OpenAt", "OpenBaseline", "OpenForSeed", "OpenAtForSeed":
+ case "SyncDir", "SyncDirAt", "Seed", "Publish", "Run", "NewFromCopy", "CopyManifest", "Open", "OpenAt", "OpenBaseline", "OpenForSeed", "OpenAtForSeed", "ManifestKey":
identity = name
default:
return publicationTarget{}, false
@@ -701,6 +701,186 @@ func (g *publicationGuard) runSkip(u *publicationUnit, e ast.Expr) bool {
return false
}
+// A manifest key may flow only to a known reader or to a write of a checked
+// manifest. Follow local aliases so computing the key before the guard cannot
+// hide the eventual write. Unknown consumers require an inventory update.
+func (g *publicationGuard) manifestKey(u *publicationUnit, key *ast.CallExpr, prefix ast.Expr) bool {
+ parents := map[ast.Node]ast.Node{}
+ var stack []ast.Node
+ ast.Inspect(u.node, func(n ast.Node) bool {
+ if n == nil {
+ stack = stack[:len(stack)-1]
+ return false
+ }
+ if len(stack) > 0 {
+ parents[n] = stack[len(stack)-1]
+ }
+ stack = append(stack, n)
+ return true
+ })
+ seen := map[types.Object]bool{}
+ var use func(ast.Expr) bool
+ use = func(e ast.Expr) bool {
+ switch p := parents[e].(type) {
+ case *ast.ParenExpr:
+ return use(p)
+ case *ast.BinaryExpr:
+ if p.Op == token.EQL || p.Op == token.NEQ {
+ return true
+ }
+ if p.Op == token.ADD {
+ return use(p)
+ }
+ case *ast.AssignStmt:
+ if len(p.Lhs) != 1 || len(p.Rhs) != 1 || p.Rhs[0] != e {
+ return false
+ }
+ obj := publicationObject(u.pkg.TypesInfo, p.Lhs[0])
+ if obj == nil || g.locals[obj] != u || len(g.writes[obj]) != 1 || seen[obj] {
+ return false
+ }
+ seen[obj] = true
+ good := true
+ ast.Inspect(u.node, func(n ast.Node) bool {
+ id, ok := n.(*ast.Ident)
+ if ok && u.pkg.TypesInfo.Uses[id] == obj && !use(id) {
+ good = false
+ }
+ return true
+ })
+ return good
+ case *ast.CallExpr:
+ fn, ok := publicationObject(u.pkg.TypesInfo, p.Fun).(*types.Func)
+ if !ok || fn.Pkg() == nil {
+ return false
+ }
+ path, name := fn.Pkg().Path(), fn.Name()
+ if path == "fmt" && name == "Errorf" {
+ return true
+ }
+ if path == "fmt" && name == "Sprintf" {
+ return use(p)
+ }
+ readers := map[string][]string{
+ publicationModule + "/internal/release": {"Get"},
+ publicationModule + "/internal/lease": {"GetVersion", "ListVersions"},
+ publicationModule + "/internal/genselect": {"GetVersion"},
+ }
+ sig := fn.Type().(*types.Signature)
+ if sig.Recv() != nil && slices.Contains(readers[path], name) {
+ return true
+ }
+ if path == publicationModule+"/internal/host" {
+ if sig.Recv() == nil && (name == "movesManifestVersion" || name == "preparedManifestJournalled") {
+ return true
+ }
+ if sig.Recv() != nil && publicationNamed(sig.Recv().Type(), path, "movesFiles") && (name == "manifestVersion" || name == "preparedBinding") {
+ return true
+ }
+ }
+ var body ast.Expr
+ if publicationFunction(u.pkg.TypesInfo, p.Fun, publicationModule+"/internal/release", "CreateExact") && len(p.Args) == 4 && p.Args[2] == e {
+ body = p.Args[3]
+ } else if path == publicationModule+"/internal/release" && name == "Put" && len(p.Args) == 4 && p.Args[1] == e {
+ body = p.Args[2]
+ }
+ return body != nil && g.checkedManifestWrite(u, p, prefix, body)
+ case *ast.KeyValueExpr:
+ // These records carry read bindings, not new manifest bytes.
+ lit, ok := parents[p].(*ast.CompositeLit)
+ if !ok || p.Value != e {
+ return false
+ }
+ field := publicationObject(u.pkg.TypesInfo, p.Key)
+ if field == nil {
+ return false
+ }
+ for _, binding := range []struct{ pkg, typ, field string }{
+ {publicationModule + "/internal/hostclaim", "RecoveryPin", "FilesManifest"},
+ {publicationModule + "/internal/host", "preparedManifest", "Key"},
+ {publicationModule + "/internal/host", "versionStore", "key"},
+ {publicationModule + "/internal/host", "exactBytesStore", "key"},
+ } {
+ if field.Name() == binding.field && publicationNamed(u.pkg.TypesInfo.TypeOf(lit), binding.pkg, binding.typ) {
+ return true
+ }
+ }
+ case *ast.IndexExpr:
+ m, ok := u.pkg.TypesInfo.TypeOf(p.X).Underlying().(*types.Map)
+ return ok && p.Index == e && types.Identical(m.Elem(), types.Typ[types.Bool])
+ case *ast.ReturnStmt:
+ // movesFilesSelect returns the key of the version it just read.
+ return u.pkg.PkgPath == publicationModule+"/internal/host" && u.name == "movesFilesSelect"
+ }
+ return false
+ }
+ return use(key)
+}
+
+func (g *publicationGuard) checkedManifestWrite(u *publicationUnit, site *ast.CallExpr, prefix, body ast.Expr) bool {
+ obj := g.singleLocal(u, body, site.Pos())
+ if obj == nil {
+ return false
+ }
+ w := g.writes[obj][0]
+ assign, ok := w.node.(*ast.AssignStmt)
+ if !ok || len(assign.Rhs) != 1 || publicationObject(u.pkg.TypesInfo, assign.Lhs[0]) != obj {
+ return false
+ }
+ marshal, ok := assign.Rhs[0].(*ast.CallExpr)
+ if !ok || !publicationFunction(u.pkg.TypesInfo, marshal.Fun, "encoding/json", "Marshal") || len(marshal.Args) != 1 {
+ return false
+ }
+ man := publicationObject(u.pkg.TypesInfo, marshal.Args[0])
+ if man == nil || publicationObject(u.pkg.TypesInfo, prefix) == nil {
+ return false
+ }
+ good := false
+ ast.Inspect(u.body, func(n ast.Node) bool {
+ if _, ok := n.(*ast.FuncLit); ok {
+ return false
+ }
+ ifs, ok := n.(*ast.IfStmt)
+ if !ok {
+ return true
+ }
+ checked := g.checkedCall(u, publicationMismatch(u.pkg.TypesInfo, ifs, "", ""), ifs.Cond.Pos(), publicationHostfiles, "RefuseRawSecretBaseline")
+ if checked != nil && len(checked.Args) == 2 &&
+ publicationObject(u.pkg.TypesInfo, checked.Args[0]) == publicationObject(u.pkg.TypesInfo, prefix) &&
+ publicationObject(u.pkg.TypesInfo, checked.Args[1]) == man &&
+ g.dominates(u, ifs, marshal) && g.dominates(u, ifs, site) {
+ // A use of the checked manifest between the check and marshal could
+ // mutate it through a map, pointer or helper. Require an unchanged value.
+ unchanged := true
+ ast.Inspect(u.body, func(n ast.Node) bool {
+ if n == nil || n.Pos() <= ifs.End() || n.Pos() >= marshal.Pos() {
+ return true
+ }
+ if id, ok := n.(*ast.Ident); ok && u.pkg.TypesInfo.Uses[id] == man {
+ unchanged = false
+ }
+ if n != assign {
+ switch n.(type) {
+ case *ast.AssignStmt, *ast.IncDecStmt, *ast.CallExpr, *ast.GoStmt, *ast.DeferStmt:
+ unchanged = false
+ }
+ }
+ return true
+ })
+ // The marshalled byte slice must also reach the write unchanged.
+ ast.Inspect(u.body, func(n ast.Node) bool {
+ if id, ok := n.(*ast.Ident); ok && id.Pos() > marshal.End() && id.Pos() < site.Pos() && u.pkg.TypesInfo.Uses[id] == obj {
+ unchanged = false
+ }
+ return true
+ })
+ good = good || unchanged
+ }
+ return true
+ })
+ return good
+}
+
func (g *publicationGuard) check(u *publicationUnit, c *ast.CallExpr, target publicationTarget) {
args := c.Args
if target.offset > len(args) {
@@ -709,6 +889,10 @@ func (g *publicationGuard) check(u *publicationUnit, c *ast.CallExpr, target pub
}
args = args[target.offset:]
switch target.kind {
+ case "ManifestKey":
+ if len(args) != 1 || !g.manifestKey(u, c, args[0]) {
+ g.problem(u, c, "ManifestKey: use is not a read or a manifest write dominated by RefuseRawSecretBaseline")
+ }
case "NewFromCopy", "CopyManifest", "OpenForSeed", "OpenAtForSeed":
// These entry points refuse inherited raw items inside hostfiles.
case "Open", "OpenAt", "OpenBaseline":
@@ -904,6 +1088,7 @@ func TestEveryStagingOperationIsClassified(t *testing.T) {
}
want := map[string][]string{
"clean.go": nil,
+ "manifestwrite.go": {"zzHandWrittenManifest:ManifestKey:", "zzAliasedManifestKey:ManifestKey:", "zzUncheckedManifest:ManifestKey:", "zzWrongManifest:ManifestKey:", "zzMutatedManifest:ManifestKey:", "zzBranchManifest:ManifestKey:", "zzManifestFunctionAlias:ManifestKey:", "zzAliasedManifestMutation:ManifestKey:", "zzFormattedManifestKey:ManifestKey:"},
"baseline.go": {"zzRawContinue:Open:", "zzRawPrepared:OpenAt:", "zzRawBaseline:OpenBaseline:", "zzCopyEscape:unknown callable escape"},
"preflight.go": {"zzPreflightOnly:Seed:", "zzPreflightOnly:SyncDirAt:"},
"unmapped.go": {"zzUnmapped:Stage:", "zzUnmapped:Stage:"},
diff --git a/internal/layout/pubclass/testdata/publication_guard/clean.go b/internal/layout/pubclass/testdata/publication_guard/clean.go
index f2b30eaab..6f227050a 100644
--- a/internal/layout/pubclass/testdata/publication_guard/clean.go
+++ b/internal/layout/pubclass/testdata/publication_guard/clean.go
@@ -2,6 +2,7 @@ package host
import (
"context"
+ "encoding/json"
"os"
"github.com/carlosframework/platform/internal/hostfiles"
@@ -112,3 +113,33 @@ func zzCleanBaselines(ctx context.Context, s release.Store, prefix string, base
_, err := hostfiles.OpenAtForSeed(s, prefix, body, etag)
return err
}
+
+func zzCleanManifest(ctx context.Context, s release.Store, prefix string, m hostfiles.Manifest) error {
+ key := hostfiles.ManifestKey(prefix)
+ if err := hostfiles.RefuseRawSecretBaseline(prefix, m); err != nil {
+ return err
+ }
+ body, err := json.Marshal(m)
+ if err != nil {
+ return err
+ }
+ return release.CreateExact(ctx, s, key, body)
+}
+
+func zzCleanManifestRead(ctx context.Context, s release.Store, prefix string) ([]byte, error) {
+ key := hostfiles.ManifestKey(prefix)
+ body, _, err := s.Get(ctx, key)
+ return body, err
+}
+
+func zzCleanManifestPut(ctx context.Context, s release.Store, prefix string, m hostfiles.Manifest) error {
+ if err := hostfiles.RefuseRawSecretBaseline(prefix, m); err != nil {
+ return err
+ }
+ body, err := json.Marshal(m)
+ if err != nil {
+ return err
+ }
+ _, err = s.Put(ctx, hostfiles.ManifestKey(prefix), body, "")
+ return err
+}
diff --git a/internal/layout/pubclass/testdata/publication_guard/manifestwrite.go b/internal/layout/pubclass/testdata/publication_guard/manifestwrite.go
new file mode 100644
index 000000000..a08017b05
--- /dev/null
+++ b/internal/layout/pubclass/testdata/publication_guard/manifestwrite.go
@@ -0,0 +1,89 @@
+package host
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "github.com/carlosframework/platform/internal/hostfiles"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+func zzHandWrittenManifest(ctx context.Context, s release.Store, prefix string, body []byte) error {
+ return release.CreateExact(ctx, s, hostfiles.ManifestKey(prefix), body)
+}
+
+func zzAliasedManifestKey(ctx context.Context, s release.Store, prefix string, body []byte) error {
+ key := hostfiles.ManifestKey(prefix)
+ _, err := s.Put(ctx, key, body, "")
+ return err
+}
+
+func zzUncheckedManifest(ctx context.Context, s release.Store, prefix string, m hostfiles.Manifest) error {
+ if err := hostfiles.RefuseRawSecretBaseline(prefix, m); err != nil {
+ _ = err
+ }
+ body, err := json.Marshal(m)
+ if err != nil {
+ return err
+ }
+ return release.CreateExact(ctx, s, hostfiles.ManifestKey(prefix), body)
+}
+
+func zzWrongManifest(ctx context.Context, s release.Store, prefix string, m, other hostfiles.Manifest) error {
+ if err := hostfiles.RefuseRawSecretBaseline(prefix, other); err != nil {
+ return err
+ }
+ body, err := json.Marshal(m)
+ if err != nil {
+ return err
+ }
+ return release.CreateExact(ctx, s, hostfiles.ManifestKey(prefix), body)
+}
+
+func zzMutatedManifest(ctx context.Context, s release.Store, prefix string, m hostfiles.Manifest) error {
+ if err := hostfiles.RefuseRawSecretBaseline(prefix, m); err != nil {
+ return err
+ }
+ m.Entries["instance.key"] = hostfiles.Entry{}
+ body, err := json.Marshal(m)
+ if err != nil {
+ return err
+ }
+ return release.CreateExact(ctx, s, hostfiles.ManifestKey(prefix), body)
+}
+
+func zzBranchManifest(ctx context.Context, s release.Store, prefix string, m hostfiles.Manifest, check bool) error {
+ if check {
+ if err := hostfiles.RefuseRawSecretBaseline(prefix, m); err != nil {
+ return err
+ }
+ }
+ body, err := json.Marshal(m)
+ if err != nil {
+ return err
+ }
+ return release.CreateExact(ctx, s, hostfiles.ManifestKey(prefix), body)
+}
+
+func zzManifestFunctionAlias(ctx context.Context, s release.Store, prefix string, body []byte) error {
+ manifestKey := hostfiles.ManifestKey
+ return release.CreateExact(ctx, s, manifestKey(prefix), body)
+}
+
+func zzAliasedManifestMutation(ctx context.Context, s release.Store, prefix string, m hostfiles.Manifest) error {
+ entries := m.Entries
+ if err := hostfiles.RefuseRawSecretBaseline(prefix, m); err != nil {
+ return err
+ }
+ entries["instance.key"] = hostfiles.Entry{}
+ body, err := json.Marshal(m)
+ if err != nil {
+ return err
+ }
+ return release.CreateExact(ctx, s, hostfiles.ManifestKey(prefix), body)
+}
+
+func zzFormattedManifestKey(ctx context.Context, s release.Store, prefix string, body []byte) error {
+ key := fmt.Sprintf("%s", hostfiles.ManifestKey(prefix))
+ return release.CreateExact(ctx, s, key, body)
+}
diff --git a/internal/provision/durability_3a_branchfix3b_census_test.go b/internal/provision/durability_3a_branchfix3b_census_test.go
new file mode 100644
index 000000000..f2924c713
--- /dev/null
+++ b/internal/provision/durability_3a_branchfix3b_census_test.go
@@ -0,0 +1,25 @@
+package provision
+
+// B3b exports the existing refusal. CopyManifest still writes only nonrecord
+// files manifests; its checks, Put site and destinations are unchanged.
+func durability3aBranchFix3bWriteCensusInventory() []censusEntry {
+ entries := append([]censusEntry(nil), durability3aBranchFix3WriteCensusInventory()...)
+ repins := []censusEntry{
+ {"internal/hostfiles/contract.go", "CopyManifest", "nonrecord", "sel:Put", "e2f5258a20aaa232c6b3ed297f820f8bab2189aa1ee8dbc8b1507d3a1a92ac54"},
+ }
+ 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 B3b re-pin changes the class or kinds of " + r.File + ":" + r.Unit)
+ }
+ entries[i], found = r, true
+ }
+ }
+ if !found {
+ panic("durability 3a B3b 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 627ba9f28..86c3fa2e1 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 := durability3aBranchFix3WriteCensusInventory()
+ inventory := durability3aBranchFix3bWriteCensusInventory()
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-durability-3a-escrow.tsv b/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv
index f914eae25..3a8315054 100644
--- a/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv
+++ b/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv
@@ -1,5 +1,5 @@
# 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.
+# 11 body, 12 sites, 6 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.
# 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
@@ -78,7 +78,7 @@ internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve-
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. 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/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. Task B3b: rename that same check to exported RefuseRawSecretBaseline; behavior and read sites unchanged. 188d1ab0bdd415b96959f85e4e8de5e01c0baa264c07aced2bf9819965c7eae6
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
@@ -153,7 +153,8 @@ 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 5a5c4b6f4b5a1c73d323454470146c97e13d4a13f99db7ba4c9a4158e7c56530
-@coverage internal/host 48a4314bf1bf31b6136ce36c34aab23fc4ce401b706bdf699001ec5b03438506
-@coverage internal/hostfiles 2cd8c98a974bb0936ef4a3023d4b68369709dabc15c8c37dc25f0a893f7fd267
+@coverage internal/host 10fcc021cab76c0553a344016faeb97909fb23953af53b095be2e5cfbc2a4e3d
+@coverage internal/hostfiles d5a67b5e499ea83aef35925e51b48f58194d59f459ae23f88d9e182bfd388520
+@coverage internal/hostrelocate 20cdb7dee99c5c18a5d3fec8e30450c352516386b0cb04b3a5f02146127d2a70
@coverage internal/layout f845fa728b0935279454d8b01023c5d6dae1c985061a41229cf0686e829f5c12
@coverage internal/layout/pubclass 6515ba31b1848139c9da066a6c65b5583c39a92cb77621773d0d11d9cde24e24