Skip to main content

Crate ikigai_shacl

Crate ikigai_shacl 

Source
Expand description

ikigai-shacl — SHACL validation as an ikigai resource.

urn:shacl:validate validates a piped RDF data graph against a SHACL shapes graph. The validation report is itself an RDF graph: the default text/turtle output is the SHACL ValidationReport (conforms + a node per violation), skolemized under a content address of the report so it carries no blank node (every one is named under REPORT_SCHEME), and application/json gives a structured Report — {conforms, violations: [{focus_node, path, component, message, value}]} — content-negotiated structured errors for free. Both faces carry the same facts: the sh:resultMessage with its {?value}-style template resolved, the offending sh:value, and the sh:resultPath.

shapes is taken by reference (the ROC-idiomatic form: a shapes graph is a resource you point at, sourced through the kernel — cacheable, golden-threaded); inline Turtle is also accepted. So the endpoint is async (the one await is the shapes resolution).

§Two validators, one resource (ledger #1176)

  • rudof (the default feature): rudof’s consolidated shacl crate, all of SHACL Core and SHACL-SPARQL’s sh:select, behind the bounds in rudof_engine. A heavy dependency tree, and one that cannot be built without a network stack on native (rudof’s IRI crate links reqwest, and its RDF crate turns on tokio).
  • core_shacl, always compiled: a subset validator with no rudof, no network stack and no recursion over either graph, for a host that turns rudof off. It REFUSES, by name, every SHACL term outside that subset rather than skip a constraint it does not understand. Vocab 0.5.7 shapes use sh:or and require rudof. Its sh:sparql / sh:select constraints come with the sparql feature (which rudof implies), and with it oxigraph’s store and ikigai-store’s guards and time budget. With default features off it is the CORE constraints alone, on oxrdf and oxttl (ledger #2107): small enough for an in-page wasm kernel, bounded by work rather than time (core_shacl::MAX_VALIDATION_WORK), and refusing a SHACL-SPARQL construct by name.

With both compiled the endpoint uses rudof; tests/differential.rs runs both over one corpus and requires the same verdicts. The module feature (a lazy-loadable WASM module) implies rudof. The JavaScript shacl-engine remains a third implementation of the same urn:shacl:validate resource, held to the parity corpus (see js-parity/).

Modules§

core_shacl
A SHACL subset validator with no rudof, no network stack and no recursion (ledger #1176).

Structs§

QuotedTriple
The value of a Term::Triple: an RDF-star quoted triple.
Report
The application/json face of urn:shacl:validate: conforms + one ReportResult per sh:result, sorted. The exact shape, pinned — this is what a consumer parses:
ReportResult
One validation result as the application/json face reports it. The first three keys are the parity Violation signature and keep their names and order; message and value follow. Sorted by these fields in this order, so a report is deterministic.
ValidationOutcome
The portable validation outcome: conforms + the sorted violation signatures. This is the parity contract in tests/corpus/*/expected.json (see tests/parity.rs); the endpoint’s application/json face is the richer Report.
Violation
One conformance violation, reduced to its implementation-independent signature — the spec-defined parts every SHACL validator agrees on. (Deliberately omits sh:resultMessage and blank-node ids, which legitimately differ between validators.) This is the cross-impl parity contract: rudof (native) and shacl-engine (browser) must produce the same set. The endpoint’s JSON face is the richer ReportResult; a signature is its first three keys.

Enums§

Term
An RDF term in the SPARQL 1.1 Query Results JSON encoding — {"type": "uri" | "bnode" | "literal", "value": …}, a literal carrying "xml:lang" when language-tagged and "datatype" when typed (a plain xsd:string carries neither, as in that spec). An RDF-star quoted triple is {"type": "triple", "value": {subject, predicate, object}} (the SPARQL 1.2 form).

Constants§

MAX_DATA_RECURSION
How deep validation may recurse along the DATA, counted in nested shape validations: the shapes graph’s own depth, plus the shapes in its recursive groups that move along a path times the data nodes along the longest chain of those paths’ links (a cycle in the data counting all of its nodes, as a recursive group of shapes does). 16,384 admits a self-recursive foaf:knows-style shape (two shapes a link) over about 8,000 people in one chain or one strongly connected group. A cycle is no escape: rudof cuts it where it closes, so a ring of 3,000 recursed as deep as a chain of 3,000 and aborted the same way. Validation is given a stack grown for each level the data can reach, so the bound, not the thread, is what refuses.
MAX_SHAPE_DEPTH
How deep the shapes graph may nest, counted in NODES along the longest chain of shape references and path operators, a recursive group counting all its shapes. The same 64, and far from both ends: the deepest shapes graphs in the ecosystem measure 5 (ikigai-vocab’s shapes.ttl and ikigai-core’s fn.shape.ttl, 2026-10-10, by the ignored measure test; this crate’s parity corpus is 3), while a debug build compiled 100 levels of sh:not on a 2 MiB thread and aborted at 300, and compiling now runs on 16 MiB or more.
MAX_TURTLE_NESTING
How deep caller RDF may nest RDF 1.2 triple terms and reified triples (<<( … )>>, << … >>), counted per <<; for RDF/XML, per nested element carrying rdf:parseType. The same number as ikigai_store::limits::MAX_SPARQL_NESTING and ikigai-shacl’s: one bound on caller nesting across the doors. Real data nests these a handful deep; a debug build survived 300 levels on a 2 MiB thread and aborted at 3000.
REPORT_SCHEME
The prefix every node of the report graph is named under: urn:ikigai:shacl:report:<content id of the report graph>:<blank-node label>. A consumer can recognize a node this crate minted by this prefix, and nothing else in a report carries it.
SPACE_ID
The name space claims: urn:iki:space:shacl.

Functions§

space
The space binding urn:shacl:validate. It is configuration-free (no parameters, nothing read while building it), so it names itself SPACE_ID; the name goes on LAST, because binding a door after naming drops the name (core 0.1.89).
validate_outcome
Validate data_ttl against shapes_ttl, returning the portable ValidationOutcome — the parity contract.
validate_report
Validate data_ttl against shapes_ttl, returning the full Report — what the application/json face serializes. rudof with the rudof feature, else core_shacl. With sparql (which rudof implies), within the base time budget (5 s), past which it is refused with a typed Error::OverBudget (a library call carries no capability to grant more); without it, within core_shacl::MAX_VALIDATION_WORK, past which it is refused with a typed Error::InvalidArgument.
validate_turtle
Validate data_ttl against shapes_ttl, returning the report graph as Turtle — what the default text/turtle face serves. rudof with the rudof feature, else core_shacl; within the same bound as validate_report.