Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.
Rust ai-nativedescription-logicsformal-verificationinfrastructure-as-codeisabelle-languageknowledge-graphleanlean4mcpmcp-serverontologyowlowl2reasoningrustshaclsparqltheorem-proving
fix: resolve clippy warnings (fixes CI)
FABIOTESSfb7232e1403e
diff --git a/src/align.rs b/src/align.rsindex 06589572..41db2ccf 100644--- a/src/align.rs+++ b/src/align.rs@@ -905,7 +905,7 @@ mod tests {).unwrap();let parsed: serde_json::Value = serde_json::from_str(&result).unwrap();- assert_eq!(parsed["ok"].as_bool().unwrap(), true);+ assert!(parsed["ok"].as_bool().unwrap());// Verify it was storedlet conn = db.conn();diff --git a/src/config.rs b/src/config.rsindex 158dacf6..4490d415 100644--- a/src/config.rs+++ b/src/config.rs@@ -72,7 +72,7 @@ pub fn resolve_ontology_dirs(cfg: &[String]) -> Vec<std::path::PathBuf> {let from_env = std::env::var("OPEN_ONTOLOGIES_ONTOLOGY_DIRS").ok();let raw: Vec<String> = match from_env {Some(v) if !v.trim().is_empty() => v- .split(|c| c == ':' || c == ';')+ .split([':', ';']).map(|s| s.trim().to_string()).filter(|s| !s.is_empty()).collect(),diff --git a/src/inputs.rs b/src/inputs.rsindex d771de6e..325a7800 100644--- a/src/inputs.rs+++ b/src/inputs.rs@@ -82,6 +82,7 @@ pub struct OntoRepoLoadInput {/// - a relative path (e.g. `subdir/pizza.ttl`) resolved against the/// configured directories,/// - an absolute path inside one of the configured directories.+ ////// Paths outside the configured `ontology_dirs` are rejected.pub name: String,/// Optional registry name override (defaults to the file stem).diff --git a/src/registry.rs b/src/registry.rsindex 02333ea2..921ffe19 100644--- a/src/registry.rs+++ b/src/registry.rs@@ -289,6 +289,7 @@ impl OntologyRegistry {/// - If `name` is in the cache but not active, only the on-disk cache is/// touched (since it was never in memory). With `delete_cache=true` the/// cache file and DB row are removed; otherwise this is a no-op.+ ////// Returns `Ok(true)` if anything was actually changed.pub fn unload_named(&self, name: &str, delete_cache: bool) -> Result<bool> {let active_name = self.active.lock().unwrap().as_ref().map(|e| e.name.clone());diff --git a/src/repo.rs b/src/repo.rsindex 8196570b..9c39b0ab 100644--- a/src/repo.rs+++ b/src/repo.rs@@ -25,7 +25,7 @@ pub fn has_rdf_extension(path: &Path) -> bool {.and_then(|e| e.to_str()).map(|e| {let lower = e.to_ascii_lowercase();- RDF_EXTENSIONS.iter().any(|x| *x == lower.as_str())+ RDF_EXTENSIONS.contains(&lower.as_str())}).unwrap_or(false)}diff --git a/src/toolfilter.rs b/src/toolfilter.rsindex ffd62261..efb2eb8e 100644--- a/src/toolfilter.rs+++ b/src/toolfilter.rs@@ -17,20 +17,15 @@ use std::collections::HashSet;use rmcp::handler::server::tool::ToolRouter;-#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]+#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Default)]#[serde(rename_all = "lowercase")]pub enum Mode {+ #[default]All,Allow,Deny,}-impl Default for Mode {- fn default() -> Self {- Mode::All- }-}-impl Mode {pub fn parse(s: &str) -> Result<Self, String> {match s.to_ascii_lowercase().as_str() {diff --git a/tests/cli_test.rs b/tests/cli_test.rsindex 9bf403d9..f6383a3d 100644--- a/tests/cli_test.rs+++ b/tests/cli_test.rs@@ -264,7 +264,7 @@ fn test_cli_lint_suppression_end_to_end() {.output().unwrap();assert!(out.status.success());let stdout = String::from_utf8_lossy(&out.stdout);- let v: serde_json::Value = serde_json::from_str(&stdout.trim()).unwrap();+ let v: serde_json::Value = serde_json::from_str(stdout.trim()).unwrap();// Find the entity string for missing_label on Doglet issues = v["issues"].as_array().unwrap();@@ -289,6 +289,6 @@ fn test_cli_lint_suppression_end_to_end() {.output().unwrap();assert!(out.status.success());let stdout = String::from_utf8_lossy(&out.stdout);- let v: serde_json::Value = serde_json::from_str(&stdout.trim()).unwrap();+ let v: serde_json::Value = serde_json::from_str(stdout.trim()).unwrap();assert!(v["suppressed_count"].as_u64().unwrap() > 0, "suppressed_count should be > 0 after 3 dismissals");}diff --git a/tests/enforce_test.rs b/tests/enforce_test.rsindex 5b3c8d89..2820ea38 100644--- a/tests/enforce_test.rs+++ b/tests/enforce_test.rs@@ -181,7 +181,7 @@ fn test_enforce_compliance_score() {let parsed: serde_json::Value = serde_json::from_str(&result).unwrap();let score = parsed["compliance"].as_f64().unwrap();- assert!(score >= 0.0 && score <= 1.0);+ assert!((0.0..=1.0).contains(&score));}#[test]@@ -210,7 +210,7 @@ fn test_enforce_with_feedback_suppression() {let result = enforcer.enforce_with_feedback("generic", Some(&db)).unwrap();let v: serde_json::Value = serde_json::from_str(&result).unwrap();let violations = v["violations"].as_array().unwrap();- assert!(violations.len() > 0);+ assert!(!violations.is_empty());assert_eq!(v["suppressed_count"].as_u64().unwrap(), 0);// Find the entity string for the missing_label violation on Dogdiff --git a/tests/plan_test.rs b/tests/plan_test.rsindex e50cb6ee..87e889b4 100644--- a/tests/plan_test.rs+++ b/tests/plan_test.rs@@ -143,7 +143,7 @@ fn test_apply_safe_mode() {let result = planner.apply("safe").unwrap();let parsed: serde_json::Value = serde_json::from_str(&result).unwrap();- assert_eq!(parsed["ok"].as_bool().unwrap(), true);+ assert!(parsed["ok"].as_bool().unwrap());// Cat should now be in the storelet stats = graph.get_stats().unwrap();assert!(stats.contains("\"classes\":2") || stats.contains("\"classes\": 2"));@@ -214,5 +214,5 @@ fn test_lock_prevents_plan() {let plan = planner.plan(new_turtle).unwrap();let parsed: serde_json::Value = serde_json::from_str(&plan).unwrap();- assert!(parsed["locked_violations"].as_array().unwrap().len() > 0);+ assert!(!parsed["locked_violations"].as_array().unwrap().is_empty());}diff --git a/tests/repo_test.rs b/tests/repo_test.rsindex 72459025..10260ab8 100644--- a/tests/repo_test.rs+++ b/tests/repo_test.rs@@ -75,7 +75,7 @@ fn glob_filters_filename_only() {#[test]fn resolve_load_target_by_bare_stem() {let (_tmp, repo, expected) = setup_repo();- let path = repo::resolve_load_target("animals", &[repo.clone()]).unwrap();+ let path = repo::resolve_load_target("animals", std::slice::from_ref(&repo)).unwrap();assert_eq!(std::fs::canonicalize(&path).unwrap(),std::fs::canonicalize(&expected).unwrap()@@ -85,7 +85,7 @@ fn resolve_load_target_by_bare_stem() {#[test]fn resolve_load_target_by_relative_path() {let (_tmp, repo, _) = setup_repo();- let path = repo::resolve_load_target("sub/nested.ttl", &[repo.clone()]).unwrap();+ let path = repo::resolve_load_target("sub/nested.ttl", std::slice::from_ref(&repo)).unwrap();assert!(path.ends_with("sub/nested.ttl") || path.ends_with("sub\\nested.ttl"));}@@ -95,7 +95,7 @@ fn resolve_load_target_rejects_outside_path() {let outside = tempfile::tempdir().unwrap();let outside_file = outside.path().join("evil.ttl");std::fs::write(&outside_file, SAMPLE_TTL).unwrap();- let err = repo::resolve_load_target(outside_file.to_str().unwrap(), &[repo.clone()])+ let err = repo::resolve_load_target(outside_file.to_str().unwrap(), std::slice::from_ref(&repo)).unwrap_err().to_string();assert!(err.contains("outside") || err.contains("no file"), "got: {}", err);@@ -119,7 +119,7 @@ fn resolve_load_target_ambiguous_returns_error() {#[test]fn resolve_within_repos_rejects_traversal() {let (_tmp, repo, _) = setup_repo();- let err = repo::resolve_within_repos("/etc", &[repo.clone()])+ let err = repo::resolve_within_repos("/etc", std::slice::from_ref(&repo)).unwrap_err().to_string();assert!(err.contains("not under"), "got: {}", err);@@ -128,7 +128,7 @@ fn resolve_within_repos_rejects_traversal() {#[test]fn resolve_within_repos_accepts_subdir() {let (_tmp, repo, _) = setup_repo();- let (resolved, repo_root) = repo::resolve_within_repos("sub", &[repo.clone()]).unwrap();+ let (resolved, repo_root) = repo::resolve_within_repos("sub", std::slice::from_ref(&repo)).unwrap();assert!(resolved.ends_with("sub"));assert_eq!(std::fs::canonicalize(&repo_root).unwrap(),@@ -155,7 +155,7 @@ fn registry_loads_path_resolved_from_repo() {};let registry = Arc::new(OntologyRegistry::new(graph.clone(), db, cfg).unwrap());- let path = repo::resolve_load_target("vehicles", &[repo.clone()]).unwrap();+ let path = repo::resolve_load_target("vehicles", std::slice::from_ref(&repo)).unwrap();let res = registry.load_file(&path.to_string_lossy(), LoadOptions::default()).unwrap();diff --git a/tests/socket_test.rs b/tests/socket_test.rsindex 646e47e1..c3fe3c28 100644--- a/tests/socket_test.rs+++ b/tests/socket_test.rs@@ -126,7 +126,7 @@ async fn check_consistency_clean() {).await;- assert_eq!(resp["consistent"].as_bool().unwrap(), true);+ assert!(resp["consistent"].as_bool().unwrap());assert_eq!(resp["contradiction_count"].as_u64().unwrap(), 0);std::fs::remove_file(&sock).ok();diff --git a/tests/terraform_loop_test.rs b/tests/terraform_loop_test.rsindex f3d696eb..e933cd12 100644--- a/tests/terraform_loop_test.rs+++ b/tests/terraform_loop_test.rs@@ -56,7 +56,7 @@ fn test_full_terraform_loop() {// --- Apply ---let apply_result = planner.apply("safe").unwrap();let apply_parsed: serde_json::Value = serde_json::from_str(&apply_result).unwrap();- assert_eq!(apply_parsed["ok"].as_bool().unwrap(), true);+ assert!(apply_parsed["ok"].as_bool().unwrap());lineage.record(&session, "A", "apply", "safe");// --- Monitor ---