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/tests/validate_bad_names.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 / tests / validate_bad_names.rs` 78 lines ยท 2630 bytes Raw Blame History 1 //! The fixture validator reports malformed corpus entries as errors and never panics: approval 2 //! files with a short or non-ASCII name, and an oversized case (15) with no tool call. 3 #![cfg(feature = "schema-check")] 4 5 use std::fs; 6 use std::path::{Path, PathBuf}; 7 8 use interplane_conformance::fixture_check; 9 10 fn copy_dir(from: &Path, to: &Path) { 11 fs::create_dir_all(to).unwrap(); 12 for e in fs::read_dir(from).unwrap() { 13 let e = e.unwrap(); 14 let dest = to.join(e.file_name()); 15 if e.file_type().unwrap().is_dir() { 16 copy_dir(&e.path(), &dest); 17 } else { 18 fs::copy(e.path(), dest).unwrap(); 19 } 20 } 21 } 22 23 /// A scratch copy of everything the validator reads. 24 fn corpus(label: &str) -> PathBuf { 25 let repo = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.."); 26 let root = Path::new(env!("CARGO_TARGET_TMPDIR")).join(label); 27 let _ = fs::remove_dir_all(&root); 28 for d in ["spec/schemas", "conformance", "dialects/fixtures"] { 29 copy_dir(&repo.join(d), &root.join(d)); 30 } 31 root 32 } 33 34 fn errors_of(root: &Path) -> String { 35 let report = fixture_check::run(root).expect("validator returns a report"); 36 assert!(!report.passed(), "a broken corpus must fail"); 37 report.text() 38 } 39 40 #[test] 41 fn unmodified_copy_passes() { 42 let root = corpus("validate-clean"); 43 assert!(fixture_check::run(&root).unwrap().passed()); 44 } 45 46 #[test] 47 fn short_and_non_ascii_approval_names_are_errors() { 48 let root = corpus("validate-bad-names"); 49 let app = root.join("conformance/fixtures/approval"); 50 let src = app.join("01-authorized-continuation.json"); 51 fs::copy(&src, app.join("7.json")).unwrap(); 52 fs::copy(&src, app.join("\u{e9}\u{e9}-accent.json")).unwrap(); 53 let text = errors_of(&root); 54 assert!(text.contains("approval/7: case slug"), "{text}"); 55 assert!( 56 text.contains("approval/\u{e9}\u{e9}-accent: case slug"), 57 "{text}" 58 ); 59 } 60 61 #[test] 62 fn oversized_case_without_a_tool_call_is_an_error() { 63 let root = corpus("validate-no-call"); 64 let fix = root.join("conformance/fixtures"); 65 let p = fs::read_dir(&fix) 66 .unwrap() 67 .map(|e| e.unwrap().path()) 68 .find(|p| p.file_name().unwrap().to_string_lossy().starts_with("15")) 69 .unwrap(); 70 let mut f: serde_json::Value = serde_json::from_str(&fs::read_to_string(&p).unwrap()).unwrap(); 71 f["steps"] = serde_json::json!([]); 72 fs::write(&p, serde_json::to_string_pretty(&f).unwrap()).unwrap(); 73 let text = errors_of(&root); 74 assert!( 75 text.contains("15: first step must carry a tool call"), 76 "{text}" 77 ); 78 }