Skip to content

feat(gen-shacl): add presence-implies-value rule pattern#17

Closed
rmessaou wants to merge 1 commit into
mainfrom
feat/shaclgen-presence-implies-value-upstream
Closed

feat(gen-shacl): add presence-implies-value rule pattern#17
rmessaou wants to merge 1 commit into
mainfrom
feat/shaclgen-presence-implies-value-upstream

Conversation

@rmessaou

@rmessaou rmessaou commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Cherry-pick of the presence-implies-value rule pattern feature for the SHACL generator.

This adds support for generating SHACL constraints that enforce presence-implies-value rules.

Generalise the boolean-guard SHACL-SPARQL pattern to enum-valued targets.
A rule whose precondition is `value_presence: PRESENT` on a value slot and
whose postcondition is `equals_string` / `equals_string_in` on a target
slot now emits an `sh:sparql` constraint requiring the target slot to be
present and hold one of the allowed values. Each allowed value resolves to
its enum `meaning` IRI, with a string-literal fallback.

Motivating case (aiSim environment):
- "if texture_sky_color is set, sky_model must be TextureSky"
- "if overcast_sky_illuminance is set, sky_model must be OvercastSky or
  MeasuredOvercastSky"

The existing boolean-guard (`equals_string: "true"`) and exclusive-value
patterns are unchanged; boolean guard keeps priority over the new branch.

Adds focused unit tests (enum IRI vs. literal fallback, single value vs.
set membership, message emission, SPARQL syntax) plus pyshacl end-to-end
validation for the new pattern.
@rmessaou rmessaou force-pushed the feat/shaclgen-presence-implies-value-upstream branch from 5d896de to bab76d1 Compare July 8, 2026 10:31
@jdsika

jdsika commented Jul 10, 2026

Copy link
Copy Markdown

Superseded by #19, which delivers the same presence-implies-value commit (content-identical cherry-pick of ea5cf575 from #18, authorship preserved) stacked on the green #11 framework instead of re-bundling it.

While auditing this branch, the self-contained bundle turned out to have four assembly issues (masked because quality-checks failed first, so the test job never ran): the _add_rules call site in the class loop was lost (the feature is dead code here — no sh:sparql is ever emitted, 16 of the branch's own tests fail locally), PresenceEnum is used but not imported (F821), the test file references _RULES_SCHEMA_YAML/EX_RULES fixtures that weren't carried over (F821 ×3), and ruff format --check fails on the test file. Details in the #19 description.

Suggest closing this one in favour of #19 — happy to walk through the diff comparison.

@jdsika

jdsika commented Jul 11, 2026

Copy link
Copy Markdown

Closing as superseded by #19 (same presence-implies-value content as a stacked, CI-green PR on the #11 framework; the assembly issues in this self-contained bundle are enumerated in the earlier comment and in #19's description).

@jdsika jdsika closed this Jul 11, 2026
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