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:

ComponentPurpose
sh:targetClassWhich class the shape validates
sh:propertyA property constraint
sh:pathWhich property is constrained
sh:datatypeExpected literal type (xsd:string, xsd:integer, etc.)
sh:classExpected resource type for object properties
sh:minCount / sh:maxCountCardinality (required, single-valued, etc.)
sh:inEnumerated allowed values
sh:patternRegex pattern for string values
sh:severityViolation, Warning, or Info
sh:messageHuman/AI-readable description of the constraint

See Also

On this page