Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

sh:node to a shape whose own sh:datatype the store cannot tell apart is refused rather than answered

FABIOTESSba3fde04bb7b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9f39e225..e5276591 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -56,6 +56,11 @@ All notable changes to Open Ontologies are documented here.
over values of exactly that type. Each now records the constraint in
`skipped_constraints` with the direct path's reason and suppresses the
verdict. W3C columns unchanged (61, 53).
+- **`sh:node` to a shape whose own `sh:datatype` the store cannot tell apart
+ is refused rather than answered.** The shape compiler refused such a
+ datatype on a property inside the referenced shape and not on the shape
+ itself, so every value the store had widened was reported. The `sh:node` is
+ now recorded as not evaluated. W3C columns unchanged.
- **A custom `sh:severity` keeps its namespace in the JSON report** (#334).
Every path set `severity` to the text after the last `#` of the declared
IRI, and every reader takes a bare name as `sh:`, so W3C
diff --git a/src/shacl.rs b/src/shacl.rs
index 34802063..abce2d00 100644
--- a/src/shacl.rs
+++ b/src/shacl.rs
@@ -2831,7 +2831,18 @@ fn compile_node_shape(
"EXISTS {{ ?{var} <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>/<http://www.w3.org/2000/01/rdf-schema#subClassOf>* <{}> }}",
strip_angle_brackets(obj)
)),
- "datatype" => clauses.push(datatype_conforms(&strip_angle_brackets(obj), var)),
+ "datatype" => {
+ // Refused for the same reason as on a property inside the
+ // shape, below: the store cannot tell the datatype from the
+ // one it derives from. Only the property form was guarded, so
+ // `sh:node` to a shape declaring `sh:datatype xsd:int` itself
+ // reported every value the store had widened to xsd:integer.
+ let dt = strip_angle_brackets(obj);
+ if datatype_is_indistinguishable_in_store(&dt) {
+ return None;
+ }
+ clauses.push(datatype_conforms(&dt, var))
+ }
"nodeKind" => clauses.push(node_kind_test(&strip_angle_brackets(obj), var)?),
_ => return None,
}
diff --git a/tests/shacl_datatype_indistinguishable_test.rs b/tests/shacl_datatype_indistinguishable_test.rs
index d3a13ee2..54a6fa94 100644
--- a/tests/shacl_datatype_indistinguishable_test.rs
+++ b/tests/shacl_datatype_indistinguishable_test.rs
@@ -175,6 +175,19 @@ fn a_qualified_shape_naming_an_unpreserved_datatype_is_not_answered() {
);
}
+/// `sh:node` to a shape whose OWN constraint is the datatype. The compiler
+/// already refused the same datatype on a property inside the referenced shape
+/// and not on the shape itself.
+#[test]
+fn a_node_shape_reference_naming_an_unpreserved_datatype_is_not_answered() {
+ refused(
+ "ex:S a sh:NodeShape ; sh:targetClass ex:Profile ;
+ sh:property [ sh:path ex:passes ; sh:node ex:Count ] .
+ ex:Count a sh:NodeShape ; sh:datatype xsd:nonNegativeInteger .",
+ "sh:node",
+ );
+}
+
/// The guard must not swallow the decidable members: the same four paths over
/// `xsd:integer` and `xsd:string` still give a verdict and still catch a value
/// that matches none of them.