From 2a03bd6cbefebb2f2a377359dfef82ec9d8e2d21 Mon Sep 17 00:00:00 2001 From: EttoreM Date: Sun, 25 Jan 2026 09:25:42 +0000 Subject: [PATCH 1/3] Merged 12_check_phase.tll files. --- .../{should => }/12_check_phase.ttl | 112 +++++++++++++++++- .../five-safes-crate/may/12_check_phase.ttl | 56 --------- .../five-safes-crate/must/12_check_phase.ttl | 93 --------------- 3 files changed, 111 insertions(+), 150 deletions(-) rename rocrate_validator/profiles/five-safes-crate/{should => }/12_check_phase.ttl (65%) delete mode 100644 rocrate_validator/profiles/five-safes-crate/may/12_check_phase.ttl delete mode 100644 rocrate_validator/profiles/five-safes-crate/must/12_check_phase.ttl diff --git a/rocrate_validator/profiles/five-safes-crate/should/12_check_phase.ttl b/rocrate_validator/profiles/five-safes-crate/12_check_phase.ttl similarity index 65% rename from rocrate_validator/profiles/five-safes-crate/should/12_check_phase.ttl rename to rocrate_validator/profiles/five-safes-crate/12_check_phase.ttl index faf74459..d352d170 100644 --- a/rocrate_validator/profiles/five-safes-crate/should/12_check_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/12_check_phase.ttl @@ -23,11 +23,87 @@ @prefix xsd: . +#=== MUST shapes ===# + +five-safes-crate:CheckValueObjectHasDescriptiveNameAndIsAssessAction + a sh:NodeShape ; + sh:name "CheckValue" ; + sh:description "" ; + + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + + SELECT ?this + WHERE { + ?this schema:additionalType shp:CheckValue . + } + """ ; + ] ; + + sh:property [ + sh:path rdf:type ; + sh:minCount 1 ; + sh:hasValue schema:AssessAction; + sh:severity sh:Violation ; + sh:message "CheckValue MUST be a `AssessAction`." ; + ] ; + + sh:property [ + sh:a sh:PropertyShape ; + sh:name "name" ; + sh:description "CheckValue MUST have a human readable name string." ; + sh:path schema:name ; + sh:datatype xsd:string ; + sh:severity sh:Violation ; + sh:message "CheckValue MUST have a human readable name string." ; + ] . + + +five-safes-crate:CheckValueActionStatusMustHaveAllowedValues + a sh:NodeShape ; + sh:name "CheckValue" ; + sh:description "" ; + + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + + SELECT ?this + WHERE { + ?this schema:additionalType shp:CheckValue ; + schema:actionStatus ?status . + } + """ ; + ] ; + + sh:property [ + a sh:PropertyShape ; + sh:name "ActionStatus" ; + sh:path schema:actionStatus ; + sh:in ( + "http://schema.org/PotentialActionStatus" + "http://schema.org/ActiveActionStatus" + "http://schema.org/CompletedActionStatus" + "http://schema.org/FailedActionStatus" + ) ; + sh:severity sh:Violation ; + sh:message "`CheckValue` --> `actionStatus` MUST have one of the allowed values." ; + ] . + + +#=== SHOULD shapes ===# + five-safes-crate:RootDataEntityShouldMentionCheckValueObject a sh:NodeShape ; sh:name "RootDataEntity" ; sh:targetClass ro-crate:RootDataEntity ; sh:description "" ; + sh:severity sh:Warning ; sh:sparql [ a sh:SPARQLConstraint ; @@ -44,7 +120,6 @@ five-safes-crate:RootDataEntityShouldMentionCheckValueObject } } """ ; - sh:severity sh:Warning ; sh:message "RootDataEntity SHOULD mention a check value object." ; ] . @@ -188,3 +263,38 @@ five-safes-crate:CheckValueShouldHaveActionStatus sh:severity sh:Warning ; sh:message "CheckValue SHOULD have actionStatus property." ; ] . + + +#=== MAY shapes ===# + +five-safes-crate:CheckValueMayHaveStartTime + a sh:NodeShape ; + sh:name "CheckValue" ; + sh:description "" ; + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + SELECT ?this + WHERE { + ?this schema:additionalType shp:CheckValue ; + schema:actionStatus ?status . + FILTER(?status IN ( + "http://schema.org/CompletedActionStatus", + "http://schema.org/FailedActionStatus", + "http://schema.org/ActiveActionStatus" + )) + } + """ ; + ] ; + + sh:property [ + a sh:PropertyShape ; + sh:name "StartTime" ; + sh:path schema:startTime ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:severity sh:Info ; + sh:message "`CheckValue` MAY have the `startTime` property." ; + ] . diff --git a/rocrate_validator/profiles/five-safes-crate/may/12_check_phase.ttl b/rocrate_validator/profiles/five-safes-crate/may/12_check_phase.ttl deleted file mode 100644 index 0e741f6c..00000000 --- a/rocrate_validator/profiles/five-safes-crate/may/12_check_phase.ttl +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright (c) 2025 eScience Lab, The University of Manchester -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -@prefix ro: <./> . -@prefix ro-crate: . -@prefix five-safes-crate: . -@prefix rdf: . -@prefix schema: . -@prefix purl: . -@prefix sh: . -@prefix validator: . -@prefix xsd: . - - -five-safes-crate:CheckValueMayHaveStartTime - a sh:NodeShape ; - sh:name "CheckValue" ; - sh:description "" ; - sh:target [ - a sh:SPARQLTarget ; - sh:select """ - PREFIX schema: - PREFIX shp: - SELECT ?this - WHERE { - ?this schema:additionalType shp:CheckValue ; - schema:actionStatus ?status . - FILTER(?status IN ( - "http://schema.org/CompletedActionStatus", - "http://schema.org/FailedActionStatus", - "http://schema.org/ActiveActionStatus" - )) - } - """ ; - ] ; - - sh:property [ - a sh:PropertyShape ; - sh:name "StartTime" ; - sh:path schema:startTime ; - sh:minCount 1 ; - sh:maxCount 1 ; - sh:severity sh:Info ; - sh:message "`CheckValue` MAY have the `startTime` property." ; - ] . diff --git a/rocrate_validator/profiles/five-safes-crate/must/12_check_phase.ttl b/rocrate_validator/profiles/five-safes-crate/must/12_check_phase.ttl deleted file mode 100644 index caecb165..00000000 --- a/rocrate_validator/profiles/five-safes-crate/must/12_check_phase.ttl +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright (c) 2025 eScience Lab, The University of Manchester -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -@prefix ro: <./> . -@prefix ro-crate: . -@prefix five-safes-crate: . -@prefix rdf: . -@prefix schema: . -@prefix purl: . -@prefix sh: . -@prefix validator: . -@prefix xsd: . - - -five-safes-crate:CheckValueObjectHasDescriptiveNameAndIsAssessAction - a sh:NodeShape ; - sh:name "CheckValue" ; - sh:description "" ; - - sh:target [ - a sh:SPARQLTarget ; - sh:select """ - PREFIX schema: - PREFIX shp: - - SELECT ?this - WHERE { - ?this schema:additionalType shp:CheckValue . - } - """ ; - ] ; - - sh:property [ - sh:path rdf:type ; - sh:minCount 1 ; - sh:hasValue schema:AssessAction; - sh:severity sh:Violation ; - sh:message "CheckValue MUST be a `AssessAction`." ; - ] ; - - sh:property [ - sh:a sh:PropertyShape ; - sh:name "name" ; - sh:description "CheckValue MUST have a human readable name string." ; - sh:path schema:name ; - sh:datatype xsd:string ; - sh:severity sh:Violation ; - sh:message "CheckValue MUST have a human readable name string." ; - ] . - -five-safes-crate:CheckValueActionStatusMustHaveAllowedValues - a sh:NodeShape ; - sh:name "CheckValue" ; - sh:description "" ; - - sh:target [ - a sh:SPARQLTarget ; - sh:select """ - PREFIX schema: - PREFIX shp: - - SELECT ?this - WHERE { - ?this schema:additionalType shp:CheckValue ; - schema:actionStatus ?status . - } - """ ; - ] ; - - sh:property [ - a sh:PropertyShape ; - sh:name "ActionStatus" ; - sh:path schema:actionStatus ; - sh:in ( - "http://schema.org/PotentialActionStatus" - "http://schema.org/ActiveActionStatus" - "http://schema.org/CompletedActionStatus" - "http://schema.org/FailedActionStatus" - ) ; - sh:severity sh:Violation ; - sh:message "`CheckValue` --> `actionStatus` MUST have one of the allowed values." ; - ] . From c571c736a2986494f92d58f812121bfff9f90f75 Mon Sep 17 00:00:00 2001 From: EttoreM Date: Sun, 25 Jan 2026 12:13:22 +0000 Subject: [PATCH 2/3] =?UTF-8?q?Preserved=20the=20original=20@context=20whe?= =?UTF-8?q?n=20re-serializing=20the=20temp=20crate=20so=20CI=20won?= =?UTF-8?q?=E2=80=99t=20downgrade=20it=20to=201.1.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/shared.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/shared.py b/tests/shared.py index c6d76af0..56dbf0b3 100644 --- a/tests/shared.py +++ b/tests/shared.py @@ -155,7 +155,8 @@ def do_entity_test( rocrate_graph.update(rocrate_entity_mod_sparql) # save the updated RO-Crate metadata - context = "https://w3id.org/ro/crate/1.1/context" + # preserve the original context to avoid forcing a downgrade + context = rocrate.get("@context", "https://w3id.org/ro/crate/1.2/context") rocrate_graph.serialize( Path(temp_rocrate_path, "ro-crate-metadata.json"), format="json-ld", From 67e33df20f52f046ddf489d2ab0ddf410f7dd80a Mon Sep 17 00:00:00 2001 From: EttoreM Date: Sun, 25 Jan 2026 19:38:07 +0000 Subject: [PATCH 3/3] patches on shared.py --- tests/shared.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/shared.py b/tests/shared.py index 56dbf0b3..80756ea5 100644 --- a/tests/shared.py +++ b/tests/shared.py @@ -97,6 +97,16 @@ def replace_uri_in_graph(graph, old_uri_str, new_uri_str): return g +def _uses_https_schema(graph: rdflib.Graph) -> bool: + for s, p, o in graph.triples((None, None, None)): + for term in (s, p, o): + if isinstance(term, rdflib.URIRef) and str(term).startswith( + "https://schema.org/" + ): + return True + return False + + def do_entity_test( rocrate_path: Union[Path, str], requirement_severity: models.Severity, @@ -152,6 +162,12 @@ def do_entity_test( if rocrate_entity_mod_sparql is not None: rocrate_graph = load_graph_and_preserve_relative_ids(rocrate) + if _uses_https_schema(rocrate_graph): + rocrate_entity_mod_sparql = rocrate_entity_mod_sparql.replace( + "http://schema.org/", + "https://schema.org/", + ) + rocrate_graph.update(rocrate_entity_mod_sparql) # save the updated RO-Crate metadata