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
+14
View File
@@ -1883,3 +1883,17 @@ The current handoff captures all operational facts needed to resume today. For h
| Task routing by work type | `docs/task-context-packs.md` |
| Broader architectural intent | `docs/architectural-principles.md` |
| Experiment history (specific) | `docs/design-evolution/README.md` → relevant chapter |
## focused-deconstruction 502 root cause and fix
**Root cause:** `/api/focused-investigation/deconstruct/route.js` passed the full provider envelope `{ response, providerApiPath, providerExecution }` from `generateReconstruction()` directly into `validateFocusedDeconstructSchema()`. The validator expects semantic fields (`targetNodeId`, `observations`, etc.) at the top level — those fields live on `wrapper.response`, not on the wrapper. All six focused-deconstruction fields appeared absent, producing a structured-output 502 on every call.
**Fix:** Route now extracts `const deconstruction = wrapper.response` and passes that inner object to both validation and response serialization. Provider diagnostics (`providerApiPath`, `providerExecution`) are preserved but do not interfere with semantic fields.
**Tests:** `tests/focused-deconstruct-boundary.test.js` mocks now reflect the real provider wrapper contract (inner deconstruction nested under `.response`). A new assertion verifies that provider envelope fields never leak into the API response. Five tests pass on first run; 48 focused-investigation-boundary tests pass.
**Previous two focused-deconstruction semantic runs remain invalid as semantic evidence.** They produced all-zero semantic fields because the defect prevented the model output from ever reaching the validator or the client.
**Next boundary:** rerun exactly one substantive compound-question answer-deconstruction observation through the corrected production route.
**Zero live model calls occurred during the fix.**