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

post processing validation #557

Merged
merged 5 commits into from
Aug 15, 2023
Merged

Conversation

dpetran
Copy link
Contributor

@dpetran dpetran commented Aug 9, 2023

Adds validation for sh:nodeKind, sh:hasValue, and sh:datatype when they are not explicitly part of the transacted flakes.

Fixes #533

Fixes #533

sh:datatype, sh:hasValue, and sh:nodeKind constraints were only being enforced during
transactions, and not when referenced by a "graph crawling" shape. This change ensures
these constraints are always applied.
@dpetran dpetran requested a review from a team August 9, 2023 19:25
Copy link
Contributor

@mpoffald mpoffald left a comment

Choose a reason for hiding this comment

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

With this PR, is it the case that there will be instances where constraints are checked twice? IIRC you said offline that you'd be doing some followup for optimizations, does that include potentially getting rid of the mid-processing versions of these to avoid duplicate checking?

[false (str "sh:in: value " val " must be one of " in)]))
has-value-results (when has-value
(if (some #(= (flake/o %) has-value) p-flakes)
[true (str "sh:not sh:hasValue: at least one value must not be " has-value)]
Copy link
Contributor

Choose a reason for hiding this comment

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

I tend to get kind of mixed up with the sh:not cases, but I'm not sure this is the right message here. I thought it would be be that none of the values can have the has-value?

(is (util/exception? invalid-person))
(is (= "SHACL PropertyShape exception - sh:hasValue: at least one value must be true."
(ex-message invalid-person)))))
(testing "extended path contstraints"
Copy link
Contributor

Choose a reason for hiding this comment

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

typo in "constraints" here

"type" "ex:User"
"ex:friend" {"@id" "ex:Bob"}})]
(is (util/exception? db-forbidden-friend))
(is (= "SHACL PropertyShape exception - sh:datatype: every datatype must be 1."
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this matches the error message you'd get with the mid-transaction-processing version of this constraint check. If we're going to keep those versions around, I think the error messages should match -- from the user's perspective, it's the same constraint, so different error messages for post/mid processing wouldn't make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an interesting one, when I try a naive mid-processing datatype validation I actually get a coercion error instead of a validation error, which makes sense as coercion happens before validation.

@dpetran
Copy link
Contributor Author

dpetran commented Aug 10, 2023

Regarding the optimizations, what I'm working on right now segregates property shapes into "eligible for mid-processing" and "everything else" buckets, where the main differentiator is whether any graph crawling is necessary. So, it aims to hit that "correct, but fast" sweet spot when its available but will only do the work once, either during or after processing.

Copy link
Contributor

@mpoffald mpoffald left a comment

Choose a reason for hiding this comment

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

🌮

@dpetran dpetran merged commit e4db5db into main Aug 15, 2023
5 checks passed
@dpetran dpetran deleted the feature/post-processing-validation branch August 15, 2023 13:56
@dpetran dpetran mentioned this pull request Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to check sh:datatype, sh:class, sh:nodeKind constraints after flakes have been transacted
2 participants