Tiramemsu

How tiramemsu is built

Tiramemsu guide · 4 October 2026

Tiramemsu is a library, not a server. It is a stack of layers over one SQLite file. Each layer uses only the layer below it, and time is resolved in exactly one place. This page shows the whole stack in one picture and says what each layer does.

Layer diagram. Front ends (SPARQL, Cypher, Rust API) feed one IR algebra. Agent memory services (budget meter, saved answers, conflict review and bundle preview, bulk import) sit beside the Rust API. The planner routes the IR to SQL codegen, the path operator tm_path, the LFTJ operator tm_lftj and text recall tm_text. These read through the temporal view in the core, next to the tx engine, text upkeep and the term dictionary. The core talks to an executor trait, implemented by tm-rusqlite and tm-wasm, which both use one SQLite file with graph tables and derived tables.
The layers, top to bottom. Solid arrows are calls; dashed arrows are the budget meter and the executor trait. Open the image for full size. Drawn from the layers diagram in lat.md/architecture.md.

The layers

Front ends. SPARQL and Cypher are parsed into one logical IR, so both languages mean the same thing over the same store. The Rust API (Db, View, Tx) can build IR too, and it is also the way in for writes.

Agent memory services. The 0.3 features live in the facade, beside the Rust API. They add no new storage path. The budget meter can stop any layer below it. Saved answers re-run their query and compare what it cited. Conflict review and import previews run a transaction that is never committed. Bulk import feeds the tx engine in chunks while it holds the write lease.

Logical IR. One small algebra: basic graph patterns, joins, optional joins, filters, unions, aggregates, paths and text matches. Each pattern can carry its own view, so one query can mix “now” and “as of last week”.

Physical operators. The planner turns most of the IR into SQL. Some work SQL does badly, so it goes to native operators instead: tm_path for reachability and shortest paths, tm_lftj (opt-in) for cyclic patterns such as triangles, and tm_text for text recall. All three are SQLite table functions, so SQL can call them too.

Core. The tx engine asserts, retracts and supersedes statements, and checks cardinality and uniqueness. It never deletes. The temporal view is the one place that turns “now”, “as of”, “valid at” or “history” into conditions on the rows; every operator reads through it. The core also keeps the full-text index up to date and maps terms to compact ids.

Executor and hosts. The core reaches SQLite through a small trait: prepared statements, transactions, savepoints and a stable snapshot. tm-rusqlite implements it with bundled SQLite and WAL. tm-wasm implements it on SQLite compiled to WebAssembly. A host says what else it can do, and the engine refuses to start rather than quietly do less.

One SQLite file. The graph is a term dictionary, a transaction log and one triple table with its indexes. Next to it sit derived tables: the text index and the saved answers. They are not history, and they can always be rebuilt from the graph.

Four ways in

Deployment diagram. In a native process, a Rust app calls the tiramemsu facade directly, and a Node.js or Python app goes through its addon and the JSON bridge; the facade uses tm-rusqlite on the memory file. An LLM app talks to a separate tiramemsu-mcp process over stdin and stdout. In a browser, a web page posts messages to a Web Worker running tiramemsu-wasm on tm-wasm, stored in OPFS or memory, which can export and import the same file.
The same engine and the same file format in every host. Drawn from the deployment diagram in lat.md/architecture.md.

More detail

The design graph in lat.md has the rest: architecture (crates, cargo features, the executor, concurrency), query (planning, paths, text recall, budgets) and storage. For what each 0.3 feature does, read what’s new in 0.3. For why every fact has an id, read layered graphs, explained, and for the two clocks, time travel and bitemporality.

All articles →