Your agent reads papers, talks to other agents, forms beliefs, and makes promises. Sooner or later someone asks it a question like this:
Who told you that? When? Do you still believe it? Does anyone else agree? And if two sources disagree, which one should I trust?
A JSON file can’t answer that once the schema has drifted for three sprints. A vector store can’t answer it either, because it tells you what is similar, not what is true.
That’s a graph problem. The tools for it are old and well tested: RDF to model facts, OWL to infer new ones, SHACL to reject bad ones, and SPARQL to ask questions. For twenty years they have mostly lived in the Java world, which means a JVM, a server to run, and a 400 MB container.
I wrote a book that brings them to Rust. It’s out today on Leanpub.
What the book is about
It’s a hands-on course that follows one running example from an empty Cargo workspace to a working agent memory.
The example is Ares, a research agent, and three agents it works with:
Calliope, a careful researcher who disagrees with Ares about confidence scores. When Ares says 0.92, Calliope says 0.75. She’s why you need provenance.
Hermes, a fast and sometimes sloppy summarizer who is always the first to spread a mistake. He’s why you need validation.
Pythia, the oracle everyone trusts, which makes her a single point of failure. She’s why you need reasoning about trust.
Their world is small: a few arXiv papers, a trust network, and some observations with confidence scores. The problems they create are the ones every multi-agent system runs into at scale. What happens when two agents disagree about the same paper? When one paper has two IRIs? When a promise is withdrawn after someone acted on it? When a trust chain loops back on itself? When another system sends malformed data?
Each chapter answers one of those questions with one piece of the semantic web stack, and each answer raises the next question. The book has three acts:
- 1.
Build the memory. RDF triples, SPARQL, RDFS types, and an OWL 2 RL reasoner that works out that trust is transitive and that two IRIs name the same paper.
- 2.
Defend the memory. Named graphs for provenance, SHACL shapes that reject bad data before it gets in, SPARQL checks for rules SHACL can’t express (self-promises, trust cycles), and a load → reason → validate → report pipeline with a
--strictflag you can run in CI. - 3.
Outgrow the memory. ShEx compared with SHACL, a second RDF engine on SQLite, the same data modelled as a property graph, and hybrid retrieval that combines BM25, vectors, and graph traversal in one query.
By the end, Ares can answer the question the second act can’t:
“Find papers similar to this one that trusted agents flagged as surprising in the last week.”
Rust-native: no Java, batteries included
Every exercise in this book could be done in Java or Python, and the answers would be about the same. What you’d also get is a slow cold start, a sidecar service to keep running, and a stack that’s hard to ship inside another binary.
In Rust:
It’s embedded by default.
oxigraphis a crate. The store runs inside your process. There’s no server to start, no socket to open, and no separate lifecycle to manage.It ships as one binary. Store, reasoner, and validator compile into a single static executable. That matters when the agent runs on a laptop, a Raspberry Pi, or in a WASM sandbox.
Memory use is predictable. Reasoners create a lot of triples. A Python reasoner will happily take six gigabytes and then run out of memory. In Rust you pay for what you allocate.
“Batteries included” means the whole stack is there, not just a triple store you then have to extend:
JobCrateRDF store + SPARQL 1.1oxigraphOWL 2 RL reasoningreasonableSHACL and ShEx validationrudof_libRDF on SQLite, Cypher, in-store validationoxiliteProperty graph, vectors, full-text searchLadybugDB (lbug)
No JVM and no Python. Run cargo build and it all works.
The Rust ecosystem here is smaller than the Java one, and the book says so. When a W3C feature has no Rust crate yet, the book tells you exactly where the gap is and how to work around it.
Agent-native: a graph built for how agents work
Most graph books are written for data teams building enterprise knowledge graphs. This one is written for people whose design document has the word “agent” in it.
That changes what the book focuses on:
Provenance comes first. Every observation records who asserted it, when, and how confident they were. Named graphs separate what Ares believes from what Calliope told it.
Validation happens at the boundary. Agents take in data from other agents, tools, and LLM output. SHACL shapes are the check that stops a hallucinated confidence of
1.7from getting into memory.Reasoning over trust. OWL rules that make trust transitive and merge the identities of the same entity, plus SPARQL checks that catch trust cycles before they become a problem.
Retrieval your LLM can use. The last chapter builds GraphRAG inside the agent’s own process: BM25 for the exact words, vectors for the meaning, the trust graph to boost sources, Reciprocal Rank Fusion to merge the rankings, and Maximal Marginal Relevance so the context window doesn’t fill up with near-duplicates.
The idea behind the whole book: your agent is its knowledge graph. It isn’t a service the agent calls. It’s part of the agent.
oxilite: RDF on SQLite
Chapters 9 and 10 move Ares’s memory to a second engine, oxilite.
Full disclosure: I wrote oxilite, partly to answer a question the book asks. Is the pipeline really “load, reason, validate, report”, or is it just tied to oxigraph? The only way to find out is to run it on a different store.
oxilite keeps Oxigraph’s data model and Rust API and swaps the storage layer. Oxigraph stores quads in RocksDB. oxilite stores them in SQLite.
For an agent, that’s a bigger change than it sounds. SQLite already runs everywhere agents run: mobile apps, browsers through WebAssembly, sandboxes, edge platforms such as Cloudflare D1, and the many agent frameworks that already keep conversation history in a .sqlite file. If an agent’s whole memory is one SQLite file, you can copy it, back it up, and inspect it with tools your ops team already knows.
What you get:
The same API as Oxigraph. Porting is usually just a change of crate name. Oxigraph’s store tests and the W3C SPARQL test suite pass.
One SQL statement per SPARQL query, with oxilite’s own statistics-based planner choosing the join order.
Reasoning built in. RDFS and OWL QL work by rewriting queries, and an OWL 2 RL closure can be stored in its own table.
Validation inside the store.
oxilite-validateruns rudof’s SHACL and ShEx validators directly on the store, with no export to Turtle first. That’s fast enough to check each agent’s batch before it’s committed.Cypher over RDF. You can query the same triples as a property graph. Labels are
rdf:type, properties are literal triples, and edge properties are RDF 1.2 reifiers. It’s one store holding one copy of the data.
LadybugDB: not Rust, still amazing
Chapter 11 rebuilds the memory as a native labelled property graph in LadybugDB, and Chapter 12 builds the whole hybrid retrieval stack on it.
To be honest up front: LadybugDB isn’t a Rust project. It continues the Kùzu project, and its core is C++. It’s in the book anyway because it’s excellent at this job, and it fits the book’s approach because it’s embedded too:
It runs in your process, like SQLite. There’s no server.
Schemas come first. Each label is a typed node table with a primary key, and each relationship type declares which node tables it connects. The schema rejects duplicate keys, wrong types, and wrong endpoints.
Columnar storage with CSR adjacency makes multi-hop traversal fast.
Cypher with serializable ACID transactions.
Extensions for vector indexes (HNSW) and full-text search. That means one embedded database can do everything the final chapter needs: vectors, BM25, and graph traversal.
From Rust it’s easy to use. The lbug crate downloads a precompiled static library for your platform, so a normal cargo build is all it takes. You still get one binary with no services.
The book also explains when to use which model. RDF is the right choice when provenance, reasoning, and merging graphs from strangers matter. A property graph is the right choice when the graph is internal, traversal-heavy, and its edges carry data. Ares ends up using both: RDF for the outward-facing layer and LadybugDB for the inward-facing one.
Who it’s for
You write Rust and have shipped at least one non-trivial Cargo project. You’ve heard of RDF and SPARQL but never used them for real, or you’ve used them in Java or Python and want the same thing without the JVM. You’re building something with agents in it.
You don’t need a background in description logic or the semantic web. Every concept is introduced through the Ares example before any formal definition.
What’s inside
13 chapters plus 2 deep dives (advanced SPARQL and JSON-LD), from workspace setup to GraphRAG.
A companion Cargo workspace:
rusty-graph-code. Each chapter has a runner, and the code compiles.An exercise at the end of every chapter, with full solutions in an appendix.
“In Production” sidebars on what changes at millions of triples, “What Could Go Wrong” sections on the mistakes real systems make, and Decision Points that compare two valid approaches before choosing one.
About 2,500 lines of Rust and a few Turtle files take you from nothing to a validated, reasoning, hybrid-search agent memory in a single process.
Read the free sample and get the book on Leanpub →
If you’re building agents in Rust, I’d like to hear what your memory layer looks like today and where it’s letting you down. Reply to this post or leave a comment.
Originally published on Sovereign Agentic AI on Substack.