Repository navigation
feat(shacl): consult f:classMembershipSource graphs for sh:class membership - #2204
mrpraneeth wants to merge 1 commit into
Conversation
…ership sh:class looks up a value's rdf:type only in the focus node's graph and the single f:shapesSource graph. A value-set or catalog kept in its own named graph (neither the shapes graph nor the referencing data's graph) can never satisfy sh:class, so data in many named graphs can't reference a shared catalog graph. f:classMembershipSource on f:shaclDefaults (repeatable f:GraphRef) adds graphs to that lookup. Shapes are still compiled only from f:shapesSource. - The same-ledger GraphRef checks are shared with f:shapesSource, so both reject f:ledger, f:atT, f:trustPolicy and f:rollbackGuard, and an unknown graph fails with "<setting> graph '…' not found". - The transaction path and the standalone validate path resolve the same membership graphs. - With a cross-ledger f:shapesSource, membership resolves against the model ledger, so the combination is rejected instead of silently ignored. - Registered in config_vocab (config edge) and the documented repair recipe. - Docs: setting groups, override control, vocabulary, SHACL cookbook. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
|
|
Thank you for this. The use case is real, and this PR made it concrete. Rather than a setting for #2264 builds on the config plumbing and shared source resolution from this PR, and you're credited as co-author on its commit. Once it lands, the write-policy workaround you described should be replaceable with a plain Closing in favour of #2264. |
Problem
sh:classresolves a value'srdf:typein the focus node's graph and the singlef:shapesSourcegraph. That covers value-sets kept next to the shapes, but not a catalog kept in a named graph of its own. A common layout:<…/shapes>;<…/org-a>,<…/org-b>, …);<…/catalog>, with its own write permissions.There,
sh:class ex:Commodityon a record can never pass, becauseex:coffee a ex:Commoditylives in neither consulted graph.f:shapesSourcetakes one graph selector, so the catalog can't be added there.Change
f:classMembershipSourceonf:shaclDefaults: a repeatablef:GraphRefwhose graphs are added to thesh:classmembership lookup.f:shapesSource. A membership graph only contributesrdf:typetriples.f:shapesSourceand the new setting now share one helper (resolve_shacl_graph_source). Both rejectf:ledger,f:atT,f:trustPolicyandf:rollbackGuard, and an unknown graph fails withf:classMembershipSource graph '…' not found…, asf:shapesSourcealready does. Thef:shapesSourceerror text is unchanged.tx.rs) and the standalone validate path (validate.rs) resolve the same membership graphs.f:shapesSource, membership resolves against the model ledger, so the combination is rejected rather than silently ignored.ShaclDefaults, read withread_graph_source_refs;config_vocab;writing-config.md.setting-groups.md,override-control.md(non-overridable, likef:shapesSource),vocabulary.md, and a "Value-sets in their own graph" section incookbook-shacl.md.Tests
Written before the change. The first two new config-graph tests failed with
Value coffee is not an instance of class Commodity, and the cross-ledger test failed with the same silent violation when the check was removed.it_config_graph:shacl_class_ignores_other_graphs_without_membership_sourcepins today's behavior;shacl_class_membership_source_adds_a_catalog_graph: a member passes and a non-member is rejected;shacl_class_membership_source_rejects_unknown_graph.it_shapes_cross_ledger:cross_ledger_shapes_reject_class_membership_source.Local results on
mainat 42bb964:cargo test -p fluree-db-api --features shacl --test grp_graphsourcecargo test -p fluree-db-api --features shacl --libcargo fmt --all --checkcargo clippy -p fluree-db-api -p fluree-db-core -p fluree-vocab --all-targets -- -D warningsThe full-workspace
--all-featuresclippy is left to CI.Context: we hit this in a ledger whose listings live in per-organization graphs and reference a shared catalog graph. We currently work around it by checking the type in a required write policy instead of
sh:class.🤖 Generated with Claude Code