mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-25 06:36:49 +09:00
`memory stats` always reported `HNSW Index: active (0 entries)` even when `memory store` had just stored a vector and `memory search` successfully retrieved it. Root cause: the rendered count was `hnsw.entryCount`, which is the live in-process JS state (`hnswIndex?.entries.size`). A fresh `memory stats` invocation has never initialized HNSW in this Node process, so the in-process counter is always 0 — even when the persistent .swarm/memory.db has many entries with embeddings. Fix: prefer the persistent count from the `memory_stats` MCP tool, which already computes `entriesWithEmbeddings` by listing the DB's real rows. Fall back to the live counter when persistent count isn't available. When both are non-zero, take the max (covers the edge case where the live process has indexed more entries than the persisted store has flushed). Behavior matrix: hnsw.available persisted live → rendered false any any → "not active" (unchanged) true 0 0 → "available but not initialized" true N>0 any → "active (max(N,live) entries)" true 0 M>0 → "active (M entries)" (unchanged) Adds `entriesWithEmbeddings?: number` to the stats result type so TypeScript is happy. The MCP tool already returns this field; this just teaches the consumer to read it. Co-authored-by: Reuven <cohen@ruv-mac-mini.local>