The Problem
AI agents that rely on long‑term context often lose consistency: memories drift, contradictions appear, and rollback is manual. Without a versioned store, developers must rebuild prompts or re‑ingest data, leading to hallucinations and wasted compute.
What This Does
Memoria implements a Git‑style, copy‑on‑write memory layer built on MatrixOne’s vector‑enabled storage. Core crates provide the API (memoria/crates/memoria‑api/src/lib.rs), the CLI (memoria/crates/memoria‑cli/src/main.rs), the embedding service (memoria/crates/memoria‑embedding/src/lib.rs), and the MCP‑compatible server (memoria/crates/memoria‑mcp/src/server.rs). Plugins (e.g., plugins/openclaw/) add agent‑specific adapters. The system snapshots, branches, and merges memory graphs while preserving semantic search indexes.
How It Is Wired
Execution starts at memoria/crates/memoria‑cli/src/main.rs (the main function, 2 593 lines, reaches 358 functions). main parses CLI flags, builds a MemoriaCli instance, and ultimately calls cmd_init_interactive, which invokes the LLM model via the string "openai" (model inference path).
The HTTP server entry point is memoria/crates/memoria‑mcp/src/server.rs:dispatch (reaches 189 functions). dispatch calls call, which constructs a request to self.client.post(self.url("/v1/memories/correct")) – a network outbound call – and may also trigger a model inference (service.llm.is_none).
Benchmark runs use memoria/crates/memoria‑cli/src/benchmark_executor.rs:execute (235 functions).
Across the codebase the most widely referenced symbols are setup (called from 164 places), uid (149), header (134) and post (133). These functions sit in memoria/crates/memoria‑api/src/lib.rs and memoria/crates/memoria‑api/src/routes/*.rs; changes to them have the largest blast radius.
External effects are concentrated in a handful of paths:
- Model inference –
main → cmd_init_interactiveanddispatch → call. - Network I/O –
run → preflight(client health check) anddispatch → call. - Database I/O –
setup → new_sql_with_llm. - Filesystem –
mainwrites/reads files for configuration and snapshots.
No circular module dependencies were detected, and the internal call graph contains 3 307 resolved edges, confirming a relatively flat dependency structure.
How To Use It
# Clone the repo
git clone https://github.com/moses-y/Memoria
cd Memoria
# Build all Rust crates (requires Rust toolchain)
make -C memoria # invokes `cargo build --workspace`
# (Optional) Run the service via Docker
docker compose up -d # uses docker-compose.yml and Dockerfile
# Set runtime configuration – copy the example env file
cp memoria/.env.example .env # edit .env as needed (e.g., DB_URL, LLM_ENDPOINT)
# Start the CLI (default starts a local server)
cargo run -p memoria-cli -- serve # entry point: memoria/crates/memoria-cli/src/main.rs
# Example: create a snapshot via the HTTP API
curl -X POST http://localhost:8080/v1/memories/snapshot \
-H "Authorization: Bearer <token>"
The repository ships a Makefile at the root and inside memoria/ that expose the typical targets (build, test, docker-build). No additional package managers are required beyond Cargo and Docker.
Real‑World Use
A customer integrating a code‑assistant bot adds plugins/openclaw/ to expose the agent’s memory through the OpenClaw protocol. When the bot writes a new fact, the plugin calls memoria/crates/memoria‑service/src/service.rs:round4, which stores the fact, triggers a governance check, and writes a snapshot. If the fact later contradicts existing knowledge, the governance hook (memoria/crates/memoria-service/src/plugin/governance_hook.rs) automatically quarantines it, preserving consistency without manual intervention.
Code Health & Issues
Static analysis findings (61 total)
- HIGH – Oversized files (
plugins/openclaw/openclaw/config.ts,plugins/openclaw/openclaw/client.ts,memoria/crates/memoria-api/tests/api_db_verify.rs) – >600 lines each, hard to reason about. - HIGH – Deep nesting (
memoria/crates/memoria-api/src/lib.rs,.../routes/sessions.rs,memoria/crates/memoria-cli/src/bin/loadtest.rs) – indentation depth 8. - HIGH – Duplicated code blocks across multiple modules (≈350 repeats).
- MEDIUM – High branching density in several plugin scripts.
Code‑health audit (8 findings)
| Severity | Issue | Location |
|---|---|---|
| High | Pin third‑party GitHub Actions to a commit SHA | .github/workflows/* |
| Medium | Declare least‑privilege GITHUB_TOKEN permissions | .github/workflows/release-docker.yml |
| Medium | Enable Dependabot / Renovate | repo root (no config) |
| Medium | Pin Docker base images by digest | memoria/Dockerfile |
| Medium | Add a dependency‑vulnerability scan step | .github/workflows/* |
| Medium | Set persist-credentials: false on checkout | .github/workflows/release-npm.yml |
| Low | Add timeout-minutes to workflow jobs | .github/workflows/release-docker.yml |
| Low | Add convention files (.editorconfig, .gitattributes, formatter config) | repo root |
All findings are deterministic; the listed fixes are the recommended actions.
The Bottom Line
Memoria delivers a production‑ready, versioned memory store for AI agents, with a well‑structured Rust codebase and Docker support. The core architecture is clear, but several large, deeply nested files and duplicated snippets increase maintenance overhead, and the CI pipeline needs tightening (action pinning, permission scoping, dependency scans). Teams comfortable with Rust and containerised deployment will find it immediately usable; others should budget time for refactoring the high‑cognitive‑load modules and hardening the CI workflow.