fix(confidence-engine): unwrap focused deconstruction response

This commit is contained in:
2026-09-06 14:47:23 +01:00
parent a0f90e8885
commit 188dd04ab9
3 changed files with 116 additions and 36 deletions
@@ -52,11 +52,14 @@ export async function POST(request) {
const provider = getProvider();
const startedAt = Date.now();
const raw = await provider.generateReconstruction(prompt, process.env.OLLAMA_MODEL);
const wrapper = await provider.generateReconstruction(prompt, process.env.OLLAMA_MODEL);
const elapsedMs = Date.now() - startedAt;
// Unwrap the semantic deconstruction from the provider envelope.
const deconstruction = wrapper.response;
// Validate schema (required fields present, no graph-mutation fields)
const validationErrors = validateFocusedDeconstructSchema(raw);
const validationErrors = validateFocusedDeconstructSchema(deconstruction);
if (validationErrors.length > 0) {
return Response.json(
{
@@ -73,11 +76,11 @@ export async function POST(request) {
return Response.json({
success: true,
targetNodeId: body.targetNodeId,
observations: raw.observations,
uncertainties: raw.uncertainties,
assumptions: raw.assumptions,
relationships: raw.relationships,
possibleFollowUpQuestions: raw.possibleFollowUpQuestions,
observations: deconstruction.observations,
uncertainties: deconstruction.uncertainties,
assumptions: deconstruction.assumptions,
relationships: deconstruction.relationships,
possibleFollowUpQuestions: deconstruction.possibleFollowUpQuestions,
elapsedMs,
});
} catch (e) {