Mini book
Hypergraphs and Metagraphs in Statement Graphs
A short, practical path from binary edges to recursive metagraphs, and how to model each step with identified statements and in graphlava.
Who this is for
You build memory for agents, or a knowledge graph that has outgrown plain edges. You know what a triple is. You have hit at least one of these: a relation with more than two ends, a fact you need to qualify ("how sure are we?"), or a group of facts you need to treat as one thing.
The book is short on purpose. Each chapter introduces one structure, shows how it is usually encoded, and then shows how a statement graph and graphlava hold it.
The ladder
Graph structures form a ladder. Each rung can express everything the rung below can, and more:
Binary graph ⊂ Hypergraph ⊂ Metagraph ⊂ Recursive metagraph
two ends many ends edges are metagraphs inside
vertices, metagraphs, to any
vertices hold depth
subgraphs
Every rung costs something: more structure to store, more cases for the query planner, more for a reader to understand. So the rule of the book is simple. Climb only as far as the problem needs. A binary edge that never needs a comment should stay a binary edge.
graphlava is at the design stage. The specifications, decision records and CI exist; the engine does not. Every graphlava example follows the specs in the repository (tg.md/ and docs/adr/). Where a syntax is not specified yet, the example is marked sketch, syntax not final. In the specs the project still has its working name, meta-core.
The running example
All chapters use one small agent memory. The prefix : stands for <http://example.org/>. Three people, :alice, :bob and :carol, and a company, :acme. The agent believes :alice :worksAt :acme, with a confidence of 0.9, learned in conversation :chat12. Alice met Bob about :pricing on 2026-11-20: one meeting with three roles (agent, target, topic) and a date, which we call e1. What the agent learned in that conversation sits in an episode graph :session7, nested in :aliceMemory, nested in :agentMemory. A Datalog rule derives who are colleagues from two :worksAt facts.
Contents
- 1. Graphs, and where they stopBinary edges, a meeting of three people, and the four signs that you have hit the hypergraph wall.
- 2. HypergraphsEdges with many ends: definitions, direction, the incidence matrix, and the encodings that keep or lose the grouping.
- 3. MetagraphsEdges that are vertices and vertices that hold subgraphs: Basu and Blanning, Gapanyuk, Goertzel's fold and unfold.
- 4. Statement graphsOne identified (s, p, o) as the common substrate, its images for RDF and property graphs, and graphlava's single ID space.
- 5. Modeling hyperedgesThree ways to store a meeting: role statements, graphlava's hyperedge record, and tiramemsu's choices.
- 6. Statements about statementsAnnotations, reifiers, inline properties and promotion, cascade delete, and the epistemic layer.
- 7. Containers: named and nested graphsVertices that hold subgraphs: membership, scope, the nesting DAG, and edges as containers.
- 8. The meta-modelSchema, hyperedge types, shapes and rules stored as statements in the system graph.
- 9. Fold, unfold and reasoningSwitching levels of detail and deriving facts with Datalog over a metagraph.
- 10. A worked exampleThe whole agent memory, end to end, in one place.
- 11. Choosing an encodingA cheat sheet: which rung, which structure, and what it costs.
Further reading
The theory in chapters 1 to 3 is told at length in Metagraph for AI Agents by Volodymyr Pavlyshyn, which also covers relational, LadybugDB and TypeDB encodings, Semantic Spacetime and layered agent memory. For the sibling store that keeps every change with two clocks, see tiramemsu.