Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/docs/TRUST-1-IMPLEMENTATION-PLAN.md # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / docs / TRUST-1-IMPLEMENTATION-PLAN.md` 255 lines · 24455 bytes Raw Blame History Rendered 1 # AIENOS TRUST-1 Implementation Plan: Owner-Controlled Boot & Recovery Gate 2 3 Status: Proposed. Requires operator approval before any trust mutation. 4 Scope: Transition from M2 (proven native boot, Secure Boot restored, native boots paused) to owner-controlled Secure Boot, TPM re-seal, emulator-first development, and safe resumption of native boots. 5 Out of scope: Blackwell GPU execution, CUDA replacement, GSP submission, native inference, Fabric rollout, desktop/GUI, mail/Matrix/OpenClaw/AstroSage, productization. GPU characterization continues as non-blocking research only. 6 7 Governing sentence: **Approval authorizes only the mutations and gates written in this plan. It does not authorize agents to improvise around failed gates.** 8 9 Conventions per milestone: Objective / Preconditions / Permitted mutations / Acceptance tests / Evidence required / Rollback. Result is PASS only when every acceptance assertion is true. Any unexplained deviation is FAIL/STOP, not partial success. Avoid ambiguous words (works, secure, ready, probably, should, supports, tested). 10 11 Owners (Q27): 12 - Operator-only: firmware setup, PK/KEK/db changes, Secure Boot enable/disable, Owner Root ceremony and private material, offline recovery credentials, destructive keyslot removal, final TPM-policy retirement, physical recovery-media custody, authority-broadening decisions, TRUST-1 approval, root-of-trust promotion. Agents prepare exact instructions and evidence only. 13 - Agent implementation: loader, kernel, A/B machinery, manifest formats, subordinate-key signing tooling, TPM simulation, measurement tooling, recovery environment, receipt formats, emulator tests, fault injection, CI classifier, reproducibility, docs, non-destructive inspection, proposed firmware/TPM commands for review. 14 - Automation: clean-tree, reproducibility, hashing, signature verification, emulator boots, fault suites, boundary classification, review enforcement, aien-proof serialization, ledger, boot budgets, manifest validation, rollback logic, retention, dirty/unapproved detection. 15 16 `aien-proof` owns `machine-1` during every trust-transition action. Every firmware/key/policy mutation has an explicit rollback procedure. 17 18 --- 19 20 ## Gate 0: Freeze current good state (Owner: Operator + Agents) 21 22 Objective: Record the known-good Spark baseline that all later rollback refers to. 23 24 Tooling and status: `scripts/tpm_measurement_campaign.sh capture` records PCR banks, 25 the event log (with a replay check against live PCRs), PK/KEK/db/dbx bytes and 26 digests, boot entries and versions, read-only. `scripts/trust1_credential_policy.sh 27 --live` decodes which TPM policy seals each systemd credential and whether it 28 would unseal now. The 2026-09-30 addendum 29 [trust1_gate0_addendum_v1.json](../evidence/trust1_gate0_addendum_v1.json) 30 corrects the 2026-09-23 receipt: Gate 0 is open until the offline material has 31 a second independent location, cold-boot PCR stability is measured, and 32 firmware auto-refresh is paused. 33 34 Preconditions: Secure Boot enabled; Linux boots normally; TPM-sealed storage unlocks; vault unlocks. 35 36 Permitted mutations: Read-only inspection only, plus writing the baseline receipt to `evidence/`. No trust, boot, TPM, or storage mutation. 37 38 Acceptance tests: 39 - Secure Boot state recorded; PK/KEK/db/dbx fingerprints recorded. 40 - PCR values stable across multiple identical cold boots or variation explained. 41 - TPM event-log digest recorded; parser correctness confirmed. 42 - BootOrder and boot entries recorded; firmware version recorded. 43 - Every encrypted volume identified; LUKS/container IDs and header metadata digests recorded; every unlock path/keyslot recorded; which TPM object unlocks which volume/credential recorded; exact current TPM policy/PCR selection per secret recorded from enrollment config, not inferred. 44 - Offline recovery credential located; age identity located; decryption actually exercised against intended volume; vault credential recovery path proven independently. Secret values never recorded: identifiers, fingerprints, policy metadata, and proof only. 45 - Service baseline after restart-storm cleanup recorded; clean git/source state for reconstruction repos recorded; M2 CPU/memory facts referenced; UART/debug uncertainties listed. 46 - ATLAS_RECOV catalogued without exposing secrets; explicitly marked not disposable, not an installer disk. 47 48 Evidence required: Baseline `EvidenceReceiptV1` with fields per Q21 (receipt type, schema, timestamp, machine ID, operator/agent identity, repo, commit SHA, dirty flag, build ID, input/output digests, toolchain, procedure ID, result, assertions, receipt dependencies, hardware state, signature). Includes Secure Boot variables export where platform permits. 49 50 Rollback: N/A (read-only). If any Q26 item unanswerable, Gate 0 FAILS: nothing else starts. 51 52 Stop condition: If Spark does not unlock tomorrow I must know what protects data, what changed, and which independent path restores access. Otherwise not frozen. 53 54 --- 55 56 ## Gate 1: Build and prove recovery media (Owner: Operator + Agents) 57 58 Objective: Dedicated recovery USB proven on the real Spark before any trust change. 59 60 Runbook: [docs/RECOVERY_MEDIA_MACHINE1.md](RECOVERY_MEDIA_MACHINE1.md). The 61 stick boots and returns unattended (#53); `scripts/build_standalone_recovery_initrd.sh` 62 now also packages `fsck.vfat`, `mkfs.vfat`, `fsck.ext4`, and `chroot` for 63 items 12-14 (mount recovered storage, repair `/boot/efi`, restore boot 64 entries); `scripts/verify_recovery_tools.sh` is the pre-boot host proof; 65 `scripts/collect_recovery_boot_evidence.sh` records the attended boot. 66 67 Status (2026-09-30, software side): the image now also carries `sbverify`, `fusermount3` and the TPM device transport library (loaded at run time, so `ldd` never saw it), and the build fails loudly when `gocryptfs` is missing (FUSE is built into the Ubuntu kernel). `verify_recovery_tools.sh` checks that every library each recovery tool needs is inside the image. The collector now records items 6 (gocryptfs stores), 8 (PCRs, event log digest), 9-10 (ESP layout, hash and signer of every EFI image) and, only when the operator sets the unlock variables for that run, items 11-12 (open one store read-only with the offline spare and check a test file). `scripts/test_recovery_unlock_chroot.sh` (manual, needs sudo) rehearses that unlock with the image's own `age` and `gocryptfs` and throwaway keys. Still physical: rebuild the stick with this image (operator approval), the attended Secure-Boot-on boot, the test-file round trip, and return to Linux. 68 69 Preconditions: Gate 0 PASS. 70 71 Permitted mutations: Create recovery image on build host; write to separate physical USB (not ATLAS_RECOV); boot it once via operator-attended boot with Secure Boot enabled. No internal trust, TPM, or slot mutation. 72 73 Acceptance tests (Q17, all must pass with Secure Boot ON): 74 1. Firmware accepts recovery image. 2. Environment starts without internal Linux. 3. No network required. 4. No model required. 5. No Cortex required. 6. Identifies NVMe and encrypted volumes. 7. Inspects Secure Boot state. 8. Inspects PCRs/event data. 9. Shows AIENOS A/B slots and manifests. 10. Verifies signatures/hashes. 11. Accesses independent recovery mechanism only when explicitly authorized. 12. Mounts recovered storage safely. 13. Can reinstall known-good loader/slot. 14. Can restore documented boot config. 15. Returns machine to known-good Linux boot. 16. No destructive overwrite unless operator explicitly chooses it. 75 - Harmless test artifact round-trip: create known file → shutdown → recovery boot → unlock via recovery path → verify → normal boot. No destructive test of real dataset. 76 77 Evidence required: Recovery receipt (image SHA-256 + BLAKE3, layout digest, tool manifest, signing cert fingerprint, boot result, test-artifact digest, unlock method, return-to-Linux proof) plus `aien-proof` ledger receipt. 78 79 Rollback: Remove USB; boot Linux default. If recovery not proven, STOP: no Gate 2+. 80 81 --- 82 83 ## Gate 2: TPM measurement campaign (Owner: Agents, Operator for reboots) 84 85 Objective: Determine which measurements represent enforceable security properties before choosing any PCR policy. 86 87 Tooling: `scripts/tpm_measurement_campaign.sh` `capture` (one snapshot per boot), 88 `compare` (item-by-item diff, exit 3 on any change) and `receipt` (per-experiment 89 JSON: before, one variable, after, post-rollback, chained to the previous 90 receipt; result `STOP_UNEXPECTED_STATE` when rollback does not restore the 91 before state). Host self-test: `scripts/test_trust1_measurement_tools.sh`. 92 93 Preconditions: Gates 0-1 PASS. System stable. No firmware auto-update during campaign. 94 95 Permitted mutations: Controlled one-variable boot experiments + rollback after each. No permanent policy change. 96 97 Acceptance tests: Baseline repeated cold boots produce stable measurements or variation explained. Each experiment changes exactly one variable (Q15 list: kernel, init image, boot order, db addition, owner cert addition, loader version, semantically-identical loader rehash, signer rotation, manifest-only, kernel-only, slot A vs B, firmware setting, firmware update if occurs, recovery boot, tampered image) with before → mutation → PCR/event result → after → rollback → post-rollback measurements recorded. Final report explains why each candidate PCR contributes to security; no PCR selected by convention. 98 99 Evidence required: Per-experiment measurement receipts (baseline, one variable, resulting PCRs, event-log digest, rollback result) chained to baseline receipt. 100 101 Rollback: Restore pre-experiment boot state after each run. Firmware changes treated as new campaign input; never relax policy automatically. 102 103 Stop condition: Any unexplained PCR change → UnexpectedState protocol (Gate 9), no policy chosen. 104 105 --- 106 107 ## Gate 3: Owner Root key ceremony (Owner: Operator; Agents prepare) 108 109 Objective: Small owner-controlled hierarchy exists offline with verified backups, unenrolled in firmware yet. 110 111 Preconditions: Gates 0-1 PASS; Gate 2 measurements collected (analysis may finish in parallel, but no firmware enrollment until Gate 2 complete). 112 113 Permitted mutations: Offline ceremony on clean disconnected environment only. Generate Owner Root, Boot Signer, Release Signer, Operator Approval key. Owner Root signs generation-1 authority manifest (subordinate publics, creation time, generation, roles, rotation rules). Two encrypted offline backups in separate locations. Export publics/fingerprints only. Destroy plaintext temp copies and verify. 114 115 Roles (Q6): Root never on Spark, never routine; Boot Signer signs small stable loader (firmware trusts its cert); Release Signer signs kernel/manifests under loader (replaceable via root-signed manifest; compromise never requires firmware-root replacement); Operator Approval authorizes boundary changes, never boots. Firmware must not trust a general dev key. Preserve factory trust alongside; full PK/KEK replacement is a later milestone after recovery independently proven. 116 117 Acceptance tests: Ceremony record contains tool versions, procedure, public fingerprints, manifest digest, backup-media IDs, both-backup decrypt verification, operator signature. Record contains no private material. Rotation path demonstrated as add → verify → exercise recovery → revoke (never delete-first). Root replacement defined as special recovery ceremony. 118 119 Evidence required: Key ceremony receipt (fingerprints, manifest digest, roles, backup count, verification success). 120 121 Status (2026-09-30, software side): `scripts/trust1_key_ceremony.sh` (OpenSSL 3 only, Linux or macOS) implements the ceremony: `preflight` refuses to run with a network route; `generate` creates Owner Root, Release Signer and Operator Approval (Ed25519) and the Boot Signer (RSA-2048 self-signed X.509 with codeSigning, the form UEFI db and sbsign need), each private key encrypted from creation, plus the generation-1 authority manifest signed by Owner Root; `backup` copies to a medium and proves every key decrypts from that copy; `record` writes the ceremony receipt (no private material); `rotate ROLE add|revoke` demonstrates add, verify, revoke as new root-signed generations with the old key quarantined, never deleted; `verify DIR MIN_GEN` refuses an older generation. Owner Root and Boot Signer are not rotatable by this tool (special ceremony, firmware db). `scripts/test_trust1_key_ceremony.sh` (verify_all step 12) exercises all of it with throwaway keys, including tamper, swapped key, wrong passphrase, rollback, and signing the loader with the Boot Signer cert. `scripts/generate_owner_boot_keys.sh` stays a disposable dev key and is not part of this gate. Operator steps: [TRUST-1-OPERATOR-STEPS.md](TRUST-1-OPERATOR-STEPS.md) Step 8. Still physical: the offline ceremony itself and the two backups in separate places. 122 123 Rollback: No firmware state changed; destroy or quarantine disputed material per operator direction and re-run ceremony if needed. 124 125 --- 126 127 ## Gate 4: Emulator security suite (Owner: Agents) 128 129 Objective: Signed loader + A/B flow proven entirely in QEMU before hardware eligibility. 130 131 Preconditions: Gates 2-3 complete (authority manifest exists). Clean checkout; dirty builds never signable. 132 133 Permitted mutations: Code, manifests, and test artifacts in repo/QEMU only. No hardware trust mutation. 134 135 Acceptance tests (Q9, all must pass): 136 Clean UEFI boot; ExitBootServices handoff; memory-map validation; MMU init; vectors; allocator invariants; timer/interrupt where emulatable; scheduler invariants; panic/fault reporting; deterministic shutdown/reset; signed loader accepted; unsigned rejected; tampered rejected; valid manifest accepted; altered manifest rejected; A/B selection; failed candidate fallback; software-TPM policy cases (current, next, rollback) pass; Recovery Core boots model-/network-free; reproducible build from clean checkout; commit/inputs/digest recorded. Soak: 100 consecutive boots, 100 expected outcomes. Fault injection: bad manifest, corrupt kernel, missing state, invalid memory map, interrupted update, boot panic, invalid policy, failed slot. 137 138 Evidence required: Build receipts (commit, lockfile digest, toolchain, command, binary digest, reproducibility) + emulator receipts (image digest, suite version, counts, fault results, swTPM state). 139 140 Status (2026-09-30): "signed loader accepted; unsigned rejected; tampered rejected" is covered by `scripts/qemu_secureboot_signing_test.sh` (verify_all step 11). It boots with Secure Boot ON under AAVMF snakeoil firmware (a published TEST key, never an owner key): the snakeoil-signed loader reaches `kernel: alive`; the unsigned image, a one-byte-flipped signed image and an image signed by a throwaway key not in db are each refused with the firmware verdict `Access Denied`. The older `qemu_security_suite.sh` "corrupt rejected" case runs with Secure Boot OFF and only shows a PE load failure. Still open for Gate 4: signing with the Gate 3 Boot Signer instead of snakeoil (needs Gate 3), manifest accepted/altered, A/B selection and fallback, swTPM policy current/next/rollback (Gate 5), the 100-boot soak (suite default is 5, verify_all runs 3), and the build/emulator receipts. 141 142 Rollback: N/A (no hardware state). Failure returns to implementation, never to hardware. 143 144 --- 145 146 ## Gate 5: TPM authorization policy simulation (Owner: Agents) 147 148 Objective: Owner-approved release-set policy defined and exercised in software TPM. 149 150 Preconditions: Gates 2-4 PASS (measurements + emulator suite). 151 152 Permitted mutations: Policy definition files and swTPM simulation only. No real TPM enrollment change. 153 154 Acceptance tests: Semantics owner-approves-N → accepts N; approves N+1 → accepts N and N+1 during transition; N+1 healthy → may retire N. Cases pass: current, next, rollback, invalid, rotation, recovery. Target statement enforced: "Secure Boot active, owner-approved chain executed, manifest in approved release set": never a frozen hex value. Anti-rollback generation semantics defined (Q29): approved vs emergency-only vs revoked; recovery override under operator control only. 155 156 Evidence required: Policy spec + simulation receipts. 157 158 Rollback: N/A. Do not proceed to storage migration until simulation passes. 159 160 --- 161 162 ## Gate 6: Storage migration preparation, no retirement (Owner: Operator + Agents) 163 164 Objective: New unlock envelope installed alongside old; independent recovery verified; nothing retired. 165 166 Preconditions: Gates 0-5 PASS. Volume healthy. 167 168 Permitted mutations: Add new TPM authorization envelope and verify new offline recovery credential while volume healthy. Add-only; never remove last working path. 169 170 Stages (Q16): 1. Prove existing recovery (decrypt, correspond to volume) or create/test new independent credential first. 2. Coexist: current TPM path + new owner-policy path + offline path. 3. Prove all three unlock. 4. Exercise approved/previous/rejected-unsigned/Linux-rollback/recovery-media cases. 5. Observation across update/rollback cycles. 171 172 Acceptance tests: Current Linux unlocks; recovery credential unlocks; owner-policy unlocks; rejected image rejected; rollback to Linux works; recovery-media unlock works. Old enrollment retained. 173 174 Evidence required: Storage-migration receipt (old verified, offline verified, new installed, new verified, old retained, header metadata digest). 175 176 Rollback: New path disabled; old + offline paths remain. If new path fails, STOP, preserve, report. 177 178 --- 179 180 ## Gate 7: TRUST-1 hardware validation, single exception (Owner: Operator; one aien-proof machine-1 hold) 181 182 Objective: With Secure Boot ON, owner-signed loader boots once, Linux remains default/fallback, storage/vault survive, no permanent trust lost. 183 184 Preconditions: Gates 0-6 PASS; recovery USB proven; owner keys backed up; Secure Boot variables archived; emulator suite passing; operator TRUST-1 approval receipt. 185 186 Permitted mutations (only these, in order): add owner trust without deleting factory trust; one-time BootNext AIENOS entry; add new TPM authorization path without removing current one. No BootOrder default change, no Linux entry replacement, no AIENOS default, no factory-trust removal, no old-TPM removal. 187 188 Checkpoints (Q18): 189 - Preflight bundle captured (variables, PCRs/event log, boot entries, unlock methods, volume metadata, kernel identity, candidate digest, key fingerprints, recovery digest, service state, approval). 190 - A: recovery media boots or STOP. 191 - B: add owner trust → reboot Linux → Secure Boot on, Linux boots, storage unlocks or restore trust and STOP. 192 - C: stage owner-signed AIENOS BootNext only → boot → loader accepted, chain valid, kernel entered, measurements recorded, timed return or recover and STOP. 193 - D: Linux returns → Secure Boot on, storage unlocks, vault unlocks, default unchanged, services stable. 194 - E: test new TPM path only after chain proven; never enroll trust + replace policy in one irreversible step. 195 - Every mutation: before evidence → one mutation → validation → rollback checkpoint. Unexpected state → STOP-PRESERVE-OBSERVE-REPORT, no improvisation; documented non-boundary rollback only. 196 197 Acceptance tests: Secure Boot stayed ON; owner loader accepted; unsigned/tampered rejected (proven in emulator + spot-check where safe); kernel alive; BootNext consumed; Linux default; storage unlocks; vault unlocks; previous unlock path still valid; recovery re-proven after. 198 199 Evidence required: TRUST-1 receipt chain (pre-state, each mutation/validation/checkpoint, final state, approvals) + aien-proof hold ledger + PCR/event snapshots + artifact digests. 200 201 Rollback: Level 1 candidate→known-good; Level 2 AIENOS→Linux default; Level 3 restore prior Secure Boot variables/keys; Level 4 previous TPM enrollment or offline credential; Level 5 dedicated recovery media (Q11). 202 203 --- 204 205 ## Gate 8: Observation period (Owner: Automation + Operator) 206 207 Objective: Prove reliability before retiring anything. 208 209 Preconditions: Gate 7 PASS. 210 211 Permitted mutations: Normal Linux boots + controlled AIENOS candidate cycles under new chain. No retirement. 212 213 Acceptance tests: Several successful Linux boots and AIENOS candidate cycles with old + new + offline paths retained and healthy. 214 215 Evidence required: Ongoing boot/storage receipts chained to TRUST-1. 216 217 Rollback: Any regression → retain all paths, return to Gate 7 analysis. 218 219 --- 220 221 ## Gate 9: Retire legacy TPM policy; resume native development (Owner: Operator approval required) 222 223 Objective: Owner-controlled policy becomes primary; ordinary native AIENOS development resumes under new chain. 224 225 Preconditions: Gate 8 evidence shows repeatable reliability. 226 227 Permitted mutations: Retire old TPM enrollment only. No other trust change in same step. 228 229 Acceptance tests: Owner policy unlocks repeatedly across boots/updates/rollbacks; offline recovery still valid; Linux default intact; AIENOS A/B discipline holds (write inactive → verify → boot once → health → promote → retain rollback; bounded attempts, no boot-loop, last-good never erased by candidate/agent; dual-invalid → recovery media; root-of-trust promotion still needs operator approval even if tests pass). 230 231 Evidence required: Retirement receipt + updated policy manifest. 232 233 Rollback: Re-enroll previous policy from archived state or unlock via offline credential. 234 235 --- 236 237 ## Cross-cutting requirements (apply to all gates) 238 239 Loader minimality (Q14): Loader answers only what may boot, which slot, and what verified facts the kernel receives. Out: networking, package management, inference, Cortex, AEGIS evaluation, general FS, shell, repair, apps, update download, complex drivers, excess unseal, business logic. Loader changes rarely. 240 241 Slot/manifest (Q19): A=known-good, B=candidate (roles, not names). Manifest minimum: format version, generation, kernel digest, image digest, loader ABI, kernel ABI, signer, commit, provenance, rollback compat, policy generation, timestamp, signature. Health gates before promotion receipt; explicit authenticated promotion. 242 243 M3 readiness (post-TRUST-1 only): Emulator must prove EL/vectors/IRQ/fault, allocator/page tables/isolation/permissions, timer/GIC, scheduler/SMP, IPC/capabilities, panic/watchdog/fallback, security invariants (no arbitrary phys map, no cross-task access, no forged caps, no writable kernel metadata), stress + 100 clean boots. First hardware M3 proves platform differences only. 244 245 Boundary enforcement (Q23): `security-boundary.toml` (root_of_trust, secure_boot, tpm_policy, storage_unlock, cryptography, kernel_privilege, aegis, capability_model, effect_broker, persistent_identity, recovery, persistent_format) mapping paths/APIs to approval class and tests. Every PR declares SECURITY_IMPACT (NONE/BOUNDARY/ROOT_OF_TRUST/AUTHORITY/RECOVERY/PERSISTENT_FORMAT). CI independently classifies; mismatch with NONE fails hard; any sensitive class requires operator approval receipt + security tests. Classifier/branch/CI/boundary-map/signing changes are ROOT_OF_TRUST/AUTHORITY, never autonomous. 246 247 Build identity (Q24): BuildIdentityV1 (repo, commit, dirty flag, dep digests, Cargo.lock, compiler, target, linker, flags, features, env whitelist, script versions, epoch, artifact digest). SHA-256 + BLAKE3. Loader/ kernel/ manifest/ recovery identities as specified. Reproducibility: two clean builds → same unsigned artifact or not signable. Sign after identity; manifest references unsigned digest + envelope digest. 248 249 Unexpected states (Q25): STOP → PRESERVE → OBSERVE → REPORT with UnexpectedStateReceipt (expected, actual, last checkpoint, last mutation, evidence, rollback options). Forbidden to fix-forward across unknown security state. Documented non-boundary rollback only; else wait for operator. Rule: unknown state means no new mutation. 250 251 Firmware policy (Q29): No auto firmware update during transition; record version before every TRUST-1-class op; firmware change = new measurement input; never auto-relax policy; recover via recovery path and deliberately authorize new state. 252 253 Disaster recovery (Q29, architectural now, required before AIENOS becomes sole environment): Off-machine encrypted backups for Owner Root, storage recovery, AIEN identity, Cortex, source/provenance, manifests/recovery artifacts. Invariant: loss of Machine 1 costs hardware and unreplicated execution state, never ownership, data, authority, or rebuild ability. 254 255 Documentation: This plan + receipts live in `docs/` and `evidence/` with hash-linked chain. Every important claim has an artifact, not a memory.