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/AGENTS.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 / AGENTS.md` 96 lines · 6116 bytes Raw Blame History Rendered 1 # Planning authority 2 3 Before using any roadmap or architecture plan, read `docs/PLAN_AUTHORITY.md` and `ROADMAP.md`. 4 5 Whole-system execution order is owned by `aien-spark/aien-architecture/CURRENT_EXECUTION_PLAN.md`. This repository does not own a competing AIEN master plan. 6 7 --- 8 9 # AIEN OS Recovery Gate — Agent Directives & Architectural Invariants 10 11 This document codifies mandatory architectural invariants, cryptographic boundaries, and coding standards for all agents modifying `aienos-recovery-gate`. 12 13 --- 14 15 ## 1. The Separation of Proofs Doctrine 16 17 Any validation or recovery flow must strictly separate and independently evaluate three distinct integrity boundaries: 18 19 1. **Store v1 Structural Integrity (Unkeyed)**: 20 - Evaluated by `Store::open()` and Store v1 DAG verification (superblocks, CommitRecords, Catalogs, CRC32C, SHA-256 graph). 21 - Validates that bytes form a crash-consistent, non-corrupted Store history. 22 - Must operate with zero key material. Informs Recovery Core whether the physical device is valid, degraded, torn, or foreign. 23 2. **M5 Keyed Authentication (`K_root_auth` / `K_vol`)**: 24 - Evaluated after key unseal using `SecurityManifest` (kind 22) HMAC-SHA256 and chunked AEAD envelope Polyval tags. 25 - Validates that the Store history and application objects were authorized by the holder of the volume encryption key. 26 3. **Anti-Rollback Freshness (`AntiRollbackSource` / `RollbackAnchor`)**: 27 - Evaluated against hardware-backed monotonic state (TPM NV counter / platform security anchor). 28 - Validates that an authorized Store history is not an unauthorized replay of an older state. 29 30 **Mandate**: Never merge, shortcut, or conflate these three proofs. A Store that fails structural integrity is physical corruption; a Store that fails keyed authentication is malicious tampering or wrong key; a Store that fails anti-rollback is replay. 31 32 --- 33 34 ## 2. Store v1 Format Immutability (ADR 0015 Permanence) 35 36 - **Frozen Superblock**: Bytes 172–4095 of the Store v1 superblock are permanently frozen as zero. 37 - **No In-Band Superblock Tags**: Never place authentication tags, MACs, or encryption headers into the physical superblock. 38 - **Application Object Encapsulation**: Cryptographic metadata must always reside in standard Store objects: 39 - `KeySlotManifest` (`kind = 21`, unencrypted bootstrap descriptor) 40 - `SecurityManifest` (`kind = 22`, 256-byte fixed authenticated root) 41 - `MigrationManifest` (`kind = 23`, cross-store lineage attestation) 42 - Application payloads (`kind = 10..20`) encapsulated in M5 chunked authenticated envelopes. 43 44 --- 45 46 ## 3. Elimination of Content-Addressing Circularities 47 48 - **No Self-Referential AAD**: Never include an entity's content hash (`ObjectId`) or Store `generation` in the Additional Authenticated Data (AAD) or MAC body before the object is sealed. 49 - `ObjectId` is `SHA256(encrypted_object_bytes)`. It does not exist prior to encryption. 50 - Store objects are immutable across generations; binding per-object encryption to a single Store generation invalidates cross-generation reuse. 51 - **Standard Envelope AAD**: 52 Every chunk's AEAD AAD must strictly adhere to: 53 ```text 54 "AIENOS-M5-CHUNK-V1\0" 55 || store_uuid: [u8; 16] 56 || object_kind: u16le 57 || object_version: u16le 58 || complete_64_byte_envelope_header: [u8; 64] 59 || chunk_index: u32le 60 || chunk_plaintext_length: u32le 61 ``` 62 63 --- 64 65 ## 4. Private Scratchpad Verification Invariant 66 67 - **Zero Plaintext Leakage**: Streaming authenticated decryption must **never** decrypt ciphertext directly into caller-provided buffers or yield unauthenticated plaintext slices. 68 - **Scratchpad Flow**: 69 1. Decrypt chunk into an internal, isolated scratchpad. 70 2. Compute and verify the Polyval authentication tag against the expected tag using constant-time comparison. 71 3. Only copy to caller output buffer after tag verification passes. 72 4. On tag failure, immediately scrub/zeroize the scratchpad and return `CryptoError::AuthenticationFailed`. 73 74 --- 75 76 ## 5. Identity-Preserving Store Migration 77 78 - **Immutable `AgentRoot`**: `genesis_store_uuid`, `LogicalAgentId`, `root_branch`, `provisioning_generation`, and `provision_source` never change across migrations. 79 - **Lineage Boundary**: When migrating to a fresh physical store, `ContinuityManifest` defines a migration boundary: 80 - Normal successor: `previous_manifest_id != 0`, `migration_parent_id == 0`. 81 - Migration successor: `previous_manifest_id == 0`, `migration_parent_id != 0` (referencing `MigrationManifest`). 82 - Chain validation terminates at a cryptographically verified migration boundary without requiring access to old storage. 83 84 --- 85 86 ## 6. Engineering & Implementation Standards 87 88 - **Zero Interpreter Policy**: Rust is the scaffolding language for new work that is not hardware-bound, and Omega is the destination language. C, assembly and native interfaces are used only where a concrete hardware, boot, firmware, ABI, driver, toolchain or qualification reason exists (the C kernel, continuity and Recovery Core in C inside that kernel, and the loader frozen as temporary scaffolding). There is no external runtime and there are zero Python/Node dependencies, and Rust-side code stays `#![no_std]` where it runs in the kernel. Source of truth: ADR 0024 in aien-spark/aien-architecture (ACCEPTED, arch#91), `docs/adr/0024-rust-scaffolding-omega-destination.md`. 89 - **Constant-Time Verification**: All cryptographic tag, MAC, and key comparisons must execute in constant time (`subtle::ConstantTimeEq` or constant-time loop). 90 - **Zeroization**: Cryptographic keys, key schedules, derived subkeys, and scratchpads must be securely zeroized on drop. 91 - **Idiomatic Rust 2021**: 92 - Prefer `as_chunks::()` over `chunks_exact(N)` when chunk length is a const. 93 - Prefer `len.is_multiple_of(N)` over `len % N == 0`. 94 - Avoid index loops over arrays containing non-Copy / zeroizing elements; use `iter_mut().enumerate()`. 95 - **Validation Discipline**: 96 - All changes must pass `AIENOS_STRICT=1 ./scripts/verify_all.sh` with zero warnings (`cargo clippy --all-targets -- -D warnings`, clean `cargo fmt`).