Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,35 @@
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .


ro-crate:FindWorkflowRunAction a sh:NodeShape, validator:HiddenShape;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code block is duplicated across quite a few files. If we have to change anything we'll need to change this across ~10 different files. Can this be centralised?

Copy link
Author

@EttoreM EttoreM Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, but as far as I know there is no import directive for ttl files.

I will investigate whether the import is possibly done via code, and, in that case, centralise that code block.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My impression is that all the .ttl files are loaded together and combined after selecting profiles but before the validation is run - this is what allows us to use ro-crate:RootDataEntity freely, and it's why this particular line works to disable a check from the base spec:

ro-crate:conformsToROCrateSpec sh:deactivated true .

So I don't think we need to import another .ttl file in order to reuse this block, we just need to make sure it's in a .ttl file that definitely gets loaded for this profile, which are the ones in the must/ folder (should/ and may/ only seem to be loaded if those severities are explicitly selected).

I tried removing this block from all files except must/7_requested_workflow_run.ttl and it seems to work. Can you try that on your side @EttoreM ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(also, more for info, there is an import mechanism in SHACL - https://book.validatingrdf.com/bookHtml011.html#sec126 - but I think this won't work in these files as the shapes are not directly resolvable at the URI we use for the profile)

Copy link
Author

@EttoreM EttoreM Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @elichad. My last commit does precisely what you suggests, with the exception that the code-block in question has been put in its own file under the MUST folder. It seems to be as a cleaner solution rather than having it in any of the existing file. In the end, that code-block does not enforce a SHACL rules, so to speak, but rather modify the graph before SHACL validation can be run.

Also I made the dependency of WorkflowRun on RootDataEntity explicit. To do this I added sh:order 0 in FindRootDataEntity (2_root_data_entity_metadata.ttl), and sh:order 1 in FindWorkflowRunAction . This ensures that RootDataEntity is inferred first, then the WorkflowRun.

sh:name "Identify the CreateAction Entity that corresponds to the Workflow run" ;
sh:description """The Workflow Run is the CreateAction entity that refers to Workflow run.
This is identified by checking that the CreateAction entity has an `instrument` property
that references the same entity as the `mainEntity` property of the Root Data Entity.""" ;
sh:target [
a sh:SPARQLTarget ;
sh:prefixes ro-crate:sparqlPrefixes ;
sh:select """
SELECT ?this
WHERE {
?this a schema:CreateAction ;
schema:instrument ?instrument .
?root schema:mainEntity ?instrument ;
a schema:Dataset .
?metadatafile schema:about ?root .
FILTER(contains(str(?metadatafile), "ro-crate-metadata.json"))
}
"""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than repeating the SPARQL query which is used to identify ro-crate:RootDataEntity can we not search here for that instead? Or, do we need to ensure that this action can be run out of sequence with that action?

Copy link
Author

@EttoreM EttoreM Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot use RootDataEntity before the graph is modified accordingly.
Ideally we will add RootdataEntity and WorkflowRun in this order and only once.

The problem is there no import directive in a "ttl" file, otherwise I would have done it as you suggested.

I will investigate whether the import is possibly done via code rather than via ttl.

] ;

sh:rule [
a sh:TripleRule ;
sh:subject sh:this ;
sh:predicate rdf:type ;
sh:object ro-crate:WorkflowRun ;
] .


five-safes-crate:WorkflowexecutionObjectHasStartTimeIfBegun
a sh:NodeShape ;
sh:name "WorkflowExecution" ;
Expand All @@ -34,11 +63,11 @@ five-safes-crate:WorkflowexecutionObjectHasStartTimeIfBegun
a sh:SPARQLTarget ;
sh:select """
PREFIX schema: <http://schema.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rocrate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/>

SELECT ?this
WHERE {
?this rdf:type schema:CreateAction ;
?this a rocrate:WorkflowRun ;
schema:actionStatus ?status .
FILTER(?status IN (
"http://schema.org/CompletedActionStatus",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,35 @@
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .


ro-crate:FindWorkflowRunAction a sh:NodeShape, validator:HiddenShape;
sh:name "Identify the CreateAction Entity that corresponds to the Workflow run" ;
sh:description """The Workflow Run is the CreateAction entity that refers to Workflow run.
This is identified by checking that the CreateAction entity has an `instrument` property
that references the same entity as the `mainEntity` property of the Root Data Entity.""" ;
sh:target [
a sh:SPARQLTarget ;
sh:prefixes ro-crate:sparqlPrefixes ;
sh:select """
SELECT ?this
WHERE {
?this a schema:CreateAction ;
schema:instrument ?instrument .
?root schema:mainEntity ?instrument ;
a schema:Dataset .
?metadatafile schema:about ?root .
FILTER(contains(str(?metadatafile), "ro-crate-metadata.json"))
}
"""
] ;

sh:rule [
a sh:TripleRule ;
sh:subject sh:this ;
sh:predicate rdf:type ;
sh:object ro-crate:WorkflowRun ;
] .


five-safes-crate:ResponsibleProject
a sh:NodeShape ;
sh:name "Responsible Project" ;
Expand All @@ -30,7 +59,7 @@ five-safes-crate:ResponsibleProject
sh:prefixes ro-crate:sparqlPrefixes ;
sh:select """
SELECT DISTINCT ?this WHERE {
?action a schema:CreateAction ;
?action a ro-crate:WorkflowRun ;
schema:agent ?agent .
?agent schema:memberOf ?this .
}
Expand All @@ -53,4 +82,4 @@ five-safes-crate:ResponsibleProject
sh:minCount 1 ;
sh:severity sh:Info ;
sh:message """The Responsible Project does not have the property `member`.""" ;
] .
] .
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,62 @@
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .


