carlos / platform Public

docs: plan 2b-2 review round 2 fixes; review closed

Systemd ConditionPathExists gate on every workload unit (Paul, rule 12),
writable admission dir for instance-control on managed boxes, no-skip
root contract job.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 55d99085338d3b0f0e5d2680251a3502229cc0d8 parent de05912
1 file changed, +116 −35
  • docs/superpowers/plans/2026-11-08-managed-fleets-2b2-box-side.md +116 −35

CI failed — run details

diff --git a/docs/superpowers/plans/2026-11-08-managed-fleets-2b2-box-side.md b/docs/superpowers/plans/2026-11-08-managed-fleets-2b2-box-side.md
index a079f0787..c0ac9be26 100644
--- a/docs/superpowers/plans/2026-11-08-managed-fleets-2b2-box-side.md
+++ b/docs/superpowers/plans/2026-11-08-managed-fleets-2b2-box-side.md
@@ -4,7 +4,7 @@
**Goal:** A console-launched managed box boots from frozen cloud-init, verifies everything it executes, trades its one-time token once, holds a root-owned joining gate that runs nothing until root has verified a console-signed ready.json, establishes the fleet's secrets key, passes real `storage` and `router_probe` checks, and is wired for production behind an off-by-default switch, with a concrete dev drill card ready for Paul.
-**Architecture:** A new provider-neutral `internal/managedboot` package holds the frozen boot inputs, the cloud-init renderer, wire types, the signed ready record and the root admission record. The console renders user data from frozen box fields, serves the seed binary to an unused token, and signs ready.json with its existing pointer-signing key. Box-side code runs as root once per boot (`carlos system managed-boot`), hands off to the installed stable binary's `bootstrap`, then queues the first carlos-edge start. Admission authority lives with root: the agent only relays ready.json to the root execution door, which verifies the signature and commits a root-only record that every root and agent start path consults. Readiness probes travel console → hub (mesh-key HMAC) → the exact `<fleet>/<label>` channel → box responder and are bridged into 2a's `managedExtraChecks`.
+**Architecture:** A new provider-neutral `internal/managedboot` package holds the frozen boot inputs, the cloud-init renderer, wire types, the signed ready record and the root admission record. The console renders user data from frozen box fields, serves the seed binary to an unused token, and signs ready.json with its existing pointer-signing key. Box-side code runs as root once per boot (`carlos system managed-boot`), hands off to the installed stable binary's `bootstrap`, then queues the first carlos-edge start. Admission authority lives with root: the agent only relays ready.json to the root execution door, which verifies the signature and commits a root-only record ending in the marker `/var/lib/carlos-managed-root/admitted`. Systemd enforces the gate: every workload unit carries a root-owned drop-in `ConditionPathExists=` on that marker, so no start, restart or recovery path can run a workload before root admits the box (decisions rule 12); per-path code gates remain a second layer. Readiness probes travel console → hub (mesh-key HMAC) → the exact `<fleet>/<label>` channel → box responder and are bridged into 2a's `managedExtraChecks`.
**Tech Stack:** Go, SQLite, `text/template` + `embed` for the boot script, nftables, systemd, Ed25519 signed wrappers (`{payload, sig}`, as `release/production.go:117`), ECDH P-256 secrets keys, `release.Store` create-only PUT, AWS SDK v2 only inside `internal/awsmanaged` (2b-1), mocked transport in tests.
@@ -37,6 +37,8 @@ Execution facts (controller brief, 2026-11-08; these supersede decisions.md rule
- Managed boxes have no instance profile, SSH key or SSM agent; diagnostics are console-output breadcrumbs, heartbeat fields and readiness reasons only (decisions rule 1).
- Paul's rulings (decisions 9-11): the first binary comes only through the console seed door to an unused token (no public URL, no custom AMI); the owner `carlos fleets secrets-key` door refuses on managed fleets until 2c; the drill deletes every AWS resource and keeps the dev console's `drill-2b` records for 2d, with no hand DB edits.
- Admission authority is root's. No root decision reads a file the service UID (carlos) can create, replace or link.
+- Paul's rule 12 (stopping rule 2, invariant): on managed boxes every workload unit carries `ConditionPathExists=/var/lib/carlos-managed-root/admitted` in a root-owned drop-in installed before any workload unit can exist; platform maintenance units carry none. The marker is written once by the verified `/managed-admit` commit and never removed. Per-path code gates stay as a second layer; do not add new per-path wrappers to chase start surfaces, the condition is the guarantee.
+- Ownership and namespace witnesses run in a required CI job that fails, never skips, when its capability is missing (Task 3); whether a capable amadan runner exists is a 2b-2 build prerequisite the controller confirms before Task 3 starts.
- Implementers stop at local checks, commit, census proposal and report. The controller owns copy review, reviews, #280, push, CI and landing.
## Review Focus
@@ -72,8 +74,8 @@ Task 3 changes the ready object's encoding (2a's `managedReadyObject`, `managedw
| Task | Files / responsibility |
|---|---|
| 1 | New `internal/managedboot/{frozen,userdata,breadcrumb}.go`, `cloudinit_v1.sh.tmpl`, `testdata/userdata-v1.golden`; console `managedworker.go`, `managedstore.go`, `managedenrol.go`, new `managedseed.go`, `server.go` route |
-| 2 | New `internal/managedboot/{enrolwire,identity,hostenv}.go`; new `internal/host/{managedboot,managedboot_linux,managedboot_other,managedstable}.go`; `system.go` verb |
-| 3 | New `internal/managedboot/{ready,admission}.go`; console `managedworker.go` (signed ready object); `internal/provision/reconcile.go`; new `internal/host/managedjoin.go`; `internal/host/agent.go`, `rootrestart.go`, `unitops.go`, `namedrecovery.go`, `claimstop_run.go`; `internal/instancectl/{server,client}.go` |
+| 2 | New `internal/managedboot/{enrolwire,identity,hostenv,units}.go`; new `internal/host/{managedboot,managedboot_linux,managedboot_other,managedstable}.go`; `system.go` verb |
+| 3 | New `internal/managedboot/{ready,admission}.go`; console `managedworker.go` (signed ready object); `internal/provision/reconcile.go`; new `internal/host/managedjoin.go`, `managedunits.go`; `internal/host/agent.go`, `systemunits.go`, `unitops.go`, `claimstop_run.go`; `internal/instancectl/{server,client}.go`; new required CI job `.amadan/ci.d/40-managed-root-contract` |
| 4 | New `internal/managedboot/fleetkey.go`; new `internal/host/managedkey.go`; `internal/status/snapshot.go` (heartbeat field); console `fleetsecretskey.go` (extract core), new `managedfleetkey.go`, `managedready.go`, `server.go` route |
| 5 | New `internal/managedboot/probe.go`; new `internal/edge/fleetprobe.go`, `edge.go` dispatch, `mesh.go` domain; `internal/tunnelclient/tunnelclient.go` header; new `internal/host/managedprobe.go`; new console `managedprobe.go` |
| 6 | `cmd/console/main.go`, console `server.go` (`NewServer`), `managedworker.go` diagnostics; `internal/awsmanaged/integration_2b2_test.go`; console `managed_e2e`/`managedbudget` tests |
@@ -142,8 +144,9 @@ TestManagedUserDataSecrets: token appears exactly twice, only inside the two roo
(boot-input.json, seed-request.json); never on a command line, URL, log/echo line or breadcrumb;
set -x absent; seed-request.json contains exactly {"token":...}; boot-input.json decodes with
DecodeLaunchInput to the input that was rendered.
-TestManagedCloudInitScriptRun (linux; under unshare -r, skipped with a reason only when user
- namespaces are unavailable): run the RENDERED script with a root prefix, PATH shims for
+TestManagedCloudInitScriptRun (linux, unprivileged, no user namespaces, never skips): run the
+ RENDERED script as the test user with CARLOS_MANAGED_BOOT_ROOT=<owned dir> and
+ CARLOS_MANAGED_BOOT_OWNER=<test uid>:<test gid>, PATH shims for
apt-get/nft/systemctl/useradd/id/chown/timeout (shims log argv), real curl against an
httptest TLS server running the real handleManagedSeed (CA via CURL_CA_BUNDLE):
re-exec under `timeout 900 /bin/sh <script>` happens once; curl writes to seed.part with
@@ -151,9 +154,14 @@ TestManagedCloudInitScriptRun (linux; under unshare -r, skipped with a reason on
bootstrap_failed breadcrumb, no unit started; right bytes => seed renamed to seed, 0700,
verify helper runs immediately before the `systemctl start carlos-managed-boot.service`;
seed-request.json removed; unit and drop-in texts written exactly (see Step 3).
-TestManagedCloudInitVerifyHelper (linux, python3): extracted verify helper refuses wrong
- owner/mode dir, noexec mount flag, symlink, hardlink count 2, non-regular file,
- malformed digest and one-byte mismatch; accepts exact bytes.
+ Hook safety: with CARLOS_MANAGED_BOOT_ROOT unset, CARLOS_MANAGED_BOOT_OWNER is ignored and
+ the expected owner is 0:0; the golden render contains no other test hook.
+TestManagedCloudInitVerifyHelper (linux, python3, unprivileged): extracted verify helper refuses
+ wrong owner (relative to the configured owner)/mode dir, noexec mount flag, symlink, hardlink
+ count 2, non-regular file, malformed digest and one-byte mismatch; accepts exact bytes.
+TestManagedCloudInitRootOwnership (required job only; CARLOS_MANAGED_ROOT_TEST=1, else FAIL not
+ skip): the same rendered script and helper as real uid 0 with a mapped service uid; owner
+ checks refuse files owned by the service uid and accept root:root 0700/0600.
TestManagedBootFrozenAtLaunch: reserved->launching commit persists Boot from the verified
stable pointer's linux-arm64 artifact + cfg.Origin/TunnelHost/ReleasePub before any Launch call;
stable unavailable/unsigned/no linux-arm64 => stays reserved, zero Launch calls, 30-min deadline unchanged;
@@ -174,6 +182,7 @@ TestManagedCoreImports: internal/managedboot added; still no AWS SDK import.
Run `GOFLAGS=-buildvcs=false go test ./internal/managedboot ./internal/compute -run 'TestManagedUserData|TestManagedCloudInit|TestManagedCoreImports' -count=1` and `GOFLAGS=-buildvcs=false go test ./internal/console -run 'TestManaged(BootFrozenAtLaunch|SeedDoor|EnrolReplyFields)' -count=1`.
Expected: FAIL on undefined symbols and missing behavior, not on environment. The script-run test lives in `internal/console` if it needs the real handler (it imports managedboot to render), keeping managedboot free of console imports.
+`TestManagedCloudInitRootOwnership` runs only in Task 3's required job `40-managed-root-contract`; locally it is not selected.
- [ ] **Step 3: Implement `managedboot.Frozen`, `RenderUserData` and the v1 template.**
@@ -181,7 +190,7 @@ The template is `#!/bin/sh`, embedded with `//go:embed`, rendered by `text/templ
`Format` selects the template; a later template change adds a new format and keeps v1 rendering for frozen boxes. The golden file is the change detector.
Script order, each step failing to breadcrumb `bootstrap_failed`:
1. `set -eu`, `umask 077`; bound the whole run with group-init's pattern (`group-init.sh.tftpl:12-15`): if `CARLOS_MANAGED_BOOT_BOUNDED` is unset, export it and `exec timeout 900 /bin/sh "$0"`.
-2. Root-owned 0700 `BootDir` via the group-init ancestor walk (`:18-45`).
+2. Root-owned 0700 `BootDir` via the group-init ancestor walk (`:18-45`). Every path is prefixed by `${CARLOS_MANAGED_BOOT_ROOT:-}` and every owner check compares against `${CARLOS_MANAGED_BOOT_OWNER:-0:0}`, the latter honoured only when the root prefix is non-empty (test-only; cloud-init sets neither).
3. apt over the HTTPS Debian mirror only (`nftables curl ca-certificates python3`); create the `carlos` system user.
4. Install table `inet carlos_managed_imds` with group-init's rule shape (`:104-140`: metadata reachable by uid 0 and carlos only, forwarded traffic rejected); persist it to `/etc/nftables.conf`, `systemctl enable nftables.service`, verify `nft list table`.
5. Write `boot-input.json` (full LaunchInput) and `seed-request.json` (`{"token":"..."}`) by heredoc, both 0600.
@@ -225,7 +234,11 @@ Commit subject: `feat: frozen managed cloud-init and token-bound seed door`.
- `type EnrolRequest struct { Token string "token"; DataDirEmpty bool "data_dir_empty"; DataDirEntries int "data_dir_entries" }` and `type EnrolReply struct { Fleet, Label, TunnelURL, TunnelToken string; Credentials struct{ ID string "id"; Secret []byte "secret" } "credentials"; Joining bool; Bucket, BucketRegion, Operation string }` with the console's JSON names; a console test pins both against `managedEnrolRequest`/`managedEnrolReply`.
- `const IdentityPath = "/etc/carlos/managed-box.json"`; `type Identity struct { Fleet, Label, Op, ReleasePubkey string }` (JSON `fleet`, `label`, `op`, `release_pubkey`), root:root 0644 in root-owned `/etc/carlos`, written once.
- `func LoadIdentity(root string) (Identity, bool, error)`: bool is "this is a managed box"; opens with an O_NOFOLLOW ancestor walk and refuses any component not owned by root or writable by group/other.
- - `const RootAdmissionDir = "/var/lib/carlos-managed-root"` (root:root 0700, created at commit; Task 3 owns its contents).
+ - `const RootAdmissionDir = "/var/lib/carlos-managed-root"` (root:root 0700, created at commit; Task 3 owns its contents); `const AdmittedMarker = RootAdmissionDir + "/admitted"`.
+ - `const AdmissionDropInName = "zz-carlos-managed-admission.conf"`; body exactly `[Unit]\nConditionPathExists=/var/lib/carlos-managed-root/admitted\n`. The `zz-` name sorts after every platform drop-in (`50-carlos-generation.conf`, `instancectl/gen.go:38`; `50-carlos-jit.conf`, `rootfs.go:80`; config-sync env drop-ins), so even an earlier empty `ConditionPathExists=` reset is followed by this assignment.
+ - `var WorkloadUnits = []string{...}` and `var MaintenanceUnits = []string{...}`: the classification of every unit embedded in `unitsFS` (`internal/host/bootstrap.go:38-39`, source `internal/host/units/`). Workload (condition): `carlos-app@.service`, `carlos-app@.socket`, `carlos-instance@.service`, `carlos-instance-gen@.service`, `carlos-instance-sidecar@.service`, `carlos-instance-cmd@.service`, `carlos-instance-tty@.service`, `carlos-instance-seed@.service`, `carlos-instance-rootfs@.service`, `carlos-instance-rootfs-gen@.service`, `carlos-instance-rootfs-cmd@.service`, `carlos-instance-rootfs-tty@.service`, `carlos-instance-rootfs-worker@.service`, `carlos-demo-build@.service`, `carlos-demo-snapshot@.service`, `carlos-dbread@.service`. Maintenance (no condition): `carlos-edge.service`, `carlos-relay.service`, `carlos-adopt.{service,path,timer}`, `carlos-config-sync.service`, `carlos-system-update.{service,path}`, `carlos-system-recover.service`, `carlos-restart.{service,path}`, `carlos-stage.{service,path}`, `carlos-instance-control.{service,socket}`, `carlos-instance-probe.service`, `carlos-instance-rootfs-probe.service`, `carlos-litestream.service`, `carlos-hibernate-verify.{service,timer}`, `carlos-restore-verify.{service,timer}`, `carlos-dbread.socket`, the three slices and three mounts, plus `carlos-managed-boot.service`.
+ - `func InstallAdmissionDropIns(etcDir string, namedUnits []string) (changed bool, err error)`: writes `<etcDir>/<unit>.d/AdmissionDropInName` (root 0644, dir root 0755, temp+fsync+rename+dir fsync) for every WorkloadUnits template and every declared named unit; refuses a named unit that is a MaintenanceUnits name; idempotent.
+ - `const ControlDropInName = "60-carlos-managed-root.conf"`; `func InstallControlDropIn(etcDir string) (bool, error)`: writes `carlos-instance-control.service.d/60-carlos-managed-root.conf` with `[Service]\nReadWritePaths=/var/lib/carlos-managed-root\n`.
- `const KeyStatusPath = "/etc/carlos/managed-key-status.json"` (root 0644; Task 4 writes it).
- `func ManagedHostEnv(id Identity, r EnrolReply, f Frozen, secretsKey string) (map[string]string, error)`: exactly CARLOS_REGION=`fleet/<fleet>`, CARLOS_FLEET, CARLOS_FLEET_BOX, CARLOS_TUNNEL_NAME, CARLOS_TUNNEL_URL, CARLOS_TUNNEL_TOKEN, CARLOS_RELEASE_PUBKEY, CARLOS_HIBERNATE_BUCKET, CARLOS_HIBERNATE_REGION, CARLOS_HIBERNATE_PREFIX=`instances`, AWS_SHARED_CREDENTIALS_FILE=`/etc/carlos/credentials`, and CARLOS_SECRETS_KEY when nonempty. Never CARLOS_DEPLOYMENT_BUCKET/DIR, CARLOS_HOST_CLAIM or CARLOS_GROUP_ADMISSION.
- Produces (**new**, package `host`): `func RunSystemManagedBoot(args []string)`; `type managedBoot struct` with injected `root string`, `http *http.Client`, `now func() time.Time`, `run func(ctx context.Context, argv []string, env []string) error`, `systemctl func(ctx context.Context, args ...string) error`, `breadcrumb func(code string)`; `func (m *managedBoot) Run(ctx context.Context, in managedboot.LaunchInput) error`; `func installManagedStable(ctx context.Context, s release.Store, pub ed25519.PublicKey, root string) (version string, err error)`.
@@ -267,8 +280,16 @@ TestManagedBootUpdateReboot: complete box; /opt/carlos/carlos replaced by a late
reboot => same; admission record (Task 3) untouched in both.
TestManagedBootStagingModes: host.env root:root 0600; credentials root:carlos 0640 parseable
by ParseStaticCredentials; managed-box.json root 0644 with release_pubkey equal to the frozen
- key; RootAdmissionDir root:root 0700 and empty; no file under any carlos-writable path is
- read by managed-boot.
+ key; RootAdmissionDir root:root 0700 and empty (no admitted marker); no file under any
+ carlos-writable path is read by managed-boot.
+TestManagedBootUnitDropIns: before the first bootstrap exec (no workload unit file exists
+ yet), every WorkloadUnits template has <unit>.d/zz-carlos-managed-admission.conf with the exact
+ body, and carlos-instance-control.service.d/60-carlos-managed-root.conf exists; no
+ MaintenanceUnits unit has the admission drop-in; the complete path re-asserts both
+ idempotently (zero writes when present, rewritten when deleted or altered).
+TestManagedUnitClassification: every file in unitsFS is in exactly one of WorkloadUnits or
+ MaintenanceUnits (a new unit added to internal/host/units without classification fails);
+ every workload template name ends in "@.service" or "@.socket".
TestManagedBootScrub: after commit, sentinel token/secret absent from every file under the fake
root except host.env and credentials: boot-input.json rewritten without the token,
seed-request.json absent, cloud-init user-data copies (instance/user-data.txt, user-data.txt.i,
@@ -286,12 +307,12 @@ TestManagedEnrolWireMatchesConsole (console package): managedboot wire types rou
- [ ] **Step 2: Run the failing tests.**
-Run `GOFLAGS=-buildvcs=false go test ./internal/managedboot ./internal/host -run 'TestManagedBoot' -count=1` and `GOFLAGS=-buildvcs=false go test ./internal/console -run TestManagedEnrolWireMatchesConsole -count=1`; expect FAIL.
+Run `GOFLAGS=-buildvcs=false go test ./internal/managedboot ./internal/host -run 'TestManagedBoot|TestManagedUnitClassification' -count=1` and `GOFLAGS=-buildvcs=false go test ./internal/console -run TestManagedEnrolWireMatchesConsole -count=1`; expect FAIL.
- [ ] **Step 3: Implement the state machine in the order the tests pin.**
-Order per boot: root/euid check and `--input` must be a root-owned 0600 regular file in `BootDir` → wait up to 60 s for the IMDS table (systemd ordering normally guarantees it) → `complete` marker present? go to the complete path : → `committed/` present? skip to install : attest → trade (retry contract below, never past `Expires`) → write `staging.<random>/` (host.env, credentials, identity, each fsynced) → fsync dir → rename to `committed/` → fsync parent → install committed files into final paths and create `RootAdmissionDir` (idempotent) → scrub → fleet key (Task 4; never fails the boot) → stable install → `run /opt/carlos/carlos bootstrap` (first exec, re-hashed just before) → write and fsync `complete` → remove the enrol drop-in and daemon-reload → `systemctl start --no-block carlos-edge.service` → emit `joining`.
-Complete path: no network, no digest check of `/opt/carlos/carlos` (after first install its integrity belongs to the existing root update/rollback path, `systemapply.go:676`); ensure the enrol drop-in is gone; queue `start --no-block carlos-edge.service`; exit 0.
+Order per boot: root/euid check and `--input` must be a root-owned 0600 regular file in `BootDir` → wait up to 60 s for the IMDS table (systemd ordering normally guarantees it) → `complete` marker present? go to the complete path : → `committed/` present? skip to install : attest → trade (retry contract below, never past `Expires`) → write `staging.<random>/` (host.env, credentials, identity, each fsynced) → fsync dir → rename to `committed/` → fsync parent → install committed files into final paths and create `RootAdmissionDir` (idempotent) → scrub → fleet key (Task 4; never fails the boot) → `InstallAdmissionDropIns` + `InstallControlDropIn` (before any workload unit file exists) → stable install → `run /opt/carlos/carlos bootstrap` (first exec, re-hashed just before) → write and fsync `complete` → remove the enrol drop-in and daemon-reload → `systemctl start --no-block carlos-edge.service` → emit `joining`.
+Complete path: no network, no digest check of `/opt/carlos/carlos` (after first install its integrity belongs to the existing root update/rollback path, `systemapply.go:676`); ensure the enrol drop-in is gone; re-assert both drop-in sets (daemon-reload only if one changed); queue `start --no-block carlos-edge.service`; exit 0.
Any partial `staging.*` directory is shredded and removed on start. Breadcrumbs go to `/dev/console`, one line each, never with values.
Trade retry: honour `Retry-After` (5 s for 503, the header value for 429), jittered 1-30 s for transport errors, stop at `Expires`; emit `enrol_pending` once when the first retry starts. After `Expires` the only remaining action is `enrol_failed` and a non-zero exit.
Because carlos-edge `Requires=` the boot unit, a failed boot leaves the agent stopped; the box runs nothing and the console's 20-minute deadline terminates it. The seed binary is never updated; it runs only this state machine, whose complete path needs nothing newer.
@@ -315,36 +336,47 @@ Reuse verification primitives only; do not invoke `system install-channel` (its
- [ ] **Step 5: Repeat Step 2 to PASS and commit.**
-Mutation checks (≤10): skip the IMDS wait; re-trade after commit; reuse partial staging; skip scrub of one cloud-init copy; skip pointer signature verify; skip pre-exec re-hash; let an empty reply bucket through; blocking `start carlos-edge`; complete path re-checks the initial digest; keep the enrol drop-in after completion.
+Mutation checks (≤10): skip the IMDS wait; re-trade after commit; reuse partial staging; skip scrub of one cloud-init copy; skip pointer signature verify; let an empty reply bucket through; blocking `start carlos-edge`; complete path re-checks the initial digest; drop-ins installed after bootstrap; one workload template missing from WorkloadUnits.
Commit subject: `feat: managed box first contact with verified install`.
-### Task 3: Root-owned admission behind every start surface
+### Task 3: Root-owned admission enforced by systemd
**Files:**
- Create: `internal/managedboot/ready.go`, `admission.go` and tests.
- Modify: console `internal/console/managedworker.go` (`managedReadyObject` :569, publication :576-638) and `managedready_test.go`; 2b-1's freshness and C08 behaviour unchanged.
- Modify: `internal/provision/reconcile.go` (`ReconcileConfig` :38, `ownsRecord` :549, `Reconcile` :1423) and tests.
- Create: `internal/host/managedjoin.go`, `managedjoin_test.go`, `managedjoin_root_linux_test.go`.
-- Modify: `internal/host/agent.go` (`runAgent` :264, `BoxProvisionConfig` :3893, `fastTick` :3160 via `fastDeps` :2670, `makeStartRoute` :5168, `adoptLoop` :1701, `configSyncLoop` :1796, root pass `runAdoptUnderRootRelease` :5619 incl. SyncUnits :5817 and `rootStartRoute` :5923), `rootrestart.go` (`rootStartRoute` :524, `rootSelectedRestart` :529), `unitops.go` (`productionUnitOps` :27), `namedrecovery.go` (`productionNamedUnitRecovery` :31), `claimstop_run.go` (`RunInstanceControl` :23).
+- Modify: `internal/host/agent.go` (`runAgent` :264, `BoxProvisionConfig` :3893, `fastTick` :3160 via `fastDeps` :2670, `makeStartRoute` :5168), `systemunits.go` (`ensureSystemUnits` :56), `unitops.go` (`InstallNamedUnits` :48), `claimstop_run.go` (`RunInstanceControl` :23).
+- Create: `internal/host/managedunits.go`, `managedunits_test.go` (systemd-semantics witnesses over the real unit files).
- Modify: `internal/instancectl/server.go` (mux :507-526), `client.go` (`NewClient` :50) and tests.
+- Create: `.amadan/ci.d/40-managed-root-contract` (required job; see Step 6).
**Interfaces:**
-- Consumes: Task 2 `LoadIdentity`, `Identity.ReleasePubkey`, `RootAdmissionDir`; `Config.Key` (console Ed25519 private key that signs channel pointers, `server.go:674-677`; public half is `Config.ReleasePub` / `CARLOS_RELEASE_PUBKEY`) and the existing `{payload, sig}` wrapper convention (`release/release.go:487`, signing at `release/production.go:117`, verify at :160); `release.ReadSerial` (`serial.go:32`, `Serial int64`); activator hooks `Service.TenantAdmittedFunc`, `Service.TenantExempt`, `ExecBackend.TenantStartAllowed` (`activator/group_admission.go:11-34`); `(*ExecBackend).Start` :2092, `StartGen` :2136, `StartGenExe` :2163, `StartSidecar` :3294, `StartWorker` :3397, `StartWorkerStaged` :3433; `(*Service).doWakeOnce` (`activator.go:2501`); edge `HAAdmission{ TenantAdmitted() bool }` (`edge/group_admission.go:8`); `appconfig.UnitOps.Restart` call at `appconfig/unitsync.go:459`.
+- Consumes: Task 2 `LoadIdentity`, `Identity.ReleasePubkey`, `RootAdmissionDir`, `AdmittedMarker`, `WorkloadUnits`, `MaintenanceUnits`, `InstallAdmissionDropIns`, `InstallControlDropIn`; the unit sources `internal/host/units/*` embedded as `unitsFS` (`bootstrap.go:38-39`); `carlos-instance-control.service` hardening (`units/carlos-instance-control.service:41-44`: `ProtectSystem=strict`, `ReadWritePaths=/run/carlos-control /run/systemd/system`); `Config.Key` (console Ed25519 private key that signs channel pointers, `server.go:674-677`; public half is `Config.ReleasePub` / `CARLOS_RELEASE_PUBKEY`) and the existing `{payload, sig}` wrapper convention (`release/release.go:487`, signing at `release/production.go:117`, verify at :160); `release.ReadSerial` (`serial.go:32`, `Serial int64`); activator hooks `Service.TenantAdmittedFunc`, `Service.TenantExempt`, `ExecBackend.TenantStartAllowed` (`activator/group_admission.go:11-34`); `(*ExecBackend).Start` :2092, `StartGen` :2136, `StartGenExe` :2163, `StartSidecar` :3294, `StartWorker` :3397, `StartWorkerStaged` :3433; `(*Service).doWakeOnce` (`activator.go:2501`); edge `HAAdmission{ TenantAdmitted() bool }` (`edge/group_admission.go:8`); `appconfig.UnitOps.Restart` call at `appconfig/unitsync.go:459`.
- Produces (**new**, package `managedboot`):
- `type ReadyRecord struct { Schema int "schema"; Kind string "kind"; Fleet, Label, Op string; ReadyAt time.Time "ready_at" }`, `const ReadyKind = "managed-ready"`.
- `func SignReady(priv ed25519.PrivateKey, r ReadyRecord) ([]byte, error)`: wrapper `{"payload": base64(json), "sig": base64(ed25519.Sign(priv, payloadB64))}`, deterministic.
- `func VerifyReady(pub ed25519.PublicKey, wire []byte, want Identity) (ReadyRecord, error)`: strict wrapper and payload decode, `Kind == ReadyKind`, schema 1, fleet/label/op equal, nonzero UTC ReadyAt; scoped grants refused.
- `const AdmissionPath = RootAdmissionDir + "/admission.json"`.
- - `func CommitAdmission(root string, wire []byte) error`: euid 0 only; `LoadIdentity`; `VerifyReady` with `Identity.ReleasePubkey`; dir must be root:root 0700 opened O_NOFOLLOW; write temp, fsync, rename, fsync dir; an existing valid record is kept (idempotent, never replaced).
- - `func RootAdmission(root string) (managed, admitted bool, err error)`: identity absent ⇒ (false, true, nil) BYO; identity present ⇒ admitted only if `AdmissionPath` is a root-owned 0600 single-link regular file in a root 0700 dir, opened O_NOFOLLOW, whose bytes re-verify; any doubt ⇒ (true, false, err).
+ - `func CommitAdmission(root string, wire []byte) error`: euid 0 only; `LoadIdentity`; `VerifyReady` with `Identity.ReleasePubkey`; dir must be root:root 0700 opened O_NOFOLLOW; write `admission.json` (temp, fsync, rename, fsync dir), then create the empty root 0600 `AdmittedMarker` (O_EXCL|O_NOFOLLOW, fsync, fsync dir) as the commit point; replay with a valid record and no marker completes the marker; an existing valid record is kept, never replaced. Nothing ever removes the marker.
+ - `func RootAdmission(root string) (managed, admitted bool, err error)`: identity absent ⇒ (false, true, nil) BYO; identity present ⇒ admitted only if `AdmittedMarker` exists as a root-owned regular file and `AdmissionPath` is a root-owned 0600 single-link regular file in a root 0700 dir, opened O_NOFOLLOW, whose bytes re-verify; any doubt ⇒ (true, false, err).
- Produces (**new**, host/instancectl/provision):
- `ReconcileConfig.Joining func() bool`: when true, `ownsRecord` returns false for every record (labelled, unlabelled, static, replica-assigned, sidecar) before the replica branch, and `Reconcile` returns nil before listing, minting or removing.
- Root door routes `POST /managed-admit` (body ≤4 KiB, the raw ready object) → `CommitAdmission`; `GET /managed-admission` → `{"managed":bool,"admitted":bool}`. `instancectl.Server` fields `ManagedAdmit func(wire []byte) error`, `ManagedAdmission func() (managed, admitted bool, err error)`; client methods `(*Client).ManagedAdmit(ctx context.Context, wire []byte) error`, `(*Client).ManagedAdmission(ctx context.Context) (managed, admitted bool, err error)`.
- Root door refuses POST `/start`, `/seed`, `/cmd`, `/tty`, `/parent`, `/demo-build`, `/demo-snapshot` with 409 `box is joining its fleet` (COPY) while `RootAdmission` is not admitted.
- - `func managedRootGate(root string) func() error`: used by every root-pass execution callback.
+ - `func managedRootGate(root string) func() error`: second-layer refusal kept on the round-1 root-pass callbacks only (`rootStartRoute`, `rootSelectedRestart`, `rollbackUnitRestart`, `productionUnitOps.Restart`, `productionNamedUnitRecovery`); no further wrappers are added.
+ - `func ensureManagedUnitDropIns(etcDir string) (changed bool, err error)` (host): on a managed box (`LoadIdentity`), calls `InstallAdmissionDropIns` with the declared named units and `InstallControlDropIn`; called from `ensureSystemUnits` before its daemon-reload/enable work, and from `InstallNamedUnits` before the declaration file is replaced. No-op on BYO.
- `type managedJoin struct` (agent side, advisory) with `func newManagedJoin(c *instancectl.Client) (*managedJoin, error)` (nil for BYO), `Joining() bool`, `TenantAdmitted() bool`, `TenantAdmissionExempt(registry.Route) bool` (false while joining), `TenantAdmissionStarting() bool` (true), `readyLeg(ctx context.Context, s release.Store, now time.Time, serial int64, serialOK bool) bool`; `const managedReadyBackstop = 60 * time.Second`; `fastDeps.managedReady func(ctx context.Context, now time.Time, serial int64, serialOK bool)`.
-**Census/review:** Root-binary units (provision, host, instancectl, activator wiring); authority inventory (start/serve surfaces, root admission door); the console ready-object writer changes (record-write census). Security review (Astra + Fable).
+**Census/review:** Root-binary units (provision, host, instancectl, activator wiring); every non-Markdown unit/drop-in byte change is root census scope; authority inventory (start/serve surfaces, root admission door); the console ready-object writer changes (record-write census). Security review (Astra + Fable).
+
+Why systemd, and which drop-in level (decisions rule 12):
+- Every workload process on a box, whatever code path asks for it (agent, root adoption, restart-only pass at `agent.go:5791` via `rootRestartRouteWith` (built at :5774, defined `rootrestart.go:544`), config sync at :5817, `rootrestart.go:343`, persisted rollback recovery `recoverRootRestarts` :5723 → `rootrollback_resume.go:143`, the root door), is a systemd unit from one of the workload templates or a declared named unit. A condition on the unit is the one boundary all of them share.
+- Template-level drop-ins (`<name>@.service.d/`) are read for every instance of that template, including instances created after the drop-in is installed, so new instances are covered without any per-instance write.
+- A prefix drop-in (`carlos-instance-.service.d/`) is rejected: it would also match maintenance units `carlos-instance-control.service`, `carlos-instance-probe.service` and `carlos-instance-rootfs-probe.service`. A global `service.d/` is rejected for the same reason.
+- Named units have operator-chosen names, so their drop-in is written per declared unit by `ensureManagedUnitDropIns` before the declaration exists; an undeclared unit is never started by any carlos path (`appconfig.DeclaredBinding`, `unitsync.go:455`).
+- With the condition unmet systemd records the start or restart job as skipped and nothing runs; callers may log success, which is safe. The existing code gates (round 1) remain as the first, louder layer.
+- `carlos-instance-control.service` needs `ReadWritePaths=/var/lib/carlos-managed-root` to commit admission under `ProtectSystem=strict`. It is installed only on managed boxes by a drop-in: on BYO boxes the directory does not exist, and a missing non-`-` ReadWritePaths entry fails the unit's namespace setup; BYO boxes also gain nothing from a wider root-door writable set. The directory stays root:root 0700.
- [ ] **Step 1: Write failing admission and gate tests.**
@@ -354,15 +386,48 @@ TestManagedReadySigned (console): published ready.json is SignReady(Config.Key,
mismatched object => uncertainty exactly as 2a's mismatch (no PUT, no revoke, no terminate);
Config.Key nil => no PUT, publishing stays pending with a COPY reason; C08/N4 witnesses
(TestManagedPublishDeadline, TestManagedDelayedPublicationFreshness) still pass.
-TestManagedRootAdmissionForgery (linux, as root in a user namespace, service UID = carlos):
- carlos cannot create, replace, rename into or symlink RootAdmissionDir/admission.json
+TestManagedRootAdmissionForgery (required job only, real uid 0 + mapped service uid; FAILS
+ when CARLOS_MANAGED_ROOT_TEST=1 is absent or the capability is missing, never skips):
+ the service uid cannot create, replace, rename into or symlink admission.json or admitted
(EACCES); a pre-placed symlink, hardlink, wrong owner, mode 0644, or dir mode 0770 =>
- RootAdmission (true,false,err); a carlos-owned file anywhere else claiming admission has no
+ RootAdmission (true,false,err); a service-uid file anywhere else claiming admission has no
effect; /start, /cmd, root pass start route all refuse in each case.
+TestManagedRootAdmissionChecks (unprivileged, fake root with configured expected owner): the
+ same refusal matrix for every check that does not need a second real uid (symlink, hardlink,
+ mode, missing marker, marker without verified record, record without marker).
TestManagedRootAdmitVerify: POST /managed-admit with unsigned, wrong-key, scoped-grant, other
kind, other fleet/label/op, trailing JSON or >4 KiB body => 4xx, no file written; valid object
- => record written, GET /managed-admission admitted=true; replay => 200, file unchanged;
- identity file tampered (not root-owned or group-writable parent) => refuse.
+ => admission.json then admitted written, GET /managed-admission admitted=true; replay => 200,
+ files unchanged; crash after admission.json before admitted => replay creates admitted;
+ identity file tampered (not root-owned or group-writable parent) => refuse; no code path
+ (grep witness over the tree) removes or truncates AdmittedMarker.
+TestManagedUnitConditionTree: install the real unitsFS units plus Task 2's drop-ins into a test
+ unit tree (etc + run layers); parse with a systemd-semantics loader (template drop-ins apply
+ to instances, lexical drop-in order across /etc and /run, empty assignment resets the
+ condition list) and, where `systemd-analyze` exists, also `systemd-analyze verify --root`:
+ every WorkloadUnits template and an instance of each (e.g. carlos-instance@shop.example.com
+ .service, carlos-instance-rootfs-worker@x.service) and a declared named unit carry
+ ConditionPathExists=/var/lib/carlos-managed-root/admitted as their effective last
+ assignment; no MaintenanceUnits unit carries it; adding the platform runtime drop-ins
+ (GenDropIn, JIT, egress, config-sync env) leaves the condition intact; none of them is named
+ AdmissionDropInName or contains a Condition directive.
+TestManagedRestartOnlyPassUnmet: joining box, valid named-unit declaration, pre-seeded routes and
+ restart marks; run the real -restart-only pass (agent.go:5791, rootRestartRouteWith) and config
+ sync against a fake systemd backed by the installed unit tree from the previous test => every
+ start/restart/try-restart job evaluates the condition as unmet and ends with no unit active;
+ after CommitAdmission writes admitted, the same pass starts the units.
+TestManagedRollbackRecoveryUnmet: joining box with a persisted rollback attempt on disk; run
+ recoverRootRestarts (agent.go:5723 -> rootrollback_resume.go:143 restartBoundUnit) => the
+ bound unit's restart is skipped (condition unmet), unit not active, attempt left for retry.
+TestManagedControlWritable: the effective installed carlos-instance-control.service (unit +
+ 60-carlos-managed-root.conf) has ProtectSystem=strict and ReadWritePaths containing
+ /run/carlos-control, /run/systemd/system and /var/lib/carlos-managed-root; BYO boxes get no
+ such drop-in; running bootstrap's install plan and ensureSystemUnits (as after a system
+ update) over a tree holding both drop-in sets leaves them intact or restores them.
+TestManagedControlCommitStrict (required job, real systemd as PID 1): instance-control started
+ from the installed unit commits admission under ProtectSystem=strict; the directory stays
+ root:root 0700; a gated template instance started before the commit is condition-skipped and
+ after it runs.
TestReconcileJoiningOwnsNothing: Joining()=true => ownsRecord false for labelled-own, unlabelled,
static, ReplicaAssignment containing box, sidecar records; Reconcile returns nil with zero
registry writes and zero store LISTs; Joining()=false => existing results unchanged.
@@ -374,6 +439,7 @@ TestManagedJoinStartSurfaces: with a valid named-unit declaration and pre-seeded
rootStartRoute (agent.go:5923 -> systemctlStartUnit), rootSelectedRestart, rollback restart,
SyncUnits' UnitOps.Restart (unitsync.go:459), named-unit recovery, root door /start (legacy,
gen, rootfs) /seed /cmd /tty /parent /demo-*; edge returns 503 "starting" for any route.
+ (Second layer: these are the round-1 code gates; the systemd condition is the guarantee.)
Platform maintenance keeps working: system update apply/rollback of /opt/carlos/carlos and
restarts of carlos-edge, carlos-instance-control and nftables; /stop /sweep GET /ready /size answer.
TestManagedJoinLiveServices: while joining the status heartbeat, tunnel dial, store-door reads,
@@ -397,7 +463,7 @@ TestManagedJoinBYOUnchanged: no identity file => no managedJoin, zero ready read
- [ ] **Step 2: Run the failing tests.**
-Run with an owned short socket dir: `TMPDIR=<owned-short-dir> GOFLAGS=-buildvcs=false go test ./internal/managedboot ./internal/provision ./internal/host ./internal/instancectl -run 'TestReconcileJoining|TestManagedJoin|TestManagedRootAdmi|TestManagedAdmission' -count=1` and `GOFLAGS=-buildvcs=false go test ./internal/console -run 'TestManagedReadySigned|TestManagedPublishDeadline|TestManagedDelayedPublicationFreshness' -count=1`; expect FAIL.
+Run with an owned short socket dir: `TMPDIR=<owned-short-dir> GOFLAGS=-buildvcs=false go test ./internal/managedboot ./internal/provision ./internal/host ./internal/instancectl -run 'TestReconcileJoining|TestManagedJoin|TestManagedRootAdmi(ssionChecks|tVerify)|TestManagedAdmission|TestManagedUnitConditionTree|TestManagedRestartOnlyPassUnmet|TestManagedRollbackRecoveryUnmet|TestManagedControlWritable' -count=1` and `GOFLAGS=-buildvcs=false go test ./internal/console -run 'TestManagedReadySigned|TestManagedPublishDeadline|TestManagedDelayedPublicationFreshness' -count=1`; expect FAIL.
- [ ] **Step 3: Sign the ready object on the console.**
@@ -407,7 +473,9 @@ Replace `managedReadyObject`'s plain JSON with `SignReady(s.cfg.Key, ...)`; the
- [ ] **Step 4: Make root the admission authority.**
`RunInstanceControl` sets `ManagedAdmit`/`ManagedAdmission` from `CommitAdmission`/`RootAdmission("/")` and wraps the listed start verbs; the root door's existing PeerOK (carlos-edge MainPID) still guards the socket.
-`runAdoptUnderRootRelease` computes `managedRootGate("/")` once per pass and wraps `rootStartRoute`, both `rootSelectedRestart` callbacks, `rollbackUnitRestart`, `productionUnitOps.Restart` and `productionNamedUnitRecovery`; system binary apply/rollback and fixed platform units are not wrapped.
+`CommitAdmission` is the only writer of `AdmittedMarker`; nothing removes it. The unit condition then admits every workload template and named unit at once, with no daemon-reload needed (systemd evaluates conditions at job start).
+`ensureSystemUnits` (`systemunits.go:56`) calls `ensureManagedUnitDropIns` on every non-restart-only root pass before its own daemon-reload/enable work, so the running (possibly updated) binary installs drop-ins for every workload template it ships; `InstallNamedUnits` (`unitops.go:48`) installs the named unit's drop-in under the same config-sync flock before replacing the declaration file.
+`runAdoptUnderRootRelease` keeps `managedRootGate("/")` on the round-1 callbacks as a second layer; the restart-only pass and persisted rollback recovery are covered by the unit condition and its witnesses, not by new wrappers. System binary apply/rollback and maintenance units are untouched.
The agent never writes admission state. `managedJoin` asks `GET /managed-admission` at arming and after each successful relay; its predicate is advisory defence in depth for agent-side surfaces.
On a BYO box every hook keeps its current value, so `fixedAdmission` (`host/group_admission.go:55`) behaves as on main; a managed box never constructs it, so group exemptions (`:81`) never apply while joining.
@@ -419,8 +487,9 @@ On a root 200: flip, then `d.fullDue.Store(true)`.
- [ ] **Step 6: Repeat Step 2 to PASS and commit.**
-Mutation checks (≤10): root trusts a carlos-writable path; CommitAdmission skips signature; follow symlinks on read; ownsRecord joining check after the replica branch; rootStartRoute ungated; UnitOps.Restart ungated; one ExecBackend start variant ungated; agent flips before root 200; ready read after admission; platform unit restart wrongly gated.
-Commit subject: `feat: root-owned admission gate for managed boxes`.
+Add the required CI job `.amadan/ci.d/40-managed-root-contract`, modelled on `30-minio-contract`: it checks its capability first (real uid 0 or a usable user namespace with root and a second mapped uid, and a systemd PID 1 for `TestManagedControlCommitStrict`) and exits non-zero naming what is missing; it runs `go test -v -count=1` with `CARLOS_MANAGED_ROOT_TEST=1` for `TestManagedCloudInitRootOwnership`, `TestManagedRootAdmissionForgery` and `TestManagedControlCommitStrict`, and requires each `--- PASS: <name> (` line, failing on skip, filter or rename. Build prerequisite: the controller confirms an amadan runner with that capability exists before Task 3 is built (the checked-in `.amadan/README.md` bubblewrap sandbox does not establish it); if none exists, stop and report.
+Mutation checks (≤10): root trusts a service-writable path; CommitAdmission skips signature; marker written before admission.json; follow symlinks on read; one workload template missing its drop-in; drop-in named to sort before platform drop-ins; prefix drop-in hitting carlos-instance-control; control drop-in omitted; ownsRecord joining check after the replica branch; agent flips before root 200.
+Commit subject: `feat: systemd-enforced admission gate for managed boxes`.
### Task 4: Mint and register the fleet's first secrets key
@@ -737,7 +806,10 @@ Merge only on Paul's go with `amadan branch merge carlos/platform managed-fleets
| §4 fetch binary through the store door and verify as platform boxes do | Task 2 stable pointer + artifact via store door; Task 1 seed by digest |
| 2a hard req: install current verified stable, never stale bootstrap | Task 2 `installManagedStable`, `TestManagedBootStableTrust` |
| 2a hard req: durable marker before any reconcile/start; survives reboot | Task 2 identity commit; Task 3 root record + reboot matrix |
-| 2a hard req: ownsRecord false for labelled/unlabelled/static; every start path refuses | Task 3 `TestReconcileJoiningOwnsNothing`, `TestManagedJoinStartSurfaces` incl. root adoption/config-sync/recovery |
+| 2a hard req: ownsRecord false for labelled/unlabelled/static; every start path refuses | Task 3 `TestReconcileJoiningOwnsNothing`; systemd condition (rule 12) via `TestManagedUnitConditionTree`, `TestManagedRestartOnlyPassUnmet`, `TestManagedRollbackRecoveryUnmet`; code gates `TestManagedJoinStartSurfaces` |
+| Rule 12: workload units carry the admitted condition, maintenance units none; marker written once | Task 2 `TestManagedBootUnitDropIns`, `TestManagedUnitClassification`; Task 3 `TestManagedRootAdmitVerify` |
+| Root door can persist admission under its hardening | Task 3 `TestManagedControlWritable`, required-job `TestManagedControlCommitStrict` |
+| Ownership/namespace witnesses cannot silently skip | Task 3 required job `40-managed-root-contract` (runner availability is a build prerequisite) |
| 2a hard req: ready GET only while joining, per serial or 60 s; zero after | Task 3 ready leg tests; Task 6 budget |
| 2a hard req: ready.json console-written only | 2b-1 Task 6 ACL; Task 3 console signature verified by root; Task 7 V6 |
| Gate absent must not fail open; root never trusts agent-written state | Task 3 `RootAdmission`, `TestManagedRootAdmissionForgery` |
@@ -761,17 +833,18 @@ Merge only on Paul's go with `amadan branch merge carlos/platform managed-fleets
| C08 consumed publication | Review Focus 2; Tasks 3 and 6 |
| Frozen retry bytes | Task 1 golden + `TestManagedBootFrozenAtLaunch`; Task 6 adapter recovery |
-Type check: `managedboot.Frozen`, `LaunchInput`, `Identity`, `ReadyRecord`, `FleetKey`, `KeyStatus`, `ProbeRequest`/`ProbeReply` are defined once (Tasks 1-5) and consumed by later tasks with the same names; the earlier agent-writable `State` type is gone.
+Type check: `managedboot.Frozen`, `LaunchInput`, `Identity`, `WorkloadUnits`/`MaintenanceUnits`, `AdmittedMarker`, `ReadyRecord`, `FleetKey`, `KeyStatus`, `ProbeRequest`/`ProbeReply` are defined once (Tasks 1-5) and consumed by later tasks with the same names; the earlier agent-writable `State` type is gone.
Every Review Focus line names a test in its owning task. No implementation bodies are prescribed; tests list observable assertions.
Not covered here by design: hub fallback for unlabelled routes can pick a joining box (`fleetChannelFor`, `edge.go:3889`); harmless with one box and no prior apps, listed for 2c.
Dependency order: Task 1 defines the frozen inputs and wire the box consumes; Task 2 produces the root-owned identity Task 3 verifies against; Task 4 runs inside Task 2's state machine and relies on Task 3 keeping the box closed on failure; Task 5 needs Task 2's identity and Task 4's fingerprint; Task 6 composes all of them with 2b-1's adapters; Task 7 needs a release containing both slices.
-## Paul's rulings recorded (decisions.md 9-11, 2026-11-08)
+## Paul's rulings recorded (decisions.md 9-12, 2026-11-08)
1. **Seed delivery (rule 9).** The console streams the frozen signed stable binary through `POST /api/fleet/enrol/seed` to an unused enrolment token without consuming it; no public URL and no custom AMI. Implemented in Task 1.
2. **Owner key registration on managed fleets (rule 10).** `carlos fleets secrets-key` refuses on managed fleets until 2c designs key replacement. Implemented in Task 4.
3. **Drill leftovers (rule 11).** Every AWS resource is deleted (instance, bucket including all versions, IAM user and keys, SG); the dev console keeps the `drill-2b` fleet and box records, noted in the drill log and removed via 2d; no hand DB edits. Implemented in Task 7.
+4. **Start gating invariant (rule 12, stopping rule 2).** Workload units carry `ConditionPathExists=/var/lib/carlos-managed-root/admitted` via root-owned drop-ins installed by managed-boot; maintenance units carry none; per-path code gates remain a second layer. Implemented in Tasks 2-3.
## Deferred to 2c/2d
@@ -800,3 +873,11 @@ Round 1 (Astra, `/home/paulca/.cache/managed-fleets-2b-notes/review-2b2-r1.md`,
- P2-8 concrete approval scope: Fixed. Task 7 Step 1 allows the read-only preflight (AMI and network describes, `tofu plan`) needed to fill the card; mutations and the drill wait for Paul's approval.
Paul's rulings on this plan's three open questions are recorded above as decisions 9-11.
+
+Round 2 (Astra, `/home/paulca/.cache/managed-fleets-2b-notes/review-2b2-r2.md`, verdict NOT READY): 2 P1, 1 P2, all accepted by the controller and fixed in this plan.
+
+- P1 admission persistence: Fixed. Managed boxes get a managed-only drop-in `carlos-instance-control.service.d/60-carlos-managed-root.conf` adding `ReadWritePaths=/var/lib/carlos-managed-root` (BYO boxes lack the directory, which would fail namespace setup, and need no wider root-door write set); the directory stays root:root 0700. Task 2 installs it before bootstrap; Task 3 `ensureSystemUnits` re-asserts it; `TestManagedControlWritable` and required-job `TestManagedControlCommitStrict`.
+- P1 complete start gating (second round in this fault family): Paul ruled under stopping rule 2 (decisions rule 12, invariant). Every workload template (`carlos-app@`, `carlos-instance*@` incl. rootfs/sidecar/cmd/tty/seed/gen/worker, `carlos-demo-build@`, `carlos-demo-snapshot@`, `carlos-dbread@`) and every declared named unit carries a template-level or per-unit root-owned drop-in `zz-carlos-managed-admission.conf` with `ConditionPathExists=/var/lib/carlos-managed-root/admitted`, installed by managed-boot before any workload unit exists and re-asserted by `ensureSystemUnits`; maintenance units carry none; the marker is written once by the verified commit and never removed. Per-path gates stay as the second layer; no new wrappers. Witnesses: `TestManagedUnitConditionTree`, `TestManagedRestartOnlyPassUnmet`, `TestManagedRollbackRecoveryUnmet`.
+- P2 mandatory verification coverage: Fixed. The rendered-script test runs unprivileged with a root prefix, configurable expected owner and shims, and never skips; real-uid ownership, forgery and strict-unit commit tests run only in the new required job `.amadan/ci.d/40-managed-root-contract`, which fails on missing capability and requires explicit `--- PASS:` lines. A capable runner is a 2b-2 build prerequisite to confirm, not a claim.
+
+Review closed after round 2 (three-round limit reached for the plan's review budget; Paul ruled the repeat family).