@exulu/backend 5.9.0 → 5.10.1
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/{chunk-LDA6HYEP.js → chunk-TFWF6WKM.js} +707 -179
- package/dist/{convert-exulu-tools-to-ai-sdk-tools-PEZCQBM5.js → convert-exulu-tools-to-ai-sdk-tools-LL7R3VTK.js} +1 -1
- package/dist/index.cjs +1017 -410
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +63 -10
- package/ee/agentic-retrieval/pipeline/index.test.ts +47 -0
- package/ee/agentic-retrieval/pipeline/index.ts +28 -0
- package/ee/agentic-retrieval/pipeline/multi-query.test.ts +56 -0
- package/ee/agentic-retrieval/pipeline/multi-query.ts +14 -0
- package/ee/agentic-retrieval/pipeline/search.test.ts +21 -0
- package/ee/agentic-retrieval/pipeline/search.ts +8 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -665,6 +665,15 @@ type ExuluContextFieldDefinition = {
|
|
|
665
665
|
* excluded by name in the input generator.
|
|
666
666
|
*/
|
|
667
667
|
hidden?: boolean;
|
|
668
|
+
/**
|
|
669
|
+
* Declares the shape of a `json` field. When present, the generated agent
|
|
670
|
+
* tools expose this schema to the model instead of the opaque "valid JSON
|
|
671
|
+
* string" instruction, so the model can see (and be validated against) the
|
|
672
|
+
* field's actual structure instead of guessing it. Undeclared `json` fields
|
|
673
|
+
* are unaffected — see json-field-schema.ts for the path/merge logic that
|
|
674
|
+
* reads this property in later tasks.
|
|
675
|
+
*/
|
|
676
|
+
schema?: z.ZodTypeAny;
|
|
668
677
|
};
|
|
669
678
|
type ExuluContextSource = {
|
|
670
679
|
id: string;
|
|
@@ -839,7 +848,9 @@ declare class ExuluContext {
|
|
|
839
848
|
item: Item;
|
|
840
849
|
job?: string;
|
|
841
850
|
}>;
|
|
842
|
-
updateItem: (item: Item, config: ExuluConfig, user?: number, role?: string, generateEmbeddingsOverwrite?: boolean, runProcessorOverwrite?: boolean
|
|
851
|
+
updateItem: (item: Item, config: ExuluConfig, user?: number, role?: string, generateEmbeddingsOverwrite?: boolean, runProcessorOverwrite?: boolean,
|
|
852
|
+
/** Names of `json` fields in `item` whose value is a merge patch rather than a full replacement (spec Part B). */
|
|
853
|
+
merge?: string[]) => Promise<{
|
|
843
854
|
item: Item;
|
|
844
855
|
job?: string;
|
|
845
856
|
}>;
|
package/dist/index.d.ts
CHANGED
|
@@ -665,6 +665,15 @@ type ExuluContextFieldDefinition = {
|
|
|
665
665
|
* excluded by name in the input generator.
|
|
666
666
|
*/
|
|
667
667
|
hidden?: boolean;
|
|
668
|
+
/**
|
|
669
|
+
* Declares the shape of a `json` field. When present, the generated agent
|
|
670
|
+
* tools expose this schema to the model instead of the opaque "valid JSON
|
|
671
|
+
* string" instruction, so the model can see (and be validated against) the
|
|
672
|
+
* field's actual structure instead of guessing it. Undeclared `json` fields
|
|
673
|
+
* are unaffected — see json-field-schema.ts for the path/merge logic that
|
|
674
|
+
* reads this property in later tasks.
|
|
675
|
+
*/
|
|
676
|
+
schema?: z.ZodTypeAny;
|
|
668
677
|
};
|
|
669
678
|
type ExuluContextSource = {
|
|
670
679
|
id: string;
|
|
@@ -839,7 +848,9 @@ declare class ExuluContext {
|
|
|
839
848
|
item: Item;
|
|
840
849
|
job?: string;
|
|
841
850
|
}>;
|
|
842
|
-
updateItem: (item: Item, config: ExuluConfig, user?: number, role?: string, generateEmbeddingsOverwrite?: boolean, runProcessorOverwrite?: boolean
|
|
851
|
+
updateItem: (item: Item, config: ExuluConfig, user?: number, role?: string, generateEmbeddingsOverwrite?: boolean, runProcessorOverwrite?: boolean,
|
|
852
|
+
/** Names of `json` fields in `item` whose value is a merge patch rather than a full replacement (spec Part B). */
|
|
853
|
+
merge?: string[]) => Promise<{
|
|
843
854
|
item: Item;
|
|
844
855
|
job?: string;
|
|
845
856
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -151,6 +151,7 @@ import {
|
|
|
151
151
|
parsePipelineConfig,
|
|
152
152
|
parseSkillAuthorConfig,
|
|
153
153
|
parseSkillFrontmatter,
|
|
154
|
+
prepareItemWrite,
|
|
154
155
|
preprocessQuery,
|
|
155
156
|
principalRotation,
|
|
156
157
|
projectComponents,
|
|
@@ -189,7 +190,7 @@ import {
|
|
|
189
190
|
verifyCredentialNonce,
|
|
190
191
|
willEmbedOnQueue,
|
|
191
192
|
workflowTemplatesSchema
|
|
192
|
-
} from "./chunk-
|
|
193
|
+
} from "./chunk-TFWF6WKM.js";
|
|
193
194
|
import {
|
|
194
195
|
LITELLM_UI_PATH,
|
|
195
196
|
ResolveModelError,
|
|
@@ -3176,6 +3177,10 @@ function createMutations(table, contexts, tools, config) {
|
|
|
3176
3177
|
if (table.name.singular === "agent") {
|
|
3177
3178
|
input = await applyAgentGuestFieldTransforms(input);
|
|
3178
3179
|
}
|
|
3180
|
+
const createValidation = prepareItemWrite({ fields: table.fields, existing: null, input });
|
|
3181
|
+
if (!createValidation.ok) {
|
|
3182
|
+
throw new Error(createValidation.message);
|
|
3183
|
+
}
|
|
3179
3184
|
Object.keys(input).forEach((key) => {
|
|
3180
3185
|
if (table.fields.find((field) => field.name === key)?.type === "json") {
|
|
3181
3186
|
if (typeof input[key] === "object" || Array.isArray(input[key])) {
|
|
@@ -3251,13 +3256,6 @@ function createMutations(table, contexts, tools, config) {
|
|
|
3251
3256
|
if (table.name.singular === "agent") {
|
|
3252
3257
|
input = await applyAgentGuestFieldTransforms(input);
|
|
3253
3258
|
}
|
|
3254
|
-
Object.keys(input).forEach((key) => {
|
|
3255
|
-
if (table.fields.find((field) => field.name === key)?.type === "json") {
|
|
3256
|
-
if (typeof input[key] === "object" || Array.isArray(input[key])) {
|
|
3257
|
-
input[key] = JSON.stringify(input[key]);
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
});
|
|
3261
3259
|
const requestedFields = getRequestedFields(info);
|
|
3262
3260
|
const sanitizedFields = sanitizeRequestedFields(table, requestedFields);
|
|
3263
3261
|
let itemQuery = db.from(tableNamePlural).select(sanitizedFields);
|
|
@@ -3267,6 +3265,24 @@ function createMutations(table, contexts, tools, config) {
|
|
|
3267
3265
|
throw new Error("Record not found");
|
|
3268
3266
|
}
|
|
3269
3267
|
await validateWriteAccess(item.id, context);
|
|
3268
|
+
const existingRow = args.merge?.length ? await db.from(tableNamePlural).where({ id: item.id }).first() : null;
|
|
3269
|
+
const prepared = prepareItemWrite({
|
|
3270
|
+
fields: table.fields,
|
|
3271
|
+
existing: existingRow ?? null,
|
|
3272
|
+
input,
|
|
3273
|
+
merge: args.merge
|
|
3274
|
+
});
|
|
3275
|
+
if (!prepared.ok) {
|
|
3276
|
+
throw new Error(prepared.message);
|
|
3277
|
+
}
|
|
3278
|
+
input = prepared.values;
|
|
3279
|
+
Object.keys(input).forEach((key) => {
|
|
3280
|
+
if (table.fields.find((field) => field.name === key)?.type === "json") {
|
|
3281
|
+
if (typeof input[key] === "object" || Array.isArray(input[key])) {
|
|
3282
|
+
input[key] = JSON.stringify(input[key]);
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
});
|
|
3270
3286
|
const columns = await db(tableNamePlural).columnInfo();
|
|
3271
3287
|
const [result] = await db(tableNamePlural).where({ id: item.id }).update({
|
|
3272
3288
|
...input,
|
|
@@ -3327,6 +3343,17 @@ function createMutations(table, contexts, tools, config) {
|
|
|
3327
3343
|
if (table.name.singular === "agent") {
|
|
3328
3344
|
input = await applyAgentGuestFieldTransforms(input);
|
|
3329
3345
|
}
|
|
3346
|
+
const existingRow = args.merge?.length ? await db.from(tableNamePlural).where({ id }).first() : null;
|
|
3347
|
+
const prepared = prepareItemWrite({
|
|
3348
|
+
fields: table.fields,
|
|
3349
|
+
existing: existingRow ?? null,
|
|
3350
|
+
input,
|
|
3351
|
+
merge: args.merge
|
|
3352
|
+
});
|
|
3353
|
+
if (!prepared.ok) {
|
|
3354
|
+
throw new Error(prepared.message);
|
|
3355
|
+
}
|
|
3356
|
+
input = prepared.values;
|
|
3330
3357
|
Object.keys(input).forEach((key) => {
|
|
3331
3358
|
if (table.fields.find((field) => field.name === key)?.type === "json") {
|
|
3332
3359
|
if (typeof input[key] === "object" || Array.isArray(input[key])) {
|
|
@@ -11361,8 +11388,34 @@ function createSDL(tables, contexts, tools, config, evals) {
|
|
|
11361
11388
|
${tableNamePlural}CreateOne(input: ${tableNameSingular}Input!, upsert: Boolean, generateEmbeddings: Boolean): ${tableNameSingular}MutationPayload
|
|
11362
11389
|
${tableNamePlural}CopyOneById(id: ID!): ${tableNameSingular}MutationPayload
|
|
11363
11390
|
|
|
11364
|
-
|
|
11365
|
-
|
|
11391
|
+
"""
|
|
11392
|
+
merge: names of json fields in \`input\` whose value is a merge patch
|
|
11393
|
+
(only the keys given are changed, other stored keys are kept, and an
|
|
11394
|
+
explicit null deletes a key) rather than a full replacement. Omit to
|
|
11395
|
+
replace the whole field, as normal (spec 2026-11-09-typed-json-fields).
|
|
11396
|
+
Every name given must be a json field this same call sends a value for;
|
|
11397
|
+
one that is not is refused, not ignored. NOT concurrency-safe: a merge
|
|
11398
|
+
reads the stored value and writes the combined result as two separate
|
|
11399
|
+
statements, with no transaction or row lock, so two merges that OVERLAP
|
|
11400
|
+
in time can still lose one of them. Merges that are serialized (each
|
|
11401
|
+
awaited before the next) both land; overlapping edits to one item need
|
|
11402
|
+
to be serialized by the caller.
|
|
11403
|
+
"""
|
|
11404
|
+
${tableNamePlural}UpdateOne(where: [Filter${tableNameSingularUpperCaseFirst}], input: ${tableNameSingular}Input!, generateEmbeddings: Boolean, merge: [String]): ${tableNameSingular}MutationPayload
|
|
11405
|
+
"""
|
|
11406
|
+
merge: names of json fields in \`input\` whose value is a merge patch
|
|
11407
|
+
(only the keys given are changed, other stored keys are kept, and an
|
|
11408
|
+
explicit null deletes a key) rather than a full replacement. Omit to
|
|
11409
|
+
replace the whole field, as normal (spec 2026-11-09-typed-json-fields).
|
|
11410
|
+
Every name given must be a json field this same call sends a value for;
|
|
11411
|
+
one that is not is refused, not ignored. NOT concurrency-safe: a merge
|
|
11412
|
+
reads the stored value and writes the combined result as two separate
|
|
11413
|
+
statements, with no transaction or row lock, so two merges that OVERLAP
|
|
11414
|
+
in time can still lose one of them. Merges that are serialized (each
|
|
11415
|
+
awaited before the next) both land; overlapping edits to one item need
|
|
11416
|
+
to be serialized by the caller.
|
|
11417
|
+
"""
|
|
11418
|
+
${tableNamePlural}UpdateOneById(id: ID!, input: ${tableNameSingular}Input!, generateEmbeddings: Boolean, merge: [String]): ${tableNameSingular}MutationPayload
|
|
11366
11419
|
${tableNamePlural}RemoveOneById(id: ID!): ${tableNameSingular}
|
|
11367
11420
|
${tableNamePlural}RemoveOne(where: JSON!): ${tableNameSingular}
|
|
11368
11421
|
`;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// ee/agentic-retrieval/pipeline/index.test.ts
|
|
2
2
|
import { createAgenticRetrievalTool, parsePreselectedItems } from "./index";
|
|
3
|
+
import { UnknownFilterPathError } from "@SRC/graphql/utilities/convert-graphql-filter-operator-to-pg-query";
|
|
3
4
|
|
|
4
5
|
jest.mock("@EE/entitlements", () => ({ checkLicense: () => ({ "agentic-retrieval": true }) }));
|
|
5
6
|
jest.mock("@SRC/exulu/resolve-reranker", () => ({ resolveReranker: jest.fn(async () => ({ model: "m", rerank: async (_q: any, c: any) => c })) }));
|
|
@@ -392,3 +393,49 @@ describe("engine v2 — identifier pins run alongside memory and routing", () =>
|
|
|
392
393
|
expect(runMemoryPhase.mock.calls[0][0].mergedCall).toBeFalsy();
|
|
393
394
|
});
|
|
394
395
|
});
|
|
396
|
+
|
|
397
|
+
describe("a refused json filter path reaching the pipeline boundary", () => {
|
|
398
|
+
// --- Final review, Important 4 -----------------------------------------
|
|
399
|
+
//
|
|
400
|
+
// Spec Part C: a refused filter must come back as a normal tool RESULT
|
|
401
|
+
// carrying the message, not as a thrown error -- a bad filter is a typo
|
|
402
|
+
// the model fixes on its next call, not a turn-ending condition. This
|
|
403
|
+
// boundary's catch-all was reporting it as "Retrieval degraded due to an
|
|
404
|
+
// internal error -- returning partial results", so the model got partial
|
|
405
|
+
// results and no path list: Part C's exact target failure in new wording.
|
|
406
|
+
it("surfaces the refusal as the step text, not as the generic degraded message", async () => {
|
|
407
|
+
const { searchContexts } = jest.requireMock("./search");
|
|
408
|
+
searchContexts.mockRejectedValueOnce(
|
|
409
|
+
new UnknownFilterPathError("felder", ["konfidenz"], ["<key>.wert", "<key>.konfidenz"]),
|
|
410
|
+
);
|
|
411
|
+
|
|
412
|
+
const run = makeTool({});
|
|
413
|
+
const out = await drain(run(inputs));
|
|
414
|
+
// The tool result is the serialized output, so assert on the parsed
|
|
415
|
+
// step text rather than on the JSON-escaped string.
|
|
416
|
+
const payload = JSON.parse(out[out.length - 1].result as string);
|
|
417
|
+
const texts = (payload.steps as { text: string }[]).map((step) => step.text);
|
|
418
|
+
|
|
419
|
+
// The four-part refusal reaches the model verbatim, list of valid paths
|
|
420
|
+
// included -- that list is the whole point of Part C.
|
|
421
|
+
expect(texts).toContainEqual(expect.stringContaining('Filter on field "felder" rejected'));
|
|
422
|
+
expect(texts).toContainEqual(expect.stringContaining("<key>.konfidenz"));
|
|
423
|
+
expect(texts).not.toContainEqual(
|
|
424
|
+
expect.stringContaining("Retrieval degraded due to an internal error"),
|
|
425
|
+
);
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
it("every OTHER pipeline failure still reports the generic degraded message", async () => {
|
|
429
|
+
const { searchContexts } = jest.requireMock("./search");
|
|
430
|
+
searchContexts.mockRejectedValueOnce(new Error("connection reset"));
|
|
431
|
+
|
|
432
|
+
const run = makeTool({});
|
|
433
|
+
const out = await drain(run(inputs));
|
|
434
|
+
const payload = JSON.parse(out[out.length - 1].result as string);
|
|
435
|
+
const texts = (payload.steps as { text: string }[]).map((step) => step.text);
|
|
436
|
+
|
|
437
|
+
expect(texts).toContainEqual(
|
|
438
|
+
expect.stringContaining("Retrieval degraded due to an internal error"),
|
|
439
|
+
);
|
|
440
|
+
});
|
|
441
|
+
});
|
|
@@ -21,6 +21,7 @@ import { needsPinRerun } from "./pin-rerun";
|
|
|
21
21
|
import type { VectorSearchChunkResult } from "@SRC/graphql/resolvers/vector-search";
|
|
22
22
|
import { parsePreselectedItems } from "./global-ids";
|
|
23
23
|
import { isExternalOrAnonymousUser } from "@SRC/exulu/resolve-max-steps";
|
|
24
|
+
import { UnknownFilterPathError } from "@SRC/graphql/utilities/convert-graphql-filter-operator-to-pg-query";
|
|
24
25
|
export { parsePreselectedItems } from "./global-ids";
|
|
25
26
|
|
|
26
27
|
// ---------------------------------------------------------------------------
|
|
@@ -803,6 +804,33 @@ export function createAgenticRetrievalTool(opts: {
|
|
|
803
804
|
yield { result: serializeOutput(result, hideSources) };
|
|
804
805
|
return { result: serializeOutput(result, hideSources) };
|
|
805
806
|
} catch (err) {
|
|
807
|
+
// A refused json filter path is the one failure here that is the
|
|
808
|
+
// CALLER's to fix, and the one that must never be reported as a
|
|
809
|
+
// degraded search (final review, Important 4). Spec Part C is
|
|
810
|
+
// explicit that a refused filter comes back as a normal tool
|
|
811
|
+
// RESULT carrying the message, not as a thrown error: a bad filter
|
|
812
|
+
// is a typo the model corrects on its next call, not a turn-ending
|
|
813
|
+
// condition. Reported as "Retrieval degraded due to an internal
|
|
814
|
+
// error — returning partial results", it was Part C's exact target
|
|
815
|
+
// failure in new wording — the model got partial results, no path
|
|
816
|
+
// list, and no reason to retry. `err.message` is already the
|
|
817
|
+
// complete four-part refusal (what was rejected, why, what was
|
|
818
|
+
// expected, and the full list of paths the schema DOES define), so
|
|
819
|
+
// it is surfaced verbatim as the step text. The throw itself stays
|
|
820
|
+
// where it is, deliberately (see UnknownFilterPathError's own doc
|
|
821
|
+
// comment); this is the boundary mapping that was missing.
|
|
822
|
+
if (err instanceof UnknownFilterPathError) {
|
|
823
|
+
console.warn("[EXULU pipeline] retrieval refused an unknown json filter path:", err.message);
|
|
824
|
+
result.steps.push({
|
|
825
|
+
stepNumber: 1,
|
|
826
|
+
text: err.message,
|
|
827
|
+
toolCalls: [],
|
|
828
|
+
chunks: [],
|
|
829
|
+
tokens: 0,
|
|
830
|
+
});
|
|
831
|
+
yield { result: serializeOutput(result, hideSources) };
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
806
834
|
console.warn("[EXULU pipeline] retrieval pipeline failed:", err);
|
|
807
835
|
result.steps.push({
|
|
808
836
|
stepNumber: 1,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { multiQuerySearch, singleSearch } from "./multi-query";
|
|
2
|
+
import { UnknownFilterPathError } from "@SRC/graphql/utilities/convert-graphql-filter-operator-to-pg-query";
|
|
2
3
|
|
|
3
4
|
const chunk = (id: string, score = 1) => ({
|
|
4
5
|
chunk_id: id,
|
|
@@ -49,3 +50,58 @@ describe("multiQuerySearch", () => {
|
|
|
49
50
|
expect(ctx.search.mock.calls[0][0].itemFilters).toEqual([{ id: { in: ["x"] } }]);
|
|
50
51
|
});
|
|
51
52
|
});
|
|
53
|
+
|
|
54
|
+
// Final review, Important 4: singleSearch's catch-all turns any failure into
|
|
55
|
+
// zero chunks, which is right for a search that broke and wrong for a filter
|
|
56
|
+
// that cannot be answered -- an undeclared json filter path degraded to an
|
|
57
|
+
// empty result the model reports as "there are none", the exact silence spec
|
|
58
|
+
// Part C exists to end. It is re-thrown so the pipeline's boundary can
|
|
59
|
+
// surface the refusal message instead.
|
|
60
|
+
describe("singleSearch and a refused json filter path", () => {
|
|
61
|
+
it("re-throws UnknownFilterPathError instead of degrading it to zero chunks", async () => {
|
|
62
|
+
const err = new UnknownFilterPathError("felder", ["konfidenz"], ["<key>.konfidenz"]);
|
|
63
|
+
const ctx = { search: jest.fn().mockRejectedValue(err) };
|
|
64
|
+
|
|
65
|
+
await expect(
|
|
66
|
+
singleSearch({
|
|
67
|
+
query: "q",
|
|
68
|
+
config: { method: "hybridSearch", limit: 5 },
|
|
69
|
+
user: {},
|
|
70
|
+
role: "r",
|
|
71
|
+
pinnedItemIds: [],
|
|
72
|
+
context: ctx,
|
|
73
|
+
}),
|
|
74
|
+
).rejects.toBe(err);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("every OTHER failure is still swallowed into an empty result, exactly as before", async () => {
|
|
78
|
+
const ctx = { search: jest.fn().mockRejectedValue(new Error("connection reset")) };
|
|
79
|
+
|
|
80
|
+
await expect(
|
|
81
|
+
singleSearch({
|
|
82
|
+
query: "q",
|
|
83
|
+
config: { method: "hybridSearch", limit: 5 },
|
|
84
|
+
user: {},
|
|
85
|
+
role: "r",
|
|
86
|
+
pinnedItemIds: [],
|
|
87
|
+
context: ctx,
|
|
88
|
+
}),
|
|
89
|
+
).resolves.toEqual([]);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("multiQuerySearch propagates it too -- one refused filter is refused for every query variation", async () => {
|
|
93
|
+
const err = new UnknownFilterPathError("felder", ["konfidenz"], ["<key>.konfidenz"]);
|
|
94
|
+
const ctx = { search: jest.fn().mockRejectedValue(err) };
|
|
95
|
+
|
|
96
|
+
await expect(
|
|
97
|
+
multiQuerySearch({
|
|
98
|
+
queries: ["q1", "q2"],
|
|
99
|
+
config: { method: "hybridSearch", limit: 5 },
|
|
100
|
+
user: {},
|
|
101
|
+
role: "r",
|
|
102
|
+
pinnedItemIds: [],
|
|
103
|
+
context: ctx,
|
|
104
|
+
}),
|
|
105
|
+
).rejects.toBe(err);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UnknownFilterPathError } from "@SRC/graphql/utilities/convert-graphql-filter-operator-to-pg-query";
|
|
1
2
|
import { RRF_K } from "./config";
|
|
2
3
|
import type { Chunk } from "./types";
|
|
3
4
|
|
|
@@ -13,6 +14,18 @@ export type SearchCallConfig = {
|
|
|
13
14
|
/**
|
|
14
15
|
* Performs a single search with the given query and configuration.
|
|
15
16
|
* Wraps the context.search call in try/catch to handle failures gracefully.
|
|
17
|
+
*
|
|
18
|
+
* One exception is deliberately NOT handled gracefully (final review,
|
|
19
|
+
* Important 4): a refused json filter path (`UnknownFilterPathError`) is
|
|
20
|
+
* not a search that failed, it is a filter that cannot be answered — the
|
|
21
|
+
* caller asked about a path the field's declared schema does not define,
|
|
22
|
+
* and degrading that to zero chunks reproduces the exact silence spec Part
|
|
23
|
+
* C exists to end (an empty result the model reports as "there are none").
|
|
24
|
+
* It is re-thrown so it reaches the pipeline's own boundary
|
|
25
|
+
* (`pipeline/index.ts`), which turns it into a step the model can read and
|
|
26
|
+
* act on. `pipeline/search.ts`'s per-context catch re-throws it for the
|
|
27
|
+
* same reason — every swallow point between the query and that boundary
|
|
28
|
+
* has to pass it along, or the mapping exists and never fires.
|
|
16
29
|
*/
|
|
17
30
|
export async function singleSearch({
|
|
18
31
|
query,
|
|
@@ -53,6 +66,7 @@ export async function singleSearch({
|
|
|
53
66
|
|
|
54
67
|
return results.chunks || [];
|
|
55
68
|
} catch (e) {
|
|
69
|
+
if (e instanceof UnknownFilterPathError) throw e;
|
|
56
70
|
console.warn("[EXULU] singleSearch failed for query:", query, e);
|
|
57
71
|
return [];
|
|
58
72
|
}
|
|
@@ -7,6 +7,7 @@ jest.mock("./prefilter", () => ({ fuzzyPrefilter: jest.fn(async () => [{ id: "p1
|
|
|
7
7
|
import { multiQuerySearch, singleSearch } from "./multi-query";
|
|
8
8
|
import { generateHydePassage } from "./hyde";
|
|
9
9
|
import { fuzzyPrefilter } from "./prefilter";
|
|
10
|
+
import { UnknownFilterPathError } from "@SRC/graphql/utilities/convert-graphql-filter-operator-to-pg-query";
|
|
10
11
|
|
|
11
12
|
const contextsById = new Map<string, any>([
|
|
12
13
|
["docs", { id: "docs", configuration: {} }],
|
|
@@ -189,3 +190,23 @@ describe("searchContexts", () => {
|
|
|
189
190
|
expect((multiQuerySearch as jest.Mock).mock.calls[0][0].pinnedItemIds).toEqual(["s1"]);
|
|
190
191
|
});
|
|
191
192
|
});
|
|
193
|
+
|
|
194
|
+
// Final review, Important 4: the second swallow point between the query and
|
|
195
|
+
// the pipeline's boundary. Its per-context catch returns [] so one broken
|
|
196
|
+
// context cannot take the whole retrieval down -- correct for a failed
|
|
197
|
+
// search, wrong for a filter path no schema defines, which is wrong for
|
|
198
|
+
// every context and has a message the model can act on.
|
|
199
|
+
describe("searchContexts and a refused json filter path", () => {
|
|
200
|
+
it("re-throws UnknownFilterPathError instead of degrading that context to zero chunks", async () => {
|
|
201
|
+
const err = new UnknownFilterPathError("felder", ["konfidenz"], ["<key>.konfidenz"]);
|
|
202
|
+
(multiQuerySearch as jest.Mock).mockRejectedValueOnce(err);
|
|
203
|
+
|
|
204
|
+
await expect(searchContexts({ ...base, contextIds: ["docs"] })).rejects.toBe(err);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("every OTHER per-context failure is still swallowed, exactly as before", async () => {
|
|
208
|
+
(multiQuerySearch as jest.Mock).mockRejectedValueOnce(new Error("connection reset"));
|
|
209
|
+
|
|
210
|
+
await expect(searchContexts({ ...base, contextIds: ["docs"] })).resolves.toEqual({ chunks: [] });
|
|
211
|
+
});
|
|
212
|
+
});
|
|
@@ -6,6 +6,7 @@ import { withTiming } from "./timing";
|
|
|
6
6
|
import { applyRewrites } from "./text-utils";
|
|
7
7
|
import type { Chunk } from "./types";
|
|
8
8
|
import { isEmbedderNotConfigured } from "@SRC/exulu/embedder-not-configured";
|
|
9
|
+
import { UnknownFilterPathError } from "@SRC/graphql/utilities/convert-graphql-filter-operator-to-pg-query";
|
|
9
10
|
|
|
10
11
|
/** Attach the source knowledge base to each chunk so citations and the chat UI can
|
|
11
12
|
* attribute passages deterministically. Only memory chunks were labeled before; the
|
|
@@ -185,6 +186,13 @@ export async function searchContexts(opts: {
|
|
|
185
186
|
|
|
186
187
|
return [];
|
|
187
188
|
} catch (err) {
|
|
189
|
+
// A refused json filter path is not "this context failed to search"
|
|
190
|
+
// (final review, Important 4): the filter names a path no schema
|
|
191
|
+
// defines, so it is wrong for every context, and returning [] here
|
|
192
|
+
// would hand the model an empty result instead of the refusal that
|
|
193
|
+
// tells it what to fix. Re-thrown so `pipeline/index.ts`'s own
|
|
194
|
+
// boundary can surface the message as a step.
|
|
195
|
+
if (err instanceof UnknownFilterPathError) throw err;
|
|
188
196
|
if (isEmbedderNotConfigured(err)) {
|
|
189
197
|
console.warn(
|
|
190
198
|
`[EXULU pipeline] context "${ctxId}" is not searchable: ${(err as Error).message}`,
|