interplane.Get Omega
Read in your language

interplane-mv

INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority.

Brought by drakestapleton

branch main Branches Tags History

interplane-mv / rust / crates / interplane-conformance / tests / subset_malformed.rs

50 lines · 1422 bytes Raw Blame History
1//! The subset rule refuses a malformed table entry by name instead of reading it as empty.
2use std::path::Path;
3
4use interplane_conformance::ojson::OJson;
5use interplane_conformance::subset::Corpus;
6
7fn corpus() -> Corpus {
8 Corpus::new(&Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.."))
9}
10
11/// The shared table with the `aien` entry changed by `edit`.
12fn table_with(edit: impl Fn(&mut serde_json::Value)) -> OJson {
13 let mut t = corpus().load_table().unwrap().to_value();
14 edit(&mut t["adapters"]["aien"]);
15 OJson::parse(&t.to_string()).unwrap()
16}
17
18fn refused(table: &OJson) -> String {
19 corpus()
20 .plans("aien", table)
21 .expect_err("a malformed entry is refused")
22}
23
24#[test]
25fn the_shared_entry_is_accepted() {
26 let table = corpus().load_table().unwrap();
27 assert!(!corpus().plans("aien", &table).unwrap().is_empty());
28}
29
30#[test]
31fn a_non_string_prefix_is_refused() {
32 let t = table_with(|e| e["effects"]["write_file"]["args"]["path"]["prefix"] = 7.into());
33 assert!(
34 refused(&t).contains("effects.write_file.args.path.prefix must be a string"),
35 "{}",
36 refused(&t)
37 );
38}
39
40#[test]
41fn a_missing_approval_map_is_refused() {
42 let t = table_with(|e| {
43 e.as_object_mut().unwrap().remove("approval_effects");
44 });
45 assert!(
46 refused(&t).contains("table entry has no approval_effects"),
47 "{}",
48 refused(&t)
49 );
50}