Expand description
§purrdf — a wasm32, in-memory RDF 1.2 engine with an idiomatic RDF/JS API
Parcel P10 of the purrdf program (docs/design/PurRDF-PLAN.md).
This crate compiles the oxigraph-free, PyO3-free purrdf kernel to
wasm32-unknown-unknown and exposes it to JavaScript/TypeScript through the
RDF/JS community spec — DataFactory, DatasetCore, and
Stream/Sink — packaged for npm/ESM as purrdf.
§Scope (by charter)
- In-memory only. The oxigraph
Store(RocksDB) andcrates/logicdo not compile to wasm and are deliberately excluded — this is the value-interned IR + the COWMutableDataset, not a persistent quad store. - Offline SPARQL. The native, oxigraph-free multiset evaluator
(
purrdf_sparql_eval) binds to the wasmDataset(see thequerymodule), so SELECT / ASK / CONSTRUCT / DESCRIBE run client-side with no server. Only the host can provide SERVICE federation; this default browser surface installs no remote source, soSERVICE/LOADhard-fails here rather than silently returning a partial answer. - Separate from the C-ABI (P8). WASM has its own ownership model,
packaging, and async I/O; it is not a C-ABI consumer and does not depend on the
no_stdtrack.
§The RDF-1.2 wedge
No incumbent RDF/JS library carries RDF-1.2 quoted-triple terms or directional
literals. purrdf’s DataFactory accepts a quoted triple anywhere a term is
expected (termType: "Quad" as subject/object) and round-trips base direction on
literals — the deliberate “overcome, don’t inherit” extension to stock RDF/JS
(.goals: SUBSUME, EXTEND, ENHANCE).
§Architecture
The #[wasm_bindgen] surface is a thin shim over purrdf seams that already
exist: TermFactory (the DataFactory 1:1 map), DatasetMut/MutableDataset (the
mutable DatasetCore), native_codecs (parse/serialize), and the
purrdf-events protocol (the Stream/Sink). Mapping logic lives in plain
Rust so it unit-tests on the native workspace gate; the wasm-bindgen wrappers are
exercised as real wasm under wasm-pack test --node.
Modules§
- shacl
- SHACL validation → SARIF 2.1.0 for the wasm/JS surface.
Structs§
- Compiled
Json LdContext - An immutable JSON-LD 1.1 context compiled once and reusable across datasets.
- Data
Factory - An RDF/JS
DataFactory. Stateless except for the auto-generated blank-node counter (blankNode()with no argument mints a fresh label). - Dataset
- An RDF/JS
DatasetCorebacked by the engine’s COW mutable dataset. - Projection
Lift - Result of lifting a strict carrier package into an in-memory RDF dataset.
- Projection
Package - A deterministic USTAR projection package and its canonical runtime ledger.
- Quad
- An RDF/JS Quad — a statement
(subject, predicate, object, graph)withtermType: "Quad". - Query
Engine - A reusable SPARQL engine that keeps the native plan cache alive across calls.
- Query
Result - A typed SPARQL result returned by the raw wasm binding.
- Select
Result - A typed SELECT result returned by the raw wasm binding.
- Select
Row - One SELECT binding row.
- Sink
- An RDF/JS
Sink— a streaming consumer that interns pushed quads through thepurrdf-eventsprotocol and freezes them atfinish(). - Term
- An RDF/JS Term.
Functions§
- lift_
projection - Lift a strict bidirectional USTAR package into an in-memory RDF dataset.
- version
- The purrdf engine version (the crate’s SemVer), exposed to JS as
version().