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-sovereign-core-mv/blob/main/crates/crumbs/src/gen/registry.rs # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. 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-sovereign-core-mv / crates / crumbs / src / gen / registry.rs` 723 lines ยท 17762 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 //! The v1 family registry: 38 mechanisms parameterized into 100+ registered 17 //! family ids, plus the capability pool the breadcrumb trail is built from. 18 //! 19 //! Family ids are assigned in registration order and are part of every 20 //! GeneratorInstanceDigest; the order below is frozen for registry v1. 21 22 use super::mechanisms::Mechanism; 23 use super::rng::Rng; 24 use super::{random_chain, FamilySpec, Params, Vocab}; 25 use crate::canon::Enc; 26 use crate::digest::{digest, Domain}; 27 use crate::program::Program; 28 use crate::provenance::Provenance; 29 use crate::sealed::{AdversarialClass, CapabilityId, DecoyStatus, Rung, SourceFamily}; 30 use crate::visible::Encoding; 31 use std::collections::HashSet; 32 use std::sync::OnceLock; 33 34 pub const REGISTRY_VERSION: &str = "crumbs-registry/1.0.0"; 35 pub const CAPABILITY_POOL_SIZE: usize = 12; 36 37 /// A hidden capability: a short transformation that later crumbs quietly require. 38 #[derive(Clone, Debug)] 39 pub struct Capability { 40 pub index: u16, 41 pub id: CapabilityId, 42 pub program: Program, 43 } 44 45 /// Twelve distinct two-step capabilities drawn deterministically from the 46 /// Basic vocabulary. Deliberately not tuned to any learner. 47 pub fn capability_pool() -> &'static [Capability] { 48 static POOL: OnceLock> = OnceLock::new(); 49 POOL.get_or_init(|| { 50 let mut rng = Rng::named("capability-pool", &[1]); 51 let mut out = Vec::new(); 52 let mut seen = HashSet::new(); 53 while out.len() < CAPABILITY_POOL_SIZE { 54 let p = random_chain(&mut rng, Vocab::Basic, 2); 55 if !seen.insert(p.behavior()) { 56 continue; 57 } 58 let mut e = Enc::new(); 59 e.str(REGISTRY_VERSION).blob(&p.to_bytes()); 60 out.push(Capability { 61 index: out.len() as u16, 62 id: digest(Domain::Capability, &e.finish()), 63 program: p, 64 }); 65 } 66 out 67 }) 68 } 69 70 pub struct Registry { 71 pub families: Vec, 72 } 73 74 impl Registry { 75 pub fn get(&self, id: u32) -> Option<&FamilySpec> { 76 self.families.iter().find(|f| f.id == id) 77 } 78 pub fn by_key(&self, key: &str) -> Option<&FamilySpec> { 79 self.families.iter().find(|f| f.key == key) 80 } 81 } 82 83 /// Capability pairs used by composition families (ordered: first applied first). 84 pub const COMPOSITION_PAIRS: [(u16, u16); 24] = [ 85 (0, 1), 86 (1, 2), 87 (2, 3), 88 (3, 4), 89 (4, 5), 90 (5, 6), 91 (6, 7), 92 (7, 8), 93 (8, 9), 94 (9, 10), 95 (10, 11), 96 (11, 0), 97 (0, 2), 98 (1, 3), 99 (2, 4), 100 (3, 5), 101 (4, 6), 102 (5, 7), 103 (6, 8), 104 (7, 9), 105 (8, 10), 106 (9, 11), 107 (10, 0), 108 (11, 1), 109 ]; 110 pub const COMPOSITION_TRIPLES: [(u16, u16, u16); 8] = [ 111 (0, 1, 2), 112 (3, 4, 5), 113 (6, 7, 8), 114 (9, 10, 11), 115 (0, 3, 6), 116 (1, 4, 7), 117 (2, 5, 8), 118 (9, 0, 4), 119 ]; 120 121 pub fn registry() -> &'static Registry { 122 static REG: OnceLock = OnceLock::new(); 123 REG.get_or_init(build) 124 } 125 126 struct B { 127 fams: Vec, 128 } 129 130 impl B { 131 #[allow(clippy::too_many_arguments)] 132 fn add( 133 &mut self, 134 key: String, 135 mechanism: Mechanism, 136 params: Params, 137 rung: Rung, 138 source: SourceFamily, 139 provenance: Provenance, 140 decoy: DecoyStatus, 141 difficulty: u16, 142 topic: &'static str, 143 ) { 144 let id = self.fams.len() as u32 + 1; 145 self.fams.push(FamilySpec { 146 id, 147 key, 148 mechanism, 149 params, 150 rung, 151 source_family: source, 152 provenance, 153 decoy, 154 difficulty, 155 topic, 156 }); 157 } 158 } 159 160 fn p(width: u8, len: u8) -> Params { 161 Params::new(width, len) 162 } 163 164 fn build() -> Registry { 165 use Mechanism as M; 166 use SourceFamily as S; 167 let syn = Provenance::synthetic(); 168 let adv = Provenance::adversarial(); 169 let hum = Provenance::human_theory(); 170 let clean = DecoyStatus::Clean; 171 let mut b = B { fams: Vec::new() }; 172 173 // Single and chained transformations across widths and vocabularies. 174 for (len, rung) in [ 175 (1u8, Rung::SingleTransformation), 176 (2, Rung::TwoTransformations), 177 (3, Rung::MultiStepAlgorithm), 178 (4, Rung::Composition), 179 ] { 180 for width in [8u8, 16, 32] { 181 b.add( 182 format!("chain-basic-l{len}-w{width}"), 183 M::OpChain, 184 p(width, len), 185 rung, 186 S::Capability, 187 syn, 188 clean, 189 len as u16 * 10, 190 "wrapping arithmetic chain", 191 ); 192 } 193 } 194 for (len, rung) in [ 195 (1u8, Rung::SingleTransformation), 196 (2, Rung::TwoTransformations), 197 (3, Rung::MultiStepAlgorithm), 198 ] { 199 let mut prm = p(32, len); 200 prm.vocab = Vocab::Extended; 201 b.add( 202 format!("chain-ext-l{len}-w32"), 203 M::OpChain, 204 prm.clone(), 205 rung, 206 S::Capability, 207 syn, 208 clean, 209 15 + len as u16 * 10, 210 "bitwise chain", 211 ); 212 prm.encoding = Encoding::RawLe; 213 b.add( 214 format!("chain-ext-l{len}-w32-raw"), 215 M::OpChain, 216 prm, 217 rung, 218 S::Capability, 219 syn, 220 clean, 221 15 + len as u16 * 10, 222 "bitwise chain, raw bytes", 223 ); 224 } 225 for k in [2u8, 3, 4] { 226 b.add( 227 format!("repeat-k{k}"), 228 M::Repeat, 229 p(16, k), 230 Rung::RepeatedTransformation, 231 S::Capability, 232 syn, 233 clean, 234 20 + k as u16 * 5, 235 "repeated transformation", 236 ); 237 } 238 for w in [8u8, 16] { 239 b.add( 240 format!("wrap-w{w}"), 241 M::WrapBoundary, 242 p(w, 2), 243 Rung::Modularity, 244 S::Capability, 245 syn, 246 clean, 247 30, 248 "wrap at lane width", 249 ); 250 } 251 b.add( 252 "threshold-w12".into(), 253 M::Threshold, 254 p(12, 1), 255 Rung::ConditionalTransformation, 256 S::Capability, 257 syn, 258 clean, 259 35, 260 "piecewise rule", 261 ); 262 b.add( 263 "threshold-w16".into(), 264 M::Threshold, 265 p(16, 1), 266 Rung::ConditionalTransformation, 267 S::Capability, 268 syn, 269 clean, 270 40, 271 "piecewise rule", 272 ); 273 for k in [1u64, 4] { 274 let mut prm = p(16, 1); 275 prm.k = k; 276 b.add( 277 format!("parity-branch-k{k}"), 278 M::ParityBranch, 279 prm, 280 Rung::ConditionalTransformation, 281 S::Capability, 282 syn, 283 clean, 284 35, 285 "residue-class branch", 286 ); 287 } 288 for a in [2u8, 3, 4] { 289 b.add( 290 format!("multi-linear-a{a}"), 291 M::MultiLinear, 292 p(12, a), 293 Rung::MultiInputRelation, 294 S::Capability, 295 syn, 296 clean, 297 30 + a as u16 * 5, 298 "weighted lane sum", 299 ); 300 } 301 b.add( 302 "abs-difference".into(), 303 M::AbsDifference, 304 p(16, 2), 305 Rung::MultiInputRelation, 306 S::Capability, 307 syn, 308 clean, 309 30, 310 "lane distance", 311 ); 312 for a in [2u8, 3] { 313 b.add( 314 format!("symmetric-lanes-a{a}"), 315 M::SymmetricLanes, 316 p(10, a), 317 Rung::Invariance, 318 S::Capability, 319 syn, 320 clean, 321 45, 322 "permutation-invariant lanes", 323 ); 324 } 325 b.add( 326 "theory-family".into(), 327 M::TheoryFamily, 328 p(12, 2), 329 Rung::TheoryFormation, 330 S::Capability, 331 syn, 332 clean, 333 55, 334 "one law, many parameters", 335 ); 336 b.add( 337 "euclid".into(), 338 M::Euclid, 339 p(16, 2), 340 Rung::MultiStepAlgorithm, 341 S::Capability, 342 hum, 343 clean, 344 60, 345 "greatest common divisor", 346 ); 347 b.add( 348 "recurrence-1".into(), 349 M::Recurrence1, 350 p(8, 1), 351 Rung::Recurrence, 352 S::Capability, 353 syn, 354 clean, 355 45, 356 "first-order recurrence", 357 ); 358 b.add( 359 "recurrence-2".into(), 360 M::Recurrence2, 361 p(8, 2), 362 Rung::Recurrence, 363 S::Capability, 364 syn, 365 clean, 366 55, 367 "second-order recurrence", 368 ); 369 b.add( 370 "poly-sequence".into(), 371 M::PolySequence, 372 p(8, 2), 373 Rung::Recurrence, 374 S::Capability, 375 syn, 376 clean, 377 45, 378 "quadratic sequence", 379 ); 380 for (s, w) in [(2u8, 8u8), (3, 12), (4, 16)] { 381 b.add( 382 format!("bit-automaton-s{s}-w{w}"), 383 M::BitAutomaton, 384 p(w, s), 385 Rung::State, 386 S::Capability, 387 syn, 388 clean, 389 50 + s as u16 * 5, 390 "finite automaton over bits", 391 ); 392 } 393 for a in [3u8, 5] { 394 b.add( 395 format!("lane-fold-a{a}"), 396 M::LaneFold, 397 p(8, a), 398 Rung::State, 399 S::Capability, 400 syn, 401 clean, 402 50, 403 "running fold over lanes", 404 ); 405 } 406 for w in [16u8, 32] { 407 b.add( 408 format!("byte-reverse-w{w}"), 409 M::ByteReverse, 410 p(w, 1), 411 Rung::Symmetry, 412 S::Capability, 413 syn, 414 clean, 415 45, 416 "byte order reversal", 417 ); 418 } 419 for w in [8u8, 16] { 420 b.add( 421 format!("bit-mirror-w{w}"), 422 M::BitMirror, 423 p(w, 1), 424 Rung::Symmetry, 425 S::Capability, 426 syn, 427 clean, 428 45, 429 "bit order reversal", 430 ); 431 } 432 b.add( 433 "nibble-permute".into(), 434 M::NibblePermute, 435 p(16, 1), 436 Rung::Symmetry, 437 S::Capability, 438 syn, 439 clean, 440 50, 441 "fixed nibble permutation", 442 ); 443 for w in [16u8, 32] { 444 b.add( 445 format!("pop-count-w{w}"), 446 M::PopCount, 447 p(w, 1), 448 Rung::MultiStepAlgorithm, 449 S::Capability, 450 syn, 451 clean, 452 45, 453 "set-bit count", 454 ); 455 } 456 for w in [12u8, 24] { 457 b.add( 458 format!("mod-residue-w{w}"), 459 M::ModResidue, 460 p(w, 1), 461 Rung::Modularity, 462 S::Capability, 463 syn, 464 clean, 465 45, 466 "residue", 467 ); 468 b.add( 469 format!("mod-affine-w{w}"), 470 M::ModAffine, 471 p(w, 3), 472 Rung::Modularity, 473 S::Capability, 474 syn, 475 clean, 476 40, 477 "affine map with wrap", 478 ); 479 } 480 for v in [4u8, 5] { 481 b.add( 482 format!("graph-components-v{v}"), 483 M::GraphComponents, 484 p(8, v), 485 Rung::MultiStepAlgorithm, 486 S::Capability, 487 hum, 488 clean, 489 65, 490 "connected components of an edge mask", 491 ); 492 } 493 for n in [12u8, 16] { 494 let mut prm = p(8, n); 495 prm.visible = 6; 496 b.add( 497 format!("hidden-graph-reach-n{n}"), 498 M::HiddenGraphReach, 499 prm, 500 Rung::LatentVariables, 501 S::Capability, 502 syn, 503 clean, 504 60, 505 "reachability in a hidden graph", 506 ); 507 } 508 b.add( 509 "digit-sum".into(), 510 M::DigitSum, 511 p(20, 1), 512 Rung::MultiStepAlgorithm, 513 S::Capability, 514 hum, 515 clean, 516 50, 517 "base-ten digit sum", 518 ); 519 for w in [16u8, 32] { 520 b.add( 521 format!("latent-offset-w{w}"), 522 M::LatentOffset, 523 p(w, 2), 524 Rung::LatentVariables, 525 S::Capability, 526 syn, 527 clean, 528 40, 529 "hidden constant offset", 530 ); 531 } 532 b.add( 533 "latent-xor-w16".into(), 534 M::LatentXorMask, 535 p(16, 2), 536 Rung::LatentVariables, 537 S::Capability, 538 syn, 539 clean, 540 45, 541 "hidden xor key", 542 ); 543 for w in [16u8, 32] { 544 b.add( 545 format!("partial-observation-w{w}"), 546 M::PartialObservation, 547 p(w, 2), 548 Rung::PartialObservation, 549 S::Capability, 550 syn, 551 clean, 552 45, 553 "only low bits observed", 554 ); 555 } 556 b.add( 557 "counterexample-sensitive".into(), 558 M::CounterexampleSensitive, 559 p(12, 2), 560 Rung::CounterexampleSearch, 561 S::Capability, 562 syn, 563 clean, 564 60, 565 "rule with a sparse exception class", 566 ); 567 568 // Rabbit holes (population: rabbit hole), classes A to E and G. 569 let rh = |c| DecoyStatus::RabbitHole(c); 570 for w in [12u8, 16] { 571 b.add( 572 format!("decoy-simple-rule-w{w}"), 573 M::DecoySimpleRule, 574 p(w, 3), 575 Rung::CounterexampleSearch, 576 S::RabbitHole, 577 adv, 578 rh(AdversarialClass::SimpleWrongRule), 579 55, 580 "masked affine shown only below the mask", 581 ); 582 b.add( 583 format!("multi-fit-w{w}"), 584 M::MultiFit, 585 p(w, 2), 586 Rung::CounterexampleSearch, 587 S::RabbitHole, 588 adv, 589 rh(AdversarialClass::MultiFit), 590 55, 591 "two chains agree on the shown inputs", 592 ); 593 } 594 b.add( 595 "spurious-field".into(), 596 M::SpuriousField, 597 p(48, 2), 598 Rung::PartialObservation, 599 S::RabbitHole, 600 adv, 601 rh(AdversarialClass::SpuriousDimension), 602 60, 603 "high field copies the answer when shown", 604 ); 605 for k in [6u8, 8] { 606 let mut prm = p(8, 2); 607 prm.visible = k; 608 b.add( 609 format!("prefix-diverges-k{k}"), 610 M::PrefixDiverges, 611 prm, 612 Rung::Recurrence, 613 S::RabbitHole, 614 adv, 615 rh(AdversarialClass::PrefixDiverges), 616 60, 617 "prefix imitates a simple rule", 618 ); 619 } 620 b.add( 621 "elegant-arbitrary".into(), 622 M::ElegantArbitrary, 623 p(8, 2), 624 Rung::TheoryFormation, 625 S::RabbitHole, 626 adv, 627 rh(AdversarialClass::ElegantArbitrary), 628 60, 629 "arbitrary table with a neat prefix", 630 ); 631 for len in [2u8, 3] { 632 let mut prm = p(16, len); 633 prm.visible = 12; 634 b.add( 635 format!("noisy-chain-l{len}"), 636 M::NoisyChain, 637 prm, 638 Rung::NoisyObservation, 639 S::RabbitHole, 640 adv, 641 rh(AdversarialClass::Noisy), 642 55, 643 "noisy visible outputs", 644 ); 645 } 646 647 // Ambiguous / insufficient evidence (class F) and no structure. 648 for n in [2u8, 3] { 649 let mut prm = p(16, 2); 650 prm.visible = n; 651 b.add( 652 format!("insufficient-evidence-n{n}"), 653 M::InsufficientEvidence, 654 prm, 655 Rung::CounterexampleSearch, 656 S::Ambiguous, 657 adv, 658 rh(AdversarialClass::InsufficientEvidence), 659 50, 660 "too few observations", 661 ); 662 } 663 b.add( 664 "no-structure".into(), 665 M::NoStructure, 666 p(8, 1), 667 Rung::TheoryFormation, 668 S::Ambiguous, 669 syn, 670 DecoyStatus::NoStructure, 671 50, 672 "random table", 673 ); 674 675 // The breadcrumb trail: capability primitives and their compositions. 676 for c in 0..CAPABILITY_POOL_SIZE as u16 { 677 let mut prm = p(16, 2); 678 prm.caps = vec![c]; 679 b.add( 680 format!("capability-{c:02}"), 681 M::CapabilityPrimitive, 682 prm, 683 Rung::TwoTransformations, 684 S::Capability, 685 syn, 686 clean, 687 20, 688 "hidden capability", 689 ); 690 } 691 for (a, c) in COMPOSITION_PAIRS { 692 let mut prm = p(16, 4); 693 prm.caps = vec![a, c]; 694 b.add( 695 format!("compose-{a:02}-{c:02}"), 696 M::CapabilityComposition, 697 prm, 698 Rung::Composition, 699 S::Composition, 700 syn, 701 clean, 702 60, 703 "composition of two capabilities", 704 ); 705 } 706 for (a, c, d) in COMPOSITION_TRIPLES { 707 let mut prm = p(16, 6); 708 prm.caps = vec![a, c, d]; 709 b.add( 710 format!("compose-{a:02}-{c:02}-{d:02}"), 711 M::CapabilityComposition, 712 prm, 713 Rung::Composition, 714 S::Composition, 715 syn, 716 clean, 717 80, 718 "composition of three capabilities", 719 ); 720 } 721 722 Registry { families: b.fams } 723 }