feat(confidence-engine): add focused finding handoff plumbing
This commit is contained in:
@@ -30,6 +30,7 @@ import {
|
||||
selectActiveUnknownCandidate,
|
||||
validateGraphReferences,
|
||||
} from "./utils.js";
|
||||
import { validateFindings } from "./finding-helpers.js";
|
||||
|
||||
function toValidationErrors(error) {
|
||||
return (
|
||||
@@ -596,7 +597,7 @@ async function updateCaseWithDependencies(body, dependencies = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
const { situationGraph, previousQuestion, answer, promptVersion } =
|
||||
const { situationGraph, previousQuestion, answer, promptVersion, findings: incomingFindings } =
|
||||
parsedRequest.data;
|
||||
|
||||
const graphSchemaValidation = situationGraphSchema.safeParse(situationGraph);
|
||||
@@ -825,6 +826,33 @@ async function updateCaseWithDependencies(body, dependencies = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
// ── v2: process incoming findings (no graph mutation) ────
|
||||
let appendedFindings = [];
|
||||
|
||||
if (incomingFindings && Array.isArray(incomingFindings) && incomingFindings.length > 0) {
|
||||
const validated = validateFindings(incomingFindings);
|
||||
|
||||
// Filter out rejected findings for display only — do NOT modify currentSummary.
|
||||
// Direct concatenation of Finding text into Current Understanding would bypass
|
||||
// the authoritative case/update reasoning that evaluates Finding context.
|
||||
// Per v1 handoff contract: "Noted as not directly relevant" and similar markers
|
||||
// are display-only; they must never be appended to summary or graph state.
|
||||
const validForDisplay = validated.findings.filter((f) => f.evaluation !== "rejected");
|
||||
|
||||
// Normalize and include approved findings in the response (display passthrough)
|
||||
const normalized = validForDisplay.map((f) => ({
|
||||
id: f.id,
|
||||
proposition: f.proposition,
|
||||
status: f.status,
|
||||
userDisposition: f.userDisposition,
|
||||
originatingTargetNodeId: f.originatingTargetNodeId,
|
||||
contributionId: f.contributionId,
|
||||
sourceObservation: f.sourceObservation,
|
||||
createdAt: f.createdAt,
|
||||
}));
|
||||
appendedFindings = normalized;
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
stage: "update_applied",
|
||||
@@ -837,6 +865,8 @@ async function updateCaseWithDependencies(body, dependencies = {}) {
|
||||
applicationResult.previousActiveUnknownNodeId,
|
||||
newActiveUnknownNodeId: applicationResult.newActiveUnknownNodeId,
|
||||
changesApplied: applicationResult.changesApplied,
|
||||
appendedFindings,
|
||||
summary: applicationResult.updatedSituationGraph?.currentSummary ?? "",
|
||||
diagnostics: buildUpdateDiagnostics({
|
||||
promptVersion,
|
||||
modelName,
|
||||
|
||||
Reference in New Issue
Block a user