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
chore(deps): migrate to Oxigraph 0.5.8 + clear Store::query deprecations (#22)
Fabio Rovaid4c2d9e28473
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ab7f0578..6b968570 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,6 +4,9 @@ All notable changes to Open Ontologies are documented here.## [Unreleased]+### Changed+- **Oxigraph dependency bumped from 0.4 → 0.5.8** (#15). Oxigraph 0.5 ships RDF 1.2 / SPARQL 1.2 support (behind `rdf-12` / `sparql-12` feature flags), a new `SparqlEvaluator` builder-based query API, JSON-LD 1.1 by default, GeoSPARQL functions, a built-in `/sparql` HTTP server, single-pass ORDER BY, and — most relevant here — **built-in RDFC 1.0 canonicalisation** (W3C Recommendation, 21 May 2024), which gives deterministic blank-node identifiers via SHA-256 over canonical N-Quads. RDFC 1.0 is the proper successor to the bnode-filter hotfix in PR #14: a follow-up release can replace the `_:`-prefix filter in `extract_vocabulary` with canonicalisation, keeping semantic content while solving the reparse-instability problem at its root. The 0.4 → 0.5 migration was back-compatible for this codebase (the auto-migrating on-disk format means existing databases load without intervention). All six `Store::query` call sites in `graph.rs`, `shacl.rs`, and `ontology.rs` have been ported to the non-deprecated `SparqlEvaluator::new().parse_query(...).on_store(&store).execute()` chain; no deprecation warnings remain on the lib build. Full test suite (~290 tests) green on 0.5.8.+### Added- **KGCL output format for `onto_drift`** (#17). The drift detector can now emit results in the [Knowledge Graph Change Language](https://github.com/INCATools/kgcl) (Mungall et al., Database 2025, doi:10.1093/database/baae133) alongside the existing JSON. Two new format options on the MCP tool: `format = "kgcl"` produces line-oriented CNL (`create node <iri>`, `obsolete node <iri>`, `obsolete node <iri> with replacement <iri>`) consumed by ROBOT and BioPortal; `format = "kgcl_json"` produces structured JSON-LD. High-confidence likely_renames (above `rename_threshold`, default 0.7) collapse into a `NodeObsoletion` with `has_direct_replacement` instead of plain add+remove pairs. New module `src/kgcl.rs` with 8 unit tests plus `tests/kgcl_drift_test.rs` integration suite.- **LLM-orchestrated borderline-candidate review for `onto_align`** (#16). The alignment engine now splits its output into three buckets driven by two thresholds rather than a single `min_confidence` cliff: candidates with confidence above `high_threshold` (default 0.85) auto-apply as today, those in `[low_threshold, high_threshold)` (default low 0.4) surface in a new `borderline` array enriched with `context` (source/target labels and parent IRIs), and those below `low_threshold` are dropped. The MCP tool returns a `summary_for_review` instructing the connected LLM to inspect each borderline pair and call `onto_align_feedback` to record verdicts — those verdicts flow into the existing self-calibrating-weights loop. This is the MCP-native form of the LogMap-LLM "LLM-as-oracle" pattern (Jiménez-Ruiz et al., EACL 2026 main, top-2 in OAEI 2025 Bio-ML): no extra LLM client, no API key, no provider abstraction — the connected orchestrator does the judging via the conversation that already exists. New public method `AlignmentEngine::align_with_thresholds(source, target, high, low, dry_run)`; the legacy `align(source, target, min_confidence, dry_run)` remains and delegates with a degenerate range (empty borderline bucket) for back-compat. New `OntoAlignInput` fields `high_threshold` + `low_threshold` (both optional); `min_confidence` retained as the back-compat alias for `high_threshold`. New `tests/align_borderline_test.rs` (5 tests) covering bucket boundaries, context enrichment, summary text, and back-compat.diff --git a/Cargo.lock b/Cargo.lockindex 454d7e31..f5229f1e 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2793,19 +2793,19 @@ dependencies = [[[package]]name = "oxigraph"-version = "0.4.11"+version = "0.5.8"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "86b57a5334aab94d88e1d24b238c093c5efb0d309614b16ac920f23ad77ee77d"+checksum = "b4ee83ce0422e6dce39a325810a9c66af71577a0a6fb5d887764bf3ae6304667"dependencies = ["dashmap",- "getrandom 0.2.17",+ "getrandom 0.3.4","libc","oxiri","oxrdf","oxrdfio","oxrocksdb-sys","oxsdatatypes",- "rand 0.8.5",+ "rand 0.9.2","rustc-hash","siphasher","sparesults",@@ -2831,34 +2831,37 @@ checksum = "54b4ed3a7192fa19f5f48f99871f2755047fabefd7f222f12a1df1773796a102"[[package]]name = "oxjsonld"-version = "0.1.0"+version = "0.2.5"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "13a1a66dc569350f3f4e5eff8a8e1a72b0c9e6ad395bb5805493cb7a2fda185f"+checksum = "f6e1380a504a8571763f13b8bcad629ff90d0300d47d8a519f3c6c599625840e"dependencies = ["json-event-parser","oxiri","oxrdf",+ "ryu-js","thiserror",][[package]]name = "oxrdf"-version = "0.2.4"+version = "0.3.3"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "a04761319ef84de1f59782f189d072cbfc3a9a40c4e8bded8667202fbd35b02a"+checksum = "0afd5c28e4a399c57ee2bc3accd40c7b671fdc7b6537499f14e95b265af7d7e0"dependencies = [+ "hex","oxilangtag","oxiri","oxsdatatypes",- "rand 0.8.5",+ "rand 0.9.2",+ "sha2","thiserror",][[package]]name = "oxrdfio"-version = "0.1.8"+version = "0.2.5"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "14d33dd87769786a0bb7de342865e33bf0c6e9872fa76f1ede23e944fdc77898"+checksum = "696223589ecbcab06b1a5df9b527dc25b0c656160cca38752fdb3878a5d3dd03"dependencies = ["oxjsonld","oxrdf",@@ -2869,9 +2872,9 @@ dependencies = [[[package]]name = "oxrdfxml"-version = "0.1.7"+version = "0.2.3"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "d8d4bf9c5331127f01efbd1245d90fd75b7c546a97cb3e95461121ce1ad5b1c8"+checksum = "cd5516ae083d09bc57ec65ed5ee97701481725de6ffaa83d968ab42a96157ba1"dependencies = ["oxilangtag","oxiri",@@ -2882,13 +2885,12 @@ dependencies = [[[package]]name = "oxrocksdb-sys"-version = "0.4.11"+version = "0.5.8"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "16430f45934d678cb6f9823e7c1bfdbdce9025f670ad85b642e46ffe5609e6ff"+checksum = "5b7ff9cbbbc3cd628be238ca7f22b4c31ab85c3fc1349ff452fd9fac78615e60"dependencies = ["bindgen","cc",- "libc",][[package]]@@ -2902,9 +2904,9 @@ dependencies = [[[package]]name = "oxttl"-version = "0.1.8"+version = "0.2.3"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "0d385f1776d7cace455ef6b7c54407838eff902ca897303d06eb12a26f4cf8a0"+checksum = "f03fd471bd54c23d76631c0a2677aa4bb308d905f6e491ee35dcb0732b7c5c6c"dependencies = ["memchr","oxilangtag",@@ -3778,6 +3780,12 @@ version = "1.0.23"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"+[[package]]+name = "ryu-js"+version = "1.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dd29631678d6fb0903b69223673e122c32e9ae559d0960a38d574695ebc0ea15"+[[package]]name = "same-file"version = "1.0.6"@@ -4075,9 +4083,9 @@ dependencies = [[[package]]name = "sparesults"-version = "0.2.5"+version = "0.3.3"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "f478f5ead16b6136bccee7a52ea43a615f8512086708f515e26ce33e0b184036"+checksum = "7e13362decdcbeb3fefadff1631238c835c112027221e83d217cc5779f5a81c2"dependencies = ["json-event-parser","memchr",@@ -4088,9 +4096,9 @@ dependencies = [[[package]]name = "spareval"-version = "0.1.4"+version = "0.2.6"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "f9d8ff5f1159e7416ed99160b962fa780851dddee133ef56e6b08a94023ea2c7"+checksum = "c8eab80b96dc836e4cf8fda72daa67ccc0244dc5303be5d4566e8fd04adbdde5"dependencies = ["hex","json-event-parser",@@ -4098,7 +4106,7 @@ dependencies = ["oxiri","oxrdf","oxsdatatypes",- "rand 0.8.5",+ "rand 0.9.2","regex","rustc-hash","sha1",@@ -4111,26 +4119,26 @@ dependencies = [[[package]]name = "spargebra"-version = "0.3.5"+version = "0.4.6"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "8907e262be4b4b363218f4688f5654d423a958aa4b8d7c7a7f898be591fa474e"+checksum = "46715eb957d1fe960cbbc0b713da8f78e2cb19df315b48fb09c9467a1c84f656"dependencies = ["oxilangtag","oxiri","oxrdf","peg",- "rand 0.8.5",+ "rand 0.9.2","thiserror",][[package]]name = "sparopt"-version = "0.2.1"+version = "0.3.6"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "1790bbdf13560c2afc245ab0f82a489003b3918e668ebd45c65fe46bfd7a1763"+checksum = "aed7a854b8ea67618f8ce69aabb0e904d7704226060e9d5a2930eb3136c3fa3b"dependencies = ["oxrdf",- "rand 0.8.5",+ "rand 0.9.2","spargebra",]diff --git a/Cargo.toml b/Cargo.tomlindex c986e2eb..ddfcd18e 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -16,7 +16,7 @@ axum = "0.8"tower-http = { version = "0.6", features = ["cors"] }tokio-util = "0.7"tokio = { version = "1", features = ["full"] }-oxigraph = "0.4"+oxigraph = "0.5"rusqlite = { version = "0.32", features = ["bundled"] }reqwest = { version = "0.12", features = ["json"] }schemars = "1"diff --git a/src/graph.rs b/src/graph.rsindex 56ba26dc..2a6342bc 100644--- a/src/graph.rs+++ b/src/graph.rs@@ -3,7 +3,7 @@ use std::sync::Mutex;use oxigraph::io::{RdfFormat, RdfParser, RdfSerializer};use oxigraph::model::*;-use oxigraph::sparql::QueryResults;+use oxigraph::sparql::{QueryResults, SparqlEvaluator};use oxigraph::store::Store;/// In-memory RDF graph store backed by Oxigraph.@@ -113,7 +113,11 @@ impl GraphStore {pub fn sparql_select(&self, query: &str) -> anyhow::Result<String> {let store = self.store.lock().unwrap();- match store.query(query)? {+ match SparqlEvaluator::new()+ .parse_query(query)?+ .on_store(&store)+ .execute()?+ {QueryResults::Solutions(solutions) => {let vars: Vec<String> = solutions.variables()@@ -211,7 +215,11 @@ impl GraphStore {let individual_query = "SELECT (COUNT(DISTINCT ?i) AS ?count) WHERE { ?i a ?c . FILTER(?c != <http://www.w3.org/2002/07/owl#Class> && ?c != <http://www.w3.org/2000/01/rdf-schema#Class> && ?c != <http://www.w3.org/2002/07/owl#ObjectProperty> && ?c != <http://www.w3.org/2002/07/owl#DatatypeProperty> && ?c != <http://www.w3.org/2002/07/owl#Ontology>) }";let count_from_query = |q: &str| -> usize {- let Ok(QueryResults::Solutions(solutions)) = store.query(q) else { return 0 };+ let Ok(prepared) = SparqlEvaluator::new().parse_query(q) else { return 0 };+ let Ok(QueryResults::Solutions(solutions)) = prepared+ .on_store(&store)+ .execute()+ else { return 0 };let Some(Ok(row)) = solutions.into_iter().next() else { return 0 };let Some(Term::Literal(lit)) = row.get("count") else { return 0 };lit.value().parse().unwrap_or(0)diff --git a/src/ontology.rs b/src/ontology.rsindex 1985b0e4..f26c7ca6 100644--- a/src/ontology.rs+++ b/src/ontology.rs@@ -2,7 +2,7 @@ use std::collections::HashSet;use std::io::Cursor;use oxigraph::io::{RdfFormat, RdfParser};-use oxigraph::sparql::QueryResults;+use oxigraph::sparql::{QueryResults, SparqlEvaluator};use oxigraph::store::Store;use crate::graph::GraphStore;@@ -109,7 +109,11 @@ impl OntologyService {FILTER NOT EXISTS { ?class <http://www.w3.org/2000/01/rdf-schema#label> ?label }}"#;- if let Ok(QueryResults::Solutions(solutions)) = store.query(query) {+ if let Ok(QueryResults::Solutions(solutions)) = SparqlEvaluator::new()+ .parse_query(query)+ .map_err(anyhow::Error::from)+ .and_then(|p| p.on_store(store).execute().map_err(anyhow::Error::from))+ {for row in solutions.flatten() {if let Some(term) = row.get("class") {issues.push(serde_json::json!({@@ -131,7 +135,11 @@ impl OntologyService {FILTER NOT EXISTS { ?class <http://www.w3.org/2000/01/rdf-schema#comment> ?comment }}"#;- if let Ok(QueryResults::Solutions(solutions)) = store.query(query) {+ if let Ok(QueryResults::Solutions(solutions)) = SparqlEvaluator::new()+ .parse_query(query)+ .map_err(anyhow::Error::from)+ .and_then(|p| p.on_store(store).execute().map_err(anyhow::Error::from))+ {for row in solutions.flatten() {if let Some(term) = row.get("class") {issues.push(serde_json::json!({@@ -153,7 +161,11 @@ impl OntologyService {FILTER NOT EXISTS { ?prop <http://www.w3.org/2000/01/rdf-schema#domain> ?d }}"#;- if let Ok(QueryResults::Solutions(solutions)) = store.query(query) {+ if let Ok(QueryResults::Solutions(solutions)) = SparqlEvaluator::new()+ .parse_query(query)+ .map_err(anyhow::Error::from)+ .and_then(|p| p.on_store(store).execute().map_err(anyhow::Error::from))+ {for row in solutions.flatten() {if let Some(term) = row.get("prop") {issues.push(serde_json::json!({diff --git a/src/shacl.rs b/src/shacl.rsindex 382f1078..c26f7176 100644--- a/src/shacl.rs+++ b/src/shacl.rs@@ -1,6 +1,6 @@use crate::graph::GraphStore;use oxigraph::io::{RdfFormat, RdfParser};-use oxigraph::sparql::QueryResults;+use oxigraph::sparql::{QueryResults, SparqlEvaluator};use oxigraph::store::Store;use std::collections::HashMap;use std::io::Cursor;@@ -371,7 +371,11 @@ fn query_solutions(store: &Store,query: &str,) -> anyhow::Result<Vec<HashMap<String, String>>> {- match store.query(query)? {+ match SparqlEvaluator::new()+ .parse_query(query)?+ .on_store(store)+ .execute()?+ {QueryResults::Solutions(solutions) => {let vars: Vec<String> = solutions.variables()