carlos / platform Public

fix(hostfiles): require refresh after uncertain manifest commits

Fence staging and commits after uncertain manifest writes until storage is read again. Revalidate HA and non-HA escrow candidates against that baseline, preserve terminal supersession, and retry snapshots whose app stages were discarded by a refresh.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 9d7ad2cd19d3967db6a2b942fbb1410aa1b46971 parent de8a9e4
14 files changed, +450 −54
  • docs/superpowers/notes/census-durability-3a-escrow-claims.md +2 −1
  • docs/superpowers/notes/census-proposal-durability-3a-escrow.md +3 −2
  • internal/activator/escrow.go +7 −0
  • internal/activator/haescrow_branchfix_test.go +170 −0
  • internal/activator/hafiles.go +38 −1
  • internal/hostfiles/hostfiles_test.go +29 −8
  • internal/hostfiles/platform.go +3 −0
  • internal/hostfiles/publisher.go +65 −35
  • internal/hostfiles/publisher_refresh_test.go +99 −0
  • internal/hostfiles/sealed.go +6 −0
  • internal/provision/durability_3a_branchfix2b_census_test.go +19 −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 +7 −5

Intent

Human

<task-notification> <task-id>bf9buno4z</task-id> <tool-use-id>toolu_01BkjGCfWaQA2jKe1DX3eNGL</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/aab63774-dfe6-44a4-9cd9-230e6f4c3d13/tasks/bf9buno4z.output</output-file> <status>completed</status> <summary>Background command "Run branch fix round 2 on Astra" 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 fd868bc7d..38d25d676 100644
--- a/docs/superpowers/notes/census-durability-3a-escrow-claims.md
+++ b/docs/superpowers/notes/census-durability-3a-escrow-claims.md
@@ -80,4 +80,5 @@ internal/host/claimfilesseed_stage.go:filesSeedOperation.stage Durability 3a Tas
# Task B2, Paul 2026-11-01: cut hostname-lifetime binding.
# 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.
+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.
diff --git a/docs/superpowers/notes/census-proposal-durability-3a-escrow.md b/docs/superpowers/notes/census-proposal-durability-3a-escrow.md
index dde809d5f..593cc48ed 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, 46 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, 47 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
| unit | change | read sites | what changed |
|---|---|---|---|
@@ -113,11 +113,12 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/host/escrow_loop.go:escrowLoop`: reads +whole:Route; written legacy, accepted-legacy, frozen
- 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/sealed.go:ReadSealed`: reads +file:Open; written legacy, accepted-legacy, frozen
- new `internal/layout/inventory.go:Inventory`: reads +file:ReadDir; written legacy, accepted-legacy, frozen
- quiet `internal/layout/plan.go:NestedPlatformNames`: reads nothing now; retired while it reads nothing (or its row keeps no sites)
- reads `internal/host/movesfiles.go:buildPrepared`: +file:Open, -file:ReadFile, +file:Stat; keeps legacy, task accepted-legacy
-Seal: `67b54b219f990c3dcfe32c6ffb11a80a4ca3898aec060fe9f4450e21098af714` → `697737b989cfc1d9b082f534265f01c533d446c1fe345782bc696219e0d71156`.
+Seal: `67b54b219f990c3dcfe32c6ffb11a80a4ca3898aec060fe9f4450e21098af714` → `18f1c7991164d28cf0b16b0aa2fb2569570acf1a9a0465ddda04f8f9240320a9`.
Overlay: `internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/activator/escrow.go b/internal/activator/escrow.go
index 2ec5dcb1a..4820b5437 100644
--- a/internal/activator/escrow.go
+++ b/internal/activator/escrow.go
@@ -853,6 +853,13 @@ func (b *ExecBackend) stageEscrowReads(ctx context.Context, rt registry.Route, p
if err := b.escrowConflict(rt.Host); err != nil {
return err
}
+ // Both retained HA publishers and non-HA publishers must judge the
+ // manifest that actually landed, never an uncertain commit's old baseline.
+ if pub.RefreshRequired() != nil {
+ if err := pub.Refresh(ctx); err != nil {
+ return fmt.Errorf("%w: refresh publisher: %w", errEscrowUnreadable, err)
+ }
+ }
m, err := baselineManifest(pub.Baseline())
if err != nil {
return fmt.Errorf("%w: %w", errEscrowUnreadable, err)
diff --git a/internal/activator/haescrow_branchfix_test.go b/internal/activator/haescrow_branchfix_test.go
index 4bf3c8a57..f1adc13c6 100644
--- a/internal/activator/haescrow_branchfix_test.go
+++ b/internal/activator/haescrow_branchfix_test.go
@@ -3,6 +3,8 @@ package activator
import (
"bytes"
"context"
+ "errors"
+ "os"
"strings"
"testing"
@@ -167,3 +169,171 @@ func TestHAEscrowReadFailureCanRetryOrdinaryEnvEdit(t *testing.T) {
t.Fatalf("ordinary env edit did not publish: %q", got)
}
}
+
+// The first trio item lands, but its manifest PUT reply is lost. Every HA
+// publication path must re-read that commit before judging the next value.
+func TestHALostReplyRechecksWriteOnce(t *testing.T) {
+ for _, pass := range []string{"platform", "snapshot", "final", "launch"} {
+ for _, item := range []string{"instance.key", "report.token"} {
+ t.Run(pass+"/"+item, func(t *testing.T) {
+ ctx := context.Background()
+ b, rt := haLaunchBackend(t, escrowHost)
+ store := &escrowLostReply{Store: b.FilesStore, manifest: hostfiles.ManifestKey(b.filesPrefix(rt.Host))}
+ b.FilesStore = store
+ writeEnv(t, b, rt, envA)
+ f, err := b.openHostFiles(ctx, rt)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := f.PublishPlatformNow(ctx); err != nil {
+ t.Fatal(err)
+ }
+ b.haWakes.setFiles(rt.Host, f)
+ writeFiles(t, b, rt, map[string]string{item: "first-value"})
+ store.lose = true
+ if err := f.PublishPlatformNow(ctx); err == nil || !strings.Contains(err.Error(), "response lost") {
+ t.Fatalf("first trio PUT: %v", err)
+ }
+ if got := sealedItem(t, b, rt, item+".sealed"); got != "first-value" {
+ t.Fatalf("first commit did not land: %q", got)
+ }
+ writeFiles(t, b, rt, map[string]string{item: "changed"})
+ switch pass {
+ case "platform":
+ err = f.PublishPlatformNow(ctx)
+ case "snapshot":
+ err = f.publishSnapshot(ctx)
+ case "final":
+ _, _, err = f.Final(ctx)
+ case "launch":
+ err = b.launchForTest(rt)
+ }
+ if err == nil || !strings.Contains(err.Error(), "ALERT: ") || !exists(escrowConflictPath(b.DataDir, rt.Host)) {
+ t.Errorf("retry must refuse with alert and marker: %v", err)
+ }
+ if got := sealedItem(t, b, rt, item+".sealed"); got != "first-value" {
+ t.Errorf("escrow = %q, want first-value", got)
+ }
+ })
+ }
+ }
+}
+
+// A platform retry may refresh while a snapshot walks without f.mu. App
+// stages discarded by that refresh must not earn a completed tree digest.
+func TestHASnapshotRefreshRestagesWholeTree(t *testing.T) {
+ ctx := context.Background()
+ b, rt := haLaunchBackend(t, escrowHost)
+ store := &escrowRecoveryReadFailure{Store: b.FilesStore, manifest: hostfiles.ManifestKey(b.filesPrefix(rt.Host))}
+ b.FilesStore = store
+ writeEnv(t, b, rt, envA)
+ writeFiles(t, b, rt, map[string]string{"a.txt": "a", "b.txt": "b"})
+ f, err := b.openHostFiles(ctx, rt)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := f.PublishPlatformNow(ctx); err != nil {
+ t.Fatal(err)
+ }
+ previous := syncFilesAt
+ t.Cleanup(func() { syncFilesAt = previous })
+ first := true
+ syncFilesAt = func(ctx context.Context, p *hostfiles.Publisher, dir *os.File, skip func(string, bool) bool) (hostfiles.SyncStats, error) {
+ if !first {
+ return previous(ctx, p, dir, skip)
+ }
+ first = false
+ if err := p.Stage(ctx, "a.txt", []byte("a"), 0o600, false); err != nil {
+ t.Fatal(err)
+ }
+ store.armed = true
+ if err := f.PublishPlatformNow(ctx); err == nil {
+ t.Fatal("manifest failure not reached")
+ }
+ store.armed, store.recovery = false, false
+ if err := f.PublishPlatformNow(ctx); err != nil {
+ t.Fatal(err)
+ }
+ return hostfiles.SyncStats{}, p.Stage(ctx, "b.txt", []byte("b"), 0o600, false)
+ }
+ if err := f.publishSnapshot(ctx); err == nil || f.lastDigest != "" {
+ t.Fatalf("discarded app stage earned a completed snapshot: %v", err)
+ }
+ if err := f.publishSnapshot(ctx); err != nil {
+ t.Fatal(err)
+ }
+ m := loadManifest(t, b, rt)
+ for _, path := range []string{"a.txt", "b.txt"} {
+ if m.Entries[path].Object == "" {
+ t.Errorf("retry omitted %s", path)
+ }
+ }
+}
+
+func TestHALostReplyRefreshFailureCanRetryOrdinaryEnvEdit(t *testing.T) {
+ ctx := context.Background()
+ b, rt := haLaunchBackend(t, escrowHost)
+ lost := &escrowLostReply{Store: b.FilesStore, manifest: hostfiles.ManifestKey(b.filesPrefix(rt.Host))}
+ store := &escrowRecoveryReadFailure{Store: lost, manifest: lost.manifest}
+ b.FilesStore = store
+ writeEnv(t, b, rt, envA)
+ f, err := b.openHostFiles(ctx, rt)
+ if err != nil {
+ t.Fatal(err)
+ }
+ lost.lose = true
+ if err := f.PublishPlatformNow(ctx); err == nil {
+ t.Fatal("lost reply not reached")
+ }
+ writeEnv(t, b, rt, envB)
+ store.recovery = true
+ if err := f.PublishPlatformNow(ctx); !errors.Is(err, errEscrowUnreadable) {
+ t.Fatalf("failed refresh must refuse: %v", err)
+ }
+ if exists(escrowConflictPath(b.DataDir, rt.Host)) {
+ t.Fatal("failed GET created a conflict marker")
+ }
+ store.recovery = false
+ if got := sealedItem(t, b, rt, hostfiles.SealedEnvItem); got != envA {
+ t.Fatalf("failed refresh changed escrow: %q", got)
+ }
+ if err := f.PublishPlatformNow(ctx); err != nil {
+ t.Fatalf("retry after refresh: %v", err)
+ }
+ if got := sealedItem(t, b, rt, hostfiles.SealedEnvItem); got != envB {
+ t.Fatalf("ordinary edit not published: %q", got)
+ }
+}
+
+func TestHASupersededPublisherStillRefusesFinal(t *testing.T) {
+ ctx := context.Background()
+ b, rt := haLaunchBackend(t, escrowHost)
+ writeEnv(t, b, rt, envA)
+ f, err := b.openHostFiles(ctx, rt)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := f.PublishPlatformNow(ctx); err != nil {
+ t.Fatal(err)
+ }
+ other, err := hostfiles.Open(ctx, b.FilesStore, b.filesPrefix(rt.Host))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := other.StagePlatform(ctx, "other-writer", []byte("winner")); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := other.Commit(ctx); err != nil {
+ t.Fatal(err)
+ }
+ writeEnv(t, b, rt, envB)
+ if err := f.PublishPlatformNow(ctx); !errors.Is(err, hostfiles.ErrSuperseded) {
+ t.Fatalf("supersession not reached: %v", err)
+ }
+ if _, complete, err := f.Final(ctx); complete || !errors.Is(err, hostfiles.ErrSuperseded) {
+ t.Fatalf("superseded Final must stay refused: complete=%v err=%v", complete, err)
+ }
+ if got := sealedItem(t, b, rt, hostfiles.SealedEnvItem); got != envA {
+ t.Fatalf("superseded Final replaced winner's env: %q", got)
+ }
+}
diff --git a/internal/activator/hafiles.go b/internal/activator/hafiles.go
index c03d63ca5..34509629a 100644
--- a/internal/activator/hafiles.go
+++ b/internal/activator/hafiles.go
@@ -170,6 +170,7 @@ type hostFiles struct {
snapMu sync.Mutex
mu sync.Mutex
lastDigest string // the tree digest of the last complete, committed full publish
+ refreshes uint64 // detects stages discarded while a snapshot walked without mu
final bool // Final has run: no pass publishes again
}
@@ -424,7 +425,15 @@ func (f *hostFiles) publishSnapshot(ctx context.Context) error {
f.snapMu.Lock()
defer f.snapMu.Unlock()
f.mu.Lock()
- final, last := f.final, f.lastDigest
+ // Refresh before the tree walk: refreshing after it would discard app
+ // stages while incorrectly marking the snapshot complete.
+ if !f.final {
+ if err := f.refreshLocked(ctx); err != nil {
+ f.mu.Unlock()
+ return err
+ }
+ }
+ final, last, refreshes := f.final, f.lastDigest, f.refreshes
f.mu.Unlock()
if final {
return errFilesFinal
@@ -442,6 +451,14 @@ func (f *hostFiles) publishSnapshot(ctx context.Context) error {
if f.final {
return errFilesFinal
}
+ // A platform commit can fail while the tree is walking. Retry the whole
+ // snapshot on the next pass, rather than refresh away its app stages.
+ if err := f.pub.RefreshRequired(); err != nil {
+ return err
+ }
+ if f.refreshes != refreshes {
+ return errors.New("files publisher refreshed during the snapshot; retry the whole tree")
+ }
if err := f.stageItemsLocked(ctx); err != nil {
return err
}
@@ -471,6 +488,9 @@ func (f *hostFiles) Final(ctx context.Context) (gen string, complete bool, err e
f.mu.Lock()
defer f.mu.Unlock()
f.final = true
+ if err := f.refreshLocked(ctx); err != nil {
+ return f.pub.Gen(), false, err
+ }
st, present, err := f.syncFiles(ctx)
if err != nil {
return f.pub.Gen(), false, err
@@ -493,6 +513,20 @@ func (f *hostFiles) Final(ctx context.Context) (gen string, complete bool, err e
return f.pub.Gen(), complete, nil
}
+// refreshLocked drops the cached tree digest with uncertain stages. The
+// shared escrow gate will validate the local trio against the fresh baseline.
+func (f *hostFiles) refreshLocked(ctx context.Context) error {
+ if f.pub.RefreshRequired() == nil {
+ return nil
+ }
+ f.lastDigest = ""
+ if err := f.pub.Refresh(ctx); err != nil {
+ return fmt.Errorf("%w: refresh files publisher: %w", errEscrowUnreadable, err)
+ }
+ f.refreshes++
+ return nil
+}
+
// baseline is the manifest the publisher last committed, as the release
// keeps it beside its local record (writeFilesBaseline).
func (f *hostFiles) baseline() hostfiles.Baseline { return f.pub.Baseline() }
@@ -524,6 +558,9 @@ func (f *hostFiles) syncFiles(ctx context.Context) (hostfiles.SyncStats, bool, e
// item and the raw trio entries, in the manifest only), then the wake
// state from the registry. f.mu is held.
func (f *hostFiles) stageItemsLocked(ctx context.Context) error {
+ if err := f.refreshLocked(ctx); err != nil {
+ return err
+ }
// The held baseline first: once the pass stages, DropRawSecrets has
// removed what the detector looks for.
if f.noteHeld != nil {
diff --git a/internal/hostfiles/hostfiles_test.go b/internal/hostfiles/hostfiles_test.go
index e9623a0c6..5470e0915 100644
--- a/internal/hostfiles/hostfiles_test.go
+++ b/internal/hostfiles/hostfiles_test.go
@@ -528,6 +528,9 @@ func TestALostCommitResponseIsNotASupersede(t *testing.T) {
if _, err := p.Commit(ctx); err == nil || errors.Is(err, ErrSuperseded) {
t.Fatalf("first commit err = %v, want the transport error", err)
}
+ if err := p.Refresh(ctx); err != nil {
+ t.Fatal(err)
+ }
seq, err := p.Commit(ctx)
if err != nil || seq != 1 {
t.Fatalf("second commit = %d, %v", seq, err)
@@ -606,12 +609,18 @@ func TestAFailedReReadAfterALostResponseIsNotASupersede(t *testing.T) {
t.Fatal("first commit should fail")
}
s.getFail = true
- var readErr *CommitRecoveryReadError
- if _, err := p.Commit(ctx); !errors.As(err, &readErr) || errors.Is(err, ErrSuperseded) {
- t.Fatalf("second commit err = %v, want CommitRecoveryReadError", err)
+ if err := p.Refresh(ctx); err == nil || errors.Is(err, ErrSuperseded) {
+ t.Fatalf("refresh: %v", err)
+ }
+ var stale *RefreshRequiredError
+ if _, err := p.Commit(ctx); !errors.As(err, &stale) {
+ t.Fatalf("failed refresh cleared refusal: %v", err)
+ }
+ if err := p.Refresh(ctx); err != nil {
+ t.Fatal(err)
}
if seq, err := p.Commit(ctx); err != nil || seq != 1 {
- t.Fatalf("third commit = %d, %v", seq, err)
+ t.Fatalf("refreshed commit = %d, %v", seq, err)
}
}
@@ -632,8 +641,7 @@ func TestThreeDeepOverlapKeepsTheNewestEntry(t *testing.T) {
}
}
-// A Stage between a commit whose response was lost and its retry changes
-// the body; the retry must still recognise the stored manifest as its own.
+// A lost reply refuses new stages until the applied manifest is re-read.
func TestALostCommitResponseFollowedByAStageIsNotASupersede(t *testing.T) {
ctx := context.Background()
s := &lostResponseStore{Store: release.NewDirStore(t.TempDir())}
@@ -643,6 +651,13 @@ func TestALostCommitResponseFollowedByAStageIsNotASupersede(t *testing.T) {
if _, err := p.Commit(ctx); err == nil || errors.Is(err, ErrSuperseded) {
t.Fatalf("first commit err = %v, want the transport error", err)
}
+ var stale *RefreshRequiredError
+ if err := p.Stage(ctx, "y", []byte("2"), 0o600, false); !errors.As(err, &stale) {
+ t.Fatalf("stage before refresh: %v", err)
+ }
+ if err := p.Refresh(ctx); err != nil {
+ t.Fatal(err)
+ }
stage(t, p, "y", "2")
seq, err := p.Commit(ctx)
if err != nil || seq != 2 {
@@ -661,8 +676,7 @@ func TestALostCommitResponseFollowedByAStageIsNotASupersede(t *testing.T) {
}
}
-// Two failed attempts against the same stale etag: only one can have been
-// applied, and whichever it was, the publisher recognises it.
+// Every uncertain attempt requires a read and restaging, applied or not.
func TestTwoFailedCommitsThenAStageRecognisesTheAppliedOne(t *testing.T) {
ctx := context.Background()
s := &lostResponseStore{Store: release.NewDirStore(t.TempDir())}
@@ -672,11 +686,18 @@ func TestTwoFailedCommitsThenAStageRecognisesTheAppliedOne(t *testing.T) {
if _, err := p.Commit(ctx); err == nil {
t.Fatal("first commit should fail")
}
+ if err := p.Refresh(ctx); err != nil {
+ t.Fatal(err)
+ }
stage(t, p, "y", "2")
s.putFail = true // the second attempt never reaches the store
if _, err := p.Commit(ctx); err == nil || errors.Is(err, ErrSuperseded) {
t.Fatalf("second commit err = %v, want the transport error", err)
}
+ if err := p.Refresh(ctx); err != nil {
+ t.Fatal(err)
+ }
+ stage(t, p, "y", "2") // the failed write did not land
stage(t, p, "z", "3")
if seq, err := p.Commit(ctx); err != nil || seq != 3 {
t.Fatalf("third commit = %d, %v; want 3, nil", seq, err)
diff --git a/internal/hostfiles/platform.go b/internal/hostfiles/platform.go
index 18dbbe48e..f7723d59f 100644
--- a/internal/hostfiles/platform.go
+++ b/internal/hostfiles/platform.go
@@ -23,6 +23,9 @@ func (p *Publisher) StagePlatformDelete(name string) error {
}
p.mu.Lock()
defer p.mu.Unlock()
+ if p.stale != nil {
+ return p.stale
+ }
if _, ok := p.man.Platform[name]; !ok {
return nil
}
diff --git a/internal/hostfiles/publisher.go b/internal/hostfiles/publisher.go
index a3437d9ff..1ad4d12a7 100644
--- a/internal/hostfiles/publisher.go
+++ b/internal/hostfiles/publisher.go
@@ -28,6 +28,13 @@ type CommitRecoveryReadError struct{ Err error }
func (e *CommitRecoveryReadError) Error() string { return e.Err.Error() }
func (e *CommitRecoveryReadError) Unwrap() error { return e.Err }
+// RefreshRequiredError means a manifest PUT may have applied. No further
+// staging or commit is admitted until Refresh or a new Open reads storage.
+type RefreshRequiredError struct{ Err error }
+
+func (e *RefreshRequiredError) Error() string { return "hostfiles: refresh required: " + e.Err.Error() }
+func (e *RefreshRequiredError) Unwrap() error { return e.Err }
+
// Publisher stages changes and commits them as one manifest revision. It
// is safe for concurrent use.
type Publisher struct {
@@ -39,11 +46,8 @@ type Publisher struct {
etag string
next int64 // the last sequence number handed out; man.Seq is the last committed
dirty bool
- // inflight holds, by sha256, every manifest body a failed Put may have
- // applied since the last successful commit, with the sequence number it
- // carried. Every one of those Puts named the same etag, so at most one
- // of them can be in storage.
- inflight map[string]int64
+ // stale refuses mutations until Refresh has read the bucket again.
+ stale *RefreshRequiredError
// committed is the sha256 of the manifest body last committed, or read
// at Open: the body behind man.Seq. "" while there is none.
// committedBody is that body itself, nil while there is none.
@@ -73,6 +77,31 @@ func Open(ctx context.Context, s release.Store, prefix string) (*Publisher, erro
return p, nil
}
+// Refresh discards staged changes and replaces the baseline with the bucket's
+// current manifest. A failed read leaves the publisher stale. Callers must
+// validate and stage their candidates again after this succeeds.
+func (p *Publisher) Refresh(ctx context.Context) error {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+ fresh, err := Open(ctx, p.s, p.prefix)
+ if err != nil {
+ return err
+ }
+ p.man, p.etag, p.next, p.dirty = fresh.man, fresh.etag, fresh.next, false
+ p.committed, p.committedBody, p.stale = fresh.committed, fresh.committedBody, nil
+ return nil
+}
+
+// RefreshRequired reports whether a commit left the bucket outcome unknown.
+func (p *Publisher) RefreshRequired() error {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+ if p.stale != nil {
+ return p.stale
+ }
+ return nil
+}
+
// RestorableWithinCap is the check a caller makes before it starts work
// that will need m restored (a move's cut, the claim's files backfill):
// every entry path of m, live, tombstoned or skipped, within the tree's
@@ -202,6 +231,9 @@ func (p *Publisher) Stage(ctx context.Context, path string, body []byte, mode ui
}
p.mu.Lock()
defer p.mu.Unlock()
+ if p.stale != nil {
+ return p.stale
+ }
if cur, ok := p.man.Entries[clean]; ok && !cur.Deleted && cur.Skipped == "" &&
cur.SHA256 == sum(body) && cur.Mode == mode&0o777 && cur.Torn == torn {
return nil
@@ -225,6 +257,9 @@ func (p *Publisher) StageSkipped(path, why string) error {
}
p.mu.Lock()
defer p.mu.Unlock()
+ if p.stale != nil {
+ return p.stale
+ }
if cur, ok := p.man.Entries[clean]; ok && cur.Skipped == why {
return nil
}
@@ -245,6 +280,9 @@ func (p *Publisher) StageDelete(path string) error {
}
p.mu.Lock()
defer p.mu.Unlock()
+ if p.stale != nil {
+ return p.stale
+ }
if cur, ok := p.man.Entries[clean]; !ok || cur.Deleted {
return nil
}
@@ -262,6 +300,9 @@ func (p *Publisher) StagePlatform(ctx context.Context, name string, body []byte)
}
p.mu.Lock()
defer p.mu.Unlock()
+ if p.stale != nil {
+ return p.stale
+ }
if cur, ok := p.man.Platform[name]; ok && cur.SHA256 == sum(body) {
return nil
}
@@ -274,12 +315,15 @@ func (p *Publisher) StagePlatform(ctx context.Context, name string, body []byte)
}
// Commit publishes everything staged as one manifest revision and returns
-// its sequence number. With nothing staged it returns the current one. A
-// failed commit leaves the staged changes in place, so the caller retries;
-// ErrSuperseded is final.
+// its sequence number. With nothing staged it returns the current one. An
+// uncertain commit requires Refresh and restaging against the re-read baseline;
+// ErrSuperseded means another writer won.
func (p *Publisher) Commit(ctx context.Context) (int64, error) {
p.mu.Lock()
defer p.mu.Unlock()
+ if p.stale != nil {
+ return 0, p.stale
+ }
if !p.dirty {
return p.man.Seq, nil
}
@@ -297,40 +341,26 @@ func (p *Publisher) Commit(ctx context.Context) (int64, error) {
}
etag, err := p.s.Put(ctx, ManifestKey(p.prefix), body, p.etag)
if errors.Is(err, release.ErrCASConflict) {
- // A lost response looks like this: the store applied an earlier Put,
- // the reply never arrived, and this retry's etag is now stale. If
- // the manifest holds exactly the bytes this Commit is writing, or
- // the bytes an earlier failed Commit wrote, it is ours.
+ // Only the exact body this attempt wrote can acknowledge this commit.
+ // Earlier uncertain writes require Refresh and caller validation instead
+ // of adopting an inflight body and publishing new candidates over it.
cur, curEtag, gerr := p.s.Get(ctx, ManifestKey(p.prefix))
- if gerr != nil {
- // Not knowing is not the same as being superseded: leave the
- // staged state and etag alone so the next Commit repeats the check.
- return 0, &CommitRecoveryReadError{Err: gerr}
- }
- if bytes.Equal(cur, body) {
+ switch {
+ case gerr != nil:
+ err = &CommitRecoveryReadError{Err: gerr}
+ case bytes.Equal(cur, body):
err, etag = nil, curEtag
- } else if seq, ok := p.inflight[sum(cur)]; ok {
- // An earlier attempt landed and later stages changed the body.
- // Adopt it, then write the current body once on top of it.
- p.man.Seq, p.etag, p.inflight, p.committed, p.committedBody = seq, curEtag, nil, sum(cur), cur
- etag, err = p.s.Put(ctx, ManifestKey(p.prefix), body, p.etag)
- if errors.Is(err, release.ErrCASConflict) {
- return 0, fmt.Errorf("%w: %s", ErrSuperseded, p.prefix)
- }
- } else {
+ default:
+ // This PUT did not apply, and a different body won. Preserve the
+ // terminal ownership refusal; it must not trigger automatic refresh.
return 0, fmt.Errorf("%w: %s", ErrSuperseded, p.prefix)
}
}
if err != nil {
- if !errors.Is(err, release.ErrCASConflict) {
- if p.inflight == nil {
- p.inflight = map[string]int64{}
- }
- p.inflight[sum(body)] = out.Seq
- }
- return 0, err
+ p.stale = &RefreshRequiredError{Err: err}
+ return 0, p.stale
}
- p.man.Seq, p.etag, p.dirty, p.inflight = out.Seq, etag, false, nil
+ p.man.Seq, p.etag, p.dirty = out.Seq, etag, false
p.committed, p.committedBody = sum(body), body
return out.Seq, nil
}
diff --git a/internal/hostfiles/publisher_refresh_test.go b/internal/hostfiles/publisher_refresh_test.go
new file mode 100644
index 000000000..83e1500dd
--- /dev/null
+++ b/internal/hostfiles/publisher_refresh_test.go
@@ -0,0 +1,99 @@
+package hostfiles
+
+import (
+ "context"
+ "errors"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/release"
+)
+
+type refreshCASStore struct {
+ release.Store
+ armed bool
+}
+
+func (s *refreshCASStore) Put(ctx context.Context, key string, body []byte, match string) (string, error) {
+ if s.armed && key == ManifestKey(pfx) {
+ return "", release.ErrCASConflict
+ }
+ return s.Store.Put(ctx, key, body, match)
+}
+
+func TestUncertainCommitFencesEveryStageUntilRefresh(t *testing.T) {
+ for _, outcome := range []string{"applied", "unapplied", "cas-read-failed"} {
+ t.Run(outcome, func(t *testing.T) {
+ ctx := context.Background()
+ cas := &refreshCASStore{Store: release.NewDirStore(t.TempDir())}
+ lost := &lostResponseStore{Store: cas}
+ counted := &countingStore{Store: lost}
+ p := open(t, counted)
+ seal := newSealer(t, newKey(t), shopBinding, sealHost)
+ stage(t, p, "x", "original")
+ switch outcome {
+ case "applied":
+ lost.armed = true
+ case "unapplied":
+ lost.putFail = true
+ case "cas-read-failed":
+ cas.armed, lost.getFail = true, true
+ }
+ _, err := p.Commit(ctx)
+ var stale *RefreshRequiredError
+ if !errors.As(err, &stale) {
+ t.Fatalf("commit = %v, want refresh required", err)
+ }
+ if outcome == "cas-read-failed" {
+ var recovery *CommitRecoveryReadError
+ if !errors.As(err, &recovery) {
+ t.Fatalf("lost recovery error type: %v", err)
+ }
+ }
+ puts, gets := counted.puts, counted.gets
+ checks := []struct {
+ name string
+ call func() error
+ }{
+ {"Stage", func() error { return p.Stage(ctx, "y", []byte("changed"), 0o600, false) }},
+ {"StageSkipped", func() error { return p.StageSkipped("y", "skip") }},
+ {"StageDelete", func() error { return p.StageDelete("x") }},
+ {"StagePlatform", func() error { return p.StagePlatform(ctx, "item", []byte("changed")) }},
+ {"StagePlatformDelete", func() error { return p.StagePlatformDelete("item") }},
+ {"StageSealed", func() error { return p.StageSealed(ctx, envRel(t), []byte("secret"), seal) }},
+ {"DropRawSecrets", func() error { return p.DropRawSecrets([]string{"x"}) }},
+ {"Commit", func() error { _, err := p.Commit(ctx); return err }},
+ }
+ for _, check := range checks {
+ if err := check.call(); !errors.As(err, &stale) {
+ t.Errorf("%s = %v, want refresh required", check.name, err)
+ }
+ }
+ if counted.puts != puts || counted.gets != gets {
+ t.Fatal("stale operations reached storage")
+ }
+ lost.getFail = true
+ if err := p.Refresh(ctx); err == nil {
+ t.Fatal("refresh should fail")
+ }
+ if err := p.RefreshRequired(); !errors.As(err, &stale) {
+ t.Fatalf("failed refresh removed fence: %v", err)
+ }
+ cas.armed = false
+ if err := p.Refresh(ctx); err != nil {
+ t.Fatal(err)
+ }
+ if p.RefreshRequired() != nil || p.Dirty() {
+ t.Fatal("refresh kept stale or staged state")
+ }
+ if p.Baseline().Found != (outcome == "applied") {
+ t.Fatal("refresh did not read the applied outcome")
+ }
+ stage(t, p, "y", "fresh")
+ commit(t, p)
+ m := loadM(t, counted)
+ if _, ok := m.Entries["x"]; ok != (outcome == "applied") {
+ t.Fatal("unapplied stages survived refresh")
+ }
+ })
+ }
+}
diff --git a/internal/hostfiles/sealed.go b/internal/hostfiles/sealed.go
index d69cf5e5f..8e05b378b 100644
--- a/internal/hostfiles/sealed.go
+++ b/internal/hostfiles/sealed.go
@@ -135,6 +135,9 @@ func (p *Publisher) StageSealed(ctx context.Context, r pubclass.SealedRel, plain
mac := s.MAC(item, plain)
p.mu.Lock()
defer p.mu.Unlock()
+ if p.stale != nil {
+ return p.stale
+ }
if cur, ok := p.man.Platform[item]; !ok || !sealedMatches(cur, mac) {
env, err := s.seal(plain)
if err != nil {
@@ -241,6 +244,9 @@ func (p *Publisher) DropRawSecrets(paths []string) error {
}
p.mu.Lock()
defer p.mu.Unlock()
+ if p.stale != nil {
+ return p.stale
+ }
if _, ok := p.man.Platform[EnvItem]; ok {
p.next++
delete(p.man.Platform, EnvItem)
diff --git a/internal/provision/durability_3a_branchfix2b_census_test.go b/internal/provision/durability_3a_branchfix2b_census_test.go
new file mode 100644
index 000000000..e880f4e53
--- /dev/null
+++ b/internal/provision/durability_3a_branchfix2b_census_test.go
@@ -0,0 +1,19 @@
+package provision
+
+// Fix round 2b fences every mutation after an uncertain manifest PUT.
+// Commit retains its manifest-only nonrecord classification, removes the
+// inflight replacement PUT, and requires a storage read before restaging.
+func durability3aBranchFix2bWriteCensusInventory() []censusEntry {
+ entries := append([]censusEntry(nil), durability3aBranchFixWriteCensusInventory()...)
+ repin := censusEntry{"internal/hostfiles/publisher.go", "Publisher.Commit", "nonrecord", "sel:Put", "0a4b61d13263b7f94e9e28d5c07335949b72114e9472de3b3722cf0f262631b1"}
+ for i, e := range entries {
+ if e.File == repin.File && e.Unit == repin.Unit {
+ if e.Class != repin.Class || e.Kinds != repin.Kinds {
+ panic("durability-3a fix 2b changes Commit classification")
+ }
+ entries[i] = repin
+ return entries
+ }
+ }
+ panic("durability-3a fix 2b re-pin of unlisted Commit")
+}
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go
index ef3ef0cd8..99091c57f 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 := durability3aBranchFixWriteCensusInventory()
+ inventory := durability3aBranchFix2bWriteCensusInventory()
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 28275f2b0..ccd8db4f8 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 697737b989cfc1d9b082f534265f01c533d446c1fe345782bc696219e0d71156
+plan14-root-reads-durability-3a-escrow.tsv 18f1c7991164d28cf0b16b0aa2fb2569570acf1a9a0465ddda04f8f9240320a9
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 d98b6292b..c48708597 100644
--- a/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv
+++ b/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv
@@ -1,7 +1,7 @@
# 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.
-# 46 new dispositions: 1 reads re-frozen at their disposition with the claim, 44 new units frozen accepted-legacy, 1 quiet units retired while they read nothing, 0 other.
+# 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.
@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
@@ -34,7 +34,7 @@
@legacy f6e622ed3b9e219a616ce6bf2f951b3e50c7897bd6e8a7f59ddb335fcbf8e3db internal/activator/escrow.go ExecBackend.publishEscrowAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: escrowReady and the layout checked, then publishEscrowLocked under the host's lock Fix round 1: refuses while the conflict marker exists or while this box does not hold the host's lease (P1-2), before anything is read. registry:Host@223,registry:Host@269,registry:Host@340,registry:Host@376,registry:Host@435,registry:Host@556,registry:Host@653,whole:Route@157,whole:Route@733 5e2b655605216fcaa50ddfd0511ca4ce913a8716582932a13debf22c4876f117
@legacy 24182e210cb1e45dc6e61f1c8bce9329a7a9f5d523098987c3cd09b1e47ac3c6 internal/activator/escrow.go ExecBackend.publishEscrowLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: reads <host>.env (unless the launch's capture is handed in), <host>/instance.key and <host>/report.token with readStamped beneath the row's data directory, seals what changed (StageSealed), DropRawSecrets of the constant raw names, commits, and writes the ledger (writeEscrowLedger: EnsureDirBeneath .escrow 0700, a 0600 temp, rename, fsync); an absent file stages nothing; a refused file publishes nothing for it; the agent as carlos (carlos-edge.service), no root caller Fix round 1: before staging, mintedConflict on the baseline it would replace, so a secret this box minted is never published over another escrowed value (P1-1). Fix round 2 (P1-1, P1-2, stale ledger): before staging, the write-once check (escrowDivergence, keyed digests only, no request): a staged instance.key or report.token whose escrowed item has another digest refuses the publish (escrowConflictFound); then, under the operation lock just before the commit, the lease again (holdsLease): lost, nothing is committed and the staged state is dropped; after a commit the ledger through keepLedger (written, else the stale one removed with RemoveBeneath under <data>/.escrow, else marked untrusted in memory). Fix round 3: escrowDivergence also holds the env's minted variables write-once (one GET of the sealed env, only when the env changed); the committed manifest is kept as what this process knows (noteKnown). Fix round 4: only a commit that wrote (the baseline's ETag moved) feeds what this process knows (learnBucket) and writes the ledger; a no-op commit on a ledger-opened publisher feeds nothing; the same reads and writes. Durability 3a Task 5: on the held baseline before staging and DropRawSecrets, noteRawSecrets(rt.Host, m). 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-1: every failed manifest commit drops the publisher, stamps, preparation read and bucket knowledge; the next operation opens the bucket and repeats divergence checks before staging. No new root input or read site. Branch fix R1 P1-4: a CommitRecoveryReadError from the existing CAS-recovery GET wraps errEscrowUnreadable, so the launch refuses rather than using the later-launch write-failure fallback. No new read. 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. 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. Branch fix R2 P1-3: delegate the existing baseline, divergence and StageSealed operations to stageEscrowReads, shared with HA. Same bucket objects and reads; lease gating, uncertain-commit state drop, and typed CAS-recovery refusal retained. registry:Host@2078,registry:Host@2342,registry:Host@3307,registry:Host@3337,registry:Host@4494,registry:Host@574,whole:Route@2269,whole:Route@2497 01b4a5ff2f2dccc3f28d998a5e478e309e3eb9762f007a0fbee34501f2743d89
@legacy 74bd4eb3be0768428751ab09e7fdcbcd46d84aa16e619a9f591d35dc57e4a824 internal/activator/escrow.go ExecBackend.restoreEscrowIfMissing legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: checks each escrowed file with instancefs.OpenBeneathOrAbsent beneath the row's data directory; when one is absent, hostfiles.Open of the host's manifest, ReadSealed of each missing item, and writeIfAbsent (instancefs.WriteAtomic of a temp, then RenameBetweenNoReplace, so a present file is never replaced; EnsureDirBeneath for the files directory, 0700); on a box that is not ready it refuses unless the ledger shows the host escrowed and the env file is here; the agent as carlos (carlos-edge.service), no root caller Fix round 0 (controller readiness ruling): with no files store it does nothing (logged once); with no sealing key it restores nothing: a ledger here and an env file here go on, otherwise keylessEscrowed refuses when the bucket holds an escrow and goes on as before 3a when it holds none. Fix round 1: the conflict marker first, then the mode (P2-5): no files store, nothing; no key, the preparation's keyless read before any file check. With a key, each trio file is checked with OpenBeneathOrAbsent (a link or FIFO is not missing); the bucket is read (bucketManifest, the preparation's one GET) only for a missing env file, or a missing trio file the ledger says was escrowed, or with no ledger once per agent start (P2-6); the same writes. Fix round 2: the ledger is read through ledgerFor, and while it is untrusted (its write and the stale ledger's removal both failed) a missing trio file always reads the bucket; the same reads and writes. Fix round 3: the ledger no longer decides a restore: a missing trio file reads the bucket unless this process itself saw the bucket's manifest for the host (its read or its commit, escrowState.known) without the item; the same reads and writes otherwise. 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. 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. registry:Host@1027,registry:Host@1145,registry:Host@138,registry:Host@1853,registry:Host@2721,registry:Host@571,registry:Host@652,registry:Host@698,registry:Host@801,whole:Route@1654,whole:Route@1750,whole:Route@200,whole:Route@241,whole:Route@314,whole:Route@360,whole:Route@477 335cb066c95f026fba5e99df8f86252ee6a50b48f799d7b1042460c2ec188642
-@legacy b7f721d0925fe5332a1809aa3e44df9e52c90e5eaccf83193acb1c14ec09b99c internal/activator/escrow.go ExecBackend.stageEscrowReads legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=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. registry:Host@206,registry:Host@383,whole:Route@437,whole:Route@598,whole:Route@716 f00a182229cbe7f895f91822d1a3b637589a0764d55b5c498feeec9e488a4018
+@legacy ea26495d3dac60f754363c02d85312eaace9be2e83bd61c2c7e00ec1a1f4251a internal/activator/escrow.go ExecBackend.stageEscrowReads legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=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. registry:Host@206,registry:Host@690,whole:Route@1023,whole:Route@744,whole:Route@905 7c8a6b14dd0fbbe5c4a3e65c15bd74cf54338421d42e7df4203ea99bfed9c6c7
@legacy 7d7ae676fe3d33d027489b397a804eaa184295667ad039688aed3757f662ab9d internal/activator/escrow.go ExecBackend.sweepPublish legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: publishEscrowAt, and on a supersession escrowReread and one more publish; a second one is the alert registry:Host@404,whole:Route@142,whole:Route@232,whole:Route@312 71bfee868a2ca8e3371cfc3c628b6ab5d8730ca48fcd099e7932049fe1e12a69
@legacy c89cfff20022faa5af3e07251a620b1b63e0b42f350483a6efec4162efdd1cca internal/activator/escrow.go Service.EscrowSweep legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the backend's EscrowSweep, nothing for a backend without one whole:Route@184 8ed0ea62a9807b7c43b3576d01f096bfe366c21bcc3be040831a3f1b80d1b123
@legacy 5e6fbfb1fc889f9d7742e9275cfaac39888a93c8d33ed329ee92088fcc52167f internal/activator/escrow.go Service.SecretsEscrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the backend's SecretsEscrowed, else IsHA whole:Route@184,whole:Route@215 87261115297104155806136d4d0001c4cd3e150e5ffe91612bb5014fb7780881
@@ -52,6 +52,7 @@
@legacy 957ad5d3377cd8a74a394858b4836b46d318fbaa7b3a3ac2c102c9b010f75ac4 internal/host/escrow_loop.go escrowLoop legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: every activator.EscrowEvery (30 s) lists the registry and runs svc.EscrowSweep over the rows; logs failures and deferrals; returns with no registry or no Service; the agent as carlos (carlos-edge.service), no root caller whole:Route@426 498f5efdf374f9c35ca954f845507ce3c8db25e9b766f873c3acf23ec2f7cb05
@legacy 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 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
@@ -102,7 +103,7 @@ internal/activator/escrow.go ExecBackend.publishEscrow legacy accepted-legacy ac
internal/activator/escrow.go ExecBackend.publishEscrowAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: escrowReady and the layout checked, then publishEscrowLocked under the host's lock Fix round 1: refuses while the conflict marker exists or while this box does not hold the host's lease (P1-2), before anything is read. registry:Host@223,registry:Host@269,registry:Host@340,registry:Host@376,registry:Host@435,registry:Host@556,registry:Host@653,whole:Route@157,whole:Route@733 5e2b655605216fcaa50ddfd0511ca4ce913a8716582932a13debf22c4876f117
internal/activator/escrow.go ExecBackend.publishEscrowLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: reads <host>.env (unless the launch's capture is handed in), <host>/instance.key and <host>/report.token with readStamped beneath the row's data directory, seals what changed (StageSealed), DropRawSecrets of the constant raw names, commits, and writes the ledger (writeEscrowLedger: EnsureDirBeneath .escrow 0700, a 0600 temp, rename, fsync); an absent file stages nothing; a refused file publishes nothing for it; the agent as carlos (carlos-edge.service), no root caller Fix round 1: before staging, mintedConflict on the baseline it would replace, so a secret this box minted is never published over another escrowed value (P1-1). Fix round 2 (P1-1, P1-2, stale ledger): before staging, the write-once check (escrowDivergence, keyed digests only, no request): a staged instance.key or report.token whose escrowed item has another digest refuses the publish (escrowConflictFound); then, under the operation lock just before the commit, the lease again (holdsLease): lost, nothing is committed and the staged state is dropped; after a commit the ledger through keepLedger (written, else the stale one removed with RemoveBeneath under <data>/.escrow, else marked untrusted in memory). Fix round 3: escrowDivergence also holds the env's minted variables write-once (one GET of the sealed env, only when the env changed); the committed manifest is kept as what this process knows (noteKnown). Fix round 4: only a commit that wrote (the baseline's ETag moved) feeds what this process knows (learnBucket) and writes the ledger; a no-op commit on a ledger-opened publisher feeds nothing; the same reads and writes. Durability 3a Task 5: on the held baseline before staging and DropRawSecrets, noteRawSecrets(rt.Host, m). 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-1: every failed manifest commit drops the publisher, stamps, preparation read and bucket knowledge; the next operation opens the bucket and repeats divergence checks before staging. No new root input or read site. Branch fix R1 P1-4: a CommitRecoveryReadError from the existing CAS-recovery GET wraps errEscrowUnreadable, so the launch refuses rather than using the later-launch write-failure fallback. No new read. 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. 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. Branch fix R2 P1-3: delegate the existing baseline, divergence and StageSealed operations to stageEscrowReads, shared with HA. Same bucket objects and reads; lease gating, uncertain-commit state drop, and typed CAS-recovery refusal retained. registry:Host@2078,registry:Host@2342,registry:Host@3307,registry:Host@3337,registry:Host@4494,registry:Host@574,whole:Route@2269,whole:Route@2497 01b4a5ff2f2dccc3f28d998a5e478e309e3eb9762f007a0fbee34501f2743d89
internal/activator/escrow.go ExecBackend.restoreEscrowIfMissing legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: checks each escrowed file with instancefs.OpenBeneathOrAbsent beneath the row's data directory; when one is absent, hostfiles.Open of the host's manifest, ReadSealed of each missing item, and writeIfAbsent (instancefs.WriteAtomic of a temp, then RenameBetweenNoReplace, so a present file is never replaced; EnsureDirBeneath for the files directory, 0700); on a box that is not ready it refuses unless the ledger shows the host escrowed and the env file is here; the agent as carlos (carlos-edge.service), no root caller Fix round 0 (controller readiness ruling): with no files store it does nothing (logged once); with no sealing key it restores nothing: a ledger here and an env file here go on, otherwise keylessEscrowed refuses when the bucket holds an escrow and goes on as before 3a when it holds none. Fix round 1: the conflict marker first, then the mode (P2-5): no files store, nothing; no key, the preparation's keyless read before any file check. With a key, each trio file is checked with OpenBeneathOrAbsent (a link or FIFO is not missing); the bucket is read (bucketManifest, the preparation's one GET) only for a missing env file, or a missing trio file the ledger says was escrowed, or with no ledger once per agent start (P2-6); the same writes. Fix round 2: the ledger is read through ledgerFor, and while it is untrusted (its write and the stale ledger's removal both failed) a missing trio file always reads the bucket; the same reads and writes. Fix round 3: the ledger no longer decides a restore: a missing trio file reads the bucket unless this process itself saw the bucket's manifest for the host (its read or its commit, escrowState.known) without the item; the same reads and writes otherwise. 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. 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. registry:Host@1027,registry:Host@1145,registry:Host@138,registry:Host@1853,registry:Host@2721,registry:Host@571,registry:Host@652,registry:Host@698,registry:Host@801,whole:Route@1654,whole:Route@1750,whole:Route@200,whole:Route@241,whole:Route@314,whole:Route@360,whole:Route@477 335cb066c95f026fba5e99df8f86252ee6a50b48f799d7b1042460c2ec188642
-internal/activator/escrow.go ExecBackend.stageEscrowReads legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=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. registry:Host@206,registry:Host@383,whole:Route@437,whole:Route@598,whole:Route@716 f00a182229cbe7f895f91822d1a3b637589a0764d55b5c498feeec9e488a4018
+internal/activator/escrow.go ExecBackend.stageEscrowReads legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=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. registry:Host@206,registry:Host@690,whole:Route@1023,whole:Route@744,whole:Route@905 7c8a6b14dd0fbbe5c4a3e65c15bd74cf54338421d42e7df4203ea99bfed9c6c7
internal/activator/escrow.go ExecBackend.sweepPublish legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: publishEscrowAt, and on a supersession escrowReread and one more publish; a second one is the alert registry:Host@404,whole:Route@142,whole:Route@232,whole:Route@312 71bfee868a2ca8e3371cfc3c628b6ab5d8730ca48fcd099e7932049fe1e12a69
internal/activator/escrow.go Service.EscrowSweep legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the backend's EscrowSweep, nothing for a backend without one whole:Route@184 8ed0ea62a9807b7c43b3576d01f096bfe366c21bcc3be040831a3f1b80d1b123
internal/activator/escrow.go Service.SecretsEscrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: the backend's SecretsEscrowed, else IsHA whole:Route@184,whole:Route@215 87261115297104155806136d4d0001c4cd3e150e5ffe91612bb5014fb7780881
@@ -120,6 +121,7 @@ internal/activator/paths.go ExecBackend.pathsAt legacy accepted-legacy accepted-
internal/host/escrow_loop.go escrowLoop legacy accepted-legacy accepted-legacy;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: new: every activator.EscrowEvery (30 s) lists the registry and runs svc.EscrowSweep over the rows; logs failures and deferrals; returns with no registry or no Service; the agent as carlos (carlos-edge.service), no root caller whole:Route@426 498f5efdf374f9c35ca954f845507ce3c8db25e9b766f873c3acf23ec2f7cb05
internal/host/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/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
@@ -145,8 +147,8 @@ internal/activator/paths.go ExecBackend.pathsFor legacy accepted-legacy accepted
@removed internal/host/movesfiles.go readClaimEnvFile H3 census-ruling-durability-3a-escrow;absent;basis=deleted: declaration and sites absent from the tree
@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 7a939c42f169fff3fdb3b3d98665d3d20d8ed935f5d19bc203e59c39a20c2e8a
+@coverage internal/activator 00b08377f1580ec647ba4d95b69768946a41362836c98423012ff29281b8280d
@coverage internal/host 941b090a234199926a9f64c927657034c3b5fb17dea1f5a18716cfe2294f55b1
-@coverage internal/hostfiles cbcc79ea1d27809889e4f6676b0b154ac61f842b9bb6d2ecfa6aeaf975f05b5f
+@coverage internal/hostfiles c36ed3386a51d450c9b212e84221fce1fb39dcf7b0b18c7690331fb9fdcec6f0
@coverage internal/layout f845fa728b0935279454d8b01023c5d6dae1c985061a41229cf0686e829f5c12
@coverage internal/layout/pubclass 6515ba31b1848139c9da066a6c65b5583c39a92cb77621773d0d11d9cde24e24