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.
Geometry validation
The geo WritePlugin prepares each write chunk before any registry, blob,
index, or axis RPC for that chunk. A geometry validation error therefore
leaves the failing chunk unapplied. File imports are already split into
bounded parser chunks, so earlier chunks remain committed and later chunks
are not attempted. This is not whole-file prevalidation and not a rollback
protocol.
Exactly collinear zero-area ring spikes are the only repair-style exception.
waratah_geo::validation::reduce_tolerated_spikes removes backtracking
vertices, revalidates the result, and checks area preservation. The original
canonical EWKB remains the blob payload and materializes unchanged.
EncodedTerm::LiteralGeometry::requires_spike_reduction is packed into an
unused high bit of the geometry-kind byte, so the term remains 20 bytes. The
reduced geometry drives envelopes, S2 postings, and Relate. Flagged native stored
candidates are reduced after blob decode; parsed typed literals and unindexed
values use the same reducer without a term flag. Unflagged legacy spikes make a
rebuild fail rather than silently indexing a different interpretation. Accepted
spikes travel through PreparedInsert::warnings; the online and offline write
shells emit them after a successful batch, and CLI imports report the per-load
total.
Recovery is to fix the source geometry, re-ingest the corrected file, and run
waratah geo rebuild-index --data-dir <data-dir> on a stopped store to
recreate the geo postings from scratch. Transport and storage failures are a
separate case: they do not carry a blanket transactional guarantee across
registry, blob, index, and axis writes.