gitnexus 1.6.4-rc.29 → 1.6.4-rc.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -114,14 +114,14 @@ let currentDbPath = null;
114
114
  let ftsLoaded = false;
115
115
  let vectorExtensionLoaded = false;
116
116
  /**
117
- * In-process cache of FTS indexes that have been ensured against the current
118
- * writable connection. Prevents repeated `CALL CREATE_FTS_INDEX` round-trips
119
- * for callers that explicitly opt into `ensureFTSIndex`. Cleared by
120
- * `closeLbug` so a re-init starts fresh.
117
+ * In-process cache of FTS indexes observed against the current singleton
118
+ * connection. Avoids repeated `CALL CREATE_FTS_INDEX` calls, which can trip
119
+ * native duplicate-index/WAL edge cases. Cleared on re-init and close.
121
120
  *
122
121
  * Key format: `${tableName}:${indexName}`.
123
122
  */
124
123
  const ensuredFTSIndexes = new Set();
124
+ const ftsIndexKey = (tableName, indexName) => `${tableName}:${indexName}`;
125
125
  /**
126
126
  * Check if an error indicates a missing column or table (schema-level problem)
127
127
  * rather than a transient/connection error. Used for legacy DB fallback logic.
@@ -225,6 +225,7 @@ export const withLbugDb = async (dbPath, operation) => {
225
225
  currentDbPath = null;
226
226
  ftsLoaded = false;
227
227
  vectorExtensionLoaded = false;
228
+ ensuredFTSIndexes.clear();
228
229
  });
229
230
  // Sleep outside the lock — no need to block others while waiting
230
231
  await new Promise((resolve) => setTimeout(resolve, DB_LOCK_RETRY_DELAY_MS * attempt));
@@ -259,6 +260,7 @@ const doInitLbug = async (dbPath) => {
259
260
  currentDbPath = null;
260
261
  ftsLoaded = false;
261
262
  vectorExtensionLoaded = false;
263
+ ensuredFTSIndexes.clear();
262
264
  }
263
265
  // LadybugDB stores the database as a single file (not a directory).
264
266
  // If the path already exists, it must be a valid LadybugDB database file.
@@ -1070,6 +1072,9 @@ export const createFTSIndex = async (tableName, indexName, properties, stemmer =
1070
1072
  if (!conn) {
1071
1073
  throw new Error('LadybugDB not initialized. Call initLbug first.');
1072
1074
  }
1075
+ const key = ftsIndexKey(tableName, indexName);
1076
+ if (ensuredFTSIndexes.has(key))
1077
+ return;
1073
1078
  if (!(await loadFTSExtension())) {
1074
1079
  return;
1075
1080
  }
@@ -1077,11 +1082,14 @@ export const createFTSIndex = async (tableName, indexName, properties, stemmer =
1077
1082
  const query = `CALL CREATE_FTS_INDEX('${tableName}', '${indexName}', [${propList}], stemmer := '${stemmer}')`;
1078
1083
  try {
1079
1084
  await conn.query(query);
1085
+ ensuredFTSIndexes.add(key);
1080
1086
  }
1081
1087
  catch (e) {
1082
- if (!e.message?.includes('already exists')) {
1083
- throw e;
1088
+ if (e.message?.includes('already exists')) {
1089
+ ensuredFTSIndexes.add(key);
1090
+ return;
1084
1091
  }
1092
+ throw e;
1085
1093
  }
1086
1094
  };
1087
1095
  /**
@@ -1102,12 +1110,11 @@ export const createFTSIndex = async (tableName, indexName, properties, stemmer =
1102
1110
  * exists or will be created on the next analyze.
1103
1111
  */
1104
1112
  export const ensureFTSIndex = async (tableName, indexName, properties, stemmer = 'porter') => {
1105
- const key = `${tableName}:${indexName}`;
1113
+ const key = ftsIndexKey(tableName, indexName);
1106
1114
  if (ensuredFTSIndexes.has(key))
1107
1115
  return;
1108
1116
  try {
1109
1117
  await createFTSIndex(tableName, indexName, properties, stemmer);
1110
- ensuredFTSIndexes.add(key);
1111
1118
  }
1112
1119
  catch (e) {
1113
1120
  // Read-only DB: writable analyze owns index creation; silently skip
@@ -1178,4 +1185,7 @@ export const dropFTSIndex = async (tableName, indexName) => {
1178
1185
  catch {
1179
1186
  // Index may not exist
1180
1187
  }
1188
+ finally {
1189
+ ensuredFTSIndexes.delete(ftsIndexKey(tableName, indexName));
1190
+ }
1181
1191
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.4-rc.29",
3
+ "version": "1.6.4-rc.30",
4
4
  "description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
5
5
  "author": "Abhigyan Patwari",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",