claim census: keep both pointer-digest ratchets and install-control's lock
platform-d8's harness stopped step 8.2 on root's #253 ratchet (/opt/carlos/pointer-digests) and on .claims-activation.lock, which 8.2's own install-control leaves in /etc/systemd/system before journal-migrate. Both ratchets become shared trees of box state and the lock a shared regular file in the unit directory root. Moving a ratchet aside would weaken anti-rollback for every channel in it. Census overlay claim-harness-census, proposed to platform-1e.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 files changed,
+108
−1
docs/superpowers/notes/census-proposal-claim-step8-readiness.md+36 −0internal/host/activation_install_linux.go+1 −1internal/host/claimcensus.go+15 −0internal/host/claimcensus_migration_linux_test.go+45 −0internal/provision/plan14_root_reads_test.go+7 −0internal/provision/testdata/plan14-root-reads-claim-harness-census.tsv+4 −0
CI passed — run details
diff --git a/docs/superpowers/notes/census-proposal-claim-step8-readiness.md b/docs/superpowers/notes/census-proposal-claim-step8-readiness.md| index a07e47745..8ea1062c0 100644 |
| --- a/docs/superpowers/notes/census-proposal-claim-step8-readiness.md |
| +++ b/docs/superpowers/notes/census-proposal-claim-step8-readiness.md |
| @@ -102,3 +102,39 @@ Ruling 6: `prepareRootFloorDirs` is still called only from `migrateRootClaimAuth |
| Envelope re-pinned: `internal/host`. `prepareRootFloorDirsOwned` gains the walk's base as a parameter and has no read site of its own. |
| 9B8: no record write changes. |
| + |
| +## Harness census |
| + |
| +Status: PROPOSED to platform-1e. platform-d8's deployment harness stopped 8.2 twice on 2026-10-20, each time on box state with no installation behind it. It would stop the same way on dev. |
| + |
| +- `opt` entry `pointer-digests/bab/claimtrial/edge.digests`: root's #253 ratchet (`release.RootRatchetDir`). |
| +- `units` entry `.claims-activation.lock`: install-control's lock (`activationLock`). Step 8.2 runs install-control before journal-migrate, so this lock is always present. |
| + |
| +The edge's ratchet under the data root (`release.EdgeRatchetDir`) was the stop before both. The trial ruled it a B2 move-aside (#324). |
| + |
| +The fix classifies all three as box state the census keeps. The re-pins are in a new overlay, `internal/provision/testdata/plan14-root-reads-claim-harness-census.tsv`, loaded last and marked `rev3=PROPOSED-claim-harness-census`. It adds no accepted-legacy row, so the seal stands. |
| + |
| +- **Ratchets.** Both directories are shared trees: directories and regular files only, so a symlink anywhere in either refuses. |
| + - A mark is one file per channel (`<acct>/<app>/<channel>.digests`). Marks are never cleared and never adopted. |
| + - Root and the agent each read both trees. Moving either tree aside would weaken #253 for every channel it holds, and moving both would reset it. Keeping them is the only safe answer for a populated box, and this closes #324's code half. |
| +- **Activation lock.** It is a shared regular file for that exact name in the unit directory root only. The same name in a drop-in directory still refuses. |
| + - The lock stays where it is. Unlinking a flocked file would let a second installer lock a fresh inode beside the first, and moving it would let an older binary lock the old place. |
| + - `activationLock` now names it through the constant `activationLockName`. The value is unchanged. |
| + |
| +Ruling 6: `claimGlobalSharedPaths` is reached only from the claim assembly, root's empty-installation census and the migration census. A claims-off or no-census box sees no change. |
| + |
| +| Unit | Change | Class | Executing identity | |
| +|---|---|---|---| |
| +| `internal/host/activation_install_linux.go` `activationLock` | re-pinned: the lock name is the constant | authority G,J4 (unchanged) | explicit operator CLI, uid 0 | |
| +| `internal/host/claimcensus.go` `claimUnitCensus` | re-pinned: adds `CensusFile(".claims-activation.lock")` | authority C,G,J4 (unchanged) | root installation admission controller, uid 0 | |
| + |
| +`claimOptCensus` and `claimBoxDataCensus` have no read site of their own (envelope only). Envelope re-pinned: `internal/host`. |
| + |
| +9B8: no record write changes. |
| + |
| +Tests: `TestMigrationCensusKeepsRatchetsAndActivationLock` reproduces each harness refusal verbatim when its class is removed (mutation-checked one class at a time). `TestMigrationCensusRefusesOutsideLeosClasses` gains four cases: |
| + |
| +- a symlink in root's ratchet; |
| +- a symlink in the edge's ratchet; |
| +- the lock replaced by a link; |
| +- the lock inside a drop-in directory. |
diff --git a/internal/host/activation_install_linux.go b/internal/host/activation_install_linux.go| index 6e09a2db9..0aeac5538 100644 |
| --- a/internal/host/activation_install_linux.go |
| +++ b/internal/host/activation_install_linux.go |
| @@ -93,7 +93,7 @@ func activationRead(path string, private bool) ([]byte, error) { |
| return activationReadAt(dir, filepath.Base(path), private) |
| } |
| func activationLock(dir *os.File) (*os.File, error) { |
| - f, err := safefile.OpenFileAt(int(dir.Fd()), ".claims-activation.lock", os.O_CREATE|os.O_RDWR, 0600) |
| + f, err := safefile.OpenFileAt(int(dir.Fd()), activationLockName, os.O_CREATE|os.O_RDWR, 0600) |
| if err != nil { |
| return nil, err |
| } |
diff --git a/internal/host/claimcensus.go b/internal/host/claimcensus.go| index 06c2abd47..db55329de 100644 |
| --- a/internal/host/claimcensus.go |
| +++ b/internal/host/claimcensus.go |
| @@ -14,6 +14,10 @@ import ( |
| "github.com/carlosframework/platform/internal/rollout" |
| ) |
| +// activationLockName is the lock install-control and its siblings hold in |
| +// the directory they install into (activationLock). |
| +const activationLockName = ".claims-activation.lock" |
| + |
| // claimGlobalSharedPaths is the empty-installation census's classification |
| // of what the box's own installers put under the managed roots (host |
| // lifecycle claim P6-D2: shared release directories, shared unit templates |
| @@ -81,6 +85,10 @@ func claimBoxDataCensus(dataDir string) []string { |
| // The edge's autocert cache: certificates and keys, the ACME account |
| // key (edge.go's -acme-cache default; bootstrap makes the directory). |
| hostbox.CensusTree(rel(filepath.Join(dataDir, "acme"))), |
| + // The agent's and edge's pointer-digest ratchet (#253): one mark per |
| + // channel, <acct>/<app>/<channel>.digests. Box anti-rollback state, |
| + // never cleared and never an installation artifact (#324). |
| + hostbox.CensusTree(rel(release.EdgeRatchetDir(dataDir))), |
| } |
| for _, path := range []string{ |
| filepath.Join(dataDir, stageRequestMarker), // the agent's root stage request |
| @@ -118,6 +126,9 @@ func claimOptCensus(optDir string) []string { |
| // The shared release store: <opt>/versions/<ver>/[<acct>/]<app>. |
| // Directories and regular files only; a symlink in it is refused. |
| hostbox.CensusTree(claimCensusRel(optDir, filepath.Dir(filepath.Dir(release.VersionPath(optDir, "", "v", "a"))))), |
| + // Root's pointer-digest ratchet (#253), the same marks as the edge's |
| + // under the data root; root reads both, so neither is moved aside. |
| + hostbox.CensusTree(claimCensusRel(optDir, release.RootRatchetDir(optDir))), |
| } |
| // Root's self-update state and the host-floor guard copy. Both are box |
| // state below one parent; it is opaque to the census, as before. |
| @@ -159,6 +170,10 @@ func claimUnitCensus(unitsDir string) []string { |
| for _, unit := range []string{"carlos-edge.service", "carlos-system-update.service", "carlos-system-recover.service"} { |
| entries = append(entries, hostbox.CensusFile(unit+".d/90-host-floor.conf")) |
| } |
| + // install-control's lock (activationLock), left in the unit directory |
| + // after it runs. It stays: unlinking a flocked file lets a second |
| + // installer lock a fresh inode beside the first. |
| + entries = append(entries, hostbox.CensusFile(activationLockName)) |
| for _, unit := range claimCensusEnabledUnits() { |
| if !slices.Contains(names, unit) || strings.Contains(unit, "@") { |
| continue |
diff --git a/internal/host/claimcensus_migration_linux_test.go b/internal/host/claimcensus_migration_linux_test.go| index 7676d16f2..130ea9ebe 100644 |
| --- a/internal/host/claimcensus_migration_linux_test.go |
| +++ b/internal/host/claimcensus_migration_linux_test.go |
| @@ -16,6 +16,7 @@ import ( |
| "github.com/carlosframework/platform/internal/hostops" |
| "github.com/carlosframework/platform/internal/provision" |
| "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| ) |
| const ( |
| @@ -168,6 +169,31 @@ func TestMigrationCensusClassifiesLeosTree(t *testing.T) { |
| } |
| } |
| +// The harness's 8.2 stops (2026-10-20): both pointer-digest ratchets and |
| +// install-control's lock, which 8.2 leaves in the unit directory before |
| +// journal-migrate runs, are box state the census keeps. |
| +func TestMigrationCensusKeepsRatchetsAndActivationLock(t *testing.T) { |
| + c := newLeoCensusTree(t) |
| + leoRatchetMarks(t, c) |
| + if err := c.check(t, allWindowUnits()); err != nil { |
| + t.Fatalf("ratchets and activation lock: %v", err) |
| + } |
| +} |
| + |
| +// leoRatchetMarks adds claimtrial's marks to root's and the edge's |
| +// ratchets, and install-control's lock to the unit directory. |
| +func leoRatchetMarks(t *testing.T, c *leoCensusTree) { |
| + t.Helper() |
| + for _, dir := range []string{release.RootRatchetDir(c.roots["opt"]), release.EdgeRatchetDir(c.roots["data"])} { |
| + app := filepath.Join(dir, "bab", "claimtrial") |
| + if err := os.MkdirAll(app, 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + leoWrite(t, filepath.Join(app, "edge.digests")) |
| + } |
| + leoWrite(t, filepath.Join(c.roots["units"], activationLockName)) |
| +} |
| + |
| // Each class is exact: one entry outside it refuses, naming the entry. |
| func TestMigrationCensusRefusesOutsideLeosClasses(t *testing.T) { |
| for name, mutate := range map[string]func(*testing.T, *leoCensusTree){ |
| @@ -183,6 +209,25 @@ func TestMigrationCensusRefusesOutsideLeosClasses(t *testing.T) { |
| "a symlink in the certificate cache": func(t *testing.T, c *leoCensusTree) { |
| leoLink(t, "/etc/passwd", filepath.Join(c.roots["data"], "acme", "escape")) |
| }, |
| + "a symlink in root's ratchet": func(t *testing.T, c *leoCensusTree) { |
| + leoRatchetMarks(t, c) |
| + leoReplaceWithLink(t, filepath.Join(release.RootRatchetDir(c.roots["opt"]), "bab", "claimtrial", "edge.digests"), "/etc/passwd") |
| + }, |
| + "a symlink in the edge's ratchet": func(t *testing.T, c *leoCensusTree) { |
| + leoRatchetMarks(t, c) |
| + leoReplaceWithLink(t, filepath.Join(release.EdgeRatchetDir(c.roots["data"]), "bab", "claimtrial", "edge.digests"), "/etc/passwd") |
| + }, |
| + "the activation lock replaced by a link": func(t *testing.T, c *leoCensusTree) { |
| + leoRatchetMarks(t, c) |
| + leoReplaceWithLink(t, filepath.Join(c.roots["units"], activationLockName), "/etc/passwd") |
| + }, |
| + "an activation lock in a drop-in directory": func(t *testing.T, c *leoCensusTree) { |
| + dir := filepath.Join(c.roots["units"], "carlos-edge.service.d") |
| + if err := os.MkdirAll(dir, 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + leoWrite(t, filepath.Join(dir, activationLockName)) |
| + }, |
| "an unknown box file": func(t *testing.T, c *leoCensusTree) { |
| leoWrite(t, filepath.Join(c.roots["data"], "new-marker")) |
| }, |
diff --git a/internal/provision/plan14_root_reads_test.go b/internal/provision/plan14_root_reads_test.go| index 3803056b8..13579404a 100644 |
| --- a/internal/provision/plan14_root_reads_test.go |
| +++ b/internal/provision/plan14_root_reads_test.go |
| @@ -985,6 +985,13 @@ func TestPlan14RootReadCensus(t *testing.T) { |
| if err = loadRootReadInventory(filepath.Join(root, "internal/provision/testdata/plan14-root-reads-claim-rootaws-sentinel.tsv"), &inv, true); err != nil { |
| t.Fatal(err) |
| } |
| + // Census overlay claim-harness-census (the migration census keeps both |
| + // pointer-digest ratchets and install-control's activation lock, the |
| + // deployment harness's 8.2 stops), loaded last. Proposed to platform-1e; |
| + // no accepted-legacy row, so the seal stands. |
| + if err = loadRootReadInventory(filepath.Join(root, "internal/provision/testdata/plan14-root-reads-claim-harness-census.tsv"), &inv, true); err != nil { |
| + t.Fatal(err) |
| + } |
| errs := append(compareRootReads(got, inv), checkRootReadLegacy(inv, seal)...) |
| errs = append(errs, checkRootReadDeclarations(got, inv)...) |
| if len(errs) > 0 { |
diff --git a/internal/provision/testdata/plan14-root-reads-claim-harness-census.tsv b/internal/provision/testdata/plan14-root-reads-claim-harness-census.tsv| new file mode 100644 |
| index 000000000..7ef805b70 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-claim-harness-census.tsv |
| @@ -0,0 +1,4 @@ |
| +# Census overlay claim-harness-census (platform-d8 deployment harness, 8.2 stops on 2026-10-20): the migration census keeps both pointer-digest ratchets (#253 marks; root's under <opt>/pointer-digests, the edge's under <data>/pointer-digests) as shared trees of box state, and install-control's .claims-activation.lock as a shared regular file in the unit directory root, so 8.2 no longer refuses on state it leaves itself or on anti-rollback marks no installation owns. activationLock names its lock through activationLockName (new constant, same value). No new read, no class change: the two rows below are re-pinned at their classes. |
| +@coverage internal/host 416f269062671d6e065a6250ecafbdee0c845be1da878b0cb8854e886adb8d5f |
| +internal/host/activation_install_linux.go activationLock authority G,J4 rev3=PROPOSED-claim-harness-census;identity=explicit operator CLI uid 0;basis=opens protected activation lock at checked directory, requires root-owned mode 0600 and takes exclusive nonblocking flock; the lock name is now the activationLockName constant, unchanged file:Fstat@217 2172dc398960891e0101bb719b2ebaa5b02d44e7e204a833897f5ad2e38db01d |
| +internal/host/claimcensus.go claimUnitCensus authority C,G,J4 rev3=PROPOSED-claim-harness-census;identity=root installation admission controller uid 0;basis=classifies the three exact guard-arm platform drop-in files and the exact activation lock name in the unit directory root as shared regular files alongside shipped units; a lock in a drop-in directory, unknown drop-ins, per-host artifacts and symlinks remain refused file:ReadFile@1029 b14864933fa08617d3eb38ada45335e27e3ecdac7476e7a538dd32d67ff60659 |