aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
aien-architecture-mv / docs / milestone-5-spec.md
| 1 | # Specification: Milestone 5 — Omega Direct AArch64 Realization (`OMEGA_AARCH64`) |
| 2 | |
| 3 | ```text |
| 4 | Document ID: SPEC-OMEGA-M5 |
| 5 | Milestone: Milestone 5 (OMEGA_AARCH64) |
| 6 | Classification: Sovereign Machine Canonical Specification |
| 7 | Target Substrate: Native AArch64 Bare-Metal Machine Bytes (No LLVM, No Foreign Assembler) |
| 8 | Status: QUALIFIED / RATIFIED (aien-spark/aien-architecture#17, aien-spark/omega@2dd4102) |
| 9 | Lineage: SILICON -> ATLAS (M1) -> PHYSICS (M2/M3) -> OMEGA (M4/M5) -> AIEN |
| 10 | ``` |
| 11 | |
| 12 | --- |
| 13 | |
| 14 | ## 1. Executive Summary & Foundational Invariants |
| 15 | |
| 16 | Milestone 4 established `OMEGA_SEMANTICS`: defining what computation means in a substrate-independent semantic graph ($G_S$) with canonical content-addressed identity (`SEMANTIC_ID`). |
| 17 | |
| 18 | Milestone 5 establishes the first direct lowering from abstract semantic meaning into native physical machine code: |
| 19 | |
| 20 | > **OMEGA SYNTHESIZES BARE-METAL AARCH64 MACHINE BYTES DIRECTLY FROM SEMANTIC MEANING WITHOUT LLVM, GCC, OR THIRD-PARTY ASSEMBLERS.** |
| 21 | |
| 22 | The objective is to establish direct physical realization while preserving absolute semantic equivalence: |
| 23 | |
| 24 | ```text |
| 25 | M4 SEMANTIC OBJECT ($G_S$) |
| 26 | F(a, b, c) = (a + b) - c |
| 27 | ↓ |
| 28 | SEMANTIC_ID S |
| 29 | ↓ |
| 30 | OMEGA AARCH64 REALIZER |
| 31 | ↓ |
| 32 | RAW MACHINE BYTES B |
| 33 | ↓ |
| 34 | REALIZATION_ID R (references S) |
| 35 | ↓ |
| 36 | PHYSICAL / QEMU EXECUTION |
| 37 | ↓ |
| 38 | native_result == semantic_result |
| 39 | ``` |
| 40 | |
| 41 | --- |
| 42 | |
| 43 | ## 2. Inviolable Governance Principles at M5 |
| 44 | |
| 45 | 1. **No Foreign Compiler Infrastructure**: |
| 46 | LLVM, GCC, Clang, GNU `as`, NASM, and third-party JITs are strictly forbidden in the canonical realization path. Machine instructions must be synthesized directly as 32-bit AArch64 binary words. |
| 47 | |
| 48 | 2. **Dual-Seam Instruction Verification**: |
| 49 | - **Seam 1 (Static Decoding Seam)**: An independent direct AArch64 decoder disassembles and validates every emitted instruction byte prior to execution, ensuring structural validity and absence of undefined opcodes. |
| 50 | - **Seam 2 (Execution Parity Seam)**: The synthesized code is executed on AArch64 (both native DGX Spark and bare-metal QEMU) and verified to yield the bit-for-bit identical result as M4 pure semantic evaluation. |
| 51 | |
| 52 | 3. **Cryptographic Binding of Realization to Meaning**: |
| 53 | $$\text{REALIZATION\_ID} = \text{SHA256}(\text{CANONICAL\_REALIZATION\_ENCODING})$$ |
| 54 | The canonical realization encoding explicitly embeds the `SEMANTIC_ID` of the source graph, binding physical machine bytes to abstract meaning. |
| 55 | |
| 56 | 4. **Adversarial Bit Mutation Gate**: |
| 57 | Mutating any single bit in the generated machine code must either: |
| 58 | - Cause immediate rejection by the independent instruction decoder, OR |
| 59 | - Produce a detectable differential mismatch during execution. |
| 60 | |
| 61 | --- |
| 62 | |
| 63 | ## 3. Strict Initial Instruction Subset (Anti-Bloat Ceiling) |
| 64 | |
| 65 | To keep the initial proof focused on **semantic preservation** without memory-system or MMU complexity, Milestone 5 restricts instruction synthesis to a strictly bounded integer computational subset: |
| 66 | |
| 67 | ### Primary Computational Primitives |
| 68 | 1. **64-bit & 32-bit Integer ALU**: |
| 69 | - `ADD` (shifted register / immediate) |
| 70 | - `SUB` (shifted register / immediate) |
| 71 | - `MUL` (register multiplication) |
| 72 | - `AND`, `ORR`, `EOR` (bitwise logical operations) |
| 73 | 2. **Immediate Loading & Register Movement**: |
| 74 | - `MOV` / `MOVZ` (wide immediate) |
| 75 | - `MOVN`, `MOVK` |
| 76 | 3. **Control Flow & Return**: |
| 77 | - `RET` (unconditional return to link register `x30`) |
| 78 | - `B` (bounded relative branch) |
| 79 | - `B.cond` (conditional branch on integer flags: `EQ`, `NE`, `LT`, `GE`) |
| 80 | - `CBZ`, `CBNZ` (compare and branch on zero / non-zero) |
| 81 | |
| 82 | *Memory loads and stores (`LDR`, `STR`) and stack frames are deferred until pure register computation is fully qualified.* |
| 83 | |
| 84 | --- |
| 85 | |
| 86 | ## 4. Lowering Rules: $G_S \to \text{AArch64}$ |
| 87 | |
| 88 | The lowering pipeline maps: |
| 89 | - Types $\to$ Register width ($w \le 32 \to$ `Wn`, $32 < w \le 64 \to$ `Xn`). |
| 90 | - Inputs $\to$ Standard AArch64 ABI parameter registers (`x0`, `x1`, `x2`, ...). |
| 91 | - Pure Operations $\to$ Direct 32-bit machine word emission. |
| 92 | - Output $\to$ Return register `x0`. |
| 93 | - Terminal $\to$ `RET` instruction (`0xD65F03C0`). |
| 94 | |
| 95 | --- |
| 96 | |
| 97 | ## 5. Canonical M5 Qualification Gates |
| 98 | |
| 99 | 1. `OMEGA_AARCH64_PROFILE_PASS`: Validates target profile, registers, and calling conventions. |
| 100 | 2. `OMEGA_AARCH64_ENCODER_PASS`: Direct binary emission of integer ALU, MOV, branches, and RET without foreign tools. |
| 101 | 3. `OMEGA_AARCH64_DECODER_SEAM_PASS`: Independent decoder validates all emitted instruction words. |
| 102 | 4. `OMEGA_AARCH64_LOWERING_PASS`: $G_S$ pure operation graphs lower deterministically into instruction sequences. |
| 103 | 5. `OMEGA_AARCH64_REALIZATION_ID_PASS`: `REALIZATION_ID` deterministically binds machine bytes and `SEMANTIC_ID`. |
| 104 | 6. `OMEGA_AARCH64_NATIVE_EXECUTION_PASS`: Native execution on AArch64 host matches M4 pure semantic evaluation. |
| 105 | 7. `OMEGA_AARCH64_QEMU_EXECUTION_PASS`: Bare-metal execution in QEMU `virt` machine matches semantic evaluation. |
| 106 | 8. `OMEGA_AARCH64_ADVERSARIAL_MUTATION_PASS`: Single-bit machine code corruption detected fail-closed. |
| 107 | 9. `OMEGA_AARCH64_CROSS_BUILD_DETERMINISM_PASS`: Reproducible byte-for-bit realization across independent runs. |