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.

For a W3C sh:ValidationReport, use validate() in Python or shifty validate --report on the CLI. See Validation results and evidence to choose between reports, structured findings, and evidence.

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

Validate a model

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.

Compute symbolic repairs

Explore candidate graph edits with the experimental repair API.

Write shapes in Shapeshift

Write SHACL shapes in a short language of their own, or from Python.

Build a repair benchmark

Generate broken graphs with known repairs to evaluate a repair tool.

Note

Symbolic repair, Shapeshift, and violation generation are experimental. Their APIs, and the Shapeshift language, may change in any release; see Experimental.

Use the tutorials to learn the interfaces, how-to guides for specific tasks, and the reference for exact options and fields. Explanation covers graph evaluation and results.

See SHACL conformance for the SHACL validator’s test results and Benchmarks for validation timings. Contributing covers development checks and documentation conventions.