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
Withdraw the result deduplication: it broke agreement with the oracle
FABIOTESSc271fbe768ad
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 696eb94d..993c50af 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -57,9 +57,6 @@ All notable changes to Open Ontologies are documented here.indistinguishable, which is the case #131 was filed about. pyshacl returnsthe property shape and this now agrees. The node shape is still reported,under `node_shape`.-- **Duplicate results.** One shape carrying two target declarations that select- the same node reported every violation on that node twice. A validation- report is a set.- **The reasoner was not a fixpoint of its own rule set.** Only the `rdf:type`,`rdfs:subClassOf` and `rdfs:subPropertyOf` indices were rebuilt eachiteration; every schema index was filtered once out of the run-startdiff --git a/docs/lean-certificates.md b/docs/lean-certificates.mdindex cd06b4fa..c98c3879 100644--- a/docs/lean-certificates.md+++ b/docs/lean-certificates.md@@ -154,5 +154,8 @@ Stated rather than discovered later.but if you materialise into a store that already held inferences they appear in `asserted.tsv` asassumptions with nothing marking them derived. Use `inference_graph: true` (decision 0001) whenthat distinction matters.-- **`focus_nodes` in a SHACL report is a sum over target declarations**, so a node selected by two- declarations of one shape is counted twice. The violations themselves are deduplicated.+- **A SHACL report double-counts a node selected by two target declarations of one shape.** Both+ `focus_nodes` and `violation_count` are affected. Collapsing identical results is not the fix:+ SHACL emits one result per SPARQL solution, pyshacl does too, and deduplicating breaks an exact+ agreement with it. The fix is to union a shape's focus nodes across its declarations, which is a+ change to the evaluation loop and is not done.diff --git a/src/shacl.rs b/src/shacl.rsindex 7aab8cb4..ac3b93c8 100644--- a/src/shacl.rs+++ b/src/shacl.rs@@ -1721,21 +1721,24 @@ impl ShaclValidator {let nothing_matched = (!targets.is_empty() && focus_nodes_total == 0)|| (targets.is_empty() && declared_any_shape);- // A validation report is a SET of results. One shape may carry two- // target declarations that select the same node (a `sh:targetClass` and- // a `sh:targetNode` for one of its instances), and the loop above walks- // targets, so that node was checked twice and every violation on it was- // reported twice. Two results identical in every field are one result.+ // Deliberately NOT deduplicated, and this was measured before it was+ // decided. One shape carrying two target declarations that select the+ // same node does get checked twice, which inflates `violation_count`+ // and `focus_nodes`. Collapsing identical results looked like the fix+ // and is not: SHACL 5.3.2 emits one result per SPARQL solution, so a+ // constraint returning several solutions for one focus node produces+ // several results that are identical wherever the extra solution binds+ // nothing this report carries. pyshacl emits those too. On the+ // 39-shape corpus from issue #132 both engines return 249 results over+ // 245 distinct (focus node, shape) pairs, and deduplicating took this+ // engine to 245 and broke an exact agreement.//- // This does not touch `focus_nodes`, which is still a sum over targets- // and so still counts such a node twice. Making that a distinct count- // means enumerating focus nodes rather than counting them in SPARQL,- // which is a memory trade on large graphs and a separate decision.- {- let mut seen: HashSet<String> = HashSet::new();- violations.retain(|v| seen.insert(v.to_string()));- }-+ // The real fix for the double-checked node is to take the union of a+ // shape's focus nodes across its target declarations rather than to+ // walk targets, which is a change to the evaluation loop and not to+ // the report. Until then the inflation is a documented limitation,+ // because a wrong count is cheaper than a validator that drops results+ // the specification says to emit.let mut report = serde_json::json!({"violation_count": violations.len(),"violations": violations,