Temporal Reasoning
Perfect memory. Exact reasoning. Complete history.
Temporal Reasoning gives AI coding agents bi-temporal graph memory: query any past state, traverse live dependency graphs, and correlate architectural decisions with structural change — all with deterministic Datalog, no fuzzy retrieval.
Questions Only Temporal Reasoning Can Answer
These queries are impossible with git log, vector search, or key-value memory:
; What did the dependency graph look like before the auth refactor?
[:find ?caller ?callee
:as-of 30
:where [?caller :calls ?callee]]
; When did this coupling first appear — and what decision caused it?
[:find ?reason
:where [:dependency/service-a :depends-on :dependency/service-b]
[?d :motivated-by ?c]
[?c :description ?reason]]
; Which modules were coupled to the payment service when we made the DB decision?
[:find ?desc
:as-of 15
:where [?module :depends-on :dependency/payment]
[?module :description ?desc]]
This is the only tool where both the decision and the structural change live as datoms in the same graph and can be joined in a single query. See Phase 5 for code structure evolution from git history.
Why Temporal Reasoning?
Most memory tools for agents are key-value stores or vector databases. They answer "what do you know now?" Temporal Reasoning answers a harder question: "what did you know then, and what changed?"
Time travel. Every write is stamped with a transaction number. You can query the graph as it existed at any past transaction:
# Decision made in session 1, transaction 3
minigraf_transact(facts='[[:decision/db :description "PostgreSQL"]]',
reason="Initial choice")
# Changed in session 4, transaction 11
minigraf_retract(facts='[[:decision/db :description "PostgreSQL"]]',
reason="Switching to CockroachDB for geo-distribution")
minigraf_transact(facts='[[:decision/db :description "CockroachDB"]]',
reason="Switching to CockroachDB for geo-distribution")
# Later: what did we think the database was before session 4?
minigraf_query(datalog='[:find ?d :as-of 10 :where [:decision/db :description ?d]]')
# → "PostgreSQL"
# What do we think now?
minigraf_query(datalog='[:find ?d :where [:decision/db :description ?d]]')
# → "CockroachDB"
Retraction with preserved history. Changing your mind doesn't erase the record. Retracted facts stay in the bi-temporal log and remain queryable at their original transaction time. This means the agent can always reconstruct why a decision changed, not just what the current state is.
Exact Datalog queries, not fuzzy search. Results are deterministic and reproducible — no embedding model, no similarity threshold, no hallucinated retrievals. A query either matches or it doesn't.
Graph traversal. Entities are first-class nodes — not isolated key-value blobs. Store service-calls-service as a real graph edge (:calls :dependency/auth-service) and traverse it with Datalog joins. Fixed-depth transitive queries (2-hop, 3-hop) are expressed as multi-hop joins. Rules unify multiple edge types under a single named relation.
Local and offline. An embedded engine and a file on disk. No API key, no network dependency, no cloud service to go down.
Architecture
┌──────────────────────────────────────────────────────────────────┐
│ AI Coding Agent │
│ (Claude Code, OpenCode, Codex) │
└──────────┬───────────────────────────────────────┬───────────────┘
│ MCP tool calls │ per-turn hooks
│ (minigraf_query, minigraf_transact, …) │ (UserPromptSubmit / Stop)
▼ ▼
┌──────────────────────────┐ ┌─────────────────────────────┐
│ MCP Server │ │ Hook scripts │
│ mcp_server.py │◄────────│ prepare_hook.py │
│ (persistent stdio) │ │ finalize_hook.py │
└──────────┬───────────────┘ └─────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────┐
│ MiniGrafDb Python binding (minigraf package) │
│ https://github.com/project-minigraf/minigraf │
│ - Bi-temporal Datalog engine │
│ - Transaction time + Valid time │
└──────────┬───────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────┐
│ Graph File │
│ memory.graph (current working directory) │
└──────────────────────────────────────────────────────────────────┘
Install