test(confidence-engine): expose CU synthesis failure shape

This commit is contained in:
2026-10-07 06:59:43 +01:00
parent d6dbc17bdf
commit 0b84f8ad28
3 changed files with 274 additions and 7 deletions
+18 -5
View File
@@ -432,16 +432,26 @@ async function composeDeepInvestigationCheckpoint({ situationGraph, previousQues
const postEpisodeFindings = [...priorFindings, ...newFindingsFromContributions, ...accumulatedEpisodes];
let currentUnderstanding = null;
let synthesisErrorDiagnostic = null;
if (episodeResult.success && updatedGraph) {
// Reuse the same provider/model plumbing — no re-creation, just reuse
const { synthesizeCurrentUnderstanding } = await import("../../lib/graph/current-understanding-synthesis.js");
const synthesized = await synthesizeCurrentUnderstanding(
{ situationGraph: updatedGraph, findings: postEpisodeFindings },
{ provider: timedProvider, modelName: model },
);
try {
const synthesized = await synthesizeCurrentUnderstanding(
{ situationGraph: updatedGraph, findings: postEpisodeFindings },
{ provider: timedProvider, modelName: model },
);
currentUnderstanding = synthesized?.currentUnderstanding ?? null;
currentUnderstanding = synthesized?.currentUnderstanding ?? null;
} catch (synthErr) {
// Expose the safe structural diagnostic from synthesis validation failure
if (synthErr?.sanitizedDiagnostic) {
synthesisErrorDiagnostic = synthErr.sanitizedDiagnostic;
}
currentUnderstanding = null;
}
}
// Consistent graphCheckpoint for both success and failure paths
@@ -487,6 +497,9 @@ async function composeDeepInvestigationCheckpoint({ situationGraph, previousQues
providerGenerateCalls,
modelName: episodeResult.modelName ?? null,
/* ── CU synthesis error diagnostic (NEW — safe structural shape on validation failure) ─── */
synthesisErrorDiagnostic,
/* ── Answer meaning (from production result) ─── */
userSupportedMeaning: episodeResult?.proposal?.answerMeaning?.userSupportedMeaning ?? null,
possibleInference: episodeResult?.proposal?.answerMeaning?.possibleInference ?? null,