generation census: journal-migrate's own registry child passes the root-task rule
platform-d8's harness stopped step 8.2 a fourth time: the retired- generation kernel census refused journal-migrate's own service-user registry child, which from an operator shell sits in no service. Only when journal-migrate runs it does a direct child of its pid pass the root-task rule, untrusted: same namespaces, every reference check and the start-time re-read still apply. procStatParent is now the one ppid parser the quiesce scan and the census share. Census overlay claim-own-child, proposed to platform-d8; overlay claim-harness-census marked ruled (platform-d8, H1 to H4).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
10 files changed,
+145
−9
docs/superpowers/notes/census-proposal-claim-step8-readiness.md+38 −1internal/host/claimjournal_migration_linux.go+13 −2internal/host/plan14_generation_kernel_linux_test.go+53 −0internal/host/rootgeneration_census_linux.go+1 −1internal/host/rootgeneration_inventory.go+10 −0internal/host/rootgeneration_kernel_linux.go+9 −0internal/host/rootmigration_production_linux.go+3 −1internal/provision/plan14_root_reads_test.go+9 −2internal/provision/testdata/plan14-root-reads-claim-harness-census.tsv+2 −2internal/provision/testdata/plan14-root-reads-claim-own-child.tsv+7 −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 8ea1062c0..4dfb60d9d 100644 |
| --- a/docs/superpowers/notes/census-proposal-claim-step8-readiness.md |
| +++ b/docs/superpowers/notes/census-proposal-claim-step8-readiness.md |
| @@ -105,7 +105,7 @@ Envelope re-pinned: `internal/host`. `prepareRootFloorDirsOwned` gains the walk' |
| ## 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. |
| +Status: RULED (platform-d8, 2026-10-20): accepted as proposed (H1 to H4); Astra approved 8a313548..5efe8763 with no findings. platform-1e had left; platform-d8 ruled. 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. |
| @@ -138,3 +138,40 @@ Tests: `TestMigrationCensusKeepsRatchetsAndActivationLock` reproduces each harne |
| - a symlink in the edge's ratchet; |
| - the lock replaced by a link; |
| - the lock inside a drop-in directory. |
| + |
| +## Own child |
| + |
| +Status: PROPOSED to platform-d8. The harness's fourth 8.2 stop was `/proc/<pid>/task/<pid>: service: permission denied`. It comes from the retired-generation kernel census, which journal-migrate runs after the migration census. The census refused journal-migrate's own service-user registry child: uid 989, with journal-migrate as its parent. The root-task rule accepts a non-root task only inside a service whose ExecStart selects the running binary, and from an SSM or ssh root shell the child is in none. The quiesce scan had the same defect (G7, fixed at 465c3a08). |
| + |
| +The re-pins are in a new overlay, `internal/provision/testdata/plan14-root-reads-claim-own-child.tsv`, loaded last and marked `rev3=PROPOSED-claim-own-child`. It adds no accepted-legacy row, so the seal stands. |
| + |
| +- **The rule.** `generationKernel` gains `parent`. When it is set, a non-root, non-kernel task whose `/proc` stat ppid equals it passes the root-task rule. |
| +- **What still applies.** The child is not trusted: |
| + - its mount and pid namespaces must equal the census's own; |
| + - its exe, cwd, root, descriptors, mappings and mounts pass every reference check; |
| + - the closing stat re-read must give the same start time. |
| +- **Who sets it.** Only journal-migrate does, through the context value `generationCensusParentKey`, holding its own pid. Every other caller of `productionGenerationKernelCensus` passes zero, so the rule is exactly as before. The registry child runs the same pinned binary, spawns nothing, and is waited for on cleanup (Astra's quiesce review). |
| +- **One parser.** `procStatParent` parses the ppid after the last `)` and is shared by `procParent` (the quiesce scan) and the census, so the two own-child rules cannot drift. |
| + |
| +Ruling 6: only `migrateRootClaimAuthority` sets the parent, and it runs only in claim migration. |
| + |
| +| Unit | Change | Class | |
| +|---|---|---| |
| +| `internal/host/rootgeneration_kernel_linux.go` `generationKernel.task` | the own-child pass for the root-task rule, untrusted | authority E2 (unchanged) | |
| +| `internal/host/rootgeneration_kernel_linux.go` `type generationKernel` | adds `parent` (declaration) | authority E2 (unchanged) | |
| +| `internal/host/rootgeneration_census_linux.go` `productionGenerationKernelCensus` | passes `generationCensusParent(ctx)` (declaration) | authority E2 (unchanged) | |
| +| `internal/host/rootmigration_production_linux.go` `migrateRootClaimAuthority` | sets the parent to its own pid | authority G,J4,E3 (unchanged) | |
| +| `internal/host/claimjournal_migration_linux.go` `procParent` | parse moved into `procStatParent` | authority C,G,J4 (unchanged) | |
| + |
| +Envelope re-pinned: `internal/host`. 9B8: no record write changes. |
| + |
| +Tests: |
| + |
| +- `TestPlan14GenerationCensusAcceptsOwnChildOnly` accepts a uid 989 child of the parent when its service lookup fails, which is the harness's case. It refuses with no parent and with another parent. With the right parent, it still refuses on any of these: |
| + - an exe on the retired binary; |
| + - a descriptor or mapping into it; |
| + - a foreign mount namespace; |
| + - a bound tree mount. |
| + |
| + With the rule removed, the accept case fails with the harness's exact error. |
| +- `TestProcStatParent` covers comms containing `)` and newlines, and malformed lines. |
diff --git a/internal/host/claimjournal_migration_linux.go b/internal/host/claimjournal_migration_linux.go| index c6c6979a8..a62b5edb6 100644 |
| --- a/internal/host/claimjournal_migration_linux.go |
| +++ b/internal/host/claimjournal_migration_linux.go |
| @@ -8,6 +8,7 @@ import ( |
| "encoding/hex" |
| "encoding/json" |
| "errors" |
| + "fmt" |
| "log" |
| "os" |
| "os/exec" |
| @@ -352,14 +353,24 @@ func procParent(statPath string) (int, error) { |
| if err != nil { |
| return 0, err |
| } |
| + ppid, err := procStatParent(raw) |
| + if err != nil { |
| + return 0, fmt.Errorf("%s: %w", statPath, err) |
| + } |
| + return ppid, nil |
| +} |
| + |
| +// procStatParent parses the ppid from a /proc stat line. The quiesce scan |
| +// and the generation census share it, so their own-child rule is one rule. |
| +func procStatParent(raw []byte) (int, error) { |
| s := string(raw) |
| i := strings.LastIndexByte(s, ')') |
| if i < 0 { |
| - return 0, errors.New("malformed " + statPath) |
| + return 0, errors.New("malformed stat") |
| } |
| fields := strings.Fields(s[i+1:]) |
| if len(fields) < 2 { |
| - return 0, errors.New("malformed " + statPath) |
| + return 0, errors.New("malformed stat") |
| } |
| return strconv.Atoi(fields[1]) |
| } |
diff --git a/internal/host/plan14_generation_kernel_linux_test.go b/internal/host/plan14_generation_kernel_linux_test.go| index 687efe2d0..57b5db72d 100644 |
| --- a/internal/host/plan14_generation_kernel_linux_test.go |
| +++ b/internal/host/plan14_generation_kernel_linux_test.go |
| @@ -335,3 +335,56 @@ func TestPlan14GenerationServiceLookupKeepsStrictRootScan(t *testing.T) { |
| }) |
| } |
| } |
| + |
| +// journal-migrate's own service-user registry child (harness 8.2, |
| +// 2026-10-20): from an operator shell it sits in no service, so the root-task |
| +// rule refused it. A direct child of the census's parent passes that rule |
| +// only; it still shares the namespaces and passes every reference check. |
| +func TestPlan14GenerationCensusAcceptsOwnChildOnly(t *testing.T) { |
| + for _, mode := range []string{"own child", "no parent", "other parent", "exe", "fd", "mapped", "foreign-mount-ns", "target mount"} { |
| + t.Run(mode, func(t *testing.T) { |
| + f := generationProc(t) |
| + b := f.reservation.Binding |
| + // The fixture's stat names ppid 1. |
| + generationWrite(t, f.task+"/status", "Uid:\t989\t989\t989\t989\nKthread:\t0\n") |
| + k := generationKernel{proc: f.proc, parent: 1, service: func(string, []byte) (bool, error) { return false, os.ErrPermission }} |
| + switch mode { |
| + case "no parent": |
| + k.parent = 0 |
| + case "other parent": |
| + k.parent = 2 |
| + case "exe": |
| + generationRelink(t, b.Path, f.task+"/exe") |
| + case "fd": |
| + generationLink(t, b.Path, f.task+"/fd/3") |
| + case "mapped": |
| + generationWrite(t, f.task+"/maps", fmt.Sprintf("1000-2000 r-xp 0000 %x:%x %d %s\n", generationMajor(b.Executable.Device), generationMinor(b.Executable.Device), b.Executable.Inode, b.Path)) |
| + case "foreign-mount-ns": |
| + generationRelink(t, "foreign", f.task+"/ns/mnt") |
| + case "target mount": |
| + generationWrite(t, f.task+"/mountinfo", "2 1 0:1 "+b.Tree+" /bound ro - tmpfs tmpfs ro\n") |
| + } |
| + _, err := k.absent(t.Context(), f.reservation) |
| + if (err == nil) != (mode == "own child") { |
| + t.Fatalf("own-child boundary: %v", err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestProcStatParent(t *testing.T) { |
| + for raw, want := range map[string]int{ |
| + "41 (test (child)) S 7 0 0": 7, |
| + "41 (a) b) c) R 916 1 1": 916, |
| + "41 (x\n) S 3 0": 3, |
| + } { |
| + if got, err := procStatParent([]byte(raw)); err != nil || got != want { |
| + t.Fatalf("%q = %d, %v; want %d", raw, got, err, want) |
| + } |
| + } |
| + for _, raw := range []string{"", "41 (x", "41 (x) S", "41 (x) S y"} { |
| + if _, err := procStatParent([]byte(raw)); err == nil { |
| + t.Fatalf("%q accepted", raw) |
| + } |
| + } |
| +} |
diff --git a/internal/host/rootgeneration_census_linux.go b/internal/host/rootgeneration_census_linux.go| index 8b49b6f0f..1a8feca71 100644 |
| --- a/internal/host/rootgeneration_census_linux.go |
| +++ b/internal/host/rootgeneration_census_linux.go |
| @@ -87,7 +87,7 @@ func productionGenerationKernelCensus(ctx context.Context) (string, string, erro |
| } |
| records, _ := ctx.Value(generationCensusReservationsKey{}).([]release.GenerationReservation) |
| return generationCensusRetry(ctx, func() (string, string, error) { |
| - return (generationKernel{proc: "/proc", cgroups: "/sys/fs/cgroup", contained: records, service: generationServiceReader(ctx)}).census(ctx, tree) |
| + return (generationKernel{proc: "/proc", cgroups: "/sys/fs/cgroup", contained: records, service: generationServiceReader(ctx), parent: generationCensusParent(ctx)}).census(ctx, tree) |
| }) |
| } |
diff --git a/internal/host/rootgeneration_inventory.go b/internal/host/rootgeneration_inventory.go| index da186221e..89b0b2dc6 100644 |
| --- a/internal/host/rootgeneration_inventory.go |
| +++ b/internal/host/rootgeneration_inventory.go |
| @@ -28,6 +28,16 @@ type generationInventory struct { |
| } |
| type generationCensusReservationsKey struct{} |
| +// generationCensusParentKey carries the pid whose direct children the |
| +// generation census accepts as this command's own (see generationKernel's |
| +// parent). Only journal-migrate sets it. |
| +type generationCensusParentKey struct{} |
| + |
| +func generationCensusParent(ctx context.Context) int { |
| + pid, _ := ctx.Value(generationCensusParentKey{}).(int) |
| + return pid |
| +} |
| + |
| type generationReconciler struct { |
| read func(context.Context) (generationInventory, error) |
| kernel func(context.Context) (string, string, error) |
diff --git a/internal/host/rootgeneration_kernel_linux.go b/internal/host/rootgeneration_kernel_linux.go| index ea3e73966..e057b014e 100644 |
| --- a/internal/host/rootgeneration_kernel_linux.go |
| +++ b/internal/host/rootgeneration_kernel_linux.go |
| @@ -30,6 +30,10 @@ type generationKernel struct { |
| owner uint32 |
| contained []release.GenerationReservation |
| service func(string, []byte) (bool, error) |
| + // parent, when set, is the pid of an offline root command (journal-migrate) |
| + // whose own direct children pass the root-task rule. They still share |
| + // its namespaces and pass every reference check below. |
| + parent int |
| } |
| func generationRead(path string) ([]byte, error) { |
| @@ -373,6 +377,11 @@ func (k generationKernel) task(ctx context.Context, path string, b release.Gener |
| } |
| } |
| kernel, rootErr := generationRootTask(status) |
| + if rootErr != nil && !kernel && k.parent != 0 { |
| + if ppid, err := procStatParent(raw); err == nil && ppid == k.parent { |
| + rootErr = nil |
| + } |
| + } |
| trusted := false |
| if k.service != nil && !kernel { |
| trusted, err = k.service(path, status) |
diff --git a/internal/host/rootmigration_production_linux.go b/internal/host/rootmigration_production_linux.go| index c3ff604d6..7b55baa7f 100644 |
| --- a/internal/host/rootmigration_production_linux.go |
| +++ b/internal/host/rootmigration_production_linux.go |
| @@ -169,7 +169,9 @@ func migrateRootClaimAuthority(ctx context.Context, store release.Store, r Claim |
| if err := migrationExecutionEmpty(execution); err != nil { |
| return err |
| } |
| - if _, _, err := productionGenerationKernelCensus(ctx); err != nil { |
| + // The migration's own service-user registry child is still running; |
| + // it is this command's, not a retired generation's. |
| + if _, _, err := productionGenerationKernelCensus(context.WithValue(ctx, generationCensusParentKey{}, os.Getpid())); err != nil { |
| return err |
| } |
| generations, err := rootstate.Open(release.RootGenerationsDir, true, false) |
diff --git a/internal/provision/plan14_root_reads_test.go b/internal/provision/plan14_root_reads_test.go| index 13579404a..138830f84 100644 |
| --- a/internal/provision/plan14_root_reads_test.go |
| +++ b/internal/provision/plan14_root_reads_test.go |
| @@ -987,11 +987,18 @@ func TestPlan14RootReadCensus(t *testing.T) { |
| } |
| // 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. |
| + // deployment harness's 8.2 stops), loaded last. Ruled by platform-d8, |
| + // accepted as proposed; 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) |
| } |
| + // Census overlay claim-own-child (the generation census accepts |
| + // journal-migrate's own registry child past the root-task rule, untrusted), |
| + // loaded last. Proposed to platform-d8; no accepted-legacy row, so the |
| + // seal stands. |
| + if err = loadRootReadInventory(filepath.Join(root, "internal/provision/testdata/plan14-root-reads-claim-own-child.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| index 7ef805b70..f0c9e1738 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-claim-harness-census.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-claim-harness-census.tsv |
| @@ -1,4 +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 |
| +internal/host/activation_install_linux.go activationLock authority G,J4 rev3=census-ruling-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=census-ruling-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 |
diff --git a/internal/provision/testdata/plan14-root-reads-claim-own-child.tsv b/internal/provision/testdata/plan14-root-reads-claim-own-child.tsv| new file mode 100644 |
| index 000000000..5f37b2cc9 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-claim-own-child.tsv |
| @@ -0,0 +1,7 @@ |
| +# Census overlay claim-own-child (platform-d8 deployment harness, the 4th 8.2 stop on 2026-10-20): the retired-generation kernel census refused journal-migrate's own service-user registry child, which from an operator shell sits in no service that selects the running binary. Only when journal-migrate runs the census (a context value with its pid) does a non-root, non-kernel task whose /proc stat ppid is that pid pass the root-task rule. It is not trusted: it must share the census's namespaces and pass every exe, cwd, root, descriptor, mapping and mount reference check, and the closing start-time re-read still binds the pid. procStatParent is the one ppid parser the quiesce scan and this census share. Classes unchanged. |
| +@coverage internal/host 091a7e0e86404ff327ac6280eb4ea80066e8e3decfb9efa5c7cbd052212f8a76 |
| +internal/host/claimjournal_migration_linux.go procParent authority C,G,J4 root-input;kept=C,G;scope=protected-decision-only;rev3=PROPOSED-claim-own-child;identity=carlos system journal-migrate, offline operator CLI, uid 0;basis=reads one /proc/<pid>/stat; the ppid parse moved into procStatParent, shared with the generation census; a malformed file is an error the scan refuses on file:ReadFile@61 2640074280b6764a0ff4e9b817703c860790b2f4877322044f1d14a1933341e9 |
| +internal/host/rootgeneration_kernel_linux.go generationKernel.task authority E2 rev3=PROPOSED-claim-own-child;identity=root generation census, uid 0;basis=unchanged reference checks; a non-root non-kernel task whose stat ppid equals the kernel's parent (set only by journal-migrate) passes the root-task rule untrusted, so namespaces must match and every reference check and the start-time re-read still apply; with no parent set the rule is exactly as before file:Readlink@1342 29f36b9d2d03972f66d7cf63803a25146b815f704dab47458696688a796a7818 |
| +internal/host/rootmigration_production_linux.go migrateRootClaimAuthority authority G,J4,E3 rev3=PROPOSED-claim-own-child;identity=offline root migration uid 0;basis=as before; its generation kernel census carries the migration's own pid so its registry child is recognised as its own file:Open@1814,file:Open@374,file:Open@615,file:Open@739,file:Open@7567,file:Read@2766,file:ReadFile@1571,whole:Route@3079 62482c7d1b91514578397f3f0bac42f34ec41d02f6cf19e3ded9fdff90795cc8 |
| +internal/host/rootgeneration_census_linux.go productionGenerationKernelCensus authority E2 rev3=PROPOSED-claim-own-child;basis=as before; passes the context's census parent (generationCensusParent, zero unless journal-migrate set it) to the kernel 3588ecc2628ef3914113d306029adbc82143f542fcfb129a5ba35a5c8f15eb93 |
| +internal/host/rootgeneration_kernel_linux.go type generationKernel authority E2 rev3=PROPOSED-claim-own-child;basis=as before, plus parent: the pid whose direct children pass the root-task rule untrusted; zero everywhere but journal-migrate 5ac1e05c15d44a84a968385bb81aff33d440d9d27256a2e4cfa57141c2c87f97 |