Skip to content

feat: Add migration guide and patterns for transitioning from SHACL-AF to SHACL 1.2#879

Draft
simonstey wants to merge 2 commits into
gh-pagesfrom
feat/shacl-af-srl
Draft

feat: Add migration guide and patterns for transitioning from SHACL-AF to SHACL 1.2#879
simonstey wants to merge 2 commits into
gh-pagesfrom
feat/shacl-af-srl

Conversation

@simonstey

Copy link
Copy Markdown
Contributor
  • Introduced a comprehensive migration guide detailing architectural differences, vocabulary mapping, syntax migration, and new capabilities in SHACL 1.2.
  • Created a migration patterns cookbook with specific examples for rewriting SHACL-AF rules into SHACL 1.2, covering various common patterns and their transformations.

@simonstey simonstey added the Rules For SHACL 1.2 Rules spec. label May 6, 2026
@simonstey simonstey changed the base branch from gh-pages to rules-rdf-syntax May 6, 2026 09:36
@afs afs force-pushed the rules-rdf-syntax branch 3 times, most recently from 81fdcfd to 24d523b Compare May 6, 2026 15:05
@afs

afs commented May 8, 2026

Copy link
Copy Markdown
Contributor

Just checking - this PR has two MD files :

migration-guide.md

migration-patterns.md

and does not itself change index.html?

@afs

afs commented May 8, 2026

Copy link
Copy Markdown
Contributor

Something else that has been suggested is adding sh:SHACLRule so that an updated SHACL-AF can execute one rule, with $this being provided to a rule execution.

sh:rule [ 
   rdf:type sh:SHACLRule ;
   srl:rule "...."
]

These features have no SHACL-AF equivalent. Migrated rules can leverage them
for improved expressiveness.

### 5.1 Negation as Failure (`NOT`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about SPARQL NOT EXISTS?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see line 327?

@afs

afs commented May 8, 2026

Copy link
Copy Markdown
Contributor

Relates to issue #776

@afs afs force-pushed the rules-rdf-syntax branch 2 times, most recently from 3cf9406 to c047619 Compare May 8, 2026 14:36
Base automatically changed from rules-rdf-syntax to gh-pages May 8, 2026 14:37
Comment thread shacl12-rules/migration-patterns.md Outdated
|------|--------|-----------|
| SHACL-AF | `sh:` | `http://www.w3.org/ns/shacl#` |
| SHACL 1.2 Rules | `srl:` | `http://www.w3.org/ns/shacl-rules#` |
| SHACL 1.2 (expressions) | `sparql:` | `http://www.w3.org/ns/sparql#` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shnex: and sparql:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is unclear to me. I cannot say whether @simonstey understands it better.

