Graphs, Hypergraphs, Metagraph for Agentic AI

Metastrudel: a mini book on a database where everything is an element

A 32-page canvas book on typed metagraphs: elements, contexts, signatures, refinements, queries stored as data, and Lean as the specification.

December 03, 2026

2

Metastrudel stores a typed metagraph. Links, types, schemas, whole subgraphs and even your queries are stored elements with an identity, so you can point at any of them, type them and query them.

Start here: the book canvas

The canvas below is the map of the book. Click any card to open that section, then follow the arrows from 1 to 5: why a new graph model, the kernel, types, queries, proof and status. Each section page carries its drawings. The logo and the project site metastrudel.org are at the bottom of the canvas.

Click a card to open its section, follow the arrows 1 to 5

Click a card to open its section, follow the arrows 1 to 5

Start here: how to read this book
Start here: how to read this book
Metastrudel is a database whose native model is a typed metagraph. Everything stored is an element. Elements are connected by links, and every element is typed inside a context. Links, types, schemas, subgraphs and even queries are elements you can point at and query.
Follow the arrows on the canvas: five sections, each a short page. The full illustrated version, with 32 pages and a drawing on each, is the interactive book: https://claude.ai/artifact/DxDHcY8RKMDESLYHDT6VUo

Start here: how to read this book

Metastrudel is a database whose native model is a typed metagraph. Everything stored is an element. Elements are connected by links, and every element is typed inside a context. Links, types, schemas, subgraphs and even queries are elements you can point at and query.

Follow the arrows on the canvas: five sections, each a short page. The full illustrated version, with 32 pages and a drawing on each, is the interactive book: https://claude.ai/artifact/DxDHcY8RKMDESLYHDT6VUo

One question runs through the whole book: who asserted that Alice owns the car, under which schema is that ownership valid, and which stored query depends on the type owns?

1 · Why a new graph model
1 · Why a new graph model
A triple says one thing. Alice met Bob about pricing on 2026-11-20, and Alice met Carol about hiring on 2026-11-21. As triples the grouping is gone: which topic belongs to which meeting? A meeting is one fact with four parts, not four facts. Making the meeting a node with role edges (agent, target, topic, when) fixes that, until you hit the hypergraph wall: a statement about a relationship, a relationship between relationships, rich properties on a relationship, nested beliefs. Each asks for the same thing: a connection must be something you can point at.
Property graphs and hypergraphs. A property graph puts key-value pairs on an edge, but a property holds a value, never a node, and nothing can point at the edge. A hypergraph fixes arity, since one hyperedge can hold Alice, Bob and the topic, but a hyperedge is not a vertex, so it cannot be the subject of another edge. RDF has the same gap: a triple has no identity unless it is reified or quoted.

1 · Why a new graph model

A triple says one thing. Alice met Bob about pricing on 2026-11-20, and Alice met Carol about hiring on 2026-11-21. As triples the grouping is gone: which topic belongs to which meeting? A meeting is one fact with four parts, not four facts. Making the meeting a node with role edges (agent, target, topic, when) fixes that, until you hit the hypergraph wall: a statement about a relationship, a relationship between relationships, rich properties on a relationship, nested beliefs. Each asks for the same thing: a connection must be something you can point at.

Property graphs and hypergraphs. A property graph puts key-value pairs on an edge, but a property holds a value, never a node, and nothing can point at the edge. A hypergraph fixes arity, since one hyperedge can hold Alice, Bob and the topic, but a hyperedge is not a vertex, so it cannot be the subject of another edge. RDF has the same gap: a triple has no identity unless it is reified or quoted.

