Skip to content

test(gen-shacl): cover nested range_expression postconditions - #35

Open
jdsika wants to merge 1 commit into
feat/shaclgen-compositional-rule-fallbackfrom
feat/shaclgen-postcondition-range-expression
Open

jdsika wants to merge 1 commit into
feat/shaclgen-compositional-rule-fallbackfrom
feat/shaclgen-postcondition-range-expression

Conversation

@jdsika

@jdsika jdsika commented Oct 2, 2026 •

Copy link
Copy Markdown

Test-only follow-up to #20 (mirror of linkml#3990). #20's composed translation handles a range_expression postcondition with the same code it uses for preconditions, but its tests covered nested postconditions only in a closed world. This PR pins the nested-postcondition cases:

Case Expected Checked against
open_world, wrapper omitted or empty conforms JSON Schema
open_world, value doesn't match violation JSON Schema
closed world, empty wrapper conforms (the inner condition holds for an absent inner slot) JSON Schema
multivalued wrapper, one member fails violation (every member must satisfy it) JSON Schema
enum value with a meaning compared as that IRI, resolved on the range class pyshacl, with explicit expectations, because the JSON-LD context renders this enum as strings (#40)
condition on the range class's identifier rule skipped with a warning the warning

The JSON Schema cases run for the declaring class and for a subclass. Four mutants of the shared code are each killed by the new cases: the inner presence default flipped, open_world ignored, the identifier check removed, and enum meaning ignored. No code changes.

History: this PR first implemented the translation itself, using an existential query form, so it had to skip multivalued wrappers and optional or multivalued inner slots. #20 now translates those cases. On this PR's original schemas, SHACL and JSON Schema agree on all 15 instances checked. The original commit is replaced by this test-only commit.

Fork stack: #19 → #20 → #35 (tests); #23 (docs) is also based on #20.

@jdsika
jdsika marked this pull request as draft October 5, 2026 12:01
@jdsika
jdsika force-pushed the feat/shaclgen-postcondition-range-expression branch from 58b7817 to cf5a2df Compare October 5, 2026 12:11
@jdsika
jdsika marked this pull request as ready for review October 5, 2026 12:25
@jdsika
jdsika force-pushed the docs/shaclgen-rule-constraints branch 2 times, most recently from 442dd51 to 6a78f26 Compare October 6, 2026 18:20
@jdsika

jdsika commented Oct 7, 2026 •

Copy link
Copy Markdown
Author

Update: reopened as a test-only follow-up on #20 (see the description).

#20 (mirror of linkml#3990, head c89faac) supersedes this PR's original implementation. Its composed translation handles nested range_expression postconditions in general:

@jdsika jdsika closed this Oct 7, 2026
@jdsika jdsika reopened this Oct 7, 2026
@jdsika
jdsika changed the base branch from docs/shaclgen-rule-constraints to feat/shaclgen-compositional-rule-fallback October 7, 2026 08:18
The composed rule translation handles a range_expression in a
postcondition with the same code as in a precondition, but its tests
exercised nested postconditions only in a closed world.  Pin the cases
specific to nested postconditions:

- open_world: an omitted or empty wrapper satisfies the rule, and a
  present non-matching value violates it;
- closed world: an empty wrapper satisfies the inner value condition,
  and every member of a multivalued wrapper must satisfy it;
- an enum value with a meaning compares as that IRI, resolved on the
  range class;
- a condition on the range class's identifier skips the rule.

Signed-off-by: jdsika <carlo.van-driesten@vdl.digital>
@jdsika
jdsika force-pushed the feat/shaclgen-postcondition-range-expression branch from cf5a2df to fbc5a66 Compare October 7, 2026 08:20
@jdsika jdsika changed the title feat(gen-shacl): translate a nested range_expression postcondition test(gen-shacl): cover nested range_expression postconditions Oct 7, 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.

1 participant