mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
a6202c39a3
* feat: implement ADR-062 (StrongDM all 3 tiers) and ADR-087 (RuVector 14/14 capabilities)
ADR-062 StrongDM Software Factory — all 6 actions across 3 tiers:
- Tier 1: Loop detection wired to MCP protocol-server (blocks on strike 3+),
token dashboard (pre-existing)
- Tier 2: Holdout testing (10% FNV-1a selection, filtered in test-execution),
gate ratcheting (monotonic 5-pass/2%/95% cap, persisted to MemoryBackend)
- Tier 3: Progressive context (TF-IDF prediction, reduces availableFiles on spawn),
meta-learning cycle (4 insight types, stored + published as domain events)
ADR-087 RuVector Advanced Capabilities — milestones 1-5:
- EWC++ recordOutcome + backgroundConsolidate wired to 3 domain coordinators
- R1: HDC fingerprinting (10K-bit hypervectors, wired to PatternStore.store())
- R3: Delta event sourcing (sparse encoding, wired to PatternStore.store())
- R13: Cognitive routing (predictive compression, wired to mailbox.send/receive)
- R14: Hyperbolic HNSW (Poincare ball, auto-indexed in PatternStore.store())
Also updates ADR statuses: 059, 060, 061 → Implemented (were already done),
062 → Implemented, 086 → In Progress, 087 → Implemented.
223 new tests across 11 test files, all passing. Zero regressions.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: implement RVF cluster (ADR-065/066/067/071) with native benchmarks
Implements the RVF persistence cluster for persistent HNSW vector storage,
agent memory branching, and HNSW unification foundation.
Key changes:
- RvfPatternStore: IPatternStore backed by @ruvector/rvf-node native HNSW
(1.2ms cold-start, 0.19ms search p50, verified with real native binary)
- AgentMemoryBranch: per-agent COW isolation via derive(), ingest-log merge,
wired into Kernel.initialize() + DefaultAgentCoordinator
- HnswLegacyBridge: adapts old IHNSWIndex to unified IHnswIndexProvider,
wired into PatternStore when useUnifiedHnsw flag enabled
- Factory routing: createPatternStore() returns RvfPatternStore when flag
enabled + native available + data directory exists
- Dream engine: accepts external RVF adapter (no duplicate file handles),
RVCOWBranchManager enhanced with recall validation check
- @ruvector/gnn bumped 0.1.19→0.1.25, 3 new feature flags added
- IPatternStore interface extracted for polymorphic pattern store usage
- 50 new tests (16 RvfPatternStore + 17 AgentMemoryBranch + 12 bridge + 5 benchmarks)
- 1188 tests pass, 0 regressions
ADR status: 066 Implemented, 067 Implemented, 065 Implemented,
069/071 In Progress (honest assessment after brutal-honesty review)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(init): resolve skills/agents paths from package root, not relative to bundle depth
esbuild code-splitting puts installer code into dist/cli/chunks/ (3 levels
deep) instead of dist/init/ (2 levels deep), so the old ../../ traversals
landed at dist/ instead of the package root — causing "Source directory not
found" errors for all global installs.
Replace brittle relative-path resolution in all 4 installers with a shared
findPackageRoot() that walks up to the nearest package.json with
name=agentic-qe. Prioritise assets/ paths (canonical npm source) over
.claude/ paths.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: complete RVF cluster Phases 2-3 (ADR-067/069/071/072) with devil's advocate fixes
Phase 2A (ADR-067): Agent memory branching enabled — useAgentMemoryBranching=true,
BRANCH_DISCARD witness action, recordIngest callback exposed to agents via config.
Phase 2B (ADR-069): Dream RVF COW — useRvfFork driven by isRVFPatternStoreEnabled(),
child adapter stored + temp files cleaned up on merge/discard, 13 tests.
Phase 2C (ADR-071): HNSW unification — useUnifiedHnsw=true, HNSWEmbeddingIndex routes
through HnswAdapter, UnifiedMemory vectorIndex uses UnifiedHnswIndex, HnswLegacyBridge
delegates to adapter string-ID APIs (no duplicate ID maps), addEmbeddingsBatch routed
correctly, saveIndex/loadIndex safe under unified mode.
Phase 3 (ADR-072): RVF primary migration scaffolding — RvfMigrationAdapter (5-stage
routing with write latency tracking), RvfConsistencyValidator (rolling divergence +
compaction), RvfStageGate (go/no-go with witness chain), rvfMigrationStage=1 default,
wired into shared-rvf-dual-writer at stage >= 2, 32 tests.
Cross-cutting fixes from devil's advocate review:
- Shared RVF adapter singleton eliminates dual file handles (kernel + dream engine)
- RvfPatternStore reports honest nativeAvailable=false + rvfInitError on failure
- ESM-safe dynamic import() replaces require() in dream-engine and branch-manager
- quality_assess defaults to src/ instead of cwd to prevent full-project scan hang
- discoverSourceFiles skips .agentic-qe/.claude/.cache dirs, adds maxFiles=5000 cap
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: complete RVF cluster plan — Phase 2C decommission, Phase 3 integration, fix 7 pre-existing test failures
Phase 2C (ADR-071) — HNSW decommission:
- Remove RuvectorFlatIndex fallback from unified-memory.ts; always use UnifiedHnswIndex
- Hardcode isUnifiedHnswActive()=true in HNSWEmbeddingIndex (hnswlib-node legacy path is dead code)
- Create HnswShadowValidator for brute-force vs HnswAdapter divergence validation
- Benchmark alias (rvf-pattern-store.bench.ts) for plan compliance
Phase 3 (ADR-072) — RVF Primary Migration integration:
- RvfMigrationCoordinator: wires adapter + validator + gate with real SQLite/RVF handles
- MCP tools: migration_status, migration_check, migration_promote (persistence category)
- Kernel boot wiring: coordinator initializes when rvfMigrationStage >= 2
- RvfMigrationAdapter.setStage(): propagate promotions to routing logic
- Promote default rvfMigrationStage from 1 (hybrid) to 2 (dual-write-sqlite-primary)
- Integration test: 13 tests covering full lifecycle (stage 1→2→3→4), write/read routing,
consistency checks, gate enforcement, fallback, metrics
Test fixes (7 pre-existing failures → 1 remaining):
- code-intelligence-metrics-wiring: spy console.info not console.log (logger routes to console.info)
- mcp-integration: disable ADR-062 loop detection (repeated identical calls are by design)
- dream-cycle-tool (2 tests): RvfPatternStore empty-query branch returns all patterns from SQLite
- coherence-integration (4 tests): RvfPatternStore vector search fallback computes brute-force
cosine over SQLite embeddings when RVF adapter unavailable; getStats() falls back to SQLite count;
auto-attach SQLitePatternStore in initialize() when not explicitly wired
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore(release): bump version to v3.9.1
- Version bump in package.json and skills-manifest.json
- Fix "Dynamic require of X is not supported" in ESM bundles by adding
createRequire banner to both CLI and MCP build scripts — every chunk
now has a working require() for Node.js builtins
- Add CHANGELOG.md entry and release notes for v3.9.1
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(ci): regenerate package-lock.json for npm ci compatibility
The lock file was out of sync with package.json — new transitive
dependencies added on main were missing. All 15 CI checks failed
at `npm ci` with "Missing from lock file" errors.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(ci): pin Node to 24.13.0 and restore working lock file
Node 24.14.1 ships npm 11.11.0 which enforces stricter lock file
validation than 11.6.x (what 24.13.0 ships). The existing lock file
passes under 11.6.x but fails under 11.11.0 with "Missing from lock
file" for transitive dependencies of private-registry packages.
Pin all 5 workflow files to node-version: '24.13.0' and restore the
lock file from commit f9b76968 (last CI-passing state) with only the
version bump to 3.9.1.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(ci): regenerate package-lock.json with npm 10 for stable npm ci
npm 11 (Node 24) produces internally inconsistent lock files that npm ci
rejects — each npm install resolves transitive deps differently. Generated
with npm 10 (Node 22 LTS) which produces stable lock files compatible with
both npm 10 and npm 11.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
421 lines
13 KiB
TypeScript
421 lines
13 KiB
TypeScript
/**
|
|
* Tests for RvfPatternStore (ADR-066)
|
|
*
|
|
* Tests the RVF-backed pattern store adapter, factory routing,
|
|
* and migration utility.
|
|
*/
|
|
|
|
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
import { RvfPatternStore } from '../../../src/learning/rvf-pattern-store.js';
|
|
import type { RvfNativeAdapter } from '../../../src/integrations/ruvector/rvf-native-adapter.js';
|
|
import type { QEPattern } from '../../../src/learning/qe-patterns.js';
|
|
import { migratePatterns } from '../../../src/learning/rvf-pattern-migration.js';
|
|
import {
|
|
setRuVectorFeatureFlags,
|
|
resetRuVectorFeatureFlags,
|
|
} from '../../../src/integrations/ruvector/feature-flags.js';
|
|
|
|
// ============================================================================
|
|
// Mock RVF Adapter
|
|
// ============================================================================
|
|
|
|
function createMockAdapter(opts: { dimension?: number } = {}): RvfNativeAdapter {
|
|
const dimension = opts.dimension ?? 384;
|
|
const vectors = new Map<string, Float32Array>();
|
|
|
|
return {
|
|
ingest: vi.fn((entries: Array<{ id: string; vector: Float32Array | number[] }>) => {
|
|
for (const e of entries) {
|
|
const vec = e.vector instanceof Float32Array ? e.vector : new Float32Array(e.vector);
|
|
vectors.set(e.id, vec);
|
|
}
|
|
return { accepted: entries.length, rejected: 0 };
|
|
}),
|
|
search: vi.fn((query: Float32Array | number[], k: number) => {
|
|
// Simple brute-force cosine similarity
|
|
const qVec = query instanceof Float32Array ? query : new Float32Array(query);
|
|
const results: Array<{ id: string; distance: number; score: number }> = [];
|
|
for (const [id, vec] of vectors) {
|
|
let dot = 0, magA = 0, magB = 0;
|
|
for (let i = 0; i < dimension; i++) {
|
|
dot += qVec[i] * vec[i];
|
|
magA += qVec[i] * qVec[i];
|
|
magB += vec[i] * vec[i];
|
|
}
|
|
const similarity = dot / (Math.sqrt(magA) * Math.sqrt(magB) + 1e-9);
|
|
results.push({ id, distance: 1 - similarity, score: similarity });
|
|
}
|
|
results.sort((a, b) => b.score - a.score);
|
|
return results.slice(0, k);
|
|
}),
|
|
delete: vi.fn((ids: string[]) => {
|
|
let deleted = 0;
|
|
for (const id of ids) {
|
|
if (vectors.delete(id)) deleted++;
|
|
}
|
|
return deleted;
|
|
}),
|
|
status: vi.fn(() => ({
|
|
totalVectors: vectors.size,
|
|
totalSegments: 1,
|
|
fileSizeBytes: vectors.size * dimension * 4,
|
|
epoch: 1,
|
|
witnessValid: true,
|
|
witnessEntries: 0,
|
|
})),
|
|
close: vi.fn(),
|
|
isOpen: vi.fn(() => true),
|
|
path: vi.fn(() => '/tmp/test-patterns.rvf'),
|
|
dimension: vi.fn(() => dimension),
|
|
size: vi.fn(() => vectors.size),
|
|
compact: vi.fn(),
|
|
fork: vi.fn(),
|
|
derive: vi.fn(),
|
|
embedKernel: vi.fn(),
|
|
extractKernel: vi.fn(() => null),
|
|
verifyWitness: vi.fn(() => ({ valid: true, totalEntries: 0, errors: [] })),
|
|
sign: vi.fn(() => null),
|
|
fileId: vi.fn(() => 'test-file-id'),
|
|
parentId: vi.fn(() => null),
|
|
lineageDepth: vi.fn(() => 0),
|
|
indexStats: vi.fn(() => ({
|
|
totalVectors: vectors.size,
|
|
dimension,
|
|
totalSegments: 1,
|
|
fileSizeBytes: 0,
|
|
epoch: 1,
|
|
witnessValid: true,
|
|
witnessEntries: 0,
|
|
idMapSize: vectors.size,
|
|
})),
|
|
freeze: vi.fn(() => 1),
|
|
} as unknown as RvfNativeAdapter;
|
|
}
|
|
|
|
// ============================================================================
|
|
// Test Helpers
|
|
// ============================================================================
|
|
|
|
function makePattern(overrides: Partial<QEPattern> = {}): QEPattern {
|
|
return {
|
|
id: `pattern-${Math.random().toString(36).slice(2, 8)}`,
|
|
patternType: 'test-template',
|
|
qeDomain: 'test-generation',
|
|
domain: 'test-generation',
|
|
name: 'Test Pattern',
|
|
description: 'A test pattern for unit testing',
|
|
confidence: 0.8,
|
|
usageCount: 5,
|
|
successRate: 0.9,
|
|
qualityScore: 0.75,
|
|
context: { tags: ['test'] },
|
|
template: { type: 'code', content: 'test()', variables: [] },
|
|
embedding: Array.from({ length: 384 }, () => Math.random()),
|
|
tier: 'short-term',
|
|
createdAt: new Date(),
|
|
lastUsedAt: new Date(),
|
|
successfulUses: 4,
|
|
reusable: false,
|
|
reuseCount: 0,
|
|
averageTokenSavings: 0,
|
|
...overrides,
|
|
} as QEPattern;
|
|
}
|
|
|
|
// ============================================================================
|
|
// RvfPatternStore Tests
|
|
// ============================================================================
|
|
|
|
describe('RvfPatternStore', () => {
|
|
let store: RvfPatternStore;
|
|
let adapter: RvfNativeAdapter;
|
|
|
|
beforeEach(async () => {
|
|
adapter = createMockAdapter();
|
|
store = new RvfPatternStore(
|
|
() => adapter,
|
|
{ rvfPath: '/tmp/test.rvf', base: undefined as any },
|
|
);
|
|
await store.initialize();
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await store.dispose();
|
|
});
|
|
|
|
describe('Initialization', () => {
|
|
it('should initialize and create adapter', async () => {
|
|
expect(store.getAdapter()).toBe(adapter);
|
|
});
|
|
|
|
it('should skip re-initialization', async () => {
|
|
const factoryFn = vi.fn(() => adapter);
|
|
const s = new RvfPatternStore(factoryFn, { rvfPath: '/tmp/test.rvf', base: undefined as any });
|
|
await s.initialize();
|
|
await s.initialize(); // second call
|
|
expect(factoryFn).toHaveBeenCalledTimes(1);
|
|
await s.dispose();
|
|
});
|
|
});
|
|
|
|
describe('Store', () => {
|
|
it('should store a pattern and ingest its vector', async () => {
|
|
const pattern = makePattern();
|
|
const result = await store.store(pattern);
|
|
|
|
expect(result.success).toBe(true);
|
|
if (result.success) {
|
|
expect(result.value).toBe(pattern.id);
|
|
}
|
|
expect(adapter.ingest).toHaveBeenCalledOnce();
|
|
});
|
|
|
|
it('should reject pattern below confidence threshold', async () => {
|
|
const pattern = makePattern({ confidence: 0.1 });
|
|
const result = await store.store(pattern);
|
|
|
|
expect(result.success).toBe(false);
|
|
expect(adapter.ingest).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('should skip vector ingest when embedding is missing', async () => {
|
|
const pattern = makePattern({ embedding: undefined });
|
|
const result = await store.store(pattern);
|
|
|
|
expect(result.success).toBe(true);
|
|
expect(adapter.ingest).not.toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('Search', () => {
|
|
it('should search by vector via RVF adapter', async () => {
|
|
// Store a pattern first
|
|
const pattern = makePattern();
|
|
await store.store(pattern);
|
|
|
|
// Search with its own embedding
|
|
const result = await store.search(pattern.embedding!, { limit: 5 });
|
|
|
|
expect(result.success).toBe(true);
|
|
if (result.success) {
|
|
expect(adapter.search).toHaveBeenCalled();
|
|
}
|
|
});
|
|
|
|
it('should filter results by domain', async () => {
|
|
const p1 = makePattern({ qeDomain: 'test-generation' });
|
|
const p2 = makePattern({ qeDomain: 'coverage-analysis' });
|
|
|
|
// Mock sqliteStore for metadata lookup
|
|
const mockSqlite = {
|
|
getPattern: vi.fn((id: string) => {
|
|
if (id === p1.id) return p1;
|
|
if (id === p2.id) return p2;
|
|
return null;
|
|
}),
|
|
};
|
|
(store as any).sqliteStore = mockSqlite;
|
|
|
|
await store.store(p1);
|
|
await store.store(p2);
|
|
|
|
const result = await store.search(p1.embedding!, {
|
|
domain: 'test-generation',
|
|
limit: 10,
|
|
});
|
|
|
|
expect(result.success).toBe(true);
|
|
if (result.success) {
|
|
for (const r of result.value) {
|
|
expect(r.pattern.qeDomain).toBe('test-generation');
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
describe('Delete', () => {
|
|
it('should delete vector from RVF adapter', async () => {
|
|
const pattern = makePattern();
|
|
await store.store(pattern);
|
|
|
|
const result = await store.delete(pattern.id);
|
|
|
|
expect(result.success).toBe(true);
|
|
expect(adapter.delete).toHaveBeenCalledWith([pattern.id]);
|
|
});
|
|
});
|
|
|
|
describe('Stats', () => {
|
|
it('should return stats from RVF adapter', async () => {
|
|
const pattern = makePattern();
|
|
await store.store(pattern);
|
|
|
|
const stats = await store.getStats();
|
|
|
|
expect(stats.totalPatterns).toBe(1);
|
|
expect(stats.hnswStats.nativeAvailable).toBe(true);
|
|
expect(stats.hnswStats.vectorCount).toBe(1);
|
|
});
|
|
});
|
|
|
|
describe('Create', () => {
|
|
it('should create a pattern with defaults', async () => {
|
|
const result = await store.create({
|
|
patternType: 'test-template',
|
|
name: 'New Pattern',
|
|
description: 'Created via create()',
|
|
template: { type: 'code', content: 'test()', variables: [] },
|
|
embedding: Array.from({ length: 384 }, () => Math.random()),
|
|
});
|
|
|
|
expect(result.success).toBe(true);
|
|
if (result.success) {
|
|
expect(result.value.name).toBe('New Pattern');
|
|
expect(result.value.tier).toBe('short-term');
|
|
expect(result.value.confidence).toBe(0.5); // default
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
// ============================================================================
|
|
// Factory Routing Tests
|
|
// ============================================================================
|
|
|
|
describe('createPatternStore factory routing', () => {
|
|
afterEach(() => {
|
|
resetRuVectorFeatureFlags();
|
|
});
|
|
|
|
it('should return PatternStore when useRVFPatternStore is false', async () => {
|
|
setRuVectorFeatureFlags({ useRVFPatternStore: false });
|
|
|
|
const { createPatternStore } = await import('../../../src/learning/pattern-store.js');
|
|
const mockMemory = {
|
|
get: vi.fn(),
|
|
set: vi.fn(),
|
|
delete: vi.fn(),
|
|
list: vi.fn(() => []),
|
|
clear: vi.fn(),
|
|
};
|
|
const store = createPatternStore(mockMemory as any);
|
|
|
|
// Should be the original PatternStore (not RvfPatternStore)
|
|
expect(store.constructor.name).toBe('PatternStore');
|
|
await store.dispose();
|
|
});
|
|
|
|
it('should return RvfPatternStore when useRVFPatternStore is true and native is available', async () => {
|
|
// Check if native binary is actually available in this environment
|
|
let nativeAvailable = false;
|
|
try {
|
|
const { isRvfNativeAvailable } = await import(
|
|
'../../../src/integrations/ruvector/rvf-native-adapter.js'
|
|
);
|
|
nativeAvailable = isRvfNativeAvailable();
|
|
} catch { /* not available */ }
|
|
|
|
if (!nativeAvailable) {
|
|
console.log('[TEST] Skipping true-path test — @ruvector/rvf-node not available');
|
|
return;
|
|
}
|
|
|
|
setRuVectorFeatureFlags({ useRVFPatternStore: true });
|
|
|
|
const { createPatternStore } = await import('../../../src/learning/pattern-store.js');
|
|
const mockMemory = {
|
|
get: vi.fn(),
|
|
set: vi.fn(),
|
|
delete: vi.fn(),
|
|
list: vi.fn(() => []),
|
|
clear: vi.fn(),
|
|
};
|
|
const store = createPatternStore(mockMemory as any);
|
|
|
|
expect(store.constructor.name).toBe('RvfPatternStore');
|
|
await store.dispose();
|
|
|
|
// Cleanup the .rvf file created
|
|
const { existsSync, unlinkSync } = await import('fs');
|
|
for (const ext of ['', '.idmap.json']) {
|
|
const p = `.agentic-qe/patterns.rvf${ext}`;
|
|
if (existsSync(p)) unlinkSync(p);
|
|
}
|
|
});
|
|
});
|
|
|
|
// ============================================================================
|
|
// Migration Utility Tests
|
|
// ============================================================================
|
|
|
|
describe('migratePatterns', () => {
|
|
it('should migrate embeddings from SQLite to RVF', () => {
|
|
const adapter = createMockAdapter();
|
|
const mockSqlite = {
|
|
getAllEmbeddings: vi.fn(() => [
|
|
{ patternId: 'p1', embedding: Array.from({ length: 384 }, () => 0.5) },
|
|
{ patternId: 'p2', embedding: Array.from({ length: 384 }, () => 0.3) },
|
|
{ patternId: 'p3', embedding: Array.from({ length: 384 }, () => 0.7) },
|
|
]),
|
|
};
|
|
|
|
const result = migratePatterns(
|
|
mockSqlite as any,
|
|
adapter,
|
|
{ batchSize: 2, dimension: 384 },
|
|
);
|
|
|
|
expect(result.totalMigrated).toBe(3);
|
|
expect(result.totalSkipped).toBe(0);
|
|
expect(result.errors).toHaveLength(0);
|
|
expect(result.durationMs).toBeGreaterThan(0);
|
|
// Two batches: [p1,p2] and [p3]
|
|
expect(adapter.ingest).toHaveBeenCalledTimes(2);
|
|
});
|
|
|
|
it('should skip embeddings with wrong dimension', () => {
|
|
const adapter = createMockAdapter();
|
|
const mockSqlite = {
|
|
getAllEmbeddings: vi.fn(() => [
|
|
{ patternId: 'p1', embedding: Array.from({ length: 384 }, () => 0.5) },
|
|
{ patternId: 'p2', embedding: Array.from({ length: 128 }, () => 0.3) }, // wrong dim
|
|
]),
|
|
};
|
|
|
|
const result = migratePatterns(
|
|
mockSqlite as any,
|
|
adapter,
|
|
{ dimension: 384 },
|
|
);
|
|
|
|
expect(result.totalMigrated).toBe(1);
|
|
expect(result.totalSkipped).toBe(1);
|
|
});
|
|
|
|
it('should handle empty embeddings list', () => {
|
|
const adapter = createMockAdapter();
|
|
const mockSqlite = {
|
|
getAllEmbeddings: vi.fn(() => []),
|
|
};
|
|
|
|
const result = migratePatterns(mockSqlite as any, adapter);
|
|
|
|
expect(result.totalMigrated).toBe(0);
|
|
expect(result.totalSkipped).toBe(0);
|
|
expect(adapter.ingest).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('should handle SQLite read failure gracefully', () => {
|
|
const adapter = createMockAdapter();
|
|
const mockSqlite = {
|
|
getAllEmbeddings: vi.fn(() => { throw new Error('DB locked'); }),
|
|
};
|
|
|
|
const result = migratePatterns(mockSqlite as any, adapter);
|
|
|
|
expect(result.totalMigrated).toBe(0);
|
|
expect(result.errors.length).toBeGreaterThan(0);
|
|
expect(result.errors[0]).toContain('DB locked');
|
|
});
|
|
});
|