Claude auto-memory storage and chunking spike

Issue: SNUG-131 ↗

Recommendation

  1. Keep Claude auto-memory in Hippo’s existing SQLite database.
  2. Do not adopt sqlite-memory; adapt its transaction, hashing, and Markdown-boundary ideas.
  3. Use adaptive Markdown chunking: preserve a short file as one chunk; otherwise split on Markdown headings, then split an oversized section into bounded overlapping windows. Keep limits configurable and record the chunker/version on every revision.
  4. Treat logical path as document identity and content hash as revision identity. Identical content at different paths remains distinct.
  5. Keep source durability separate from active search projection. A failed or pending replacement must not hide the previous successfully enriched result.

This is a HITL decision. SNUG-132 should not start until the maintainer accepts or changes the recommendation.

Corpus observations

A metadata-only scan found 165 local Claude auto-memory Markdown files totaling 316,363 bytes. Median size was 1,519 bytes, p90 was 4,027 bytes, and maximum was 13,729 bytes. The Hippo memory directory contained 45 files totaling 100,516 bytes. These sizes do not justify a second datastore.

The committed spike corpus is entirely synthetic. It includes a MEMORY.md index, linked topic files, headings, lists, code, short/long files, repeated content under distinct paths, and expected retrieval questions. No real Claude memory content or absolute home path is committed.

Reproduction

mise run bench:auto-memory-spike
uv run --project brain pytest brain/tests/test_auto_memory_spike.py -v

The generated measurement table lives in docs/research/2026-06-27-auto-memory-spike-results.md.

Results

All three strategies achieved Hit@1 1.000 and MRR 1.000 on the initial five-query lexical corpus:

StrategyChunksHit@1MRR
Whole file61.0001.000
Markdown headings131.0001.000
48-token windows with 12-token overlap121.0001.000

The correct conclusion is not that chunking is irrelevant. The corpus proves that whole-file retrieval is sufficient for small, well-separated memories and that extra chunks add index cost without improving these lexical queries. The schema must therefore support one-or-many chunks without requiring eager splitting. Heading-aware boundaries are preferable when a file is large enough to split because they preserve author structure; token windows are a fallback for an oversized heading section, not the primary semantic boundary.

The scratch mutation tests also prove:

Semantic/vector quality was not measured because the spike deliberately avoids the live inference service and the upstream extension could not be built in the DNS-restricted execution environment. SNUG-132 should retain a configurable chunking strategy and add live-model acceptance coverage before declaring exact production thresholds permanent.

Frozen minimal contract for SNUG-132

The names below are conceptual; the migration may adjust names to match existing schema conventions, but it must preserve these identities and boundaries.

Current document

memory_documents

Revision

memory_revisions

Chunk

memory_chunks

Chunking policy for the first vertical slice

Exact production limits remain configurable. The upstream defaults of 400 estimated tokens and 80-token overlap are reasonable starting benchmark values, not a frozen interoperability contract.

Risks carried into SNUG-132

See sqlite-memory compatibility.