tests/mimir_villa_robot.rs
//! **Robot: the Villa lens's shell-out taxonomy.**
//!
//! Villa ([`nornir::mimir_lens::villa`]) is the Mimir lens for IMPURE / shell-out
//! operations over the code graph. Its feed is the code room's CALLS edges into
//! the impure std / libc / nix items (Mímir v2); the classifier those callees go
//! through — by RESOLVED path and node kind — is asserted here.
//!
//! Every check also emits a [`nornir_testmatrix::functional_status`] row (a no-op
//! unless built `--features testmatrix`).
use nornir::mimir_lens::villa::{self, Kind};
/// The taxonomy is exhaustive and the process-heresy anchor is `Command::new` — a
/// guard so a future scanner change that renames the callee is caught here, not in
/// a silently-empty warehouse.
#[test]
fn villa_classifies_the_shell_out_taxonomy() {
use nornir_testmatrix::functional_status;
let checks: &[(&str, &str, Option<Kind>)] = &[
("std::process::Command::new", "method", Some(Kind::Process)),
("tokio::process::Command::new", "method", Some(Kind::Process)),
("libc::unix::system", "ffi", Some(Kind::Shell)),
("nix::unistd::execvp", "fn", Some(Kind::Shell)),
("std::os::unix::process::Command::exec", "method", Some(Kind::Shell)),
("std::process::exit", "fn", Some(Kind::ProcessControl)),
// resolved callees: sharing a name with an impure item is not impurity
("clap::builder::Command::new", "method", None),
("sqlx::query::Query::exec", "method", None),
("serde_json::from_str", "fn", None),
];
for (callee, kind, want) in checks {
let got = villa::classify(callee, kind);
let ok = got == *want;
functional_status(
"mimir-villa",
&format!("classify_{}", callee.replace([':', ' '], "_")),
ok,
&format!("classify({callee}, {kind}) = {got:?}, want {want:?}"),
);
assert!(ok, "classify({callee}, {kind}) = {got:?}, want {want:?}");
}
}