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
A node shape's own constraints are evaluated, for every target form (#231)
Fabio Rovaiccce3d768643
diff --git a/src/shacl.rs b/src/shacl.rsindex f703500f..200bca7d 100644--- a/src/shacl.rs+++ b/src/shacl.rs@@ -31,12 +31,20 @@ use std::sync::Arc;/// not evaluated), or on the node shape itself (`sh:closed`, `sh:deactivated`)./// A target that selects no nodes reaches the same null verdict by the other/// route, `unmatched_shapes`. Reporting success for rules that were never run is-/// the one failure mode this validator must not have, and one case of it is-/// open. The node-shape complement only inspects shapes returned by the-/// `sh:targetClass` discovery query, so a shape whose only target is-/// `sh:targetNode`, `sh:targetSubjectsOf` or `sh:targetObjectsOf` has its-/// node-level constraints dropped with no `skipped_constraints` entry and the-/// verdict comes back true.+/// the one failure mode this validator must not have.+///+/// A node shape's OWN constraints (the value constraints asserted on the shape+/// rather than under `sh:property`) are evaluated against the focus node+/// itself, which is what SHACL defines as the value nodes of a node shape:+/// `sh:class`, `sh:datatype`, `sh:nodeKind`, `sh:hasValue`, `sh:in`,+/// `sh:pattern` (with `sh:flags`), `sh:minLength`, `sh:maxLength` and the four+/// range bounds, for every one of the four target forms. Until this existed+/// every one of them was recorded as skipped and 31 of the 32 `core/node`+/// cases in the W3C suite came back UNDETERMINED. The node-level constructs+/// this validator still does not evaluate (`sh:closed`, `sh:not`, `sh:and`,+/// `sh:or`, `sh:xone`, `sh:node`, `sh:languageIn`, `sh:equals`, `sh:disjoint`,+/// the qualified forms) are recorded in `skipped_constraints` whatever target+/// form selected the shape, and suppress the verdict.pub struct ShaclValidator;impl ShaclValidator {@@ -291,7 +299,11 @@ impl ShaclValidator {sh:node)) && !(?pred IN (sh:closed, sh:deactivated)&& isLiteral(?o) && datatype(?o) = xsd:boolean && ?o = false- ))+ ) && !(NOT EXISTS { ?shape sh:path ?_selfPathNL } && ?pred IN (+ sh:class, sh:datatype, sh:nodeKind, sh:hasValue, sh:in,+ sh:pattern, sh:flags, sh:minLength, sh:maxLength,+ sh:minInclusive, sh:maxInclusive, sh:minExclusive, sh:maxExclusive+ )))}"#,)?;@@ -366,6 +378,208 @@ impl ShaclValidator {}};+ // 2b. The node shape's OWN value constraints, evaluated against the+ // focus node. SHACL 2.1.2: for a node shape the value nodes are the+ // focus node itself, so every check below is the property-shape+ // form with the focus node standing in for the path's values. Only+ // shapes without `sh:path` come here; a shape carrying one is a+ // property shape and is handled by the loop that follows.+ //+ // Each (predicate, object) pair is one constraint, so a shape with+ // two `sh:class` values is checked twice and reports twice, as the+ // specification asks. Collected as rows rather than OPTIONALs for+ // that reason: an OPTIONAL per predicate multiplies the rows and+ // would report every constraint once per value of every other.+ let node_own = query_solutions_bound(+ &shapes_store,+ r#"+ PREFIX sh: <http://www.w3.org/ns/shacl#>+ SELECT ?shape ?pred ?obj WHERE {+ ?shape ?pred ?obj .+ FILTER NOT EXISTS { ?shape sh:path ?_ownPath }+ FILTER(?pred IN (+ sh:class, sh:datatype, sh:nodeKind, sh:hasValue, sh:pattern,+ sh:minLength, sh:maxLength, sh:minInclusive, sh:maxInclusive,+ sh:minExclusive, sh:maxExclusive, sh:flags, sh:message, sh:severity+ ))+ }+ "#,+ "shape",+ &shape_node,+ )?;+ // `sh:in` is a list and is collected by its own query. It is+ // collected BEFORE the emptiness test on purpose: a node shape whose+ // only constraint is `sh:in` has an empty `node_own`, and gating the+ // whole block on that returned `conforms: true` with no record.+ let in_members: Vec<String> = query_solutions_bound(+ &shapes_store,+ r#"+ PREFIX sh: <http://www.w3.org/ns/shacl#>+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>+ SELECT ?shape ?member WHERE {+ ?shape sh:in/rdf:rest*/rdf:first ?member .+ FILTER NOT EXISTS { ?shape sh:path ?_ownPathIn }+ }+ "#,+ "shape",+ &shape_node,+ )?+ .iter()+ .filter_map(|r| r.get("member").map(|m| m.trim().to_string()))+ .collect();+ if !node_own.is_empty() || !in_members.is_empty() {+ let own: Vec<(String, String)> = node_own+ .iter()+ .filter_map(|r| Some((short_sh(r.get("pred")?), r.get("obj")?.trim().to_string())))+ .collect();+ let pick = |k: &str| own.iter().find(|(p, _)| p == k).map(|(_, v)| v.clone());+ let own_message = pick("message").map(|m| strip_quotes(&m)).unwrap_or_default();+ let own_severity = pick("severity")+ .map(|s| {+ let s = strip_angle_brackets(&s);+ s.rsplit('#').next().unwrap_or("Violation").to_string()+ })+ .unwrap_or_else(|| "Violation".to_string());+ let own_flags = pick("flags").map(|f| strip_quotes(&f));++ // (constraint, SPARQL test that is TRUE for a violating focus node, default message)+ let mut checks: Vec<(String, String, String)> = Vec::new();+ for (pred, obj) in &own {+ match pred.as_str() {+ "class" => {+ let cls = strip_angle_brackets(obj);+ checks.push((+ "class".into(),+ format!("NOT EXISTS {{ ?focus <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>/<http://www.w3.org/2000/01/rdf-schema#subClassOf>* <{cls}> }}"),+ format!("Value is not a SHACL instance of <{cls}>"),+ ));+ }+ "datatype" => {+ let dt = strip_angle_brackets(obj);+ if datatype_is_indistinguishable_in_store(&dt) {+ skipped.push(serde_json::json!({+ "shape": strip_angle_brackets(&shape_iri),+ "constraint": "sh:datatype",+ "reason": format!(+ "the store does not preserve <{dt}>; a conforming value and a widened one are the same term, so this cannot be decided"+ ),+ }));+ continue;+ }+ // A literal whose lexical form is not in the+ // datatype's lexical space is ill-typed and violates+ // sh:datatype (SHACL 4.1.2), and DATATYPE() alone+ // cannot see that: "aldi"^^xsd:integer answers+ // xsd:integer. The lexical test below catches it for+ // the datatypes whose lexical space is written down.+ let ill = ill_typed_test(&dt, "focus")+ .map(|t| format!(" || {t}"))+ .unwrap_or_default();+ checks.push((+ "datatype".into(),+ format!("(!isLiteral(?focus) || DATATYPE(?focus) != <{dt}>{ill})"),+ format!("Value does not have datatype <{dt}>"),+ ));+ }+ "nodeKind" => match node_kind_test(&strip_angle_brackets(obj), "focus") {+ Some(test) => checks.push((+ "nodeKind".into(),+ format!("!({test})"),+ format!("Value is not of node kind <{}>", strip_angle_brackets(obj)),+ )),+ None => skipped.push(serde_json::json!({+ "shape": strip_angle_brackets(&shape_iri),+ "constraint": "sh:nodeKind",+ "reason": format!("unknown node kind {obj}; it was not evaluated"),+ })),+ },+ "hasValue" => checks.push((+ "hasValue".into(),+ format!("?focus != {obj}"),+ format!("Value is not {obj}"),+ )),+ "pattern" => {+ let pattern = strip_quotes(obj);+ let escaped = pattern.replace('\\', "\\\\").replace('"', "\\\"");+ let flags = own_flags+ .as_ref()+ .map(|f| format!(", \"{}\"", f.replace('\\', "\\\\").replace('"', "\\\"")))+ .unwrap_or_default();+ // A blank node has no string form to match and is a+ // violation of any pattern (SHACL 4.4.3).+ checks.push((+ "pattern".into(),+ format!("(isBlank(?focus) || !REGEX(STR(?focus), \"{escaped}\"{flags}))"),+ format!("Value does not match pattern {pattern}"),+ ));+ }+ "minLength" | "maxLength" => {+ let Ok(bound) = strip_quotes(obj).parse::<u64>() else {+ skipped.push(serde_json::json!({+ "shape": strip_angle_brackets(&shape_iri),+ "constraint": format!("sh:{pred}"),+ "reason": "bound is not a non-negative integer; it was not evaluated",+ }));+ continue;+ };+ let (cmp, wording) =+ if pred == "minLength" { ("<", "shorter than") } else { (">", "longer than") };+ checks.push((+ pred.clone(),+ format!("(isBlank(?focus) || STRLEN(STR(?focus)) {cmp} {bound})"),+ format!("Value is {wording} {bound} characters"),+ ));+ }+ "minInclusive" | "maxInclusive" | "minExclusive" | "maxExclusive" => {+ let ok = match pred.as_str() {+ "minInclusive" => ">=",+ "maxInclusive" => "<=",+ "minExclusive" => ">",+ _ => "<",+ };+ // A value that cannot be compared with the bound (a+ // string against an integer, an IRI against anything)+ // is a violation under SHACL 4.5, and a comparison+ // error inside FILTER would otherwise drop the row+ // and hide it. COALESCE turns the error into false,+ // which is the reported outcome.+ checks.push((+ pred.clone(),+ format!("!COALESCE(?focus {ok} {obj}, false)"),+ format!("Value is not {ok} {obj}"),+ ));+ }+ _ => {}+ }+ }+ if !in_members.is_empty() {+ checks.push((+ "in".into(),+ format!("?focus NOT IN ({})", in_members.join(", ")),+ "Value is not one of the permitted sh:in terms".into(),+ ));+ }+ for (constraint, test, default_msg) in checks {+ let query = format!(+ r#"SELECT DISTINCT ?focus WHERE {{+ {focus_pattern}+ FILTER({test})+ }}"#+ );+ for row in &graph_sparql_select(graph, scope, &query)? {+ if let Some(focus) = row.get("focus") {+ let msg = if own_message.is_empty() { default_msg.clone() } else { own_message.clone() };+ violations.push(attribute(&shape_iri, &shape_iri, serde_json::json!({+ "severity": own_severity,+ "focus_node": strip_angle_brackets(focus),+ "constraint": constraint,+ "message": msg,+ })));+ }+ }+ }+ }+let props = query_solutions_bound(&shapes_store,&format!(@@ -2806,6 +3020,34 @@ fn constraint_component(constraint: &str) -> String {format!("http://www.w3.org/ns/shacl#{name}ConstraintComponent")}+/// `Some(test)` that is TRUE when `?var` is a literal of `datatype` whose+/// lexical form is outside that datatype's lexical space, for the datatypes+/// whose lexical space is written down here. `None` for any other datatype,+/// where an ill-typed literal cannot be told from a well-typed one.+///+/// The patterns are the XSD lexical spaces, not the value spaces: `01` is a+/// valid integer lexical form and `1.` a valid decimal one. Backslashes are+/// doubled once for the SPARQL string literal they are spliced into.+fn ill_typed_test(datatype: &str, var: &str) -> Option<String> {+ const XSD: &str = "http://www.w3.org/2001/XMLSchema#";+ let local = datatype.strip_prefix(XSD)?;+ let re = match local {+ "integer" => "^[+-]?[0-9]+$",+ "decimal" => "^[+-]?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)$",+ "double" | "float" => "^([+-]?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([eE][+-]?[0-9]+)?|[+-]?INF|NaN)$",+ "boolean" => "^(true|false|1|0)$",+ "date" => "^-?[0-9]{4}-[0-9]{2}-[0-9]{2}(Z|[+-][0-9]{2}:[0-9]{2})?$",+ "dateTime" => "^-?[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})?$",+ _ => return None,+ };+ Some(format!("(DATATYPE(?{var}) = <{datatype}> && !REGEX(STR(?{var}), \"{re}\"))"))+}++/// `<http://www.w3.org/ns/shacl#class>` -> `class`, for the node-level rows.+fn short_sh(pred: &str) -> String {+ strip_angle_brackets(pred).rsplit('#').next().unwrap_or_default().to_string()+}+fn strip_angle_brackets(s: &str) -> String {let s = s.trim();if s.starts_with('<') && s.ends_with('>') {diff --git a/tests/shacl_node_target_skip_test.rs b/tests/shacl_node_target_skip_test.rsindex f3e6c767..dc3c6d0a 100644--- a/tests/shacl_node_target_skip_test.rs+++ b/tests/shacl_node_target_skip_test.rs@@ -1,13 +1,18 @@-//! A node-level constraint must reach `skipped_constraints` whatever target form-//! selected the shape.+//! A node shape's own constraints are EVALUATED whatever target form selected+//! the shape, and the ones this validator cannot evaluate are recorded.//!-//! The node-shape complement builds its set of known shapes from the-//! `sh:targetClass` discovery query alone. A shape whose only target is-//! `sh:targetNode`, `sh:targetSubjectsOf` or `sh:targetObjectsOf` was therefore-//! filtered out of that check, so an unimplemented constraint asserted directly-//! on it was dropped with no record and the verdict came back `true`. Reporting-//! success for a rule that was never run is the one failure mode this validator-//! is built not to have, so it gets a test that fails before the fix.+//! History, because the test is shaped by it. The node-shape complement once+//! built its set of known shapes from the `sh:targetClass` discovery query+//! alone, so a shape whose only target was `sh:targetNode`,+//! `sh:targetSubjectsOf` or `sh:targetObjectsOf` had an unimplemented+//! constraint dropped with no record and the verdict came back `true`. That was+//! closed by widening the complement. Then every node-level value constraint+//! was still only RECORDED, never run: `sh:class` directly on a node shape+//! produced `conforms: null` over data that plainly violated it, and 31 of the+//! 32 `core/node` cases in the W3C suite were UNDETERMINED. This file now pins+//! both halves: a value constraint on the node shape reports a violation for+//! every target form, and a construct that is not evaluated is still recorded+//! for every target form.use open_ontologies::graph::GraphStore;use open_ontologies::shacl::ShaclValidator;@@ -22,88 +27,125 @@ const DATA: &str = r#"ex:alice a ex:Person ; ex:addr ex:notAnAddress .ex:notAnAddress a ex:Person .+ ex:home a ex:Address ."#;-/// `sh:class` directly on the node shape is not evaluated by this validator, so-/// it must be recorded. The only target here is `sh:targetNode`.-const TARGET_NODE_SHAPES: &str = r#"- @prefix sh: <http://www.w3.org/ns/shacl#> .- @prefix ex: <http://example.org/> .- ex:AliceShape a sh:NodeShape ;- sh:targetNode ex:alice ;- sh:class ex:Address .-"#;--const TARGET_SUBJECTS_OF_SHAPES: &str = r#"- @prefix sh: <http://www.w3.org/ns/shacl#> .- @prefix ex: <http://example.org/> .- ex:AddrSubjectShape a sh:NodeShape ;- sh:targetSubjectsOf ex:addr ;- sh:class ex:Address .-"#;--const TARGET_OBJECTS_OF_SHAPES: &str = r#"- @prefix sh: <http://www.w3.org/ns/shacl#> .- @prefix ex: <http://example.org/> .- ex:AddrObjectShape a sh:NodeShape ;- sh:targetObjectsOf ex:addr ;- sh:class ex:Address .-"#;--fn report(shapes: &str) -> serde_json::Value {- let graph = Arc::new(GraphStore::new());- graph.load_turtle(DATA, None).expect("load");- let json = ShaclValidator::validate(&graph, shapes).expect("validate");- serde_json::from_str(&json).expect("parse")+/// The four target forms, each selecting `ex:alice` (or, for objectsOf, the+/// object `ex:notAnAddress`), each asserting the node-level constraint given.+fn shapes(target: &str, constraint: &str) -> String {+ format!(+ r#"+ @prefix sh: <http://www.w3.org/ns/shacl#> .+ @prefix ex: <http://example.org/> .+ ex:Shape a sh:NodeShape ;+ {target} ;+ {constraint} .+ "#+ )}-fn assert_recorded_and_suppressed(shapes: &str, label: &str) {- let r = report(shapes);-- let skipped = r["skipped_constraints"]- .as_array()- .cloned()- .unwrap_or_default();- assert!(- skipped- .iter()- .any(|s| s["constraint"].as_str().unwrap_or_default().ends_with("#class")),- "{label}: node-level sh:class was dropped with no skipped_constraints entry: {r}"- );+const TARGETS: [(&str, &str); 4] = [+ ("sh:targetClass", "sh:targetClass ex:Person"),+ ("sh:targetNode", "sh:targetNode ex:alice"),+ ("sh:targetSubjectsOf", "sh:targetSubjectsOf ex:addr"),+ ("sh:targetObjectsOf", "sh:targetObjectsOf ex:addr"),+];- assert!(- r["conforms"].is_null(),- "{label}: an unevaluated constraint must suppress the verdict, got {}: {r}",- r["conforms"]- );+fn report(shapes: &str) -> serde_json::Value {+ let store = Arc::new(GraphStore::new());+ store.load_turtle(DATA, None).unwrap();+ let out = ShaclValidator::validate(&store, shapes).unwrap();+ serde_json::from_str(&out).unwrap()}+/// `sh:class ex:Address` on the node shape: none of the selected nodes is an+/// Address, so every target form must report a ClassConstraintComponent+/// violation and a false verdict. Not null: the constraint ran.#[test]-fn a_target_node_shape_records_its_unevaluated_node_constraint() {- assert_recorded_and_suppressed(TARGET_NODE_SHAPES, "sh:targetNode");+fn a_node_level_class_constraint_is_evaluated_for_every_target_form() {+ for (label, target) in TARGETS {+ let r = report(&shapes(target, "sh:class ex:Address"));+ assert_eq!(+ r["conforms"],+ false,+ "{label}: node-level sh:class was not evaluated (verdict {}): {r}",+ r["conforms"]+ );+ let hits: Vec<&serde_json::Value> = r["violations"]+ .as_array()+ .unwrap()+ .iter()+ .filter(|v| {+ v["source_constraint_component"]+ == "http://www.w3.org/ns/shacl#ClassConstraintComponent"+ && v["source_shape"] == "http://example.org/Shape"+ })+ .collect();+ assert!(!hits.is_empty(), "{label}: no class violation attributed to the node shape: {r}");+ assert!(+ hits.iter().all(|v| v.get("result_path").is_none()),+ "{label}: a node-shape result carries a result_path; node shapes have none: {r}"+ );+ assert!(+ r["skipped_constraints"]+ .as_array()+ .map(|s| s.iter().all(|e| e["constraint"] != "sh:class"))+ .unwrap_or(true),+ "{label}: sh:class was evaluated AND recorded as skipped: {r}"+ );+ }}+/// The gate can pass: the same constraint over a node that satisfies it is a+/// true verdict, not null and not false.#[test]-fn a_target_subjects_of_shape_records_its_unevaluated_node_constraint() {- assert_recorded_and_suppressed(TARGET_SUBJECTS_OF_SHAPES, "sh:targetSubjectsOf");+fn a_satisfied_node_level_constraint_conforms() {+ let r = report(&shapes("sh:targetNode ex:home", "sh:class ex:Address"));+ assert_eq!(r["conforms"], true, "{r}");+ assert_eq!(r["violation_count"], 0, "{r}");}+/// The other node-level value constraints, each over a node that violates it.#[test]-fn a_target_objects_of_shape_records_its_unevaluated_node_constraint() {- assert_recorded_and_suppressed(TARGET_OBJECTS_OF_SHAPES, "sh:targetObjectsOf");+fn the_other_node_level_value_constraints_are_evaluated() {+ for (constraint, component) in [+ ("sh:nodeKind sh:Literal", "NodeKindConstraintComponent"),+ ("sh:hasValue ex:home", "HasValueConstraintComponent"),+ ("sh:in ( ex:home ex:bob )", "InConstraintComponent"),+ ("sh:pattern \"^http://example.org/b\"", "PatternConstraintComponent"),+ ("sh:minLength 100", "MinLengthConstraintComponent"),+ ("sh:maxLength 3", "MaxLengthConstraintComponent"),+ // An IRI cannot be compared with a number; SHACL 4.5 makes that a violation.+ ("sh:minInclusive 1", "MinInclusiveConstraintComponent"),+ ] {+ let r = report(&shapes("sh:targetNode ex:alice", constraint));+ assert_eq!(r["conforms"], false, "{constraint}: {r}");+ assert!(+ r["violations"].as_array().unwrap().iter().any(|v| {+ v["source_constraint_component"] == format!("http://www.w3.org/ns/shacl#{component}")+ }),+ "{constraint}: no {component} result: {r}"+ );+ }}-/// The control. A `sh:targetClass` shape already reached the complement before-/// the fix, so this passes either way and catches a fix that works by-/// disabling the check rather than widening it.+/// A node-level construct this validator does not evaluate must still reach+/// `skipped_constraints` and suppress the verdict, for every target form. The+/// data would pass it, so a fix that "works" by dropping the record shows up+/// as a true verdict here.#[test]-fn a_target_class_shape_still_records_its_unevaluated_node_constraint() {- const SHAPES: &str = r#"- @prefix sh: <http://www.w3.org/ns/shacl#> .- @prefix ex: <http://example.org/> .- ex:PersonShape a sh:NodeShape ;- sh:targetClass ex:Person ;- sh:class ex:Address .- "#;- assert_recorded_and_suppressed(SHAPES, "sh:targetClass");+fn an_unevaluated_node_level_construct_is_recorded_for_every_target_form() {+ for (label, target) in TARGETS {+ let r = report(&shapes(target, "sh:languageIn ( \"en\" )"));+ let skipped = r["skipped_constraints"].as_array().cloned().unwrap_or_default();+ assert!(+ skipped.iter().any(|e| e["constraint"] == "http://www.w3.org/ns/shacl#languageIn"),+ "{label}: node-level sh:languageIn was dropped with no skipped_constraints entry: {r}"+ );+ assert!(+ r["conforms"].is_null(),+ "{label}: a run with an unevaluated constraint reported {} instead of null",+ r["conforms"]+ );+ }}diff --git a/tests/shacl_test.rs b/tests/shacl_test.rsindex 5d39e1b6..24ecc30b 100644--- a/tests/shacl_test.rs+++ b/tests/shacl_test.rs@@ -397,9 +397,13 @@ fn skipped_names(v: &serde_json::Value, shape: &str, constraint: &str) -> bool {#[test]fn test_node_shape_constraints_reach_the_tri_state_verdict() {- // sh:closed, a node-level sh:not and sh:nodeKind are not implemented. Each- // must be recorded as skipped under its own IRI, and the verdict must be- // null, not a pass. Data: ex:a carries ex:mech, undeclared by any shape.+ // sh:closed and a node-level sh:not are not implemented. Each must be+ // recorded as skipped under its own IRI, and the verdict must be null,+ // not a pass. Data: ex:a carries ex:mech, undeclared by any shape.+ //+ // sh:nodeKind used to be in this list. A node shape's own value+ // constraints are now EVALUATED against the focus node, so it is asserted+ // below as a verdict in each direction rather than as a recorded gap.let store = store_with(NOT_DATA);let cases = [("sh:closed true", "closed"),@@ -407,7 +411,6 @@ fn test_node_shape_constraints_reach_the_tri_state_verdict() {"sh:not [ sh:property [ sh:path ex:mech ; sh:hasValue ex:bad ] ]","not",),- ("sh:nodeKind sh:IRI", "nodeKind"),];for (constraint_ttl, local) in cases {let shapes = format!(@@ -428,6 +431,23 @@ fn test_node_shape_constraints_reach_the_tri_state_verdict() {"{local}: must be recorded as skipped on ex:S: {v}");}+ // Evaluated, both ways: ex:a is an IRI.+ for (constraint_ttl, want) in [("sh:nodeKind sh:IRI", true), ("sh:nodeKind sh:Literal", false)] {+ let shapes = format!(+ r#"+ @prefix sh: <http://www.w3.org/ns/shacl#> .+ @prefix ex: <http://example.org/> .+ ex:S a sh:NodeShape ; sh:targetClass ex:Thing ; {constraint_ttl} .+ "#+ );+ let v: serde_json::Value =+ serde_json::from_str(&ShaclValidator::validate(&store, &shapes).unwrap()).unwrap();+ assert_eq!(v["conforms"], want, "{constraint_ttl} is evaluated on the focus node: {v}");+ assert!(+ !skipped_names(&v, "http://example.org/S", &format!("{SH_NS}nodeKind")),+ "{constraint_ttl}: evaluated AND recorded as skipped: {v}"+ );+ }}#[test]diff --git a/tests/w3c_shacl_baseline.json b/tests/w3c_shacl_baseline.jsonindex 08156ce8..e475f464 100644--- a/tests/w3c_shacl_baseline.json+++ b/tests/w3c_shacl_baseline.json@@ -3,49 +3,49 @@"suite_commit": "94d8bc2bd4fc4fdc6f2964d1ec4a892329e05f06","counts": {"total": 120,- "pass": 35,- "fail": 17,- "undetermined": 68,+ "pass": 61,+ "fail": 15,+ "undetermined": 44,"error": 0},- "partial_compliance": 36,+ "partial_compliance": 61,"outcomes": {"core/complex/personexample": "UNDETERMINED","core/complex/shacl-shacl": "UNDETERMINED","core/misc/deactivated-001": "UNDETERMINED",- "core/misc/deactivated-002": "UNDETERMINED",- "core/misc/message-001": "UNDETERMINED",- "core/misc/severity-001": "UNDETERMINED",- "core/misc/severity-002": "FAIL",+ "core/misc/deactivated-002": "PASS",+ "core/misc/message-001": "PASS",+ "core/misc/severity-001": "PASS",+ "core/misc/severity-002": "PASS","core/node/and-001": "UNDETERMINED","core/node/and-002": "UNDETERMINED",- "core/node/class-001": "UNDETERMINED",- "core/node/class-002": "UNDETERMINED",- "core/node/class-003": "UNDETERMINED",+ "core/node/class-001": "PASS",+ "core/node/class-002": "PASS",+ "core/node/class-003": "PASS","core/node/closed-001": "UNDETERMINED","core/node/closed-002": "UNDETERMINED",- "core/node/datatype-001": "UNDETERMINED",- "core/node/datatype-002": "UNDETERMINED",+ "core/node/datatype-001": "PASS",+ "core/node/datatype-002": "PASS","core/node/disjoint-001": "UNDETERMINED","core/node/equals-001": "UNDETERMINED",- "core/node/hasValue-001": "UNDETERMINED",- "core/node/in-001": "UNDETERMINED",+ "core/node/hasValue-001": "PASS",+ "core/node/in-001": "PASS","core/node/languageIn-001": "UNDETERMINED",- "core/node/maxExclusive-001": "UNDETERMINED",- "core/node/maxInclusive-001": "UNDETERMINED",- "core/node/maxLength-001": "UNDETERMINED",- "core/node/minExclusive-001": "UNDETERMINED",- "core/node/minInclusive-001": "UNDETERMINED",- "core/node/minInclusive-002": "UNDETERMINED",- "core/node/minInclusive-003": "UNDETERMINED",- "core/node/minLength-001": "UNDETERMINED",+ "core/node/maxExclusive-001": "PASS",+ "core/node/maxInclusive-001": "PASS",+ "core/node/maxLength-001": "PASS",+ "core/node/minExclusive-001": "PASS",+ "core/node/minInclusive-001": "PASS",+ "core/node/minInclusive-002": "PASS",+ "core/node/minInclusive-003": "PASS",+ "core/node/minLength-001": "PASS","core/node/node-001": "UNDETERMINED",- "core/node/nodeKind-001": "UNDETERMINED",+ "core/node/nodeKind-001": "PASS","core/node/not-001": "UNDETERMINED","core/node/not-002": "UNDETERMINED","core/node/or-001": "PASS",- "core/node/pattern-001": "UNDETERMINED",- "core/node/pattern-002": "UNDETERMINED",+ "core/node/pattern-001": "PASS",+ "core/node/pattern-002": "PASS","core/node/qualified-001": "UNDETERMINED","core/node/xone-001": "UNDETERMINED","core/node/xone-duplicate": "UNDETERMINED",@@ -59,7 +59,7 @@"core/path/path-sequence-duplicate-001": "UNDETERMINED","core/path/path-strange-001": "FAIL","core/path/path-strange-002": "FAIL",- "core/path/path-unused-001": "UNDETERMINED",+ "core/path/path-unused-001": "PASS","core/path/path-zeroOrMore-001": "UNDETERMINED","core/path/path-zeroOrOne-001": "UNDETERMINED","core/property/and-001": "UNDETERMINED",@@ -100,11 +100,11 @@"core/property/qualifiedValueShapesDisjoint-001": "UNDETERMINED","core/property/uniqueLang-001": "UNDETERMINED","core/property/uniqueLang-002": "UNDETERMINED",- "core/targets/multipleTargets-001": "UNDETERMINED",+ "core/targets/multipleTargets-001": "PASS","core/targets/targetClass-001": "PASS",- "core/targets/targetClassImplicit-001": "UNDETERMINED",+ "core/targets/targetClassImplicit-001": "PASS","core/targets/targetNode-001": "PASS",- "core/targets/targetObjectsOf-001": "UNDETERMINED",+ "core/targets/targetObjectsOf-001": "PASS","core/targets/targetSubjectsOf-001": "PASS","core/targets/targetSubjectsOf-002": "PASS","core/validation-reports/shared": "FAIL",@@ -120,7 +120,7 @@"sparql/pre-binding/pre-binding-003": "FAIL","sparql/pre-binding/pre-binding-004": "FAIL","sparql/pre-binding/pre-binding-005": "FAIL",- "sparql/pre-binding/pre-binding-006": "FAIL",+ "sparql/pre-binding/pre-binding-006": "UNDETERMINED","sparql/pre-binding/pre-binding-007": "PASS","sparql/pre-binding/shapesGraph-001": "FAIL","sparql/pre-binding/unsupported-sparql-001": "UNDETERMINED",