forked from crs4/rocrate-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Check Phase Ruleset #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d6c9070
First chunk of rules implemented. Missing rules that still need to be…
EttoreM 974b84d
Added extra tests and added startDate in CheckValue entity of RO-Crat…
EttoreM a58d89e
Added tests for rules 1-7.
EttoreM 8949a7a
Added the remaining python tests.
EttoreM 3bebd04
Ammended linting errors
EttoreM c8a70b2
Ammended duplicated name for tests.
EttoreM 08070ac
Removed linting error
EttoreM 18898b0
Removed linting error - 2
EttoreM e080c23
Removed linting error - 3
EttoreM 88a050e
Added condition for the MAY have startTime and SHOULD have endTime.
EttoreM c429269
Provided RFC 339 pattern for timestamps in relevant messages.
EttoreM 6635be9
Allowed for comma to separate seconds from fractions of seconds in ti…
EttoreM eb5384a
Addressed Doug's comments on this PR.
EttoreM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
rocrate_validator/profiles/five-safes-crate/may/12_check_phase.ttl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # 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: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> . | ||
| @prefix five-safes-crate: <https://github.com/eScienceLab/rocrate-validator/profiles/five-safes-crate/> . | ||
| @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
| @prefix schema: <http://schema.org/> . | ||
| @prefix purl: <http://purl.org/dc/terms/> . | ||
| @prefix sh: <http://www.w3.org/ns/shacl#> . | ||
| @prefix validator: <https://github.com/crs4/rocrate-validator/> . | ||
| @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
|
|
||
|
|
||
| five-safes-crate:CheckValueMayHaveStartTime | ||
| a sh:NodeShape ; | ||
| sh:name "CheckValue" ; | ||
| sh:description "" ; | ||
| sh:target [ | ||
| a sh:SPARQLTarget ; | ||
| sh:select """ | ||
| PREFIX schema: <http://schema.org/> | ||
| PREFIX shp: <https://w3id.org/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." ; | ||
| ] . |
149 changes: 149 additions & 0 deletions
149
rocrate_validator/profiles/five-safes-crate/must/12_check_phase.ttl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| # 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: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> . | ||
| @prefix five-safes-crate: <https://github.com/eScienceLab/rocrate-validator/profiles/five-safes-crate/> . | ||
| @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
| @prefix schema: <http://schema.org/> . | ||
| @prefix purl: <http://purl.org/dc/terms/> . | ||
| @prefix sh: <http://www.w3.org/ns/shacl#> . | ||
| @prefix validator: <https://github.com/crs4/rocrate-validator/> . | ||
| @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
|
|
||
|
|
||
| five-safes-crate:CheckValueObjectHasDescriptiveNameAndIsAssessAction | ||
| a sh:NodeShape ; | ||
| sh:name "CheckValue" ; | ||
| sh:description "" ; | ||
|
|
||
| sh:target [ | ||
| a sh:SPARQLTarget ; | ||
| sh:select """ | ||
| PREFIX schema: <http://schema.org/> | ||
| PREFIX shp: <https://w3id.org/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 `schema: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:CheckValueStartTimeMustFollowISOStandard | ||
| a sh:NodeShape ; | ||
| sh:name "CheckValue" ; | ||
| sh:description "" ; | ||
| sh:target [ | ||
| a sh:SPARQLTarget ; | ||
| sh:select """ | ||
| PREFIX schema: <http://schema.org/> | ||
| PREFIX shp: <https://w3id.org/shp#> | ||
| SELECT ?this | ||
| WHERE { | ||
| ?this schema:additionalType shp:CheckValue ; | ||
| schema:startTime ?o | ||
|
|
||
| } | ||
| """ ; | ||
| ] ; | ||
|
|
||
| sh:property [ | ||
| a sh:PropertyShape ; | ||
| sh:name "StartTime" ; | ||
| sh:path schema:startTime ; | ||
| 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})$" ; | ||
| sh:severity sh:Violation ; | ||
| sh:message "`CheckValue` --> `startTime` MUST follows the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ; | ||
| ] . | ||
|
|
||
|
|
||
| five-safes-crate:CheckValueEndTimeMustFollowISOStandard | ||
| a sh:NodeShape ; | ||
| sh:name "CheckValue" ; | ||
| sh:description "" ; | ||
| sh:target [ | ||
| a sh:SPARQLTarget ; | ||
| sh:select """ | ||
| PREFIX schema: <http://schema.org/> | ||
| PREFIX shp: <https://w3id.org/shp#> | ||
| SELECT ?this | ||
| WHERE { | ||
| ?this schema:additionalType shp:CheckValue ; | ||
| schema:endTime ?o | ||
|
|
||
| } | ||
| """ ; | ||
| ] ; | ||
|
|
||
| sh:property [ | ||
| a sh:PropertyShape ; | ||
| sh:name "EndTime" ; | ||
| sh:path schema:endTime ; | ||
| 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})$" ; | ||
| sh:severity sh:Violation ; | ||
| sh:message "`CheckValue` --> `endTime` MUST follows the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ; | ||
| ] . | ||
|
|
||
|
|
||
| five-safes-crate:CheckValueActionStatusMustHaveAllowedValues | ||
| a sh:NodeShape ; | ||
| sh:name "CheckValue" ; | ||
| sh:description "" ; | ||
|
|
||
| sh:target [ | ||
| a sh:SPARQLTarget ; | ||
| sh:select """ | ||
| PREFIX schema: <http://schema.org/> | ||
| PREFIX shp: <https://w3id.org/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." ; | ||
| ] . |
191 changes: 191 additions & 0 deletions
191
rocrate_validator/profiles/five-safes-crate/should/12_check_phase.ttl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| # 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: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> . | ||
| @prefix five-safes-crate: <https://github.com/eScienceLab/rocrate-validator/profiles/five-safes-crate/> . | ||
| @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
| @prefix schema: <http://schema.org/> . | ||
| @prefix purl: <http://purl.org/dc/terms/> . | ||
| @prefix sh: <http://www.w3.org/ns/shacl#> . | ||
| @prefix validator: <https://github.com/crs4/rocrate-validator/> . | ||
| @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
|
|
||
|
|
||
| five-safes-crate:RootDataEntityShouldMentionCheckValueObject | ||
| a sh:NodeShape ; | ||
| sh:name "RootDataEntity" ; | ||
| sh:targetClass ro-crate:RootDataEntity ; | ||
| sh:description "" ; | ||
|
|
||
| sh:sparql [ | ||
| a sh:SPARQLConstraint ; | ||
| sh:name "mentions" ; | ||
| sh:description "RootDataEntity SHOULD mention a check value object." ; | ||
| sh:select """ | ||
| PREFIX schema: <http://schema.org/> | ||
| PREFIX shp: <https://w3id.org/shp#> | ||
| SELECT $this | ||
| WHERE { | ||
| FILTER NOT EXISTS{ | ||
| $this schema:mentions ?action . | ||
| ?action schema:additionalType shp:CheckValue . | ||
| } | ||
| } | ||
| """ ; | ||
| sh:severity sh:Warning ; | ||
| sh:message "RootDataEntity SHOULD mention a check value object." ; | ||
| ] . | ||
|
|
||
|
|
||
| five-safes-crate:CheckValueObjectShouldPointToRootDataEntity | ||
| a sh:NodeShape ; | ||
| sh:name "CheckValue" ; | ||
| sh:description "" ; | ||
| sh:target [ | ||
| a sh:SPARQLTarget ; | ||
| sh:select """ | ||
| PREFIX schema: <http://schema.org/> | ||
| PREFIX shp: <https://w3id.org/shp#> | ||
| SELECT ?this | ||
| WHERE { | ||
| ?this schema:additionalType shp:CheckValue . | ||
| } | ||
| """ ; | ||
| ] ; | ||
|
|
||
| sh:property [ | ||
| a sh:PropertyShape ; | ||
| sh:name "object" ; | ||
| sh:path schema:object ; | ||
| sh:minCount 1 ; | ||
| sh:hasValue ro-crate:RootDataEntity ; | ||
| sh:severity sh:Warning ; | ||
| sh:message "`CheckValue` --> `object` SHOULD point to the root of the RO-Crate" ; | ||
| ] . | ||
|
|
||
|
|
||
| five-safes-crate:CheckValueInstrumentShouldPointToEntityTypedDefinedTerm | ||
| a sh:NodeShape ; | ||
| sh:name "CheckValue" ; | ||
| sh:description "" ; | ||
| sh:target [ | ||
| a sh:SPARQLTarget ; | ||
| sh:select """ | ||
| PREFIX schema: <http://schema.org/> | ||
| PREFIX shp: <https://w3id.org/shp#> | ||
| SELECT ?this | ||
| WHERE { | ||
| ?this schema:additionalType shp:CheckValue . | ||
| } | ||
| """ ; | ||
| ] ; | ||
|
|
||
| sh:property [ | ||
| a sh:PropertyShape ; | ||
| sh:name "instrument" ; | ||
| sh:path schema:instrument ; | ||
| sh:minCount 1 ; | ||
| sh:class schema:DefinedTerm ; | ||
| sh:severity sh:Warning ; | ||
| sh:message "`CheckValue` --> `instrument` SHOULD point to an entity typed `schema:DefinedTerm`" ; | ||
| ] . | ||
|
|
||
|
|
||
| five-safes-crate:CheckValueAgentShouldIdentifyTheAgentWhoPerformnedTheCheck | ||
| a sh:NodeShape ; | ||
| sh:name "CheckValue" ; | ||
| sh:description "" ; | ||
| sh:target [ | ||
| a sh:SPARQLTarget ; | ||
| sh:select """ | ||
| PREFIX schema: <http://schema.org/> | ||
| PREFIX shp: <https://w3id.org/shp#> | ||
| SELECT ?this | ||
| WHERE { | ||
| ?this schema:additionalType shp:CheckValue . | ||
| } | ||
| """ ; | ||
| ] ; | ||
|
|
||
| sh:property [ | ||
| a sh:PropertyShape ; | ||
| sh:name "agent" ; | ||
| sh:path schema:agent ; | ||
| sh:minCount 1 ; | ||
| sh:nodeKind sh:IRI ; | ||
| sh:severity sh:Warning ; | ||
| sh:message "`CheckValue` --> `agent` SHOULD reference the agent who initiated the check" ; | ||
| ] . | ||
|
|
||
|
|
||
| five-safes-crate:CheckValueShouldHaveEndTime | ||
| a sh:NodeShape ; | ||
| sh:name "CheckValue" ; | ||
| sh:description "" ; | ||
| sh:target [ | ||
| a sh:SPARQLTarget ; | ||
| sh:select """ | ||
| PREFIX schema: <http://schema.org/> | ||
| PREFIX shp: <https://w3id.org/shp#> | ||
| SELECT ?this | ||
| WHERE { | ||
| ?this schema:additionalType shp:CheckValue ; | ||
| schema:actionStatus ?status . | ||
| FILTER(?status IN ( | ||
| "http://schema.org/CompletedActionStatus", | ||
| "http://schema.org/FailedActionStatus" | ||
| )) | ||
| } | ||
| """ ; | ||
| ] ; | ||
|
|
||
| sh:property [ | ||
| a sh:PropertyShape ; | ||
| sh:name "EndTime" ; | ||
| sh:path schema:endTime ; | ||
| sh:minCount 1 ; | ||
| sh:maxCount 1 ; | ||
| sh:severity sh:Warning ; | ||
| sh:message "`CheckValue` SHOULD have the `endTime` property." ; | ||
| ] . | ||
|
|
||
|
|
||
| five-safes-crate:CheckValueShouldHaveActionStatus | ||
| a sh:NodeShape ; | ||
| sh:name "CheckValue" ; | ||
| sh:description "" ; | ||
|
|
||
| sh:target [ | ||
| a sh:SPARQLTarget ; | ||
| sh:select """ | ||
| PREFIX schema: <http://schema.org/> | ||
| PREFIX shp: <https://w3id.org/shp#> | ||
|
|
||
| SELECT ?this | ||
| WHERE { | ||
| ?this schema:additionalType shp:CheckValue . | ||
| } | ||
| """ ; | ||
| ] ; | ||
|
|
||
| sh:property [ | ||
| a sh:PropertyShape ; | ||
| sh:name "ActionStatus" ; | ||
| sh:path schema:actionStatus ; | ||
| sh:minCount 1 ; | ||
| sh:severity sh:Warning ; | ||
| sh:message "CheckValue SHOULD have actionStatus property." ; | ||
| ] . | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should point to an
rocrate:RootDataEntityhere, rather than checking for an object that has a<./>value. Just in case the definition of the root data entity changes later.See this code for how I did this for the Sign-Off phase:
rocrate-validator/rocrate_validator/profiles/five-safes-crate/should/4_sign_off.ttl
Lines 107 to 125 in a7c7165