aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / docs / PHASE_3_TO_5_SPECIFICATION.md
| 1 | # AIENOS: Technical Specification & Contracts (Phases 3 – 5) |
| 2 | |
| 3 | > **REFERENCE TECHNICAL SPECIFICATION, NOT AN ACTIVE ROADMAP.** Current AIENOS sequencing is [../ROADMAP.md](../ROADMAP.md). Whole-system sequencing is owned by `aien-spark/aien-architecture/CURRENT_EXECUTION_PLAN.md`. See [PLAN_AUTHORITY.md](PLAN_AUTHORITY.md). |
| 4 | |
| 5 | > **Status:** Reference Architecture/Contract Snapshot |
| 6 | > **Target:** Native Agent Wakeup, Epistemic Memory, Capability Enforcement, and C1 Branch-Native Compute |
| 7 | > **Authority:** AIENOS Final Architectural Blueprint §§ 9–14, 17–19, 28 |
| 8 | |
| 9 | --- |
| 10 | |
| 11 | ## 1. Overview & Phased Roadmap |
| 12 | |
| 13 | This specification establishes the formal data structures, interface boundaries, and invariant contracts for the three evolutionary phases succeeding Native Bare-Metal Boot (Phase 2): |
| 14 | |
| 15 | ```text |
| 16 | Phase 2 (Substrate) Phase 3 (Continuity) Phase 4 (Intelligence) Phase 5 (Sovereignty) |
| 17 | ┌─────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐ |
| 18 | │ AIENOS Kernel │ ───► │ Persistent Agent │──► │ AEGIS & J-Worlds │ ──► │ Direct GB10 Path │ |
| 19 | │ no_std aarch64 │ │ Agent State ABI │ │ Capability Graph │ │ Hardware C1 VMM │ |
| 20 | │ UART / MMIO │ │ Cortex Epistemic │ │ C1 Prefix Tree (§28)│ │ A/B/C Benchmarks │ |
| 21 | └─────────────────┘ └─────────────────────┘ └─────────────────────┘ └─────────────────────┘ |
| 22 | ``` |
| 23 | |
| 24 | --- |
| 25 | |
| 26 | ## 2. Phase 3: The Persistent Agent Wakes Up |
| 27 | |
| 28 | ### 2.1 The Agent State ABI (§9) |
| 29 | |
| 30 | The foundational principle dictates: **Losing physical inference state costs computation, not identity.** |
| 31 | The Agent State ABI separates persistent semantic identity from ephemeral execution incarnations. |
| 32 | |
| 33 | ```text |
| 34 | LogicalAgentId (UUID v7 / Ed25519 public key) |
| 35 | │ |
| 36 | ├── LogicalBranchId (Deterministic UUID / SHA-256 derivation) |
| 37 | │ ├── ParentBranchId: Option<LogicalBranchId> |
| 38 | │ ├── TokenHistory: Append-only log of token sequence IDs & hashes |
| 39 | │ ├── Lineage: Tree path from root Genesis Agent |
| 40 | │ └── EpistemicRefs: Set of Cortex observation/fact UUIDs |
| 41 | │ |
| 42 | ▼ |
| 43 | Execution Incarnation (Ephemeral per boot/process) |
| 44 | │ |
| 45 | ├── IncarnationId: u64 (Monotonic boot counter) |
| 46 | ├── SequenceId: u32 (Scheduler slot) |
| 47 | └── PhysicalInferenceState: |
| 48 | ├── KVPageTableRef: Option<PhysicalPageTablePtr> |
| 49 | ├── AcceleratorBufferRef: Option<BufferHandle> |
| 50 | └── ComputeState: Idle | Prefilling | Decoding | Suspended | Evicted |
| 51 | ``` |
| 52 | |
| 53 | #### Core ABI Operations |
| 54 | ```rust |
| 55 | pub trait AgentStateAbi { |
| 56 | /// Fork an existing logical branch into an isolated child branch |
| 57 | fn fork_branch(&self, parent: LogicalBranchId) -> Result<LogicalBranchId, StateError>; |
| 58 | |
| 59 | /// Checkpoint logical agent state to durable storage |
| 60 | fn checkpoint(&self, agent_id: LogicalAgentId) -> Result<CheckpointHash, StateError>; |
| 61 | |
| 62 | /// Suspend execution incarnation without mutating logical state |
| 63 | fn suspend(&mut self, branch_id: LogicalBranchId) -> Result<(), StateError>; |
| 64 | |
| 65 | /// Resume execution, re-instantiating physical state via recompute or cache |
| 66 | fn resume(&mut self, branch_id: LogicalBranchId) -> Result<SequenceId, StateError>; |
| 67 | |
| 68 | /// Reconstruct lost physical state from TokenHistory and EpistemicRefs |
| 69 | fn reconstruct_physical(&mut self, branch_id: LogicalBranchId) -> Result<(), StateError>; |
| 70 | } |
| 71 | ``` |
| 72 | |
| 73 | ### 2.2 Model ABI (§14) |
| 74 | |
| 75 | Models are swappable intelligence components, not the operating system or root of trust. |
| 76 | |
| 77 | ```rust |
| 78 | pub trait ModelAbi { |
| 79 | type Token; |
| 80 | type Logits; |
| 81 | |
| 82 | /// Query static architecture metadata |
| 83 | fn metadata(&self) -> ModelMetadata; |
| 84 | |
| 85 | /// Initialize prompt prefill context |
| 86 | fn prefill(&mut self, tokens: &[Self::Token], state: &mut PhysicalInferenceState) -> Result<(), ModelError>; |
| 87 | |
| 88 | /// Decode the next token step |
| 89 | fn step(&mut self, state: &mut PhysicalInferenceState) -> Result<Self::Logits, ModelError>; |
| 90 | |
| 91 | /// Tokenize text to internal token IDs |
| 92 | fn tokenize(&self, text: &str) -> Vec<Self::Token>; |
| 93 | |
| 94 | /// Detokenize IDs back to UTF-8 |
| 95 | fn detokenize(&self, tokens: &[Self::Token]) -> String; |
| 96 | } |
| 97 | ``` |
| 98 | |
| 99 | ### 2.3 Cortex Epistemic Store (§11) |
| 100 | |
| 101 | Cortex preserves knowledge with verifiable provenance, preventing self-reinforcing hallucination. |
| 102 | |
| 103 | ```rust |
| 104 | #[repr(u8)] |
| 105 | pub enum EpistemicStatus { |
| 106 | DirectObservation = 1, // Raw sensor / hardware / file input |
| 107 | VerifiedFact = 2, // Mathematically / cryptographically proven |
| 108 | Inference = 3, // Model deduction from observations |
| 109 | Hypothesis = 4, // Tentative exploration branch |
| 110 | Contradiction = 5, // Detected epistemic conflict |
| 111 | OperatorDecision = 6, // Canonical directive from operator |
| 112 | } |
| 113 | |
| 114 | pub struct EpistemicRecord { |
| 115 | pub id: Uuid, |
| 116 | pub status: EpistemicStatus, |
| 117 | pub statement: String, |
| 118 | pub provenance_source: String, |
| 119 | pub evidence_hash: [u8; 32], |
| 120 | pub created_at_utc: u64, |
| 121 | pub confidence: f32, |
| 122 | pub verified_by: Option<String>, |
| 123 | } |
| 124 | ``` |
| 125 | |
| 126 | --- |
| 127 | |
| 128 | ## 3. Phase 4: Native System Intelligence (AEGIS, Worlds & Capabilities) |
| 129 | |
| 130 | ### 3.1 The Capability Graph (§13) |
| 131 | |
| 132 | Traditional process permissions are replaced with unforgeable capability tokens arranged in a directed acyclic capability graph. |
| 133 | |
| 134 | ```text |
| 135 | root.authority (Operator) |
| 136 | │ |
| 137 | ├── cap::filesystem [scope: /projects, mode: rw] |
| 138 | ├── cap::network [scope: local-fabric, port: 8080] |
| 139 | ├── cap::model [model: Llama-3.2-1B, max_tokens: 4096] |
| 140 | ├── cap::device [device: MMIO_UART, access: read_write] |
| 141 | └── cap::world [action: create, max_depth: 4] |
| 142 | ``` |
| 143 | |
| 144 | ### 3.2 AEGIS Effect Intent Pipeline (§5) |
| 145 | |
| 146 | Intelligence proposes; deterministic authority disposes. The model cannot authorize itself. |
| 147 | |
| 148 | ```text |
| 149 | AIEN Reasoning Loop |
| 150 | │ |
| 151 | ▼ (Proposes action) |
| 152 | EffectIntent { |
| 153 | action: "publish_code", |
| 154 | parameters: { repo: "aienos-repo", commit: "..." }, |
| 155 | claimed_capability: "cap::git::publish" |
| 156 | } |
| 157 | │ |
| 158 | ▼ |
| 159 | AEGIS Evaluator |
| 160 | ├── 1. Cryptographic validation of capability token |
| 161 | ├── 2. Verification of operator policy (Is action reversible?) |
| 162 | │ ├── Reversible (Inside World) ──► Auto-Approve |
| 163 | │ └── Irreversible (External) ──► Solicit Operator Approval |
| 164 | │ |
| 165 | ▼ (Approved) |
| 166 | EffectBroker |
| 167 | │ (Dispatches to native device / driver) |
| 168 | ▼ |
| 169 | Hardware / Network / Disk Effect |
| 170 | ``` |
| 171 | |
| 172 | ### 3.3 J-Space Worlds (§12) |
| 173 | |
| 174 | A World is an isolated, transactional sandbox with copy-on-write semantics: |
| 175 | - Modifications to files, memory, and runtime state are isolated to a delta layer. |
| 176 | - Rollback is instantaneous via pointer drop. |
| 177 | - Promotion to canonical state requires an explicit `PromoteWorldIntent` verified by AEGIS. |
| 178 | |
| 179 | --- |
| 180 | |
| 181 | ## 4. Phase 5: Native Hardware Acceleration & Hardware-Bound C1 Compute |
| 182 | |
| 183 | ### 4.1 Hardware-Accelerated C1 Copy-On-Write Engine (§10, §19, §28) |
| 184 | > *Note:* The algorithmic C1 Copy-On-Write prefix tree data structure and §28 invariants are established in Phase 4 (`crates/aienos-c1-tree`); Phase 5 binds physical KV page frames directly to the NVIDIA Blackwell GB10 accelerator over NVLink-C2C. |
| 185 | |
| 186 | Instead of replicating common prefix KV states across $N$ parallel reasoning branches, AIENOS maintains a shared physical prefix tree: |
| 187 | |
| 188 | ```text |
| 189 | Root Prefix: System Prompt + Codebase Context (100K Tokens) |
| 190 | Physical Address: [Page 0x1000 .. 0x4000] (RefCount: 3) |
| 191 | │ |
| 192 | ┌───────────┼───────────┐ |
| 193 | ▼ ▼ ▼ |
| 194 | Branch 1 Branch 2 Branch 3 |
| 195 | (Plan A) (Plan B) (Plan C) |
| 196 | [Private] [Private] [Private] |
| 197 | Page 0x5000 Page 0x6000 Page 0x7000 |
| 198 | ``` |
| 199 | |
| 200 | #### Invariant Matrix: |
| 201 | 1. **Zero Duplication**: Shared prompt tokens map to identical physical KV pages. |
| 202 | 2. **Deterministic Divergence**: Allocation of private pages occurs strictly upon divergent token generation. |
| 203 | 3. **Eviction Independence**: Children preserve semantic identity even if physical KV pages are evicted to RAM or disk; reconstruction re-executes deterministically from the last checkpoint. |
| 204 | |
| 205 | ### 4.2 Hardware Sovereignty: 3-Way Benchmark Suite (§19) |
| 206 | |
| 207 | Performance is measured systematically across three configurations: |
| 208 | - **Config A**: Reference baseline on Ubuntu 24.04 LTS (frozen in Phase 1). |
| 209 | - **Config B**: Minimal Linux compatibility island. |
| 210 | - **Config C**: Native AIENOS bare-metal substrate. |
| 211 | |
| 212 | ```text |
| 213 | Benchmark Metrics: |
| 214 | 1. Power-On to Agent Ready (ms) |
| 215 | 2. Agent Ready to Model Inference Ready (ms) |
| 216 | 3. Time-to-First-Token (TTFT) across 1K, 16K, 128K context |
| 217 | 4. Sustained Token Generation (tokens/sec) |
| 218 | 5. Branch Fork Overhead (microseconds to branch 100K context) |
| 219 | 6. Scheduler Jitter (microseconds at 99.9th percentile) |
| 220 | 7. Physical Memory Overhead per Concurrent Agent Branch (MiB) |
| 221 | ``` |
| 222 | |
| 223 | --- |
| 224 | |
| 225 | ## 5. Verification & Acceptance Criteria for Next Phases |
| 226 | |
| 227 | - [ ] `AgentStateAbi` supports deterministic serialization and deserialization across reboot. |
| 228 | - [ ] Epistemic store detects and rejects ungrounded self-reinforcing assertions. |
| 229 | - [ ] AEGIS sandbox rejects any irreversible effect originating from an unapproved intent. |
| 230 | - [ ] C1 COW tree demonstrates zero memory increase when branching a 10,000-token prefix across 10 concurrent exploratory branches. |
| 231 | - [ ] Machine-readable evidence logs accompany all measured performance claims. |