graphlava

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.

The graphlava logo: a diamond of baklava with pastry layers on its sides and, on top, four nodes joined to a pistachio in the centre.

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.

Surfaces SPARQL 1.2, Datalog, Rust and C (v0) · Cypher subset, Swift, Kotlin (v1)
IR and planner extended Datalog · index nested-loop, Leapfrog Triejoin, merge and hash joins · plan cache
Reasoning, vectors on-demand rules: magic sets, semi-naive (v0) · materialized rules, scope-aware vector search (v1)
Data model statements · inline properties · hyperedges · nested graphs
Terms 64-bit IDs with a kind tag · inline literals · dictionary
Storage redb 4.6, one file, one owner process · sync, ordered or relaxed commits

A sibling, not a fork

graphlava and tiramemsu share the idea that every fact is a statement with an ID. They split on time.

graphlavatiramemsu
StateCurrent state only; values overwrite in placeNever forgets; every change kept with two clocks
Change a factupdate(id, o), same IDsupersede, a new statement that replays its layers
n-ary relationsNative hyperedge recordsA node with role statements, or an annotated edge
Storageredb 4.6SQLite (default) or redb
StatusAlpha, 0.1.0-alpha.2Released, 0.12

More in graphlava and tiramemsu.

Read