mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-06 08:16:02 +00:00
* refactor: migrate from KuzuDB to LadybugDB v0.15 KuzuDB was archived (Apple acquisition, Oct 2025). LadybugDB is the community fork with full API compatibility. - Package swap: kuzu → @ladybugdb/core, kuzu-wasm → @ladybugdb/wasm-core - Rename all internal paths: kuzu → lbug (adapters, schema, storage) - Storage path: .gitnexus/kuzu → .gitnexus/lbug (with auto-cleanup) - Add explicit VECTOR extension loading (required in v0.15) - Update CI workflow, documentation, and all tests - 1151 unit + 27 integration tests passing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address code review findings (P1-P3) P1: Fix WASM adapter to use getAll() API, wire cleanupOldKuzuFiles into analyze command, add symlink path traversal protection. P2: Cache VECTOR extension load state, batch augmentation engine queries (20→4), fix web getCopyQuery for multi-language tables, fix stale KuzuDB references, correct brainstorm package names. P3: Complete lbug-wasm.d.ts type declarations, batch semantic search per-label, update stale BM25 comment. * chore: remove outdated KuzuDB migration brainstorming document * fix: load FTS extension in MCP pool adapter on init The read-only pool adapter never loaded the FTS extension, so all QUERY_FTS_INDEX calls failed silently. This broke search-pool and augmentation integration tests, and caused empty results in the web UI server mode. * feat: implement shared Database caching and connection reference counting * feat: enhance KuzuDB migration handling and status reporting * fix: mock cleanupOldKuzuFiles in local backend callTool tests * fix: update mock for cleanupOldKuzuFiles and adjust imports in callTool tests --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
90 lines
2.8 KiB
TypeScript
90 lines
2.8 KiB
TypeScript
/**
|
|
* Test helper: In-memory knowledge graph builder
|
|
*
|
|
* Provides a convenient API for constructing test graphs
|
|
* without touching the filesystem or LadybugDB.
|
|
*/
|
|
import { createKnowledgeGraph } from '../../src/core/graph/graph.js';
|
|
import type { KnowledgeGraph, GraphNode, NodeLabel, RelationshipType } from '../../src/core/graph/types.js';
|
|
|
|
export interface TestNodeInput {
|
|
id: string;
|
|
label: NodeLabel;
|
|
name: string;
|
|
filePath: string;
|
|
startLine?: number;
|
|
endLine?: number;
|
|
isExported?: boolean;
|
|
extra?: Record<string, any>;
|
|
}
|
|
|
|
export interface TestRelInput {
|
|
sourceId: string;
|
|
targetId: string;
|
|
type: RelationshipType;
|
|
confidence?: number;
|
|
reason?: string;
|
|
step?: number;
|
|
}
|
|
|
|
/**
|
|
* Build a test graph from simple input arrays.
|
|
*/
|
|
export function buildTestGraph(
|
|
nodes: TestNodeInput[],
|
|
relationships: TestRelInput[] = [],
|
|
): KnowledgeGraph {
|
|
const graph = createKnowledgeGraph();
|
|
|
|
for (const n of nodes) {
|
|
graph.addNode({
|
|
id: n.id,
|
|
label: n.label,
|
|
properties: {
|
|
name: n.name,
|
|
filePath: n.filePath,
|
|
startLine: n.startLine,
|
|
endLine: n.endLine,
|
|
isExported: n.isExported,
|
|
...n.extra,
|
|
},
|
|
});
|
|
}
|
|
|
|
for (const r of relationships) {
|
|
graph.addRelationship({
|
|
id: `${r.sourceId}-${r.type}-${r.targetId}`,
|
|
sourceId: r.sourceId,
|
|
targetId: r.targetId,
|
|
type: r.type,
|
|
confidence: r.confidence ?? 1.0,
|
|
reason: r.reason ?? '',
|
|
step: r.step,
|
|
});
|
|
}
|
|
|
|
return graph;
|
|
}
|
|
|
|
/**
|
|
* Create a minimal graph with a few files, functions, and relationships.
|
|
* Useful as a baseline for integration tests.
|
|
*/
|
|
export function createMinimalTestGraph(): KnowledgeGraph {
|
|
return buildTestGraph(
|
|
[
|
|
{ id: 'File:src/index.ts', label: 'File', name: 'index.ts', filePath: 'src/index.ts' },
|
|
{ id: 'File:src/utils.ts', label: 'File', name: 'utils.ts', filePath: 'src/utils.ts' },
|
|
{ id: 'Function:src/index.ts:main:1', label: 'Function', name: 'main', filePath: 'src/index.ts', startLine: 1, endLine: 10, isExported: true },
|
|
{ id: 'Function:src/utils.ts:helper:1', label: 'Function', name: 'helper', filePath: 'src/utils.ts', startLine: 1, endLine: 5, isExported: true },
|
|
{ id: 'Class:src/index.ts:App:12', label: 'Class', name: 'App', filePath: 'src/index.ts', startLine: 12, endLine: 30, isExported: true },
|
|
{ id: 'Folder:src', label: 'Folder', name: 'src', filePath: 'src' },
|
|
],
|
|
[
|
|
{ sourceId: 'Function:src/index.ts:main:1', targetId: 'Function:src/utils.ts:helper:1', type: 'CALLS' },
|
|
{ sourceId: 'Function:src/index.ts:main:1', targetId: 'Class:src/index.ts:App:12', type: 'CALLS' },
|
|
{ sourceId: 'File:src/index.ts', targetId: 'Function:src/index.ts:main:1', type: 'CONTAINS' },
|
|
{ sourceId: 'File:src/utils.ts', targetId: 'Function:src/utils.ts:helper:1', type: 'CONTAINS' },
|
|
],
|
|
);
|
|
}
|