SHACL
The constraint language for validating data in the graph.
SHACL (Shapes Constraint Language) defines what valid data looks like. Where RDF lets you state any fact about anything, SHACL defines rules about what facts should exist, what types they should have, and how many there should be. In Poliglot, SHACL shapes are how you express business rules as machine-readable constraints.
What SHACL Does
SHACL shapes declare constraints on resources in the graph. A shape targets a class and defines what properties instances of that class should have:
tasks:TaskShape
a sh:NodeShape ;
sh:targetClass tasks:Task ;
sh:property [
sh:path tasks:title ;
sh:datatype xsd:string ;
sh:minCount 1 ;
sh:message "Every task must have a title."
] .This says: every tasks:Task must have at least one tasks:title property, and it must be a string. If a task is missing a title, validation produces a finding with the message "Every task must have a title."
When Validation Runs
In Poliglot, SHACL validation runs at two points:
- Assembly: when your matrix is built and deployed. Catches spec-level issues before they reach runtime.
- Runtime: continuously, as data changes in the context graph. Catches data quality issues as actions produce output.
Validation findings have severity levels (sh:Violation, sh:Warning, sh:Info) that determine how RARS responds. Violations are errors. Warnings are signals. Info is advisory.
SHACL in Matrix Development
SHACL is covered in depth in the Constraints and Validation guide, which covers:
- Writing effective constraint messages for AI self-correction
- Multi-level severity strategies
- Constraining values with enumerations, patterns, and types
- Constraint inheritance across class hierarchies
- Open vs closed shapes
- Design principles for validation strategy
The Standard
SHACL is a W3C standard. The core constraint components used in matrix development:
| Component | Purpose |
|---|---|
sh:targetClass | Which class the shape validates |
sh:property | A property constraint |
sh:path | Which property is constrained |
sh:datatype | Expected literal type (xsd:string, xsd:integer, etc.) |
sh:class | Expected resource type for object properties |
sh:minCount / sh:maxCount | Cardinality (required, single-valued, etc.) |
sh:in | Enumerated allowed values |
sh:pattern | Regex pattern for string values |
sh:severity | Violation, Warning, or Info |
sh:message | Human/AI-readable description of the constraint |
See Also
- Constraints and Validation: patterns and best practices for SHACL in matrix development
- SHACL Specification: the W3C standard
- SHACL Advanced Features: SPARQL-based constraints and rules