Summary
Replace the 18MB sql.js WASM SQLite hard dependency with RuVector Format (RVF) across @claude-flow/shared, @claude-flow/memory, and @claude-flow/embeddings.
ADR: v3/implementation/adrs/ADR-057-rvf-native-storage-backend.md
Branch: feat/adr-057-rvf-storage-backend
Problem
sql.js is 18MB — the single largest hard dependency in the core install path
- sql.js provides no vector indexing — uses brute-force O(n) cosine similarity
- Adds 35s to Docker cold start and inflates images by ~18MB even after pruning
Proposed Solution
Replace sql.js with RVF (@ruvector/rvf), which provides:
| Metric |
sql.js |
RVF |
| Package size |
18MB WASM |
52KB WASM / ~2MB native |
| Vector search |
O(n) brute-force |
O(log n) HNSW — 150x-12,500x faster |
| Quantization |
fp32 only |
fp16/int8/int4/binary — 2-8x memory savings |
| Crash safety |
Manual export/save |
Append-only (no WAL) |
| Progressive loading |
N/A |
70% recall on first query |
Migration
- Automatic: Transparent migration on first access (legacy
.db/.json → .rvf)
- Manual:
ruflo migrate run --storage, ruflo migrate rollback --storage
- Backward compatible: Legacy formats permanently readable;
.bak files preserved
- 3 formats supported: sql.js
.db, better-sqlite3 .db, JSON .json
Implementation Phases
Impact
- -18MB from core install size
- 150x-12,500x faster vector search
- 2-8x memory reduction via quantization
- Docker lite image: 324MB → ~306MB
Related
- ADR-053: AgentDB v3 Controller Activation
- ADR-054: RVF-Powered Plugin Marketplace
- ADR-055: AgentDB Controller Bug Remediation
- ADR-056: agentic-flow v3 Integration
Summary
Replace the 18MB
sql.jsWASM SQLite hard dependency with RuVector Format (RVF) across@claude-flow/shared,@claude-flow/memory, and@claude-flow/embeddings.ADR:
v3/implementation/adrs/ADR-057-rvf-native-storage-backend.mdBranch:
feat/adr-057-rvf-storage-backendProblem
sql.jsis 18MB — the single largest hard dependency in the core install pathProposed Solution
Replace sql.js with RVF (
@ruvector/rvf), which provides:Migration
.db/.json→.rvf)ruflo migrate run --storage,ruflo migrate rollback --storage.bakfiles preserved.db, better-sqlite3.db, JSON.jsonImplementation Phases
RvfBackendimplementingIMemoryBackendinterfaceRvfEventLogimplementingIEventStorein@claude-flow/sharedRvfEmbeddingCachefor@claude-flow/embeddingsmigrate status/run/rollback/validate --storage)optionalDependencies, update Docker imagesImpact
Related