ro-crate:FindWorkflowRunAction a sh:NodeShape, validator:HiddenShape;
sh:name "Identify the CreateAction Entity that corresponds to the Workflow run" ;
sh:description """The Workflow Run is the CreateAction entity that refers to Workflow run.
This is identified by checking that the CreateAction entity has an `instrument` property
that references the same entity as the `mainEntity` property of the Root Data Entity.""" ;
sh:target [
a sh:SPARQLTarget ;
sh:prefixes ro-crate:sparqlPrefixes ;
sh:select """
SELECT ?this
WHERE {
?this a schema:CreateAction ;
schema:instrument ?instrument .
?root schema:mainEntity ?instrument ;
a schema:Dataset .
?metadatafile schema:about ?root .
FILTER(contains(str(?metadatafile), "ro-crate-metadata.json"))
}
"""
] ;

sh:rule [
a sh:TripleRule ;
sh:subject sh:this ;
sh:predicate rdf:type ;
sh:object ro-crate:WorkflowRun ;
] .


five-safes-crate:WorkflowMustHaveDescriptiveName
a sh:NodeShape ;
sh:name "WorkflowExecution" ;
sh:targetClass schema:CreateAction ;
sh:targetClass ro-crate:WorkflowRun ;

sh:property [
a sh:PropertyShape ;
sh:name "name" ;
sh:minCount 1 ;
sh:description "Workflow (CreateAction) MUST have a name string of at least 10 characters." ;
sh:description "WorkflowRun MUST have a name string of at least 10 characters." ;
sh:path schema:name ;
sh:datatype xsd:string ;
sh:minLength 10 ;
sh:severity sh:Violation ;
sh:message "Workflow (CreateAction) MUST have a name string of at least 10 characters." ;
sh:message "WorkflowRun MUST have a name string of at least 10 characters." ;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just going to comment on this one change - but this applies through the changes we've made.

I don't think that we should be mentioning WorkflowRun in any error messages that the validator returns to the end user. This is because WorkflowRun is an internal definition we have created, that has no existence outside of the validator. Instead we should retain the old messages which mention the CreateAction definition.

] .


five-safes-crate:WorkflowMustHaveActionStatusWithAllowedValues
a sh:NodeShape ;
sh:name "WorkflowExecution" ;
sh:targetClass schema:CreateAction ;
sh:targetClass ro-crate:WorkflowRun ;
sh:property [
a sh:PropertyShape ;
sh:minCount 1 ;
sh:name "actionStatus" ;
sh:description "WorkflowExecution MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
sh:description "WorkflowRun MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
sh:path schema:actionStatus ;
sh:in (
"http://schema.org/PotentialActionStatus"
Expand All @@ -58,5 +87,5 @@ five-safes-crate:WorkflowMustHaveActionStatusWithAllowedValues
"http://schema.org/FailedActionStatus"
) ;
sh:severity sh:Violation ;
sh:message "WorkflowExecution MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
sh:message "WorkflowRun MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
] .
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,37 @@
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .


