Skip to content

Commit 145188c

Browse files
authored
Merge pull request #41 from eScienceLab/37-implement-workflow-execution-phase-ruleset
Implemented rules for the Workflow Execution Phase.
2 parents 1984245 + 2b75192 commit 145188c

6 files changed

Lines changed: 534 additions & 2 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright (c) 2025 eScience Lab, The University of Manchester
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
@prefix ro: <./> .
16+
@prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> .
17+
@prefix five-safes-crate: <https://github.com/eScienceLab/rocrate-validator/profiles/five-safes-crate/> .
18+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
19+
@prefix schema: <http://schema.org/> .
20+
@prefix sh: <http://www.w3.org/ns/shacl#> .
21+
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
22+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
23+
24+
25+
five-safes-crate:WorkflowexecutionObjectHasStartTimeIfBegun
26+
a sh:NodeShape ;
27+
sh:name "WorkflowExecution" ;
28+
sh:description "The workflow execution object MAY have a startTime if execution was initiated." ;
29+
30+
sh:target [
31+
a sh:SPARQLTarget ;
32+
sh:select """
33+
PREFIX schema: <http://schema.org/>
34+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
35+
36+
SELECT ?this
37+
WHERE {
38+
?this rdf:type schema:CreateAction ;
39+
schema:actionStatus ?status .
40+
FILTER(?status IN (
41+
"http://schema.org/CompletedActionStatus",
42+
"http://schema.org/FailedActionStatus",
43+
"http://schema.org/ActiveActionStatus"
44+
))
45+
}
46+
""" ;
47+
] ;
48+
49+
sh:property [
50+
a sh:PropertyShape ;
51+
sh:name "StartTime" ;
52+
sh:path schema:startTime ;
53+
sh:minCount 1 ;
54+
sh:maxCount 1 ;
55+
sh:severity sh:Info ;
56+
sh:description "The workflow execution object MAY have a startTime if execution was initiated." ;
57+
sh:message "The workflow execution object MAY have a startTime if execution was initiated." ;
58+
] .
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Copyright (c) 2025 eScience Lab, The University of Manchester
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
@prefix ro: <./> .
16+
@prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> .
17+
@prefix five-safes-crate: <https://github.com/eScienceLab/rocrate-validator/profiles/five-safes-crate/> .
18+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
19+
@prefix schema: <http://schema.org/> .
20+
@prefix purl: <http://purl.org/dc/terms/> .
21+
@prefix sh: <http://www.w3.org/ns/shacl#> .
22+
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
23+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
24+
25+
26+
five-safes-crate:WorkflowMustHaveDescriptiveName
27+
a sh:NodeShape ;
28+
sh:name "WorkflowExecution" ;
29+
sh:targetClass schema:CreateAction ;
30+
31+
sh:property [
32+
sh:a sh:PropertyShape ;
33+
sh:name "name" ;
34+
sh:minCount 1 ;
35+
sh:description "Workflow (CreateAction) MUST have a name string of at least 10 characters." ;
36+
sh:path schema:name ;
37+
sh:datatype xsd:string ;
38+
sh:minLength 10 ;
39+
sh:severity sh:Violation ;
40+
sh:message "Workflow (CreateAction) MUST have a name string of at least 10 characters." ;
41+
] .
42+
43+
44+
five-safes-crate:WorkflowexecutionObjectHasCompliantStartTimeFormat
45+
a sh:NodeShape ;
46+
sh:name "WorkflowExecution" ;
47+
sh:description "The startTime of the workflow execution object MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
48+
sh:targetClass schema:CreateAction ;
49+
50+
sh:property [
51+
a sh:PropertyShape ;
52+
sh:name "StartTime" ;
53+
sh:path schema:startTime ;
54+
sh:minCount 0 ;
55+
sh:pattern "^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt][0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|z|[+-][0-9]{2}:[0-9]{2})$" ;
56+
sh:severity sh:Violation ;
57+
sh:message "The startTime of the workflow execution object MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
58+
] .
59+
60+
61+
five-safes-crate:WorkflowexecutionObjectHasCompliantEndTimeFormat
62+
a sh:NodeShape ;
63+
sh:name "WorkflowExecution" ;
64+
sh:description "The endTime of the workflow execution object MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
65+
sh:targetClass schema:CreateAction ;
66+
67+
sh:property [
68+
a sh:PropertyShape ;
69+
sh:name "EndTime" ;
70+
sh:path schema:endTime ;
71+
sh:minCount 0 ;
72+
sh:pattern "^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt][0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|z|[+-][0-9]{2}:[0-9]{2})$" ;
73+
sh:severity sh:Violation ;
74+
sh:message "The endTime of the workflow execution object MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
75+
] .
76+
77+
78+
five-safes-crate:WorkflowMustHaveActionStatusWithAllowedValues
79+
a sh:NodeShape ;
80+
sh:name "WorkflowExecution" ;
81+
sh:targetClass schema:CreateAction ;
82+
sh:property [
83+
a sh:PropertyShape ;
84+
sh:minCount 1 ;
85+
sh:name "actionStatus" ;
86+
sh:description "WorkflowExecution MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
87+
sh:path schema:actionStatus ;
88+
sh:in (
89+
"http://schema.org/PotentialActionStatus"
90+
"http://schema.org/ActiveActionStatus"
91+
"http://schema.org/CompletedActionStatus"
92+
"http://schema.org/FailedActionStatus"
93+
) ;
94+
sh:severity sh:Violation ;
95+
sh:message "WorkflowExecution MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
96+
] .
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Copyright (c) 2025 eScience Lab, The University of Manchester
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
@prefix ro: <./> .
16+
@prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> .
17+
@prefix five-safes-crate: <https://github.com/eScienceLab/rocrate-validator/profiles/five-safes-crate/> .
18+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
19+
@prefix schema: <http://schema.org/> .
20+
@prefix purl: <http://purl.org/dc/terms/> .
21+
@prefix sh: <http://www.w3.org/ns/shacl#> .
22+
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
23+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
24+
25+
26+
27+
five-safes-crate:RootDataEntityShouldMentionWorkflow
28+
a sh:NodeShape ;
29+
sh:name "RootDataEntity" ;
30+
sh:description "RootDataEntity SHOULD mention workflow execution object (typed CreateAction)." ;
31+
sh:targetClass ro-crate:RootDataEntity ;
32+
sh:sparql [
33+
a sh:SPARQLConstraint ;
34+
sh:name "mentions" ;
35+
sh:select """
36+
PREFIX schema: <http://schema.org/>
37+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
38+
SELECT $this
39+
WHERE {
40+
41+
FILTER NOT EXISTS {
42+
$this schema:mentions ?workflowExecution .
43+
?workflowExecution rdf:type schema:CreateAction .
44+
}
45+
}
46+
""" ;
47+
sh:severity sh:Warning ;
48+
sh:message "RootDataEntity SHOULD mention workflow execution object (typed CreateAction)." ;
49+
] .
50+
51+
52+
53+
five-safes-crate:WorkflowexecutionObjectHasEndTimeIfEnded
54+
a sh:NodeShape ;
55+
sh:name "WorkflowExecution" ;
56+
sh:description "The workflow execution object SHOULD have an endTime property if it has ended." ;
57+
58+
sh:target [
59+
a sh:SPARQLTarget ;
60+
sh:select """
61+
PREFIX schema: <http://schema.org/>
62+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
63+
64+
SELECT ?this
65+
WHERE {
66+
?this rdf:type schema:CreateAction ;
67+
schema:actionStatus ?status .
68+
FILTER(?status IN (
69+
"http://schema.org/CompletedActionStatus",
70+
"http://schema.org/FailedActionStatus"
71+
))
72+
}
73+
""" ;
74+
] ;
75+
76+
sh:property [
77+
a sh:PropertyShape ;
78+
sh:name "EndTime" ;
79+
sh:path schema:endTime ;
80+
sh:minCount 1 ;
81+
sh:maxCount 1 ;
82+
sh:severity sh:Warning ;
83+
sh:description "The workflow execution object SHOULD have an endTime property if it has ended." ;
84+
sh:message "The workflow execution object SHOULD have an endTime property if it has ended." ;
85+
] .

tests/data/crates/valid/five-safes-crate-result/ro-crate-metadata.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@
106106
{
107107
"@id": "#query-37252371-c937-43bd-a0a7-3680b48c0538",
108108
"@type": "CreateAction",
109-
"actionStatus": "http://schema.org/CompleteActionStatus",
109+
"startTime": "2023-04-18T12:12:00+01:00",
110+
"endTime": "2023-04-19T16:59:59+01:00",
111+
"actionStatus": "http://schema.org/CompletedActionStatus",
110112
"agent": {
111113
"@id": "https://orcid.org/0000-0001-9842-9718"
112114
},

0 commit comments

Comments
 (0)