shacl2cypher
Reference

Every option, field and exit code

For version 0.2.0. Run shacl2cypher <command> --help for the options of the binary you have installed.

compile · validate · schema dump · s2c: annotations · supported SHACL · datatypes · manifest · rows · reports · exit codes

compile

Compile shapes files (Turtle .ttl, N-Triples .nt, TriG .trig) into manifest.json and queries.cypher.

shacl2cypher compile [OPTIONS] --dialect <DIALECT> <SHAPES>...
--dialect neo4j|ladybug
Target Cypher dialect. Required.
--schema <FILE>
Schema snapshot JSON. Required for ladybug. Optional for neo4j, where it adds evidence for resolution and diagnostics.
--ontology <FILE>
Repeatable. Files contributing rdfs:subClassOf statements for class expansion.
--node-key <PROPERTY>
Property identifying nodes in rows when a shape has no s2c:key. Also needed when IRI constants are compared with relationship values.
--neo4j-labels explicit|inherited
explicit (default) matches every subclass label. inherited assumes nodes already carry their superclass labels.
--strict
Fail on any label, property or relationship type chosen by convention alone.
--lenient
Record unsupported features as unsupported rules instead of failing.
--verbose
Include all focus properties in detail rows.
--max-path-depth <N>
Upper bound for sh:zeroOrMorePath/sh:oneOrMorePath. Default 10; LadybugDB allows at most 30.
--allow-remote-imports
Fetch owl:imports of http(s) IRIs (30 s timeout, 16 MB cap).
--fail-on-schema-mismatch
Turn static schema diagnostics into one compile error.
-o, --output <DIR>
Output directory. Default: the working directory.

Compile errors print one error: line per problem with file:line, write no files and exit 1. Static diagnostics print as warning: file:line: code: message.

validate

Validate a database against shapes files, compiled in memory for the connected dialect, or against a compiled manifest.

shacl2cypher validate [OPTIONS] [SHAPES]...

It accepts every compile option except --dialect and -o, plus:

--manifest <FILE>
Run a manifest written by compile. A manifest for another dialect is rejected.
--connect <URI>
Neo4j Bolt URI, e.g. bolt://localhost:7687.
--user, --password, --database
Neo4j credentials (NEO4J_USER, NEO4J_PASSWORD) and database name.
--ladybug <FILE>
LadybugDB database file, opened read-only. A missing file is an error.
--format table|json|junit|sarif
Report format. Default table.
-o, --output <FILE>
Write the report to a file instead of stdout.
--limit <N>
Violations listed per rule. Default 100; 0 lists all.
--sample-size <N>
Focus samples per summary row. Default 5.
--timeout <SECONDS>
Per-query timeout. A timed-out rule is reported and the other rules still run.
--fail-on violation|warning|info
Lowest severity whose violations fail the run. Default violation.

Every rule with queries runs its summary query. Rules with violations then run their detail query.

schema dump

shacl2cypher schema dump (--connect <URI> | --ladybug <FILE>) [-o schema.json]

Writes a snapshot that compile --schema accepts unchanged:

{
  "nodeTypes": [{ "name": "Person", "properties": [{ "name": "email", "type": "STRING" }] }],
  "relTypes":  [{ "name": "KNOWS", "endpoints": [{ "from": "Person", "to": "Person" }],
                  "properties": [{ "name": "since", "type": "DATE" }] }]
}

Types: STRING, INT64/INT32/INT16/INT8, UINT64…UINT8, DOUBLE, FLOAT, DECIMAL, BOOLEAN, DATE, LOCAL_DATETIME, ZONED_DATETIME, LOCAL_TIME, ZONED_TIME, DURATION, POINT, BLOB, ANY and LIST<T>. On Neo4j the snapshot reflects observed data: mixed types become ANY, and endpoints come from a scan of every relationship.

The s2c: annotation vocabulary

Declare @prefix s2c: <https://w3id.org/shacl2cypher#> . Other SHACL engines ignore these triples. Parsing is strict: an unknown s2c: predicate, an invalid value or a wrong subject is a compile error.

AnnotationSubjectMeaning
s2c:labelclass IRI or node shapelabel / node table name
s2c:propertypredicate or property shapeproperty key
s2c:relationshippredicate or property shaperelationship type / rel table
s2c:directionpredicate or property shape"out" or "in"
s2c:keynode shapeidentifying property of the focus label
s2c:datatypepredicate or property shapeexact native type, e.g. "LOCAL_DATETIME"
s2c:collectionpredicate or property shape"list" (one value per element) or "scalar"
s2c:iriAsStringproperty shapeIRI constants as "local" names (default) or "full" IRIs
s2c:targetRelationshipnode shapeevery relationship of this type is a focus
s2c:nameany shapeexplicit rule name

