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/interplane-mv/blob/main/rust/crates/interplane-conformance/src/trust_digest.rs # interplane-mv INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority. 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 `interplane-mv / rust / crates / interplane-conformance / src / trust_digest.rs` 77 lines ยท 3152 bytes Raw Blame History 1 //! Freeze file for the 0.3 trust corpus (bench/PROTOCOL-0.3.md section 8): 2 //! `conformance/TRUST-DIGEST.txt`. 3 //! 4 //! `corpus_digest` is the sha256 of the `sha256sum` lines (` \n`, repo-relative paths) 5 //! of every `conformance/fixtures/**/*.json` in byte order of the path (the whole corpus the 6 //! negative-control matrix depends on, not only the injection cases). `negative_controls_sha256` 7 //! freezes `conformance/negative-controls.json`, `protocol_sha256` freezes 8 //! `bench/PROTOCOL-0.3.md` and `adapter_translation_sha256` freezes 9 //! `conformance/adapter-translation.json` (the data of the subset rule). `t3_subset` and 10 //! `t4_subset` list the fixtures each adapter must run, computed by [`crate::subset`]. 11 use std::path::Path; 12 13 use sha2::{Digest, Sha256}; 14 15 use crate::subset::Corpus; 16 17 pub const OUT: &str = "conformance/TRUST-DIGEST.txt"; 18 const CORPUS: &str = "conformance/fixtures"; 19 const NEGCTL: &str = "conformance/negative-controls.json"; 20 const PROTOCOL: &str = "bench/PROTOCOL-0.3.md"; 21 const TRANSLATION: &str = "conformance/adapter-translation.json"; 22 23 fn sha(b: &[u8]) -> String { 24 format!("{:x}", Sha256::digest(b)) 25 } 26 27 fn read(root: &Path, rel: &str) -> Result, String> { 28 std::fs::read(root.join(rel)).map_err(|e| format!("{rel}: {e}")) 29 } 30 31 fn walk(dir: &Path, rel: &str, out: &mut Vec) -> Result<(), String> { 32 for e in std::fs::read_dir(dir).map_err(|e| format!("{}: {e}", dir.display()))? { 33 let e = e.map_err(|e| e.to_string())?; 34 let name = e.file_name().to_string_lossy().into_owned(); 35 let sub = if rel.is_empty() { 36 name.clone() 37 } else { 38 format!("{rel}/{name}") 39 }; 40 if e.file_type().map_err(|e| e.to_string())?.is_dir() { 41 walk(&e.path(), &sub, out)?; 42 } else if name.ends_with(".json") { 43 out.push(sub); 44 } 45 } 46 Ok(()) 47 } 48 49 /// The text `conformance/TRUST-DIGEST.txt` must hold for the checkout at `root`. 50 pub fn compute(root: &Path) -> Result { 51 let mut names = vec![]; 52 walk(&root.join(CORPUS), "", &mut names)?; 53 names.sort_by(|a, b| a.as_bytes().cmp(b.as_bytes())); 54 let mut lines = String::new(); 55 for n in &names { 56 let body = read(root, &format!("{CORPUS}/{n}"))?; 57 lines.push_str(&format!("{} {CORPUS}/{n}\n", sha(&body))); 58 } 59 let corpus = Corpus::new(root); 60 let table = corpus.load_table()?; 61 let t3 = corpus.subset("odysseus", &table)?; 62 let t4 = corpus.subset("aien", &table)?; 63 Ok(format!( 64 "corpus: {CORPUS}\ncorpus_files: {}\ncorpus_digest: sha256:{}\nnegative_controls: {NEGCTL}\nnegative_controls_sha256: sha256:{}\n\ 65 protocol: {PROTOCOL}\nprotocol_sha256: sha256:{}\nadapter_translation: {TRANSLATION}\nadapter_translation_sha256: sha256:{}\n\ 66 t3_subset_count: {}\nt3_subset: {}\nt4_subset_count: {}\nt4_subset: {}\n", 67 names.len(), 68 sha(lines.as_bytes()), 69 sha(&read(root, NEGCTL)?), 70 sha(&read(root, PROTOCOL)?), 71 sha(&read(root, TRANSLATION)?), 72 t3.len(), 73 t3.join(","), 74 t4.len(), 75 t4.join(","), 76 )) 77 }