Skip to content
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

Shape validation fails related to 5 named individuals #936

Closed
bact opened this issue Dec 6, 2024 · 15 comments
Closed

Shape validation fails related to 5 named individuals #936

bact opened this issue Dec 6, 2024 · 15 comments
Labels
model Something about the abstract model RDF/OWL/SHACL RDF graph, schema, ontology, constraint
Milestone

Comments

@bact
Copy link
Collaborator

bact commented Dec 6, 2024

These violations are all new and mostly related to the 5 new creationInfo_*:

pyshacl produces 32 violations. Update 2024-12-10 09:24 UTC: 22 violations.

For example:

BlankNode -- Fixed:

Constraint Violation in NodeKindConstraintComponent (http://www.w3.org/ns/shacl#NodeKindConstraintComponent):
Severity: sh:Violation
Source Shape: ns1:CreationInfo
Focus Node: https://spdx.org/rdf/3.0.1/creationInfo_NoneLicense
Value Node: https://spdx.org/rdf/3.0.1/creationInfo_NoneLicense
Message: Value is not of Node Kind sh:BlankNode

Agent:

Constraint Violation in ClassConstraintComponent (http://www.w3.org/ns/shacl#ClassConstraintComponent):
Severity: sh:Violation
Source Shape: [ sh:class ns1:Agent ; sh:minCount Literal("1", datatype=xsd:integer) ; sh:nodeKind sh:IRI ; sh:path ns1:createdBy ]
Focus Node: https://spdx.org/rdf/3.0.1/creationInfo_NoneLicense
Value Node: https://spdx.org/
Result Path: ns1:createdBy
Message: Value does not have class ns1:Agent

string -- Fixed:

Constraint Violation in DatatypeConstraintComponent (http://www.w3.org/ns/shacl#DatatypeConstraintComponent):
Severity: sh:Violation
Source Shape: [ sh:datatype xsd:string ; sh:maxCount Literal("1", datatype=xsd:integer) ; sh:nodeKind sh:Literal ; sh:path ns1:comment ]
Focus Node: https://spdx.org/rdf/3.0.1/creationInfo_NoneLicense
Value Node: Literal("This individual element was defined by the spec.", lang=en)
Result Path: ns1:comment
Message: Value is not Literal with datatype xsd:string

Abstract class:

Constraint Violation in NotConstraintComponent (http://www.w3.org/ns/shacl#NotConstraintComponent):
Severity: sh:Violation
Source Shape: ns1:Element
Focus Node: ns6:NoneLicense
Value Node: ns6:NoneLicense
Message: Node ns6:NoneLicense must not conform to shape [ sh:class ns1:Element ; sh:message Literal("https://spdx.org/rdf/3.0.1/terms/Core/Element is an abstract class and should not be instantiated directly. Instantiate a subclass instead.", lang=en) ]
Constraint Violation in NotConstraintComponent (http://www.w3.org/ns/

spdx3-validate 0.0.5 also produce similar violations:

BlankNode -- Fixed:

Violation of type sh:NodeKindConstraintComponent:
Severity: sh:Violation
Focus Node: https://spdx.org/rdf/3.0.1/creationInfo_NoneLicense
Value Node: https://spdx.org/rdf/3.0.1/creationInfo_NoneLicense
Result path: -
Message: Value is not of Node Kind sh:BlankNode

Agent:

Violation of type sh:ClassConstraintComponent:
Severity: sh:Violation
Source Shape:
@Prefix sh: http://www.w3.org/ns/shacl# .
@Prefix xsd: http://www.w3.org/2001/XMLSchema# .
[] sh:class https://spdx.org/rdf/3.0.1/terms/Core/Agent ;
sh:minCount 1 ;
sh:nodeKind sh:IRI ;
sh:path https://spdx.org/rdf/3.0.1/terms/Core/createdBy .
Focus Node: https://spdx.org/rdf/3.0.1/creationInfo_NoneLicense
Value Node: https://spdx.org/
Result path: https://spdx.org/rdf/3.0.1/terms/Core/createdBy
Message: Value does not have class ns1:Agent

string: -- Fixed:

Violation of type sh:DatatypeConstraintComponent:
Severity: sh:Violation
Source Shape:
@Prefix sh: http://www.w3.org/ns/shacl# .
@Prefix xsd: http://www.w3.org/2001/XMLSchema# .
[] sh:datatype xsd:string ;
sh:maxCount 1 ;
sh:nodeKind sh:Literal ;
sh:path https://spdx.org/rdf/3.0.1/terms/Core/comment .
Focus Node: https://spdx.org/rdf/3.0.1/creationInfo_NoneLicense
Value Node: "This individual element was defined by the spec."@en
Result path: https://spdx.org/rdf/3.0.1/terms/Core/comment
Message: Value is not Literal with datatype xsd:string

Abstract class:

Violation of type sh:NotConstraintComponent:
Severity: sh:Violation
Focus Node: https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense
Value Node: https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense
Result path: -
Message: Node ns6:NoneLicense must not conform to shape [ sh:class ns1:Element ; sh:message Literal("https://spdx.org/rdf/3.0.1/terms/Core/Element is an abstract class and should not be instantiated directly. Instantiate a subclass instead.", lang=en) ]

Note

Prior to the merges of #933 and spdx/spec-parser#159, there were 5 violations.
All of them are about missing CreationInfo:
https://github.com/spdx/spdx-spec/actions/runs/11867207295/job/33074971508?pr=1134

Those 5 violations are now fixed.

@bact bact added model Something about the abstract model RDF/OWL/SHACL RDF graph, schema, ontology, constraint labels Dec 6, 2024
@bact bact added this to the 3.0.1 milestone Dec 6, 2024
@zvr
Copy link
Member

zvr commented Dec 6, 2024

So, the first is because we had said that CreationInfo (and all non-Element classes) should be blank nodes. We decided to use a URI for the instances of CreationInfo for the 5 Individuals. I was expecting that.

It will be fixed when I merge the fix for spdx/spec-parser#160

@zvr
Copy link
Member

zvr commented Dec 6, 2024

Shall we have different issues for each error?

The second one is the good ol' spdx/spec-parser#74

@goneall
Copy link
Member

goneall commented Dec 6, 2024

It will be fixed when I merge the fix for spdx/spec-parser#160

On yesterday's call, I suggested not lifting the restriction - based on this, I'll retract that recommendation - more important to get the validation to work.

@bact
Copy link
Collaborator Author

bact commented Dec 6, 2024

Shall we have different issues for each error?

The second one is the good ol' spdx/spec-parser#74

Agree. I will separate one issue per error type.

@goneall
Copy link
Member

goneall commented Dec 7, 2024

I was able to I hand edited the model.ttl file to pass the validation.

I had to make the following 3 types of changes:

  • Changed ns1:createdBy <https://spdx.org/> ; to ns1:createdBy ns1:SpdxOrganization ;
  • Removed the restriction for instantiating abstracted classes (e.g. sh:not [ sh:class ns1:ElementCollection ; ...)
  • Add the xsd:string type to the string literals for the individuals (e.g. ns1:comment "This individual element was defined by the spec."^^xsd:string ;)

Attached is the working model.ttl file.
spdx-model-passed.ttl.txt

I'll add 3 issues to the spec parser for each of the above changes.

@goneall
Copy link
Member

goneall commented Dec 7, 2024

Ping @zvr @bact @JPEWdev on the above analysis

@bact
Copy link
Collaborator Author

bact commented Dec 9, 2024

Thank you @goneall. I agree with the analysis

@goneall
Copy link
Member

goneall commented Dec 9, 2024

I forgot about one other change I made to the working model.ttl file:

Changed sh:nodeKind sh:BlankNode to sh:nodeKind sh:BlankNodeOrIRI .

This is covered in the existing spec parser issue spdx/spec-parser#160

@JPEWdev
Copy link
Contributor

JPEWdev commented Dec 9, 2024

The problem is that we are defining named individuals that are explicitly concrete instaniations of abstract classes (e.g. Element is abstract, but NoneElement is now a concrete instance of it). This will be a problem for any way that we validate abstract classes, so I don't think fixing it by reverting the spec parser change is a good idea.

@zvr
Copy link
Member

zvr commented Dec 9, 2024

Oooops! You are absolutely correct, @JPEWdev .
How come noone noticed this before?

What is the way forward on this?

We created the NoneElement and NoAssertionElement to be used as destinations for the to property of a Relationship, in order to be able to express two things.

Maybe they should not be simple Elements, but something else?

@goneall
Copy link
Member

goneall commented Dec 9, 2024

Thanks @JPEWdev - I was beating my head against the wall trying to figure out why this showed up now.

For licensing, we have a class IndividualLicensingInfo which is concrete.

Perhaps for elements we need an IndividualElement which is concrete.

@goneall
Copy link
Member

goneall commented Dec 9, 2024

I just tried implementing an IndividualElement and I'm still getting the same constraint error.

Note that I'm also getting a constraint error on licensing individuals and on the Agent defined in the example file.

@goneall
Copy link
Member

goneall commented Dec 9, 2024

I added a draft PR with the IndividualElement implementation: #937

@bact
Copy link
Collaborator Author

bact commented Dec 10, 2024

Note that with spdx/spec-parser#169, the string type issues and BlankNode issues are now resolved (you may need to reload the https://spdx.github.io/spdx-spec/v3.0.1/rdf/spdx-model.ttl or rerun your workflow).

@goneall
Copy link
Member

goneall commented Dec 10, 2024

Resolved with the above referenced merges

@goneall goneall closed this as completed Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
model Something about the abstract model RDF/OWL/SHACL RDF graph, schema, ontology, constraint
Projects
None yet
Development

No branches or pull requests

4 participants