Supported SHACL

GroupFeatures
Targetssh:targetClass, implicit class targets, sh:targetSubjectsOf, sh:targetObjectsOf, s2c:targetRelationship
Cardinalitysh:minCount, sh:maxCount
Value typesh:datatype, sh:nodeKind, sh:class
Rangessh:minInclusive, sh:maxInclusive, sh:minExclusive, sh:maxExclusive
Stringssh:minLength, sh:maxLength, sh:pattern with sh:flags (i, s, m, x, q)
Othersh:in, sh:hasValue, sh:equals, sh:disjoint, sh:lessThan, sh:lessThanOrEquals, sh:closed, sh:ignoredProperties
Metadatash:severity, sh:message (with {$this}/{?value}), sh:deactivated
Logicalsh:node, sh:not, sh:and, sh:or, sh:xone
Qualifiedsh:qualifiedValueShape, sh:qualifiedMinCount, sh:qualifiedMaxCount, sh:qualifiedValueShapesDisjoint
Pathssequence, sh:inversePath, sh:alternativePath, sh:zeroOrMorePath, sh:oneOrMorePath, sh:zeroOrOnePath

Rejected at compile time (or unsupported rules with --lenient): sh:targetNode, SHACL-SPARQL, sh:languageIn, sh:uniqueLang, rdf:langString, and recursive shapes. Property shapes nested inside property shapes are not supported yet.

Datatypes

XSDNeo4j 5LadybugDB
xsd:string, xsd:anyURIIS :: STRINGSTRING
xsd:integer, long, int, short, byteIS :: INTEGER plus a range check for narrow typesINT64/INT32/INT16/INT8
xsd:decimal, double, floatIS :: FLOAT (decimal is lossy)DECIMAL/DOUBLE/FLOAT
xsd:booleanIS :: BOOLEANBOOL
xsd:dateIS :: DATEDATE
xsd:dateTimeZONED DATETIME or LOCAL DATETIMETIMESTAMP
xsd:durationIS :: DURATIONINTERVAL
rdf:langStringcompile errorcompile error

Manifest

Top-level fields: schemaVersion, compilerVersion, dialect, inputs ({path, role, sha256}), schemaSnapshotHash, options, rules, staticDiagnostics, recommendedIndexes.

Each rule: name, ruleId, fingerprint, shape, path, constraint, severity, status, costClass, source, statusReason, pathDepthCap, message and queries (detail, summary, or null).

StatusMeaning
compiledHas queries.
guaranteed-by-schemaThe enforced schema (LadybugDB) already guarantees it; no query.
schema-mismatchThe enforced schema contradicts it; a static diagnostic explains why.
deactivatedsh:deactivated true.
unsupportedA rejected feature, recorded under --lenient.

Cost classes, most to least expensive: unbounded-path, quadratic (pair constraints over relationship paths), scan+expand (any traversal), scan.

Rule ids are structural, e.g. ex:PersonShape/ex:address/sh:or[0]/ex:street/sh:minCount. Names use local names (PersonShape.name.minCount). On a collision, a 6-hex content hash is appended.

Result rows

Detail rows (one per violation, capped by $limit): ruleId, shape, path, constraint, severity, focus, value, message, details.

Summary rows (exactly one per rule, even with zero violations): ruleId, severity, violationCount, sample.

Reports

FormatContent
tablestatus, severity, count and time per rule, up to 10 violations each, then totals
jsonthe full report: conforms, complete, a summary, and every rule with durationMs and detail rows
junitone test case per rule; violations are failures, timeouts and query errors are errors
sarifSARIF 2.1.0, one result per violation located at the constraint's shapes file and line

Rule statuses in a report: passed, failed, timeout, error, skipped (deactivated, unsupported, schema-mismatch), guaranteed-by-schema.

Exit codes

CodeMeaning
0No rule at or above --fail-on has violations, and every query completed.
1A rule at or above --fail-on has violations. For compile: compile errors.
2Usage or setup error: bad arguments, compile errors during validate, unreachable database, or no backend compiled in.
3Nothing failed, but a query timed out or errored, so the result is incomplete.