Statements about statements. Give every statement an identifier and let it stand wherever a node can. Frankfurt has a route to London (#1). Attached to #1 are a distance of 655 km, its source (an atlas) and the atlas's trust of 90%. A second source says 650 km, and that statement conflicts with the first distance: an edge between edges. That is a statement graph, a DAG with values at the leaves in which subject and object may themselves be statements.

The metagraph. Edges are vertices: a connection has its own identity, so other connections can start or end at it. Vertices are containers: a graph is itself a node, so a session sits inside a memory that sits inside an agent's memory. Metastrudel adds the missing third piece: types, schemas and queries are elements of the same metagraph.

What a metagraph adds. A role has an identity. An attribute value can carry a source. Entities, relations and attributes share one root with two shapes, atom and link. A context is an element, edges can connect contexts, and a query runs inside one. Types and schema live in three layers. Each context is open or closed on its own.

2 · The kernel
2 · The kernel
The kernel is small on purpose. Everything the database stores is an element, and every element has the same record.
The element record. An element has an id, a home (the context it lives in), a type, a link (its role-and-value structure, empty for atoms), a valid interval and a transaction time. Atoms carry a value; links carry roles. Nothing else is stored.

2 · The kernel

The kernel is small on purpose. Everything the database stores is an element, and every element has the same record.

The element record. An element has an id, a home (the context it lives in), a type, a link (its role-and-value structure, empty for atoms), a valid interval and a transaction time. Atoms carry a value; links carry roles. Nothing else is stored.

Links, roles and values. A link is a set of named roles, and each role points at another element or holds a value. Eight primitive value kinds cover the leaves. Because a link is an element, a link can be the target of another link: statements about statements need no extra mechanism.

Contexts, home and membership. A context is an element that contains other elements. Every element has exactly one home, and can additionally be a member of other contexts. Home decides who owns the element and which schema governs it; membership decides where it is visible.

Three layers. Meta, Schema and Data. Data elements are typed by schema elements, and schema elements are typed by meta elements. There is no Type : Type, so the hierarchy stops without a paradox.

Immutable and bitemporal. Elements are never updated in place. A change writes a new element with a new transaction time, and valid time says when the fact held in the world. So you can ask what was true then, and also what we believed then.

Content-addressed identity. An element's id is a BLAKE3 hash over its home, its type and its key links. Two writers who state the same fact in the same context get the same id, which makes merging and sync a matter of set union.

5 · Proof and status
5 · Proof and status
The last section is about trust: what is normative, what is built, and what is still open.
Proof first. The Lean 4 development is the normative specification. It defines elements, contexts, typing and query semantics. Reference test vectors are generated from it, and the Rust engine must reproduce them exactly. When the two disagree, the engine is wrong.

5 · Proof and status

The last section is about trust: what is normative, what is built, and what is still open.

Proof first. The Lean 4 development is the normative specification. It defines elements, contexts, typing and query semantics. Reference test vectors are generated from it, and the Rust engine must reproduce them exactly. When the two disagree, the engine is wrong.

A graph, end to end. The book walks one small graph from the first element, through contexts, signatures and bindings, to a stored query and its answer, so each idea appears once in a working example.

What the design commits to. Everything is an element. Identity is content-addressed. History is kept, never overwritten. Types and queries are data. Each context decides for itself whether it is open or closed.

Status. Metastrudel is at the design stage. The data model is specified in Lean 4 and the engine is planned in Rust; there is no release to install yet. The kernel (milestone M0) and typing (M1) are done as of the December 2 post. The syntax in the book comes from the design documents and may still change.

Further reading. Project site: https://metastrudel.org . Source: https://github.com/Volland/metastrudel . The site also links the design blog posts. The interactive 32-page book is at https://claude.ai/artifact/DxDHcY8RKMDESLYHDT6VUo .

4 · Queries
4 · Queries
Queries in Metastrudel are not strings. A query is a metagraph, stored in the database like any other data.
Queries are metagraphs. A query is a context made of q:Match elements (patterns to find) and q:Call elements (calls to other stored queries or built-ins). For example, owners_in matches an Ownership link in a given context and returns its owner role. Because the query is data, it can be versioned, typed, shared and queried.

4 · Queries

Queries in Metastrudel are not strings. A query is a metagraph, stored in the database like any other data.

Queries are metagraphs. A query is a context made of q:Match elements (patterns to find) and q:Call elements (calls to other stored queries or built-ins). For example, owners_in matches an Ownership link in a given context and returns its owner role. Because the query is data, it can be versioned, typed, shared and queried.

Scope and absence. Every query runs inside a scope, a context or a set of contexts. Absence is meaningful: asking for elements that have no Ownership link is a question about the scope, and the answer depends on whether that context is open or closed.

Contexts as values. A context can be a value in a result. linked_teams returns contexts, active_agent names one, and touches_owns asks which contexts a link reaches. You can navigate from data to the structure that holds it.

Facts about facts. A query can match a link and also the links that talk about it: el L H T S O binds a link, its home, its type, its source and its owner in one pattern, so provenance and trust are ordinary joins.

Absence and recursion. A reaches query follows links transitively, and negation over a closed scope is stratified, so the answer is well defined.

Hypotheses and time. F => G asks what would follow if F held. Queries run at now, at a past transaction time, or bitemporally, which answers what was true then and what we knew then.

Two engines. A Datalog engine handles the common bulk path. A lean-elpi engine handles typed, higher-order and hypothetical queries. Both read the same stored queries.

Why another query language. Because queries, types and facts share one model, a tool that understands the model understands all three, and there is no separate language to keep in sync.

3 · Types
3 · Types
Types say what an element may be and what it may link to. Metastrudel's types are signatures, and they are elements like everything else.
Signatures. A signature lists the roles a link must have and what each role's target must be. A check is a lookup: does this element's link satisfy the signature it claims?

3 · Types

Types say what an element may be and what it may link to. Metastrudel's types are signatures, and they are elements like everything else.

Signatures. A signature lists the roles a link must have and what each role's target must be. A check is a lookup: does this element's link satisfy the signature it claims?

Why dependent types, and how much. Some constraints depend on values: a role's target must live in the same context as the source, or a count must match a list. We allow types to mention values, and stop well short of full theorem proving, so checking stays fast and decidable.

Parameters and bindings. A signature can take parameters. A binding is a link on conforms_to that fixes them, so instantiating a generic type is itself a stored fact you can query.

One signature, two schemas. The same Ownership signature can be bound once for team42's contexts and once for a fleet, with different parameters and different closed or open rules, and neither schema knows about the other.

Refinements. A refinement narrows a type with a predicate over its own links, for example a Route whose distance is positive. Refinements are checked when an element is written.

What we left out. No universe hierarchy, no general recursion in types, no user-written proofs inside the database. Those belong in the Lean specification, not the engine.

Declared versus derived types. A declared type is what the writer claims. A derived type is what the system can prove from the element's links: M |- x : T. A fast checker handles the common cases and falls back to the full judgment only when it must.

What types give the database. Validation at write time, schema-aware queries, safe merges across contexts, and a place to hang documentation and constraints that is queryable like any other data.

Metastrudel: a database where everything is an element

Website: https://metastrudel.org

This mini book walks through the whole model on one canvas. Each of its 32 pages explains one concept with a drawing in the same visual language, the pages are linked in reading order, and the chapters are contexts. Drag to pan, pinch or ctrl+scroll to zoom, and press O for the overview. There are five chapters.

Why a new graph model (6 pages): triples, property graphs and hypergraphs, statements about statements, and what a metagraph adds.

The kernel (6 pages): element, link, context, three layers, bitemporal time and content-addressed identity.

Types (8 pages): signatures, parameters and bindings, refinements, declared and derived types, what we left out, and what types give the database.

Queries (8 pages): queries stored as metagraphs, scope and absence, recursion, hypothetical reasoning, time views, two engines, and why the language is barely new.

Proof and status (4 pages): Lean as the specification, a graph built end to end, what the design commits to, and further reading.

Status: Metastrudel is at the design stage. The data model is specified in Lean 4 and the engine is planned in Rust; there is no release to install yet. The syntax in the book comes from the design documents and may still change.

Project site: https://metastrudel.org

Why We Need a New Graph Language: Inside Metastrudel’s Typed Metagraph Architecture

2

Graphs, Hypergraphs, Metagraph for Agentic AI

Metagraph, hypergraphs, fractal and holonic structures for AI agents and memory