WHERE {
$this ex:width ?width .
$this ex:height ?height .
BIND (?width * ?height AS ?area) .

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BIND -> SET

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e.,

Suggested change
BIND (?width * ?height AS ?area) .
SET (?area := ?width * ?height ) .

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but not for the "old" SHACL-AF rules -->

have to change it here though:

**SHACL 1.2 SRL:**
```
PREFIX ex: <http://example.com/ns#>

RULE { ?this ex:area ?area }
WHERE {
    ?this a ex:Rectangle .
    ?this ex:width ?width .
    ?this ex:height ?height .
    SET (?area := ?width * ?height ) .
}
```

@afs

afs commented May 15, 2026

Copy link
Copy Markdown
Contributor

Excellent!

Do you think this should be a WG NOTE, or https://github.com/w3c/shacl-resources, or some other place?

Comment thread shacl12-rules/migration-patterns.md Outdated
Comment thread shacl12-rules/migration-patterns.md Outdated
Comment thread shacl12-rules/migration-patterns.md Outdated
Comment thread shacl12-rules/migration-patterns.md Outdated
Comment thread shacl12-rules/migration-guide.md Outdated
Comment thread shacl12-rules/migration-guide.md Outdated
Comment thread shacl12-rules/migration-guide.md Outdated
Comment thread shacl12-rules/migration-guide.md Outdated
Comment thread shacl12-rules/migration-guide.md Outdated
Comment thread shacl12-rules/migration-guide.md Outdated
Comment thread shacl12-rules/migration-guide.md Outdated
Comment thread shacl12-rules/migration-guide.md Outdated
Comment thread shacl12-rules/migration-guide.md Outdated
Comment thread shacl12-rules/migration-guide.md Outdated
Comment thread shacl12-rules/migration-guide.md Outdated
Comment thread shacl12-rules/migration-guide.md Outdated

**After (in SRL):**
```
BIND(ex:multiply(?w, ?h) AS ?area)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given all the BIND -> SET comments elsewhere, shouldn't the same be applied here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you are totally right

Comment thread shacl12-rules/migration-guide.md Outdated
Comment thread shacl12-rules/migration-patterns.md Outdated
Comment thread shacl12-rules/migration-patterns.md Outdated
Comment thread shacl12-rules/migration-patterns.md Outdated
Comment thread shacl12-rules/migration-patterns.md Outdated
Comment thread shacl12-rules/migration-patterns.md Outdated
Comment thread shacl12-rules/migration-patterns.md Outdated
Comment thread shacl12-rules/migration-patterns.md Outdated
@afs

afs commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

@simonstey Would it be possible to update this PR so that it only has the markdown files?

@simonstey simonstey force-pushed the feat/shacl-af-srl branch from 8bfb87f to 6e6f7a3 Compare June 17, 2026 07:02
@simonstey

Copy link
Copy Markdown
Contributor Author

@simonstey Would it be possible to update this PR so that it only has the markdown files?

done


fwiw, since I had to look up on how to do this without too much hassle myself, I might as well share it->

move branch base onto latest gh-pages ->

git reset --hard origin/gh-pages

pull the two files from the old tip ->

git checkout 8bfb87f3 -- shacl12-rules/migration-guide.md shacl12-rules/migration-patterns.md

commit and push ->

git commit -m "feat: Add SHACL-AF to SHACL 1.2 migration guide and patterns"
git push --force-with-lease

@afs

afs commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

git rebase should have worked.

Comment on lines +84 to +85
dependency cycle contains a closed dependency; if it does, the spec leaves the
outcome undefined. This guarantees a single well-defined, finite outcome.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dependency cycle contains a closed dependency; if it does, the spec leaves the
outcome undefined. This guarantees a single well-defined, finite outcome.
dependency cycle contain a closed dependency; if any do, this specification
leaves the outcome undefined. This guarantees a single, well-defined, finite
outcome.

Comment on lines +90 to +91
an assignment, or a blank-node-producing head is what introduces a hard stratum
boundary.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
an assignment, or a blank-node-producing head is what introduces a hard stratum
boundary.
an assignment, or a blank-node-producing head introduces a hard stratum boundary.

| — | `srl:filter` | New; `FILTER` equivalent |
| — | `srl:assign` | New; assignment element (`SET`) |
| — | `srl:assignVar` | New; the variable assigned by an `srl:assign` |
| — | `srl:assignValue` | New; the value/expression of an `srl:assign` |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|| `srl:assignValue` | New; the value/expression of an `srl:assign` |
|| `srl:assignValue` | New; the value or expression of an `srl:assign` |

Comment on lines +160 to +162
are used both in `srl:head` (triple templates) and in `srl:body`/`srl:data`
(triple patterns and data triples), not only for the SHACL-AF `sh:subject`/etc.
mapping shown above.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
are used both in `srl:head` (triple templates) and in `srl:body`/`srl:data`
(triple patterns and data triples), not only for the SHACL-AF `sh:subject`/etc.
mapping shown above.
are used in `srl:head` (triple templates) as well as `srl:body` and `srl:data`
(triple patterns and data triples), not only for the SHACL-AF `sh:subject`, etc.,
mappings shown above.

- `CONSTRUCT { } WHERE { }` → `RULE { } WHERE { }`
- Declare prefixes via `PREFIX` keyword, not `sh:prefixes` indirection
- SPARQL `BIND(expr AS ?v)` → SRL `SET (?v := expr)`; SRL text has no `BIND`
- The assignment makes this rule a **run-once rule** (it has an `srl:assign`)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The assignment makes this rule a **run-once rule** (it has an `srl:assign`)
- The assignment (`srl:assign`) makes this a **run-once rule**

Comment on lines 516 to 517
definition mechanism is defined in SHACL 1.2 Node Expressions (separate spec),
not in the rules spec itself.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this (and similar) reference be made a live link to SHACL 1.2 Node Expressions, if not directly to the definition of the function definition mechanism therein?

Suggested change
definition mechanism is defined in SHACL 1.2 Node Expressions (separate spec),
not in the rules spec itself.
definition mechanism is defined in SHACL 1.2 Node Expressions (a separate
specification), not in the Rules specification itself.

Comment on lines +531 to +534
- Within a stratum, evaluate **run-once rules** (those with assignments or
blank-node-producing heads) exactly once, then iterate the **general rules**
to a fixed point
- Evaluate each stratum completely and in order before proceeding to the next

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even in an unordered list, there is often a logic to their ordering and their wording. I believe these adjustments make this list more logical and more likely to be followed correctly.

Suggested change
- Within a stratum, evaluate **run-once rules** (those with assignments or
blank-node-producing heads) exactly once, then iterate the **general rules**
to a fixed point
- Evaluate each stratum completely and in order before proceeding to the next
- Evaluate each stratum completely and in order before proceeding to the next
- Within each stratum, evaluate all **run-once rules** (those with assignments
or blank-node-producing heads) exactly once, then iterate the **general rules**
to a fixed point

recursion through **open** dependencies within a stratum — rules iterate until no
new triples are produced. Recursion through a **closed** dependency (negation,
assignment, or blank-node-producing head) violates the stratification condition
and is undefined. Implementations need semi-naive evaluation or equivalent to

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
and is undefined. Implementations need semi-naive evaluation or equivalent to
and is undefined. Implementations need semi-naive evaluation or an equivalent to

Comment on lines +400 to +402
- A *closed* dependency (negation, assignment, or a blank node in the head) is
what forces the depended-on rule into a strictly earlier stratum. Ordinary
positive chaining like this does not.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- A *closed* dependency (negation, assignment, or a blank node in the head) is
what forces the depended-on rule into a strictly earlier stratum. Ordinary
positive chaining like this does not.
- A *closed* dependency (negation, assignment, or a blank node in the head)
forces a depended-on rule into a strictly earlier stratum. Ordinary positive
chaining like this does not.

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

Labels

Rules For SHACL 1.2 Rules spec.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants