Data validity rules
Waratah enforces a small set of data-validity rules on every write path.
These are server-side data contracts: they reject input that RDF 1.1
syntax technically permits, on the grounds that it is semantically wrong
and no real-world data uses it. They are deliberately distinct from the
SPARQL deviations, which concern query
semantics — validity rules constrain what the server stores, and they are
unconditional: they are not gated by --strict-sparql.
Every write path funnels through one place — WriteFanout::insert_quads
(waratah_compute/src/fanout.rs) — which serves the HTTP ingest API,
waratah import (online and offline), the demo load, and standalone
mode.
The object of rdf:type must be an IRI or a blank node
The rule matches the exact predicate IRI rdf:type. Any other predicate —
including properties you define that resemble rdf:type — is not
affected.
| Quad | Accepted |
|---|---|
|
yes |
|
yes |
|
no |
|
yes |
|
The last row: a subproperty of |
Why
Two reasons, one semantic and one structural.
Semantic. RDFS types the object of rdf:type as a class identified by
an IRI. A literal in that position is legal RDF syntax but semantically
wrong, and no real-world dataset uses it — the realistic producer is a
CSV-to-RDF conversion that mapped a column of labels into the type
position. Refusing it at the door gives that mistake a loud, named
failure instead of silently stored data that no class query matches.
Structural. The TSG column family keys rdf:type quads as
Type‖Subject‖Graph. With literal type objects excluded, every slot-0
term is a node encoding — and every node encoding (named node plus the
three blank-node variants) is exactly 17 bytes: one type byte plus a
16-byte payload. The tsg column family therefore uses the same fixed
17-byte prefix extractor as the S- and P-leading column families
(waratah_storage/src/rocksdb.rs). A unit test in
waratah_storage/src/encode/binary.rs pins the 17-byte width of every
node encoding so a future node variant cannot silently misalign the
prefix.
Where it is enforced and what happens
WriteFanout::insert_quads validates the whole quad slice before any
InsertQuads chunk is sent: one offending quad rejects the entire call
with ComputeError::InvalidQuad, and no axis, registry, or blob RPC is
attempted. Validation is also op-independent — a delete of such a quad is
rejected identically, since a quad this store can never hold is invalid
either way.
Surfaces:
-
HTTP ingest answers
400with a message naming the violated rule and the offending quad (waratah_api/src/error.rs). -
File loads (HTTP ingest and
waratah import) stream inINSERT_QUAD_CHUNKbatches, so a violation aborts the load at the first batch containing it; earlier batches stay committed — the same behavior as the oversized-literal rejection. -
In-process callers see
ComputeError::InvalidQuaddirectly.