Every agent memory design eventually answers one question: which representation is allowed to be the truth? This build log implements the same memory workload twice on one host — a git-backed markdown wiki with a derived FTS5 index, and a SQLite-primary store with no files at all — and measures what each one costs in ingest time, index build time, query latency and disk bytes. The numbers below are ours, from scripts you can read; the retrieval-quality numbers are ai-memory’s, cited with their provenance.
The Question: What Does “Owning” Agent Memory Mean?
Ownership is not where bytes sit for an hour. It is which representation is authoritative when memory is written, read, revised, and queried across many sessions.
One implementation makes this explicit. As stated in ARCHITECTURE.md:
“The core invariant is unchanged: the markdown wiki is the source of truth, and SQLite is the derived index for search, sessions, observations, handoffs, audit, embeddings, and the optional managed-workstream continuity ledger.”
That sentence is the whole design argument. If the index is derived, you can delete it and rebuild it. If the database is primary, there is no second copy to rebuild from. The alternative keeps extracted facts in SQL plus vectors and entities as the store itself.
The ai-memory README frames the project as long-term memory shared across coding CLIs, delivered as a single Rust binary. The question for this build log is narrower: what does each ownership choice cost to maintain, and what does it buy?
Both arms of our build answer queries through the same FTS5 index, so this choice was never about query speed. It is about whether you pay a small, measurable maintenance tax to keep a second, human-readable, git-versioned representation of memory.
Two Arms, One Workload
We built the same workload twice on one idle host and measured four quantities on both arms: ingest cost, index build cost, query latency, and on-disk footprint.
Arm A follows ai-memory’s shape: a git-backed markdown wiki plus a derived FTS5 index. Notes are plain markdown files on disk, committed in git, then indexed into FTS5 for search. Retrieval in the documented design is FTS5 plus lexical entity plus link-neighbor retrieval, with optional vectors, as described in comparison.md.
Arm B follows a SQLite-primary shape inspired by Mem0: one table plus FTS5, no files. This mirrors the Mem0 pattern where memory means extracted facts rather than verbatim transcripts. Mem0 documents the pattern as deduplicate and embed, entity linking, then write to a SQL database for facts and metadata, a vector database for embeddings, and an entity store for entities and relationships, described in Mem0 memory types. Its usage pattern is two-phase:
- After a useful interaction, call
addto store what should be remembered. - Before a model call, call
searchand pass the best results into the prompt.
That two-phase flow is documented in Mem0 memory types.
The corpus was identical for both arms: synthetic session notes, 1,200 of them averaging 1,451 bytes each (1,809,714 bytes of markdown in total), queried with the same 60 two-term queries — all measured by us. The scripts are bench.py for the head-to-head and bench2.py for the scale sweep. Results are bench-results.json and scale-results.json. We did not deploy either arm in production.
Mem0 scopes memory by user and agent and run, per Mem0 memory types. Its storage examples make the extraction model concrete: an utterance like preferring aisle seats becomes a normalized fact about seat preference, and a statement about using Postgres for a project becomes a project decision fact, both examples from Mem0 memory types. When verbatim storage is required, Mem0 provides infer=False to store raw content exactly as provided, also documented in Mem0 memory types.
What the Docs Establish Before You Measure
Before numbers, the docs establish what each layer can do.
FTS5 gives full-text search without an external service. Per SQLite FTS5, it offers phrase queries, prefix queries, NEAR queries, column filters, and boolean operators, plus table options and tokenizers and auxiliary functions including bm25() for ranking and highlight() and snippet() for presenting matches. That is the retrieval substrate for both arms in our build.
SQLite write-ahead logging matters for concurrent access. Per SQLite WAL, WAL provides more concurrency because readers do not block writers and a writer does not block readers, reading and writing can proceed concurrently, disk I/O tends to be more sequential, and WAL is significantly faster in most scenarios according to that linked source. WAL has been available as a write-ahead log option beginning with version 3.7.0 released on 2010-07-21, per that same SQLite WAL source. Whether WAL is enabled in ai-memory or in our build is not established by these sources.
The file side gives a different set of properties: comparison.md describes the wiki as plain markdown you can grep, open in Obsidian, edit by hand or rsync, and describes the SQLite index as derived and rebuildable.
“The wiki is plain markdown + YAML frontmatter, a native Open Knowledge Format bundle. You can
grepit, open it in Obsidian, edit it by hand, orrsyncit. The SQLite index is derived and rebuildable.”
Physically, what accumulates is described in ARCHITECTURE.md as a Karpathy-style LLM wiki: a git-versioned tree of markdown pages on disk that gets compiled and appended to over time, with pages versioned in place via supersession. That same architecture bundles SQLite and vendored libgit2 into a single Rust binary with no external services, per ARCHITECTURE.md and comparison.md. For maintenance, git provides a maintenance command documented at git-gc, cited here only as a git maintenance command because the excerpt is truncated.
The Tradeoff Table
This table is the spine of the post. Cells marked as not established mean the supplied sources do not support a claim either way.
| Concern | Git-backed markdown + derived index | SQLite primary |
|---|---|---|
| Source of truth | Markdown wiki is canonical; SQLite is explicitly derived and rebuildable | Single store for facts and metadata plus vector and entity stores; no separate file tree is authoritative |
| Retrieval | FTS5 plus lexical entity plus link-neighbor retrieval, optional vectors, zero-LLM by default | FTS5 alone provides phrase and prefix and NEAR and column-filter and boolean queries with bm25() ranking and highlight() and snippet() |
| Inspectability | Grep and Obsidian and hand edit and rsync are documented properties | Not established by these sources |
| Versioning | Git-versioned tree; pages versioned in place via supersession; per-page history behavior beyond that phrase is not established by these sources | Not established by these sources |
| Concurrency | Not established by these sources for the markdown path | WAL mode documents that readers do not block writers and writer does not block readers |
| Write amplification | Not established by these sources | Not established by these sources |
| Disk footprint | Not established by these sources | Not established by these sources |
| Rebuildability | Explicit: index can be deleted and regenerated from the wiki | Not established by these sources; with SQLite-primary the DB is the only representation |
| Multi-agent access | Shared memory across CLIs with claim-once handoffs described for ai-memory | Scoping by user and agent and run is described; claim-once or cross-CLI behavior is not described in these sources |
| Deletion / TTL | Episodic logs decay is described as a precedent; general TTL for git-backed markdown is not established | Not established by these sources |
The concurrency row deserves care. ai-memory describes one writer actor with lock-aware delivery, but git-layer concurrency semantics for the markdown arm are not established by these sources. Likewise, write-amplification figures for either arm are not established by these sources.
The Head-to-Head: Four Measured Quantities
Same corpus, same queries, both arms, one idle host. Corpus: 1,200 notes (measured by us), mean size 1,451 bytes per note, 1,809,714 bytes of markdown in total, queried with 60 two-term queries. Every figure in this table is measured by us.
| Metric | Arm A: markdown + derived FTS5 | Arm B: SQLite primary |
|---|---|---|
| Write / insert | Write 1,200 files: 55.0 ms; 24 commits issued, one per 50 notes; commit cost 884.3 ms total, 36.8 ms per commit | Insert 1,200 rows plus FTS rows: 96.7 ms |
| Index build / rebuild | Build derived FTS5 index: 66.4 ms; rebuild from scratch: 63.0 ms | No separate build step; index rows written during insert |
| Query p50 / p95 | FTS5 p50 0.017 ms, p95 0.025 ms; grep p50 7.452 ms, p95 13.495 ms | FTS5 p50 0.032 ms, p95 0.043 ms |
| Bytes per note | Markdown 1,809,714 bytes; post-gc .git 966,947 bytes; derived DB 2,957,312 bytes; total 4,778 bytes per note | Database 2,990,080 bytes; 2,492 bytes per note |
| 6-writer test | 6 writers times 150 file writes: 0 failed processes, 108.5 ms wall | 6 writers times 150 inserts: 900 ok, 0 errors, 101.4 ms wall |
The 96.7 ms versus 66.4 ms comparison needs its caveat inline: Arm B’s per-row FTS insert pattern is slower than Arm A’s bulk insert-select pattern, so the gap is mostly that insert pattern, not a property of SQLite versus markdown (measured by us).
The takeaway is narrow. Ingest and index build are both well under a second at this size on this host. Query latency through FTS5 is sub-tenth-millisecond on both arms. Footprint differs because Arm A keeps three things on disk: files plus history plus derived index.
Finding #1: Both Arms Query the Same Index
Arm A’s fast query number is against the derived index, not against the files. The file-only path is grep with no index.
At the head-to-head size, grep p50 of 7.452 ms (measured by us) versus FTS5 p50 of 0.017 ms is a large gap, and grep p95 of 13.495 ms versus FTS5 p95 of 0.025 ms is similarly large. The file-only path is 140x slower at 1,200 notes and 770x slower at 10,000 notes.
This is why the ownership framing matters. Files own the memory, but files do not serve queries. The derived index serves queries. If you choose git-backed markdown without maintaining the derived index, you accept grep latency on every read. If you maintain the index, reads look like any other FTS5 reads.
No published per-query latency figure for ai-memory exists in these sources. No published ingest rate or footprint or index-build cost for ai-memory exists in these sources either. Our latency numbers are cost measurements on synthetic text, not quality measurements.
Finding #2: grep Is Linear, FTS5 Stays Flat
We swept the same corpus shape to larger sizes to see how the two read paths scale. All figures in this table are measured by us.
| Notes | FTS5 p50 (ms) | FTS5 p95 (ms) | grep p50 (ms) | grep p95 (ms) | DB bytes | bytes/note |
|---|---|---|---|---|---|---|
| 1,200 notes | 0.053 | 0.083 | 7.44 | 11.86 | 2,920,448 | 2,434 |
| 5,000 notes | 0.052 | 0.09 | 25.15 | 64.61 | 12,050,432 | 2,410 |
| 10,000 notes | 0.066 | 0.106 | 50.83 | 64.0 | 24,621,056 | 2,462 |
Per-note grep cost is 6.2 microseconds per note at the smallest size (measured by us), 5.0 microseconds per note at the middle size, and 5.1 microseconds per note at the largest size. It is linear in store size. FTS5 stays flat, moving from 0.053 ms to 0.066 ms across growth of 8.3x larger store.
The operational point is simple. Grep is fine for debugging and hand inspection. It is not a query path for an agent loop that reads on every turn. The derived index exists so the agent loop never pays linear scan cost.
Finding #3: What Version History Costs on Disk
Version history has a concrete byte cost in this build. Before running git gc, the repo reported 1,296 loose objects (measured by us) and a size of 5,520 KiB. After git gc packed them, the .git directory measured 966,947 bytes on disk.
Against markdown bytes of 1,809,714 bytes (measured by us), history costs about 0.53x the bytes of the notes themselves. Total per-note bytes including files plus history plus derived DB is 4,778 bytes per note, versus 2,492 bytes per note for the SQLite-primary DB.
That 0.53x figure is a single post-git gc snapshot, not a growth model (measured by us). A long-lived repo packs incrementally, edit patterns change compression, and history grows with rewrites and supersession. The internals of git gc are not established by these sources beyond its existence as a maintenance command documented at git-gc.
What the bytes buy is inspectability and recovery: grep, hand edits, rsync, per-page history, and a derived index you can delete and regenerate. Whether hand edits are safe under schema or frontmatter validation is not established by these sources.
What These Numbers Cannot Tell You
All six caveats, in order:
- Both arms are single-process on one idle host; these are not multi-tenant production numbers.
- Arm A’s query latency is measured against the derived index, not against the files. The file-only path is the grep row, which is 140x slower at 1,200 notes and 770x slower at 10,000 notes (measured by us).
- Arm B’s per-row FTS insert pattern is slower than Arm A’s bulk insert-select pattern; the 96.7 ms versus 66.4 ms difference is mostly that insert pattern, not a property of SQLite versus markdown.
- The corpus is synthetic. It has no semantic structure, so it cannot measure retrieval quality — only cost. Quality numbers must be cited from ai-memory’s published benchmark runs.
- Concurrent writers did not collide here because each writer wrote distinct files in Arm A or distinct rows with its own connection in Arm B. Neither arm was tested under a hot-row or same-file contention workload.
git gcwas run once by hand; a long-lived repo packs incrementally. The 0.53x figure is a single post-gc snapshot, not a growth model.
Explicitly not established inventory: no published ingest rate, per-query latency, footprint, or index-build cost for ai-memory exists in these sources. No write-amplification figures exist for either arm. Whether WAL is enabled in ai-memory or our build is not established. Whether ai-memory’s FTS table is contentless or external-content or plain is not established.
What the Research Adds
Cost without quality can mislead. A recent filesystem-memory study, Zhou et al., arXiv 2607.26637 (59 pages, 12 figures, 18 tables), names the two working assumptions that are usually left untested, quoted near-verbatim from the paper: that an agent can keep a growing store organized as memories accumulate, conflict, and go stale, and that this organization pays. The full HTML text carries the growth experiments behind the claims below.
Its headline finding is split. What organization reliably buys is search economy: organized stores roughly halve retrieval cost where material is large, per the arXiv paper. But today’s agents fall short of that promise: in the growth study, organization erodes for all but the strongest management agent, and no agent measured converts organization itself into better answers. The model is not the only lever over store shape: changing the tool set alone reshapes the store as strongly as swapping the model, all per the arXiv paper.
For this build log, the implication is direct. Our synthetic corpus measures cost, not quality. Quality must come from published retrieval runs with provenance.
Those published runs exist for the file-owned design. Every number in this paragraph is cited from ai-memory’s published benchmark, reported in comparison.md and the benchmarks README. The 2.6 line reports hit@5 of 0.666 zero-LLM and 0.815 with default local embeddings. The 3.0 observation stream raises zero-LLM to 0.951 and local embeddings to 0.945 on all 470 questions. The 3.4.3 run measures 0.951 zero-LLM and 0.943 local at hit@5. With capture skipped and each raw session indexed whole in component mode, zero-LLM FTS scores 0.972. The 3.5.0 baselines list 0.953 zero-LLM FTS plus observation stream, and 0.940 with local embeddings plus observation stream. The harness claims full provenance — commit, dataset sha256, hardware and mode — for every number it produces.
Other tools’ recall numbers mentioned in those docs are different harness kinds and not comparable. We do not rank them against hit@5 here.
FAQ
Is the derived index ever stale?
It can lag writes if you query between file commit and reindex, but it is rebuildable by design. In our build, rebuilding the derived index from scratch took 63.0 ms (measured by us) at the head-to-head size. The documented property is that the SQLite index is derived and rebuildable, per comparison.md. Treat rebuild as a routine operation, not a recovery procedure.
Can’t I just grep and skip the index?
You can for debugging, but not as the agent read path. Grep cost per note was 6.2 microseconds at the smallest sweep size (measured by us), 5.0 microseconds at the middle size, and 5.1 microseconds at the largest size. FTS5 p50 moved only from 0.053 ms to 0.066 ms across the full sweep. At larger sizes the gap becomes the budget.
Doesn’t git history bloat disk?
It adds measurable bytes, but in this snapshot the cost was bounded. History after git gc was 966,947 bytes (measured by us) against notes of 1,809,714 bytes, or about 0.53x. Before git gc the repo showed 1,296 loose objects and a size of 5,520 KiB. The figure is a single snapshot, not a growth model, and git gc internals beyond its existence as a maintenance command are not established by these sources.
What about vectors and retrieval quality?
Our build does not measure quality because the corpus has no semantic structure. For quality, cite the published harness: 0.951 zero-LLM plus observation stream in the 3.4.3 run, 0.953 zero-LLM FTS plus observation stream in the 3.5.0 release, and 0.972 zero-LLM FTS in component mode with capture skipped — all cited from ai-memory’s published benchmark, with provenance in the benchmarks README and numbers reported in comparison.md. Other tools’ recall numbers are different harness kinds and not comparable.
Which arm for multi-agent access?
If agents must share memory with explicit handoffs, the file-owned design documents claim-once handoffs where quitting one agent and opening another in the same repo yields a handoff owned and claimed exactly once, per comparison.md. Mem0 instead scopes by user and agent and run, per Mem0 memory types. Contention under hot-row or same-file writes was untested by us, so choose on the documented access model, not on our six-writer numbers alone.
The Bottom Line
Let files own the memory and treat the database as a rebuildable cache — unless footprint or single-store simplicity is your hard constraint, in which case accept that the database is the only copy.
At the head-to-head size, the file-owned arm kept 1,809,714 bytes of markdown (measured by us) plus 966,947 bytes of history plus a 2,957,312 byte derived index, for 4,778 bytes per note, against 2,492 bytes per note for SQLite primary. Index rebuild took 63.0 ms and per-commit cost was 36.8 ms. What that tax buys is grep, hand edits, rsync, per-page history via supersession, and the ability to delete and regenerate the index.
This verdict is bounded by what we actually did: one host, no production deployment, no contention workload, synthetic corpus. It measures cost, not retrieval quality. For quality, rely on cited benchmark runs with provenance, not on our timings.
How This Guide Was Built
The numbers in this post come from benchmark scripts we wrote and ran on one host: bench.py for the head-to-head comparison and bench2.py for the scale sweep, with results in bench-results.json and scale-results.json. We did not deploy either arm in production. Cited quality numbers come from ai-memory’s in-repo harness with its published provenance, per benchmarks README and comparison.md, and architectural quotes come from ARCHITECTURE.md and the ai-memory README.
📖 Related Reads
- ToolBrain — tool reviews, LLM comparisons, and AI workflow guides
- CodeIntel Log — code quality, debugging, and software engineering benchmarks
- Hermes Tutorials — Hermes Agent setup, configuration, and advanced workflows
Cross-links automatically generated from NiteAgent.
← Back to all posts


