@mmnto/mcp 1.13.0 → 1.14.0
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.
- package/dist/context.d.ts +58 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +220 -6
- package/dist/context.js.map +1 -1
- package/dist/context.test.js +108 -2
- package/dist/context.test.js.map +1 -1
- package/dist/smoke-test.d.ts +2 -0
- package/dist/smoke-test.d.ts.map +1 -0
- package/dist/smoke-test.js +196 -0
- package/dist/smoke-test.js.map +1 -0
- package/dist/tools/search-knowledge.d.ts +6 -0
- package/dist/tools/search-knowledge.d.ts.map +1 -1
- package/dist/tools/search-knowledge.js +493 -40
- package/dist/tools/search-knowledge.js.map +1 -1
- package/dist/tools/search-knowledge.test.js +901 -56
- package/dist/tools/search-knowledge.test.js.map +1 -1
- package/package.json +2 -2
|
@@ -4,9 +4,79 @@ import { ContentTypeSchema } from '@mmnto/totem';
|
|
|
4
4
|
import { getContext, reconnectStore } from '../context.js';
|
|
5
5
|
import { logSearch, setLogDir } from '../search-log.js';
|
|
6
6
|
import { formatSystemWarning, formatXmlResponse } from '../xml-format.js';
|
|
7
|
+
function makeFailureLog() {
|
|
8
|
+
return { primary: null, linked: new Map() };
|
|
9
|
+
}
|
|
10
|
+
function failureLogIsEmpty(log) {
|
|
11
|
+
return log.primary === null && log.linked.size === 0;
|
|
12
|
+
}
|
|
7
13
|
const MAX_SEARCH_RESULTS = 100;
|
|
8
14
|
/** Session-level flag — healthCheck runs only on the first search call. */
|
|
9
15
|
let firstHealthCheckDone = false;
|
|
16
|
+
/** Session-level flag — linkedStoreInitErrors surface only on the first search call. */
|
|
17
|
+
let firstLinkedStoresCheckDone = false;
|
|
18
|
+
/**
|
|
19
|
+
* Reset both session flags. Test-only export — production code should never
|
|
20
|
+
* call this. Allows test suites to exercise the first-query behaviors
|
|
21
|
+
* repeatedly across individual test cases.
|
|
22
|
+
*/
|
|
23
|
+
export function _resetSessionFlags() {
|
|
24
|
+
firstHealthCheckDone = false;
|
|
25
|
+
firstLinkedStoresCheckDone = false;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Run a one-time check on linked-store initialization errors (mmnto/totem#1294
|
|
29
|
+
* Phase 2). Returns a formatted system warning listing every linked index
|
|
30
|
+
* that failed to initialize, or null when none failed / after the first call.
|
|
31
|
+
*
|
|
32
|
+
* This is INTENTIONALLY non-blocking — unlike `runFirstQueryHealthCheck`,
|
|
33
|
+
* which treats a dimension mismatch as fatal, linked-store failures are
|
|
34
|
+
* always recoverable by degrading to primary-only search. The warning is
|
|
35
|
+
* surfaced so the agent sees it in-context, but the server continues to
|
|
36
|
+
* serve every subsequent search from whatever stores did initialize.
|
|
37
|
+
*/
|
|
38
|
+
async function runFirstLinkedStoresCheck() {
|
|
39
|
+
if (firstLinkedStoresCheckDone)
|
|
40
|
+
return null;
|
|
41
|
+
try {
|
|
42
|
+
const { linkedStoreInitErrors } = await getContext();
|
|
43
|
+
// mmnto/totem#1295 CR minor: only consume the one-shot flag AFTER
|
|
44
|
+
// getContext resolves successfully. Setting it before the await meant
|
|
45
|
+
// a transient init failure on the first call would permanently
|
|
46
|
+
// suppress the startup warning for the rest of the session.
|
|
47
|
+
firstLinkedStoresCheckDone = true;
|
|
48
|
+
if (linkedStoreInitErrors.size === 0)
|
|
49
|
+
return null;
|
|
50
|
+
// mmnto/totem#1295 CR minor: `linkedStoreInitErrors` now holds BOTH
|
|
51
|
+
// fatal init failures AND non-fatal startup warnings (e.g., empty
|
|
52
|
+
// linked stores, name collisions where the first link still loaded).
|
|
53
|
+
// Use neutral wording so the summary line accurately covers both.
|
|
54
|
+
const lines = [
|
|
55
|
+
`Cross-Repo Context Mesh: ${linkedStoreInitErrors.size} linked index startup issue(s).`,
|
|
56
|
+
'',
|
|
57
|
+
'Federated search will proceed using only the stores that initialized successfully. Review the issues below so cross-repo queries return complete context. (mmnto/totem#1294)',
|
|
58
|
+
'',
|
|
59
|
+
];
|
|
60
|
+
for (const [name, err] of linkedStoreInitErrors.entries()) {
|
|
61
|
+
lines.push(` - ${name}: ${err}`);
|
|
62
|
+
}
|
|
63
|
+
return formatSystemWarning(lines.join('\n'));
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
// Meta-failure: getContext() itself threw. Log and return null — the
|
|
67
|
+
// outer runFirstQueryHealthCheck will surface that failure via its own
|
|
68
|
+
// path, so there's no value in double-reporting here.
|
|
69
|
+
logSearch({
|
|
70
|
+
timestamp: new Date().toISOString(),
|
|
71
|
+
query: 'internal:linked-stores-check',
|
|
72
|
+
resultCount: 0,
|
|
73
|
+
durationMs: 0,
|
|
74
|
+
topScore: null,
|
|
75
|
+
error: `Linked stores check failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
76
|
+
});
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
10
80
|
/**
|
|
11
81
|
* Run a one-time health check on the LanceDB index and return any warnings.
|
|
12
82
|
* Returns null when healthy or after the first call (cached).
|
|
@@ -14,13 +84,24 @@ let firstHealthCheckDone = false;
|
|
|
14
84
|
async function runFirstQueryHealthCheck() {
|
|
15
85
|
if (firstHealthCheckDone)
|
|
16
86
|
return null;
|
|
17
|
-
firstHealthCheckDone = true;
|
|
18
87
|
try {
|
|
19
88
|
const { store } = await getContext();
|
|
20
89
|
const result = await store.healthCheck();
|
|
21
|
-
|
|
90
|
+
// Healthy — consume the one-shot flag and skip the warning for this
|
|
91
|
+
// session. This is the common case.
|
|
92
|
+
if (result.healthy) {
|
|
93
|
+
firstHealthCheckDone = true;
|
|
22
94
|
return null;
|
|
23
|
-
|
|
95
|
+
}
|
|
96
|
+
// mmnto/totem#1295 CR MAJOR: dimension mismatch must KEEP firing on
|
|
97
|
+
// every query until the user actually fixes the index. Consuming the
|
|
98
|
+
// flag here would let query 2 onwards skip the gate and fall back to
|
|
99
|
+
// the cryptic LanceDB "vector dimension mismatch" error — exactly
|
|
100
|
+
// what the friendly diagnostic exists to prevent. The outer
|
|
101
|
+
// `registerSearchKnowledge` blocks the search with isError: true
|
|
102
|
+
// whenever this branch returns a warning, so a persistent mismatch
|
|
103
|
+
// produces a persistent actionable message rather than a one-shot
|
|
104
|
+
// reminder followed by silent cryptic failures.
|
|
24
105
|
if (!result.dimensionMatch && result.storedDimensions !== null) {
|
|
25
106
|
const lines = [
|
|
26
107
|
`DIMENSION MISMATCH: Index has ${result.storedDimensions}-dim vectors but the configured embedder produces ${result.expectedDimensions}-dim vectors.`,
|
|
@@ -32,7 +113,10 @@ async function runFirstQueryHealthCheck() {
|
|
|
32
113
|
];
|
|
33
114
|
return formatSystemWarning(lines.join('\n'));
|
|
34
115
|
}
|
|
35
|
-
//
|
|
116
|
+
// Non-fatal health warnings (stale rows, missing partitions, etc.):
|
|
117
|
+
// search still returns results — the warning is informational, not
|
|
118
|
+
// blocking — so one-shot consumption is appropriate here.
|
|
119
|
+
firstHealthCheckDone = true;
|
|
36
120
|
const lines = ['Index health issues detected:'];
|
|
37
121
|
for (const issue of result.issues) {
|
|
38
122
|
lines.push(`- ${issue}`);
|
|
@@ -54,31 +138,360 @@ async function runFirstQueryHealthCheck() {
|
|
|
54
138
|
return null;
|
|
55
139
|
}
|
|
56
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Format a single search result for display. Linked-store results (sourceRepo
|
|
143
|
+
* set) get a `[<sourceRepo>]` prefix on the label and the absolute path as
|
|
144
|
+
* the File field, so the agent can route file-reading tools without having
|
|
145
|
+
* to reason about which repo owns the result. Primary results (sourceRepo
|
|
146
|
+
* undefined) use the compact relative-path form for readability.
|
|
147
|
+
*
|
|
148
|
+
* mmnto/totem#1294 Phase 2.
|
|
149
|
+
*/
|
|
150
|
+
function formatResult(r, index) {
|
|
151
|
+
// Build the header line in two halves so the `[tag] label` segment is
|
|
152
|
+
// joined with explicit `+` rather than two adjacent template placeholders
|
|
153
|
+
// (which the concat-without-delimiter lint rule flags).
|
|
154
|
+
const labelWithTag = r.sourceRepo ? `[${r.sourceRepo}] ` + r.label : r.label;
|
|
155
|
+
// mmnto/totem#1295 CR MAJOR: ALWAYS display the absolute path. The whole
|
|
156
|
+
// point of `absoluteFilePath` on `SearchResult` is to give agents an
|
|
157
|
+
// unambiguous Read/Edit target. Falling back to the relative `filePath`
|
|
158
|
+
// for primary hits reintroduced repo-root ambiguity in the common case —
|
|
159
|
+
// exactly the bug that field was added to fix.
|
|
160
|
+
return (`### ${index + 1}. ${labelWithTag} (${r.type})\n` +
|
|
161
|
+
`**File:** ${r.absoluteFilePath} | **Score:** ${r.score.toFixed(3)}\n\n` +
|
|
162
|
+
r.content);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Run federated search across primary + all linked stores in parallel.
|
|
166
|
+
* Each store fetches up to `perStoreLimit` results; the combined pool is
|
|
167
|
+
* then re-sorted by score and truncated to `finalLimit`.
|
|
168
|
+
*
|
|
169
|
+
* Mirrors the semantic-merge pattern established in
|
|
170
|
+
* `packages/cli/src/commands/spec.ts:retrieveContext` — fetch per-store
|
|
171
|
+
* budgets, concat, re-rank by score, truncate.
|
|
172
|
+
*
|
|
173
|
+
* **Runtime failure handling (mmnto/totem#1295 rewrite):** On a linked-
|
|
174
|
+
* store search error, attempt a targeted `reconnect()` + retry. If the
|
|
175
|
+
* retry succeeds, return the fresh results. If it fails, record the
|
|
176
|
+
* failure into the caller-provided `failures` log and return empty for
|
|
177
|
+
* that store on THIS query only. Primary failures go in `failures.primary`
|
|
178
|
+
* (a dedicated slot — `'primary'` would collide with a legal link name);
|
|
179
|
+
* linked failures go in `failures.linked` keyed by link name.
|
|
180
|
+
*
|
|
181
|
+
* This function DOES NOT mutate the global `linkedStores` or
|
|
182
|
+
* `linkedStoreInitErrors` maps — an earlier revision evicted failing
|
|
183
|
+
* stores to avoid log spam, but GCA + CR both flagged that as a Tenet 4
|
|
184
|
+
* violation: transient errors (file locks during parallel sync, network
|
|
185
|
+
* blips) caused permanent context loss until server restart. The correct
|
|
186
|
+
* tradeoff is to accept some log spam for resilience, and surface
|
|
187
|
+
* runtime failures via the per-request warning path (see `performSearch`).
|
|
188
|
+
*
|
|
189
|
+
* mmnto/totem#1294 Phase 2 + mmnto/totem#1295 fix.
|
|
190
|
+
*/
|
|
191
|
+
async function federatedSearch(query, typeFilter, perStoreLimit, finalLimit, failures) {
|
|
192
|
+
const { store: primaryStore, linkedStores } = await getContext();
|
|
193
|
+
// mmnto/totem#1295 GCA HIGH: catch primary failures inside federatedSearch
|
|
194
|
+
// ONLY when linked stores exist, so a transient primary failure doesn't
|
|
195
|
+
// kill linked-store results. For non-mesh users (no linked stores), let
|
|
196
|
+
// primary failures bubble to the outer reconnect+retry in
|
|
197
|
+
// `registerSearchKnowledge` — that path produces a hard error which is
|
|
198
|
+
// strictly more useful than "empty results + warning" when primary is
|
|
199
|
+
// the only target. The outer path also still handles raw-prefix cases
|
|
200
|
+
// (Cases 1, 4) where primary is the only target regardless of mesh state.
|
|
201
|
+
//
|
|
202
|
+
// When the inner catch fires, primary uses the SAME targeted reconnect+
|
|
203
|
+
// retry pattern as linked stores below: catch → reconnect → retry → on
|
|
204
|
+
// second failure, log and record into `failures.primary`. Promise.all
|
|
205
|
+
// never rejects from the primary slot.
|
|
206
|
+
const hasLinkedStores = linkedStores.size > 0;
|
|
207
|
+
const primaryPromise = hasLinkedStores
|
|
208
|
+
? primaryStore
|
|
209
|
+
.search({ query, typeFilter, maxResults: perStoreLimit })
|
|
210
|
+
.catch(async (err) => {
|
|
211
|
+
const firstMsg = err instanceof Error ? err.message : String(err);
|
|
212
|
+
try {
|
|
213
|
+
await primaryStore.reconnect();
|
|
214
|
+
return await primaryStore.search({ query, typeFilter, maxResults: perStoreLimit });
|
|
215
|
+
}
|
|
216
|
+
catch (retryErr) {
|
|
217
|
+
const retryMsg = retryErr instanceof Error ? retryErr.message : String(retryErr);
|
|
218
|
+
const combinedMsg = `search failed (initial: ${firstMsg}; reconnect+retry: ${retryMsg})`;
|
|
219
|
+
logSearch({
|
|
220
|
+
timestamp: new Date().toISOString(),
|
|
221
|
+
query: 'internal:primary-store-search',
|
|
222
|
+
resultCount: 0,
|
|
223
|
+
durationMs: 0,
|
|
224
|
+
topScore: null,
|
|
225
|
+
error: `Primary store ${combinedMsg}`,
|
|
226
|
+
});
|
|
227
|
+
failures.primary = combinedMsg;
|
|
228
|
+
return [];
|
|
229
|
+
}
|
|
230
|
+
})
|
|
231
|
+
: primaryStore.search({ query, typeFilter, maxResults: perStoreLimit });
|
|
232
|
+
// Linked stores: catch per-store failures so one broken linked index
|
|
233
|
+
// doesn't break the overall query. On failure, attempt targeted
|
|
234
|
+
// reconnect + retry, then return empty for this query (populating
|
|
235
|
+
// `failures.linked` for the caller to surface). Global state is NEVER
|
|
236
|
+
// mutated here — the store stays in `linkedStores` so the next query
|
|
237
|
+
// can try again (the transient issue may have cleared).
|
|
238
|
+
const linkedPromises = Array.from(linkedStores.entries()).map(([name, ls]) => ls.search({ query, typeFilter, maxResults: perStoreLimit }).catch(async (err) => {
|
|
239
|
+
const firstMsg = err instanceof Error ? err.message : String(err);
|
|
240
|
+
try {
|
|
241
|
+
await ls.reconnect();
|
|
242
|
+
return await ls.search({ query, typeFilter, maxResults: perStoreLimit });
|
|
243
|
+
}
|
|
244
|
+
catch (retryErr) {
|
|
245
|
+
const retryMsg = retryErr instanceof Error ? retryErr.message : String(retryErr);
|
|
246
|
+
const combinedMsg = `search failed (initial: ${firstMsg}; reconnect+retry: ${retryMsg})`;
|
|
247
|
+
logSearch({
|
|
248
|
+
timestamp: new Date().toISOString(),
|
|
249
|
+
query: `internal:linked-store-search:${name}`,
|
|
250
|
+
resultCount: 0,
|
|
251
|
+
durationMs: 0,
|
|
252
|
+
topScore: null,
|
|
253
|
+
error: `Linked store "${name}" ${combinedMsg}`,
|
|
254
|
+
});
|
|
255
|
+
failures.linked.set(name, combinedMsg);
|
|
256
|
+
return [];
|
|
257
|
+
}
|
|
258
|
+
}));
|
|
259
|
+
const [primaryResults, ...linkedResults] = await Promise.all([primaryPromise, ...linkedPromises]);
|
|
260
|
+
const buckets = [primaryResults, ...linkedResults];
|
|
261
|
+
// Single-bucket fast path (no linked stores configured): scores are
|
|
262
|
+
// already comparable since they all come from one store. Skip RRF
|
|
263
|
+
// normalization to keep the original scores visible to the agent.
|
|
264
|
+
if (buckets.length === 1) {
|
|
265
|
+
return primaryResults.slice(0, finalLimit);
|
|
266
|
+
}
|
|
267
|
+
// mmnto/totem#1295 GCA CRITICAL: re-rank via Reciprocal Rank Fusion
|
|
268
|
+
// across stores. `LanceStore.search` returns scores in incompatible
|
|
269
|
+
// scales depending on the search method:
|
|
270
|
+
//
|
|
271
|
+
// - Hybrid (default): RRF scores ~0.01–0.04
|
|
272
|
+
// - Vector-only (no FTS): 1/(1+distance) ~0.5–0.95
|
|
273
|
+
// - FTS-only: raw _score, often > 1
|
|
274
|
+
//
|
|
275
|
+
// Sorting by raw scores would bias the merge toward whichever store
|
|
276
|
+
// happens to use the larger-scale scoring method. RRF fixes this: each
|
|
277
|
+
// store's results are treated as a ranked list and a new score is
|
|
278
|
+
// assigned based on rank-within-store. The visible `score` field is
|
|
279
|
+
// OVERWRITTEN with the RRF score so the displayed order matches the
|
|
280
|
+
// displayed score (avoids the "ranked first but lower number" UX
|
|
281
|
+
// confusion). Within-store relative ordering is preserved.
|
|
282
|
+
//
|
|
283
|
+
// RRF k=60 matches the constant used inside `LanceStore.rrfMerge` for
|
|
284
|
+
// intra-store hybrid fusion, for consistency.
|
|
285
|
+
const RRF_K_FEDERATION = 60;
|
|
286
|
+
const reranked = [];
|
|
287
|
+
for (const bucket of buckets) {
|
|
288
|
+
bucket.forEach((r, rank) => {
|
|
289
|
+
reranked.push({ ...r, score: 1 / (RRF_K_FEDERATION + rank + 1) });
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
reranked.sort((a, b) => (b.score ?? 0) - (a.score ?? 0));
|
|
293
|
+
return reranked.slice(0, finalLimit);
|
|
294
|
+
}
|
|
57
295
|
async function performSearch(query, typeFilter, maxResults, boundary) {
|
|
58
|
-
const {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
296
|
+
const { config, linkedStores, linkedStoreInitErrors } = await getContext();
|
|
297
|
+
const finalLimit = maxResults ?? 5;
|
|
298
|
+
// Per-query runtime failure log (mmnto/totem#1295). Populated by
|
|
299
|
+
// `federatedSearch` when primary or any linked store errors during this
|
|
300
|
+
// specific query. Surfaced as a compact system warning on the response
|
|
301
|
+
// so the agent sees the failure in-context — NOT gated by any session-
|
|
302
|
+
// level "already warned" flag. Every query where a store fails produces
|
|
303
|
+
// its own warning; this is the correct Tenet 4 tradeoff versus the
|
|
304
|
+
// earlier one-shot snapshot approach.
|
|
305
|
+
//
|
|
306
|
+
// Primary lives in `failures.primary` (a dedicated slot, NOT keyed under
|
|
307
|
+
// `'primary'` in a map) because `'primary'` is a legal link name —
|
|
308
|
+
// `deriveLinkName` strips leading dots so a `.primary/` linked repo would
|
|
309
|
+
// collide with a reserved key. CR MAJOR catch on round 7.
|
|
310
|
+
const failures = makeFailureLog();
|
|
311
|
+
// ─── Boundary resolution (mmnto/totem#1294 Phase 2) ──
|
|
312
|
+
//
|
|
313
|
+
// Order of precedence:
|
|
314
|
+
// 1. Local partition name (config.partitions[boundary]) → primary only, prefix filter
|
|
315
|
+
// 2. Linked store name (linkedStores has key === boundary) → route ONLY to that linked store
|
|
316
|
+
// 3. Broken linked store name (linkedStoreInitErrors has key === boundary) → explicit error
|
|
317
|
+
// 4. Raw prefix string → primary only, prefix filter (today's fallback)
|
|
318
|
+
// 5. Undefined → federated across primary + ALL linked stores
|
|
319
|
+
//
|
|
320
|
+
// Partition names win over linked-store names on collision. Users who
|
|
321
|
+
// want to query a linked store whose name collides with a local
|
|
322
|
+
// partition can rename the linked directory.
|
|
323
|
+
//
|
|
324
|
+
// Case 3 exists to prevent a silent-fallback drift bug (Tenet 4): if a
|
|
325
|
+
// linked store previously existed but failed to reconnect, falling
|
|
326
|
+
// through to the raw-prefix branch would query the primary store using
|
|
327
|
+
// the broken link's name as a path prefix and return unrelated primary
|
|
328
|
+
// hits. The agent would think it's querying the linked repo but get
|
|
329
|
+
// local results — exactly the "silent drift" pattern Tenet 4 forbids.
|
|
330
|
+
// Shield AI catch on mmnto/totem#1294 Phase 2 review.
|
|
331
|
+
let results;
|
|
332
|
+
if (boundary !== undefined && config.partitions?.[boundary]) {
|
|
333
|
+
// Case 1: local partition — primary only, prefix filter
|
|
334
|
+
const { store: primaryStore } = await getContext();
|
|
335
|
+
results = await primaryStore.search({
|
|
336
|
+
query,
|
|
337
|
+
typeFilter,
|
|
338
|
+
maxResults: finalLimit,
|
|
339
|
+
boundary: config.partitions[boundary],
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
else if (boundary !== undefined && linkedStores.has(boundary)) {
|
|
343
|
+
// Case 2: linked store name — route ONLY to that linked store.
|
|
344
|
+
//
|
|
345
|
+
// Complete failure of an explicitly-targeted linked store (initial
|
|
346
|
+
// search throws AND reconnect+retry also throws) returns isError: true
|
|
347
|
+
// for symmetry with Case 3 (mmnto/totem#1295 GCA HIGH). When the
|
|
348
|
+
// user explicitly names a boundary, "no results" and "the boundary
|
|
349
|
+
// is broken" are very different signals — falling through to a
|
|
350
|
+
// generic "no results" response would let the agent misinterpret a
|
|
351
|
+
// real outage as an absence of relevant knowledge.
|
|
352
|
+
const linked = linkedStores.get(boundary);
|
|
353
|
+
try {
|
|
354
|
+
results = await linked.search({ query, typeFilter, maxResults: finalLimit });
|
|
355
|
+
}
|
|
356
|
+
catch (err) {
|
|
357
|
+
const firstMsg = err instanceof Error ? err.message : String(err);
|
|
358
|
+
try {
|
|
359
|
+
await linked.reconnect();
|
|
360
|
+
results = await linked.search({ query, typeFilter, maxResults: finalLimit });
|
|
361
|
+
}
|
|
362
|
+
catch (retryErr) {
|
|
363
|
+
const retryMsg = retryErr instanceof Error ? retryErr.message : String(retryErr);
|
|
364
|
+
const errorText = formatSystemWarning([
|
|
365
|
+
`Linked-store search: targeted index "${boundary}" failed.`,
|
|
366
|
+
'',
|
|
367
|
+
` Initial error: ${firstMsg}`,
|
|
368
|
+
` Reconnect+retry error: ${retryMsg}`,
|
|
369
|
+
'',
|
|
370
|
+
`Cross-repo search for this boundary cannot proceed on this query. The store may recover on a subsequent call if the failure was transient (stale handle, file lock). mmnto/totem#1294.`,
|
|
371
|
+
].join('\n'));
|
|
372
|
+
return {
|
|
373
|
+
content: [{ type: 'text', text: errorText }], // totem-ignore #1294 — system-generated + XML-wrapped
|
|
374
|
+
isError: true,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
else if (boundary !== undefined && linkedStoreInitErrors.has(boundary)) {
|
|
380
|
+
// Case 3: explicitly-named linked store is in the failure map. Surface
|
|
381
|
+
// the specific error rather than silently degrading to raw-prefix
|
|
382
|
+
// search on the primary (which would return bogus hits from the
|
|
383
|
+
// primary repo under the link's name as a prefix).
|
|
384
|
+
const errMsg = linkedStoreInitErrors.get(boundary);
|
|
385
|
+
const warning = formatSystemWarning([
|
|
386
|
+
`Linked index "${boundary}" is not available: ${errMsg ?? 'unknown error'}`,
|
|
387
|
+
'',
|
|
388
|
+
`Cross-repo search for this boundary cannot proceed. Fix the linked index and restart the MCP server (mmnto/totem#1294).`,
|
|
389
|
+
].join('\n'));
|
|
70
390
|
return {
|
|
71
|
-
content: [
|
|
72
|
-
|
|
73
|
-
],
|
|
391
|
+
content: [{ type: 'text', text: warning }], // totem-ignore #1294 — system-generated + XML-wrapped
|
|
392
|
+
isError: true,
|
|
74
393
|
};
|
|
75
394
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
395
|
+
else if (boundary !== undefined) {
|
|
396
|
+
// Case 4: raw prefix — primary only, prefix filter (today's behavior)
|
|
397
|
+
const { store: primaryStore } = await getContext();
|
|
398
|
+
results = await primaryStore.search({
|
|
399
|
+
query,
|
|
400
|
+
typeFilter,
|
|
401
|
+
maxResults: finalLimit,
|
|
402
|
+
boundary,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
// Case 5: no boundary → federated search across primary + all linked.
|
|
407
|
+
// Pass the `failures` log so the federation path can populate it on
|
|
408
|
+
// store errors without mutating global state. Primary lives in a
|
|
409
|
+
// dedicated slot to avoid colliding with linked-store names.
|
|
410
|
+
results = await federatedSearch(query, typeFilter, finalLimit, finalLimit, failures);
|
|
411
|
+
}
|
|
412
|
+
// Build the runtime-failures warning (if any) once so we can decide
|
|
413
|
+
// whether to skip the "no results" early return for warn-only cases.
|
|
414
|
+
//
|
|
415
|
+
// Only Case 5 (federated) reaches this with `failures` populated:
|
|
416
|
+
// Cases 1/4 bubble primary failures up, Case 2 returns isError early
|
|
417
|
+
// on full linked failure (mmnto/totem#1295 GCA HIGH), Case 3 returns
|
|
418
|
+
// isError immediately. So the IIFE only ever runs in the federated case.
|
|
419
|
+
//
|
|
420
|
+
// Copy branches three ways based on which store(s) failed (mmnto/totem
|
|
421
|
+
// #1295 CR fixes — accurate reporting + no `'primary'` map-key collision).
|
|
422
|
+
const runtimeWarning = (() => {
|
|
423
|
+
if (failureLogIsEmpty(failures))
|
|
424
|
+
return null;
|
|
425
|
+
const detailLines = [];
|
|
426
|
+
if (failures.primary !== null) {
|
|
427
|
+
detailLines.push(` - primary: ${failures.primary}`);
|
|
428
|
+
}
|
|
429
|
+
for (const [name, err] of failures.linked.entries()) {
|
|
430
|
+
detailLines.push(` - ${name}: ${err}`);
|
|
431
|
+
}
|
|
432
|
+
const recoveryNote = 'The store(s) above may recover on a subsequent call if the failure was transient (stale handle, file lock). mmnto/totem#1294.';
|
|
433
|
+
const primaryFailed = failures.primary !== null;
|
|
434
|
+
const linkedFailureCount = failures.linked.size;
|
|
435
|
+
let summary;
|
|
436
|
+
if (primaryFailed && linkedFailureCount > 0) {
|
|
437
|
+
summary = `Federated search: primary store and ${linkedFailureCount} linked index(es) failed on this query.`;
|
|
438
|
+
}
|
|
439
|
+
else if (primaryFailed) {
|
|
440
|
+
summary = `Federated search: primary store failed on this query. Linked stores returned their results normally.`;
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
summary = `Federated search: ${linkedFailureCount} linked index(es) failed on this query. Other stores returned their results normally.`;
|
|
444
|
+
}
|
|
445
|
+
return formatSystemWarning([summary, '', ...detailLines, '', recoveryNote].join('\n'));
|
|
446
|
+
})();
|
|
447
|
+
// mmnto/totem#1295 CR MAJOR: detect the "entire federation is down" case
|
|
448
|
+
// and return isError instead of a success-shaped "No results found" body.
|
|
449
|
+
//
|
|
450
|
+
// When `boundary === undefined` (federated Case 5), every store we TRIED
|
|
451
|
+
// to query failed, and results came back empty, the agent must see this
|
|
452
|
+
// as an outage — not as "no relevant knowledge found." Otherwise it
|
|
453
|
+
// concludes there's nothing in the index when the entire search plane
|
|
454
|
+
// is actually broken.
|
|
455
|
+
//
|
|
456
|
+
// The condition is narrow on purpose:
|
|
457
|
+
// - `boundary === undefined`: only the federated case (targeted Cases
|
|
458
|
+
// 2 & 3 have their own isError paths; Cases 1 & 4 bubble primary
|
|
459
|
+
// failures to the outer reconnect+retry)
|
|
460
|
+
// - `failures.primary !== null`: primary actually failed (if primary
|
|
461
|
+
// succeeded with 0 rows, that's a legitimate "no results")
|
|
462
|
+
// - `failures.linked.size === linkedStores.size`: every linked store
|
|
463
|
+
// also failed (if ANY linked store succeeded with 0 rows, that
|
|
464
|
+
// answer is authoritative)
|
|
465
|
+
//
|
|
466
|
+
// Primary failures with at least one healthy linked store still return
|
|
467
|
+
// a success-shaped response with the runtime warning prepended — the
|
|
468
|
+
// linked stores' zero-results answer is authoritative for the query.
|
|
469
|
+
const allFederatedStoresFailed = boundary === undefined &&
|
|
470
|
+
failures.primary !== null &&
|
|
471
|
+
failures.linked.size === linkedStores.size;
|
|
472
|
+
if (results.length === 0) {
|
|
473
|
+
if (allFederatedStoresFailed) {
|
|
474
|
+
return {
|
|
475
|
+
content: [
|
|
476
|
+
{
|
|
477
|
+
type: 'text',
|
|
478
|
+
text: runtimeWarning ??
|
|
479
|
+
'[Totem Error] Federated search failed: every queried store errored.', // totem-ignore #1294 — system-generated + XML-wrapped
|
|
480
|
+
},
|
|
481
|
+
],
|
|
482
|
+
isError: true,
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
const body = formatXmlResponse('knowledge', 'No results found.');
|
|
486
|
+
const text = runtimeWarning ? runtimeWarning + '\n\n' + body : body; // totem-ignore #1294 — system-generated + XML-wrapped
|
|
487
|
+
return { content: [{ type: 'text', text }] };
|
|
488
|
+
}
|
|
489
|
+
const formatted = results.map((r, i) => formatResult(r, i)).join('\n\n---\n\n');
|
|
81
490
|
let text = formatXmlResponse('knowledge', formatted);
|
|
491
|
+
// Prepend the per-query runtime warning if federatedSearch populated it
|
|
492
|
+
if (runtimeWarning) {
|
|
493
|
+
text = runtimeWarning + '\n\n' + text; // totem-ignore #1294 — system-generated + XML-wrapped
|
|
494
|
+
}
|
|
82
495
|
// Append a system warning when the payload is large enough to risk context pressure
|
|
83
496
|
if (text.length > config.contextWarningThreshold) {
|
|
84
497
|
text +=
|
|
@@ -104,10 +517,18 @@ export function registerSearchKnowledge(server) {
|
|
|
104
517
|
.max(MAX_SEARCH_RESULTS)
|
|
105
518
|
.optional()
|
|
106
519
|
.describe(`Maximum number of results to return (default: 5, max: ${MAX_SEARCH_RESULTS})`),
|
|
520
|
+
// Normalize blank/whitespace boundaries to undefined so they take
|
|
521
|
+
// the federated default path. Without this, "" and " " fall into
|
|
522
|
+
// the raw-prefix branch and silently drop linked-repo federation.
|
|
523
|
+
// mmnto/totem#1295 CR fix — input sanitization at the MCP boundary.
|
|
107
524
|
boundary: z
|
|
108
|
-
.
|
|
109
|
-
|
|
110
|
-
|
|
525
|
+
.preprocess((value) => {
|
|
526
|
+
if (typeof value !== 'string')
|
|
527
|
+
return value;
|
|
528
|
+
const trimmed = value.trim();
|
|
529
|
+
return trimmed === '' ? undefined : trimmed;
|
|
530
|
+
}, z.string().optional())
|
|
531
|
+
.describe('Partition name, linked-index name, or file path prefix to scope results. Resolution order: (1) configured partition names (e.g., "core", "cli", "mcp") → primary index, prefix-filtered; (2) linked-index names from linkedIndexes config (e.g., "strategy") → routes only to that cross-repo index; (3) raw path prefixes (e.g., "src/components/") → primary, prefix-filtered. When omitted, search federates across primary + all linked indexes, merging by semantic score. Blank or whitespace-only values are normalized to "omitted" (federated default).'),
|
|
111
532
|
},
|
|
112
533
|
annotations: {
|
|
113
534
|
readOnlyHint: true,
|
|
@@ -136,10 +557,16 @@ export function registerSearchKnowledge(server) {
|
|
|
136
557
|
// Dimension mismatch is fatal — search will crash with a cryptic LanceDB error
|
|
137
558
|
if (healthWarning && healthWarning.includes('DIMENSION MISMATCH')) {
|
|
138
559
|
return {
|
|
139
|
-
content: [{ type: 'text', text: healthWarning }], // totem-ignore — healthWarning is from formatSystemWarning (already XML-wrapped)
|
|
560
|
+
content: [{ type: 'text', text: healthWarning }], // totem-ignore #1294 — healthWarning is from formatSystemWarning (already XML-wrapped)
|
|
140
561
|
isError: true,
|
|
141
562
|
};
|
|
142
563
|
}
|
|
564
|
+
// First-query linked-stores gate — non-blocking (mmnto/totem#1294 Phase 2).
|
|
565
|
+
// Surfaces init failures so the agent sees them in-context on the first
|
|
566
|
+
// search_knowledge call. Unlike dimension mismatch, linked-store failures
|
|
567
|
+
// are always recoverable (degrade to primary-only), so we don't set
|
|
568
|
+
// isError — we just prepend the warning to the result content below.
|
|
569
|
+
const linkedStoresWarning = await runFirstLinkedStoresCheck();
|
|
143
570
|
let result;
|
|
144
571
|
try {
|
|
145
572
|
result = await performSearch(query, type_filter, max_results, boundary);
|
|
@@ -177,20 +604,46 @@ export function registerSearchKnowledge(server) {
|
|
|
177
604
|
const resultText = result.content[0]?.text ?? '';
|
|
178
605
|
const scoreMatches = [...resultText.matchAll(/\*\*Score:\*\* ([\d.]+)/g)];
|
|
179
606
|
const topScore = scoreMatches.length > 0 ? parseFloat(scoreMatches[0][1]) : null;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
607
|
+
// Log error responses (e.g., the broken-linked-boundary path at
|
|
608
|
+
// performSearch Case 3) as errors instead of zero-result successes,
|
|
609
|
+
// so routing failures are visible in search-log.jsonl. Without this
|
|
610
|
+
// branch, isError responses would be indistinguishable from "no
|
|
611
|
+
// matches found." mmnto/totem#1295 CR fix.
|
|
612
|
+
if (result.isError) {
|
|
613
|
+
logSearch({
|
|
614
|
+
timestamp: new Date().toISOString(),
|
|
615
|
+
query,
|
|
616
|
+
typeFilter: type_filter,
|
|
617
|
+
boundary,
|
|
618
|
+
resultCount: 0,
|
|
619
|
+
durationMs: Date.now() - start,
|
|
620
|
+
topScore: null,
|
|
621
|
+
error: resultText,
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
logSearch({
|
|
626
|
+
timestamp: new Date().toISOString(),
|
|
627
|
+
query,
|
|
628
|
+
typeFilter: type_filter,
|
|
629
|
+
boundary,
|
|
630
|
+
resultCount: scoreMatches.length,
|
|
631
|
+
durationMs: Date.now() - start,
|
|
632
|
+
topScore,
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
// Prepend health warning and linked-stores warning to the first search
|
|
636
|
+
// result if issues were found. Order is deliberate: health first
|
|
637
|
+
// (local index issues are higher priority), then linked-stores second.
|
|
638
|
+
const warnings = [];
|
|
639
|
+
if (healthWarning)
|
|
640
|
+
warnings.push(healthWarning);
|
|
641
|
+
if (linkedStoresWarning)
|
|
642
|
+
warnings.push(linkedStoresWarning); // totem-ignore #1294 — system-generated
|
|
643
|
+
if (warnings.length > 0 && result.content.length > 0) {
|
|
191
644
|
result.content[0] = {
|
|
192
645
|
type: 'text',
|
|
193
|
-
text:
|
|
646
|
+
text: warnings.join('\n\n') + '\n\n' + result.content[0].text, // totem-ignore #1294 — all system-generated + XML-wrapped
|
|
194
647
|
};
|
|
195
648
|
}
|
|
196
649
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-knowledge.js","sourceRoot":"","sources":["../../src/tools/search-knowledge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAI1E,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,2EAA2E;AAC3E,IAAI,oBAAoB,GAAG,KAAK,CAAC;AAEjC;;;GAGG;AACH,KAAK,UAAU,wBAAwB;IACrC,IAAI,oBAAoB;QAAE,OAAO,IAAI,CAAC;IACtC,oBAAoB,GAAG,IAAI,CAAC;IAE5B,IAAI,CAAC;QACH,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,UAAU,EAAE,CAAC;QACrC,MAAM,MAAM,GAAsB,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC;QAE5D,IAAI,MAAM,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;QAEhC,yFAAyF;QACzF,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,MAAM,CAAC,gBAAgB,KAAK,IAAI,EAAE,CAAC;YAC/D,MAAM,KAAK,GAAG;gBACZ,iCAAiC,MAAM,CAAC,gBAAgB,qDAAqD,MAAM,CAAC,kBAAkB,eAAe;gBACr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