@carlonicora/nestjs-neo4jsonapi 2.14.11 → 2.15.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/agents/contextualiser/contexts/contextualiser.context.d.ts +41 -0
- package/dist/agents/contextualiser/contexts/contextualiser.context.d.ts.map +1 -1
- package/dist/agents/contextualiser/contexts/contextualiser.context.js +17 -0
- package/dist/agents/contextualiser/contexts/contextualiser.context.js.map +1 -1
- package/dist/agents/contextualiser/contexts/notebook.context.d.ts +22 -0
- package/dist/agents/contextualiser/contexts/notebook.context.d.ts.map +1 -1
- package/dist/agents/contextualiser/contexts/notebook.context.js +14 -0
- package/dist/agents/contextualiser/contexts/notebook.context.js.map +1 -1
- package/dist/agents/contextualiser/factories/contextualiser.context.factory.d.ts.map +1 -1
- package/dist/agents/contextualiser/factories/contextualiser.context.factory.js +2 -0
- package/dist/agents/contextualiser/factories/contextualiser.context.factory.js.map +1 -1
- package/dist/agents/contextualiser/nodes/atomicfacts.node.service.d.ts.map +1 -1
- package/dist/agents/contextualiser/nodes/atomicfacts.node.service.js +17 -5
- package/dist/agents/contextualiser/nodes/atomicfacts.node.service.js.map +1 -1
- package/dist/agents/contextualiser/nodes/chunk.node.service.d.ts +1 -14
- package/dist/agents/contextualiser/nodes/chunk.node.service.d.ts.map +1 -1
- package/dist/agents/contextualiser/nodes/chunk.node.service.js +56 -206
- package/dist/agents/contextualiser/nodes/chunk.node.service.js.map +1 -1
- package/dist/agents/contextualiser/nodes/chunk.vector.node.service.d.ts +3 -12
- package/dist/agents/contextualiser/nodes/chunk.vector.node.service.d.ts.map +1 -1
- package/dist/agents/contextualiser/nodes/chunk.vector.node.service.js +44 -133
- package/dist/agents/contextualiser/nodes/chunk.vector.node.service.js.map +1 -1
- package/dist/agents/contextualiser/nodes/keyconcepts.node.service.d.ts +1 -2
- package/dist/agents/contextualiser/nodes/keyconcepts.node.service.d.ts.map +1 -1
- package/dist/agents/contextualiser/nodes/keyconcepts.node.service.js +60 -60
- package/dist/agents/contextualiser/nodes/keyconcepts.node.service.js.map +1 -1
- package/dist/agents/contextualiser/nodes/question.refiner.node.service.d.ts.map +1 -1
- package/dist/agents/contextualiser/nodes/question.refiner.node.service.js +7 -2
- package/dist/agents/contextualiser/nodes/question.refiner.node.service.js.map +1 -1
- package/dist/agents/contextualiser/nodes/rational.node.service.js +2 -1
- package/dist/agents/contextualiser/nodes/rational.node.service.js.map +1 -1
- package/dist/agents/contextualiser/services/contextualiser.service.d.ts.map +1 -1
- package/dist/agents/contextualiser/services/contextualiser.service.js +30 -22
- package/dist/agents/contextualiser/services/contextualiser.service.js.map +1 -1
- package/dist/agents/prompts/index.d.ts +0 -2
- package/dist/agents/prompts/index.d.ts.map +1 -1
- package/dist/agents/prompts/index.js +7 -5
- package/dist/agents/prompts/index.js.map +1 -1
- package/dist/agents/responder/contexts/responder.context.d.ts +96 -0
- package/dist/agents/responder/contexts/responder.context.d.ts.map +1 -1
- package/dist/agents/responder/interfaces/unified.trace.interface.d.ts +9 -0
- package/dist/agents/responder/interfaces/unified.trace.interface.d.ts.map +1 -1
- package/dist/agents/responder/nodes/__tests__/helpers/answer-node.harness.d.ts +38 -0
- package/dist/agents/responder/nodes/__tests__/helpers/answer-node.harness.d.ts.map +1 -0
- package/dist/agents/responder/nodes/__tests__/helpers/answer-node.harness.js +36 -0
- package/dist/agents/responder/nodes/__tests__/helpers/answer-node.harness.js.map +1 -0
- package/dist/agents/responder/nodes/graph.node.service.d.ts.map +1 -1
- package/dist/agents/responder/nodes/graph.node.service.js +18 -3
- package/dist/agents/responder/nodes/graph.node.service.js.map +1 -1
- package/dist/agents/responder/nodes/planner.node.service.d.ts.map +1 -1
- package/dist/agents/responder/nodes/planner.node.service.js +9 -0
- package/dist/agents/responder/nodes/planner.node.service.js.map +1 -1
- package/dist/agents/responder/nodes/responder.answer.node.service.d.ts +26 -1
- package/dist/agents/responder/nodes/responder.answer.node.service.d.ts.map +1 -1
- package/dist/agents/responder/nodes/responder.answer.node.service.js +127 -13
- package/dist/agents/responder/nodes/responder.answer.node.service.js.map +1 -1
- package/dist/agents/responder/services/responder.service.d.ts.map +1 -1
- package/dist/agents/responder/services/responder.service.js +4 -0
- package/dist/agents/responder/services/responder.service.js.map +1 -1
- package/dist/common/utils/settled.d.ts +33 -0
- package/dist/common/utils/settled.d.ts.map +1 -0
- package/dist/common/utils/settled.js +66 -0
- package/dist/common/utils/settled.js.map +1 -0
- package/dist/config/interfaces/config.prompts.interface.d.ts +12 -0
- package/dist/config/interfaces/config.prompts.interface.d.ts.map +1 -1
- package/dist/eval/retrieval/end-to-end-sweep.service.d.ts +52 -0
- package/dist/eval/retrieval/end-to-end-sweep.service.d.ts.map +1 -0
- package/dist/eval/retrieval/end-to-end-sweep.service.js +194 -0
- package/dist/eval/retrieval/end-to-end-sweep.service.js.map +1 -0
- package/dist/eval/retrieval/evidence.matcher.d.ts +23 -0
- package/dist/eval/retrieval/evidence.matcher.d.ts.map +1 -0
- package/dist/eval/retrieval/evidence.matcher.js +38 -0
- package/dist/eval/retrieval/evidence.matcher.js.map +1 -0
- package/dist/eval/retrieval/index.d.ts +10 -0
- package/dist/eval/retrieval/index.d.ts.map +1 -0
- package/dist/eval/retrieval/index.js +35 -0
- package/dist/eval/retrieval/index.js.map +1 -0
- package/dist/eval/retrieval/question-set.loader.d.ts +16 -0
- package/dist/eval/retrieval/question-set.loader.d.ts.map +1 -0
- package/dist/eval/retrieval/question-set.loader.js +73 -0
- package/dist/eval/retrieval/question-set.loader.js.map +1 -0
- package/dist/eval/retrieval/retrieval-eval.module.d.ts +14 -0
- package/dist/eval/retrieval/retrieval-eval.module.d.ts.map +1 -0
- package/dist/eval/retrieval/retrieval-eval.module.js +48 -0
- package/dist/eval/retrieval/retrieval-eval.module.js.map +1 -0
- package/dist/eval/retrieval/retrieval-eval.types.d.ts +84 -0
- package/dist/eval/retrieval/retrieval-eval.types.d.ts.map +1 -0
- package/dist/eval/retrieval/retrieval-eval.types.js +25 -0
- package/dist/eval/retrieval/retrieval-eval.types.js.map +1 -0
- package/dist/eval/retrieval/retrieval-sweep.service.d.ts +35 -0
- package/dist/eval/retrieval/retrieval-sweep.service.d.ts.map +1 -0
- package/dist/eval/retrieval/retrieval-sweep.service.js +93 -0
- package/dist/eval/retrieval/retrieval-sweep.service.js.map +1 -0
- package/dist/eval/retrieval/rubric-judge.service.d.ts +30 -0
- package/dist/eval/retrieval/rubric-judge.service.d.ts.map +1 -0
- package/dist/eval/retrieval/rubric-judge.service.js +138 -0
- package/dist/eval/retrieval/rubric-judge.service.js.map +1 -0
- package/dist/eval/retrieval/sweep-report.d.ts +11 -0
- package/dist/eval/retrieval/sweep-report.d.ts.map +1 -0
- package/dist/eval/retrieval/sweep-report.js +79 -0
- package/dist/eval/retrieval/sweep-report.js.map +1 -0
- package/dist/eval/retrieval/token-accounting.check.d.ts +39 -0
- package/dist/eval/retrieval/token-accounting.check.d.ts.map +1 -0
- package/dist/eval/retrieval/token-accounting.check.js +75 -0
- package/dist/eval/retrieval/token-accounting.check.js.map +1 -0
- package/dist/foundations/atomicfact/repositories/atomicfact.repository.d.ts.map +1 -1
- package/dist/foundations/atomicfact/repositories/atomicfact.repository.js +7 -0
- package/dist/foundations/atomicfact/repositories/atomicfact.repository.js.map +1 -1
- package/dist/foundations/chunk/repositories/chunk.repository.d.ts +87 -1
- package/dist/foundations/chunk/repositories/chunk.repository.d.ts.map +1 -1
- package/dist/foundations/chunk/repositories/chunk.repository.js +239 -50
- package/dist/foundations/chunk/repositories/chunk.repository.js.map +1 -1
- package/dist/foundations/chunk/repositories/retrieval.constants.d.ts +69 -0
- package/dist/foundations/chunk/repositories/retrieval.constants.d.ts.map +1 -0
- package/dist/foundations/chunk/repositories/retrieval.constants.js +72 -0
- package/dist/foundations/chunk/repositories/retrieval.constants.js.map +1 -0
- package/dist/foundations/keyconcept/repositories/keyconcept.repository.d.ts +2 -0
- package/dist/foundations/keyconcept/repositories/keyconcept.repository.d.ts.map +1 -1
- package/dist/foundations/keyconcept/repositories/keyconcept.repository.js +9 -5
- package/dist/foundations/keyconcept/repositories/keyconcept.repository.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** One question with its ground truth. Authored per repo, corrected by the owner. */
|
|
3
|
+
export declare const evalQuestionSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
corpus: z.ZodString;
|
|
6
|
+
question: z.ZodString;
|
|
7
|
+
mustRetrieve: z.ZodArray<z.ZodString>;
|
|
8
|
+
rubric: z.ZodString;
|
|
9
|
+
scopeId: z.ZodOptional<z.ZodString>;
|
|
10
|
+
scopeType: z.ZodOptional<z.ZodString>;
|
|
11
|
+
scopeLabel: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
export type EvalQuestion = z.infer<typeof evalQuestionSchema>;
|
|
14
|
+
export declare const evalQuestionSetSchema: z.ZodObject<{
|
|
15
|
+
version: z.ZodLiteral<1>;
|
|
16
|
+
product: z.ZodString;
|
|
17
|
+
questions: z.ZodArray<z.ZodObject<{
|
|
18
|
+
id: z.ZodString;
|
|
19
|
+
corpus: z.ZodString;
|
|
20
|
+
question: z.ZodString;
|
|
21
|
+
mustRetrieve: z.ZodArray<z.ZodString>;
|
|
22
|
+
rubric: z.ZodString;
|
|
23
|
+
scopeId: z.ZodOptional<z.ZodString>;
|
|
24
|
+
scopeType: z.ZodOptional<z.ZodString>;
|
|
25
|
+
scopeLabel: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export type EvalQuestionSet = z.infer<typeof evalQuestionSetSchema>;
|
|
29
|
+
/** Why a question failed its rubric. Closed set — see spec §6.5. */
|
|
30
|
+
export type RubricFailureMode = "evidence-not-retrieved" | "retrieved-but-unused" | "contradicted-source" | "hedged-without-answering";
|
|
31
|
+
export interface RubricVerdict {
|
|
32
|
+
passed: boolean;
|
|
33
|
+
failureMode?: RubricFailureMode;
|
|
34
|
+
explanation: string;
|
|
35
|
+
}
|
|
36
|
+
/** One question's result in retrieval-only mode. */
|
|
37
|
+
export interface RetrievalSweepResult {
|
|
38
|
+
questionId: string;
|
|
39
|
+
evidenceRetrieved: number;
|
|
40
|
+
missingSnippets: string[];
|
|
41
|
+
chunksRead: number;
|
|
42
|
+
retrievalMs: number;
|
|
43
|
+
error?: string;
|
|
44
|
+
}
|
|
45
|
+
/** One question's result in end-to-end mode. Extends the retrieval facts with answer facts. */
|
|
46
|
+
export interface EndToEndSweepResult extends RetrievalSweepResult {
|
|
47
|
+
evidenceCited: number;
|
|
48
|
+
uncitedSnippets: string[];
|
|
49
|
+
verdict: RubricVerdict;
|
|
50
|
+
inputTokens: number;
|
|
51
|
+
outputTokens: number;
|
|
52
|
+
answerMs: number;
|
|
53
|
+
tokenAccounting: TokenAccountingCheck;
|
|
54
|
+
/** Snippets found in the entries the answer model actually received (post-trim). */
|
|
55
|
+
evidenceRead: number;
|
|
56
|
+
/** Notebook entries that survived the trim; 0 when readObserved is false. */
|
|
57
|
+
chunksKept: number;
|
|
58
|
+
/** Kept entries that reached the model in core (unwidened) form; 0 when readObserved is false. */
|
|
59
|
+
chunksKeptCore: number;
|
|
60
|
+
/** False when the turn produced no keptChunkIds (failed turn / node skipped). */
|
|
61
|
+
readObserved: boolean;
|
|
62
|
+
}
|
|
63
|
+
/** Spec §6.5 — the harness validates its own token accounting. */
|
|
64
|
+
export interface TokenAccountingCheck {
|
|
65
|
+
ledgerInput: number;
|
|
66
|
+
observedInput: number;
|
|
67
|
+
ledgerOutput: number;
|
|
68
|
+
observedOutput: number;
|
|
69
|
+
agrees: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Whether the comparison actually ran. A question that never produced a turn
|
|
72
|
+
* has nothing to compare — reporting `agrees: true` there would be the one
|
|
73
|
+
* direction this mechanism must never fail (§6.5).
|
|
74
|
+
*/
|
|
75
|
+
checked: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface SweepSummary<T extends RetrievalSweepResult> {
|
|
78
|
+
product: string;
|
|
79
|
+
mode: "retrieval-only" | "end-to-end";
|
|
80
|
+
model: string;
|
|
81
|
+
startedAt: string;
|
|
82
|
+
results: T[];
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=retrieval-eval.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieval-eval.types.d.ts","sourceRoot":"","sources":["../../../src/eval/retrieval/retrieval-eval.types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qFAAqF;AACrF,eAAO,MAAM,kBAAkB;;;;;;;;;iBAc7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;iBAIhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,oEAAoE;AACpE,MAAM,MAAM,iBAAiB,GAC3B,wBAAwB,GAAG,sBAAsB,GAAG,qBAAqB,GAAG,0BAA0B,CAAC;AAEzG,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,oDAAoD;AACpD,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,+FAA+F;AAC/F,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,oBAAoB,CAAC;IACtC,oFAAoF;IACpF,YAAY,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAC;IACnB,kGAAkG;IAClG,cAAc,EAAE,MAAM,CAAC;IACvB,iFAAiF;IACjF,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,kEAAkE;AAClE,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,oBAAoB;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,gBAAgB,GAAG,YAAY,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,CAAC,EAAE,CAAC;CACd"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.evalQuestionSetSchema = exports.evalQuestionSchema = void 0;
|
|
4
|
+
// src/eval/retrieval/retrieval-eval.types.ts
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
/** One question with its ground truth. Authored per repo, corrected by the owner. */
|
|
7
|
+
exports.evalQuestionSchema = zod_1.z.object({
|
|
8
|
+
id: zod_1.z.string().describe("Stable identifier, unique within the set"),
|
|
9
|
+
corpus: zod_1.z.string().describe("Which corpus this question is asked against, e.g. 'a360ai/P10'"),
|
|
10
|
+
question: zod_1.z.string().describe("The question exactly as a user would ask it"),
|
|
11
|
+
mustRetrieve: zod_1.z.array(zod_1.z.string()).describe("Distinctive text snippets a correct answer must be grounded in"),
|
|
12
|
+
rubric: zod_1.z.string().describe("What a correct answer must assert, in one or two sentences"),
|
|
13
|
+
scopeId: zod_1.z.string().optional().describe("Scope root id when the turn is scope-confined"),
|
|
14
|
+
scopeType: zod_1.z.string().optional().describe("JSON:API type of the scope root"),
|
|
15
|
+
scopeLabel: zod_1.z
|
|
16
|
+
.string()
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("Neo4j label of the scope root, e.g. 'Campaign'. Required whenever scopeId is set: the scope guard needs the label, and deriving it would pull the graph catalog into the runner."),
|
|
19
|
+
});
|
|
20
|
+
exports.evalQuestionSetSchema = zod_1.z.object({
|
|
21
|
+
version: zod_1.z.literal(1),
|
|
22
|
+
product: zod_1.z.string().describe("Which product this set belongs to, e.g. 'a360ai'"),
|
|
23
|
+
questions: zod_1.z.array(exports.evalQuestionSchema).min(1),
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=retrieval-eval.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieval-eval.types.js","sourceRoot":"","sources":["../../../src/eval/retrieval/retrieval-eval.types.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,6BAAwB;AAExB,qFAAqF;AACxE,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;IACnE,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gEAAgE,CAAC;IAC7F,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;IAC5E,YAAY,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,gEAAgE,CAAC;IAC5G,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4DAA4D,CAAC;IACzF,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+CAA+C,CAAC;IACxF,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;IAC5E,UAAU,EAAE,OAAC;SACV,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,kLAAkL,CACnL;CACJ,CAAC,CAAC;AAGU,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACrB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kDAAkD,CAAC;IAChF,SAAS,EAAE,OAAC,CAAC,KAAK,CAAC,0BAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAC9C,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ChunkRepository } from "../../foundations/chunk/repositories/chunk.repository";
|
|
2
|
+
import { EvidenceMatcher } from "./evidence.matcher";
|
|
3
|
+
import { EvalQuestionSet, RetrievalSweepResult, SweepSummary } from "./retrieval-eval.types";
|
|
4
|
+
/**
|
|
5
|
+
* The fast inner loop: asks the retrieval layer what it WOULD read for each
|
|
6
|
+
* question and stops there. No answer is generated, so the only provider call
|
|
7
|
+
* is embedding the question.
|
|
8
|
+
*
|
|
9
|
+
* Questions run SEQUENTIALLY on purpose — `retrievalMs` is a reported metric and
|
|
10
|
+
* concurrency would make it meaningless (spec §6.3).
|
|
11
|
+
*/
|
|
12
|
+
export declare class RetrievalSweepService {
|
|
13
|
+
private readonly chunkRepository;
|
|
14
|
+
private readonly evidence;
|
|
15
|
+
private readonly logger;
|
|
16
|
+
constructor(chunkRepository: ChunkRepository, evidence: EvidenceMatcher);
|
|
17
|
+
/**
|
|
18
|
+
* SCOPE COMES FROM CLS, NOT FROM A PARAMETER.
|
|
19
|
+
*
|
|
20
|
+
* `ChunkRepository` reads company scope from `ClsService` (via
|
|
21
|
+
* `Neo4jService.initQuery`, which pulls `companyId`/`userId` off CLS) and the
|
|
22
|
+
* run's scope root from `AGENT_SCOPE_CLS_KEY`
|
|
23
|
+
* (`common/repositories/agent-scope.filter.ts`), which fails closed. A caller
|
|
24
|
+
* that does not establish that context retrieves nothing — or, worse,
|
|
25
|
+
* retrieves unscoped. The entry point is responsible for it; see
|
|
26
|
+
* apps/api/src/eval/run-sweep.ts.
|
|
27
|
+
*
|
|
28
|
+
* This is why `run` takes no companyId: accepting one would imply it is
|
|
29
|
+
* honoured here, and it is not.
|
|
30
|
+
*/
|
|
31
|
+
run(params: {
|
|
32
|
+
set: EvalQuestionSet;
|
|
33
|
+
}): Promise<SweepSummary<RetrievalSweepResult>>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=retrieval-sweep.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieval-sweep.service.d.ts","sourceRoot":"","sources":["../../../src/eval/retrieval/retrieval-sweep.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE7F;;;;;;;GAOG;AACH,qBACa,qBAAqB;IAI9B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAJ3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;gBAG9C,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,eAAe;IAG5C;;;;;;;;;;;;;OAaG;IACG,GAAG,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,eAAe,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC;CA0CzF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var RetrievalSweepService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.RetrievalSweepService = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const chunk_repository_1 = require("../../foundations/chunk/repositories/chunk.repository");
|
|
16
|
+
const evidence_matcher_1 = require("./evidence.matcher");
|
|
17
|
+
/**
|
|
18
|
+
* The fast inner loop: asks the retrieval layer what it WOULD read for each
|
|
19
|
+
* question and stops there. No answer is generated, so the only provider call
|
|
20
|
+
* is embedding the question.
|
|
21
|
+
*
|
|
22
|
+
* Questions run SEQUENTIALLY on purpose — `retrievalMs` is a reported metric and
|
|
23
|
+
* concurrency would make it meaningless (spec §6.3).
|
|
24
|
+
*/
|
|
25
|
+
let RetrievalSweepService = RetrievalSweepService_1 = class RetrievalSweepService {
|
|
26
|
+
constructor(chunkRepository, evidence) {
|
|
27
|
+
this.chunkRepository = chunkRepository;
|
|
28
|
+
this.evidence = evidence;
|
|
29
|
+
this.logger = new common_1.Logger(RetrievalSweepService_1.name);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* SCOPE COMES FROM CLS, NOT FROM A PARAMETER.
|
|
33
|
+
*
|
|
34
|
+
* `ChunkRepository` reads company scope from `ClsService` (via
|
|
35
|
+
* `Neo4jService.initQuery`, which pulls `companyId`/`userId` off CLS) and the
|
|
36
|
+
* run's scope root from `AGENT_SCOPE_CLS_KEY`
|
|
37
|
+
* (`common/repositories/agent-scope.filter.ts`), which fails closed. A caller
|
|
38
|
+
* that does not establish that context retrieves nothing — or, worse,
|
|
39
|
+
* retrieves unscoped. The entry point is responsible for it; see
|
|
40
|
+
* apps/api/src/eval/run-sweep.ts.
|
|
41
|
+
*
|
|
42
|
+
* This is why `run` takes no companyId: accepting one would imply it is
|
|
43
|
+
* honoured here, and it is not.
|
|
44
|
+
*/
|
|
45
|
+
async run(params) {
|
|
46
|
+
const startedAt = new Date().toISOString();
|
|
47
|
+
const results = [];
|
|
48
|
+
for (const question of params.set.questions) {
|
|
49
|
+
const began = Date.now();
|
|
50
|
+
try {
|
|
51
|
+
const chunks = await this.chunkRepository.findPotentialChunks({
|
|
52
|
+
question: question.question,
|
|
53
|
+
dataLimits: {},
|
|
54
|
+
});
|
|
55
|
+
const haystack = chunks.map((chunk) => chunk.content ?? "").join("\n\n");
|
|
56
|
+
const scored = this.evidence.score({ snippets: question.mustRetrieve, haystack });
|
|
57
|
+
results.push({
|
|
58
|
+
questionId: question.id,
|
|
59
|
+
evidenceRetrieved: scored.found,
|
|
60
|
+
missingSnippets: scored.missing,
|
|
61
|
+
chunksRead: chunks.length,
|
|
62
|
+
retrievalMs: Date.now() - began,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
67
|
+
this.logger.warn(`retrieval sweep: question ${question.id} failed: ${message}`);
|
|
68
|
+
results.push({
|
|
69
|
+
questionId: question.id,
|
|
70
|
+
evidenceRetrieved: 0,
|
|
71
|
+
missingSnippets: question.mustRetrieve,
|
|
72
|
+
chunksRead: 0,
|
|
73
|
+
retrievalMs: Date.now() - began,
|
|
74
|
+
error: message,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
product: params.set.product,
|
|
80
|
+
mode: "retrieval-only",
|
|
81
|
+
model: "n/a — retrieval only",
|
|
82
|
+
startedAt,
|
|
83
|
+
results,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.RetrievalSweepService = RetrievalSweepService;
|
|
88
|
+
exports.RetrievalSweepService = RetrievalSweepService = RetrievalSweepService_1 = __decorate([
|
|
89
|
+
(0, common_1.Injectable)(),
|
|
90
|
+
__metadata("design:paramtypes", [chunk_repository_1.ChunkRepository,
|
|
91
|
+
evidence_matcher_1.EvidenceMatcher])
|
|
92
|
+
], RetrievalSweepService);
|
|
93
|
+
//# sourceMappingURL=retrieval-sweep.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieval-sweep.service.js","sourceRoot":"","sources":["../../../src/eval/retrieval/retrieval-sweep.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,4FAAwF;AACxF,yDAAqD;AAGrD;;;;;;;GAOG;AAEI,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAGhC,YACmB,eAAgC,EAChC,QAAyB;QADzB,oBAAe,GAAf,eAAe,CAAiB;QAChC,aAAQ,GAAR,QAAQ,CAAiB;QAJ3B,WAAM,GAAG,IAAI,eAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;IAK9D,CAAC;IAEJ;;;;;;;;;;;;;OAaG;IACH,KAAK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E,CAAC,CAAC;gBAChF,OAAO,CAAC,IAAI,CAAC;oBACX,UAAU,EAAE,QAAQ,CAAC,EAAE;oBACvB,iBAAiB,EAAE,CAAC;oBACpB,eAAe,EAAE,QAAQ,CAAC,YAAY;oBACtC,UAAU,EAAE,CAAC;oBACb,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;oBAC/B,KAAK,EAAE,OAAO;iBACf,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO;YAC3B,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,sBAAsB;YAC7B,SAAS;YACT,OAAO;SACR,CAAC;IACJ,CAAC;CACF,CAAA;AAhEY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAKyB,kCAAe;QACtB,kCAAe;GALjC,qBAAqB,CAgEjC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { LLMService } from "../../core/llm/services/llm.service";
|
|
2
|
+
import { RubricVerdict } from "./retrieval-eval.types";
|
|
3
|
+
export declare const RUBRIC_JUDGE_PROMPT = "\nYou are grading one answer produced by a retrieval-augmented assistant.\n\nYou are given the user's question, a rubric stating what a correct answer MUST\nassert, the answer that was produced, and how many pieces of required evidence\nthe answer cited.\n\nDecide ONE thing: does the answer satisfy the rubric?\n\nJudge only against the rubric. Do not reward length, tone, formatting or\nconfidence. An answer that is well written but does not assert what the rubric\nrequires has failed. An answer that asserts what the rubric requires in plain\nlanguage has passed, even if it is terse.\n\nWhen the answer FAILS, classify why, choosing exactly one:\n\n- evidence-not-retrieved: the answer could not have been written because the\n required material never reached it. Typically the citation count is zero.\n- retrieved-but-unused: the required material was cited or is clearly present,\n and the answer still does not assert what the rubric requires.\n- contradicted-source: the answer asserts something that conflicts with the\n material it cites.\n- hedged-without-answering: the answer declines, defers, or describes what it\n would need, instead of answering.\n\nBe strict and be consistent. Your explanation must be one sentence naming the\nspecific rubric requirement that was met or missed.\n";
|
|
4
|
+
/**
|
|
5
|
+
* Grades one answer against its rubric.
|
|
6
|
+
*
|
|
7
|
+
* A judging failure degrades to a FAILED verdict for that question rather than
|
|
8
|
+
* killing the sweep — the graceful-degradation rule in 06-llm-calls.md rule 8,
|
|
9
|
+
* applied deliberately: an ungraded question must never silently count as a pass.
|
|
10
|
+
*
|
|
11
|
+
* ATTRIBUTION EXCEPTION (06-llm-calls.md rule 5). `tokenUsageType` and
|
|
12
|
+
* `metadata` are set, but `relationshipId` / `relationshipType` are deliberately
|
|
13
|
+
* absent: a sweep grades the harness itself, so there is no tenant entity whose
|
|
14
|
+
* spend this is. LLMService skips usage persistence unless BOTH are set, which
|
|
15
|
+
* is the intended outcome here — eval spend must not land on a customer's
|
|
16
|
+
* ledger. The call is still fully identifiable in dumps and telemetry through
|
|
17
|
+
* metadata.agentName / metadata.nodeName.
|
|
18
|
+
*/
|
|
19
|
+
export declare class RubricJudgeService {
|
|
20
|
+
private readonly llmService;
|
|
21
|
+
private readonly logger;
|
|
22
|
+
constructor(llmService: LLMService);
|
|
23
|
+
judge(params: {
|
|
24
|
+
question: string;
|
|
25
|
+
rubric: string;
|
|
26
|
+
answer: string;
|
|
27
|
+
evidenceCited: number;
|
|
28
|
+
}): Promise<RubricVerdict>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=rubric-judge.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rubric-judge.service.d.ts","sourceRoot":"","sources":["../../../src/eval/retrieval/rubric-judge.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAqB,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE1E,eAAO,MAAM,mBAAmB,8xCA2B/B,CAAC;AAoCF;;;;;;;;;;;;;;GAcG;AACH,qBACa,kBAAkB;IAGjB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAFvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;gBAEjC,UAAU,EAAE,UAAU;IAE7C,KAAK,CAAC,MAAM,EAAE;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,aAAa,EAAE,MAAM,CAAC;KACvB,GAAG,OAAO,CAAC,aAAa,CAAC;CAuC3B"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var RubricJudgeService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.RubricJudgeService = exports.RUBRIC_JUDGE_PROMPT = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const llm_service_1 = require("../../core/llm/services/llm.service");
|
|
17
|
+
exports.RUBRIC_JUDGE_PROMPT = `
|
|
18
|
+
You are grading one answer produced by a retrieval-augmented assistant.
|
|
19
|
+
|
|
20
|
+
You are given the user's question, a rubric stating what a correct answer MUST
|
|
21
|
+
assert, the answer that was produced, and how many pieces of required evidence
|
|
22
|
+
the answer cited.
|
|
23
|
+
|
|
24
|
+
Decide ONE thing: does the answer satisfy the rubric?
|
|
25
|
+
|
|
26
|
+
Judge only against the rubric. Do not reward length, tone, formatting or
|
|
27
|
+
confidence. An answer that is well written but does not assert what the rubric
|
|
28
|
+
requires has failed. An answer that asserts what the rubric requires in plain
|
|
29
|
+
language has passed, even if it is terse.
|
|
30
|
+
|
|
31
|
+
When the answer FAILS, classify why, choosing exactly one:
|
|
32
|
+
|
|
33
|
+
- evidence-not-retrieved: the answer could not have been written because the
|
|
34
|
+
required material never reached it. Typically the citation count is zero.
|
|
35
|
+
- retrieved-but-unused: the required material was cited or is clearly present,
|
|
36
|
+
and the answer still does not assert what the rubric requires.
|
|
37
|
+
- contradicted-source: the answer asserts something that conflicts with the
|
|
38
|
+
material it cites.
|
|
39
|
+
- hedged-without-answering: the answer declines, defers, or describes what it
|
|
40
|
+
would need, instead of answering.
|
|
41
|
+
|
|
42
|
+
Be strict and be consistent. Your explanation must be one sentence naming the
|
|
43
|
+
specific rubric requirement that was met or missed.
|
|
44
|
+
`;
|
|
45
|
+
/**
|
|
46
|
+
* The closed set of failure modes (spec §6.5). Declared once so the schema the
|
|
47
|
+
* model is constrained to and the runtime guard below can never drift apart.
|
|
48
|
+
*/
|
|
49
|
+
const FAILURE_MODES = [
|
|
50
|
+
"evidence-not-retrieved",
|
|
51
|
+
"retrieved-but-unused",
|
|
52
|
+
"contradicted-source",
|
|
53
|
+
"hedged-without-answering",
|
|
54
|
+
];
|
|
55
|
+
const outputSchema = zod_1.z.object({
|
|
56
|
+
passed: zod_1.z.boolean().describe("True only if the answer asserts everything the rubric requires"),
|
|
57
|
+
failureMode: zod_1.z
|
|
58
|
+
.enum(FAILURE_MODES)
|
|
59
|
+
.optional()
|
|
60
|
+
.describe("Present if and only if passed is false. One of the four named modes, verbatim."),
|
|
61
|
+
explanation: zod_1.z.string().describe("One sentence naming the specific rubric requirement that was met or missed"),
|
|
62
|
+
});
|
|
63
|
+
const inputSchema = zod_1.z.object({
|
|
64
|
+
question: zod_1.z.string().describe("The user's question, verbatim"),
|
|
65
|
+
rubric: zod_1.z
|
|
66
|
+
.string()
|
|
67
|
+
.describe("BINDING CRITERION. What a correct answer must assert. Judge against this and nothing else."),
|
|
68
|
+
answer: zod_1.z.string().describe("The answer under test. Grade it; do not improve or continue it."),
|
|
69
|
+
evidenceCited: zod_1.z
|
|
70
|
+
.number()
|
|
71
|
+
.describe("How many required evidence snippets the answer cited. Zero suggests evidence-not-retrieved."),
|
|
72
|
+
});
|
|
73
|
+
const isFailureMode = (value) => typeof value === "string" && FAILURE_MODES.includes(value);
|
|
74
|
+
/**
|
|
75
|
+
* Grades one answer against its rubric.
|
|
76
|
+
*
|
|
77
|
+
* A judging failure degrades to a FAILED verdict for that question rather than
|
|
78
|
+
* killing the sweep — the graceful-degradation rule in 06-llm-calls.md rule 8,
|
|
79
|
+
* applied deliberately: an ungraded question must never silently count as a pass.
|
|
80
|
+
*
|
|
81
|
+
* ATTRIBUTION EXCEPTION (06-llm-calls.md rule 5). `tokenUsageType` and
|
|
82
|
+
* `metadata` are set, but `relationshipId` / `relationshipType` are deliberately
|
|
83
|
+
* absent: a sweep grades the harness itself, so there is no tenant entity whose
|
|
84
|
+
* spend this is. LLMService skips usage persistence unless BOTH are set, which
|
|
85
|
+
* is the intended outcome here — eval spend must not land on a customer's
|
|
86
|
+
* ledger. The call is still fully identifiable in dumps and telemetry through
|
|
87
|
+
* metadata.agentName / metadata.nodeName.
|
|
88
|
+
*/
|
|
89
|
+
let RubricJudgeService = RubricJudgeService_1 = class RubricJudgeService {
|
|
90
|
+
constructor(llmService) {
|
|
91
|
+
this.llmService = llmService;
|
|
92
|
+
this.logger = new common_1.Logger(RubricJudgeService_1.name);
|
|
93
|
+
}
|
|
94
|
+
async judge(params) {
|
|
95
|
+
try {
|
|
96
|
+
const response = await this.llmService.call({
|
|
97
|
+
inputSchema,
|
|
98
|
+
inputParams: {
|
|
99
|
+
question: params.question,
|
|
100
|
+
rubric: params.rubric,
|
|
101
|
+
answer: params.answer,
|
|
102
|
+
evidenceCited: params.evidenceCited,
|
|
103
|
+
},
|
|
104
|
+
outputSchema,
|
|
105
|
+
systemPrompts: [exports.RUBRIC_JUDGE_PROMPT],
|
|
106
|
+
// A grading pass is judgement, not creation: no sampling variance, so
|
|
107
|
+
// the same answer is graded the same way on every run.
|
|
108
|
+
temperature: 0,
|
|
109
|
+
// Deliberate for THIS call (06-llm-calls.md rule 6 / checkpoint step 5):
|
|
110
|
+
// stated here rather than inherited from the tier, so a deployment that
|
|
111
|
+
// retunes the default cannot silently change how the baseline is graded.
|
|
112
|
+
// "low" matches the model this baseline is measured on (gpt-5.6-luna).
|
|
113
|
+
reasoningEffort: "low",
|
|
114
|
+
tokenUsageType: "retrieval_eval",
|
|
115
|
+
metadata: { agentName: "retrieval-eval", nodeName: "rubric-judge" },
|
|
116
|
+
});
|
|
117
|
+
// The schema already constrains the model; this guard keeps the returned
|
|
118
|
+
// union honest even when the provider falls back to lenient parsing.
|
|
119
|
+
const failureMode = isFailureMode(response.failureMode) ? response.failureMode : undefined;
|
|
120
|
+
return {
|
|
121
|
+
passed: response.passed,
|
|
122
|
+
...(failureMode ? { failureMode } : {}),
|
|
123
|
+
explanation: response.explanation,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
128
|
+
this.logger.warn(`rubric judge failed, recording the question as failed: ${message}`);
|
|
129
|
+
return { passed: false, explanation: `Judge unavailable: ${message}` };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
exports.RubricJudgeService = RubricJudgeService;
|
|
134
|
+
exports.RubricJudgeService = RubricJudgeService = RubricJudgeService_1 = __decorate([
|
|
135
|
+
(0, common_1.Injectable)(),
|
|
136
|
+
__metadata("design:paramtypes", [llm_service_1.LLMService])
|
|
137
|
+
], RubricJudgeService);
|
|
138
|
+
//# sourceMappingURL=rubric-judge.service.js.map
|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AC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,0DAA0D,OAAO,EAAE,CAAC,CAAC;YACtF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,sBAAsB,OAAO,EAAE,EAAE,CAAC;QACzE,CAAC;IACH,CAAC;CACF,CAAA;AAjDY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;qCAI8B,wBAAU;GAHxC,kBAAkB,CAiD9B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RetrievalSweepResult, SweepSummary } from "./retrieval-eval.types";
|
|
2
|
+
/**
|
|
3
|
+
* Renders a sweep to markdown, leading with the number that decides whether a
|
|
4
|
+
* change ships.
|
|
5
|
+
*
|
|
6
|
+
* A token-accounting mismatch is rendered as a banner, not a column: a sweep
|
|
7
|
+
* whose own arithmetic does not close cannot be used as a baseline, and that
|
|
8
|
+
* must not be discoverable only by reading a table.
|
|
9
|
+
*/
|
|
10
|
+
export declare function renderSweepReport(summary: SweepSummary<RetrievalSweepResult>): string;
|
|
11
|
+
//# sourceMappingURL=sweep-report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sweep-report.d.ts","sourceRoot":"","sources":["../../../src/eval/retrieval/sweep-report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,oBAAoB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AASjG;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,CAAC,oBAAoB,CAAC,GAAG,MAAM,CA8ErF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderSweepReport = renderSweepReport;
|
|
4
|
+
const isEndToEnd = (result) => result.verdict !== undefined;
|
|
5
|
+
/** Total `mustRetrieve` snippets for the question — same denominator `evidenceRetrieved` uses. */
|
|
6
|
+
const questionSnippetTotal = (result) => result.evidenceRetrieved + result.missingSnippets.length;
|
|
7
|
+
/**
|
|
8
|
+
* Renders a sweep to markdown, leading with the number that decides whether a
|
|
9
|
+
* change ships.
|
|
10
|
+
*
|
|
11
|
+
* A token-accounting mismatch is rendered as a banner, not a column: a sweep
|
|
12
|
+
* whose own arithmetic does not close cannot be used as a baseline, and that
|
|
13
|
+
* must not be discoverable only by reading a table.
|
|
14
|
+
*/
|
|
15
|
+
function renderSweepReport(summary) {
|
|
16
|
+
const lines = [];
|
|
17
|
+
const graded = summary.results.filter(isEndToEnd);
|
|
18
|
+
const passed = graded.filter((result) => result.verdict.passed).length;
|
|
19
|
+
lines.push(`# Retrieval sweep — ${summary.product} (${summary.mode})`);
|
|
20
|
+
lines.push("");
|
|
21
|
+
lines.push(`Model \`${summary.model}\` · started ${summary.startedAt}`);
|
|
22
|
+
lines.push("");
|
|
23
|
+
// `checked &&` on purpose: a question whose turn never completed carries
|
|
24
|
+
// `checked: false, agrees: false`, and it is already reported as a failure
|
|
25
|
+
// below. Counting it here too would announce a token mismatch that was never
|
|
26
|
+
// measured and cast doubt on a sweep whose arithmetic is fine.
|
|
27
|
+
const mismatched = graded.filter((result) => result.tokenAccounting.checked && !result.tokenAccounting.agrees);
|
|
28
|
+
if (mismatched.length > 0) {
|
|
29
|
+
lines.push(`> **TOKEN ACCOUNTING MISMATCH on ${mismatched.length} question(s).**`);
|
|
30
|
+
lines.push("> This sweep cannot be used as a baseline until the discrepancy is explained.");
|
|
31
|
+
for (const result of mismatched) {
|
|
32
|
+
lines.push(`> \`${result.questionId}\`: reported ${result.tokenAccounting.ledgerInput}/` +
|
|
33
|
+
`${result.tokenAccounting.ledgerOutput}, observed ` +
|
|
34
|
+
`${result.tokenAccounting.observedInput}/${result.tokenAccounting.observedOutput}`);
|
|
35
|
+
}
|
|
36
|
+
lines.push("");
|
|
37
|
+
}
|
|
38
|
+
if (graded.length > 0) {
|
|
39
|
+
const totalMustRetrieve = graded.reduce((sum, result) => sum + questionSnippetTotal(result), 0);
|
|
40
|
+
const totalEvidenceRead = graded.reduce((sum, result) => sum + result.evidenceRead, 0);
|
|
41
|
+
lines.push(`**Rubric passes: ${passed}/${graded.length}** · evidence read ${totalEvidenceRead}/${totalMustRetrieve}`);
|
|
42
|
+
lines.push("");
|
|
43
|
+
lines.push("| Question | Verdict | Failure mode | Evidence retrieved | Evidence read | Evidence cited | Chunks | Chunks kept | Chunks kept core | Tokens in/out | Answer ms |");
|
|
44
|
+
lines.push("|---|---|---|---:|---:|---:|---:|---:|---:|---:|---:|");
|
|
45
|
+
for (const result of graded) {
|
|
46
|
+
lines.push(`| \`${result.questionId}\` | ${result.verdict.passed ? "pass" : "**fail**"} | ` +
|
|
47
|
+
`${result.verdict.failureMode ?? "—"} | ` +
|
|
48
|
+
`${result.evidenceRetrieved}/${result.evidenceRetrieved + result.missingSnippets.length} | ` +
|
|
49
|
+
`${result.readObserved ? `${result.evidenceRead}/${questionSnippetTotal(result)}` : "n/a"} | ` +
|
|
50
|
+
`${result.evidenceCited}/${result.evidenceCited + result.uncitedSnippets.length} | ` +
|
|
51
|
+
`${result.chunksRead} | ${result.chunksKept} | ${result.chunksKeptCore} | ${result.inputTokens}/${result.outputTokens} | ${result.answerMs} |`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
lines.push("| Question | Evidence retrieved | Chunks | Retrieval ms |");
|
|
56
|
+
lines.push("|---|---:|---:|---:|");
|
|
57
|
+
for (const result of summary.results) {
|
|
58
|
+
lines.push(`| \`${result.questionId}\` | ` +
|
|
59
|
+
`${result.evidenceRetrieved}/${result.evidenceRetrieved + result.missingSnippets.length} | ` +
|
|
60
|
+
`${result.chunksRead} | ${result.retrievalMs} |`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const failures = graded.filter((result) => !result.verdict.passed);
|
|
64
|
+
if (failures.length > 0) {
|
|
65
|
+
lines.push("");
|
|
66
|
+
lines.push("## Failures");
|
|
67
|
+
for (const result of failures) {
|
|
68
|
+
lines.push("");
|
|
69
|
+
lines.push(`### \`${result.questionId}\` — ${result.verdict.failureMode ?? "ungraded"}`);
|
|
70
|
+
lines.push(result.verdict.explanation);
|
|
71
|
+
if (result.missingSnippets.length > 0) {
|
|
72
|
+
lines.push("");
|
|
73
|
+
lines.push(`Never retrieved: ${result.missingSnippets.map((s) => `"${s}"`).join(", ")}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return lines.join("\n");
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=sweep-report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sweep-report.js","sourceRoot":"","sources":["../../../src/eval/retrieval/sweep-report.ts"],"names":[],"mappings":";;AAiBA,8CA8EC;AA7FD,MAAM,UAAU,GAAG,CAAC,MAA4B,EAAiC,EAAE,CAChF,MAA8B,CAAC,OAAO,KAAK,SAAS,CAAC;AAExD,kGAAkG;AAClG,MAAM,oBAAoB,GAAG,CAAC,MAA2B,EAAU,EAAE,CACnE,MAAM,CAAC,iBAAiB,GAAG,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC;AAE3D;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAAC,OAA2C;IAC3E,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;IAEvE,KAAK,CAAC,IAAI,CAAC,uBAAuB,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;IACvE,KAAK,CA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AED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TokenAccountingCheck } from "./retrieval-eval.types";
|
|
2
|
+
/**
|
|
3
|
+
* Cross-checks a turn's reported token aggregate against the sum of the calls
|
|
4
|
+
* actually observed for it.
|
|
5
|
+
*
|
|
6
|
+
* Spec §6.5. The `2C + A` reducer bug inflated every archived chat figure and
|
|
7
|
+
* went unnoticed for a full measurement cycle; this check is what makes the
|
|
8
|
+
* same class of bug loud instead of silent. Provider-reported per-call figures
|
|
9
|
+
* are the source of truth.
|
|
10
|
+
*/
|
|
11
|
+
export declare class TokenAccountingChecker {
|
|
12
|
+
private readonly logger;
|
|
13
|
+
private observedInput;
|
|
14
|
+
private observedOutput;
|
|
15
|
+
/** Record one provider call's reported usage for the question in flight. */
|
|
16
|
+
observe(params: {
|
|
17
|
+
input: number;
|
|
18
|
+
output: number;
|
|
19
|
+
}): void;
|
|
20
|
+
/**
|
|
21
|
+
* Clears the accumulator WITHOUT producing a verdict.
|
|
22
|
+
*
|
|
23
|
+
* For the question that never completed a turn: it has nothing to compare, but
|
|
24
|
+
* it may still have deposited observations before it threw. Leaving them in
|
|
25
|
+
* place attributes them to the NEXT question — which either invents a mismatch
|
|
26
|
+
* that is not there or, worse, masks one that is. `check()` resets as a side
|
|
27
|
+
* effect of comparing; this is the same reset for the path that cannot compare.
|
|
28
|
+
*/
|
|
29
|
+
reset(): void;
|
|
30
|
+
/** Compare and RESET, so the next question starts clean. */
|
|
31
|
+
check(params: {
|
|
32
|
+
questionId: string;
|
|
33
|
+
ledger: {
|
|
34
|
+
input: number;
|
|
35
|
+
output: number;
|
|
36
|
+
};
|
|
37
|
+
}): TokenAccountingCheck;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=token-accounting.check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-accounting.check.d.ts","sourceRoot":"","sources":["../../../src/eval/retrieval/token-accounting.check.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAK9D;;;;;;;;GAQG;AACH,qBACa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAClE,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,cAAc,CAAK;IAE3B,4EAA4E;IAC5E,OAAO,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAKxD;;;;;;;;OAQG;IACH,KAAK,IAAI,IAAI;IAKb,4DAA4D;IAC5D,KAAK,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,GAAG,oBAAoB;CA2BvG"}
|