Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gitnexus/src/core/lbug/lbug-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ const doInitLbug = async (dbPath: string) => {
}
}

// Load VECTOR extension for semantic search support
// Load query extensions once per core adapter session.
await loadFTSExtension();
await loadVectorExtension();

currentDbPath = dbPath;
Expand Down
15 changes: 6 additions & 9 deletions gitnexus/test/helpers/test-indexed-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ export function withTestLbugDB(
// already open for this dbPath (no new native objects created).
await adapter.initLbug(dbPath);

// 2. Load FTS extension (idempotent — skips if already loaded)
await adapter.loadFTSExtension();

// 3. Drop stale FTS indexes from previous test file
// 2. Drop stale FTS indexes from previous test file
if (options?.ftsIndexes?.length) {
for (const idx of options.ftsIndexes) {
try {
Expand All @@ -101,27 +98,27 @@ export function withTestLbugDB(
}
}

// 4. Clear all data via adapter (DETACH DELETE cascades to relationships)
// 3. Clear all data via adapter (DETACH DELETE cascades to relationships)
for (const table of NODE_TABLES) {
await adapter.executeQuery(`MATCH (n:\`${table}\`) DETACH DELETE n`);
}
await adapter.executeQuery(`MATCH (n:${EMBEDDING_TABLE_NAME}) DELETE n`);

// 5. Seed new data via adapter
// 4. Seed new data via adapter
if (options?.seed?.length) {
for (const q of options.seed) {
await adapter.executeQuery(q);
}
}

// 6. Create FTS indexes on fresh data
// 5. Create FTS indexes on fresh data
if (options?.ftsIndexes?.length) {
for (const idx of options.ftsIndexes) {
await adapter.createFTSIndex(idx.table, idx.indexName, idx.columns);
}
}

// 7. Open pool adapter by injecting the core adapter's writable Database.
// 6. Open pool adapter by injecting the core adapter's writable Database.
// LadybugDB enforces file locks — writable + read-only can't coexist
// on the same path, and db.close() segfaults on macOS due to N-API
// destructor issues. Reusing the writable Database avoids both problems.
Expand All @@ -148,7 +145,7 @@ export function withTestLbugDB(
const tmpHandle: TestDBHandle = { dbPath: tmpDir, cleanup: async () => {} };
ref.handle = { dbPath, repoId, tmpHandle, cleanup };

// 8. User's final setup (mocks, dynamic imports, etc.)
// 7. User's final setup (mocks, dynamic imports, etc.)
if (options?.afterSetup) {
await options.afterSetup(ref.handle);
}
Expand Down
14 changes: 14 additions & 0 deletions gitnexus/test/integration/lbug-core-adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ withTestLbugDB(
}
});

it('initLbug loads FTS so reopened HTTP-style sessions can query existing indexes', async () => {
const adapter = await import('../../src/core/lbug/lbug-adapter.js');
const indexName = 'function_fts_init_probe';

await adapter.createFTSIndex('Function', indexName, ['name', 'content']);
await adapter.closeLbug();

await adapter.initLbug(handle.dbPath);

await expect(adapter.queryFTS('Function', indexName, 'main', 5)).resolves.toEqual(
expect.arrayContaining([expect.objectContaining({ filePath: 'src/index.ts' })]),
);
});

it('getLbugStats: returns correct node and edge counts for seeded data', async () => {
const { getLbugStats } = await import('../../src/core/lbug/lbug-adapter.js');

Expand Down
7 changes: 6 additions & 1 deletion gitnexus/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default defineConfig({
name: 'lbug-db',
include: [
'test/integration/lbug-core-adapter.test.ts',
'test/integration/lbug-vector-extension.test.ts',
'test/integration/lbug-pool.test.ts',
'test/integration/lbug-pool-stability.test.ts',
'test/integration/local-backend.test.ts',
Expand All @@ -62,6 +63,8 @@ export default defineConfig({
'test/integration/lbug-lock-retry.test.ts',
'test/integration/api-impact-e2e.test.ts',
'test/integration/shape-check-regression.test.ts',
'test/integration/java-class-impact.test.ts',
'test/integration/class-impact-all-languages.test.ts',
],
fileParallelism: false,
sequence: { groupOrder: 1 },
Expand All @@ -75,6 +78,7 @@ export default defineConfig({
include: ['test/**/*.test.ts'],
exclude: [
'test/integration/lbug-core-adapter.test.ts',
'test/integration/lbug-vector-extension.test.ts',
'test/integration/lbug-pool.test.ts',
'test/integration/lbug-pool-stability.test.ts',
'test/integration/local-backend.test.ts',
Expand All @@ -84,9 +88,10 @@ export default defineConfig({
'test/integration/augmentation.test.ts',
'test/integration/staleness-and-stability.test.ts',
'test/integration/lbug-lock-retry.test.ts',
'test/integration/lbug-lock-retry.test.ts',
'test/integration/api-impact-e2e.test.ts',
'test/integration/shape-check-regression.test.ts',
'test/integration/java-class-impact.test.ts',
'test/integration/class-impact-all-languages.test.ts',
],
},
},
Expand Down
Loading