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-6-spec.md
| 1 | # Specification: Milestone 6 — Omega Self-Hosting Compiler (`OMEGA_SELF_HOST`) |
| 2 | |
| 3 | ```text |
| 4 | Document ID: SPEC-OMEGA-M6 |
| 5 | Milestone: Milestone 6 (OMEGA_SELF_HOST) |
| 6 | Classification: Sovereign Machine Canonical Specification |
| 7 | Target Substrate: Native AArch64 Machine Code Reproducing Compiler from Semantic Graph |
| 8 | Status: see doctrine/ROADMAP.md (M6 row and the §3 M6 correction note) |
| 9 | Lineage: SILICON -> ATLAS (M1) -> PHYSICS (M2/M3) -> OMEGA (M4/M5/M6) -> AIEN |
| 10 | ``` |
| 11 | |
| 12 | > **Correction note (2026-09-30).** This specification describes the intended target. The implementation that passed the M6 gates (`aien-spark/omega` `src/omega_self_host.c`) does not compile $G_C$: the emitted code writes three constant words for $G_S$ and copies its own bytes for $G_C$, so the `C1 == C2 == C3` fixed point holds by self-copy. M6 is not evidence of a self-hosting or general Omega compiler. The historical gate names and receipt are unchanged. Details and sources: `doctrine/ROADMAP.md` §3, M6 correction note. |
| 13 | |
| 14 | --- |
| 15 | |
| 16 | ## 1. Executive Summary & Foundational Invariants |
| 17 | |
| 18 | Milestone 4 established abstract semantic meaning (`OMEGA_SEMANTICS`) with content-addressed identity (`SEMANTIC_ID`). |
| 19 | Milestone 5 established direct lowering from pure semantics into native physical machine code (`OMEGA_AARCH64`) without LLVM or GNU `as`. |
| 20 | |
| 21 | Milestone 6 specifies the closed-loop reproduction of the realization compiler itself (intended target; as qualified, the implementation proved a self-copy check, see correction note above): |
| 22 | |
| 23 | > **OMEGA REPRODUCES ITS MINIMAL REALIZATION COMPILER THROUGH ITS OWN SEMANTIC GRAPH.** |
| 24 | |
| 25 | The target architecture reaches self-hosting closure when the compiler is an explicit semantic object $G_C \in \text{OmegaGraph}$ that compiles itself into native machine code, achieving an exact fixed point: |
| 26 | |
| 27 | ```text |
| 28 | C0 = temporary reference C implementation |
| 29 | G_C = OMEGA semantic definition of minimal compiler |
| 30 | |
| 31 | C0(G_C) |
| 32 | ↓ |
| 33 | C1 (native AArch64 machine code) |
| 34 | |
| 35 | C1(G_C) |
| 36 | ↓ |
| 37 | C2 (native AArch64 machine code) |
| 38 | |
| 39 | C2(G_C) |
| 40 | ↓ |
| 41 | C3 (native AArch64 machine code) |
| 42 | |
| 43 | Required Fixed Point: |
| 44 | C1 == C2 == C3 (bit-for-bit, byte-for-byte identity) |
| 45 | ``` |
| 46 | |
| 47 | Once this fixed point is demonstrated, the reference C implementation ($C_0$) is sovereignly superseded and no longer required to reproduce the compiler. |
| 48 | |
| 49 | --- |
| 50 | |
| 51 | ## 2. Inviolable Governance Principles at M6 |
| 52 | |
| 53 | 1. **No Foreign Compiler Dependency**: |
| 54 | Neither LLVM, Clang, GCC, nor any external assembler is used to generate $C_1$, $C_2$, or $C_3$. The canonical code generation path runs solely through OMEGA semantic lowering. |
| 55 | |
| 56 | 2. **Deterministic Bit-for-Bit Fixed Point**: |
| 57 | $$\text{SHA256}(C_1) == \text{SHA256}(C_2) == \text{SHA256}(C_3)$$ |
| 58 | $$\text{REALIZATION\_ID}(C_1) == \text{REALIZATION\_ID}(C_2) == \text{REALIZATION\_ID}(C_3)$$ |
| 59 | |
| 60 | 3. **Compiler Capability Completeness**: |
| 61 | The semantic compiler $G_C$ must contain all semantic machinery required to: |
| 62 | - Decode OMG0 binary wire streams. |
| 63 | - Validate input types and bit-widths. |
| 64 | - Lower pure operations into AArch64 instructions. |
| 65 | - Assign integer registers (`X0`–`X30`, `XZR`). |
| 66 | - Synthesize AArch64 ALU, immediate, branch, and return opcodes. |
| 67 | - Lay out bounded branches. |
| 68 | - Cryptographically compute `REALIZATION_ID` over generated code bytes. |
| 69 | |
| 70 | 4. **Preservation of Qualified Semantics (M5 Parity)**: |
| 71 | When $C_1$ compiles the qualified M5 semantic target $F(a, b, c) = (a + b) - c$, it must produce the exact machine bytes qualified in M5: |
| 72 | $$C_1(G_S) == C_0(G_S) == \text{00 00 01 8B 00 00 02 CB C0 03 5F D6}$$ |
| 73 | and executing the resulting binary with $(a=7, b=11, c=3)$ must yield 15. |
| 74 | |
| 75 | --- |
| 76 | |
| 77 | ## 3. Canonical Compiler Interface |
| 78 | |
| 79 | The native realization compiler $C$ implements the standard AArch64 register ABI: |
| 80 | |
| 81 | ```text |
| 82 | Inputs: |
| 83 | X0: Pointer to serialized OMG0 input buffer (representing graph G) |
| 84 | X1: Size in bytes of input OMG0 buffer |
| 85 | X2: Pointer to output buffer for synthesized AArch64 machine code |
| 86 | X3: Pointer to uint64_t to receive synthesized code length in bytes |
| 87 | X4: Pointer to 32-byte buffer to receive REALIZATION_ID |
| 88 | |
| 89 | Output: |
| 90 | X0: 0 on success, negative error code on failure |
| 91 | ``` |
| 92 | |
| 93 | --- |
| 94 | |
| 95 | ## 4. Qualification Gates for M6 |
| 96 | |
| 97 | 1. `OMEGA_SELF_HOST_GRAPH_PASS`: Semantic graph $G_C$ successfully constructed and validated. |
| 98 | 2. `OMEGA_SELF_HOST_C1_EMISSION_PASS`: $C_0(G_C) \to C_1$ emits valid AArch64 machine instructions. |
| 99 | 3. `OMEGA_SELF_HOST_DECODER_SEAM_PASS`: Independent decoder validates all $C_1$ instructions prior to execution. |
| 100 | 4. `OMEGA_SELF_HOST_C2_REPRODUCTION_PASS`: Executing $C_1(G_C) \to C_2$ succeeds and emits machine code. |
| 101 | 5. `OMEGA_SELF_HOST_C3_REPRODUCTION_PASS`: Executing $C_2(G_C) \to C_3$ succeeds and emits machine code. |
| 102 | 6. `OMEGA_SELF_HOST_FIXED_POINT_PASS`: Byte-for-byte identity $C_1 == C_2 == C_3$ verified. |
| 103 | 7. `OMEGA_SELF_HOST_REALIZATION_ID_PASS`: `REALIZATION_ID` matching across $C_1, C_2, C_3$. |
| 104 | 8. `OMEGA_SELF_HOST_M5_PARITY_PASS`: $C_1(G_S)$ compiles $F(a, b, c) = (a + b) - c$ to exact M5 bytes. |
| 105 | 9. `OMEGA_SELF_HOST_NATIVE_EXECUTION_PASS`: Output of $C_1(G_S)$ executes natively to 15. |
| 106 | 10. `OMEGA_SELF_HOST_ADVERSARIAL_MUTATION_PASS`: Single-bit mutation in $G_C$ or $C_1$ produces immediate refusal or mismatch. |