From 9a5617632369780e13151dfe8cec9a5958560041 Mon Sep 17 00:00:00 2001 From: robbond Date: Wed, 30 Sep 2026 17:05:47 +0100 Subject: [PATCH] fix(confidence-engine): supply overview-specific output schema to generateReconstruction synthesizeInvestigationOverview() called provider.generateReconstruction(prompt, modelName) without an output contract. Without a structured-output schema the provider defaults to its initial-reconstruction format which lacks { understanding, plausibleInterpretations }, causing 'Missing or invalid required fields' validation failure. Add overviewOutputSchema (JSON-schema matching validateOverviewResponse contract) and pass as third argument, matching the proven pattern in synthesizeCurrentUnderstanding(). 53/53 tests PASS. Co-Authored-By: Claude Code --- docs/current-handoff.md | 1 + lib/graph/investigation-overview-synthesis.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/docs/current-handoff.md b/docs/current-handoff.md index f3f3398..17d3411 100644 --- a/docs/current-handoff.md +++ b/docs/current-handoff.md @@ -391,6 +391,7 @@ RAW USER EVIDENCE - `synthesizeInvestigationOverview()` previously passed the full provider envelope (`{ response: { understanding, plausibleInterpretations }, providerApiPath, providerExecution }`) directly into `validateOverviewResponse()`, which expected only `{ understanding, plausibleInterpretations }`. This caused "Missing or invalid required fields" on real providers. - Fix now unwraps `.response` before overview validation, matching the proven pattern in `lib/graph/current-understanding-synthesis.js` (line 296: `validateSynthesisResponse(providerResult.response)`). +- **Additional fix:** `synthesizeInvestigationOverview()` previously called `provider.generateReconstruction(prompt, modelName)` without an output schema, while `synthesizeCurrentUnderstanding()` passes `synthesisOutputSchema`. Without a structured-output contract the provider defaults to initial-reconstruction format, which lacks `{ understanding, plausibleInterpretations }`, causing validation failure. Fix adds `overviewOutputSchema` (JSON-schema: `{ understanding: string, plausibleInterpretations: string }`) and passes it as third argument. - Owning regression (`tests/graph/investigation-overview-synthesis.test.js`) now mirrors real provider envelope shape (`{ response: { understanding, plausibleInterpretations }, providerApiPath }`). Regression fails against pre-fix seam and passes after fix. - Canonical overview live helper `scripts/overview-experiment-helper.cjs` established with deterministic no-network self-test (zero live calls). Product-launch zero-Findings fixture reaches successful overview synthesis in deterministic mode. 53/53 overview tests pass. - **Zero live proof yet.** Zero live calls made in this handoff. diff --git a/lib/graph/investigation-overview-synthesis.js b/lib/graph/investigation-overview-synthesis.js index c597601..a60451a 100644 --- a/lib/graph/investigation-overview-synthesis.js +++ b/lib/graph/investigation-overview-synthesis.js @@ -31,6 +31,16 @@ const overviewResponseSchema = z.object({ plausibleInterpretations: z.string().min(1), }); +const overviewOutputSchema = { + type: "object", + properties: { + understanding: { type: "string" }, + plausibleInterpretations: { type: "string" }, + }, + required: ["understanding", "plausibleInterpretations"], + additionalProperties: false, +}; + const FORBIDDEN_FIELD_NAMES = new Set([ "recommendation", "decision", @@ -245,6 +255,7 @@ export async function synthesizeInvestigationOverview(params, deps) { providerResult = await provider.generateReconstruction( prompt, modelName, + overviewOutputSchema, ); } catch (err) { throw new Error(`Overview synthesis provider call failed: ${err.message}`);