five-safes-crate:RootDataEntityMentionsCreateAction
ro-crate:FindWorkflowRunAction a sh:NodeShape, validator:HiddenShape;
sh:name "Identify the CreateAction Entity that corresponds to the Workflow run" ;
sh:description """The Workflow Run is the CreateAction entity that refers to Workflow run.
This is identified by checking that the CreateAction entity has an `instrument` property
that references the same entity as the `mainEntity` property of the Root Data Entity.""" ;
sh:target [
a sh:SPARQLTarget ;
sh:prefixes ro-crate:sparqlPrefixes ;
sh:select """
SELECT ?this
WHERE {
?this a schema:CreateAction ;
schema:instrument ?instrument .
?root schema:mainEntity ?instrument ;
a schema:Dataset .
?metadatafile schema:about ?root .
FILTER(contains(str(?metadatafile), "ro-crate-metadata.json"))
}
"""
] ;

# Expand data graph with triples from the file data entity
sh:rule [
a sh:TripleRule ;
sh:subject sh:this ;
sh:predicate rdf:type ;
sh:object ro-crate:WorkflowRun ;
] .


five-safes-crate:RootDataEntityMentionsWorkflowRun
a sh:NodeShape ;
sh:name "RootDataEntity" ;
sh:targetClass ro-crate:RootDataEntity ;
Expand All @@ -33,42 +63,43 @@ five-safes-crate:RootDataEntityMentionsCreateAction
sh:name "mentions" ;
sh:path schema:mentions;
sh:qualifiedValueShape [
sh:class schema:CreateAction ;
sh:class ro-crate:WorkflowRun ;
] ;
sh:qualifiedMinCount 1 ;
sh:severity sh:Violation ;
sh:message "`RootDataEntity` MUST reference at least one `CreateAction` through `mentions`" ;
sh:message "`RootDataEntity` MUST reference at least one `WorkflowRun` through `mentions`" ;
] .


five-safes-crate:CreateActionInstrumentAndStatus
five-safes-crate:WorkflowRunExistence
a sh:NodeShape ;
sh:name "CreateAction" ;
sh:targetClass schema:CreateAction ;
sh:description "" ;
sh:severity sh:Violation ; # Apply to all property shapes / constraints below
sh:name "RootDataEntity" ;
sh:targetClass ro-crate:RootDataEntity ;
sh:description "" ;

sh:property [
a sh:PropertyShape ;
sh:name "instrument" ;
sh:path schema:instrument;
sh:minCount 1 ;
sh:message "`CreateAction` MUST have the `instrument` property" ;
] ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:name "instrument" ;
sh:name "WorkflowRun" ;
sh:prefixes ro-crate:sparqlPrefixes ;
sh:select """
SELECT $this ?main ?instrument
WHERE {
?root schema:mainEntity ?main .
$this schema:instrument ?instrument .
FILTER (?instrument != ?main)
}
SELECT $this
WHERE {
FILTER NOT EXISTS {
?workflowRun a ro-crate:WorkflowRun .
}
}
""" ;
sh:message "`CreateAction` --> `instrument` MUST reference the same entity as `Root Data Entity` --> `mainEntity`" ;
] ;
sh:message "The crate MUST contain at least one `WorkflowRun` entity" ;
] .


five-safes-crate:WorkflowRunObject
a sh:NodeShape ;
sh:name "WorkflowRun" ;
sh:targetClass ro-crate:WorkflowRun ;
sh:description "" ;
sh:severity sh:Violation ; # Apply to all property shapes / constraints below

sh:sparql [
a sh:SPARQLConstraint ;
sh:prefixes ro-crate:sparqlPrefixes ;
Expand All @@ -80,5 +111,5 @@ five-safes-crate:CreateActionInstrumentAndStatus
FILTER NOT EXISTS { ?object a ?type . }
}
""" ;
sh:message "Each `object` in `CreateAction` MUST reference an existing entity." ;
] .
sh:message "Each `object` in `WorkflowRun` MUST reference an existing entity." ;
] .
37 changes: 37 additions & 0 deletions rocrate_validator/profiles/five-safes-crate/ontology.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (c) 2024-2026 CRS4
#
# 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 owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .
@prefix rocrate: <https://w3id.org/ro/crate/1.1/> .
@prefix bioschemas: <https://bioschemas.org/> .
@prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> .
@prefix isa-ro-crate: <https://github.com/crs4/rocrate-validator/profiles/isa-ro-crate/> .

<urn:absolute:.> rdf:type owl:Ontology ;
owl:versionIRI <urn:absolute:1.0> .

# # #################################################################
# # # Classes
# # #################################################################

# Declare a WorkflowRun class
ro-crate:WorkflowRun rdf:type owl:Class ;
rdfs:subClassOf schema:CreateAction ;
rdfs:label "WorkflowRun"@en .
Loading
Loading