feat(confidence-engine): establish current understanding synthesis seam

This commit is contained in:
2026-08-30 18:48:38 +01:00
parent 00ba343ed9
commit ff1119b4d5
5 changed files with 953 additions and 15 deletions
+51 -15
View File
@@ -2761,27 +2761,63 @@ defect has been reduced to a defined reconstruction problem.
Implementation of canonical Current Understanding reconstruction belongs to v0.50.
### v0.50 — NEXT BOUNDARY
## v0.50 — STANDALONE SYNTHESIS SEAM (2026-08-30)
The first bounded question for the next branch:
### Closed boundaries
> **What minimal synthesis API/helper boundary should own the dedicated `SituationGraph + eligible Findings → Current Understanding` LLM operation?**
**Standalone synthesis seam implemented.**
Do not answer that question in this task.
- **Domain function:** `lib/graph/current-understanding-synthesis.js`
- `filterEligibleFindings()` — eligibility contract: null/agree eligible; not_quite/not_relevant/rejected excluded
- `buildSynthesisPrompt()` — full SituationGraph (nodes + edges + centralStatement) + eligible Findings
- `synthesizeCurrentUnderstanding()` — DI-driven provider call, narrative-only output
- `validateSynthesisResponse()` / `synthesisResponseSchema` — zod schema for `{ currentUnderstanding }`
Subsequent v0.50 work will need to resolve:
- **API route:** `app/api/cases/synthesis/route.js` — `POST /api/cases/synthesis`, thin parse → invoke → return pattern
1. synthesis API/helper ownership
2. deterministic input normalization / eligible-Finding selection
3. synthesis prompt/schema contract
4. completed-transition integration points
5. removal/replacement of append semantics
6. retirement of Done-for-now CU promotion
7. reload/cache freshness strategy
8. targeted deterministic + live behavioural verification
- **Domain seam ownership:**
- ScenarioForm → WHEN synthesis occurs (NOT wired; untouched in this increment)
- This module → HOW canonical state becomes narrative
- Provider → generation via DI (default provider + test injection pattern)
This is a roadmap, not permission to implement all of it at once.
v0.50 must continue using bounded increments.
- **Eligibility filtering inside domain seam:**
- `null` → eligible (accepted-by-default, provisional working interpretation)
- `agree` → eligible (confirmed evidence)
- `not_quite` → excluded until corrected proposition saved
- `not_relevant` → excluded (discounted from active reasoning)
- `evaluation: "rejected"` → excluded
- **Full SituationGraph + canonical Findings input** — not just centralStatement; nodes and edges included
- **narrative-only output** — `{ currentUnderstanding }` string; no graph/Finding mutation
- **52 targeted tests passing:**
- `tests/graph/current-understanding-synthesis.test.js` — 40/40
- `tests/app/api/current-understanding-synthesis-route.test.js` — 12/12
- **Build result:** clean production build
- **No ScenarioForm trigger integration yet** — wire-in in a future increment.
### Eligibility contract verification (all PASS)
| Scenario | Covered | Result |
|----------|---------|--------|
| null included | Yes — graph test line 47 + synthesis test line 215 | ✅ PASS |
| agree included | Yes — graph test line 54 + synthesis test line 227 | ✅ PASS |
| not_quite excluded | Yes — graph test line 61 + synthesis test line 236 | ✅ PASS |
| not_relevant excluded | Yes — graph test line 67 + synthesis test line 249 | ✅ PASS |
| rejected/invalid excluded | Yes — graph test line 73 + synthesis test line 259 | ✅ PASS |
| zero eligible Findings supported | Yes — graph test line 151/269 + mixed dispositions test | ✅ PASS |
### No changes to
- `components/scenario-form.jsx`
- `components/reasoning-workspace.jsx`
- `app/api/cases/update/route.js`
- Done-for-now code
- storage
- focused workspace
---