Skip to content

fix(vector-db): pass unique storagePath to VectorDB to prevent daemon lock conflict#2230

Open
ruvnet wants to merge 2 commits into
mainfrom
fix/hnsw-storage-path-lock
Open

fix(vector-db): pass unique storagePath to VectorDB to prevent daemon lock conflict#2230
ruvnet wants to merge 2 commits into
mainfrom
fix/hnsw-storage-path-lock

Conversation

@ruvnet

@ruvnet ruvnet commented May 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • HNSW was silently degrading to brute-force FallbackVectorDB on every startup
  • Root cause: new VectorDBClass({ dimensions }) — no storagePath — so the native binding defaulted to agentdb.rvf in CWD, which running daemons hold exclusively
  • The constructor threw "Database already open. Cannot acquire lock", the silent catch {} swallowed the error, and every search ran O(n) brute-force instead of HNSW
  • The benchmark's ~1.0× speedup and recall@10 = 1.0 at every N were the signature of brute-force vs brute-force

Fix (v3/@claude-flow/cli/src/ruvector/vector-db.ts)

  1. Added uniqueStoragePath() — generates os.tmpdir()/ruvector-<pid>-<rand>.rvf so each adapter instance owns its own file and never contends with the daemon lock
  2. Changed new VectorDBClass({ dimensions })new VectorDBClass({ dimensions, storagePath: uniqueStoragePath() })
  3. Made the fallback catch {} emit console.warn so any future HNSW init failure is visible

Published

@claude-flow/cli@3.7.0-alpha.82 and claude-flow@3.7.0-alpha.82 shipped to npm with this fix.

Test plan

  • npx @claude-flow/cli@latest — HNSW activates (no [vector-db] HNSW init failed warning)
  • Benchmark at N=5000 shows ≥2× speedup vs brute-force baseline

🤖 Generated with claude-flow

ruvnet added 2 commits May 29, 2026 11:48
… lock conflict

Without a storagePath the native VectorDB opened the default "agentdb.rvf"
in CWD, which running claude-flow daemons already hold exclusively. The
constructor threw "Database already open. Cannot acquire lock", the silent
catch {} degraded the adapter to FallbackVectorDB, and every benchmark
measured brute-force-vs-brute-force instead of HNSW.

Fix: generate a per-call temp file path (os.tmpdir/ruvector-<pid>-<rand>.rvf)
so the adapter never races the daemon's lock. Also surface any remaining
HNSW init failures as console.warn instead of swallowing them silently.

Co-Authored-By: claude-flow <ruv@ruv.net>
Bumps @claude-flow/cli and claude-flow to 3.7.0-alpha.82 to ship the
HNSW storage-path fix (vector-db.ts: pass unique tmpdir path to VectorDB
constructor so it no longer races the daemon lock on agentdb.rvf).

Co-Authored-By: claude-flow <ruv@ruv.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant