fix(confidence-engine): expose reconstruction validation issues
This commit is contained in:
@@ -192,6 +192,54 @@ describe("analyseScenario compatibility", () => {
|
||||
expect(result.nextQuestion).toBeUndefined();
|
||||
});
|
||||
|
||||
it("preserves nested validation issues and complete raw output on reconstruction failure", async () => {
|
||||
mockGenerateReconstruction.mockResolvedValue({
|
||||
inputClassification: {
|
||||
primaryType: "unexplained_change",
|
||||
secondaryTypes: [],
|
||||
reasoningModes: [],
|
||||
classificationReason: "reason",
|
||||
confidence: "medium",
|
||||
},
|
||||
reconstruction: {
|
||||
summary: "summary",
|
||||
actors: [],
|
||||
systemsOrObjects: [],
|
||||
expectedStates: [],
|
||||
observedStates: [{ id: "obs-1", confidence: "high" }],
|
||||
differences: [],
|
||||
knownTransitions: [],
|
||||
unexplainedTransitions: [],
|
||||
contradictions: [],
|
||||
importantUnknowns: [],
|
||||
plausibleInterpretations: [],
|
||||
padding: "x".repeat(2500),
|
||||
},
|
||||
evidence: [],
|
||||
nextQuestion: {
|
||||
id: "q1",
|
||||
question: "What changed?",
|
||||
targets: [],
|
||||
reason: "reason",
|
||||
expectedInformationValue: "high",
|
||||
},
|
||||
});
|
||||
|
||||
const { analyseScenario } = await import("@/lib/analysis.js");
|
||||
const result = await analyseScenario("Scenario text", {
|
||||
promptVersion: "v0.3",
|
||||
});
|
||||
|
||||
expect(result.success).toBe(false);
|
||||
expect(result.rawResponse.length).toBeGreaterThan(2000);
|
||||
expect(result.validationIssues).toContainEqual(expect.objectContaining({
|
||||
path: ["reconstruction", "observedStates", 0, "description"],
|
||||
code: "invalid_type",
|
||||
message: "Required",
|
||||
}));
|
||||
expect(result.errors).toContain("reconstruction: Required");
|
||||
});
|
||||
|
||||
it("succeeds when reported_claim is the only evidenceType mismatch", async () => {
|
||||
mockGenerateReconstruction.mockResolvedValue({
|
||||
inputClassification: {
|
||||
|
||||
Reference in New Issue
Block a user