carlos / platform Public

docs: managed fleets 2b-2 plan and build ledger

Plan copied from managed-fleets-2b-plan (55d99085), approved by Paul
2026-11-09. Ledger records the 2b-1 carry-item rulings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 1cf2194b044c02d3029610a1d30fd902af3d9a4d parent 97c70fe
2 files changed, +924 −0
  • docs/superpowers/notes/managed-fleets-2b2-ledger.md +41 −0
  • docs/superpowers/plans/2026-11-08-managed-fleets-2b2-box-side.md +883 −0

CI passed — run details

diff --git a/docs/superpowers/notes/managed-fleets-2b2-ledger.md b/docs/superpowers/notes/managed-fleets-2b2-ledger.md
new file mode 100644
index 000000000..d571e74ec
--- /dev/null
+++ b/docs/superpowers/notes/managed-fleets-2b2-ledger.md
@@ -0,0 +1,41 @@
+# SDD ledger — plan: docs/superpowers/plans/2026-11-08-managed-fleets-2b2-box-side.md
+
+Managed fleets 2b-2 build ledger: tasks, commits, review results, rulings and deferred minors.
+Branch managed-fleets-2b2, base main 97c70feb (2b-1 merged), plan 55d99085 (approved by Paul 2026-11-09).
+Controller: Opus session (build-2b2 handoff from 8423ef5). Implementers: Opus subagents, one per task.
+Reviews: Astra (codex gpt-6-astra, high) every task; Fable (claude-fable-5-1) also on Tasks 2-5, Task 6 wiring and the
+whole branch. Later rulings supersede earlier ones on the same point.
+
+Ruling: SDD workspace (briefs, reports, review packages) lives in /home/paulca/.cache/managed-fleets-2b-notes/sdd2b2;
+the worktree stays clean — cost if wrong: none.
+Ruling: Task 1 is reviewed by Astra alone; the plan's "Task 1 + Task 2 as one security unit" is honoured by giving
+Task 2's Astra + Fable review the Task 1 diff as context — cost if wrong: a Task 1 seam defect surfaces one task later.
+
+## 2b-1 carry items (2b-1 ledger "carried to 2b-2")
+
+Ruling: C1 (Fable F-1) a DescribeImages failure before RunInstances is dispatched is classed ambiguous and holds quota
+forever with an hourly Find. Fixed in Task 6 (pre-switch-on): a failure that provably precedes dispatch is a definite
+not-launched outcome (box fails, quota released, reason recorded); only post-dispatch ambiguity holds quota (C08 rules
+unchanged) — cost if wrong: a drill box's quota stuck until 2d removal.
+Ruling: C2 (Fable F-2 / T2 P3-1) a fleet whose keep key is gone has no recovery path. Task 6 makes the state visible
+and bounded: a confirmed-absent keep key (successful list, key not present) surfaces as needs-operator with a reason
+naming it, never a silent hold; minting a replacement keep key is 2c key replacement (rule 10 territory) — cost if
+wrong: an operator deletes the user's key by hand and the fleet stays needs-operator until 2c.
+Ruling: C3 (Fable F-8) runbook note: deleting the earlier delivered access key removes that box's bucket access.
+Written into the Task 7 drill card's cleanup notes and the managed-fleets runbook section touched by Task 6 docs — cost
+if wrong: none (note only).
+Ruling: C4 (Fable F-3 / T6 P3-2) a box can write a sibling's heartbeat/status objects (all boxes of one fleet share one
+IAM user). Accepted for 2b-2 as one trust domain (one owner, one fleet user); readiness must not rest on the heartbeat
+alone: Task 5 passes `router_probe` only on an exact echo with the hub's channel attestation for that box, and Task 5
+adds a witness that a sibling-written heartbeat without the exact-channel probe never makes a box ready. Per-box IAM is
+out of scope — cost if wrong: a compromised sibling can fake liveness for its own fleet only.
+Ruling: C5 s3:DeleteObjectVersion stays out of the fleet-data policy in 2b-2: no 2b-2 path moves a managed box or
+deletes versions (probe objects use DeleteObject, which writes a delete marker under versioning); managed-fleet moves
+are 2c and grant it with a named consumer there. The drill exercises no move — cost if wrong: a move on a managed fleet
+fails AccessDenied (none is offered before 2c).
+Ruling: C6 drill checks for the RunInstances snapshot resource permission and the EBS default encryption key go on the
+Task 7 card as read-only preflight (`aws ec2 get-ebs-default-kms-key-id`, describe of the AMI's snapshot) plus one
+`run-instances --dry-run` listed as the first post-approval step — cost if wrong: the drill's first launch fails
+UnauthorizedOperation and is cleaned up by the deadline.
+
+## Tasks
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
new file mode 100644
index 000000000..c0ac9be26
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-08-managed-fleets-2b2-box-side.md
@@ -0,0 +1,883 @@
+# Managed fleets 2b-2: box side and the first real box Implementation Plan
+
+> **For agentic workers:** Follow the controller's execution contract task-by-task; implementers do not spawn subagents. Steps use checkbox (`- [ ]`) syntax for tracking.
+
+**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 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.
+
+**Spec:** `docs/superpowers/specs/2026-10-28-managed-fleets-design.md` §4 Phase 2 (enrolment, secrets key, born examined, ready means ready, diagnostics) and "Phase 2 addendum (Paul, 2026-11-01)", §5 provider boundary, §6 request budget, §7 switch-on, §8 acceptance. Binding split/rulings: `/home/paulca/.cache/managed-fleets-2b-notes/decisions.md` ("2b-2" = recon tasks 6-11; Paul's rules 9-11). Recon: `/home/paulca/.cache/managed-fleets-2b-notes/recon.md` §§3, 4, 6, 7, 9, 10, 11. Sibling: `docs/superpowers/plans/2026-11-08-managed-fleets-2b1-console-aws.md`. Predecessor: `docs/superpowers/plans/2026-11-01-managed-fleets-2a-core.md` "Deferred to 2b-2d"; ledger `docs/superpowers/notes/managed-fleets-2a-ledger.md`.
+
+Source baseline is main `9622c65a159480a687f066f7a24e28a31c68360d` plus the 2b-1 plan as written (its branch is being built now).
+Existing signatures cited below were rechecked in that checkout on 2026-11-08, including every seam added in review round 1. Declarations marked **new** are this plan's decisions.
+Every 2b-1 interface consumed is named exactly as the 2b-1 plan defines it (section "Consumed from 2b-1").
+This draft writes only this file; it runs no tests, makes no commits and dispatches no agents.
+
+## Global Constraints
+
+Execution facts (controller brief, 2026-11-08; these supersede decisions.md rule 8's implementer/reviewer pairing for 2b-2):
+
+- One branch, `managed-fleets-2b2`, cut from main after 2b-1 merges. Tasks commit in order; one reviewed squash merge at the end, on Paul's explicit go.
+- Opus implements. Astra reviews; Fable also reviews the security and termination tasks (Tasks 2, 3, 4, 5 and Task 6's wiring/diagnostics). Stop at the first review round with no P1; three rounds maximum; two rounds in one fault family go to Paul.
+- Carry 2a's closed rounds 1-3, the C01-C14 pre-flight rulings, 2b-1's closed review and this plan's review history in every brief. Splitting 2b resets nothing and reopens neither the joining gate nor C08.
+- Commit subjects under 80 characters (79 max) with a blank line before the body.
+- No tenant names. Neutral examples only: shop, example.com, production; the drill fleet is `drill-2b`.
+- Member-facing copy (refusals, readiness reasons, show text, docs) is marked `COPY` by implementers and goes through the controller's copy review before merge. Breadcrumb codes and log lines are not member copy.
+- Provider-neutral core: no AWS SDK import outside `internal/awsmanaged`; `TestManagedCoreImports` (`internal/compute/imports_test.go:13`) is extended to `internal/managedboot`.
+- Request budget (spec §6): no new steady-state per-box polling; numbers in "Request budget" below. Joining-only reads are bounded; zero ready reads after admission.
+- Verification budget: targeted `-run` selections on touched packages, `-count=1`; never run the whole `internal/console` package locally; at most ~10 mutation checks per risky task (Tasks 2-5); one `-race` run over touched packages in Task 6; CI owns full suites and darwin/windows/linux-arm64 cross-builds.
+- Go: `GOFLAGS=-buildvcs=false`; leave GOCACHE at its default. Socket-path tests use an owned short directory on disk under `$TMPDIR` or `~/.cache`, never `/tmp`.
+- Census: every task names whether it touches root-binary units, refusal doors, record-write or authority inventories. `make census-card` / `make census-propose NAME=managed-fleets-2b2 CLAIMS=<owned-file>`; an independent reviewer's approval is recorded on discussion #280 at the reviewed tip.
+- No live AWS mutation before Paul approves the Task 7 drill card. The only live AWS calls allowed earlier are Task 7's read-only preflight (AMI/subnet/VPC describes, `tofu plan`) needed to fill the card. Tests use mocked clients/transport with IMDS disabled.
+- `enabled` stays false in every deployment until the approved drill; production providers are constructed only when the operator opts in (Task 6).
+- `CARLOS_HOST_CLAIM` stays an explicit refusal for every managed path, including the new console doors (decisions rule 7). No gated-SQL escape hatch.
+- Preserve C08: a matching published ready.json may already have admitted the box; console uncertainty never revokes, overwrites, deletes or terminates it, and the box never returns to joining.
+- 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
+
+1. **Reboot between the trade and durable staging.** The console has consumed the token and released credentials, but the box restarts before its staged commit is durable. Expected: no partially written credentials or host.env survive, no second credential release, the box runs nothing and ends at breadcrumb `enrol_failed`, and the console's 20-minute deadline cleans it up. A reboot after the commit resumes with zero further enrol calls. Owner: Task 2 `TestManagedBootRebootBoundaries`.
+2. **The box consumes ready.json, then console verification fails (C08).** The PUT succeeded, root committed admission, and the console's verifying GET is lost or reads a mismatch. Expected: root's admission record stays, the box keeps serving and makes zero further ready reads; the console stays `publishing`/uncertain, holds quota, and never revokes or terminates. Owners: Task 3 `TestManagedAdmissionOneWay`; Task 6 `TestManaged2B2ConsumedPublicationUncertain`.
+3. **A tampered or unsigned stable binary.** The pointer has a bad or scoped-key signature, the artifact hash differs, the linux-arm64 artifact is missing, or the staged file changes between fetch and first exec. Expected: nothing executes, breadcrumb `bootstrap_failed`, no admission. Owner: Task 2 `TestManagedBootStableTrust` (seed side: Task 1 `TestManagedCloudInitScriptRun`).
+4. **Two first boxes race to mint the fleet key.** A `--boxes 3` create launches three boxes with no key yet. Expected: exactly one private object exists, every box installs that key, the registry fingerprint equals the object's, and no box ever overwrites or registers a different key. Owner: Task 4 `TestManagedFleetKeyFirstWriterWins`.
+5. **A router probe answered by a sibling box.** The target channel is disconnected while siblings are connected, or a misrouted request reaches another box. Expected: the hub never falls back to another channel; a box answers only probes naming its own fleet/label/op; the console passes `router_probe` only on an exact echo with the hub's channel attestation. Owner: Task 5 `TestFleetProbeExactChannel`.
+
+---
+
+## Consumed from 2b-1 (names exactly as that plan defines them)
+
+| 2b-1 task | Interface consumed here |
+|---|---|
+| 1 | Internal sentinel `errManagedEnrolRetryable` → HTTP 503 with `Retry-After: 5`, `Cache-Control: no-store`; unknown/expired/used token → generic 403 (terminal for the client); 429 keeps `Retry-After: 60` |
+| 2 | `(*Server).launchManagedBox(ctx context.Context, b managedBox, now time.Time, firstDispatch bool) error`; `compute.ErrLaunchConflict`; `ReadinessCheckedAt` (`readiness_checked_at`); `refreshManagedPublication`; durable table `managed_fleet_delivered_keys(fleet, account, key_id)`; `credential_state`/`credential_reason` with `needs-operator`; enrolment 503 while needs-operator |
+| 2 | `RotateFleetCredentials(ctx context.Context, fleet, keep string, delivered []string) (Credentials, error)`, `fleetstore.ErrDeliveredKeyStillLive` |
+| 3 | `awsmanaged.ComputeConfig{Deployment, AccountID string; Regions []string}`, `awsmanaged.NewCompute(ctx context.Context, cfg ComputeConfig) (*Compute, error)`; `Compute.ConsoleOutput` returns only `sanitizeConsoleOutput` codes `seed_verified`, `enrol_pending`, `enrol_failed`, `stable_verified`, `joining`, `bootstrap_failed` (≤32 lines) |
+| 3 | UserData is opaque frozen bytes, ≤16,384 decoded bytes, encoded once; adapter refuses larger |
+| 4 | `awsmanaged.StorageConfig{Deployment, AccountID, IAMRegion, BucketPrefix, UserPath, BoundaryARN string; Regions []string}`, `awsmanaged.NewStorage(ctx context.Context, cfg StorageConfig) (*Storage, error)`; test-only `NewComputeWith`/`NewStorageWith(ctx, cfg, transport HTTPClient)` in `internal/awsmanaged/export_test.go` |
+| 4 | `fleetstore.Credentials.ID` = AWS access-key ID; `Secret` = UTF-8 secret-access-key bytes (JSON base64) |
+| 4 | Fleet-data policy paths: `instances/*`, `moves/*`, `move-snapshots/*`; `system/fleet-secrets-key.json` GetObject + PutObject only with `s3:if-none-match = "*"` (no delete); `_carlos/probes/*` Get/Put/Delete |
+| 5 | Module variables `managed_fleets_enabled`, `managed_fleets_deployment`, `managed_fleets_regions`, `managed_fleet_bucket_prefix`, `managed_fleet_user_path`; outputs `managed_fleet_user_boundary_arn`, `managed_fleet_user_path`, `managed_fleet_bucket_prefix` |
+| 6 | `managedReadyObjectKey(fleet, key string) bool`: store door denies PUT/DELETE of every `fleets/<fleet>/boxes/<label>/ready.json`; GET remains |
+
+If 2b-1 lands with a different name for any of these, the implementer stops and reports; the plan is amended by the controller, not adapted silently.
+Task 3 changes the ready object's encoding (2a's `managedReadyObject`, `managedworker.go:569`) to a signed wrapper; 2b-1's publication and freshness logic is otherwise consumed unchanged.
+
+## File map
+
+| 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,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 |
+| 7 | New `docs/superpowers/notes/managed-fleets-2b2-drill-card.md` (approval card after read-only preflight), drill log after approval only |
+
+## Request budget (spec §6 numbers this plan commits to)
+
+| Actor and phase | Calls | Bound / test |
+|---|---|---|
+| Console worker, idle or all boxes settled | 0 SQL, store, provider, probe | Task 6 `TestManaged2B2Budget` (extends 2a `managedbudget_test.go:58`) |
+| Console, reserved→launching | 1 stable pointer GET per worker pass (shared by all boxes in the pass) | Task 1 `TestManagedBootFrozenAtLaunch` |
+| Console seed door | 1 artifact stream per box boot (+ retries within expiry) | Task 1 `TestManagedSeedDoor` |
+| Box first contact | 1 trade (+ 503/429 retries), 1 pointer GET, 1 artifact GET via store door | Task 2 `TestManagedBootTradeRetry`, reboot matrix |
+| Box fleet key | first box ≤2 GET + 1 create-only PUT; later box 1 GET | Task 4 key tests |
+| Joining box, ready.json | 1 GET at arming, ≤1 per observed serial change, else ≤1 per 60 s; relay to root is a local socket call | Task 3 `TestManagedJoinReadyLeg` |
+| Admitted box, ready.json | 0, forever, including after reboot and binary updates | Task 3 `TestManagedAdmissionOneWay`; Task 2 `TestManagedBootUpdateReboot` |
+| Enrolled box readiness | ≤1 heartbeat GET + ≤1 hub probe per 60 s; probe = 3 fleet-bucket requests | Task 5 `TestManagedProbeBudget` |
+| Ready/failed boxes | 0 probes, 0 heartbeat reads by the managed worker | Task 5, Task 6 |
+| Failed launched box | exactly 1 ConsoleOutput at the deadline | Task 6 `TestManaged2B2Diagnostics` |
+
+The serial read every ~2 s and the status heartbeat are existing BYO fleet-box traffic; this plan adds nothing to them.
+
+## Inherited items this plan closes or carries
+
+- 2a plan :922 "current verified stable binary": Task 2. :923 durable marker incl. statics, bootstrap/status/probes still run: Tasks 2-3. :924 ready GET bounds: Task 3. :926 allowlists, digest before exec, IMDS barrier, scrub, genuine directory inspection: Tasks 1-2. :927 storage, router, first-box key, approved drill: Tasks 4, 5, 7. :928 first-box private-key persistence: Task 4.
+- Recon §3 "freeze what empty covers": the attested set is `/data` only (absent or an empty directory, not a symlink), scanned before anything writes under it.
+- Recon §3 "gate absent must mean known admitted/BYO": identity present + no valid root admission record is joining (Task 3 fail-closed tests).
+- 2b-1 Task 1: the client contract is 503/429 retried within the original expiry, 403 terminal; Task 2 implements it.
+- 2a T7 M5 (client cancellation after claim can sacrifice a box) stays accepted: the client never cancels a trade mid-request; a lost reply ends at `enrol_failed` and deadline cleanup.
+- 2a final-review :108 (short transport-only CLI retry window) is a CLI item, untouched here.
+- C08 and 2b-1's N4 freshness rule: the box side never re-checks or revokes its own admission (Task 3).
+
+### Task 1: Freeze boot inputs, render cloud-init and serve the seed
+
+**Files:**
+- Create: `internal/managedboot/frozen.go`, `userdata.go`, `breadcrumb.go`, `cloudinit_v1.sh.tmpl`, `testdata/userdata-v1.golden`, `userdata_test.go`, `userdata_linux_test.go`.
+- Modify: `internal/console/managedstore.go` (managedBox field, AdvanceManagedBox invariant at :374), `managedworker.go` (`managedLaunchRequest` at :236, reserved→launching at :296), `managedenrol.go` (reply fields), `server.go` (route beside `POST /api/fleet/enrol` at :2234).
+- Create: `internal/console/managedseed.go`, `managedseed_test.go`; extend `managedenrol_test.go`, `internal/compute/imports_test.go`.
+
+**Interfaces:**
+- Consumes: existing `(*Server).managedLaunchRequest(b managedBox) (compute.LaunchSpec, error)`; `deriveManagedEnrolToken` (`managedstore.go:74`); `(*Server).managedStable(ctx context.Context) (*release.SystemPointer, error)` (`managedready.go:27`); `Config.Origin`, `Config.TunnelHost`, `Config.ReleasePub`, `Config.Releases`; 2b-1 `launchManagedBox(..., firstDispatch bool)`.
+- Produces (**new**, package `managedboot`):
+ - `const FormatV1 = 1`; `const MaxUserDataBytes = 12288`; `const SeedArtifactPlatform = "linux-arm64"`.
+ - `const BootDir = "/var/lib/carlos-managed-boot"`; `BootInputPath = BootDir + "/boot-input.json"` (full LaunchInput, root 0600); `SeedRequestPath = BootDir + "/seed-request.json"` (token only, root 0600, deleted after the seed is verified).
+ - `type Frozen struct { Format int "format"; ConsoleOrigin string "console_origin"; TunnelHost string "tunnel_host"; ReleasePubkey string "release_pubkey"; SeedVersion string "seed_version"; SeedKey string "seed_key"; SeedSHA256 string "seed_sha256" }` (JSON tags as quoted).
+ - `func (f Frozen) Validate() error`; `func (f Frozen) IsZero() bool`.
+ - `type LaunchInput struct { Frozen Frozen "frozen"; Fleet, Label, Op, Token string; Expires time.Time }` with JSON `fleet`, `label`, `op`, `token`, `expires`; `func DecodeLaunchInput(b []byte) (LaunchInput, error)` (strict, unknown fields refused).
+ - `func RenderUserData(in LaunchInput) (string, error)`: pure; refuses any field failing its allowlist or output above MaxUserDataBytes.
+ - Breadcrumb codes `CodeSeedVerified`, `CodeEnrolPending`, `CodeEnrolFailed`, `CodeStableVerified`, `CodeJoining`, `CodeBootstrapFailed` with values exactly 2b-1's six codes; `func Breadcrumb(code string) string` returns `"CARLOS_BOOT:" + code`.
+- Produces (**new**, console): managedBox field `Boot managedboot.Frozen` JSON `boot`; `(*Server).managedBootFrozen(ctx context.Context) (managedboot.Frozen, error)`; `(*Server).handleManagedSeed(w http.ResponseWriter, r *http.Request)` on `POST /api/fleet/enrol/seed` with strict body `{"token"}` only; `(*Server).managedSeedFor(ctx context.Context, token string, now time.Time) (managedboot.Frozen, error)`; managedEnrolReply gains `Bucket string "bucket"`, `BucketRegion string "bucket_region"`, `Operation string "op"`.
+
+**Census/review:** New public refusal door (`/api/fleet/enrol/seed`, Paul rule 9) and a changed enrol reply: refusal-door and authority census. `internal/managedboot` enters the root binary (Task 2 imports it): root-unit census. Reviewed with Task 2 as one security unit.
+
+- [ ] **Step 1: Write the failing renderer, script, freeze and seed-door tests.**
+
+```text
+TestManagedUserDataGolden: fixed LaunchInput => bytes equal testdata/userdata-v1.golden;
+ two renders equal; no time.Now, randomness, map order or gzip in output; len <= 12288.
+TestManagedUserDataAllowlist: each field rejected when invalid, nothing rendered:
+ fleet/label not ^[a-z0-9-]{1,32}$; op not 32 lowercase hex; token not 64 lowercase hex;
+ origin not https://<hostname>[:port] with no path/query/userinfo; tunnel host not a hostname;
+ pubkey not std-base64 of 32 bytes; seed key not ^bootstrap/router/[0-9A-Za-z._-]+/carlos-linux-arm64$;
+ sha not 64 lowercase hex; expires zero or non-UTC; Format != 1.
+ Injection probes (quote, $(), backtick, newline, NUL, unicode line separator) in every field => error.
+TestManagedUserDataSecrets: token appears exactly twice, only inside the two root-only heredocs
+ (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, 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
+ -o and the body sent is the token-only file; wrong seed bytes => helper refuses, no exec,
+ 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).
+ 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;
+ recovery after restart re-renders identical UserData even after stable/config/origin change;
+ AdvanceManagedBox refuses any later Boot change; launching box with zero Boot => no Launch.
+TestManagedSeedDoor: valid unused token in launching/booting window => 200 octet-stream of the
+ frozen SeedKey bytes, Content-Length set, Cache-Control no-store; token NOT consumed (enrol still 200 after);
+ unknown/used/expired/before-launch token => identical 403; store failure => 503 Retry-After 5;
+ IP limiter before deployment limiter (shared with enrol); HostClaim => 409; >4 KiB, unknown field
+ (a full LaunchInput included) => 400; more than 4 concurrent streams => 503 Retry-After 5;
+ response never contains the token.
+TestManagedEnrolReplyFields: 200 reply carries bucket, bucket_region, op equal to the box's
+ frozen Storage and OpID; existing fields unchanged; 403/503 bodies unchanged.
+TestManagedCoreImports: internal/managedboot added; still no AWS SDK import.
+```
+
+- [ ] **Step 2: Run the targeted failing tests.**
+
+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.**
+
+The template is `#!/bin/sh`, embedded with `//go:embed`, rendered by `text/template` with values already allowlisted; each value is emitted single-quoted. Plain text only (no gzip), so output never depends on a compressor version.
+`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`). 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.
+6. `curl --proto =https --tlsv1.2 -fsS --retry 20 --retry-max-time 600 --max-filesize 100663296 -H 'Content-Type: application/json' --data-binary @seed-request.json -o BootDir/seed.part <origin>/api/fleet/enrol/seed`; write `seed.sha256`; run the verify helper against `seed.part`; rename to `seed`; delete `seed-request.json`; emit `seed_verified`.
+7. Write `/etc/systemd/system/carlos-managed-boot.service`: `[Unit] Requires=nftables.service`, `After=nftables.service`, `Before=carlos-edge.service`; `[Service] Type=oneshot`, `RemainAfterExit=yes`, `ExecStart=` verify helper then `BootDir/seed system managed-boot --input BootDir/boot-input.json`; `[Install] WantedBy=multi-user.target`. Write drop-in `carlos-managed-boot.service.d/10-enrol.conf` with `Wants=network-online.target` and `After=network-online.target` (removed by Task 2 at completion). Write `carlos-edge.service.d/60-managed.conf` with `Requires=` and `After=carlos-managed-boot.service`.
+8. `systemctl daemon-reload`, `systemctl enable carlos-managed-boot.service`, verify helper, `systemctl start carlos-managed-boot.service`.
+
+Do not copy group-only pieces: lifecycle hook, `Restart=no`, group marker, SSM fetches, awscli.
+
+- [ ] **Step 4: Freeze Boot at the reserved→launching commit and render user data from it.**
+
+`managedBootFrozen` reads the pass's verified stable pointer once, takes `Current.Artifacts["linux-arm64"]`, base64-encodes `Config.ReleasePub`, and validates the result.
+Persist it in the same CAS that sets `LaunchStartedAt`/`EnrolExpires`; 2b-1's firstDispatch call happens only after that commit.
+AdvanceManagedBox: once `before.Boot` is nonzero it must equal `after.Boot`; `after.Launch.UserData` stays empty in SQL (the token is never stored).
+`managedLaunchRequest` returns an error for zero Boot and otherwise sets `spec.UserData` from `RenderUserData` with the derived token; 2a's JSON user data is removed.
+
+- [ ] **Step 5: Add the seed door and the additive enrol reply fields.**
+
+Strict 4 KiB `{"token"}` decode; HostClaim refusal; reuse `s.cli.managedEnrolIP` then `managedEnrolGlobal`.
+Token lookup is the enrol lookup's hash path with the same state/window predicate (`managedenrol.go:82`) but no CAS and no state change.
+Stream via `release.Opener` (`S3Store.Open`, `store.go:930`) when the store implements it, else Get, capped at 96 MiB; the box verifies the digest, the console does not vouch for bytes.
+A package-level semaphore of 4 bounds concurrent streams. Refusal bodies are COPY.
+The door never reveals whether a token exists: unknown, used, expired and not-yet-launched answer the same 403 body as enrolment.
+Log lines name the fleet/label and outcome only; the token, its hash and the request body are never logged.
+
+- [ ] **Step 6: Repeat Step 2 to PASS; run `TestManagedFrozenLaunchRetryAcrossConfigChange` and `TestManagedEnrolReplayAndRace` once; commit.**
+
+Mutation checks (≤7): drop one allowlist regex; render the token into the curl argv; send boot-input.json as the seed body; skip the Boot immutability check; consume the token in the seed door; skip the verify helper before exec; allow zero Boot launch.
+Commit subject: `feat: frozen managed cloud-init and token-bound seed door`.
+
+### Task 2: Run first contact: gate, attest, trade once, stage durably, install stable, start edge
+
+**Files:**
+- Create: `internal/managedboot/enrolwire.go`, `identity.go`, `hostenv.go` and tests.
+- Create: `internal/host/managedboot.go` (state machine, platform-neutral), `managedboot_linux.go` (fs, nft, systemd), `managedboot_other.go` (refuses), `managedstable.go`; tests `managedboot_test.go`, `managedboot_linux_test.go`, `managedstable_test.go`.
+- Modify: `system.go` (`systemVerb` list at :56, `runSystem` switch) to add `managed-boot`.
+
+**Interfaces:**
+- Consumes: Task 1 `LaunchInput`, `DecodeLaunchInput`, `Frozen`, `Breadcrumb`, `BootDir`; `release.GetSystemPointer(ctx context.Context, s Store, pub ed25519.PublicKey, component, channel string) (*SystemPointer, string, error)` (`systempointer.go:259`); `release.FetchToFile(ctx context.Context, s Store, key, dst string, limit int64, wantSHA256 string) error` (`fetch.go:22`); `openFleetDoorStore(getenv func(string) string, identity FleetIdentity) (release.Store, error)` (`agent.go:5472`); `rootaws.ParseStaticCredentials(body []byte) (aws.Credentials, error)` (`credentials.go:15`); `hostenv.Render`/`Parse` (`hostenv.go:267`, :316); bootstrap exec pattern of `installGroup` (`hostenv/group.go:170`). Bootstrap enables but does not start carlos-edge (`bootstrap.go:247-250`, `systemctlPlanArming` :274-281, message :697).
+- Produces (**new**, package `managedboot`):
+ - `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 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)`.
+
+**Census/review:** Root-binary units (host, managedboot, system verb). Security review (Astra + Fable): verified execution, credential staging, scrubbing, service ordering.
+
+- [ ] **Step 1: Write failing first-contact tests against a fake root and fake console/store.**
+
+```text
+TestManagedBootFirewallOrdering: unit text has Requires=/After=nftables.service and the enrol
+ drop-in Wants=/After=network-online.target; table absent at start but present after 5 s
+ (fake clock) => proceeds; table never appears within 60 s => bootstrap_failed, zero HTTP
+ calls, edge start never queued; nft list errors => same; enrol drop-in removed (daemon-reload)
+ only after the complete marker is durable.
+TestManagedBootAttestation: /data absent => empty,0; empty dir => empty,0; one entry (incl. dotfile,
+ lost+found) => not empty, exact count, trade still sent honestly, console 403 => enrol_failed;
+ /data symlink or non-directory => not empty; scan happens before any write under /data.
+TestManagedBootTradeRetry: 503 Retry-After 5 and 429 retried until Expires, then enrol_failed;
+ transport error retried; 403 terminal at once; at most one 200 consumed; reply with wrong
+ fleet/label/op, tunnel_url != https://<TunnelHost>, joining=false, empty credentials or
+ bucket => refused, nothing staged, enrol_failed; secret never in logs/errors/breadcrumbs.
+TestManagedBootRebootBoundaries: crash injected after each durable step:
+ (a) before trade => next boot trades once; (b) after request sent, before reply => next boot
+ retries, console 403 => enrol_failed, nothing staged, no workloads, edge never queued;
+ (c) reply received, staging partially written => next boot removes the partial staging dir
+ (shredded), does not reuse partial credentials, 403 => enrol_failed;
+ (d) after commit rename => next boot makes ZERO enrol calls and continues;
+ (e) after scrub, key, stable install, bootstrap, complete marker each => resume without
+ repeating a completed network step; no root admission record exists at any point.
+TestManagedBootStartPlan: recorded systemctl argv after a first successful boot is exactly
+ daemon-reload, (bootstrap's own enable plan), daemon-reload after drop-in removal,
+ `start --no-block carlos-edge.service`, in that order, after the complete marker fsync;
+ the oneshot never runs a blocking `start carlos-edge`; crash between complete marker and
+ queueing => next boot's complete path queues `start --no-block carlos-edge.service` once.
+TestManagedBootUpdateReboot: complete box; /opt/carlos/carlos replaced by a later signed
+ version (as systemapply.go:676 renames it) => reboot: managed-boot complete path succeeds
+ without reading /opt/carlos/carlos, queues edge, makes zero enrol/store/ready calls;
+ interrupted update then the existing root recovery/rollback path restores a binary =>
+ 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 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,
+ scripts/part-001, instances/<id>/...) shredded; scrub failure => bootstrap_failed before bootstrap.
+TestManagedBootStableTrust: pointer signed by another key, scoped-key grant, wrong component/
+ channel, missing linux-arm64, artifact sha mismatch, oversize artifact, staged file swapped
+ or re-linked between fetch and first exec => nothing executed, bootstrap_failed, no admission;
+ valid pointer => /opt/carlos/carlos root 0755 equals signed sha, stable_verified emitted,
+ bootstrap argv run with clean env and cwd /, re-hashed immediately before that first exec.
+TestManagedBootNoDeploymentAuthority: staged env and child env never contain deployment bucket,
+ deployment dir, HOST_CLAIM, GROUP_ADMISSION, AWS profile selectors or the enrol token.
+TestManagedEnrolWireMatchesConsole (console package): managedboot wire types round-trip the
+ console's managedEnrolRequest/managedEnrolReply JSON exactly.
+```
+
+- [ ] **Step 2: Run the failing tests.**
+
+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) → `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.
+
+Trust chain the tests must keep intact (recon §3 "bootstrap trust cycle"):
+
+| Link | Trusted because |
+|---|---|
+| User data (token, seed digest, release pubkey, origins) | written by the console through RunInstances; readable afterwards only by uid 0/carlos via the IMDS gate |
+| Seed binary | its SHA-256 equals the frozen `SeedSHA256`, checked by the root-only helper immediately before each exec; TLS to the console is transport only |
+| Enrol reply | HTTPS to the frozen console origin, bound to the single-use token; cross-checked against frozen fleet/label/op/tunnel host |
+| Stable pointer and artifact | Ed25519 signature under the frozen root pubkey (`GetSystemPointer` rejects scoped grants), artifact SHA from the signed pointer, re-hashed before first exec; later updates by systemapply |
+| Ready object (Task 3) | console signature under the same frozen pubkey, verified by root from the root-owned identity file |
+| Fleet key object | create-only write under the fleet's own IAM user; validated public/private/fingerprint consistency; registered fingerprint must match |
+
+- [ ] **Step 4: Implement `installManagedStable` over the store door.**
+
+Open the store with `openFleetDoorStore` using the committed identity env; channel `stable`, component `router`.
+Fetch into the root-only staging dir with the 96 MiB limit (`systemstate.go:29`) and the signed SHA; rename to `/opt/carlos/carlos`.
+Reuse verification primitives only; do not invoke `system install-channel` (its group/floor checks assume a deployment-bucket identity).
+
+- [ ] **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; 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 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), `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`, `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 `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`: 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); 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.**
+
+```text
+TestManagedReadySigned (console): published ready.json is SignReady(Config.Key, record);
+ verify GET decodes and verifies with Config.ReleasePub; foreign-key, unsigned, other-kind or
+ 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 (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 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
+ => 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.
+TestManagedJoinStartSurfaces: with a valid named-unit declaration and pre-seeded routes
+ (native, rootfs, sidecar, worker, named unit, static) in the local registry while joining,
+ every surface refuses and launches nothing: Service wake (request and background),
+ ExecBackend Start/StartGen/StartGenExe/StartSidecar/StartWorker/StartWorkerStaged,
+ makeStartRoute, worker boot pass, adoptLoop adoption, configSyncLoop restart, root pass
+ 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,
+ system pointer leg and probe responder (Task 5) all run.
+TestManagedJoinReadyLeg: absent/403/5xx/malformed/unsigned/wrong-key/wrong fleet, label or op
+ => no relay or a root refusal, stays joining; reads: one at arming, one per changed serial,
+ else at most one per 60 s; serial read error => backstop only; valid object => relayed to
+ POST /managed-admit; only a 200 flips the agent and requests one full reconcile and worker
+ boot pass; root refusal or socket error => stays joining, retried next due.
+TestManagedAdmissionOneWay: after admission, 1000 ticks with serial changes => zero ready GETs;
+ ready object later deleted, rewritten or store unreachable => box stays admitted (root record
+ is authoritative); agent restart => GET /managed-admission, no ready reads; reboot => same;
+ admission record deleted by root-level tampering => joining again, reported, never silently admitted.
+TestManagedJoinRebootMatrix: restart before ready, after ready GET before relay, after root
+ commit before the agent flip, after flip before reconcile => final state consistent; no start
+ before root's durable record; no lost admission after it.
+TestManagedJoinBYOUnchanged: no identity file => no managedJoin, zero ready reads, root door
+ routes answer managed=false, group admission and exemptions exactly as on main; identity +
+ CARLOS_GROUP_ADMISSION=1 => agent refuses to arm tenant work (config error).
+```
+
+- [ ] **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(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.**
+
+Replace `managedReadyObject`'s plain JSON with `SignReady(s.cfg.Key, ...)`; the create-only PUT, GET-verify, original ReadyAt and C08 classification stay as 2a/2b-1 define them. Ed25519 and the payload encoding are deterministic, so a re-issued PUT carries identical bytes.
+`Kind` separates this payload from every other object the same key signs; strict decoding rejects pointer, production-flag or door-key payloads.
+
+- [ ] **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.
+`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.
+
+- [ ] **Step 5: Gate agent-side surfaces and add the joining-only ready leg.**
+
+Pass `join.Joining` as a func into BoxProvisionConfig's configure list so every loop (`instancesLoop` :4324 retains cfg) sees the live value. Bind `TenantAdmittedFunc`, `TenantExempt`, `ExecBackend.TenantStartAllowed`; wrap `makeStartRoute`, the worker boot pass, adoptLoop's start path and configSyncLoop's restarts; hand the edge `join` as its `HAAdmission`.
+In `fastTick` call `d.managedReady(ctx, now, doc.Serial, err == nil)` after the serial read on every tick; it returns at once when not joining and tracks its own last-seen serial so the 2-second `runFull` clamp never suppresses or repeats a read. Path `fleets/<fleet>/boxes/<label>/ready.json` via the store door.
+On a root 200: flip, then `d.fullDue.Store(true)`.
+
+- [ ] **Step 6: Repeat Step 2 to PASS and commit.**
+
+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
+
+**Files:**
+- Create: `internal/managedboot/fleetkey.go`, `fleetkey_test.go`; `internal/host/managedkey.go`, `managedkey_test.go`.
+- Modify: `internal/host/managedboot.go` (insert the key step after scrub); `internal/status/snapshot.go` (`Box` :846, additive field) and the agent's heartbeat writer.
+- Modify: `internal/console/fleetsecretskey.go` (extract core from `handleAPIFleetSecretsKey` at :72), `managedready.go` (storage check reads the heartbeat field), `server.go` route; create `internal/console/managedfleetkey.go`, `managedfleetkey_test.go`; extend `fleetsecretskey_test.go`.
+
+**Interfaces:**
+- Consumes: `appconfig.GenerateKey() (privB64, pubB64 string, err error)` (`crypto.go:96`), `ParsePrivateKey`, `ParsePublicKey`, `KeyFingerprint(pub *ecdh.PublicKey) string` (`fingerprint.go:16`); `lease.NewFilesStore(ctx context.Context, bucket, region string) (release.Store, error)` (`lease/endpoint.go:182`) as the fleet-bucket store; `release.Store.Put(ctx, key, body, "")` is create-only and maps 412 to `release.ErrCASConflict` (`store.go:1001`, :37); `fleetIdentityOK(reg consoleRegistry, name, token, wantFleet, wantAccount string) bool` (`apiinteractivebox.go:117`); `recordFleetKeyFP`, `reg.SetFleetSecretsKey`, `registry.ErrFleetKeyInUse`, `expectedSecretsFP`, `lockAccount`; Task 2 `KeyStatusPath`.
+- Produces (**new**):
+ - `const FleetKeyObject = "system/fleet-secrets-key.json"` (2b-1's policy path).
+ - `type FleetKey struct { Schema int "schema"; Fleet string "fleet"; Public string "public"; Private string "private"; Fingerprint string "fingerprint"; MintedBy string "minted_by"; Op string "op" }`; `func (k FleetKey) Validate(fleet string) error`.
+ - `type KeyStatus struct { Code string "code" }` with codes `ok`, `object_invalid`, `object_unreadable`, `registration_refused`, `registration_unavailable` (fixed codes; console maps them to COPY reasons).
+ - `func ensureFleetKey(ctx context.Context, s release.Store, id managedboot.Identity) (managedboot.FleetKey, error)`: GET; absent ⇒ mint + create-only PUT; ErrCASConflict or ambiguous PUT ⇒ GET and adopt the stored object; never a second PUT over an existing object.
+ - `func registerFleetKey(ctx context.Context, c *http.Client, origin, tunnelToken string, id managedboot.Identity, pub string) error`.
+ - `status.Box.ManagedKey string` JSON `managed_key,omitempty` (the agent copies `KeyStatus.Code` from the root-owned file).
+ - Console: `type fleetKeyOutcome struct { Fleet, Fingerprint string; Changed bool }`; `(*Server).registerFleetSecretsKey(ctx context.Context, acct *Account, reg consoleRegistry, fleet string, key *ecdh.PublicKey, actor string, initialOnly bool) (fleetKeyOutcome, error)` with typed errors `errFleetKeyPlatformKey`, `errFleetKeyReplaceRefused`, `errFleetKeyInUse`, `*fleetKeySealedApps`, `*fleetKeyInstances`, `*fleetKeyNotRecorded{Status int}`.
+ - Console route `POST /api/fleet/managed/secrets-key` → `(*Server).handleManagedFleetKey(w, r)`; body `{"fleet","label","op","pubkey"}`, `Authorization: Bearer <tunnel token>`.
+
+**Census/review:** New public refusal door; record-write census for the registry key mutation via a second caller; authority inventory (box token gains initial-key-only registration); owner door refusal on managed fleets (Paul rule 10). Security review (Astra + Fable).
+
+- [ ] **Step 1: Write failing key tests.**
+
+```text
+TestManagedFleetKeyFirstWriterWins: three boxes, empty bucket, barrier before PUT => exactly one
+ PUT returns success, two get ErrCASConflict, all three install the same private key, one object
+ exists, registry fingerprint equals its fingerprint; replay registration => changed=false.
+TestManagedFleetKeyAmbiguousPut: PUT times out but succeeded => GET finds own object, adopts it;
+ PUT times out and failed => GET absent => one retry create-only; GET keeps failing =>
+ key status object_unreadable; object never deleted or overwritten.
+TestManagedFleetKeyLaterBox: object present => zero mint, zero PUT, one GET; installs key.
+TestManagedFleetKeyFailureContinues: malformed, foreign-fleet or mismatched public/fingerprint
+ object, registration 409/403, or registration unreachable past the boot deadline => key status
+ written (root 0644), no CARLOS_SECRETS_KEY, managed-boot still completes and queues the edge,
+ root admission still absent; agent starts joining and its heartbeat carries managed_key=<code>.
+TestManagedFleetKeyHostEnv: CARLOS_SECRETS_KEY written atomically into host.env before bootstrap;
+ private key absent from logs, breadcrumbs, errors, console requests, heartbeat and probe replies.
+TestManagedReadinessKeyStatus (console): heartbeat managed_key other than "" or "ok" => storage
+ check State "fail" with the code's COPY reason, regardless of the probe; show/CLI status
+ displays it through the existing readiness view; "ok" => probe decides (Task 5).
+TestManagedFleetKeyDoor: valid active token for fleet/label, managed fleet, box in enrolled or
+ publishing state of op => 200; first key => changed=true, owner record + registry updated;
+ same key => changed=false, zero writes; different key already registered => 409, zero writes;
+ platform's own key => 400; key used by another fleet => 409; wrong/expired/revoked token,
+ BYO fleet, wrong op, box ready/failed/terminated, other account's fleet => identical 403;
+ HostClaim => 409; rate-limited before any lookup.
+TestFleetSecretsKeyCoreParity: owner door on BYO fleets through the extracted core keeps every
+ existing response code/body/audit line; replacement still allowed exactly as before.
+TestFleetSecretsKeyOwnerDoorManaged: owner door on a managed fleet => 409 (COPY), zero writes.
+```
+
+- [ ] **Step 2: Run the failing tests.**
+
+Run `GOFLAGS=-buildvcs=false go test ./internal/managedboot ./internal/host -run 'TestManagedFleetKey' -count=1` and `GOFLAGS=-buildvcs=false go test ./internal/console -run 'TestManagedFleetKeyDoor|TestManagedReadinessKeyStatus|TestFleetSecretsKey(CoreParity|OwnerDoorManaged)|TestAPIFleetSecretsKey' -count=1`; expect FAIL.
+
+- [ ] **Step 3: Extract the validation core; refuse the owner door on managed fleets.**
+
+Move fingerprint, platform-key, account-lock reread, sealed-values/instances replacement checks, owner record, registry write and audit into `registerFleetSecretsKey`; the handler maps typed errors back to today's exact bodies.
+`initialOnly=true` refuses any registered fingerprint other than the presented one before the sealed-value checks run.
+Per Paul rule 10 the owner door refuses managed fleets with a COPY message saying the fleet's first box registers its key; 2c designs replacement.
+
+- [ ] **Step 4: Add the operation-bound managed door.**
+
+Order: HostClaim refusal → limiter (reuse the enrol IP/global pair) → strict 4 KiB decode → registry fleet row (managed, owner account) → `fleetIdentityOK` → SQL box row `(fleet, label, op)` in `enrolled` or `publishing` → `registerFleetSecretsKey(..., initialOnly=true)` with actor `managed-box <fleet>/<label> op <op>`.
+No general fleet-token access to owner routes; no key replacement authority. Bodies are COPY.
+
+- [ ] **Step 5: Implement box-side ensure + register; never fail the boot on it.**
+
+Runs as root after scrub. Root loads the committed fleet key from the fixed file `/etc/carlos/credentials` through `rootaws.LoadDefaultConfig` (`rootaws/config.go:17`, :38).
+Open the fleet bucket with `lease.NewFilesStore(ctx, bucket, bucketRegion)`; it carries no change index, so a key PUT bumps nothing in the deployment store.
+Register after the object is confirmed; 503/429 retried within the boot deadline. Any key failure writes `KeyStatusPath` and continues: boot completes, the agent starts with workload admission closed (no root admission exists), and the heartbeat carries the code so the console's storage check reports `fail` with a reason through the existing CLI status path.
+Without the key the agent's config sync stays disabled (`agent.go:1797`), and the box can never reach ready, so a fleet whose key cannot be established never runs workloads.
+The object holds the private half in plaintext under SSE-S3, which Paul accepted in addendum P2; the policy grants no delete on it.
+
+- [ ] **Step 6: Repeat Step 2 to PASS and commit.**
+
+Mutation checks (≤8): unconditional PUT; trust local mint after a CAS conflict; register before object confirmation; initialOnly ignored; skip op/state check; accept BYO fleet; key failure aborts the boot; owner door left open on managed fleets.
+Commit subject: `feat: first managed box mints and registers the fleet key`.
+
+### Task 5: Prove storage and the router path to the exact box
+
+**Files:**
+- Create: `internal/managedboot/probe.go`, `probe_test.go`.
+- Create: `internal/edge/fleetprobe.go`, `fleetprobe_test.go`; modify `internal/edge/edge.go` (tunnel-host branch at :1994, header scrub at :2056 and :3857), `internal/edge/mesh.go` (new domain), `internal/tunnelclient/tunnelclient.go` (header beside :272).
+- Create: `internal/host/managedprobe.go`, `managedprobe_test.go`.
+- Create: `internal/console/managedprobe.go`, `managedprobe_test.go`.
+
+**Interfaces:**
+- Consumes: `(*TunnelHub).transportFor(name string) http.RoundTripper` (`tunnel.go:487`, exact channel, no fallback); `tunnelclient.FromTunnel`; mesh keys via `(*Server).edgeProofKeys(ctx context.Context) (current, next []byte)` (`console/edgeproof.go:126`) and the edge's mirrored current/next keys (`mesh.go:163`, `signingKey` :172); `managedExtraChecks.Checks(context.Context, managedBox) (storage, router managedCheck, err error)` (`managedready.go:14`); 2b-1 `managed_fleet_delivered_keys`; Task 2 `Identity`; Task 3 `managedJoin`; Task 4 `FleetKeyObject`, heartbeat `managed_key`; `lease.NewFilesStore`.
+- Produces (**new**):
+ - `type ProbeRequest struct { Fleet, Label, Op, Nonce string; Storage bool }`; `type ProbeReply struct { Fleet, Label, Op, Nonce string; Storage ProbeStorage; SecretsKeyFP string "secrets_key_fp" }`; `type ProbeStorage struct { OK bool "ok"; KeyID string "key_id"; Code string "code" }`; strict decoders, 1 KiB request / 4 KiB reply caps.
+ - Edge: `const fleetProbePath = "/__carlos/fleet-probe"`, `const managedProbePath = "/__carlos/managed-probe"`, `const fleetProbeDomain = "carlos-fleet-probe\x00"`, `const fleetProbeAuthHeader = "X-Carlos-Fleet-Probe-Auth"`, `const fleetProbeChannelHeader = "X-Carlos-Probe-Channel"`; `func signFleetProbe(key []byte, channel string, body []byte, now time.Time) string`; `func verifyFleetProbeEitherKey(current, next []byte, channel, header string, body []byte, now time.Time) bool`; `func (e *Edge) serveFleetProbe(w http.ResponseWriter, r *http.Request)`; `func (e *Edge) serveManagedProbe(w http.ResponseWriter, r *http.Request)`; `type ManagedProbeResponder interface { Respond(ctx context.Context, req managedboot.ProbeRequest) (managedboot.ProbeReply, error) }` set by an `edge.RunOption`.
+ - `tunnelclient.ManagedProbeHeader = "X-Carlos-Managed-Probe"`.
+ - Host: `type managedProber struct` implementing `ManagedProbeResponder`; storage challenge key `_carlos/probes/<label>/<nonce>`.
+ - Console: `type managedProbeChecks struct` with `func newManagedProbeChecks(s *Server) *managedProbeChecks` and `Checks(ctx context.Context, b managedBox) (storage, router managedCheck, err error)`; `(*Store).managedDeliveredKeys(ctx context.Context, fleet, account string) ([]string, error)` (reads 2b-1's table; use 2b-1's reader if it lands one).
+
+**Census/review:** Root-binary units (edge, tunnelclient, host); new hub path is an authenticated door (census refusal inventory); readiness authority. Security review (Astra + Fable).
+
+- [ ] **Step 1: Write failing probe tests.**
+
+```text
+TestFleetProbeExactChannel: target disconnected, siblings connected => hub 503, zero requests to
+ any sibling channel, console router pending; target connected => request reaches only target;
+ box responder given a request naming another label/fleet/op => 404, no storage work;
+ reply echoing another label or nonce => console router pending.
+TestFleetProbeAuth: missing/garbled/expired (>30 s skew)/wrong-key/wrong-channel/altered-body
+ MAC => identical 401 before any channel lookup; next-key accepted; GET or non-hub host => 404;
+ inbound X-Carlos-Managed-Probe and X-Carlos-Probe-Channel stripped from every other request;
+ a fleet box token cannot read control/edge-mesh-key through the store door.
+TestFleetProbeBounds: >1 KiB request body => 400; box reply >4 KiB, redirect, non-200, timeout
+ (10 s), broken return leg (connection reset after request) => pending, hub never retries
+ another channel; hub sets X-Carlos-Probe-Channel to the channel it used.
+TestManagedProbeResponder: joining box answers before any route exists and before admission;
+ not FromTunnel or header absent => 404; storage=true => PUT/GET/DELETE of
+ _carlos/probes/<label>/<nonce> with the delivered credentials, body round-trip compared,
+ KeyID = credentials file access key ID (never the secret); S3 failure => ok=false with code;
+ SecretsKeyFP from the installed key ("" when absent); one probe at a time per box.
+TestManagedProbeChecks (console): router pass only on 200 + channel header + exact echo;
+ storage pass only when ok=true, key_id in managed_fleet_delivered_keys for fleet/account, and
+ secrets_key_fp nonempty and equal to the registry fleet fingerprint; a Task 4 key-status
+ failure keeps storage "fail" whatever the probe says; independent results (router pass +
+ storage pending, and reverse); hub unreachable => both pending, err nil; replayed reply with
+ old nonce => pending; reasons COPY; HostClaim => no probe.
+TestManagedProbeBudget: enrolled box, 10 readiness passes inside 60 s => one probe; ready or
+ failed boxes => zero probes; idle worker => zero; each probe => exactly 3 fleet-bucket calls.
+```
+
+- [ ] **Step 2: Run the failing tests.**
+
+Run `TMPDIR=<owned-short-dir> GOFLAGS=-buildvcs=false go test ./internal/edge ./internal/host ./internal/managedboot -run 'TestFleetProbe|TestManagedProbe' -count=1` and `GOFLAGS=-buildvcs=false go test ./internal/console -run 'TestManagedProbe(Checks|Budget)' -count=1`; expect FAIL.
+
+- [ ] **Step 3: Add the hub endpoint and box responder.**
+
+Hub branch: only on the reserved tunnel host, `POST`, clean path, before `e.tunnels.ServeHTTP`; verify MAC over channel, timestamp and body; forward with `transportFor(channel)` to `managedProbePath` carrying `ManagedProbeHeader: 1`; never call `fleetChannelFor` (its `ConnectedOfFleet` fallback, `edge.go:3898`, is exactly the sibling hazard).
+Box branch: before demo/route lookup and before `admissionRefuses`, only when `FromTunnel(ctx)` and the header is set; responder checks fleet/label against identity and op against it too.
+The agent passes the responder to the edge through a new `edge.RunOption` only on a managed box; BYO boxes keep answering the path with the ordinary 404.
+The responder runs as the carlos user; its S3 client uses the normal SDK chain with `AWS_SHARED_CREDENTIALS_FILE=/etc/carlos/credentials` (root:carlos 0640), the file the hibernate lease uses.
+Strip `ManagedProbeHeader` and `fleetProbeChannelHeader` from every inbound request next to the existing `ReplicaProbeHeader` scrub (`edge.go:2056`) and from proxied requests (`:3857`).
+The mesh key's existing rotation (current/next) applies unchanged; the new MAC domain keeps probe signatures unusable as hop or door marks and vice versa.
+
+- [ ] **Step 4: Bridge into readiness.**
+
+`Checks` builds a fresh 32-byte hex nonce, signs with the edge's signing-key rule over the console's mirrored keys, POSTs to `https://<TunnelHost>/__carlos/fleet-probe` with a 10 s timeout and no redirects, and maps results as the tests pin.
+Transport/hub failures return pending checks with `err == nil` so 2a's "pending unless pass" handling applies.
+
+- [ ] **Step 5: Repeat Step 2 to PASS and commit.**
+
+Mutation checks (≤8): hub uses fleetChannelFor; MAC omits body; responder ignores label; console ignores channel header; storage pass without key_id check; fp check skipped; header not stripped; probe on ready boxes.
+Commit subject: `feat: real storage and router readiness for managed boxes`.
+
+### Task 6: Wire production providers and prove one box end to end
+
+**Files:**
+- Modify: `cmd/console/main.go` (Config at :482; provider construction beside the app-store backend at :1065); `internal/console/server.go` (`NewServer` :1783 sets `managedExtra`); `internal/console/managedworker.go` (one console-output read at failure).
+- Create: `internal/awsmanaged/integration_2b2_test.go` (package `awsmanaged_test`, uses 2b-1's `NewComputeWith`/`NewStorageWith`); `internal/console/managed2b2_test.go`; extend `managedbudget_test.go`, `managed_e2e_test.go`.
+- Docs: `docs/site/cli.md` gains no command; add a short operator note on the opt-in variables in the existing operator doc that lists console env (COPY), stating managed fleets stay off by default.
+
+**Interfaces:**
+- Consumes: 2b-1 `awsmanaged.NewCompute`, `NewStorage`, configs and module outputs; Tasks 1-5.
+- Produces (**new**): console env `CARLOS_MANAGED_FLEETS_BACKEND` (only `aws` accepted), `CARLOS_MANAGED_FLEET_DEPLOYMENT`, `CARLOS_MANAGED_FLEET_ACCOUNT_ID`, `CARLOS_MANAGED_FLEET_REGIONS` (comma list), `CARLOS_MANAGED_FLEET_IAM_REGION`, `CARLOS_MANAGED_FLEET_BUCKET_PREFIX`, `CARLOS_MANAGED_FLEET_USER_PATH`, `CARLOS_MANAGED_FLEET_BOUNDARY`; `func managedProvidersFromEnv(ctx context.Context, getenv func(string) string) (compute.Provisioner, fleetstore.Provisioner, string, error)` in `cmd/console`; managedBox field `BootBreadcrumbs string` JSON `boot_breadcrumbs` and additive show field `boot` (COPY mapping of the last code).
+
+**Census/review:** Console production wiring and termination-adjacent diagnostics: Astra + Fable. Consolidated branch census proposal (all tasks).
+
+- [ ] **Step 1: Write failing wiring, composition and budget tests.**
+
+```text
+TestManagedProvidersFromEnv: backend unset => nil, nil, "" (admission keeps 503);
+ backend=aws with any variable missing/invalid (non-12-digit account, empty boundary, root
+ user path, empty prefix, region not in list) or CARLOS_RELEASE_KEY absent (no signing key for
+ ready.json) => error naming the variable, console start fails like the app-store backend;
+ valid => both providers non-nil, ManagedDeployment set; backend=fake or other => error.
+ No real network: rootaws with dummy creds, IMDS off.
+TestManagedExtraWired: NewServer with TunnelHost + providers => managedExtra is the probe bridge;
+ without TunnelHost => nil (storage/router stay pending).
+TestManaged2B2OneBox (console fakes + real handlers + real managedboot/host code against a fake
+ root, fake hub, fake fleet bucket, fake root door): create --boxes 1 => Boot frozen => UserData
+ rendered => seed fetched => trade => staged => key minted/registered => stable installed =>
+ edge queued => joining heartbeat => six checks pass => signed ready.json create-only PUT =>
+ agent relays => root commits => shop (native) record placed after ready reconciles and starts;
+ nothing started before root's record.
+TestManaged2B2KeyFailureStatus: malformed key object in the fake bucket => boot completes, agent
+ joining, heartbeat managed_key=object_invalid, `carlos fleets show` (CLI against the handler)
+ prints storage failed with the COPY reason; no ready.json, no workloads; deadline cleanup.
+TestAWSManaged2B2Recovery (awsmanaged_test, mocked transport): lost RunInstances reply =>
+ same instance found, UserData bytes identical across adapter reconstruction; storage prepared
+ once; credentials delivered once and recorded in the delivered set.
+TestManaged2B2ConsumedPublicationUncertain: PUT succeeds, root commits admission, console verify
+ GET fails/mismatches => console stays publishing+uncertain, quota held, zero revoke/terminate
+ calls; box admitted and serving; next verify pass resolves to ready with no second PUT.
+TestManaged2B2Diagnostics: box fails at the 20-minute deadline => exactly one ConsoleOutput call,
+ sanitized codes persisted, show reports the last code; enrol/tunnel/access/private-key
+ sentinels absent from show, progress, logs and persisted rows; no ConsoleOutput while healthy.
+TestManaged2B2Budget: 1/10/100 ready boxes, 100 idle passes => zero SQL/store/provider/probe
+ calls; joining box: ready GETs <= serial changes + 1 per 60 s, zero after admission;
+ enrolled box: <= 1 heartbeat GET + 1 probe per 60 s; no ListDeployment/ConsoleOutput timers.
+TestManaged2B2HostClaim: HostClaim on => enrol, seed door, managed key door and probes refuse;
+ worker passes refuse as in 2a.
+```
+
+- [ ] **Step 2: Run the failing tests.**
+
+Run `GOFLAGS=-buildvcs=false go test ./cmd/console ./internal/console -run 'TestManagedProvidersFromEnv|TestManagedExtraWired|TestManaged2B2' -count=1` and `GOFLAGS=-buildvcs=false go test ./internal/awsmanaged -run TestAWSManaged2B2 -count=1`; expect FAIL.
+
+- [ ] **Step 3: Construct providers only on explicit opt-in.**
+
+Follow the app-store backend's precedent (`main.go:1065-1072`): opted-in but incomplete configuration, including a missing `Config.Key`, is a fatal start error with a precise message (COPY); not opted in leaves both providers nil.
+Never substitute a fake. `enabled` in `system/managed-fleets.json` remains the admission switch.
+
+- [ ] **Step 4: Record breadcrumbs once on failure.**
+
+When a launched box fails its readiness or enrolment deadline, call `ConsoleOutput` once inside the existing cleanup step (outside lockFleet per 2b-1 Task 2), persist the sanitized codes, and expose the last one in show. No other call site.
+
+- [ ] **Step 5: Repeat Step 2 to PASS, then run the final local gate once.**
+
+`TMPDIR=<owned-short-dir> GOFLAGS=-buildvcs=false go test -race ./internal/managedboot ./internal/host ./internal/provision ./internal/instancectl ./internal/edge ./internal/status ./internal/console ./internal/awsmanaged ./cmd/console -run 'TestManaged|TestReconcileJoining|TestFleetProbe|TestFleetSecretsKey|TestAWSManaged2B2|TestManagedCoreImports|TestStoreDoorManagedReady' -count=1`.
+`GOFLAGS=-buildvcs=false go build -o <owned-disk-scratch>/carlos .` and `./cmd/console`; targeted `go vet` on touched packages; gofmt on touched files.
+Full suites and cross-builds run on amadan CI before landing. Report real failures; do not loop full suites.
+
+- [ ] **Step 6: Census, copy inventory and commit.**
+
+`make census-card`; per-unit CLAIMS in owned scratch; `make census-propose NAME=managed-fleets-2b2 CLAIMS=<file>` covering host/edge/provision/instancectl/activator wiring/managedboot/status units, the seed/key/probe/root-admission doors, registry key writes, the signed ready-object writer and the box-token authority change.
+Hand the controller the COPY inventory (refusals, readiness reasons, key-status reasons, show text, operator doc lines).
+Commit subject: `feat: wire managed fleet providers behind an opt-in switch`.
+
+### Task 7: Prepare the dev drill card; run it only after Paul approves
+
+**Files:**
+- Create: `docs/superpowers/notes/managed-fleets-2b2-drill-card.md` (the approval card).
+- After approval only: `docs/superpowers/notes/managed-fleets-2b2-drill-log.md`.
+
+**Interfaces:**
+- Consumes: everything above, released; 2b-1 Task 5 module variables/outputs; `system/managed-fleets.json` shape (`internal/release/managedfleets.go:7`).
+- Produces: a card with every value filled from read-only preflight, then (after Paul's approval only) one executed and cleaned-up drill.
+
+**Census/review:** No code. The card itself gets one Astra read for completeness before it goes to Paul.
+
+- [ ] **Step 1: Run the read-only preflight needed to fill the card.**
+
+Allowed before approval, all with `--profile kass` and read-only: `aws ec2 describe-images` for the current Debian 13 arm64 AMI (pin its ID and root device), `describe-vpcs`/`describe-subnets`/`describe-route-tables` for the VPC/subnet below, `describe-security-groups` to confirm the drill SG name is free, and `tofu plan` (no apply) in platform-infrastructure dev with the release ref and `managed_fleets_enabled = true`; attach the inspected plan output to the card. Read the dev console's `CARLOS_HOST_CLAIM` setting.
+Nothing that creates, modifies or deletes anything runs before Paul's approval: no apply, no SG creation, no config write, no release roll, no launch.
+
+- [ ] **Step 2: Write the card with every value concrete.**
+
+| Item | Value on the card |
+|---|---|
+| Account / profile | dev deployment account 640012953448, AWS profile `kass` (always named explicitly) |
+| Region / network | eu-west-1; default VPC vpc-02212d67a9fca3b20; subnet-0975dda9ac0e65347 (eu-west-1c); preflight confirms existence and an internet-gateway default route |
+| Image | the Debian 13 arm64 EBS AMI ID pinned by the preflight describe (historical ami-071babd89cea53fa3 is only a starting point) |
+| Box | one t4g.small, 30 GiB encrypted gp3, IMDSv2 hop 1, no instance profile, no key pair, no SSM |
+| Security group | new `carlos-managed-drill` in that VPC: no inbound; egress tcp/443 to 0.0.0.0/0 and ::/0 only (console, hub, store, S3, Debian HTTPS mirror); NTP/DNS use link-local VPC services |
+| Fleet / config | fleet `drill-2b` in an ops-owned dev account; `system/managed-fleets.json` enabled=true, ceiling=1, account_limit=1, size `small` → t4g.small, that image/subnet/SG, root_gb 30 |
+| IAM / infra | platform-infrastructure dev: module ref bump to the release containing 2b-1 + 2b-2, `managed_fleets_enabled = true`; the inspected `tofu plan` from Step 1 is attached |
+| Console | dev console on sophie (console.service) with the Task 6 env and `CARLOS_RELEASE_KEY` present; `CARLOS_HOST_CLAIM` off there (decisions rule 7) or the drill stops |
+| Release | release tag; dev stable pointer must name that release (its linux-arm64 artifact is the seed and the installed binary); roll order dev boxes → dev console |
+| Cost cap / TTL | ≤ US$5 total; window ≤ 4 h attended; abort and clean up at TTL whatever the state |
+| Isolation | r10r and every existing fleet untouched; no shared SG, role or bucket |
+
+- [ ] **Step 3: Write the exact verification list.**
+
+```text
+V1 CLI: carlos fleets create drill-2b --managed --region eu-west-1 --size small --boxes 1
+ returns an op; show reports each phase; six checks reach pass; ready.json exists once,
+ signed, and verifies with the deployment's release public key.
+V2 Console output contains only CARLOS_BOOT codes, ending at joining; no token/secret text.
+V3 Before ready.json: box heartbeat shows the stable version; no instance unit ever started.
+V4 shop (native) and a rootfs sample placed after ready serve at their public URLs.
+V5 Box reboot: comes back admitted, zero enrol calls, zero ready.json reads, apps serve.
+V6 From the box (via a sample app's admin path or console diagnostics, not SSH): fleet key
+ PUT to another fleet's bucket and to the deployment bucket are denied; PUT/DELETE of
+ ready.json through the store door are denied; GET of own objects works.
+V7 Fleet key object exists once; registry fingerprint equals it.
+V8 Request counts from the console's budget counters match Task 6's numbers for the window.
+```
+
+- [ ] **Step 4: Write the exact cleanup list (part of the approval, Paul rule 11).**
+
+```text
+C1 system/managed-fleets.json enabled=false (admission off first).
+C2 Terminate the instance by its exact ID after an identity-tag check (aws ec2 describe +
+ terminate-instances --profile kass); observe terminated.
+C3 Fleet bucket: delete every object version and delete marker (list-object-versions, paged),
+ abort multipart uploads, then delete the bucket; confirm 404.
+C4 IAM user: list and delete every access key, delete the inline policy, delete the user.
+C5 Delete the drill SG after the ENI is gone.
+C6 The dev console keeps the drill-2b fleet and box rows; record them in the drill log; they
+ are removed through 2d's removal path. No hand DB edits.
+C7 Leave infra at managed_fleets_enabled=true or revert per Paul's instruction on the card.
+```
+
+- [ ] **Step 5: Hand the card to the controller for Paul; stop.**
+
+Do not run any mutating step without Paul's explicit approval of this card. After approval, execute V1-V8 then C1-C7, log each command and result in the drill log, and remove local scratch.
+Commit subject (card only): `docs: managed fleets 2b-2 dev drill approval card`.
+
+## Landing (controller)
+
+Push `managed-fleets-2b2` to amadan.net; describe with `amadan branch describe carlos/platform managed-fleets-2b2 -body -`; require green `amadan ci status carlos/platform -branch managed-fleets-2b2` at the full tip, Astra (+ Fable) review closed, #280 census approval and copy review applied.
+Merge only on Paul's go with `amadan branch merge carlos/platform managed-fleets-2b2 -squash -expect <full-tip> -message <subject-and-body>`; check subject length and the blank-line body first. The drill (Task 7 execution) follows the release and Paul's card approval, not the merge.
+
+## Self-review
+
+| Spec / decision / inherited requirement | Coverage |
+|---|---|
+| decisions.md split: 2b-2 = recon tasks 6-11 | Tasks 1-2 (recon 6), 3 (7), 4 (8), 5 (9), 6 (10), 7 (11) |
+| Rule 1: no profile/SSH/SSM, dedicated egress-only SG | 2b-1 adapter request; Task 2 never needs IMDS credentials; Task 7 SG |
+| Rule 7: HOST_CLAIM refusal stays | Tasks 1, 4, 6 refusal tests on every new door |
+| Rule 8 pairing | Superseded for 2b-2 by the controller brief (Opus implements; Astra/Fable review) |
+| Rule 9: console seed door to an unused token | Task 1 seed door, script-run test |
+| Rule 10: owner door refuses on managed fleets until 2c | Task 4 `TestFleetSecretsKeyOwnerDoorManaged` |
+| Rule 11: drill deletes all AWS resources, keeps console rows, no DB edits | Task 7 C1-C7 |
+| §4 enrolment: one-time token, no long-lived secret in user data/logs | Task 1 renderer/secrets tests; Task 2 trade, scrub, wire |
+| §4 port #183 hardening: allowlists, IMDS gate, shredding cloud-init copies | Task 1 allowlist + nft in template; Task 2 firewall ordering + scrub |
+| §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`; 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` |
+| §4 born examined: first report lists data dir empty | Task 2 attestation before any /data write |
+| §4 ready means ready: six checks incl. storage and router probe | Task 5 real checks; Task 4 key status into storage |
+| §4 diagnostics: breadcrumbs, launch errors, failed check visible | Task 2 codes; Task 4 heartbeat key status; Task 6 ConsoleOutput + show |
+| Box actually starts serving after boot | Task 2 `TestManagedBootStartPlan` (`--no-block` edge start) |
+| Reboot after platform self-update | Task 2 `TestManagedBootUpdateReboot` |
+| Addendum P1: key once in enrolment reply, never user data | Task 1 secrets test; Task 2 staging; Task 6 recovery test |
+| Addendum P2: first box mints, registers via existing door, private half in fleet bucket; later boxes read it | Task 4 (later-box read covered; many-box add flows 2c) |
+| "No parallel key path" | Task 4 extracted core shared by both doors |
+| §5 provider boundary + import test | managedboot added to `TestManagedCoreImports`; AWS only via 2b-1 |
+| §6 request budget with stated numbers and a counting test | "Request budget" table; Tasks 3, 5, 6 budget tests |
+| §7 switch-on after an approved dev drill | Task 7 card; enabled stays false until then |
+| §8.1 checks shown passing (one box here; three in 2c) | Task 6 `TestManaged2B2OneBox`; Task 7 V1 |
+| §8.2 apps serve after ready (custom domain 2c) | Task 6 composed; Task 7 V4 |
+| §8.4 box credentials cannot reach deployment/other fleet bucket | 2b-1 policy fixtures; Task 7 V6 live |
+| §8.5 secrets never in logs/progress/pages | Tasks 1, 2, 4, 6 sentinel tests; Task 7 V2 |
+| §8.6 reboot recovery (managed box) | Tasks 2/3 reboot matrices; Task 7 V5 |
+| §8.8 docs and copy review | Task 6 operator note; COPY inventory to controller |
+| 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`, `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-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
+
+- **2c:** Many real boxes and `boxes add` with key consumption at scale; three-box §8.1 acceptance; partial-capacity drill; custom-domain serving.
+- **2c:** Hub fallback (`fleetChannelFor` step 2) must skip joining boxes so a second box joining an active fleet cannot receive unlabelled app traffic it will refuse.
+- **2c:** Multiple hubs behind one tunnel hostname: a probe landing on a hub without the channel reports pending; hub-to-hub probe forwarding is not built.
+- **2c:** Fleet secrets-key replacement or recovery for managed fleets (owner door stays refused, rule 10); re-credentialing boxes stranded by 2b-1's needs-operator state.
+- **2c:** Full bootstrap diagnostics beyond the six breadcrumb codes and the key-status codes; richer show output.
+- **2d:** Member box and fleet removal, drain/wait/terminate/detach; deletion of drill-era console rows through that path.
+- **2d:** 30-day last-box bucket retention, revival by add, version/delete-marker reaping by the platform rather than by hand.
+- **2d:** Hourly regional orphan sweep with 24-hour grace.
+- **Later:** `CARLOS_HOST_CLAIM` support through a trusted gated BEGIN IMMEDIATE seam; baked managed AMI instead of boot-time apt; phase 3 billing and VPC peering.
+- Carry N2 and the accepted 2a/2b-1 minors as follow-ups.
+
+## Review history
+
+Round 1 (Astra, `/home/paulca/.cache/managed-fleets-2b-notes/review-2b2-r1.md`, verdict NOT READY): 6 P1, 2 P2, all accepted by the controller and fixed in this plan. This revision does not reset the round count.
+
+- P1-1 root admission authority: Fixed. Admission is a root-owned record in root-only `RootAdmissionDir` (0700), committed by the root door only after verifying the console's signed ready.json (`Config.Key`, the pointer-signing key; `{payload, sig}` wrapper) against the release public key in root-owned `managed-box.json`; the agent only relays. Task 3 `TestManagedRootAdmissionForgery`, `TestManagedRootAdmitVerify`, `TestManagedReadySigned`.
+- P1-2 complete start gating: Fixed. Task 3 gates `rootStartRoute` (`agent.go:5923` → `rootrestart.go:524-526`), `rootSelectedRestart`, rollback restart, `UnitOps.Restart` (`unitops.go:35`, `unitsync.go:459`), named-unit recovery, adoptLoop and configSyncLoop, preserving platform maintenance units; witnesses use valid named-unit declarations and pre-seeded routes.
+- P1-3 first-contact wire contract: Fixed. Task 1 separates `boot-input.json` (full LaunchInput) from token-only `seed-request.json`; the bounded re-exec runs `timeout 900 /bin/sh "$0"`; curl writes with `-o seed.part`; `TestManagedCloudInitScriptRun` runs the rendered script against the real seed handler with mocked system commands.
+- P1-4 boot completion: Fixed. Task 2 queues `systemctl start --no-block carlos-edge.service` after the durable complete marker, and again on every complete-path boot; `TestManagedBootStartPlan` covers interruption between completion and queueing.
+- P1-5 update-compatible reboot: Fixed. The complete path does not re-verify `/opt/carlos/carlos`; the initial digest applies only to first install, and integrity afterwards belongs to systemapply. `TestManagedBootUpdateReboot` covers update→reboot and interrupted update→recovery→reboot.
+- P1-6 reboot prerequisites: Fixed. The boot unit has `Requires=`/`After=nftables.service`, plus `Wants=`/`After=network-online.target` in an enrol drop-in removed at completion; `TestManagedBootFirewallOrdering` covers delayed restoration and failure.
+- P2-7 failure diagnostics: Fixed. Key failures never fail the boot; root writes `managed-key-status.json`, the agent starts closed and reports `managed_key` in its heartbeat, and the storage check fails with a reason in CLI status. Task 4 `TestManagedFleetKeyFailureContinues`, `TestManagedReadinessKeyStatus`; Task 6 `TestManaged2B2KeyFailureStatus`.
+- 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).