durability 3a: close publication guard bypasses
Require inventory-mapped Stage classification and a single-definition refusal root. Reject embedded publishers and unmatched fixture diagnostics. Bind the seed descriptor once without changing production behavior, and refresh its census pin.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12 files changed,
+158
−49
docs/superpowers/notes/census-durability-3a-escrow-claims.md+1 −1docs/superpowers/notes/census-proposal-durability-3a-escrow.md+1 −1internal/host/claimfilesseed_stage.go+6 −3internal/layout/pubclass/publication_guard_test.go+60 −31internal/layout/pubclass/testdata/publication_guard/clean.go+3 −3internal/layout/pubclass/testdata/publication_guard/embedding.go+18 −0internal/layout/pubclass/testdata/publication_guard/ignored.go+2 −2internal/layout/pubclass/testdata/publication_guard/reassign.go+2 −2internal/layout/pubclass/testdata/publication_guard/refusalwrites.go+41 −0internal/layout/pubclass/testdata/publication_guard/unclassified.go+4 −4internal/layout/pubclass/testdata/publication_guard/unmapped.go+18 −0internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv+2 −2
Intent
Attributed to this commit: 19.9 g CO₂e (2,164,987 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 85c73d7d5..27ad63656 100644 |
| --- a/docs/superpowers/notes/census-durability-3a-escrow-claims.md |
| +++ b/docs/superpowers/notes/census-durability-3a-escrow-claims.md |
| @@ -71,4 +71,4 @@ internal/host/movesfiles.go:movesFiles.Establish Durability 3a Task 5 (parked pa |
| internal/host/movesfiles.go:claimEnvPresent Durability 3a Task 5: new: whether the claim env file exists, without reading it: nested, instancefs.OpenBeneathOrAbsent beneath the instance directory (no link at any component; the descriptor closed at once); flat, os.Lstat of <data>/<host>.env (a link there counts as present, so it refuses). An undecidable answer is an error. Only feeds a refusal. |
| internal/host/movesfiles.go:buildPrepared Durability 3a Task 5 (parked path, CARLOS_MOVES_PHASE1 only): wantEnv refuses with pubclass.ErrSecretPath before anything is read or written; the env presence check for !wantEnv is os.Stat instead of os.ReadFile (the secret is no longer read into memory); hostfiles.RefuseSecretsAt over root.Open(".") (+file:Open, a descriptor of the os.Root it already opened, never a pathname) before NewPrepared; the walk checks pubclass.Of(...) == App before each Stage; the env file is never staged. Only refuses more, and reads less. |
| internal/host/relocationflush.go:ReleaseFlushFiles.Flush Durability 3a Task 5 (parked path, host claims only): the env file's presence is decided first with instancefs.OpenBeneathOrAbsent (the bytes are never read, replacing readInstanceFile of the env): present refuses with pubclass.ErrSecretPath before the manifest is read; hostfiles.RefuseSecretsAt over the root it opened, after the tenant seam and before hostfiles.Seed; absent still stages the env item's delete. Only refuses more, and reads less. |
| -internal/host/claimfilesseed_stage.go:filesSeedOperation.stage Durability 3a Task 5 (parked path, host claims with origins only): hostfiles.RefuseSecretsAt over the root it opened, before hostfiles.Seed: any path the classifier does not call App refuses the seed before its first write, with pubclass.ErrSecretPath. No read added; the walk is the descriptor walk Seed itself makes. |
| +internal/host/claimfilesseed_stage.go:filesSeedOperation.stage Durability 3a Task 5 (parked path, host claims with origins only): hostfiles.RefuseSecretsAt over the root it opened, before hostfiles.Seed: any path the classifier does not call App refuses the seed before its first write, with pubclass.ErrSecretPath. No read added; the walk is the descriptor walk Seed itself makes. Task 7 fix round 1: bind the descriptor returned through work.With once as dir; stat, RefuseSecretsAt and Seed use that same descriptor. No path, read, authority, refusal or production behavior changes; the account/host identity and descriptor lifetime are unchanged. |
diff --git a/docs/superpowers/notes/census-proposal-durability-3a-escrow.md b/docs/superpowers/notes/census-proposal-durability-3a-escrow.md| index b5ff3c1d0..81836ef46 100644 |
| --- a/docs/superpowers/notes/census-proposal-durability-3a-escrow.md |
| +++ b/docs/superpowers/notes/census-proposal-durability-3a-escrow.md |
| @@ -11,7 +11,7 @@ Ruling `census-ruling-durability-3a-escrow`. The independent reviewer approves o |
| | `internal/activator/instancekey.go` `ExecBackend.ensureInstanceKeyAt` | body | unchanged (4) | durability 3a Task 4: asks mintGuardFor(ctx, rt) (was haMintGuard): an HA host's guard as before; an eligible host's escrowMintGuard, which on a ready box reads the bucket manifest and the sealed env item when a mint is next and refuses while the escrow holds the key, and on a box that is not ready refuses every mint; nil for any other host, which mints as before. The replica and fenced/conflict refusals are unchanged; only adds refusals Fix round 1: asks mintGuardWith(ctx, rt, !create): a launch's ensure shares its preparation's escrow read, the backfill's reads the bucket afresh; only refuses. | |
| | `internal/activator/instancekey.go` `ensureInstanceKey` | body | unchanged (1) | durability 3a Task 4: the guard is asked with InstanceKeyVar, at the same point (the locked read found no key and the bucket allowed a mint); create-only, fail-closed and defer-on-unknown unchanged; the same one site; only adds a refusal | |
| | `internal/host/agent.go` `runAgent` | body | unchanged (6) | durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. | |
| -| `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. | |
| +| `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. | |
| | `internal/host/movesfiles.go` `movesFiles.Establish` | body | unchanged (0) | Durability 3a Task 5 (parked path, host claims only): a present env file (claimEnvPresent: nested via instancefs.OpenBeneathOrAbsent, flat via Lstat; the bytes are never read) refuses with pubclass.ErrSecretPath before any bucket write; the env bytes are no longer read (readClaimEnvFile deleted); with no env file the establishment proceeds and stages StagePlatformDelete(EnvItem), so a raw env item a baseline holds is dropped, never carried into the new generation; openPrepared no longer takes the env and establishedOver no longer GETs an env object. Only refuses more, and reads less. | |
| | `internal/host/relocationflush.go` `ReleaseFlushFiles.Flush` | body | unchanged (1) | Durability 3a Task 5 (parked path, host claims only): the env file's presence is decided first with instancefs.OpenBeneathOrAbsent (the bytes are never read, replacing readInstanceFile of the env): present refuses with pubclass.ErrSecretPath before the manifest is read; hostfiles.RefuseSecretsAt over the root it opened, after the tenant seam and before hostfiles.Seed; absent still stages the env item's delete. Only refuses more, and reads less. | |
| | `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. | |
diff --git a/internal/host/claimfilesseed_stage.go b/internal/host/claimfilesseed_stage.go| index 97355bfee..339c3918e 100644 |
| --- a/internal/host/claimfilesseed_stage.go |
| +++ b/internal/host/claimfilesseed_stage.go |
| @@ -135,7 +135,10 @@ func (s *filesSeedOperation) stage(ctx context.Context, o hostclaim.Observed, in |
| if err != nil { |
| return err |
| } |
| - before, err := root.Stat() |
| + // The descriptor opened under work.With is fixed for both the refusal |
| + // and the seed; the closure's output is not reused as a mutable root. |
| + dir := root |
| + before, err := dir.Stat() |
| if err != nil { |
| return err |
| } |
| @@ -143,10 +146,10 @@ func (s *filesSeedOperation) stage(ctx context.Context, o hostclaim.Observed, in |
| // through the descriptor it reads from. Any path the classifier does |
| // not call App (the trio at the files directory's root) refuses the |
| // seed before its first write: this parked path does not seal. |
| - if err := hostfiles.RefuseSecretsAt(ctx, root, pubclass.Nested, o.Host); err != nil { |
| + if err := hostfiles.RefuseSecretsAt(ctx, dir, pubclass.Nested, o.Host); err != nil { |
| return fmt.Errorf("files seed of %s: %w", o.Host, err) |
| } |
| - s.stats, err = hostfiles.Seed(ctx, p, root, wake, nil) |
| + s.stats, err = hostfiles.Seed(ctx, p, dir, wake, nil) |
| if err != nil { |
| return err |
| } |
diff --git a/internal/layout/pubclass/publication_guard_test.go b/internal/layout/pubclass/publication_guard_test.go| index d40512a62..90963aeb3 100644 |
| --- a/internal/layout/pubclass/publication_guard_test.go |
| +++ b/internal/layout/pubclass/publication_guard_test.go |
| @@ -250,6 +250,26 @@ func (g *publicationGuard) zeroFields(u *publicationUnit, n ast.Node, t types.Ty |
| } |
| } |
| +// Scan whole declarations, including anonymous structs in signatures. |
| +func (g *publicationGuard) embeddings(u *publicationUnit, decl ast.Node) { |
| + ast.Inspect(decl, func(n ast.Node) bool { |
| + st, ok := n.(*ast.StructType) |
| + if !ok { |
| + return true |
| + } |
| + for _, field := range st.Fields.List { |
| + if len(field.Names) != 0 { |
| + continue |
| + } |
| + ptr, ok := types.Unalias(u.pkg.TypesInfo.TypeOf(field.Type)).(*types.Pointer) |
| + if ok && (publicationNamed(ptr.Elem(), publicationHostfiles, "Publisher") || publicationNamed(ptr.Elem(), publicationHostfiles, "Prepared")) { |
| + g.problem(u, field, "embedding: hostfiles Publisher or Prepared exposes staging methods") |
| + } |
| + } |
| + return true |
| + }) |
| +} |
| + |
| func (g *publicationGuard) collect(u *publicationUnit) { |
| info := u.pkg.TypesInfo |
| ast.Inspect(u.node, func(n ast.Node) bool { |
| @@ -576,14 +596,10 @@ func publicationMismatch(info *types.Info, ifs *ast.IfStmt, pkg, name string) as |
| return nil |
| } |
| -// Files publishers stage files-relative names; Of also accepts their |
| -// inventory-relative form, host+"/"+x. Only that exact, stable mapping is |
| -// recognized, never a substring occurrence of x in another expression. |
| +// Stage takes files-relative names; Of takes inventory-relative names. |
| +// Only the exact, stable mapping host+"/"+x classifies what Stage reads. |
| func (g *publicationGuard) classifiedPath(u *publicationUnit, c *ast.CallExpr, obj types.Object) bool { |
| info := u.pkg.TypesInfo |
| - if publicationObject(info, c.Args[2]) == obj { |
| - return true |
| - } |
| suffix, ok := ast.Unparen(c.Args[2]).(*ast.BinaryExpr) |
| if !ok || suffix.Op != token.ADD || publicationObject(info, suffix.Y) != obj { |
| return false |
| @@ -633,8 +649,8 @@ func (g *publicationGuard) refused(u *publicationUnit, site ast.Node, root ast.E |
| if u.body == nil { |
| return false |
| } |
| - obj := publicationObject(u.pkg.TypesInfo, root) |
| - if _, ok := ast.Unparen(root).(*ast.Ident); !ok || obj == nil || g.locals[obj] != u { |
| + obj := g.singleLocal(u, root, site.Pos()) |
| + if obj == nil { |
| return false |
| } |
| good := false |
| @@ -649,7 +665,7 @@ func (g *publicationGuard) refused(u *publicationUnit, site ast.Node, root ast.E |
| expr := publicationMismatch(u.pkg.TypesInfo, ifs, "", "") |
| c := g.checkedCall(u, expr, ifs.Cond.Pos(), publicationHostfiles, "RefuseSecretsAt") |
| if c != nil && len(c.Args) == 4 && publicationObject(u.pkg.TypesInfo, c.Args[1]) == obj && |
| - g.unchanged(obj, c.Pos(), site.End()) && g.dominates(u, ifs, site) { |
| + g.writes[obj][0].node.Pos() < c.Pos() && g.dominates(u, ifs, site) { |
| good = true |
| } |
| return true |
| @@ -657,15 +673,6 @@ func (g *publicationGuard) refused(u *publicationUnit, site ast.Node, root ast.E |
| return good |
| } |
| -func (g *publicationGuard) unchanged(obj types.Object, from, to token.Pos) bool { |
| - for _, w := range g.writes[obj] { |
| - if w.node.Pos() >= from && w.node.Pos() < to { |
| - return false |
| - } |
| - } |
| - return true |
| -} |
| - |
| func (g *publicationGuard) runSkip(u *publicationUnit, e ast.Expr) bool { |
| c, ok := ast.Unparen(e).(*ast.CompositeLit) |
| if !ok { |
| @@ -755,10 +762,11 @@ func publicationProblems(pkgs []*packages.Package) []publicationProblem { |
| for _, decl := range file.Decls { |
| switch d := decl.(type) { |
| case *ast.FuncDecl: |
| + u := &publicationUnit{pkg: pkg, name: d.Name.Name, node: d.Body, body: d.Body} |
| + g.embeddings(u, d) |
| if d.Body == nil { |
| continue |
| } |
| - u := &publicationUnit{pkg: pkg, name: d.Name.Name, node: d.Body, body: d.Body} |
| g.units = append(g.units, u) |
| g.parameter(u, d.Recv) |
| g.parameter(u, d.Type.Params) |
| @@ -766,11 +774,16 @@ func publicationProblems(pkgs []*packages.Package) []publicationProblem { |
| g.collect(u) |
| case *ast.GenDecl: |
| for _, spec := range d.Specs { |
| - v, ok := spec.(*ast.ValueSpec) |
| - if !ok { |
| + var u *publicationUnit |
| + switch v := spec.(type) { |
| + case *ast.ValueSpec: |
| + u = &publicationUnit{pkg: pkg, name: "var " + v.Names[0].Name, node: v} |
| + case *ast.TypeSpec: |
| + u = &publicationUnit{pkg: pkg, name: "type " + v.Name.Name, node: v} |
| + default: |
| continue |
| } |
| - u := &publicationUnit{pkg: pkg, name: "var " + v.Names[0].Name, node: v} |
| + g.embeddings(u, spec) |
| g.units = append(g.units, u) |
| g.collect(u) |
| } |
| @@ -815,6 +828,16 @@ func publicationProblems(pkgs []*packages.Package) []publicationProblem { |
| if call, ok := parent.(*ast.CallExpr); ok && call.Fun == e { |
| return true |
| } |
| + // A method or field name in a declaration is not a callable |
| + // value escaping to another consumer. |
| + if id, ok := e.(*ast.Ident); ok && u.pkg.TypesInfo.Defs[id] != nil { |
| + return true |
| + } |
| + if kv, ok := parent.(*ast.KeyValueExpr); ok && kv.Key == e { |
| + if field, ok := publicationObject(u.pkg.TypesInfo, e).(*types.Var); ok && field.IsField() { |
| + return true |
| + } |
| + } |
| if !g.bound[e] { |
| g.problem(u, e, "unknown callable escape") |
| } |
| @@ -866,15 +889,18 @@ func TestEveryStagingOperationIsClassified(t *testing.T) { |
| } |
| } |
| want := map[string][]string{ |
| - "clean.go": nil, |
| - "unclassified.go": {"zzUnclassified:Stage:", "zzNondominating:Stage:", "zzBypass:Stage:", "zzWrongBreak:Stage:", "zzWrongInventoryPath:Stage:"}, |
| - "ignored.go": {"zzIgnored:Stage:", "zzSwallowed:Stage:"}, |
| - "nilvar.go": {"zzNilVar:SyncDirAt:", "zzMixedSkip:SyncDirAt:", "zzUncheckedRefusal:SyncDirAt:", "zzWrongRoot:SyncDirAt:", "zzNilRun:Run:"}, |
| - "prepared.go": {"zzPrepared:Stage:", "zzPrepared:StagePlatform:", "zzRelay:StagePlatform:", "zzRelayAssign:StagePlatform:", "zzRelayZero:StagePlatform:"}, |
| - "reassign.go": {"zzReassign:Stage:", "zzReassignClass:Stage:", "zzReassignRoot:SyncDirAt:", "zzReassignHost:Stage:", "zzReassignOptions:Run:"}, |
| - "mixedalias.go": {"zzMixedAlias:mixed callable alias", "zzMixedAliasCall:SyncDirAt:", "zzMethodAlias:StagePlatform:", "zzFieldAlias:StagePlatform:", "zzPassAlias:unknown callable parameter", "zzReturnAlias:unknown callable escape", "zzSliceAlias:unknown callable escape"}, |
| - "wrapper.go": {"zzWrapper:SyncDirAt:"}, |
| - "iface.go": {"zzIface:StagePlatform:", "zzIface:StagePlatform:", "zzIfacePrepared:Stage:"}, |
| + "clean.go": nil, |
| + "unmapped.go": {"zzUnmapped:Stage:", "zzUnmapped:Stage:"}, |
| + "refusalwrites.go": {"zzRefusalLoop:SyncDirAt:", "zzRefusalClosure:SyncDirAt:", "zzRefusalPointer:SyncDirAt:"}, |
| + "embedding.go": {"type zzEmbeddedPublisher:embedding:", "type zzEmbeddedPrepared:embedding:", "zzEmbeddedLocal:embedding:", "zzEmbeddedSignature:embedding:", "zzEmbeddedSignature:embedding:"}, |
| + "unclassified.go": {"zzUnclassified:Stage:", "zzNondominating:Stage:", "zzBypass:Stage:", "zzWrongBreak:Stage:", "zzWrongInventoryPath:Stage:"}, |
| + "ignored.go": {"zzIgnored:Stage:", "zzSwallowed:Stage:"}, |
| + "nilvar.go": {"zzNilVar:SyncDirAt:", "zzMixedSkip:SyncDirAt:", "zzUncheckedRefusal:SyncDirAt:", "zzWrongRoot:SyncDirAt:", "zzNilRun:Run:"}, |
| + "prepared.go": {"zzPrepared:Stage:", "zzPrepared:StagePlatform:", "zzRelay:StagePlatform:", "zzRelayAssign:StagePlatform:", "zzRelayZero:StagePlatform:"}, |
| + "reassign.go": {"zzReassign:Stage:", "zzReassignClass:Stage:", "zzReassignRoot:SyncDirAt:", "zzReassignHost:Stage:", "zzReassignOptions:Run:"}, |
| + "mixedalias.go": {"zzMixedAlias:mixed callable alias", "zzMixedAliasCall:SyncDirAt:", "zzMethodAlias:StagePlatform:", "zzFieldAlias:StagePlatform:", "zzPassAlias:unknown callable parameter", "zzReturnAlias:unknown callable escape", "zzSliceAlias:unknown callable escape", "zzUnknownAlias:unknown callable parameter", "var zzStage:mixed callable alias"}, |
| + "wrapper.go": {"zzWrapper:SyncDirAt:"}, |
| + "iface.go": {"zzIface:StagePlatform:", "zzIface:StagePlatform:", "zzIfacePrepared:Stage:"}, |
| } |
| if len(fixtures) != len(want) { |
| t.Fatalf("loaded %d fixtures, want %d", len(fixtures), len(want)) |
| @@ -897,6 +923,9 @@ func TestEveryStagingOperationIsClassified(t *testing.T) { |
| remaining = slices.Delete(remaining, i, i+1) |
| } |
| } |
| + if len(remaining) != 0 { |
| + t.Errorf("unexpected fixture diagnostics: %v", remaining) |
| + } |
| }) |
| } |
| } |
diff --git a/internal/layout/pubclass/testdata/publication_guard/clean.go b/internal/layout/pubclass/testdata/publication_guard/clean.go| index 6132606c4..0ab4ef43b 100644 |
| --- a/internal/layout/pubclass/testdata/publication_guard/clean.go |
| +++ b/internal/layout/pubclass/testdata/publication_guard/clean.go |
| @@ -11,7 +11,7 @@ import ( |
| func zzClean(ctx context.Context, p *hostfiles.Publisher, q *hostfiles.Prepared, root *os.File, host, path string) error { |
| x := path |
| - if c := pubclass.Of(pubclass.Nested, host, x, false); c != pubclass.App { |
| + if c := pubclass.Of(pubclass.Nested, host, host+"/"+x, false); c != pubclass.App { |
| return nil |
| } |
| if err := p.Stage(ctx, x, nil, 0600, false); err != nil { |
| @@ -52,7 +52,7 @@ func zzCleanRefusal(ctx context.Context, p *hostfiles.Publisher, root *os.File, |
| func zzCleanLoop(ctx context.Context, p *hostfiles.Publisher, host string, paths []string) error { |
| for _, x := range paths { |
| - if pubclass.Of(pubclass.Nested, host, x, false) != pubclass.App { |
| + if pubclass.Of(pubclass.Nested, host, host+"/"+x, false) != pubclass.App { |
| continue |
| } |
| if err := p.Stage(ctx, x, nil, 0600, false); err != nil { |
| @@ -80,7 +80,7 @@ func zzCleanOtherCalls(ctx context.Context, p *hostfiles.Publisher, root *os.Fil |
| func zzCleanBreak(ctx context.Context, p *hostfiles.Publisher, host string, paths []string) error { |
| for _, x := range paths { |
| - if pubclass.Of(pubclass.Nested, host, x, false) != pubclass.App { |
| + if pubclass.Of(pubclass.Nested, host, host+"/"+x, false) != pubclass.App { |
| break |
| } |
| if err := p.Stage(ctx, x, nil, 0600, false); err != nil { |
diff --git a/internal/layout/pubclass/testdata/publication_guard/embedding.go b/internal/layout/pubclass/testdata/publication_guard/embedding.go| new file mode 100644 |
| index 000000000..cc341fdcd |
| --- /dev/null |
| +++ b/internal/layout/pubclass/testdata/publication_guard/embedding.go |
| @@ -0,0 +1,18 @@ |
| +package host |
| + |
| +import "github.com/carlosframework/platform/internal/hostfiles" |
| + |
| +type zzEmbeddedPublisher struct{ *hostfiles.Publisher } |
| +type zzEmbeddedPrepared struct{ *hostfiles.Prepared } |
| + |
| +func zzEmbeddedLocal() { |
| + _ = struct{ *hostfiles.Publisher }{} |
| +} |
| + |
| +func zzEmbeddedSignature(in struct { |
| + *hostfiles.Publisher |
| +}) (out struct { |
| + *hostfiles.Prepared |
| +}) { |
| + return |
| +} |
diff --git a/internal/layout/pubclass/testdata/publication_guard/ignored.go b/internal/layout/pubclass/testdata/publication_guard/ignored.go| index 612ad9285..d94f48bd1 100644 |
| --- a/internal/layout/pubclass/testdata/publication_guard/ignored.go |
| +++ b/internal/layout/pubclass/testdata/publication_guard/ignored.go |
| @@ -8,12 +8,12 @@ import ( |
| func zzIgnored(ctx context.Context, p *hostfiles.Publisher, host, path string) error { |
| x := path |
| - pubclass.Of(pubclass.Nested, host, x, false) |
| + pubclass.Of(pubclass.Nested, host, host+"/"+x, false) |
| return p.Stage(ctx, x, nil, 0600, false) |
| } |
| func zzSwallowed(ctx context.Context, p *hostfiles.Publisher, host, path string) error { |
| x := path |
| - if pubclass.Of(pubclass.Nested, host, x, false) != pubclass.App { |
| + if pubclass.Of(pubclass.Nested, host, host+"/"+x, false) != pubclass.App { |
| _ = x |
| } |
| return p.Stage(ctx, x, nil, 0600, false) |
diff --git a/internal/layout/pubclass/testdata/publication_guard/reassign.go b/internal/layout/pubclass/testdata/publication_guard/reassign.go| index 688317678..baf0ef22c 100644 |
| --- a/internal/layout/pubclass/testdata/publication_guard/reassign.go |
| +++ b/internal/layout/pubclass/testdata/publication_guard/reassign.go |
| @@ -9,7 +9,7 @@ import ( |
| func zzReassign(ctx context.Context, p *hostfiles.Publisher, host, path string) error { |
| x := path |
| - if c := pubclass.Of(pubclass.Nested, host, x, false); c != pubclass.App { |
| + if c := pubclass.Of(pubclass.Nested, host, host+"/"+x, false); c != pubclass.App { |
| return nil |
| } |
| x = host + ".env" |
| @@ -17,7 +17,7 @@ func zzReassign(ctx context.Context, p *hostfiles.Publisher, host, path string) |
| } |
| func zzReassignClass(ctx context.Context, p *hostfiles.Publisher, host, path string) error { |
| x := path |
| - c := pubclass.Of(pubclass.Nested, host, x, false) |
| + c := pubclass.Of(pubclass.Nested, host, host+"/"+x, false) |
| c = pubclass.App |
| if c != pubclass.App { |
| return nil |
diff --git a/internal/layout/pubclass/testdata/publication_guard/refusalwrites.go b/internal/layout/pubclass/testdata/publication_guard/refusalwrites.go| new file mode 100644 |
| index 000000000..4ece51f3e |
| --- /dev/null |
| +++ b/internal/layout/pubclass/testdata/publication_guard/refusalwrites.go |
| @@ -0,0 +1,41 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "github.com/carlosframework/platform/internal/hostfiles" |
| + "github.com/carlosframework/platform/internal/layout/pubclass" |
| + "os" |
| +) |
| + |
| +func zzRefusalLoop(ctx context.Context, p *hostfiles.Publisher, root, other *os.File, host string) error { |
| + if err := hostfiles.RefuseSecretsAt(ctx, root, pubclass.Nested, host); err != nil { |
| + return err |
| + } |
| + for range 2 { |
| + if _, err := hostfiles.SyncDirAt(ctx, p, root, nil); err != nil { |
| + return err |
| + } |
| + root = other |
| + } |
| + return nil |
| +} |
| + |
| +func zzRefusalClosure(ctx context.Context, p *hostfiles.Publisher, root, other *os.File, host string) error { |
| + reset := func() { root = other } |
| + if err := hostfiles.RefuseSecretsAt(ctx, root, pubclass.Nested, host); err != nil { |
| + return err |
| + } |
| + reset() |
| + _, err := hostfiles.SyncDirAt(ctx, p, root, nil) |
| + return err |
| +} |
| + |
| +func zzRefusalPointer(ctx context.Context, p *hostfiles.Publisher, root, other *os.File, host string) error { |
| + ptr := &root |
| + if err := hostfiles.RefuseSecretsAt(ctx, root, pubclass.Nested, host); err != nil { |
| + return err |
| + } |
| + *ptr = other |
| + _, err := hostfiles.SyncDirAt(ctx, p, root, nil) |
| + return err |
| +} |
diff --git a/internal/layout/pubclass/testdata/publication_guard/unclassified.go b/internal/layout/pubclass/testdata/publication_guard/unclassified.go| index 149b91cbe..99f322f2d 100644 |
| --- a/internal/layout/pubclass/testdata/publication_guard/unclassified.go |
| +++ b/internal/layout/pubclass/testdata/publication_guard/unclassified.go |
| @@ -8,7 +8,7 @@ import ( |
| func zzUnclassified(ctx context.Context, p *hostfiles.Publisher, host, path, other string) error { |
| x := path |
| - if c := pubclass.Of(pubclass.Nested, host, x, false); c != pubclass.App { |
| + if c := pubclass.Of(pubclass.Nested, host, host+"/"+x, false); c != pubclass.App { |
| return nil |
| } |
| if err := p.Stage(ctx, x, nil, 0600, false); err != nil { |
| @@ -20,7 +20,7 @@ func zzUnclassified(ctx context.Context, p *hostfiles.Publisher, host, path, oth |
| func zzNondominating(ctx context.Context, p *hostfiles.Publisher, host, path string, check bool) error { |
| x := path |
| if check { |
| - if pubclass.Of(pubclass.Nested, host, x, false) != pubclass.App { |
| + if pubclass.Of(pubclass.Nested, host, host+"/"+x, false) != pubclass.App { |
| return nil |
| } |
| } |
| @@ -31,7 +31,7 @@ func zzBypass(ctx context.Context, p *hostfiles.Publisher, host, path string, by |
| if bypass { |
| goto stage |
| } |
| - if pubclass.Of(pubclass.Nested, host, x, false) != pubclass.App { |
| + if pubclass.Of(pubclass.Nested, host, host+"/"+x, false) != pubclass.App { |
| return nil |
| } |
| stage: |
| @@ -40,7 +40,7 @@ stage: |
| func zzWrongBreak(ctx context.Context, p *hostfiles.Publisher, host, path string) error { |
| x := path |
| for { |
| - if pubclass.Of(pubclass.Nested, host, x, false) != pubclass.App { |
| + if pubclass.Of(pubclass.Nested, host, host+"/"+x, false) != pubclass.App { |
| break |
| } |
| break |
diff --git a/internal/layout/pubclass/testdata/publication_guard/unmapped.go b/internal/layout/pubclass/testdata/publication_guard/unmapped.go| new file mode 100644 |
| index 000000000..827262fd7 |
| --- /dev/null |
| +++ b/internal/layout/pubclass/testdata/publication_guard/unmapped.go |
| @@ -0,0 +1,18 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "github.com/carlosframework/platform/internal/hostfiles" |
| + "github.com/carlosframework/platform/internal/layout/pubclass" |
| +) |
| + |
| +func zzUnmapped(ctx context.Context, p *hostfiles.Publisher, q *hostfiles.Prepared, host string) error { |
| + x := "instance.key" |
| + if pubclass.Of(pubclass.Nested, host, x, false) != pubclass.App { |
| + return nil |
| + } |
| + if err := p.Stage(ctx, x, nil, 0600, false); err != nil { |
| + return err |
| + } |
| + return q.Stage(ctx, x, nil, 0600) |
| +} |
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 d778925ac..4ab499166 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-durability-3a-escrow.tsv |
| @@ -73,7 +73,7 @@ internal/activator/instancekey.go ExecBackend.BackfillInstanceKey legacy accepte |
| internal/activator/instancekey.go ExecBackend.ensureInstanceKeyAt legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: after the unchanged replica and fenced/conflict checks, asks haMintGuard(ctx, rt) (+whole:Route) and hands the guard to ensureInstanceKey; a classification error fails with InstanceKeyFailed; a non-HA host gets a nil guard and mints exactly as before; only adds a refusal;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: asks mintGuardFor(ctx, rt) (was haMintGuard): an HA host's guard as before; an eligible host's escrowMintGuard, which on a ready box reads the bucket manifest and the sealed env item when a mint is next and refuses while the escrow holds the key, and on a box that is not ready refuses every mint; nil for any other host, which mints as before. The replica and fenced/conflict refusals are unchanged; only adds refusals Fix round 1: asks mintGuardWith(ctx, rt, !create): a launch's ensure shares its preparation's escrow read, the backfill's reads the bucket afresh; only refuses. registry:Host@598,registry:Replica@159,whole:Route@491,whole:Route@667 5605bd1a4441859415f51b50c38e959987b2524fa8ccbec7364949e7097e9770 |
| internal/activator/instancekey.go ensureInstanceKey legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more parameter, guard (nil for every caller but ensureInstanceKeyAt on an HA host), asked once the locked read finds no key and the bucket allows a mint, before anything is minted; its refusal returns InstanceKeyFailed with nothing written. Create-only, fail-closed and defer-on-unknown are unchanged; the one site unchanged, no read added; only adds a refusal;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 4: the guard is asked with InstanceKeyVar, at the same point (the locked read found no key and the bucket allowed a mint); create-only, fail-closed and defer-on-unknown unchanged; the same one site; only adds a refusal file:Stat@4816 2d53f8246ac317c066d4b804cdc251aaf60abbd4423c6b780f0cbee227203fc8 |
| internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. file:Exec@17444,file:Open@1150,file:Statfs@43158,registry:App@11199,whole:Route@11191,whole:Route@27377 d4c92bfae3a3a3cc174c0cd9876bf1055eba80ca525a70e7ca05b16cb0023bff |
| -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. file:Stat@1343,file:Stat@604 8b3169518a586c07106c0015db56d7dfc308ece3b5f42be45949a27ce4ea7faa |
| +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. file:Stat@1497,file:Stat@761 7ad83fe3e76838280c03cb9189cb3d7b758a2cd861d6fe4947ae4f46d7a08f39 |
| internal/host/movesfiles.go movesFiles.Establish authority C,J4 rev3=PROPOSED-p3;run=12;basis=agent files preparation; retains seed admitted-writer and ordinary origin proof with one C8 commit; H3 is inventory bookkeeping, C owns the enabled effect;rev3=census-ruling-durability-3a-escrow;basis=Durability 3a Task 5 (parked path, host claims only): a present env file (claimEnvPresent: nested via instancefs.OpenBeneathOrAbsent, flat via Lstat; the bytes are never read) refuses with pubclass.ErrSecretPath before any bucket write; the env bytes are no longer read (readClaimEnvFile deleted); with no env file the establishment proceeds and stages StagePlatformDelete(EnvItem), so a raw env item a baseline holds is dropped, never carried into the new generation; openPrepared no longer takes the env and establishedOver no longer GETs an env object. Only refuses more, and reads less. df33d8996c148bf34cdb6d5a59ac73137498beab31c561d926e3d19c59856a27 |
| internal/host/relocationflush.go ReleaseFlushFiles.Flush legacy accepted-legacy accepted-legacy;rev3=PROPOSED-seed;basis=census-ruling-FS-R6; tenant files and env are published data, never authority;rev3=census-ruling-durability-3a-escrow;basis=Durability 3a Task 5 (parked path, host claims only): the env file's presence is decided first with instancefs.OpenBeneathOrAbsent (the bytes are never read, replacing readInstanceFile of the env): present refuses with pubclass.ErrSecretPath before the manifest is read; hostfiles.RefuseSecretsAt over the root it opened, after the tenant seam and before hostfiles.Seed; absent still stages the env item's delete. Only refuses more, and reads less. file:Open@1428 076b8778ed1ca1052499a7432df959a9941cf8ea41e20c50a210c83a56f5c285 |
| 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 |
| @@ -144,7 +144,7 @@ internal/activator/paths.go ExecBackend.pathsFor legacy accepted-legacy accepted |
| @remove internal/host/schedule_wiring.go scheduleHostHA |
| @removed internal/host/schedule_wiring.go scheduleHostHA H3 census-ruling-durability-3a-escrow;absent;basis=durability 3a Task 4: renamed to scheduleHostEscrowed (on this card), asking SecretsEscrowed instead of IsHA |
| @coverage internal/activator 9a5b7bf16692f6a58bc6c8449372dd9001648b3246f25d6dfa73b80c58041055 |
| -@coverage internal/host 28a020a40fbfb1e0f39c49c02994e8b4619ed77f4e3afe2cda96696ff4ab1174 |
| +@coverage internal/host b6a9db2ad78f4f60e6038e876c67d8c26e0f405b52f48a842cbc1b58fdb3926f |
| @coverage internal/hostfiles d79efb83d55025d18980240619281b671b8b928d72461aaefda686fbfa3ae68c |
| @coverage internal/layout f845fa728b0935279454d8b01023c5d6dae1c985061a41229cf0686e829f5c12 |
| @coverage internal/layout/pubclass bd3938f002a5dca044378b71670e904736653d4914a8b1e06275e2b4dc79ed67 |