shapetrees / specification

Specification for Shape Trees
https://shapetrees.org
Other
12 stars 5 forks source link

Shape validation doesn't really discriminate between different shapeTrees #75

Open Giacomo-Papaluca opened 2 years ago

Giacomo-Papaluca commented 2 years ago

I have a concern about shapeTree validation and I'm going to introduce it with an example. Imagine we have a shapes graph like this one

<#ProjectShape> ...project shape constraints.

<#TaskShape> ...task shape constraints.

If we call, for example, the validateResource algorithm with a ProjectShapeTree (that has ProjectShape as its shape) and a Project resource as inputs, everything works fine: if the resource respects the constraints the validation result is true otherwise is false.

Now if we call the same algorithm with the same Project resource but with the TaskShapeTree (that has TaskShape as shape) I would assume that a correct behavior would be to return a false validation by default because I'm trying to validate a Project with a TaskShapeTree. Instead (if they are both resources and not containers), since shape validation takes all the constraints of a shape and checks if the resource respects them, and since we are trying to validate a TaskShape, there would be no constraint for a Project resource and so the validation would be automatically true (and this stands for any possible imaginable shape different from the "expected shape" of the resource that should be ProjectShape). Obviously if I validate the resource against the entire shapeGraph there would be constraints for the Project resource in the ProjectShape "area" of the graph, so the validation would depend on those constraints, but still that would mean that, in case the resource respects all the ProjectShape constraints, I would have a valid result for validateResource(TaskShapeTree, myProjectResource), isn't that quite an unexpected behavior? I'm not sure if this concern relates mostly to the shapeTree validation or to the shape validation but I'll start posting this issue here. Thanks in advance for the attention.

p.s. I thought about this issue while working with this example dataset and experimenting shape validation with the zazuko shacl playground