gitnexus 1.6.13-rc.67 → 1.6.13-rc.68

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.
@@ -893,9 +893,10 @@ export declare const buildFtsQueryCypher: (tableName: string, indexName: string,
893
893
  * @param query - Search query string
894
894
  * @param limit - Maximum results
895
895
  * @param conjunctive - If true, all terms must match (AND); if false, any term matches (OR)
896
+ * @param missingIndex - Preserve the empty-result default, or propagate missing indexes for diagnostics
896
897
  * @returns Array of { node properties, score }
897
898
  */
898
- export declare const queryFTS: (tableName: string, indexName: string, query: string, limit?: number, conjunctive?: boolean) => Promise<Array<{
899
+ export declare const queryFTS: (tableName: string, indexName: string, query: string, limit?: number, conjunctive?: boolean, missingIndex?: 'empty' | 'throw') => Promise<Array<{
899
900
  nodeId: string;
900
901
  name: string;
901
902
  filePath: string;
@@ -3504,9 +3504,10 @@ export const buildFtsQueryCypher = (tableName, indexName, limit, conjunctive = f
3504
3504
  * @param query - Search query string
3505
3505
  * @param limit - Maximum results
3506
3506
  * @param conjunctive - If true, all terms must match (AND); if false, any term matches (OR)
3507
+ * @param missingIndex - Preserve the empty-result default, or propagate missing indexes for diagnostics
3507
3508
  * @returns Array of { node properties, score }
3508
3509
  */
3509
- export const queryFTS = async (tableName, indexName, query, limit = 20, conjunctive = false) => {
3510
+ export const queryFTS = async (tableName, indexName, query, limit = 20, conjunctive = false, missingIndex = 'empty') => {
3510
3511
  if (!conn) {
3511
3512
  throw new Error('LadybugDB not initialized. Call initLbug first.');
3512
3513
  }
@@ -3532,7 +3533,7 @@ export const queryFTS = async (tableName, indexName, query, limit = 20, conjunct
3532
3533
  // NEW-6 — this used to be a bare `.includes('does not exist')` check
3533
3534
  // that could not tell the two apart).
3534
3535
  const message = e instanceof Error ? e.message : String(e);
3535
- if (classifyFtsQueryError(message) === 'missing-index') {
3536
+ if (missingIndex === 'empty' && classifyFtsQueryError(message) === 'missing-index') {
3536
3537
  return [];
3537
3538
  }
3538
3539
  throw e;
@@ -29,6 +29,8 @@ export interface FTSSearchResponse {
29
29
  * which only does so when every table failed).
30
30
  */
31
31
  nonBenignErrors?: string[];
32
+ /** Configured table.index names that could not be queried because their index is missing. */
33
+ missingIndexes?: string[];
32
34
  }
33
35
  /**
34
36
  * Search using LadybugDB's built-in FTS (fresh, reads from disk)
@@ -86,6 +86,7 @@ export const searchFTSFromLbug = async (query, limit = 20, repoId, disabledReaso
86
86
  const resultsByIndex = [];
87
87
  let queriesSucceeded = 0;
88
88
  const nonBenignErrors = [];
89
+ const missingIndexes = [];
89
90
  const ftsExtension = getExtensionCapabilities().find((c) => c.name === 'fts');
90
91
  if (ftsExtension && !ftsExtension.loaded) {
91
92
  // tri-review NEW-4 (applies to BOTH the MCP pool path and the CLI/pipeline
@@ -114,26 +115,32 @@ export const searchFTSFromLbug = async (query, limit = 20, repoId, disabledReaso
114
115
  queriesSucceeded++;
115
116
  resultsByIndex.push(outcome.rows);
116
117
  }
117
- else if (!outcome.benign) {
118
+ else if (outcome.benign) {
119
+ missingIndexes.push(`${table}.${indexName}`);
120
+ }
121
+ else {
118
122
  nonBenignErrors.push(redactPaths(outcome.message ?? 'Unknown FTS query error'));
119
123
  }
120
124
  }
121
125
  }
122
126
  else {
123
127
  // Use core lbug adapter (CLI / pipeline context) — also sequential for safety.
124
- // tri-review Residual-1: `queryFTS` itself only swallows a genuinely-missing
125
- // index (via the SAME classifyFtsQueryError this module re-exports); a
126
- // missing-table or real query error rethrows here — track it the same way
127
- // the MCP pool path does instead of a bare `catch {}` that dropped it.
128
+ // Opt into missing-index propagation so absent indexes cannot masquerade
129
+ // as successful zero-match queries. Keep core/pool classification identical.
128
130
  for (const { table, indexName } of FTS_INDEXES) {
129
131
  try {
130
- const result = await queryFTS(table, indexName, searchQuery, limit, false);
132
+ const result = await queryFTS(table, indexName, searchQuery, limit, false, 'throw');
131
133
  queriesSucceeded++;
132
134
  resultsByIndex.push(result);
133
135
  }
134
136
  catch (e) {
135
137
  const message = e instanceof Error ? e.message : String(e);
136
- nonBenignErrors.push(redactPaths(message));
138
+ if (classifyFtsQueryError(message) === 'missing-index') {
139
+ missingIndexes.push(`${table}.${indexName}`);
140
+ }
141
+ else {
142
+ nonBenignErrors.push(redactPaths(message));
143
+ }
137
144
  }
138
145
  }
139
146
  }
@@ -174,5 +181,6 @@ export const searchFTSFromLbug = async (query, limit = 20, repoId, disabledReaso
174
181
  })),
175
182
  ftsAvailable,
176
183
  ...(nonBenignErrors.length > 0 && { nonBenignErrors }),
184
+ ...(missingIndexes.length > 0 && { missingIndexes }),
177
185
  };
178
186
  };
@@ -48,15 +48,12 @@ export interface FtsWarningContext {
48
48
  */
49
49
  export declare const ftsDegradedWarning: (context?: FtsWarningContext, disabledReason?: FtsDisabledReason) => string;
50
50
  /**
51
- * Warning for when the FTS extension is loaded and indexes exist, but every
52
- * configured table's query failed for a real, non-benign reason (timeout,
53
- * connection reset, native fault) — as opposed to `ftsDegradedWarning`'s
54
- * missing-index case. `--repair-fts` will not fix a query/connection error,
55
- * so this deliberately does NOT suggest it: reusing the missing-index
56
- * message here would reproduce, for this cause, the exact misleading
57
- * "run --repair-fts" guidance #2767 itself was about (tri-review NEW-1).
51
+ * Warning when no FTS query succeeded and at least one failed for a real,
52
+ * non-benign reason (timeout, connection reset, native fault). `--repair-fts`
53
+ * will not fix those errors. If indexes are also missing, the caller composes
54
+ * their repair guidance separately; do not deny that additional failure cause.
58
55
  */
59
- export declare const ftsQueryFailedWarning: (context: FtsWarningContext) => string;
56
+ export declare const ftsQueryFailedWarning: (context: FtsWarningContext, hasMissingIndexes?: boolean) => string;
60
57
  export declare const SUPPORTED_FTS_STEMMERS: ReadonlySet<string>;
61
58
  export interface CreateSearchFTSIndexesOptions {
62
59
  indexes?: readonly FTSIndexDefinition[];
@@ -72,18 +72,17 @@ export const ftsDegradedWarning = (context, disabledReason) => {
72
72
  suffix);
73
73
  };
74
74
  /**
75
- * Warning for when the FTS extension is loaded and indexes exist, but every
76
- * configured table's query failed for a real, non-benign reason (timeout,
77
- * connection reset, native fault) — as opposed to `ftsDegradedWarning`'s
78
- * missing-index case. `--repair-fts` will not fix a query/connection error,
79
- * so this deliberately does NOT suggest it: reusing the missing-index
80
- * message here would reproduce, for this cause, the exact misleading
81
- * "run --repair-fts" guidance #2767 itself was about (tri-review NEW-1).
75
+ * Warning when no FTS query succeeded and at least one failed for a real,
76
+ * non-benign reason (timeout, connection reset, native fault). `--repair-fts`
77
+ * will not fix those errors. If indexes are also missing, the caller composes
78
+ * their repair guidance separately; do not deny that additional failure cause.
82
79
  */
83
- export const ftsQueryFailedWarning = (context) => 'FTS keyword search failed — every configured index query returned an error' +
80
+ export const ftsQueryFailedWarning = (context, hasMissingIndexes = false) => 'FTS keyword search failed — every configured index query returned an error' +
84
81
  (context.lastErrorRedacted ? ` (${context.lastErrorRedacted})` : '') +
85
- '; results do not include keyword matches. This is not a missing-index ' +
86
- 'condition — see server logs for details.' +
82
+ '; results do not include keyword matches. ' +
83
+ (hasMissingIndexes
84
+ ? 'See server logs for query error details.'
85
+ : 'This is not a missing-index condition — see server logs for details.') +
87
86
  ` (resolved: ${formatResolvedSuffix(context)})`;
88
87
  // Stemmers shipped by the LadybugDB FTS extension. Mirrors the lowercase token
89
88
  // set in the extension bundled with @ladybugdb/core 0.18.x (see package.json).
@@ -2413,6 +2413,7 @@ export class LocalBackend {
2413
2413
  // regardless of whether OTHER tables succeeded — previously a real error
2414
2414
  // on N-1 of N tables while one succeeded left zero diagnostic trail.
2415
2415
  const ftsQueryErrors = bm25SearchResult?.nonBenignErrors;
2416
+ const ftsMissingIndexes = bm25SearchResult?.missingIndexes;
2416
2417
  if (ftsQueryErrors) {
2417
2418
  // tri-review NEW-5: these strings are already classified non-benign by
2418
2419
  // classifyFtsQueryError — do NOT route them through logQueryError,
@@ -2847,12 +2848,11 @@ export class LocalBackend {
2847
2848
  branch: repo.branch,
2848
2849
  indexedAt: this.lastObservedPoolState.get(repo.lbugPath)?.indexedAt ?? repo.indexedAt,
2849
2850
  };
2850
- // tri-review NEW-1: every table failing for a REAL error (timeout,
2851
- // connection reset) is not a missing-index condition — `ftsDegradedWarning`'s
2852
- // "run --repair-fts" headline won't fix it. Route to a dedicated message
2853
- // instead of burying the real cause as a trailing suffix on bad advice.
2851
+ // Real errors (timeout, connection reset) need their own diagnosis.
2852
+ // When some indexes are also missing, preserve both causes and append
2853
+ // their repair guidance below even though no FTS query succeeded.
2854
2854
  warnings.push(ftsQueryErrors
2855
- ? ftsQueryFailedWarning({ ...warningContext, lastErrorRedacted: ftsQueryErrors[0] })
2855
+ ? ftsQueryFailedWarning({ ...warningContext, lastErrorRedacted: ftsQueryErrors[0] }, !!ftsMissingIndexes?.length)
2856
2856
  : ftsDegradedWarning(warningContext, ftsDisabledReason));
2857
2857
  }
2858
2858
  else if (ftsQueryErrors) {
@@ -2863,6 +2863,10 @@ export class LocalBackend {
2863
2863
  // that convention instead of only logging server-side.
2864
2864
  warnings.push(`FTS keyword search partially failed — ${ftsQueryErrors.length} of the configured indexes hit a query error and were skipped; results may be missing matches from those node types (see server logs).`);
2865
2865
  }
2866
+ if (ftsMissingIndexes?.length && (ftsUsed || ftsQueryErrors)) {
2867
+ warnings.push(`FTS keyword search is incomplete: missing configured indexes (${ftsMissingIndexes.join(', ')}). ` +
2868
+ 'Results may be missing matches from those node types. Run `gitnexus analyze --repair-fts`.');
2869
+ }
2866
2870
  // #2331: a CJK query against a server process resolving
2867
2871
  // GITNEXUS_FTS_CJK_SEGMENTATION to 'none' silently misses sub-phrase
2868
2872
  // matches with no other signal — this is the only place an agent driving
@@ -2979,7 +2983,7 @@ export class LocalBackend {
2979
2983
  // #2767: a partial FTS failure (some tables ok, one or more real errors)
2980
2984
  // is as much a "results may be incomplete" signal as enrichmentDegraded —
2981
2985
  // flag it the same way rather than only via the warning string.
2982
- const ftsPartial = ftsUsed && !!ftsQueryErrors;
2986
+ const ftsPartial = ftsUsed && (!!ftsQueryErrors || !!ftsMissingIndexes?.length);
2983
2987
  return {
2984
2988
  processes,
2985
2989
  process_symbols,
@@ -3023,6 +3027,7 @@ export class LocalBackend {
3023
3027
  const bm25Results = ftsResponse?.results ?? [];
3024
3028
  const ftsUsed = ftsResponse?.ftsAvailable ?? false;
3025
3029
  const nonBenignErrors = ftsResponse?.nonBenignErrors;
3030
+ const missingIndexes = ftsResponse?.missingIndexes;
3026
3031
  const results = [];
3027
3032
  for (const bm25Result of bm25Results) {
3028
3033
  const fullPath = bm25Result.filePath;
@@ -3087,7 +3092,12 @@ export class LocalBackend {
3087
3092
  });
3088
3093
  }
3089
3094
  }
3090
- return { results, ftsUsed, ...(nonBenignErrors && { nonBenignErrors }) };
3095
+ return {
3096
+ results,
3097
+ ftsUsed,
3098
+ ...(nonBenignErrors && { nonBenignErrors }),
3099
+ ...(missingIndexes && { missingIndexes }),
3100
+ };
3091
3101
  }
3092
3102
  /**
3093
3103
  * Keyword-only indexes are the default. Do not put this on `query.warning`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.13-rc.67",
3
+ "version": "1.6.13-rc.68",
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",