AI/TLDR

Lemmalog

Agent memory as a deductive database, with proofs instead of recall

Agent MemoryOpen source
Updated
28 Aug 2026
Language
Rust
License
MIT
Coverage
1 story
$cargo build --release --features mcp

What's new

28 Aug 2026

Lemmalog was published with a write-up arguing that agent memory should be a deductive database rather than retrieved text, alongside the engine, MCP server, REPL and design document.

Latest news

Overview

Lemmalog is a Datalog engine built to serve as an LLM agent's memory. Its thesis is that an agent's memory should be a deductive database rather than a pile of retrieved text: base facts are asserted at the ingestion boundary by an extractor, rules derive closures, temporal projections, contradiction candidates and relevance diffusion, and every derived fact carries provenance back to the source episodes it came from. Because derivation is incremental, each conversation turn updates the derived views instead of re-deriving them — or, worse, re-reasoning them in context.

The engine is written in Rust and parses its rules at runtime (an interpreter, not a proc-macro), with stratified negation, seminaive fixpoint evaluation, bi-temporal facts, semiring annotations that carry confidence and provenance, and magic-sets demand evaluation for point queries. A why() call returns the proof tree behind any fact, so an agent can check where a conclusion came from before trusting it, and retracting one fact scopes recomputation to its transitive dependents.

It is packaged three ways for agent use: a Rust crate, a REPL, and an MCP server exposing twelve tools to harnesses such as Claude Code and Kimi CLI. The intended division of labour is that the host model reads the conversation and asserts triples in a line protocol, while Lemmalog derives closures, temporal views, canonicalizations and aggregations deterministically. The repo also ships a generic agent skill that encodes the working discipline the project's own experiments converged on.

What it does

  • Runtime-parsed stratified Datalog with negation-as-absence, seminaive fixpoint evaluation, and magic-sets demand evaluation for point queries
  • Provenance and confidence carried as semiring annotations, so why() returns a proof tree back to the source episodes
  • Bi-temporal facts (valid_from / valid_to / asserted_at) with scoped negative deltas: retraction recomputes only the transitive dependents
  • MCP server (12 tools) plus a headless CLI over the same snapshot, for harnesses and for sub-agents or cron jobs that cannot reach MCP
  • Entity resolution by star-shaped aliasing that derives alias_conflict facts instead of silently merging two identities
  • Hybrid retrieval (BM25 plus entity and graph boosting) with a budget-aware context assembler, and what_if hypotheticals with byte-identical store restore

Getting started

Lemmalog builds with Cargo. The quickest path for an agent harness is the MCP server; the REPL is useful for learning the rule grammar first.

Build the MCP server

The MCP server is behind a feature flag.

bashbash
cargo build --release --features mcp

Register it with your harness

Both Claude Code and Kimi CLI take a stdio JSON-RPC command. Set LEMMALOG_MCP_PATH at registration time to persist the store across sessions.

bashbash
claude mcp add lemmalog --env LEMMALOG_MCP_PATH=/tmp/lemmalog.snapshot -- \
  $(pwd)/target/release/lemmalog-mcp

Assert facts, install rules, then query

The host model asserts triples with the line protocol S --rel[conf]--> O; rules derive the rest. Note the grammar: bare capitalized words are variables, so entity names must be quoted.

texttext
lemmalog_observe       {"facts": "Alice --works_at--> Acme\nAlice --manager--> Bob", "ts": 100}
lemmalog_install_rules {"rules": "reports_to(X,Y) :- current(X,\"manager\",Y)."}
lemmalog_query         {"goal": "reports_to(\"Alice\", Y)"}

Ask why before trusting a conclusion

why() returns the proof tree for a derived fact, down to the episodes that supported it. Sub-agents and scripts can use the headless CLI against the same snapshot.

bashbash
LEMMALOG_MCP_PATH=/tmp/lemmalog.snapshot lemmalog-cli query --goal 'current("s", R, O)'

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Give a long-running investigation, audit, or debugging session a working memory whose conclusions can be re-checked rather than re-remembered
  • Keep an agent's knowledge consistent under change: retract one fact and have every conclusion built on it invalidated automatically
  • Replace a growing transcript in the context window with a derived, budget-aware context block plus verbatim provenance
  • Share one deductive store between a parent agent and its sub-agents through the MCP server and the headless CLI

How Lemmalog compares

Lemmalog alongside other open-source agent memory tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Claude-Mem★ 94.4kPersistent memory layer for coding agents: it captures what an agent does during a session, compresses it into semantic summaries, and injects the relevant parts back into later sessions.
Mem0★ 65.8kA memory layer that you add to existing LLM agents to extract, store, and recall user facts and preferences across sessions using vector, graph, and key-value backends.
MemPalace★ 59.2kLocal-first agent memory that stores conversations verbatim instead of summarising them, with a structured palace index, pluggable vector backends and an MCP server.
OpenViking★ 38.3kA context database that stores an agent's memories, resources, and skills as one browsable viking:// filesystem with three-tier (abstract/overview/details) on-demand loading.
Graphiti★ 31.1kA library that builds a temporal knowledge graph from an agent's conversations and data so facts can be tracked and queried as they change over time.
Cognee★ 30.9kA graph-native memory engine that turns raw documents and conversations into a queryable knowledge graph for agents that need to build lasting knowledge.
Supermemory★ 30.8kA memory and context engine that ingests information across tools and sessions and can run fully locally, acting as a second brain for AI applications.
Lemmalog★ 316Agent memory as a deductive database, with proofs instead of recall