🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(memory): remove RvfBackend's dead @ruvector/rvf native branch (#4279)
Mathew Beane78817c3e5fa0
diff --git a/v3/@claude-flow/memory/src/database-provider.ts b/v3/@claude-flow/memory/src/database-provider.tsindex 66ea089963..ae39c32a24 100644--- a/v3/@claude-flow/memory/src/database-provider.ts+++ b/v3/@claude-flow/memory/src/database-provider.ts@@ -168,7 +168,7 @@ async function selectProvider(console.log(`[DatabaseProvider] Recommended provider: ${platformInfo.recommendedProvider}`);}- // Try RVF first (always available via pure-TS fallback, native when @ruvector/rvf installed)+ // Try RVF first (pure-TS, always available)if (await testRvf()) {if (verbose) {console.log('[DatabaseProvider] RVF backend available');diff --git a/v3/@claude-flow/memory/src/rvf-backend.test.ts b/v3/@claude-flow/memory/src/rvf-backend.test.tsnew file mode 100644index 0000000000..81ac2726b7--- /dev/null+++ b/v3/@claude-flow/memory/src/rvf-backend.test.ts@@ -0,0 +1,111 @@+/**+ * RvfBackend — #4279 regression guard.+ *+ * The backend used to try `@ruvector/rvf` first and, had that ever succeeded,+ * skip `loadFromDisk()` and later overwrite `databasePath` with only the+ * entries written since startup. The native branch is gone; these tests pin+ * that a reopen always reloads the snapshot, even when an `@ruvector/rvf`+ * whose factories succeed is importable.+ */++import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';+import * as fs from 'node:fs';+import * as path from 'node:path';+import * as os from 'node:os';+import { RvfBackend } from './rvf-backend.js';+import { createDefaultEntry } from './types.js';++const rvfFactories = vi.hoisted(() => ({+ create: vi.fn(async () => ({ close: async () => {} })),+ open: vi.fn(async () => ({ close: async () => {} })),+}));++// Stand-in whose static factories and instance open() all succeed, so the+// old init would have taken the native branch.+vi.mock('@ruvector/rvf', () => {+ class MockRvfDb {+ static create = rvfFactories.create;+ static open = rvfFactories.open;+ async open(): Promise<void> {}+ async close(): Promise<void> {}+ }+ return { RvfDatabase: MockRvfDb };+});++const DIM = 8;++function vec(seed: number): Float32Array {+ const out = new Float32Array(DIM);+ for (let i = 0; i < DIM; i++) out[i] = Math.sin(seed * 7 + i);+ return out;+}++function entry(key: string, seed: number) {+ return { ...createDefaultEntry({ key, content: `content ${key}`, namespace: 'ns' }), embedding: vec(seed) };+}++describe('RvfBackend (#4279)', () => {+ let dir: string;+ let dbPath: string;++ beforeEach(() => {+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'cf-mem-rvf-4279-'));+ dbPath = path.join(dir, 'memory.rvf');+ rvfFactories.create.mockClear();+ rvfFactories.open.mockClear();+ });++ afterEach(() => {+ try { fs.rmSync(dir, { recursive: true, force: true }); } catch { /* ignore */ }+ });++ function backend(): RvfBackend {+ return new RvfBackend({ databasePath: dbPath, dimensions: DIM, autoPersistInterval: 0 });+ }++ it('reloads existing entries on reopen and keeps them on the next persist', async () => {+ const first = backend();+ await first.initialize();+ await first.store(entry('a', 1));+ await first.store(entry('b', 2));+ await first.shutdown();++ const second = backend();+ await second.initialize();+ expect(await second.count()).toBe(2);+ expect((await second.getByKey('ns', 'a'))?.content).toBe('content a');++ await second.store(entry('c', 3));+ await second.shutdown();++ const raw = fs.readFileSync(dbPath);+ expect(raw.subarray(0, 4).toString('latin1')).toBe('RVF\0');++ const third = backend();+ await third.initialize();+ expect(await third.count()).toBe(3);+ const hits = await third.search(vec(2), { k: 1 });+ expect(hits[0]?.entry.key).toBe('b');+ await third.shutdown();+ });++ it('never opens a native @ruvector/rvf store', async () => {+ const b = backend();+ await b.initialize();+ await b.store(entry('a', 1));+ await b.shutdown();++ expect(rvfFactories.create).not.toHaveBeenCalled();+ expect(rvfFactories.open).not.toHaveBeenCalled();+ });++ it('reports a healthy index without recommending @ruvector/rvf', async () => {+ const b = backend();+ await b.initialize();+ const health = await b.healthCheck();+ expect(health.status).toBe('healthy');+ expect(health.components.index.status).toBe('healthy');+ expect(health.recommendations.join(' ')).not.toContain('@ruvector/rvf');+ await b.shutdown();+ });+});diff --git a/v3/@claude-flow/memory/src/rvf-backend.ts b/v3/@claude-flow/memory/src/rvf-backend.tsindex 92e5327a30..d1b394bdec 100644--- a/v3/@claude-flow/memory/src/rvf-backend.ts+++ b/v3/@claude-flow/memory/src/rvf-backend.ts@@ -210,11 +210,19 @@ const DEFAULT_EF_CONSTRUCTION = 200;const DEFAULT_MAX_ELEMENTS = 100000;const DEFAULT_PERSIST_INTERVAL = 30000;+/**+ * Pure-TS RVF backend: entries live in memory and persist to a single+ * `RVF\0` snapshot file at `databasePath`, with `HnswLite` for search.+ *+ * There is deliberately no `@ruvector/rvf` native path (#4279). The SDK is a+ * vector index (u64 ids, `{id, distance}` results, no payloads), so it cannot+ * hold `MemoryEntry` records, and a native store opened at `databasePath`+ * would compete with the snapshot for the same file.+ */export class RvfBackend implements IMemoryBackend {private entries = new Map<string, MemoryEntry>();private keyIndex = new Map<string, string>();private hnswIndex: HnswLite | null = null;- private nativeDb: any = null;private config: Required<RvfBackendConfig>;private initialized = false;private dirty = false;@@ -246,16 +254,13 @@ export class RvfBackend implements IMemoryBackend {async initialize(): Promise<void> {if (this.initialized) return;- const useNative = await this.tryNativeInit();- if (!useNative) {- this.hnswIndex = new HnswLite(- this.config.dimensions,- this.config.hnswM,- this.config.hnswEfConstruction,- this.config.metric,- );- await this.loadFromDisk();- }+ this.hnswIndex = new HnswLite(+ this.config.dimensions,+ this.config.hnswM,+ this.config.hnswEfConstruction,+ this.config.metric,+ );+ await this.loadFromDisk();if (this.config.autoPersistInterval > 0 && this.config.databasePath !== ':memory:') {this.persistTimer = setInterval(() => {@@ -266,8 +271,7 @@ export class RvfBackend implements IMemoryBackend {this.initialized = true;if (this.config.verbose) {- const mode = this.nativeDb ? 'native @ruvector/rvf' : 'pure-TS fallback';- console.log(`[RvfBackend] Initialized (${mode}), ${this.entries.size} entries loaded`);+ console.log(`[RvfBackend] Initialized, ${this.entries.size} entries loaded`);}}@@ -283,11 +287,6 @@ export class RvfBackend implements IMemoryBackend {await this.persistToDisk();}- if (this.nativeDb) {- try { await this.nativeDb.close(); } catch {}- this.nativeDb = null;- }-this.entries.clear();this.keyIndex.clear();this.hnswIndex = null;@@ -491,10 +490,6 @@ export class RvfBackend implements IMemoryBackend {const recommendations: string[] = [];if (!this.initialized) issues.push('Backend not initialized');- if (!this.hnswIndex && !this.nativeDb) {- issues.push('No vector index available');- recommendations.push('Install @ruvector/rvf for native HNSW performance');- }const status = issues.length === 0? 'healthy'@@ -504,7 +499,7 @@ export class RvfBackend implements IMemoryBackend {status,components: {storage: { status: this.initialized ? 'healthy' : 'unhealthy', latency: 0 },- index: { status: this.hnswIndex || this.nativeDb ? 'healthy' : 'degraded', latency: 0 },+ index: { status: this.hnswIndex ? 'healthy' : 'degraded', latency: 0 },cache: { status: 'healthy', latency: 0 },},timestamp: Date.now(),@@ -513,31 +508,6 @@ export class RvfBackend implements IMemoryBackend {};}- private async tryNativeInit(): Promise<boolean> {- try {- const rvf = await import('@ruvector/rvf' as string);- this.nativeDb = new rvf.RvfDatabase({- path: this.config.databasePath,- dimensions: this.config.dimensions,- metric: this.config.metric,- quantization: this.config.quantization,- hnswM: this.config.hnswM,- hnswEfConstruction: this.config.hnswEfConstruction,- maxElements: this.config.maxElements,- });- await this.nativeDb.open();- if (this.config.verbose) {- console.log('[RvfBackend] Native @ruvector/rvf loaded successfully');- }- return true;- } catch {- if (this.config.verbose) {- console.log('[RvfBackend] @ruvector/rvf not available, using pure-TS fallback');- }- return false;- }- }-private compositeKey(namespace: string, key: string): string {return `${namespace}\0${key}`;}