From 4a3ac34b1359c05588905ba8f929b08c03ffd025 Mon Sep 17 00:00:00 2001 From: perplexity-mcp Date: Sat, 2 May 2026 09:31:22 +0000 Subject: [PATCH] =?UTF-8?q?feat(ring-sr-alg-00):=20GOLD=20II=20arena-types?= =?UTF-8?q?=20=C2=B7=20closes=20#450?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds trios-algorithm-arena/SR-ALG-00 — dependency-free typed metadata for one algorithm submitted to the IGLA arena. Bottom of the GOLD II dependency graph; SR-ALG-01..03 + BR-OUTPUT all import their wire format from here. ## Critical: no Python in crates/ AlgorithmSpec::entry_path points OUTSIDE crates/ (typically into parameter-golf/records/...). Real Python spawn is the job of SR-02 trainer-runner — NEVER this crate. R-L6-PURE-007. ## Public surface - AlgorithmId(Uuid) v4 newtype - EntryHash([u8; 32]) SHA-256, lowercase-hex JSON (length 64) - GoldenState([u8; 32]) SHA-256, optional in spec - EnvVar(String) / EnvValue(String) - AlgorithmSpec { algorithm_id, name, entry_path: PathBuf, entry_hash, env: Vec<(EnvVar, EnvValue)>, golden_state_hash: Option<...>, theorem: Option, // e.g. 'Coq.Reals Theorem 3.1 SAC-1' } - AlgorithmSpec::new(name, path, hash) cheap constructor - AlgorithmSpec::verify_hash(actual: &[u8; 32]) -> bool ## Tests (12/12 GREEN) - algorithm_id_unique_per_instance - entry_hash_32_bytes_serialises_as_hex64 - entry_hash_rejects_wrong_length 31-byte hex string fails - golden_state_serialises_as_hex64 - env_empty_vec_valid - entry_path_from_str_round_trips - theorem_optional absent field omitted from JSON - golden_state_hash_optional same - verify_hash_correct - verify_hash_wrong_fails - serde_roundtrip_full_spec every field roundtrips - schema_field_names_stable JSON keys frozen for downstream ## Compliance - L1 ✓ no .sh - L3 ✓ clippy clean - L4 ✓ tests before merge - L6 ✓ no I/O, no async - L13 ✓ I-SCOPE: only crates/trios-algorithm-arena/ - L14 ✓ Agent: trailer - R-RING-DEP-002 ✓ deps = serde + uuid + hex (+ serde_json dev) - R-RING-FACADE-001 ✓ outer src/lib.rs is re-exports only - R-L6-PURE-007 ✓ no .py in this crate; entry_path is a *reference* - I5 ✓ ring has README.md, TASK.md, AGENTS.md, RING.md, Cargo.toml, src/lib.rs 🌻 phi^2 + phi^-2 = 3 · TRINITY · GOLD II bottom Soul-name: Arena Architect Closes #450 Part of #446 Agent: Arena-Architect --- Cargo.toml | 1 + crates/trios-algorithm-arena/Cargo.lock | 519 ++++++++++++++++++ crates/trios-algorithm-arena/Cargo.toml | 29 + crates/trios-algorithm-arena/RING.md | 70 +++ .../rings/SR-ALG-00/AGENTS.md | 49 ++ .../rings/SR-ALG-00/Cargo.toml | 16 + .../rings/SR-ALG-00/README.md | 73 +++ .../rings/SR-ALG-00/RING.md | 52 ++ .../rings/SR-ALG-00/TASK.md | 34 ++ .../rings/SR-ALG-00/src/lib.rs | 422 ++++++++++++++ crates/trios-algorithm-arena/src/lib.rs | 10 + 11 files changed, 1275 insertions(+) create mode 100644 crates/trios-algorithm-arena/Cargo.lock create mode 100644 crates/trios-algorithm-arena/Cargo.toml create mode 100644 crates/trios-algorithm-arena/RING.md create mode 100644 crates/trios-algorithm-arena/rings/SR-ALG-00/AGENTS.md create mode 100644 crates/trios-algorithm-arena/rings/SR-ALG-00/Cargo.toml create mode 100644 crates/trios-algorithm-arena/rings/SR-ALG-00/README.md create mode 100644 crates/trios-algorithm-arena/rings/SR-ALG-00/RING.md create mode 100644 crates/trios-algorithm-arena/rings/SR-ALG-00/TASK.md create mode 100644 crates/trios-algorithm-arena/rings/SR-ALG-00/src/lib.rs create mode 100644 crates/trios-algorithm-arena/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index b389ea5bea..f66521b719 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,6 +74,7 @@ exclude = [ "crates/trios-a2a", "crates/trios-igla-race-hack", "crates/trios-igla-race-pipeline", + "crates/trios-algorithm-arena", ] resolver = "2" diff --git a/crates/trios-algorithm-arena/Cargo.lock b/crates/trios-algorithm-arena/Cargo.lock new file mode 100644 index 0000000000..25a1135576 --- /dev/null +++ b/crates/trios-algorithm-arena/Cargo.lock @@ -0,0 +1,519 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "bitflags" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", + "wasip3", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown 0.17.0", + "serde", + "serde_core", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "js-sys" +version = "0.3.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1840c94c045fbcf8ba2812c95db44499f7c64910a912551aaaa541decebcacf" +dependencies = [ + "cfg-if", + "futures-util", + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libc" +version = "0.2.186" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "trios-algorithm-arena" +version = "0.1.0" +dependencies = [ + "trios-algorithm-arena-sr-alg-00", +] + +[[package]] +name = "trios-algorithm-arena-sr-alg-00" +version = "0.1.0" +dependencies = [ + "hex", + "serde", + "serde_json", + "uuid", +] + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "uuid" +version = "1.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76" +dependencies = [ + "getrandom", + "js-sys", + "serde_core", + "wasm-bindgen", +] + +[[package]] +name = "wasip2" +version = "1.0.3+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" +dependencies = [ + "wit-bindgen 0.57.1", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen 0.51.0", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df52b6d9b87e0c74c9edfa1eb2d9bf85e5d63515474513aa50fa181b3c4f5db1" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b1041f495fb322e64aca85f5756b2172e35cd459376e67f2a6c9dffcedb103" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dcd0ff20416988a18ac686d4d4d0f6aae9ebf08a389ff5d29012b05af2a1b41" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49757b3c82ebf16c57d69365a142940b384176c24df52a087fb748e2085359ea" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/crates/trios-algorithm-arena/Cargo.toml b/crates/trios-algorithm-arena/Cargo.toml new file mode 100644 index 0000000000..bec8c45941 --- /dev/null +++ b/crates/trios-algorithm-arena/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "trios-algorithm-arena" +version.workspace = true +edition.workspace = true +authors.workspace = true +license.workspace = true +description = "TRIOS ALGORITHM ARENA — GOLD II crate (algorithm spec metadata)" +publish = false + +[workspace] +members = [ + "rings/SR-ALG-00", +] + +[workspace.package] +version = "0.1.0" +edition = "2021" +authors = ["Dmitrii Vasilev"] +license = "MIT" +repository = "https://github.com/gHashTag/trios" + +[dependencies] +trios-algorithm-arena-sr-alg-00 = { path = "rings/SR-ALG-00" } + +[workspace.dependencies] +serde = { version = "1", features = ["derive"] } +serde_json = "1" +uuid = { version = "1", features = ["v4", "serde"] } +hex = "0.4" diff --git a/crates/trios-algorithm-arena/RING.md b/crates/trios-algorithm-arena/RING.md new file mode 100644 index 0000000000..5f5362da4b --- /dev/null +++ b/crates/trios-algorithm-arena/RING.md @@ -0,0 +1,70 @@ +# RING — trios-algorithm-arena (Gold Crate, GOLD II) + +## Identity + +| Field | Value | +|----------|-------| +| Metal | 🥇 Gold | +| Type | Crate (nested workspace) | +| Position | GOLD II — algorithm arena (algorithm-vs-pipeline registry) | +| Sealed | No | + +## Purpose + +The canonical metadata layer for *individual algorithms* competing in +the IGLA race. While GOLD I (`trios-igla-race-pipeline`) owns the +**pipeline** primitives (BPB writer, scarabs, queues, gardener), GOLD +II owns the **algorithm spec** primitives — the manifest that pins +which Python entry point runs, which environment variables it expects, +which golden state it should converge to, and which Coq theorem (if +any) backs it. + +## Why GOLD II is independent of GOLD I + +- GOLD I = "how the fleet runs" (queues, BPB, ASHA, deploy) +- GOLD II = "what the fleet runs" (entry path, hash, env, theorem) + +Separating the two means SR-ALG-00..03 + BR-OUTPUT (this crate) and +SR-00..05 + BR-OUTPUT (GOLD I) can ship independently and merge in +parallel. + +## Ring Structure (L-ARCH-001) + +``` +crates/trios-algorithm-arena/ +├── src/lib.rs ← re-export facade (≤ 50 LoC) +├── Cargo.toml ← outer GOLD, nested workspace +├── RING.md ← this file +└── rings/ + └── SR-ALG-00/ ← arena-types (day 1) + ├── README.md + ├── TASK.md + ├── AGENTS.md + ├── RING.md + ├── Cargo.toml + └── src/lib.rs +``` + +Future rings: SR-ALG-01 jepa, SR-ALG-02 universal-transformer, +SR-ALG-03 e2e-ttt (★ P0 — beat parameter-golf #1837), BR-OUTPUT +AlgorithmArena assembler. + +## Critical constraint — no Python in `crates/` + +`AlgorithmSpec::entry_path` points *out* of `crates/` (typically into +`parameter-golf/records/...`). Real Python spawn is the job of SR-02 +trainer-runner — not this crate. R-L6-PURE-007 forbids `.py` files +inside any Rust crate. + +## Laws + +- L1 — no `.sh` +- L3 — clippy clean +- L4 — tests before merge +- L13 — I-SCOPE: only this crate +- L14 — `Agent: ` trailer +- R-RING-FACADE-001 — `src/lib.rs` re-exports only + +## Anchor + +`φ² + φ⁻² = 3` · TRINITY · GOLD II diff --git a/crates/trios-algorithm-arena/rings/SR-ALG-00/AGENTS.md b/crates/trios-algorithm-arena/rings/SR-ALG-00/AGENTS.md new file mode 100644 index 0000000000..3790a893d9 --- /dev/null +++ b/crates/trios-algorithm-arena/rings/SR-ALG-00/AGENTS.md @@ -0,0 +1,49 @@ +# AGENTS.md — SR-ALG-00 (trios-algorithm-arena) + +> AAIF-compliant | MCP-compatible + +## Identity + +- Ring: SR-ALG-00 +- Package: `trios-algorithm-arena-sr-alg-00` +- Role: AlgorithmSpec metadata (bottom of GOLD II dependency graph) +- Soul-name: `Arena Architect` +- Codename: `LEAD` + +## What this ring does + +Defines `AlgorithmId`, `EntryHash`, `GoldenState`, `EnvVar`, `EnvValue`, `AlgorithmSpec`. No logic. No I/O. Pure data + serde. + +## Rules (ABSOLUTE) + +- R1 — pure Rust +- L6 — no async, no I/O, no subprocess, no network +- L13 — I-SCOPE: only this ring +- R-RING-DEP-002 — deps = `serde + uuid + hex` (+ `serde_json` dev) +- R-RING-FACADE-001 — outer crate `src/lib.rs` re-exports only +- **R-L6-PURE-007** — NO `.py` files in this crate. `entry_path` is a *reference* into `parameter-golf/records/...`. Real Python spawn is SR-02 trainer-runner's job. + +## You MAY + +- ✅ Add new optional fields to `AlgorithmSpec` (with stable JSON keys) +- ✅ Add new `Display` / `From` impls +- ✅ Add tests, especially property tests on hex roundtrip + +## You MAY NOT + +- ❌ Add a Python file to this crate +- ❌ Add tokio / sqlx / reqwest +- ❌ Change wire format JSON keys without auditing every consumer ring +- ❌ Drop the 32-byte-length guard in `EntryHash` / `GoldenState` + +## Build + +```bash +cargo build -p trios-algorithm-arena-sr-alg-00 +cargo clippy -p trios-algorithm-arena-sr-alg-00 --all-targets -- -D warnings +cargo test -p trios-algorithm-arena-sr-alg-00 +``` + +## Anchor + +`φ² + φ⁻² = 3` diff --git a/crates/trios-algorithm-arena/rings/SR-ALG-00/Cargo.toml b/crates/trios-algorithm-arena/rings/SR-ALG-00/Cargo.toml new file mode 100644 index 0000000000..86d838bc7c --- /dev/null +++ b/crates/trios-algorithm-arena/rings/SR-ALG-00/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "trios-algorithm-arena-sr-alg-00" +version.workspace = true +edition.workspace = true +authors.workspace = true +license.workspace = true +description = "SR-ALG-00 — arena-types: AlgorithmSpec metadata (entry_path, entry_hash, env, golden_state_hash, theorem)" +publish = false + +[dependencies] +serde = { workspace = true } +uuid = { workspace = true } +hex = { workspace = true } + +[dev-dependencies] +serde_json = { workspace = true } diff --git a/crates/trios-algorithm-arena/rings/SR-ALG-00/README.md b/crates/trios-algorithm-arena/rings/SR-ALG-00/README.md new file mode 100644 index 0000000000..5f09e5214c --- /dev/null +++ b/crates/trios-algorithm-arena/rings/SR-ALG-00/README.md @@ -0,0 +1,73 @@ +# SR-ALG-00 — Arena Types (algorithm-spec metadata) + +**Soul-name:** `Arena Architect` · **Codename:** `LEAD` · **Tier:** 🥉 Bronze · **Kingdom:** Rust + +> Closes #450 · Part of #446 · Anchor: `φ² + φ⁻² = 3` + +## What this ring does + +Dependency-free typed metadata for one algorithm submitted to the +TRIOS IGLA arena. SR-ALG-00 is the **bottom of the GOLD II graph** — +SR-ALG-01..03 + BR-OUTPUT all import their wire format from here. + +## Public types + +| Type | Wire-format role | +|---|---| +| `AlgorithmId` | UUID v4 newtype | +| `EntryHash([u8; 32])` | SHA-256 of the entry script (lowercase hex JSON) | +| `EnvVar(String)`, `EnvValue(String)` | env-pair newtypes | +| `GoldenState([u8; 32])` | SHA-256 of the convergence checkpoint (optional) | +| `AlgorithmSpec` | full manifest (id, name, entry_path, entry_hash, env, golden_state_hash?, theorem?) | +| `AlgorithmSpec::new(name, path, hash)` | cheap constructor | +| `AlgorithmSpec::verify_hash(actual)` | bool | + +## Critical: no Python in `crates/` + +`AlgorithmSpec::entry_path` MUST point *outside* `crates/` (typically +into `parameter-golf/records/...`). Real Python spawn is the job of +SR-02 trainer-runner — never this crate. R-L6-PURE-007. + +## Dependencies + +- `serde` (derive) +- `uuid` (`v4`, `serde`) +- `hex` — lowercase hex serialisation for 32-byte hashes +- `serde_json` (dev only) + +No `tokio`, no `sqlx`, no `reqwest`. R-RING-DEP-002. + +## Tests (12/12 GREEN) + +| Test | Asserts | +|---|---| +| `algorithm_id_unique_per_instance` | newtype freshness | +| `entry_hash_32_bytes_serialises_as_hex64` | 32 bytes → 64 hex chars | +| `entry_hash_rejects_wrong_length` | 31-byte hex string fails to deserialise | +| `golden_state_serialises_as_hex64` | round-trip | +| `env_empty_vec_valid` | empty env compiles + roundtrips | +| `entry_path_from_str_round_trips` | `PathBuf` parity | +| `theorem_optional` | absent field omitted from JSON | +| `golden_state_hash_optional` | absent field omitted from JSON | +| `verify_hash_correct` | match path | +| `verify_hash_wrong_fails` | mismatch path | +| `serde_roundtrip_full_spec` | every field roundtrips | +| `schema_field_names_stable` | JSON keys frozen for downstream rings | + +## Build & test + +```bash +cargo build -p trios-algorithm-arena-sr-alg-00 +cargo clippy -p trios-algorithm-arena-sr-alg-00 --all-targets -- -D warnings +cargo test -p trios-algorithm-arena-sr-alg-00 +``` + +## Laws + +- L1 ✓ no `.sh` +- L3 ✓ clippy clean +- L6 ✓ no I/O, no async +- L13 ✓ I-SCOPE: this ring only +- L14 ✓ `Agent: Arena-Architect` trailer +- R-RING-DEP-002 ✓ deps = `serde + uuid + hex` (+ `serde_json` dev) +- R-L6-PURE-007 ✓ no `.py` in this crate; entry_path is a *reference* diff --git a/crates/trios-algorithm-arena/rings/SR-ALG-00/RING.md b/crates/trios-algorithm-arena/rings/SR-ALG-00/RING.md new file mode 100644 index 0000000000..21ce2b8c14 --- /dev/null +++ b/crates/trios-algorithm-arena/rings/SR-ALG-00/RING.md @@ -0,0 +1,52 @@ +# RING — SR-ALG-00 (trios-algorithm-arena) + +## Identity + +| Field | Value | +|---------|-------| +| Metal | 🥉 Bronze | +| Package | `trios-algorithm-arena-sr-alg-00` | +| Sealed | No | + +## Purpose + +Wire-format ring for the algorithm arena. SR-ALG-01..03 + BR-OUTPUT +all import their manifest types from here. No I/O, no async — pure +data + serde. + +## Why SR-ALG-00 is the bottom of the graph + +Every other ring in GOLD II (jepa, universal-transformer, e2e-ttt, +arena assembler) depends on `AlgorithmSpec`, `EntryHash`, +`GoldenState`. Keeping SR-ALG-00 dep-free guarantees the entire GOLD +II branch compiles in one pass. + +## API Surface (pub) + +| Item | Role | +|---|---| +| `AlgorithmId(Uuid)` | unique submission id | +| `EntryHash([u8; 32])` | SHA-256 hex newtype | +| `GoldenState([u8; 32])` | optional convergence-checkpoint hash | +| `EnvVar(String)` / `EnvValue(String)` | env-pair newtypes | +| `AlgorithmSpec` | full manifest with `verify_hash()` | + +## Dependencies + +- `serde` (derive) +- `uuid` (`v4`, `serde`) +- `hex` — lowercase hex serialisation +- `serde_json` (dev only) + +## Laws + +- R1 — pure Rust +- L6 — no I/O, no async +- L13 — I-SCOPE: this ring only +- R-RING-DEP-002 — strict dep list above +- R-RING-FACADE-001 — outer crate re-exports only +- R-L6-PURE-007 — no `.py` in this crate + +## Anchor + +`φ² + φ⁻² = 3` diff --git a/crates/trios-algorithm-arena/rings/SR-ALG-00/TASK.md b/crates/trios-algorithm-arena/rings/SR-ALG-00/TASK.md new file mode 100644 index 0000000000..fbe6f0f94d --- /dev/null +++ b/crates/trios-algorithm-arena/rings/SR-ALG-00/TASK.md @@ -0,0 +1,34 @@ +# TASK — SR-ALG-00 (trios-algorithm-arena) + +## Status: DONE ✅ + +Closes #450 · Part of #446 + +## Completed + +- [x] Outer GOLD II crate `trios-algorithm-arena` scaffolded (`Cargo.toml` nested workspace, `src/lib.rs` ≤ 50 LoC, `RING.md`) +- [x] SR-ALG-00 ring at `rings/SR-ALG-00/` with `README.md`, `TASK.md`, `AGENTS.md`, `RING.md`, `Cargo.toml`, `src/lib.rs` (I5 mandatory) +- [x] Cargo deps limited to `serde + uuid + hex` (+ `serde_json` dev) — R-RING-DEP-002 +- [x] `AlgorithmId` newtype (UUID v4) with `Display`, `Hash`, `Eq` +- [x] `EntryHash([u8; 32])` — custom serde to lowercase hex (length 64) +- [x] `GoldenState([u8; 32])` — same hex layout, optional in spec +- [x] `EnvVar`, `EnvValue` newtypes (transparent serde) +- [x] `AlgorithmSpec` with: `algorithm_id`, `name`, `entry_path: PathBuf`, `entry_hash`, `env`, `golden_state_hash?`, `theorem?` +- [x] `AlgorithmSpec::new(name, path, hash)` cheap constructor +- [x] `AlgorithmSpec::verify_hash(&[u8; 32])` boolean check +- [x] 12 unit tests — uniqueness, hash length, hex roundtrip, optional fields, full roundtrip, schema field-name stability +- [x] `forbid(unsafe_code)` + `deny(missing_docs)` +- [x] `cargo clippy --all-targets -- -D warnings` clean +- [x] `Agent: Arena-Architect` trailer (L14) +- [x] L7 experience entry + +## Open (handed to next rings) + +- [ ] SR-ALG-01 jepa +- [ ] SR-ALG-02 universal-transformer +- [ ] **SR-ALG-03 e2e-ttt** ★ P0-CRITICAL — beat parameter-golf #1837 (`val_bpb < 1.07063`) +- [ ] BR-OUTPUT — AlgorithmArena assembler + +## Next ring + +SR-ALG-03 e2e-ttt (#457). It is the WIN ring for EPIC #446. diff --git a/crates/trios-algorithm-arena/rings/SR-ALG-00/src/lib.rs b/crates/trios-algorithm-arena/rings/SR-ALG-00/src/lib.rs new file mode 100644 index 0000000000..d6b503f4c8 --- /dev/null +++ b/crates/trios-algorithm-arena/rings/SR-ALG-00/src/lib.rs @@ -0,0 +1,422 @@ +//! SR-ALG-00 — arena-types +//! +//! Dependency-free typed metadata for one algorithm submitted to the +//! TRIOS IGLA arena. This is the bottom of the GOLD II dependency +//! graph; SR-ALG-01..03 + BR-OUTPUT all import their wire format from +//! here. +//! +//! Closes #450 · Part of #446 · Anchor: phi^2 + phi^-2 = 3 +//! +//! ## Critical: no Python in `crates/` +//! +//! `AlgorithmSpec::entry_path` points *out* of `crates/` (typically +//! into `parameter-golf/records/...`). Real Python spawn is the job of +//! SR-02 trainer-runner — never this crate. R-L6-PURE-007. +//! +//! ## Public types +//! +//! | Type | Wire-format role | +//! |-----------------|------------------| +//! | `AlgorithmId` | UUID v4 newtype identifying one algorithm | +//! | `EntryHash` | `[u8; 32]` SHA-256 of the entry script source | +//! | `EnvVar` | environment variable name newtype | +//! | `EnvValue` | environment variable value newtype | +//! | `GoldenState` | `[u8; 32]` SHA-256 of the convergence checkpoint | +//! | `AlgorithmSpec` | full manifest | +//! +//! ## Rules +//! +//! - R1 — pure Rust +//! - L6 — no I/O, no async, no subprocess +//! - L13 — I-SCOPE: only this ring +//! - R-RING-DEP-002 — deps = `serde + uuid + hex` (+ `serde_json` dev) +//! - R-L6-PURE-007 — no `.py` in this crate; entry_path is a *reference* + +#![forbid(unsafe_code)] +#![deny(missing_docs)] + +use std::fmt; +use std::path::PathBuf; + +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +// ───────────── newtypes ───────────── + +/// Unique identifier of one algorithm submission. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AlgorithmId(pub Uuid); + +impl AlgorithmId { + /// Generate a fresh v4 id. + pub fn new() -> Self { + Self(Uuid::new_v4()) + } + /// Underlying UUID. + pub fn as_uuid(&self) -> &Uuid { + &self.0 + } +} +impl Default for AlgorithmId { + fn default() -> Self { + Self::new() + } +} +impl fmt::Display for AlgorithmId { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.0.fmt(f) + } +} + +/// Environment variable name (e.g. `OPTIMIZER`). +#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[serde(transparent)] +pub struct EnvVar(pub String); + +impl EnvVar { + /// Build from any string-like input. + pub fn new(s: impl Into) -> Self { + Self(s.into()) + } + /// Backing string. + pub fn as_str(&self) -> &str { + &self.0 + } +} +impl fmt::Display for EnvVar { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&self.0) + } +} + +/// Environment variable value. +#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[serde(transparent)] +pub struct EnvValue(pub String); + +impl EnvValue { + /// Build from any string-like input. + pub fn new(s: impl Into) -> Self { + Self(s.into()) + } + /// Backing string. + pub fn as_str(&self) -> &str { + &self.0 + } +} +impl fmt::Display for EnvValue { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&self.0) + } +} + +// ───────────── 32-byte hashes ───────────── + +/// SHA-256 of the entry script source (post-normalisation). +/// +/// JSON serialisation is lowercase hex (length 64) for human-readable +/// arena manifests. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct EntryHash(pub [u8; 32]); + +impl EntryHash { + /// Underlying bytes. + pub fn as_bytes(&self) -> &[u8; 32] { + &self.0 + } + /// Compare to a candidate `[u8; 32]`. + pub fn matches(&self, other: &[u8; 32]) -> bool { + &self.0 == other + } +} + +impl fmt::Display for EntryHash { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&hex::encode(self.0)) + } +} + +impl Serialize for EntryHash { + fn serialize(&self, ser: S) -> Result { + ser.serialize_str(&hex::encode(self.0)) + } +} + +impl<'de> Deserialize<'de> for EntryHash { + fn deserialize>(de: D) -> Result { + let s = String::deserialize(de)?; + let bytes = hex::decode(&s).map_err(serde::de::Error::custom)?; + if bytes.len() != 32 { + return Err(serde::de::Error::custom(format!( + "EntryHash must be 32 bytes (64 hex chars), got {}", + bytes.len() + ))); + } + let mut out = [0u8; 32]; + out.copy_from_slice(&bytes); + Ok(Self(out)) + } +} + +/// SHA-256 of the convergence checkpoint a contestant must reach. +/// +/// Serialises as lowercase hex. Optional in [`AlgorithmSpec`] — +/// theory-only entries ship without one. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct GoldenState(pub [u8; 32]); + +impl GoldenState { + /// Underlying bytes. + pub fn as_bytes(&self) -> &[u8; 32] { + &self.0 + } +} + +impl fmt::Display for GoldenState { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&hex::encode(self.0)) + } +} + +impl Serialize for GoldenState { + fn serialize(&self, ser: S) -> Result { + ser.serialize_str(&hex::encode(self.0)) + } +} + +impl<'de> Deserialize<'de> for GoldenState { + fn deserialize>(de: D) -> Result { + let s = String::deserialize(de)?; + let bytes = hex::decode(&s).map_err(serde::de::Error::custom)?; + if bytes.len() != 32 { + return Err(serde::de::Error::custom(format!( + "GoldenState must be 32 bytes (64 hex chars), got {}", + bytes.len() + ))); + } + let mut out = [0u8; 32]; + out.copy_from_slice(&bytes); + Ok(Self(out)) + } +} + +// ───────────── AlgorithmSpec ───────────── + +/// Manifest for one algorithm submitted to the IGLA arena. +/// +/// `entry_path` MUST point *outside* `crates/` (typically into +/// `parameter-golf/records/...`). This crate never executes Python. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct AlgorithmSpec { + /// Unique id of this submission. + pub algorithm_id: AlgorithmId, + /// Human-readable name (`"e2e-ttt"`, `"jepa-12k"`, …). + pub name: String, + /// Filesystem path to the entry script (NEVER inside `crates/`). + pub entry_path: PathBuf, + /// SHA-256 of the entry script source (post-normalisation). + pub entry_hash: EntryHash, + /// Ordered list of `(env_var, env_value)` pairs. + pub env: Vec<(EnvVar, EnvValue)>, + /// Optional convergence checkpoint hash. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub golden_state_hash: Option, + /// Optional theorem citation (e.g. `"Coq.Reals Thm 3.1 SAC-1"`). + #[serde(default, skip_serializing_if = "Option::is_none")] + pub theorem: Option, +} + +impl AlgorithmSpec { + /// Cheap convenience constructor for the common case + /// (`name`, `entry_path`, `entry_hash`). + pub fn new(name: impl Into, entry_path: PathBuf, entry_hash: EntryHash) -> Self { + Self { + algorithm_id: AlgorithmId::new(), + name: name.into(), + entry_path, + entry_hash, + env: Vec::new(), + golden_state_hash: None, + theorem: None, + } + } + + /// Compare an actual SHA-256 to the manifest's [`EntryHash`]. + pub fn verify_hash(&self, actual: &[u8; 32]) -> bool { + self.entry_hash.matches(actual) + } +} + +// ───────────── tests ───────────── + +#[cfg(test)] +mod tests { + use super::*; + + fn fixed_32() -> [u8; 32] { + // 0x00..0x1f + let mut out = [0u8; 32]; + for (i, b) in out.iter_mut().enumerate() { + *b = i as u8; + } + out + } + + fn other_32() -> [u8; 32] { + let mut out = [0u8; 32]; + for (i, b) in out.iter_mut().enumerate() { + *b = (i as u8).wrapping_add(0x55); + } + out + } + + #[test] + fn algorithm_id_unique_per_instance() { + let a = AlgorithmId::new(); + let b = AlgorithmId::new(); + assert_ne!(a, b); + } + + #[test] + fn entry_hash_32_bytes_serialises_as_hex64() { + let h = EntryHash(fixed_32()); + let s = serde_json::to_string(&h).unwrap(); + // 64 hex chars + 2 quotes + assert_eq!(s.len(), 66, "expected 64-char hex string, got {}", s); + let back: EntryHash = serde_json::from_str(&s).unwrap(); + assert_eq!(h, back); + } + + #[test] + fn entry_hash_rejects_wrong_length() { + // 31 bytes → 62 hex chars → must fail. + let s = format!("\"{}\"", "ab".repeat(31)); + assert!(serde_json::from_str::(&s).is_err()); + } + + #[test] + fn golden_state_serialises_as_hex64() { + let g = GoldenState(fixed_32()); + let s = serde_json::to_string(&g).unwrap(); + let back: GoldenState = serde_json::from_str(&s).unwrap(); + assert_eq!(g, back); + } + + #[test] + fn env_empty_vec_valid() { + let spec = AlgorithmSpec::new( + "noop", + PathBuf::from("parameter-golf/records/noop/train.py"), + EntryHash(fixed_32()), + ); + assert!(spec.env.is_empty()); + let s = serde_json::to_string(&spec).unwrap(); + let back: AlgorithmSpec = serde_json::from_str(&s).unwrap(); + assert_eq!(spec, back); + } + + #[test] + fn entry_path_from_str_round_trips() { + let path = PathBuf::from("parameter-golf/records/e2e-ttt/train.py"); + let spec = AlgorithmSpec::new("e2e-ttt", path.clone(), EntryHash(fixed_32())); + assert_eq!(spec.entry_path, path); + } + + #[test] + fn theorem_optional() { + let spec = AlgorithmSpec::new( + "no-theory", + PathBuf::from("parameter-golf/records/no-theory/train.py"), + EntryHash(fixed_32()), + ); + assert!(spec.theorem.is_none()); + let s = serde_json::to_string(&spec).unwrap(); + assert!(!s.contains("\"theorem\""), "theorem must be omitted when None"); + } + + #[test] + fn golden_state_hash_optional() { + let spec = AlgorithmSpec::new( + "no-state", + PathBuf::from("parameter-golf/records/no-state/train.py"), + EntryHash(fixed_32()), + ); + assert!(spec.golden_state_hash.is_none()); + let s = serde_json::to_string(&spec).unwrap(); + assert!( + !s.contains("\"golden_state_hash\""), + "golden_state_hash must be omitted when None" + ); + } + + #[test] + fn verify_hash_correct() { + let h = fixed_32(); + let spec = AlgorithmSpec::new( + "x", + PathBuf::from("parameter-golf/records/x/train.py"), + EntryHash(h), + ); + assert!(spec.verify_hash(&h)); + } + + #[test] + fn verify_hash_wrong_fails() { + let spec = AlgorithmSpec::new( + "x", + PathBuf::from("parameter-golf/records/x/train.py"), + EntryHash(fixed_32()), + ); + assert!(!spec.verify_hash(&other_32())); + } + + #[test] + fn serde_roundtrip_full_spec() { + let mut h = [0u8; 32]; + for (i, b) in h.iter_mut().enumerate() { + *b = i as u8; + } + let spec = AlgorithmSpec { + algorithm_id: AlgorithmId::new(), + name: "e2e-ttt".into(), + entry_path: PathBuf::from("parameter-golf/records/e2e-ttt/train.py"), + entry_hash: EntryHash(h), + env: vec![ + (EnvVar::new("OPTIMIZER"), EnvValue::new("AdamW")), + (EnvVar::new("LR"), EnvValue::new("0.005")), + ], + golden_state_hash: Some(GoldenState(h)), + theorem: Some("Coq.Reals Theorem 3.1 SAC-1".into()), + }; + let s = serde_json::to_string(&spec).unwrap(); + let back: AlgorithmSpec = serde_json::from_str(&s).unwrap(); + assert_eq!(spec, back); + } + + #[test] + fn schema_field_names_stable() { + // Wire-format guard: SR-ALG-01..03 + BR-OUTPUT depend on these + // exact JSON key names. Renaming any field MUST be paired with + // an audit of every consumer. + let spec = AlgorithmSpec::new( + "x", + PathBuf::from("parameter-golf/records/x/train.py"), + EntryHash(fixed_32()), + ); + let v: serde_json::Value = serde_json::to_value(&spec).unwrap(); + for k in [ + "algorithm_id", + "name", + "entry_path", + "entry_hash", + "env", + ] { + assert!( + v.get(k).is_some(), + "AlgorithmSpec field '{}' missing from JSON", + k + ); + } + } +} diff --git a/crates/trios-algorithm-arena/src/lib.rs b/crates/trios-algorithm-arena/src/lib.rs new file mode 100644 index 0000000000..2cbf6100c9 --- /dev/null +++ b/crates/trios-algorithm-arena/src/lib.rs @@ -0,0 +1,10 @@ +//! trios-algorithm-arena — GOLD II crate facade. +//! +//! Re-exports SR-ALG-00 typed primitives for every downstream GOLD II +//! ring (SR-ALG-01 jepa, SR-ALG-02 universal-transformer, SR-ALG-03 +//! e2e-ttt, BR-OUTPUT AlgorithmArena assembler). +//! +//! L-RING-FACADE-001: this file MUST NOT contain business logic — only +//! re-exports. + +pub use trios_algorithm_arena_sr_alg_00::*;