carlos / platform Public

census: overlay claims-on-gate-recover, PROPOSED

Loaded last, after scan-demand-revival, under
rev3=PROPOSED-claims-on-gate-recover, to be asked of the census owner on
#280 (docs/superpowers/notes/census-proposal-claims-on-gate-recover.md).

The changed authority units are re-pinned at their class and task:
RunSystemApply, systemApplier.Run, checkGuardRecovery,
checkUnarmedParticipationRecovery, generationKernel.absent and .task,
generationCensusRetry and generationServiceReader. The service reader's
reads move into three new units at its class, E2 (generationServiceEnv.reader,
generationServiceShow, generationServiceTrust). The deleted-exe image proof,
generationServiceEnv.deletedProgram, is a new root read classified F,J4,
as the guard's own image proof. internal/host's envelope is re-pinned. No
legacy row, so the seal stands; the record-write census is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 8eed5c193bde2f974fbf8f75399c9ab402567976 parent 5e276a8
3 files changed, +150 −0
  • docs/superpowers/notes/census-proposal-claims-on-gate-recover.md +118 −0
  • internal/provision/plan14_root_reads_test.go +15 −0
  • internal/provision/testdata/plan14-root-reads-claims-on-gate-recover.tsv +17 −0

CI passed — run details

diff --git a/docs/superpowers/notes/census-proposal-claims-on-gate-recover.md b/docs/superpowers/notes/census-proposal-claims-on-gate-recover.md
new file mode 100644
index 000000000..a5a897613
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-claims-on-gate-recover.md
@@ -0,0 +1,118 @@
+# Census: the claims-on update gate and recover's generation census
+
+Status: PROPOSED. Every row carries `rev3=PROPOSED-claims-on-gate-recover`.
+The ruling is asked of the census owner on #280.
+
+The branch is `claims-on-gate-recover`, from main 3d444a1b. It fixes two
+defects a deployment harness found on a box running with CARLOS_HOST_CLAIM
+on: (a) the update gate rolled every update back, and its rollback too,
+because a claims-on edge takes about 22 s to listen and the gate waited 20 s;
+(b) carlos-system-recover's root generation census refused racily and, since
+the edge's guard drop-in `Requires=` the recover unit, kept the edge down.
+
+It adds one census overlay,
+`internal/provision/testdata/plan14-root-reads-claims-on-gate-recover.tsv`,
+loaded last in `TestPlan14RootReadCensus`, after scan-demand-revival. Every
+row is authority. There is no legacy row and no frozen declaration, so the
+seal stands at `a21dba12…f0cc262`. The `internal/host` envelope is re-pinned.
+The record-write census (`TestPlan9B8RecordWriteCensus`) does not change: no
+record write is added or moved.
+
+## Ruling 6
+
+Claims-off and no-census boxes see no change.
+
+- The gate's new window and fail-fast are keyed on CARLOS_HOST_CLAIM, read
+ with `hostwrite.Enabled` from the update and recover units' environment
+ (both load host.env). Claims off, the gate is exactly the 20 s one and
+ reads no `systemctl show` inside its wait
+ (`TestClaimsOffGateIsUnchangedByAnEdgeThatListensAt22s`,
+ `TestClaimsOffGateWaitsItsFullWindowThroughACrash`).
+- The recover deferral applies only where root participation is required
+ (a census). A no-census box's refused settlement fails recover as on main
+ (`TestRuling6NoCensusRecoverIsUnchanged`).
+- The generation census itself still runs only where it ran before: it is
+ reached only through the ledger's launch verifier, which a no-census box
+ never consults.
+
+## The units
+
+### (a) The update gate
+
+| unit | change | executing identity | disposition |
+|---|---|---|---|
+| `internal/host/systemapply.go` `RunSystemApply` | re-pinned, no read of its own: picks the gate window through `systemApplyGate` (CARLOS_HOST_CLAIM by `hostwrite.Enabled`) | root apply and recovery, uid 0 | authority, D,F,J4, unchanged |
+
+The gate (`systemApplier.gate`, `gateCheck`, `gateFailFast`, `systemGateWaitFor`)
+reads only `systemctl is-active` and `systemctl show` answers it already read,
+and has no row.
+
+### (b) Recover's generation census
+
+| unit | change | executing identity | disposition |
+|---|---|---|---|
+| `internal/host/guardtransaction.go` `systemApplier.checkGuardRecovery` | re-pinned: its reads are unchanged; the two no-journal settlements call `settleWithoutJournal`, which on a census box wraps a refused `controllersRecovered` in `errSettlementDeferred` | root system update and recovery, uid 0 | authority, D, unchanged |
+| `internal/host/systemapply.go` `systemApplier.Run` | re-pinned: its lock-file read is unchanged; under `--recover` a deferred settlement is logged and not fatal, and is not tried again at the end of the run | root apply and recovery, uid 0 | authority, D,F,J4, unchanged |
+| `internal/host/systemparticipation.go` `systemApplier.checkUnarmedParticipationRecovery` | re-pinned, no read of its own: with no journal open its settlement goes through `settleWithoutJournal` | root system update and recovery, uid 0 | authority, G,F, unchanged |
+| `internal/host/rootgeneration_kernel_linux.go` `generationKernel.absent` | re-pinned: same reads; a task refusal is typed (`generationTaskRefusal`, same text) so the retry can tell task-level refusals from structural ones | root census, uid 0 | authority, E2, unchanged |
+| `internal/host/rootgeneration_kernel_linux.go` `generationKernel.task` | re-pinned: same reads; a start time that moves mid-inspection refuses as `errGenerationTaskReplaced` (still `os.ErrPermission`); every reference check still runs on every accepted service task | root census, uid 0 | authority, E2, unchanged |
+| `internal/host/rootgeneration_census_linux.go` `generationCensusRetry` | re-pinned, no read of its own: whole passes; task-level refusals a later pass can clear retry with backoff from 250 ms for at most 20 s; reference, namespace, mount and structural refusals refuse at once | root census, uid 0 | authority, E2, unchanged |
+| `internal/host/rootgeneration_services_linux.go` `generationServiceReader` | re-pinned, now a binding with no read: the production `generationServiceEnv` | root census, uid 0 | authority, E2, unchanged |
+| `internal/host/rootgeneration_services_linux.go` `generationServiceEnv.reader` | new: `generationServiceReader`'s body. The exe `Readlink` moves first, for diagnostics only. Every refusal names check, unit, cgroup and exe. A non-root task whose exe reads `<path> (deleted)` goes to `deletedProgram` | root census, uid 0 | authority, E2 (its caller's) |
+| `internal/host/rootgeneration_services_linux.go` `generationServiceShow` | new: the `systemctl show` moved out unchanged | root census, uid 0 | authority, E2 (its caller's) |
+| `internal/host/rootgeneration_services_linux.go` `generationServiceTrust` | new: the unit-file `EvalSymlinks` and `OpenTrustedFile` moved out unchanged | root census, uid 0 | authority, E2 (its caller's) |
+| `internal/host/rootgeneration_services_linux.go` `generationServiceEnv.deletedProgram` | new root read: opens a service task's image through `/proc/<pid>/exe`, `Fstat`s it and hashes it | root census, uid 0, in carlos-system-recover, carlos-system-update, instance-control's start and the guard-exec prelude | authority, F,J4 |
+
+### Why the deleted-exe read is F,J4
+
+`deletedProgram` makes the proof the guard makes before it execs a binary,
+on the same kind of input. The guard's reads are F,J4 root-input:
+`hostfloor` `OpenProtected`, `Disk.VerifyFile` and `ExecutingHash` (which
+opens `/proc/self/exe` and hashes it), and in this package
+`readRootFloorBinary`. `deletedProgram` opens the running image of another
+task the same way, requires a regular file owned by root, with no links left
+and no group or other write, hashes at most 512 MiB of it, and accepts only a
+digest equal to the signed router build of `<opt>/carlos` or
+`<opt>/carlos.prev`, which `readRootFloorBinary` proves from the identity
+cache the box holds. Classifying it at E2 with its caller would understate
+what it decides: a match is what lets an unselected inode count as the
+unit's program.
+
+It is reached only for a non-root task of a unit whose selected program is
+`<opt>/carlos` and whose exe link reads `<opt>/carlos (deleted)`. Anything
+else refuses as before. Acceptance only lets the census go on to the
+reference checks: exe, cwd, root, descriptors, maps and mounts are still
+compared against the retired generations
+(`TestRecoverCensusStillChecksReferencesOfAnAcceptedDeletedExe`).
+
+## Tests named in the rows
+
+- (a): `TestSystemGateWaitIsKeyedOnClaimsMode`,
+ `TestSystemApplyReadsClaimsModeFromTheUnitEnvironment`,
+ `TestClaimsOnGatePassesAnEdgeThatListensAt22s`,
+ `TestClaimsOnGateWaitsUpTo120s`, `TestClaimsOnGateFailsFastOnACrashRestart`,
+ `TestClaimsOnGateFailsFastOnAFailedOrInactiveEdge`,
+ `TestClaimsOnRollbackGateUsesTheSameRule`,
+ `TestClaimsOnRollbackGateFailsFastToo`, and the two claims-off tests above.
+- (b) fix 1: `TestRecoverDefersACensusRefusalWithNoJournalOpen`,
+ `TestRecoverFailsACensusRefusalWithAJournalOpen`,
+ `TestRecoverDefersACensusRefusalWithoutAnArmedFloor`,
+ `TestApplyStillFailsACensusRefusalWithNoJournalOpen`,
+ `TestRuling6NoCensusRecoverIsUnchanged`; `TestGuardRecoveryRefusesControllersAfterBegin`,
+ `TestPlan9M8GuardRecoveryRecoversPendingWithoutJournal` and
+ `TestSystemGuardRegionHAKeepsFailedCompletionEvidence` now expect the
+ no-journal paths to exit 0 with the transaction kept.
+- (b) fix 2: `TestRecoverCensusAcceptsADeletedExeOfTheCurrentOrPreviousBuild`,
+ `TestRecoverCensusAcceptsTheEdgesDeletedExeInSupervise`,
+ `TestRecoverCensusRefusesOtherDeletedExes`,
+ `TestRecoverCensusRefusesADeletedExeNotOwnedByRoot`,
+ `TestRecoverCensusStillChecksReferencesOfAnAcceptedDeletedExe`.
+- (b) fix 3: `TestRecoverCensusRetriesATransientRefusalWithinTheWindow`,
+ `TestRecoverCensusRetriesOnlyTaskLevelTransients`,
+ `TestPlan14GenerationCensusRetriesWholeObservation` (unchanged).
+- (b) fix 4: `TestRecoverCensusRefusalsNameCheckUnitCgroupAndExe`.
+
+The census tests drive the production service lookup over a fake `/proc`,
+replacing only `systemctl`, the unit files' ownership check, the
+signed-binary proof and the owner uid, which a non-root test cannot provide.
+No root-runner test was run for this branch.
diff --git a/internal/provision/plan14_root_reads_test.go b/internal/provision/plan14_root_reads_test.go
index b56965763..a5b90ca30 100644
--- a/internal/provision/plan14_root_reads_test.go
+++ b/internal/provision/plan14_root_reads_test.go
@@ -1034,6 +1034,21 @@ func TestPlan14RootReadCensus(t *testing.T) {
t.Fatal(err)
}
seal = "a21dba12b0f3cd0811c624ec352d6ff5c46936ef0da1d4ce9d31cdd13cc0f262"
+ // Census overlay claims-on-gate-recover (a claims-on box's update gate
+ // waits 120 s and fails fast; carlos-system-recover defers a refused
+ // census with no journal open, accepts a service still running the
+ // signed current or previous router build it was renamed over, retries
+ // task-level refusals for at most 20 s and names each refusal's check,
+ // unit, cgroup and exe), loaded last. PROPOSED-claims-on-gate-recover,
+ // to be asked of the census owner on #280
+ // (docs/superpowers/notes/census-proposal-claims-on-gate-recover.md).
+ // Changed authority units re-pinned at their class and task; the
+ // service reader's reads move into three new units at its class (E2);
+ // the deleted-exe image proof is a new root read at F,J4, as the
+ // guard's own image proof. No legacy row; the seal stands.
+ if err = loadRootReadInventory(filepath.Join(root, "internal/provision/testdata/plan14-root-reads-claims-on-gate-recover.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-claims-on-gate-recover.tsv b/internal/provision/testdata/plan14-root-reads-claims-on-gate-recover.tsv
new file mode 100644
index 000000000..79222f163
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-claims-on-gate-recover.tsv
@@ -0,0 +1,17 @@
+# Census overlay claims-on-gate-recover (the claims-on update gate and carlos-system-recover's generation census, on main 3d444a1b), loaded LAST, after scan-demand-revival. PROPOSED, not ruled: rev3=PROPOSED-claims-on-gate-recover, to be asked of the census owner on #280 (docs/superpowers/notes/census-proposal-claims-on-gate-recover.md).
+# (a) RunSystemApply re-pinned: the gate window follows CARLOS_HOST_CLAIM. The gate itself (systemApplier.gate, gateCheck, gateFailFast) has no root read and no row.
+# (b) checkGuardRecovery, Run and checkUnarmedParticipationRecovery re-pinned for the no-journal deferral; generationKernel.absent and .task re-pinned for typed task refusals; generationCensusRetry re-pinned for the bounded backoff; generationServiceReader re-pinned as a binding, its reads moved into three new E2 units at its class; generationServiceEnv.deletedProgram is a new root read at F,J4 like the guard's own image proof.
+# Every changed unit is authority: no legacy row, no frozen declaration, so the seal stands. internal/host's envelope is re-pinned.
+internal/host/guardtransaction.go systemApplier.checkGuardRecovery authority D rev3=PROPOSED-claims-on-gate-recover;identity=root system update/recovery uid 0 (carlos-system-update.service, carlos-system-recover.service);basis=re-pinned at its class and task; its reads are unchanged (activation and marker records). The two no-journal settlements now call settleWithoutJournal, which on a census box wraps a refused controllersRecovered in errSettlementDeferred so Run under --recover leaves the participation transaction, reservation and update record open and exits 0; the journal-open branch, the apply, and no-census boxes keep main behaviour (ruling 6). Claims-on or retained root census uses root exclusion; claims-off with no census preserves main participation and recovery behavior. TestRecoverDefersACensusRefusalWithNoJournalOpen, TestRecoverFailsACensusRefusalWithAJournalOpen, TestRuling6NoCensusRecoverIsUnchanged, TestGuardRecoveryRefusesControllersAfterBegin. file:ReadFile@433,file:ReadFile@660 f086097ba7dd0f88406ec8fc84a397ccf070adc2e3ffab8e90c61601034ce59d
+internal/host/systemapply.go systemApplier.Run authority D,F,J4 rev3=PROPOSED-claims-on-gate-recover;identity=root apply/recovery uid 0;basis=re-pinned at its class and task; its lock-file read is unchanged. A checkGuardRecovery error wrapping errSettlementDeferred under --recover is logged and not fatal, and the end-of-run settlement is not retried after a deferral; every other refusal returns as before. root-input;kept=D,F;scope=protected-decision-only. TestRecoverDefersACensusRefusalWithNoJournalOpen, TestApplyStillFailsACensusRefusalWithNoJournalOpen. file:OpenFile@483 e82ca5b50ea583a2f49a7c5ddf9e33a2162ec6fca307e2553d4efe6d0238329d
+internal/host/systemapply.go RunSystemApply authority D,F,J4 rev3=PROPOSED-claims-on-gate-recover;identity=root apply/recovery uid 0;basis=re-pinned at its class and task, no read of its own: reads CARLOS_HOST_CLAIM from the unit environment through systemApplyGate (hostwrite.Enabled, as the agent does) to pick the update gate window, 120 s with fail-fast claims-on and 20 s unchanged claims-off. Registers local verifier and invokes census-gated release wrapper; absent census executes main apply directly even with leftover release state. TestSystemApplyReadsClaimsModeFromTheUnitEnvironment, TestClaimsOffGateIsUnchangedByAnEdgeThatListensAt22s. d563475f2ac28b1d1bc0bae86fa326ccaae3df1efb71928f7efd69a644a4e960
+internal/host/systemparticipation.go systemApplier.checkUnarmedParticipationRecovery authority G,F rev3=PROPOSED-claims-on-gate-recover;identity=root system update/recovery uid 0;basis=re-pinned at its class and task, no read of its own: with no journal open the settlement goes through settleWithoutJournal, so a refused census defers (transaction and update record kept, recover exits 0); with a journal open it refuses as before. Pending acquisition triggers production controller settlement even without an update journal; normal ledger admission stays refused until verified recovery clears the marker. TestRecoverDefersACensusRefusalWithoutAnArmedFloor. 775e5894f5dc32c7f5403df536d423bdb7a185006406be4688f031324050a17b
+internal/host/rootgeneration_kernel_linux.go generationKernel.absent authority E2 rev3=PROPOSED-claims-on-gate-recover;identity=root claim/adopt/update controller uid 0;basis=re-pinned at its class and task; its reads are unchanged. A task refusal is now typed (generationTaskRefusal, same text: the /proc path and the cause) so the census retry can tell task-level refusals from structural ones; bounded task and persistent generation inspection retains boot and process start checks. file:Readlink@312 b758554c182902d80a255122404d8418ec78a9d49ed32c78b9116493ab137b5a
+internal/host/rootgeneration_kernel_linux.go generationKernel.task authority E2 rev3=PROPOSED-claims-on-gate-recover;identity=root claim/adopt/update controller uid 0;basis=re-pinned at its class and task; its reads are unchanged. A start time that moves during inspection now refuses with errGenerationTaskReplaced (still os.ErrPermission) so a fresh pass may clear it; every accepted service, including a deleted-exe task, still has exe, cwd, root, descriptors, maps and mounts checked against retired generations and its start rechecked. TestRecoverCensusStillChecksReferencesOfAnAcceptedDeletedExe, TestPlan14GenerationServiceReferences. file:Readlink@1248 b154974e026435c6c072bdd702dd5dba72d561a99823657c625332f63adb003b
+internal/host/rootgeneration_census_linux.go generationCensusRetry authority E2 rev3=PROPOSED-claims-on-gate-recover;identity=root claim/adopt/update controller uid 0;basis=re-pinned at its class and task, no read of its own: runs whole independent census passes through generationCensusRetryFor. Task-level refusals a later pass can clear (exited, replaced, refused by the service lookup) retry with backoff from 250 ms for at most 20 s, then the last refusal is returned unchanged; other missing-process errors retry at most three times as before; reference, namespace, mount and structural refusals refuse immediately; no partial census is accepted. TestRecoverCensusRetriesATransientRefusalWithinTheWindow, TestRecoverCensusRetriesOnlyTaskLevelTransients, TestPlan14GenerationCensusRetriesWholeObservation. 558610eb740f2af3365c6880122abcb4a1dbbd5be687805d1fdf265db88f3f63
+internal/host/rootgeneration_services_linux.go generationServiceReader authority E2 rev3=PROPOSED-claims-on-gate-recover;identity=root generation kernel reader uid 0;basis=re-pinned at its class and task, no read of its own now: binds the production generationServiceEnv (/proc, /opt/carlos, owner uid 0, systemctl show, trusted unit files, readRootFloorBinary) and returns its reader; the reads moved into generationServiceEnv.reader, generationServiceShow and generationServiceTrust unchanged. e008d36af58a61e8eddf18d54a8c70243e9f9c62185c93f66e4bd5557048d9e4
+internal/host/rootgeneration_services_linux.go generationServiceEnv.reader authority E2 rev3=PROPOSED-claims-on-gate-recover;identity=root generation kernel reader uid 0;basis=new unit, generationServiceReader's body at its class: classifies independently verified platform and system services by trusted unit files, systemd main PID, cgroup and protected executable; only edge main threads may use its delegated supervise subgroup; exact guard-exec edge verifies guard and selected current against signed protected identities. The exe Readlink moves before the cgroup checks for diagnostics only (a failure still refuses at its old place); every refusal names check, unit, cgroup and exe and wraps its cause. A non-root task whose exe reads <path> (deleted) goes to deletedProgram instead of the path walk; root tasks of unselected units keep the walk. TestRecoverCensusRefusalsNameCheckUnitCgroupAndExe, TestRecoverCensusAcceptsTheEdgesDeletedExeInSupervise. file:Readlink@1017 4faa70c023ebe85bca7862dc5de60382536154aefc27ef21a66af2739f81fb97
+internal/host/rootgeneration_services_linux.go generationServiceShow authority E2 rev3=PROPOSED-claims-on-gate-recover;identity=root generation kernel reader uid 0;basis=new unit, the systemctl show of ControlGroup, MainPID, ExecStart, FragmentPath and DropInPaths moved out of generationServiceReader unchanged, at its class. file:CommandContext@103 26d82849d8e6d22eb35b0d9befd0b5c02d81cec9dc3bfaf4b684504c16c4d0cd
+internal/host/rootgeneration_services_linux.go generationServiceTrust authority E2 rev3=PROPOSED-claims-on-gate-recover;identity=root generation kernel reader uid 0;basis=new unit, the unit-file EvalSymlinks and rootstate.OpenTrustedFile check moved out of generationServiceReader unchanged, at its class. file:EvalSymlinks@63 07fe0cf4c6a8b17eaa223ec37b44818152ac1e70c8fe3832bedcb99c61cf24a1
+internal/host/rootgeneration_services_linux.go generationServiceEnv.deletedProgram authority F,J4 rev3=PROPOSED-claims-on-gate-recover;identity=root generation kernel reader uid 0 (carlos-system-recover, carlos-system-update, instance-control start, guard-exec prelude);basis=NEW root read, classified as guard-exec's equivalent (hostfloor OpenProtected, Disk.VerifyFile and ExecutingHash, F,J4 root-input) because it is the same proof on the same kind of input: it opens a service task's running image through /proc/<pid>/exe, requires a regular file owned by root with no links left and no group or other write, hashes its bytes (at most 512 MiB) and accepts only a digest equal to the signed router build of <opt>/carlos or <opt>/carlos.prev as readRootFloorBinary proves it from the local identity cache. Only for a non-root task of a unit whose selected program is <opt>/carlos and whose exe link reads <opt>/carlos (deleted); anything else refuses as before. Acceptance only lets the census reach the reference checks. TestRecoverCensusAcceptsADeletedExeOfTheCurrentOrPreviousBuild, TestRecoverCensusRefusesOtherDeletedExes, TestRecoverCensusRefusesADeletedExeNotOwnedByRoot. file:Fstat@389,file:Open@285 bfc0a7c3935b2f414ef9354390744b9a82d9f08d7ff93943fd685a6c98906cbf
+@coverage internal/host 9acd729653931aa89061368f8d05f3f0c4ceac7b4c4c46192a40002debbc63b4