Skip to content

Add SPARQL validation - #1425

Open
JPEWdev wants to merge 2 commits into
spdx:developfrom
JPEWdev:sparql
Open

Add SPARQL validation#1425
JPEWdev wants to merge 2 commits into
spdx:developfrom
JPEWdev:sparql

Conversation

@JPEWdev

@JPEWdev JPEWdev commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

An example SPARQL query in the model. See: spdx/spec-parser#213

@bact

bact commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

@bact bact added the RDF/OWL/SHACL RDF graph, schema, ontology, constraint label Jul 31, 2026
@JPEWdev

JPEWdev commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Generating these SPARQL rules from the text descriptions seemed like a really good fit for AI generation, and it did a really good job.

@JPEWdev

JPEWdev commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@JPEWdev may be related issue

* [SPDX enumeration value URLs could use `.` or `_` not `/` as separator #1166](https://github.com/spdx/spdx-3-model/issues/1166)

Yes, I did notice that. It does work with correctly with BASE though, which is why I chose to use that instead. I think that should be good enough for the SPARQL queries

RelationshipTypes values frequently place additional constraints on
Relationship in which they are used. Previously, these could only be
validated manually. However, it is also possible to write SPARQL queries
that correctly enforce these constraints and provide useful error
messages when they are validated.

AI-Generated: Claude Sonnet 5
Adds SPARQL queries that enforce the additional restrictions required by
various classes

AI-Generated: Claude Sonnet 5
@bact

bact commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

This will work as an example or for a validation?

@JPEWdev

JPEWdev commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

It turned out to be pretty easy to get the AI to spit out the SPARQL queries, so I would probably say this isn't an example anymore. I've been testing the rules by generating a model with spdx/spec-parser#213 applied to the spec parser and it does appear to work as intended

@JPEWdev JPEWdev changed the title SPARQL example Add SPARQL validation Jul 31, 2026
@bact

bact commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Looks great. Will be really really useful if we can have this integrated into the published RDF/Turtule file:

sh:sparql [
    sh:message "..." ;
    sh:select """
        SELECT ...
    """ ;
]

which spdx/spec-parser#213 is exactly doing.

In terms of human editor creation and review, this requires knowledge of SPARQL.
As long as this field is optional, it should be fine (as the author who add constraints in prose doesn't have to immediately have the SPARQL; the SPARQL can be added later in time, by the same or the different author).

(I have a different proposal, based on a YAML-based rule - which may be more author-friendly - but it is still another domain-specific language to learn - and not a standardized one like the SPARQL used here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RDF/OWL/SHACL RDF graph, schema, ontology, constraint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants