@actuarial-ts/agents 0.1.0 → 0.3.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/README.md +4 -2
- package/dist/advisor.d.ts +2 -1
- package/dist/advisor.d.ts.map +1 -1
- package/dist/advisor.js +3 -1
- package/dist/advisor.js.map +1 -1
- package/dist/divergence.d.ts +267 -0
- package/dist/divergence.d.ts.map +1 -0
- package/dist/divergence.js +414 -0
- package/dist/divergence.js.map +1 -0
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +20 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/judgment.d.ts +26 -0
- package/dist/judgment.d.ts.map +1 -1
- package/dist/judgment.js +21 -0
- package/dist/judgment.js.map +1 -1
- package/dist/mcp.d.ts +165 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +155 -0
- package/dist/mcp.js.map +1 -0
- package/dist/promotion.d.ts +295 -0
- package/dist/promotion.d.ts.map +1 -0
- package/dist/promotion.js +824 -0
- package/dist/promotion.js.map +1 -0
- package/dist/remote.d.ts +221 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +295 -0
- package/dist/remote.js.map +1 -0
- package/dist/tools.d.ts +87 -6
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +182 -15
- package/dist/tools.js.map +1 -1
- package/package.json +11 -4
- package/src/advisor.ts +141 -0
- package/src/divergence.ts +642 -0
- package/src/errors.ts +62 -0
- package/src/evals.ts +162 -0
- package/src/index.ts +9 -0
- package/src/judgment.ts +458 -0
- package/src/mcp.ts +274 -0
- package/src/promotion.ts +1240 -0
- package/src/remote.ts +371 -0
- package/src/tools.ts +561 -0
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Divergence explainer (interchange spec rev 2.1, Section 9 item 3): the
|
|
3
|
+
* agent invoked ONLY when the deterministic referee returns verdict
|
|
4
|
+
* "disagree". It never re-judges the comparison - the referee's verdict is
|
|
5
|
+
* final - it produces a structured HYPOTHESIS about why two engines diverged
|
|
6
|
+
* ("engine b requested sigma_interpolation=log-linear; the mack1993-vw
|
|
7
|
+
* profile requires mack; expected signature: SE-concentrated deviations -
|
|
8
|
+
* observed"), for the reviewing actuary to act on.
|
|
9
|
+
*
|
|
10
|
+
* Architecture decisions (each is load-bearing):
|
|
11
|
+
*
|
|
12
|
+
* - EVIDENCE ASSEMBLY IS PURE AND DETERMINISTIC. assembleDivergenceEvidence
|
|
13
|
+
* is a pure function of (CrosscheckReportDoc, MethodResultDoc a,
|
|
14
|
+
* MethodResultDoc b) plus the interchange profile registry - no clock, no
|
|
15
|
+
* randomness, no I/O. The convention map travels AS DATA: the alignment
|
|
16
|
+
* requirements are imported from @actuarial-ts/interchange's
|
|
17
|
+
* CONVENTION_PROFILES (the executable form of docs/interop/
|
|
18
|
+
* convention-map.md), never re-read from a file. Identical inputs yield
|
|
19
|
+
* identical evidence and an identical prompt, so the fixture tests can
|
|
20
|
+
* assert exactly what any model would be shown.
|
|
21
|
+
*
|
|
22
|
+
* - ONLY-ON-DISAGREE IS STRUCTURAL. A report whose verdict is not
|
|
23
|
+
* "disagree" throws AgentsError("VERDICT_NOT_DISAGREE") at assembly time;
|
|
24
|
+
* there is no flag to loosen. Agreement needs no explaining, and running
|
|
25
|
+
* an explainer on an agree/verified-by-value report would manufacture
|
|
26
|
+
* doubt about a comparison the referee already settled.
|
|
27
|
+
*
|
|
28
|
+
* - VIOLATIONS SURFACE FIRST. The requirement-by-requirement alignment
|
|
29
|
+
* check orders findings violated > unverifiable > satisfied, so the most
|
|
30
|
+
* probable root cause (a profile requirement the engine visibly did not
|
|
31
|
+
* run) is the first thing both the model and the human read.
|
|
32
|
+
*
|
|
33
|
+
* - READ-ONLY BY CONSTRUCTION. The explainer gets exactly one tool, and it
|
|
34
|
+
* only returns the already-assembled evidence (carried on the
|
|
35
|
+
* RequestContext under DIVERGENCE_EVIDENCE_CONTEXT_KEY); there is no
|
|
36
|
+
* action tool to reach for. The prompt also embeds the full evidence, so
|
|
37
|
+
* a single generate call suffices and the tool exists for follow-up
|
|
38
|
+
* turns, not as a required hop.
|
|
39
|
+
*
|
|
40
|
+
* HOUSE GOTCHA honored: no literal backtick characters in instruction
|
|
41
|
+
* content (a backtick inside a template literal once broke server boot).
|
|
42
|
+
*/
|
|
43
|
+
import { Agent } from "@mastra/core/agent";
|
|
44
|
+
import { RequestContext } from "@mastra/core/request-context";
|
|
45
|
+
import { ReservingError } from "@actuarial-ts/core";
|
|
46
|
+
import { CONVENTION_PROFILES, crosscheckReportDocSchema, methodResultDocSchema, } from "@actuarial-ts/interchange";
|
|
47
|
+
import { z } from "zod";
|
|
48
|
+
import { AgentsError } from "./errors.js";
|
|
49
|
+
import { defineActuarialTool, toolRegistry } from "./tools.js";
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// Evidence assembly (pure)
|
|
52
|
+
function stableJson(value) {
|
|
53
|
+
return value === undefined ? "(absent)" : JSON.stringify(value);
|
|
54
|
+
}
|
|
55
|
+
function sameValue(x, y) {
|
|
56
|
+
return x === y || JSON.stringify(x) === JSON.stringify(y);
|
|
57
|
+
}
|
|
58
|
+
function validateDoc(label, doc, schema) {
|
|
59
|
+
const parsed = schema.safeParse(doc);
|
|
60
|
+
if (!parsed.success) {
|
|
61
|
+
throw new ReservingError("BAD_INTERCHANGE", `assembleDivergenceEvidence input "${label}" is malformed: ${parsed
|
|
62
|
+
.error.issues.map((i) => `${i.path.join(".") || "$"}: ${i.message}`)
|
|
63
|
+
.join("; ")}`);
|
|
64
|
+
}
|
|
65
|
+
return parsed.data;
|
|
66
|
+
}
|
|
67
|
+
function engineMatches(doc, stamp) {
|
|
68
|
+
return doc.result.engine.name === stamp.name && doc.result.engine.version === stamp.version;
|
|
69
|
+
}
|
|
70
|
+
const STATUS_RANK = {
|
|
71
|
+
violated: 0,
|
|
72
|
+
unverifiable: 1,
|
|
73
|
+
satisfied: 2,
|
|
74
|
+
};
|
|
75
|
+
function alignmentFindingsFor(side, doc, profile, claimedProfileId) {
|
|
76
|
+
const engineName = doc.result.engine.name;
|
|
77
|
+
if (profile === null) {
|
|
78
|
+
return [
|
|
79
|
+
{
|
|
80
|
+
engine: side,
|
|
81
|
+
engineName,
|
|
82
|
+
parameter: "*",
|
|
83
|
+
required: undefined,
|
|
84
|
+
requested: undefined,
|
|
85
|
+
effective: undefined,
|
|
86
|
+
status: "unverifiable",
|
|
87
|
+
detail: claimedProfileId === null
|
|
88
|
+
? `engine ${side} (${engineName}): no convention profile is claimed on either result, so ` +
|
|
89
|
+
"no alignment requirements exist to check against"
|
|
90
|
+
: `engine ${side} (${engineName}): claimed profile "${claimedProfileId}" is not in the ` +
|
|
91
|
+
"interchange profile registry; its requirements cannot be checked",
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
const alignment = profile.alignment[engineName] ?? null;
|
|
96
|
+
if (alignment === null) {
|
|
97
|
+
return [
|
|
98
|
+
{
|
|
99
|
+
engine: side,
|
|
100
|
+
engineName,
|
|
101
|
+
parameter: "*",
|
|
102
|
+
required: undefined,
|
|
103
|
+
requested: undefined,
|
|
104
|
+
effective: undefined,
|
|
105
|
+
status: "unverifiable",
|
|
106
|
+
detail: `engine ${side} (${engineName}): profile "${profile.id}" has no alignment entry for ` +
|
|
107
|
+
"this engine name; its requirements cannot be checked",
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
const requestedParams = doc.result.parameters;
|
|
112
|
+
const effectiveParams = doc.result.effectiveParameters;
|
|
113
|
+
const findings = [];
|
|
114
|
+
for (const [parameter, required] of Object.entries(alignment.parameters)) {
|
|
115
|
+
const requested = requestedParams[parameter];
|
|
116
|
+
const effective = effectiveParams?.[parameter];
|
|
117
|
+
const ran = effective !== undefined ? effective : requested;
|
|
118
|
+
const base = {
|
|
119
|
+
engine: side,
|
|
120
|
+
engineName,
|
|
121
|
+
parameter,
|
|
122
|
+
required,
|
|
123
|
+
requested,
|
|
124
|
+
effective,
|
|
125
|
+
};
|
|
126
|
+
if (ran === undefined) {
|
|
127
|
+
findings.push({
|
|
128
|
+
...base,
|
|
129
|
+
status: "unverifiable",
|
|
130
|
+
detail: `engine ${side} (${engineName}) parameter "${parameter}": profile "${profile.id}" requires ` +
|
|
131
|
+
`${stableJson(required)}, but the result records no such parameter (a prose requirement or ` +
|
|
132
|
+
"an unrecorded setting); not mechanically checkable",
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
else if (sameValue(required, ran)) {
|
|
136
|
+
findings.push({
|
|
137
|
+
...base,
|
|
138
|
+
status: "satisfied",
|
|
139
|
+
detail: `engine ${side} (${engineName}) parameter "${parameter}": profile "${profile.id}" requires ` +
|
|
140
|
+
`${stableJson(required)}; the engine ran ${stableJson(ran)}`,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
const deviationNote = effective !== undefined && !sameValue(effective, requested)
|
|
145
|
+
? ` (requested ${stableJson(requested)}, effective ${stableJson(effective)})`
|
|
146
|
+
: "";
|
|
147
|
+
findings.push({
|
|
148
|
+
...base,
|
|
149
|
+
status: "violated",
|
|
150
|
+
detail: `VIOLATED: profile "${profile.id}" requires ${parameter}=${stableJson(required)} for ` +
|
|
151
|
+
`${engineName}; engine ${side} ran ${parameter}=${stableJson(ran)}${deviationNote}`,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return findings;
|
|
156
|
+
}
|
|
157
|
+
function deviationSignatureOf(report) {
|
|
158
|
+
const body = report.report;
|
|
159
|
+
const tolerance = {
|
|
160
|
+
central: body.tolerance.central,
|
|
161
|
+
standardError: body.tolerance.standardError,
|
|
162
|
+
};
|
|
163
|
+
let maxCentral = 0;
|
|
164
|
+
let maxSe = null;
|
|
165
|
+
const ranked = [];
|
|
166
|
+
for (const row of body.deviations.perOrigin) {
|
|
167
|
+
for (const metric of ["ultimate", "unpaid"]) {
|
|
168
|
+
const deviation = row[metric];
|
|
169
|
+
if (deviation === null)
|
|
170
|
+
continue;
|
|
171
|
+
maxCentral = Math.max(maxCentral, deviation);
|
|
172
|
+
ranked.push({ origin: row.origin, metric, deviation });
|
|
173
|
+
}
|
|
174
|
+
if (row.standardError !== null) {
|
|
175
|
+
maxSe = Math.max(maxSe ?? 0, row.standardError);
|
|
176
|
+
ranked.push({ origin: row.origin, metric: "standardError", deviation: row.standardError });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const totals = body.deviations.totals;
|
|
180
|
+
for (const metric of ["ultimate", "unpaid"]) {
|
|
181
|
+
const deviation = totals[metric];
|
|
182
|
+
if (deviation !== null)
|
|
183
|
+
maxCentral = Math.max(maxCentral, deviation);
|
|
184
|
+
}
|
|
185
|
+
if (totals.standardError !== null)
|
|
186
|
+
maxSe = Math.max(maxSe ?? 0, totals.standardError);
|
|
187
|
+
const centralExceeds = maxCentral > tolerance.central;
|
|
188
|
+
const seExceeds = tolerance.standardError !== null && maxSe !== null && maxSe > tolerance.standardError;
|
|
189
|
+
const concentration = centralExceeds && seExceeds
|
|
190
|
+
? "mixed"
|
|
191
|
+
: centralExceeds
|
|
192
|
+
? "central"
|
|
193
|
+
: seExceeds
|
|
194
|
+
? "standard-error"
|
|
195
|
+
: "none";
|
|
196
|
+
ranked.sort((x, y) => y.deviation - x.deviation);
|
|
197
|
+
return {
|
|
198
|
+
tolerance,
|
|
199
|
+
maxCentral,
|
|
200
|
+
maxStandardError: maxSe,
|
|
201
|
+
centralExceedsTolerance: centralExceeds,
|
|
202
|
+
standardErrorExceedsTolerance: seExceeds,
|
|
203
|
+
concentration,
|
|
204
|
+
totals: {
|
|
205
|
+
ultimate: totals.ultimate,
|
|
206
|
+
unpaid: totals.unpaid,
|
|
207
|
+
standardError: totals.standardError,
|
|
208
|
+
},
|
|
209
|
+
worstOrigins: ranked.slice(0, 5),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Assembles the divergence evidence for a disagree crosscheck: pure and
|
|
214
|
+
* deterministic (see the module doc). Throws:
|
|
215
|
+
* - AgentsError("VERDICT_NOT_DISAGREE") when the report's verdict is not
|
|
216
|
+
* "disagree" - the only-on-disagree rule is structural, not advisory;
|
|
217
|
+
* - AgentsError("DIVERGENCE_INPUT_MISMATCH") when the supplied result docs
|
|
218
|
+
* do not match the report's engine stamps (wrong docs, or a/b swapped);
|
|
219
|
+
* - ReservingError("BAD_INTERCHANGE") when any input document is malformed.
|
|
220
|
+
*/
|
|
221
|
+
export function assembleDivergenceEvidence(options) {
|
|
222
|
+
const report = validateDoc("report", options.report, crosscheckReportDocSchema);
|
|
223
|
+
const a = validateDoc("a", options.a, methodResultDocSchema);
|
|
224
|
+
const b = validateDoc("b", options.b, methodResultDocSchema);
|
|
225
|
+
const body = report.report;
|
|
226
|
+
if (body.verdict !== "disagree") {
|
|
227
|
+
throw new AgentsError("VERDICT_NOT_DISAGREE", `The divergence explainer is invoked ONLY on a "disagree" crosscheck verdict (spec 9 item 3); ` +
|
|
228
|
+
`this report's verdict is "${body.verdict}" - there is no divergence to explain`);
|
|
229
|
+
}
|
|
230
|
+
if (!engineMatches(a, body.engines.a) || !engineMatches(b, body.engines.b)) {
|
|
231
|
+
const swapped = engineMatches(a, body.engines.b) && engineMatches(b, body.engines.a);
|
|
232
|
+
throw new AgentsError("DIVERGENCE_INPUT_MISMATCH", swapped
|
|
233
|
+
? "The supplied result docs are SWAPPED relative to the report: doc a matches the report's " +
|
|
234
|
+
"engine b and vice versa; pass them in the report's a/b order"
|
|
235
|
+
: `The supplied result docs do not match the report's engine stamps: report compared ` +
|
|
236
|
+
`a=${body.engines.a.name}@${body.engines.a.version} vs ` +
|
|
237
|
+
`b=${body.engines.b.name}@${body.engines.b.version}, got ` +
|
|
238
|
+
`a=${a.result.engine.name}@${a.result.engine.version} and ` +
|
|
239
|
+
`b=${b.result.engine.name}@${b.result.engine.version}`);
|
|
240
|
+
}
|
|
241
|
+
const claimedProfileId = a.result.engine.conventionProfile ?? b.result.engine.conventionProfile ?? null;
|
|
242
|
+
const profile = claimedProfileId !== null ? (CONVENTION_PROFILES[claimedProfileId] ?? null) : null;
|
|
243
|
+
const engineEvidenceOf = (doc) => ({
|
|
244
|
+
name: doc.result.engine.name,
|
|
245
|
+
version: doc.result.engine.version,
|
|
246
|
+
conventionProfile: doc.result.engine.conventionProfile ?? null,
|
|
247
|
+
method: doc.result.method,
|
|
248
|
+
requested: doc.result.parameters,
|
|
249
|
+
effective: doc.result.effectiveParameters ?? null,
|
|
250
|
+
profileAlignment: profile === null
|
|
251
|
+
? null
|
|
252
|
+
: (profile.alignment[doc.result.engine.name] ?? null),
|
|
253
|
+
});
|
|
254
|
+
const findings = [
|
|
255
|
+
...alignmentFindingsFor("a", a, profile, claimedProfileId),
|
|
256
|
+
...alignmentFindingsFor("b", b, profile, claimedProfileId),
|
|
257
|
+
].sort((x, y) => STATUS_RANK[x.status] - STATUS_RANK[y.status]);
|
|
258
|
+
return {
|
|
259
|
+
verdict: "disagree",
|
|
260
|
+
profile: {
|
|
261
|
+
id: claimedProfileId,
|
|
262
|
+
known: profile !== null,
|
|
263
|
+
description: profile?.description ?? null,
|
|
264
|
+
tolerance: profile !== null ? { ...profile.tolerance } : null,
|
|
265
|
+
},
|
|
266
|
+
alignmentFindings: findings,
|
|
267
|
+
engines: { a: engineEvidenceOf(a), b: engineEvidenceOf(b) },
|
|
268
|
+
deviationSignature: deviationSignatureOf(report),
|
|
269
|
+
warnings: {
|
|
270
|
+
report: [...body.warnings],
|
|
271
|
+
engineA: [...(a.result.warnings ?? [])],
|
|
272
|
+
engineB: [...(b.result.warnings ?? [])],
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
// ---------------------------------------------------------------------------
|
|
277
|
+
// Structured hypothesis
|
|
278
|
+
/** The explainer's structured output (spec 9 item 3). */
|
|
279
|
+
export const divergenceHypothesisSchema = z.object({
|
|
280
|
+
/** The single most probable root cause, stated as a testable claim. */
|
|
281
|
+
suspectedCause: z.string().min(1),
|
|
282
|
+
/** The exact misaligned parameter/flag name (e.g. "sigma_interpolation"),
|
|
283
|
+
* or null when no specific flag is implicated. */
|
|
284
|
+
misalignedFlag: z.string().min(1).nullable(),
|
|
285
|
+
/** The deviation signature the suspected cause WOULD produce. */
|
|
286
|
+
expectedSignature: z.string().min(1),
|
|
287
|
+
/** The deviation signature the evidence actually shows. */
|
|
288
|
+
observedSignature: z.string().min(1),
|
|
289
|
+
/** What the operator should do next to confirm or fix. */
|
|
290
|
+
recommendation: z.string().min(1),
|
|
291
|
+
});
|
|
292
|
+
// ---------------------------------------------------------------------------
|
|
293
|
+
// Instructions + prompt assembly (pure, deterministic)
|
|
294
|
+
/** RequestContext key the evidence tool reads (set by explainDivergence). */
|
|
295
|
+
export const DIVERGENCE_EVIDENCE_CONTEXT_KEY = "divergenceEvidence";
|
|
296
|
+
/**
|
|
297
|
+
* The explainer's instruction template. A constant, not a builder: the
|
|
298
|
+
* explainer has exactly one job and no host-specific domain sections. No
|
|
299
|
+
* backtick characters (house gotcha).
|
|
300
|
+
*/
|
|
301
|
+
export const DIVERGENCE_EXPLAINER_INSTRUCTIONS = [
|
|
302
|
+
"You are a cross-engine divergence diagnostician inside an actuarial reserving toolchain. A deterministic referee compared the same computation run by two independent engines and returned the verdict \"disagree\". Your job is to produce a structured HYPOTHESIS about the root cause - you never re-litigate the verdict, and you never change any state.",
|
|
303
|
+
"## Working rules",
|
|
304
|
+
[
|
|
305
|
+
"1. Every claim you make must come from the supplied divergence evidence (in the user message, and available again via the get_divergence_evidence tool). Never invent parameters, deviations, or profile requirements.",
|
|
306
|
+
"2. The alignment findings are ordered violations first. A VIOLATED finding - a convention-profile requirement the engine visibly did not run - is the strongest root-cause candidate; check whether its expected deviation signature matches the observed one before settling on it.",
|
|
307
|
+
"3. The deviation signature tells you WHERE the disagreement lives: central estimates (ultimates/unpaid), standard errors, or both. A sigma/variance-convention misalignment concentrates in standard errors while central estimates agree; a factor/selection misalignment moves central estimates.",
|
|
308
|
+
"4. In misalignedFlag, name the exact parameter as it appears in the evidence (for example sigma_interpolation), or use null when no specific flag is implicated.",
|
|
309
|
+
"5. Be direct and technical; the reader is a credentialed actuary. State the hypothesis, the expected vs observed signature, and one concrete next step.",
|
|
310
|
+
].join("\n"),
|
|
311
|
+
].join("\n\n");
|
|
312
|
+
/**
|
|
313
|
+
* Deterministic user-prompt assembly: a readable summary (violations first,
|
|
314
|
+
* then the deviation signature) followed by the full evidence as JSON.
|
|
315
|
+
* Identical evidence yields a byte-identical prompt, so tests can pin
|
|
316
|
+
* exactly what any model is shown.
|
|
317
|
+
*/
|
|
318
|
+
export function assembleDivergencePrompt(evidence) {
|
|
319
|
+
const sig = evidence.deviationSignature;
|
|
320
|
+
const profileLine = evidence.profile.id === null
|
|
321
|
+
? "Convention profile: none claimed."
|
|
322
|
+
: `Convention profile: "${evidence.profile.id}"${evidence.profile.known ? "" : " (NOT in the registry)"} - ${evidence.profile.description ?? "no description"}`;
|
|
323
|
+
const findingLines = evidence.alignmentFindings.map((f) => `- [${f.status.toUpperCase()}] ${f.detail}`);
|
|
324
|
+
const seLine = sig.maxStandardError === null
|
|
325
|
+
? "standard errors: not compared"
|
|
326
|
+
: `max standard-error deviation ${sig.maxStandardError} (tolerance ${sig.tolerance.standardError ?? "out of scope"}; ${sig.standardErrorExceedsTolerance ? "EXCEEDED" : "within"})`;
|
|
327
|
+
const sections = [
|
|
328
|
+
"A crosscheck referee compared two engines running the same computation and returned verdict DISAGREE.",
|
|
329
|
+
`Engine a: ${evidence.engines.a.name}@${evidence.engines.a.version} (method ${evidence.engines.a.method}). ` +
|
|
330
|
+
`Engine b: ${evidence.engines.b.name}@${evidence.engines.b.version} (method ${evidence.engines.b.method}).`,
|
|
331
|
+
profileLine,
|
|
332
|
+
"Alignment findings (violations first):\n" + findingLines.join("\n"),
|
|
333
|
+
`Deviation signature: concentration ${sig.concentration}; max central deviation ${sig.maxCentral} ` +
|
|
334
|
+
`(tolerance ${sig.tolerance.central}; ${sig.centralExceedsTolerance ? "EXCEEDED" : "within"}); ${seLine}.`,
|
|
335
|
+
"Full assembled evidence (JSON):\n" + JSON.stringify(evidence, null, 2),
|
|
336
|
+
"Produce the structured hypothesis: suspectedCause, misalignedFlag (the exact parameter name, or null), expectedSignature, observedSignature, recommendation.",
|
|
337
|
+
];
|
|
338
|
+
return sections.join("\n\n");
|
|
339
|
+
}
|
|
340
|
+
// ---------------------------------------------------------------------------
|
|
341
|
+
// The read-only evidence tool
|
|
342
|
+
/**
|
|
343
|
+
* The explainer's single tool: returns the already-assembled evidence from
|
|
344
|
+
* the request context. Read-only by construction - it can only restate what
|
|
345
|
+
* explainDivergence assembled; there is nothing to mutate.
|
|
346
|
+
*/
|
|
347
|
+
export function createDivergenceEvidenceTool() {
|
|
348
|
+
return defineActuarialTool({
|
|
349
|
+
id: "get_divergence_evidence",
|
|
350
|
+
description: "Returns the assembled divergence evidence for the disagree crosscheck under review: " +
|
|
351
|
+
"convention-profile alignment requirements, each engine's requested vs effective parameters, " +
|
|
352
|
+
"requirement-by-requirement findings (violations first), the deviation signature, and all " +
|
|
353
|
+
"warnings. Read-only.",
|
|
354
|
+
kind: "read",
|
|
355
|
+
inputSchema: z.object({}),
|
|
356
|
+
// Tenant-free BY DESIGN: this tool restates divergence evidence the host
|
|
357
|
+
// already assembled and injected into the request context via
|
|
358
|
+
// explainDivergence. There is no per-tenant data path to protect — the
|
|
359
|
+
// evidence is scoped by the host before this tool can see it.
|
|
360
|
+
tenant: "none",
|
|
361
|
+
execute: async (_input, _tenant, context) => {
|
|
362
|
+
const evidence = context.requestContext?.get(DIVERGENCE_EVIDENCE_CONTEXT_KEY);
|
|
363
|
+
if (evidence === undefined) {
|
|
364
|
+
throw new AgentsError("NO_DIVERGENCE_EVIDENCE", `No assembled divergence evidence in the request context (key "${DIVERGENCE_EVIDENCE_CONTEXT_KEY}"); ` +
|
|
365
|
+
"drive this agent through explainDivergence, which assembles and injects it");
|
|
366
|
+
}
|
|
367
|
+
return { success: true, evidence: evidence };
|
|
368
|
+
},
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Builds the divergence-explainer Agent: the constant instruction template
|
|
373
|
+
* plus the single read-only evidence tool. Drive it with explainDivergence,
|
|
374
|
+
* which assembles the evidence, injects it into the request context, and
|
|
375
|
+
* runs the one structured-output generate call.
|
|
376
|
+
*/
|
|
377
|
+
export function createDivergenceExplainer(options) {
|
|
378
|
+
return new Agent({
|
|
379
|
+
id: options.id ?? "divergence-explainer",
|
|
380
|
+
name: options.name ?? "Divergence Explainer",
|
|
381
|
+
description: options.description ??
|
|
382
|
+
"Cross-engine divergence diagnostician: on a disagree crosscheck verdict, reads the assembled " +
|
|
383
|
+
"evidence (profile requirements, requested vs effective parameters, deviation signature) and " +
|
|
384
|
+
"produces a structured root-cause hypothesis. Read-only; never re-judges the referee.",
|
|
385
|
+
instructions: DIVERGENCE_EXPLAINER_INSTRUCTIONS,
|
|
386
|
+
model: options.model,
|
|
387
|
+
tools: toolRegistry([createDivergenceEvidenceTool()]).tools,
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Drives one structured-output generate call: assembles the evidence
|
|
392
|
+
* (throwing on a non-disagree verdict), injects it into the request context
|
|
393
|
+
* for the evidence tool, prompts the explainer, and zod-validates the
|
|
394
|
+
* model's hypothesis before returning it - the boundary is validated in
|
|
395
|
+
* both directions.
|
|
396
|
+
*/
|
|
397
|
+
export async function explainDivergence(options) {
|
|
398
|
+
const evidence = assembleDivergenceEvidence({
|
|
399
|
+
report: options.report,
|
|
400
|
+
a: options.a,
|
|
401
|
+
b: options.b,
|
|
402
|
+
});
|
|
403
|
+
const requestContext = options.requestContext ?? new RequestContext();
|
|
404
|
+
requestContext.set(DIVERGENCE_EVIDENCE_CONTEXT_KEY, evidence);
|
|
405
|
+
const prompt = assembleDivergencePrompt(evidence);
|
|
406
|
+
const result = await options.explainer.generate([{ role: "user", content: prompt }], {
|
|
407
|
+
structuredOutput: { schema: divergenceHypothesisSchema },
|
|
408
|
+
requestContext,
|
|
409
|
+
maxSteps: options.maxSteps ?? 4,
|
|
410
|
+
});
|
|
411
|
+
const hypothesis = divergenceHypothesisSchema.parse(result.object);
|
|
412
|
+
return { hypothesis, evidence, prompt };
|
|
413
|
+
}
|
|
414
|
+
//# sourceMappingURL=divergence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"divergence.js","sourceRoot":"","sources":["../src/divergence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,GAKtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAsF/D,8EAA8E;AAC9E,2BAA2B;AAE3B,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,SAAS,CAAC,CAAU,EAAE,CAAU;IACvC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAA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,CAAC,CAAC;KACb,CAAC,CAAC;IACH,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,IAAI,cAAc,EAAE,CAAC;IACtE,cAAc,CAAC,GAAG,CAAC,+BAA+B,EAAE,QAAQ,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE;QACnF,gBAAgB,EAAE,EAAE,MAAM,EAAE,0BAA0B,EAAE;QACxD,cAAc;QACd,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC;KAChC,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,0BAA0B,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC1C,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* thrown during tool execution into a { success: false, error } envelope.
|
|
11
11
|
*/
|
|
12
12
|
/** Every machine-readable code an AgentsError can carry. */
|
|
13
|
-
export declare const AGENTS_ERROR_CODES: readonly ["NO_TENANT_CONTEXT", "TENANT_IN_SCHEMA", "BAD_INPUT_SCHEMA", "BAD_GATE", "MISSING_RATIONALE", "DUPLICATE_TOOL_ID"];
|
|
13
|
+
export declare const AGENTS_ERROR_CODES: readonly ["NO_TENANT_CONTEXT", "TENANT_IN_SCHEMA", "BAD_INPUT_SCHEMA", "BAD_GATE", "MISSING_RATIONALE", "DUPLICATE_TOOL_ID", "BAD_PROMOTION_OPTIONS", "EMPTY_STUDY", "TOLERANCE_CEILING_EXCEEDED", "SEGMENT_UNRESOLVED", "SEGMENT_AMBIGUOUS", "VERDICT_NOT_DISAGREE", "DIVERGENCE_INPUT_MISMATCH", "NO_DIVERGENCE_EVIDENCE", "REMOTE_RESULT_INVALID", "MCP_SELF_TEST_FAILED"];
|
|
14
14
|
export type AgentsErrorCode = (typeof AGENTS_ERROR_CODES)[number];
|
|
15
15
|
/**
|
|
16
16
|
* Thrown for invalid agent-toolkit input: tenant-seam violations, malformed
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,4DAA4D;AAC5D,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,4DAA4D;AAC5D,eAAO,MAAM,kBAAkB,+WAgCrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;gBACnB,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM;CAKnD"}
|
package/dist/errors.js
CHANGED
|
@@ -22,6 +22,26 @@ export const AGENTS_ERROR_CODES = [
|
|
|
22
22
|
"MISSING_RATIONALE",
|
|
23
23
|
/** Two tools with the same id were passed to toolRegistry. */
|
|
24
24
|
"DUPLICATE_TOOL_ID",
|
|
25
|
+
/** promoteStudy was called with malformed deps/options (programmer error). */
|
|
26
|
+
"BAD_PROMOTION_OPTIONS",
|
|
27
|
+
/** A study document carries no selections; nothing to promote. */
|
|
28
|
+
"EMPTY_STUDY",
|
|
29
|
+
/** The study's stated replayTolerance exceeds the host ceiling (spec 6 Gate 1). */
|
|
30
|
+
"TOLERANCE_CEILING_EXCEEDED",
|
|
31
|
+
/** A selection's segment labels match no host workspace target (no fuzzy matching in v1). */
|
|
32
|
+
"SEGMENT_UNRESOLVED",
|
|
33
|
+
/** Two selections resolve to the same workspace target; v1 promotes one selection per segment. */
|
|
34
|
+
"SEGMENT_AMBIGUOUS",
|
|
35
|
+
/** The divergence explainer was invoked on a report whose verdict is not "disagree" (spec 9 item 3: only-on-disagree is structural). */
|
|
36
|
+
"VERDICT_NOT_DISAGREE",
|
|
37
|
+
/** The result docs handed to the divergence explainer do not match the crosscheck report's engine stamps (wrong docs, or a/b swapped). */
|
|
38
|
+
"DIVERGENCE_INPUT_MISMATCH",
|
|
39
|
+
/** The divergence evidence tool ran without assembled evidence in the request context (drive the agent through explainDivergence). */
|
|
40
|
+
"NO_DIVERGENCE_EVIDENCE",
|
|
41
|
+
/** A remote sidecar 2xx response failed interchange parseDocument (bad JSON, bad schema, broken integrity tag, or a non-result kind). */
|
|
42
|
+
"REMOTE_RESULT_INVALID",
|
|
43
|
+
/** The boot self-test found an MCP-exposed probe tool that did NOT fail closed without tenant context; the MCP tenant seam is not wired up and the server must abort startup. */
|
|
44
|
+
"MCP_SELF_TEST_FAILED",
|
|
25
45
|
];
|
|
26
46
|
/**
|
|
27
47
|
* Thrown for invalid agent-toolkit input: tenant-seam violations, malformed
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,sFAAsF;IACtF,mBAAmB;IACnB,sHAAsH;IACtH,kBAAkB;IAClB,kBAAkB;IAClB,2EAA2E;IAC3E,UAAU;IACV,iEAAiE;IACjE,mBAAmB;IACnB,8DAA8D;IAC9D,mBAAmB;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,sFAAsF;IACtF,mBAAmB;IACnB,sHAAsH;IACtH,kBAAkB;IAClB,kBAAkB;IAClB,2EAA2E;IAC3E,UAAU;IACV,iEAAiE;IACjE,mBAAmB;IACnB,8DAA8D;IAC9D,mBAAmB;IACnB,8EAA8E;IAC9E,uBAAuB;IACvB,kEAAkE;IAClE,aAAa;IACb,mFAAmF;IACnF,4BAA4B;IAC5B,6FAA6F;IAC7F,oBAAoB;IACpB,kGAAkG;IAClG,mBAAmB;IACnB,wIAAwI;IACxI,sBAAsB;IACtB,0IAA0I;IAC1I,2BAA2B;IAC3B,sIAAsI;IACtI,wBAAwB;IACxB,yIAAyI;IACzI,uBAAuB;IACvB,iLAAiL;IACjL,sBAAsB;CACd,CAAC;AAIX;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,IAAI,CAAkB;IAC/B,YAAY,IAAqB,EAAE,OAAe;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export * from "./errors.js";
|
|
2
2
|
export * from "./tools.js";
|
|
3
3
|
export * from "./judgment.js";
|
|
4
|
+
export * from "./promotion.js";
|
|
4
5
|
export * from "./advisor.js";
|
|
5
6
|
export * from "./evals.js";
|
|
7
|
+
export * from "./divergence.js";
|
|
8
|
+
export * from "./remote.js";
|
|
9
|
+
export * from "./mcp.js";
|
|
6
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export * from "./errors.js";
|
|
2
2
|
export * from "./tools.js";
|
|
3
3
|
export * from "./judgment.js";
|
|
4
|
+
export * from "./promotion.js";
|
|
4
5
|
export * from "./advisor.js";
|
|
5
6
|
export * from "./evals.js";
|
|
7
|
+
export * from "./divergence.js";
|
|
8
|
+
export * from "./remote.js";
|
|
9
|
+
export * from "./mcp.js";
|
|
6
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
package/dist/judgment.d.ts
CHANGED
|
@@ -37,12 +37,28 @@
|
|
|
37
37
|
import { createWorkflow } from "@mastra/core/workflows";
|
|
38
38
|
import { z } from "zod";
|
|
39
39
|
import { type AssumptionActor, type AssumptionLedger, type JsonValue } from "@actuarial-ts/compliance";
|
|
40
|
+
/**
|
|
41
|
+
* The request-context key a host sets (server-side, from its authenticated
|
|
42
|
+
* session — the same trust path as the tenant id) to identify WHO is resuming
|
|
43
|
+
* gates. The resume payload cannot supply it: a payload travels through
|
|
44
|
+
* model-reachable surfaces, and an identity that can be asserted from there
|
|
45
|
+
* is a claim, not a record.
|
|
46
|
+
*/
|
|
47
|
+
export declare const ACTOR_IDENTITY_CONTEXT_KEY = "actorIdentity";
|
|
40
48
|
/** One decision in the audit trail; skip gates record skipped: true. */
|
|
41
49
|
export interface JudgmentTrailEntry {
|
|
42
50
|
stage: string;
|
|
43
51
|
decision: string;
|
|
44
52
|
rationale: string;
|
|
45
53
|
skipped: boolean;
|
|
54
|
+
/** Coarse classification from the resume payload (default | actuary | agent). */
|
|
55
|
+
actor?: AssumptionActor;
|
|
56
|
+
/**
|
|
57
|
+
* The authenticated identity from the request context, when the host set
|
|
58
|
+
* one. Absent means the host supplied none — identity is never invented,
|
|
59
|
+
* and never read from the resume payload.
|
|
60
|
+
*/
|
|
61
|
+
actorIdentity?: string;
|
|
46
62
|
}
|
|
47
63
|
/**
|
|
48
64
|
* What earlier gates decided, keyed by gate id: the validated resume payload
|
|
@@ -151,16 +167,22 @@ declare const chainResultSchema: z.ZodObject<{
|
|
|
151
167
|
decision: z.ZodString;
|
|
152
168
|
rationale: z.ZodString;
|
|
153
169
|
skipped: z.ZodBoolean;
|
|
170
|
+
actor: z.ZodOptional<z.ZodEnum<["default", "actuary", "agent"]>>;
|
|
171
|
+
actorIdentity: z.ZodOptional<z.ZodString>;
|
|
154
172
|
}, "strip", z.ZodTypeAny, {
|
|
155
173
|
stage: string;
|
|
156
174
|
decision: string;
|
|
157
175
|
rationale: string;
|
|
158
176
|
skipped: boolean;
|
|
177
|
+
actor?: "default" | "agent" | "actuary" | undefined;
|
|
178
|
+
actorIdentity?: string | undefined;
|
|
159
179
|
}, {
|
|
160
180
|
stage: string;
|
|
161
181
|
decision: string;
|
|
162
182
|
rationale: string;
|
|
163
183
|
skipped: boolean;
|
|
184
|
+
actor?: "default" | "agent" | "actuary" | undefined;
|
|
185
|
+
actorIdentity?: string | undefined;
|
|
164
186
|
}>, "many">;
|
|
165
187
|
ledger: z.ZodType<AssumptionLedger, z.ZodTypeDef, AssumptionLedger>;
|
|
166
188
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -169,6 +191,8 @@ declare const chainResultSchema: z.ZodObject<{
|
|
|
169
191
|
decision: string;
|
|
170
192
|
rationale: string;
|
|
171
193
|
skipped: boolean;
|
|
194
|
+
actor?: "default" | "agent" | "actuary" | undefined;
|
|
195
|
+
actorIdentity?: string | undefined;
|
|
172
196
|
}[];
|
|
173
197
|
ledger: AssumptionLedger;
|
|
174
198
|
}, {
|
|
@@ -177,6 +201,8 @@ declare const chainResultSchema: z.ZodObject<{
|
|
|
177
201
|
decision: string;
|
|
178
202
|
rationale: string;
|
|
179
203
|
skipped: boolean;
|
|
204
|
+
actor?: "default" | "agent" | "actuary" | undefined;
|
|
205
|
+
actorIdentity?: string | undefined;
|
|
180
206
|
}[];
|
|
181
207
|
ledger: AssumptionLedger;
|
|
182
208
|
}>;
|
package/dist/judgment.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"judgment.d.ts","sourceRoot":"","sources":["../src/judgment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAc,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGL,KAAK,eAAe,EAEpB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACf,MAAM,0BAA0B,CAAC;AAOl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