v3/docs/adr/ADR-335-mv-hnsw-agent-memory-upgrade.md
Status: Proposed Authors: claude (dream-cycle agent, 2026-05-30) Related: ADR-006 (Unified Memory Service), ADR-009 (Hybrid Memory Backend), ADR-017 (RuVector Integration)
Ruflo's current HNSW backend indexes each memory entry as a single embedding vector. Measured performance is ~1.9× vs brute-force at N=20k (ruvector NAPI). A 2026 PVLDB paper (arXiv:2604.02815) introduces MV-HNSW, the first hierarchical graph index native to multi-vector data, and benchmarks 14× search-latency reduction at >90% recall across seven real-world datasets.
Agent memory entries are structurally multi-field: they contain an exchange core (semantic summary), a technical detail, thematic room labels, and file-path tags. The current architecture embeds these as a single concatenated vector, losing the structural signal that multi-vector indexing exploits. This means:
No existing ADR (085–143) addresses multi-vector indexing for agent memory.
Upgrade v3/@claude-flow/memory/src/hnsw/ to a multi-vector index pattern:
core (1–2 sentence exchange summary), detail (technical specifics), labels (thematic room tags), paths (file-path anchors).searchMemory(query, opts) to accept an optional axis filter so callers can target core or paths axes directly for precision lookups.Positive
Negative / Risks
scripts/benchmark-intelligence.mjs.| File | Change |
|---|---|
v3/@claude-flow/memory/src/hnsw/index.ts | Add MVHNSWIndex class alongside existing HNSWIndex |
v3/@claude-flow/memory/src/types.ts | Add MultiVectorEntry type with four axis fields |
v3/@claude-flow/memory/src/agentdb.ts | Route writes to MVHNSWIndex when entry has structured fields |
scripts/benchmark-intelligence.mjs | Add mv-hnsw-recall benchmark suite |
docs/reviews/intelligence-system-audit-2026-05-29.md — measured HNSW baseline (~1.9× at N=20k)