memorygraph

memorygraph

Enables AI agents to record, recall, correct, and forget evidence-backed factual claims with temporal history, while explaining whether remembered information is current, historical, or contested.

Category
访问服务器

README

MemoryGraph

Your agent found a relevant memory. MemoryGraph tells it whether that memory is still true.

MemoryGraph is a local-first evidence and revision layer for AI-agent beliefs. It preserves source observations, represents claims as a temporal graph, and explains why a claim is current, historical, or contested.

MVP status

The deterministic MVP is running. The authoritative architecture starts at 00-architecture-index.md; the implemented kernel covers:

  • Immutable source observations.
  • Typed entity nodes and atomic claim edges with exact evidence spans.
  • Bi-temporal current and historical belief queries.
  • Explicit confirmation, contradiction, and atomic supersession.
  • recall, history, and explain commands.
  • Hard bank isolation and an append-only mutation event log.
  • A provider-agnostic dream-proposal validator with evidence, watermark, claim-version, idempotency, confidence, challenger, and review gates.
  • Durable dream runs, tasks, proposals, review items, leases, event watermarks, and atomic proposal commits.
  • A deterministic metadata provider that exercises the complete dream cycle without sending source data to an external model.
  • MemoryRotBench fixtures, baselines, retrieval grading, and engine integration.
  • Hybrid FTS/vector recall with a dependency-free local baseline and replaceable embedder.
  • Retrieval-time quarantine for untrusted instruction-like content.
  • Crash-recoverable Dream workers with leases, heartbeat renewal, retries, and replay-safe resume.
  • An OpenAI-compatible structured-output provider that can only propose candidates.
  • A five-tool STDIO MCP server: recall, record, explain, correct, and forget.
  • User-approved Codex JSONL ingestion and a project-scoped Codex installer.
  • A deterministic Obsidian-compatible Markdown review projection.
  • First-class procedural episodes for bounded reuse of successful and failed coding attempts.
  • Reproducible no-memory, Markdown, BM25, flat-context, and external/Graphify benchmark adapters.
  • Cross-platform CI, package verification, and actionable doctor diagnostics.

The real engine currently passes all 12 public MemoryRotBench queries and all seven production chaos contracts. The repository test suite has 196 passing tests at this checkpoint. In the first fingerprinted public matrix, the strongest simple baselines pass 7/12 while MemoryGraph passes 12/12.

Quick start

uv sync
uv run memorygraph init --database /tmp/memorygraph.db
uv run memorygraph doctor --database /tmp/memorygraph.db
uv run memorygraph bank create personal:founder --database /tmp/memorygraph.db
uv run memorygraph dogfood bootstrap --database /tmp/memorygraph.db
uv run memorygraph predicate define works_at \
  --bank personal:founder --cardinality one --volatility volatile \
  --database /tmp/memorygraph.db

Record evidence, then turn it into a claim:

OBSERVATION_ID=$(uv run memorygraph observe "Abrar works at Acme." \
  --bank personal:founder --source-key event:acme \
  --database /tmp/memorygraph.db)

CLAIM_ID=$(uv run memorygraph claim assert Abrar works_at Acme \
  --bank personal:founder --observation "$OBSERVATION_ID" \
  --database /tmp/memorygraph.db)

The Python API also exposes confirm_claim, contradict_claim, supersede_claim, recall, history, and explain for embedded applications.

Record a coding attempt so future agents can reuse a successful strategy—or avoid a known failure—without pretending it is universally applicable:

memorygraph record-attempt "Run migrations before starting the worker" \
  --bank project:my-app --source-key attempt:migrate-worker \
  --task "start durable worker" --outcome success \
  --applicability-json '{"database":"sqlite"}'

Run the dream cycle

The embedded provider reads typed candidates from metadata.memorygraph, proposes graph changes, validates evidence and temporal preconditions, then commits eligible proposals in one transaction. Model providers implement the same candidate-only protocol and never get a direct database write path.

PYTHONPATH=src:. uv run python examples/run_dream_cycle.py \
  --database /tmp/memorygraph-dream.db

uv run memorygraph dream status RUN_ID \
  --bank personal:founder --database /tmp/memorygraph-dream.db

uv run memorygraph dream reviews \
  --bank personal:founder --database /tmp/memorygraph-dream.db

uv run memorygraph dream rollback RUN_ID \
  --bank personal:founder --database /tmp/memorygraph-dream.db

For CLI ingestion, pass the candidate envelope with observe --metadata-file FILE.json, then run memorygraph dream run --bank BANK. --mode dry_run validates and persists proposals but does not consume the observation or change claims.

For durable execution, queue work and run a worker separately:

uv run memorygraph dream queue \
  --bank personal:founder --database /tmp/memorygraph-dream.db

uv run memorygraph dream worker \
  --bank personal:founder --database /tmp/memorygraph-dream.db

To use an OpenAI-compatible Responses endpoint, set the configured key variable and pass a model to both the queue and worker. Provider output is parsed as strict structured data and still passes through the same deterministic evidence and commit gates.

export OPENAI_API_KEY=...
uv run memorygraph dream queue --bank personal:founder \
  --provider-model YOUR_MODEL --database /tmp/memorygraph-dream.db
