Skip to content

Pass snippet SHACL closures to transform output profile validation - #94

Merged
avillar merged 2 commits into
masterfrom
transform-output-snippet-closures
Oct 21, 2026
Merged

avillar merged 2 commits into
masterfrom
transform-output-snippet-closures

Conversation

@rob-metalinkage

Copy link
Copy Markdown
Collaborator

Problem

A snippet's shacl-closure is used when the example itself is validated, but not when a transform's output is validated against outputs.profiles. validate_transform_output only received the profile bblock's inherited closures. Background facts that an example relies on (e.g. descriptions of related resources held elsewhere) were therefore lost for its transformed output, and the same data could pass as the example and fail as the transform output.

Change

  • validate_transform_output takes an optional additional_shacl_closures argument and passes it to the validators, as _validate_resource already does.
  • transform.py passes the snippet's own shacl-closure entries. Relative paths are resolved against the source bblock: the RDF validator resolves relative closures against its own bblock, which here is the profile bblock. The profile's inherited closures still come from the profile bblock, as before.
  • Unit test: test_validate_transform_output_passes_snippet_closures_to_validators.

The transform context's snippet['shacl-closure'] is unchanged (snippet closures plus inherited ones).

Testing

  • pytest tests: 169 passed, run in the bblocks-postprocess:latest image with this branch's ogc/ mounted.
  • End to end on opengeospatial/ogcapi-sosa: a SOSA spec example whose Turtle is transformed to JSON and validated against ogc.sosa.properties.observation, with a per-example closure. Both reports list "Using snippet SHACL closures" and pass, and no other report changed.

🤖 Generated with Claude Code

validate_transform_output only used the profile bblock's inherited closures,
so a snippet's shacl-closure applied to the example itself but not to its
transformed output. Pass the snippet's own closures through, resolved
against the source bblock (relative paths would otherwise resolve against
the profile bblock).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rob-metalinkage added a commit to rob-metalinkage/ogcapi-sosa that referenced this pull request Oct 21, 2026
closures/<base>.ttl (or <stem>.ttl for all roots of a multi-root example)
under _sources/spec-examples/ is added as that example's snippet
shacl-closure. It applies to the Turtle validation and, with
opengeospatial/bblocks-postprocess#94, to the transform output profile
validation. The transform does not merge it into its output. Closures are
for facts about related resources only, not the example's own missing
mandatory fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@avillar
avillar merged commit f0a2840 into master Oct 21, 2026
1 check passed
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.

2 participants