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/aien-architecture-mv/blob/main/docs/milestone-11-spec.md # aien-architecture-mv Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories. 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 `aien-architecture-mv / docs / milestone-11-spec.md` 215 lines · 12612 bytes Raw Blame History Rendered 1 # Specification: Milestone 11 — Omega Library Discovery (`OMEGA_LIBRARY_DISCOVERY`) 2 3 ```text 4 Document ID: SPEC-OMEGA-M11 5 Milestone: Milestone 11 (OMEGA_LIBRARY_DISCOVERY) 6 Classification: Sovereign Machine Canonical Specification 7 Target Substrate: Autonomous Abstraction Discovery from Program Corpus with Verified Reuse 8 Status: COMPLETE / RATIFIED (aien-spark/aien-architecture#23, aien-spark/omega#17) 9 Lineage: SILICON -> ATLAS (M1) -> PHYSICS (M2/M3) -> OMEGA (M4-M11) -> AIEN 10 ``` 11 12 --- 13 14 ## 1. Executive Summary & Core Invariants 15 16 Milestone 10 established the program library substrate (`OMEGA_LIBRARY_V1`), providing content-addressed component cataloging, typed contracts, dependency DAG tracking, and baseline synthesis primitive export. 17 Milestone 11 establishes autonomous abstraction discovery (`OMEGA_LIBRARY_DISCOVERY`): 18 19 > **RECURRING STRUCTURE IS DISCOVERED, NOT BESTOWED. EVERY ABSTRACTION MUST COMPRESS EVIDENCE, PRESERVE MEANING, AND SURVIVE VERIFICATION BEFORE ENTERING THE LIBRARY.** 20 21 The objective of Milestone 11 is autonomous abstraction discovery from a verified program corpus with verified reuse. The system does not rely on human programmers to invent reusable functions or subroutines. Instead, the discovery engine inspects synthesized and verified programs, identifies recurring computational sub-structures, abstracts them into parameterized library components, refactors the original programs, and deploys the new abstractions to solve harder held-out tasks at reduced search depth. 22 23 As mandated by canonical roadmap doctrine (`DOCTRINE-ROADMAP`), every discovered abstraction admitted under Milestone 11 must satisfy the **4 Core Invariants**: 24 1. **Compresses Multiple Verified Programs**: The abstraction replaces recurring sub-graphs across multiple verified programs in the corpus, achieving a strictly positive net description length / cost reduction ($\Delta \text{Cost} > 0$). 25 2. **Preserves Semantics Under Refactoring**: Substituting the discovered abstraction into corpus programs preserves exact input/output behavioral equivalence across all test cases. 26 3. **Is Reused on Held-Out Tasks**: The admitted abstraction is exported to the synthesis primitive bank and successfully leveraged to synthesize solutions for held-out tasks that were previously out-of-reach or computationally expensive. 27 4. **Reduces Search Cost and Depth**: Synthesis of held-out tasks using the augmented library demonstrates measurable reduction in search depth ($D' < D$) and candidate exploration count compared to baseline primitive search. 28 29 --- 30 31 ## 2. Discovery Engine Architecture 32 33 The Milestone 11 discovery pipeline consists of five sovereign phases: 34 35 ``` 36 +-------------------------------------------------------------------------------+ 37 | OMEGA_LIBRARY_DISCOVERY PIPELINE | 38 +-------------------------------------------------------------------------------+ 39 | 1. Corpus Ingestion : Load verified programs into OmegaCorpus | 40 | 2. Sub-Expression Mine : Mine recurring common sub-DAGs (frequency >= 2) | 41 | 3. Compression Scoring : Evaluate Delta Cost = sum(orig - refactored) - abst | 42 | 4. Verification Ladder : Candidate passes M7 V0 (struct), V1 (diff), V2 (prop)| 43 | 5. Library Admission : Insert into OmegaLibrary -> Export to Synthesis Bank | 44 +-------------------------------------------------------------------------------+ 45 ``` 46 47 ### 2.1 Corpus Representation (`OmegaCorpus`) 48 The discovery engine operates on an `OmegaCorpus`, an immutable collection of verified programs produced by Milestone 9 synthesis (`OMEGA_SYNTHESIS_V0`) or canonical demonstration tasks. Each corpus entry binds: 49 - The verified program graph ($G_S$) and instruction representation (`OmegaProgram`). 50 - Input/output specification test vectors and contracts. 51 - Provenance receipt hashes establishing Milestone 7 (`OMEGA_VERIFY`) verification passage. 52 53 ### 2.2 Sub-Expression Mining 54 The mining engine extracts candidate abstractions from the corpus: 55 - Traverses program expression DAGs to enumerate contiguous sub-DAGs and compositions. 56 - Computes structural canonical hashes to group isomorphic and behavioral-equivalent sub-expressions. 57 - Enforces non-triviality: rejects single base primitives, trivial identities, or sub-expressions that already exist in the primitive bank. 58 - Identifies candidates with frequency $\ge 2$ across distinct programs or distinct call sites. 59 60 ### 2.3 Evaluation & Minimum Description Length Metric 61 Candidate abstractions are ranked according to their net structural cost savings across the corpus. The objective metric is the description length / cost reduction: 62 63 $$\Delta \text{Cost} = \sum_{P \in \text{Corpus}} \left( \text{Cost}_{\text{orig}}(P) - \text{Cost}_{\text{refactored}}(P) \right) - \text{Cost}(\text{Abstraction})$$ 64 65 Where: 66 - $\text{Cost}_{\text{orig}}(P)$ is the instruction count and complexity cost of program $P$ before refactoring. 67 - $\text{Cost}_{\text{refactored}}(P)$ is the cost of $P$ when recurring sub-DAGs are replaced by a single call/primitive invocation of the candidate abstraction. 68 - $\text{Cost}(\text{Abstraction})$ is the intrinsic cost of declaring and storing the new abstraction in the library. 69 - Candidate promotion strictly requires $\Delta \text{Cost} > 0$. 70 71 ### 2.4 Semantic Preservation & Refactoring Engine 72 Refactoring replaces the identified sub-expression instances within corpus programs with invocations of the newly formed abstraction. The engine evaluates refactored programs against the original verification harness: 73 - Test-case equivalence: All original input/output vectors must yield bit-identical outputs. 74 - Invariant preservation: Contract preconditions and postconditions must remain satisfied. 75 - Fails closed on any behavioral divergence. 76 77 ### 2.5 Verification Ladder for Library Admission 78 Before a candidate abstraction can be admitted into `OmegaLibrary`, it must be elevated to a first-class `OmegaProgram` and strictly pass the complete Milestone 7 (`OMEGA_VERIFY`) verification ladder: 79 - **$V_0$ Structural Validation**: Rejects malformed DAGs, unbound register operands, type mismatch, and invalid opcodes. 80 - **$V_1$ Differential Testing**: Compares native AArch64 execution against canonical reference evaluation across dense test vectors. 81 - **$V_2$ Property Verification**: Formally checks invariant bounds, overflow behavior, and termination guarantees. 82 83 ### 2.6 Admission and Synthesis Acceleration 84 Upon passing $V_0-V_2$: 85 - The abstraction is assigned a canonical `SemanticId` and inserted into `OmegaLibrary` with dependency links. 86 - Library version is monotonically incremented, and the state digest is re-sealed. 87 - The updated library is exported to `SynthPrimitiveBank` via `omega_library_export_primitives()`. 88 - Subsequent synthesis runs on held-out tasks draw upon the discovered abstraction as a foundational primitive, finding solutions at reduced search depth ($D \le 2$ instead of $D \ge 4$). 89 90 --- 91 92 ## 3. Discovery Engine Data Model & Interfaces 93 94 ```c 95 #define OMEGA_CORPUS_MAX_PROGRAMS 64 96 #define OMEGA_MAX_CANDIDATES 128 97 #define OMEGA_MAX_OCCURRENCES 32 98 99 typedef struct { 100 OmegaProgram program; 101 uint8_t proof_receipt[32]; 102 size_t test_case_count; 103 uint64_t test_inputs[16]; 104 uint64_t test_expected[16]; 105 } OmegaCorpusEntry; 106 107 typedef struct { 108 size_t count; 109 OmegaCorpusEntry entries[OMEGA_CORPUS_MAX_PROGRAMS]; 110 uint8_t corpus_digest[32]; 111 } OmegaCorpus; 112 113 typedef struct { 114 size_t program_idx; 115 uint32_t start_op_idx; 116 uint32_t end_op_idx; 117 } SubExpressionOccurrence; 118 119 typedef struct { 120 SemanticId candidate_id; 121 char name[64]; 122 OmegaProgram abstraction_prog; 123 size_t occurrence_count; 124 SubExpressionOccurrence occurrences[OMEGA_MAX_OCCURRENCES]; 125 uint32_t abstraction_cost; 126 int32_t delta_cost; /* Net compression: sum(orig - refactored) - abstraction_cost */ 127 bool is_nontrivial; 128 bool semantics_preserved; 129 VerifyReport verify_report; 130 } OmegaCandidateAbstraction; 131 132 typedef struct { 133 uint32_t min_occurrences; /* Minimum corpus frequency (>= 2) */ 134 uint32_t min_nodes; /* Minimum sub-DAG node count (>= 2 for non-triviality) */ 135 int32_t min_delta_cost; /* Minimum net compression savings (> 0) */ 136 bool require_v2_verification; /* Mandatory V0-V2 gate passage */ 137 } DiscoveryConfig; 138 139 typedef struct { 140 size_t subgraphs_mined; 141 size_t candidates_evaluated; 142 size_t candidates_rejected_trivial; 143 size_t candidates_rejected_negative_gain; 144 size_t candidates_rejected_semantics; 145 size_t candidates_rejected_verify; 146 size_t abstractions_admitted; 147 } DiscoveryStats; 148 149 typedef struct { 150 bool discovery_succeeded; 151 OmegaCandidateAbstraction best_abstraction; 152 uint32_t library_version_before; 153 uint32_t library_version_after; 154 uint8_t new_state_digest[32]; 155 DiscoveryStats stats; 156 } DiscoveryResult; 157 158 typedef struct { 159 SynthesisTask held_out_task; 160 size_t baseline_candidates_explored; 161 uint32_t baseline_depth_required; 162 size_t accelerated_candidates_explored; 163 uint32_t accelerated_depth_required; 164 bool accelerated_solved; 165 } DiscoveryAccelerationReport; 166 167 /* Corpus Management */ 168 int omega_corpus_init(OmegaCorpus *corpus); 169 void omega_corpus_destroy(OmegaCorpus *corpus); 170 int omega_corpus_add(OmegaCorpus *corpus, const OmegaProgram *prog, const uint8_t receipt[32]); 171 int omega_corpus_compute_digest(OmegaCorpus *corpus); 172 173 /* Sub-Expression Mining & Evaluation */ 174 int omega_discovery_mine(const OmegaCorpus *corpus, const DiscoveryConfig *config, 175 OmegaCandidateAbstraction *out_candidates, size_t max_candidates, 176 size_t *out_count); 177 178 int omega_discovery_evaluate_compression(const OmegaCorpus *corpus, 179 OmegaCandidateAbstraction *candidate); 180 181 int omega_discovery_verify_semantics(const OmegaCorpus *corpus, 182 const OmegaCandidateAbstraction *candidate); 183 184 /* Verification & Library Admission */ 185 int omega_discovery_verify_candidate(OmegaCandidateAbstraction *candidate); 186 187 int omega_discovery_admit_abstraction(OmegaLibrary *lib, 188 const OmegaCandidateAbstraction *candidate, 189 uint8_t out_receipt_hash[32]); 190 191 /* End-to-End Discovery and Held-Out Validation */ 192 int omega_discovery_run(const OmegaCorpus *corpus, OmegaLibrary *lib, 193 const DiscoveryConfig *config, DiscoveryResult *result); 194 195 int omega_discovery_evaluate_heldout(const OmegaLibrary *lib, 196 const SynthesisTask *held_out_task, 197 DiscoveryAccelerationReport *report); 198 ``` 199 200 --- 201 202 ## 4. Qualification Gates for M11 203 204 Milestone 11 qualification requires 100% pass across 10 canonical gates: 205 206 1. `OMEGA_DISCOVERY_CORPUS_MINING_PASS`: Sub-expression mining traverses `OmegaCorpus` programs and identifies recurring sub-DAG patterns with frequency $\ge 2$. 207 2. `OMEGA_DISCOVERY_NONTRIVIAL_PASS`: Candidate abstraction is non-trivial (contains $\ge 2$ primitive operations; is not an identity, single constant, or already present in base primitives). 208 3. `OMEGA_DISCOVERY_COMPRESSION_PASS`: Description length / cost reduction metric evaluates strictly positive ($\Delta \text{Cost} > 0$), confirming measurable corpus compression. 209 4. `OMEGA_DISCOVERY_SEMANTIC_PRESERVATION_PASS`: Corpus programs refactored with the candidate abstraction preserve bit-exact input/output behavior across all test cases. 210 5. `OMEGA_DISCOVERY_V0_STRUCTURAL_PASS`: Candidate abstraction passes M7 $V_0$ structural validation (well-formed DAG, type correctness, register bounds). 211 6. `OMEGA_DISCOVERY_V1_DIFFERENTIAL_PASS`: Candidate abstraction passes M7 $V_1$ differential evaluation against native AArch64 execution. 212 7. `OMEGA_DISCOVERY_V2_PROPERTY_PASS`: Candidate abstraction passes M7 $V_2$ invariant and property checking. 213 8. `OMEGA_DISCOVERY_LIBRARY_ADMISSION_PASS`: Discovered abstraction is admitted into `OmegaLibrary`, increments version, seals state digest, and exports to `SynthPrimitiveBank`. 214 9. `OMEGA_DISCOVERY_SEARCH_ACCELERATION_PASS`: Synthesis on a held-out task using the updated primitive bank finds a verified solution at reduced search depth ($D' < D$) and candidate count. 215 10. `OMEGA_DISCOVERY_RECEIPT_PASS`: Master qualification runner produces an immutable cryptographic receipt recording corpus hash, abstraction ID, compression metric, verification proofs, and search acceleration evidence.