Shifty

PyPI Crates.io docs.rs GitHub BSD-3-Clause
pip install pyshifty cargo install --path crates/shifty-cli

Shifty is a SHACL/SHACL-AF inference and validation engine for RDF graphs. It is available from Python, the command line, C++17, Rust, and WebAssembly.

Quick start

Validate a data graph against a shapes graph:

shifty validate --shapes shapes.ttl --data data.ttl
conforms: false — 1 violation in 2 findings

Finding 1 of 2
  target       class(ex:Person)
  severity     Violation
  shape        ex:PersonShape
  failure      at least 1 value(s) required along ex:email, found 0
  path         ex:email
  found        0 value(s) along the path; at least 1 required
  requirement  ∃[1..] ex:email

  affects      ex:bob
  value node   (the focus node itself)
  also fails   Finding 2

Finding 2 of 2
  target       class(ex:Person)
  severity     Violation
  shape        ex:PersonShape
  failure      test(datatype(xsd:string)) not satisfied
  path         ex:name
  requirement  test(datatype(xsd:string))

  affects      ex:bob
  value node   "123"^^xsd:integer
  also fails   Finding 1

notation
  ∃[m..n] p . X   between m and n values along p satisfy X

Run SHACL-AF rules to a fixed point:

shifty infer --shapes rules.ttl --data data.ttl

The structured Python interface returns a validation decision and reasons:

import shifty


result = shifty.validate_algebra("data.ttl", "shapes.ttl")
print("conforms:", result.conforms)
for violation in result.violations:
    print(violation.focus_node)
conforms: False
<http://example.org/bob>

The playground runs the WebAssembly build locally in the browser, so graphs entered there do not leave the machine.

Validation interfaces

Shifty compiles SHACL into the path and shape algebra developed in Ahmetaj et al., Common Foundations for SHACL, ShEx, and PG-Schema (The Web Conference 2025). The compiled representation supports normalization, shared subexpressions, indexed target selection, and cost-based planning before evaluation begins.

Two result interfaces are available:

Interface

Result

Native algebraic

validate_algebra() returns structured violations and their nested algebraic reasons; the CLI renders the same result model by default. This is the lower-overhead reporting path and does not construct a W3C sh:ValidationReport.

W3C-compatible

validate() and shifty validate --report return a W3C sh:ValidationReport for interoperability with SHACL tooling.

The native representation also supports evidence, passing-node property witnesses, and shape-map bindings. See Result interfaces for the tradeoffs between the two result models and Introducing the Shifty SHACL Engine for the original rationale.

Interface support

Python

pip install pyshifty. Validate, infer, explain, and reuse prepared schemas from pyshifty.

Command line

Install the shifty binary and use it in scripts or CI.

C++

Link the C++17 static library and use its prepared-validator API.

Rust

Use the engine crates directly; API details live on docs.rs.

Browser / WebAssembly

Run Shifty locally in the browser.

Common tasks

Run a first validation

Install Shifty, validate a small graph, and fix one failure.

Configure validation

Choose graph visibility, report format, severity threshold, and named entry shapes.

Run inference

Execute SHACL-AF rules and retrieve the inferred triples.

Explain a failure

Trace a finding through its compiled constraint and supporting triples.

Extract shape-map bindings

Query which focus nodes and values matched selected shapes.

Inspect the compiler pipeline

Inspect the lowered algebra, normalization, recursion strata, and plan.

Compute symbolic repairs

Explore candidate graph edits with the experimental repair API.

Note

Symbolic repair is experimental. Its API may change; see Repair a graph for its current scope.

Documentation

Tutorials

Guided introductions to validation, results, and evidence.

How-to guides

Procedures for specific validation and inference tasks.

Reference

Interfaces, options, fields, and feature-support boundaries.

Explanation

Design, semantics, and performance tradeoffs.

Benchmarks

Validation performance across real building models, tracked per release.

The documentation contribution guide describes the page conventions and preview workflow. Documentation issues can be filed on GitHub.