uv run memorygraph dream worker --bank personal:founder \
  --provider-model YOUR_MODEL --database /tmp/memorygraph-dream.db

Connect Codex

Install the package, initialize a project bank, and add project-scoped MCP configuration:

uv run memorygraph init
uv run memorygraph bank create project:my-app
uv run memorygraph install-codex --project .
uv run memorygraph probe-codex --project .

The installer creates or repairs a [mcp_servers.memorygraph] block in .codex/config.toml, points it at the current Python environment's memorygraph.mcp STDIO module, and configures Codex to prompt for writes. It does not modify global Codex configuration. The five MCP operations require explicit bank scope.

probe-codex validates the project config and exercises a real MCP subprocess lifecycle. Use --project-database if you want the probe to hit the configured project database instead of temporary disposable probe DBs.

Importing session content is opt-in. Each JSONL record must carry bank, session_id, turn_id, role, content, and approved; unapproved records are skipped by default:

memorygraph ingest-codex approved-session.jsonl

Dogfood Alpha

The official offline six-arm fixture matrix is:

PYTHONPATH=src:. uv run python examples/run_dogfood_fixture_matrix.py

For a real project, bootstrap the operating contract first:

uv run memorygraph dogfood bootstrap \
  --database .memorygraph/memory.db \
  --bank project:my-app \
  --workspace my-app

The fixture matrix runs these arms:

  • no_memory
  • markdown
  • memorygraph_graph_only
  • memorygraph_gated_dream
  • memorygraph_always_dream
  • graphify_compatible

It measures task pass/fail, useful recall precision, forbidden or stale recall leakage, repeated mistakes, latency, token estimates, tool calls, retries, estimated cost fields, and Dream review load. Results are written to benchmarks/reports/dogfood-offline-mvp.json and the append-only ledger benchmarks/reports/dogfood-offline-mvp.jsonl. Task pass/fail follows query expectations; Dream review backlog remains a separate, visible cost.

Current offline fixture result on 2026-08-22:

  • memorygraph_always_dream: 3/3
  • memorygraph_graph_only: 1/3
  • memorygraph_gated_dream: 1/3
  • graphify_compatible: 1/3
  • markdown: 1/3, with forbidden-fragment leakage

graphify_compatible is a protocol adapter that lets an external retriever compete against the same manifest, time bounds, and grading contract. It is not a claim that this repository has already completed a live Graphify comparison.

Human review in Obsidian

Generate a Markdown vault containing current claims, exact provenance, relations, and the Dream review queue:

memorygraph project-obsidian --bank project:my-app \
  --output .memorygraph/obsidian

The Markdown is disposable and manifest-managed. SQLite observations and append-only events stay authoritative; edits to generated notes never silently mutate memory.

Dogfood Beta

Beta adds a live, repository-owned evidence loop on top of the deterministic Alpha matrix. Start by bootstrapping the project bank, installing project-scoped MCP configuration, and probing the configured project database:

memorygraph dogfood bootstrap --database .memorygraph/memory.db \
  --bank project:memorygraph --workspace agent-memory-research
memorygraph install-codex --project .
memorygraph probe-codex --project . --project-database --configured-only

Real-session instrumentation is explicit and append-only; MemoryGraph never scrapes private Codex history. Record approved recall, attempt, and task events with memorygraph dogfood capture, then run make dogfood-live. The report tracks successful tasks, useful recall precision, forbidden recall, repeated mistakes, latency, tokens, tool calls, and retries. The full operating contract and event schema are in 13-dogfood-beta.md.

Run the accelerated Beta gate without waiting for five organic projects:

make dogfood-beta

This runs five isolated, time-separated workstreams against no-memory, Markdown, and MemoryGraph, then composes the existing public retrieval and production chaos suites into one fingerprinted pass/fail report at benchmarks/reports/dogfood-beta.json. It is accelerated deterministic evidence, not a claim of five sustained users.

Why a graph?

The graph gives agents composable structure: entities are nodes and claims such as Abrar --works_at--> Stripe are typed edges. MemoryGraph does not treat an edge as timeless truth. Each claim version carries valid time, system time, lifecycle, provenance, and exact source evidence. That is the difference between a useful memory graph and a stale fact store.

Development

uv sync --extra dev
uv run pytest
uv run ruff check .
PYTHONPATH=src:. python examples/run_memoryrotbench_memorygraph.py
PYTHONPATH=src:. python examples/run_memoryrotbench_chaos_memorygraph.py
python examples/run_memoryrotbench_baseline_matrix.py
PYTHONPATH=src:. uv run python examples/run_dogfood_fixture_matrix.py

Expected results: 12/12 public retrieval cases and 7/7 production chaos cases. The matrix appends immutable, corpus- and evaluator-fingerprinted records to benchmarks/reports/public-baseline-matrix.jsonl. Supply --graphify-command to run an external Graphify adapter against exactly the same visible corpus and grading contract.

Next product layer

The next gate is still real-world proof: live model-backed dogfood sessions, real Graphify head-to-head comparisons, and design-partner usage over actual coding work. Full-pipeline deletion residue is audited and reported; any identity residue that cannot be safely erased without rewriting history is surfaced instead of hidden. The dream validator remains the safety waist every provider and worker must pass through.

Licensed under Apache-2.0.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选