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-lenshift/examples/replay_scan.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-lenshift / examples / replay_scan.rs` 44 lines ยท 1523 bytes Raw Blame History 1 //! Standalone scanner: `replay_scan ...` scans every `.json` file below each path, 2 //! recursively, and exits non-zero if any file has a finding. Run it on anything you plan to 3 //! commit as a replay fixture (including drafts outside `dialects/replay`). 4 use interplane_lenshift::replay::scan; 5 use serde_json::Value; 6 use std::path::Path; 7 8 fn walk(p: &Path, bad: &mut usize, n: &mut usize) { 9 if p.is_dir() { 10 let mut es: Vec<_> = std::fs::read_dir(p) 11 .expect("read dir") 12 .map(|e| e.unwrap().path()) 13 .collect(); 14 es.sort(); 15 for e in es { 16 walk(&e, bad, n); 17 } 18 } else if p.extension().and_then(|e| e.to_str()) == Some("json") { 19 *n += 1; 20 let t = std::fs::read_to_string(p).expect("read"); 21 let found = match serde_json::from_str::(&t) { 22 Ok(v) => scan(&v), 23 Err(e) => vec![format!("not JSON: {e}")], 24 }; 25 if !found.is_empty() { 26 *bad += 1; 27 eprintln!("{}:\n {}", p.display(), found.join("\n ")); 28 } 29 } 30 } 31 32 fn main() { 33 let (mut bad, mut n) = (0, 0); 34 let args: Vec = std::env::args().skip(1).collect(); 35 if args.is_empty() { 36 eprintln!("usage: replay_scan ..."); 37 std::process::exit(2); 38 } 39 for a in &args { 40 walk(Path::new(a), &mut bad, &mut n); 41 } 42 println!("scanned {n} files, {bad} with findings"); 43 std::process::exit(if bad == 0 && n > 0 { 0 } else { 1 }); 44 }