Layered like baklava.
Linked like a graph.
graphlava is an embedded metagraph database in Rust, built for agent memory. Statements carry statements, hyperedges are stored once, and graphs nest inside graphs, all in one file, queried with SPARQL 1.2 and Datalog.
Status: alpha (0.1.0-alpha.2). The engine runs: store, named and nested graphs, hyperedges, SPARQL 1.2, Datalog and a graphlava command-line tool. It is a pre-release and the file format is not frozen, so a later version may not open today's files. Keep your data in RDF too and nothing you cannot regenerate. The Python, Node.js, Swift and Kotlin bindings are still in progress.
cargo install graphlava-cli --version 0.1.0-alpha.2
alpha.2 moves the storage engine to redb 4.6 and needs Rust 1.90 or newer. On 10M statements the relaxed mix p99 drops from 613 µs to 166 µs and a file takes 257 bytes per statement instead of 411. Files written by alpha.1 do not open.
One piece, four layers
Read the logo from the outside in. The pastry layers are statements stacked on statements. The diamond is a graph that holds them. The pistachio is a hyperedge: one centre, many roles.
Statements about statements
Every statement has a stable 64-bit ID. Annotate it with a confidence or a source; change its object and the ID, with its annotations, stays.
Hyperedges
A meeting with an agent, a target and a topic is one record with typed roles, indexed per role; its date is a property of the record. Role triples stay virtual until you annotate one.
Nested graphs
Graphs are nodes and nest as a DAG. GRAPH :g sees g and everything under it; GRAPH! :g sees only g.
Meta-model as data
Predicates, hyperedge types, shapes and rules are statements in the system graph, read by the planner and the write path.
A taste
The statement ID is the RDF 1.2 reifier, so annotating a fact and reading the annotation back are plain scans with no join on rdf:reifies.
# a fact with a confidence on it
INSERT DATA { :alice :worksAt :acme {| :confidence 0.9 |} }
# who works at Acme, and how sure are we?
SELECT ?who ?c WHERE {
<< ?who :worksAt :acme ~ ?r >> .
?r :confidence ?c .
FILTER(?c > 0.8)
}
# the same memory from Datalog: rules run on demand in v0; @materialized arrives in v1
@materialized
ancestor(?x, ?y) :- :parent(?x, ?y) .
ancestor(?x, ?z) :- ancestor(?x, ?y), :parent(?y, ?z) .
?- ancestor(:alice, ?who) .
How it stacks
One process, one file. Every query language lowers to one extended-Datalog IR; only the storage layer knows the engine.
A sibling, not a fork
graphlava and tiramemsu share the idea that every fact is a statement with an ID. They split on time.
| graphlava | tiramemsu | |
|---|---|---|
| State | Current state only; values overwrite in place | Never forgets; every change kept with two clocks |
| Change a fact | update(id, o), same ID | supersede, a new statement that replays its layers |
| n-ary relations | Native hyperedge records | A node with role statements, or an annotated edge |
| Storage | redb 4.6 | SQLite (default) or redb |
| Status | Alpha, 0.1.0-alpha.2 | Released, 0.12 |
More in graphlava and tiramemsu.
Read
Mini book: hypergraphs and metagraphs in statement graphs
From binary edges to recursive metagraphs, and how to model each part with statements and in graphlava.
Statement graphs
The one data model under RDF, RDF-star and property graphs, and how graphlava stores it.
graphlava and tiramemsu
Two stores from one idea: mutable current state versus layered, never-forget memory.
graphlava and Neptune OneGraph
What an embedded store takes from Amazon's 1G model, and where it goes its own way.