feat(confidence-engine): synthesize restored findings

This commit is contained in:
2026-08-31 08:18:44 +01:00
parent addec52461
commit 989b88a4a1
3 changed files with 223 additions and 11 deletions
+39
View File
@@ -2971,3 +2971,42 @@ to be determined
#### Exact first trace question
How does the reconstructed Current Understanding from synthesis reach the ScenarioForm state on cold return without re-fetching or losing narrative continuity?
### RESTORE synthesis trigger CLOSED (v0.50.4)
- `components/scenario-form.jsx` — `updateFindingDisposition` now triggers `synthesizeFromFindings` on both:
- `not_relevant → null` (Restore)
- `eligible → not_relevant` (Not Relevant) — pre-existing, preserved as regression guard
- Same explicit-next-state pattern: derive `nextFindings` from local state → `setFindings(() => nextFindings)` → gate synthesis on completed canonical eligibility transition → `synthesizeFromFindings(fetch, { situationGraph: currentGraph, findings: normalizeFindings(nextFindings) })` → replaces CU on success; no fallback/approach on failure
**Changes:**
- `updateFindingDisposition` (line 267): derives `nextFindings` explicitly from local `findings` array → calls `setFindings(() => nextFindings)` → determines `previousDisposition` from the finding being updated → triggers synthesis when eligibility set changes (`not_relevant → null` OR `eligible → not_relevant`) → on success, replaces CU with reconstruction; on failure, preserves restored Finding and previous CU
- No roll-back of Restore because narrative projection failed
- `null → null` no-op produces zero synthesis calls
**Deterministic gate:**
- Finding trigger tests: 36/36 PASS (original 24 + correction 5 + not_relevant 6 + restore 5 + regression 1)
- synthesis seam + route: 54/54 PASS
- build: PASS
**Trigger contract:**
- `not_relevant → null` synthesis calls: **1** ✅
- `null → null` synthesis calls: **0** ✅
- Restored Finding retained in payload with disposition `null` ✅
- Finding.id preserved ✅
- proposition preserved ✅
- sourceObservation preserved ✅
- Other Findings preserved ✅
- Previous CU NOT sent as synthesis input ✅
- Restore remains canonical on synthesis failure ✅
- Previous CU preserved on synthesis failure ✅
- No automatic retry ✅
- No legacy append fallback ✅
- Not Relevant regression (eligible → not_relevant): 1 synthesis call ✅
**Live runtime:**
- One eligible Finding → clicked "not relevant" (1 synthesis, HTTP 200)
- Same Finding → clicked "restore" (1 synthesis, HTTP 200)
- Finding visibly returned to normal state ("not relevant" button restored)
- Current Understanding visibly replaced with new reconstruction text
- Same Finding remains at same position