feat(confidence-engine): v0.60e route investigation identity

Migrate the Investigation page route to own durable investigation identity
via its route [id] segment, passing that ID through to ScenarioForm for
hydration and persistence.

- Remove hardcoded INVESTIGATION_ID constant from page.jsx
- Use params.id as routeId; loadInvestigation(routeId) loads by identity
- Pass investigationId prop into ScenarioForm in both branch paths
- Session restore calls loadInvestigation(investigationId)
- All 4 save call sites include id: investigationId in snapshot
- Missing identified Investigation starts clean (no singleton fallback)
- Legacy singleton is not migrated/fallback-loaded
- Portfolio remains unmigrated; Report remains unmigrated; Restart untouched

Deterministic tests: 34/34 pass (scenario-form-persistence + investigation-storage)
Build: PASS
Live Playwright: all criteria verified at /investigations/v060e-live
This commit is contained in:
2026-09-03 19:02:37 +01:00
parent 827411f254
commit 01e141aa66
3 changed files with 52 additions and 13 deletions
+36 -1
View File
@@ -381,7 +381,42 @@ Migrate existing application callers to the identity-aware contract signatures:
**Status:** UI/routes are **not** migrated. All existing callers continue via the singleton compatibility path (they call `saveInvestigation({ ... })` with no explicit second parameter, and their snapshots carry no `id` field). No production caller was modified in this increment.
**Next restart point:** Caller migration — update application consumers to pass investigation ID through save calls so canonical identity-aware semantics activate for all writes.
## v0.60e — Route-Owned Investigation Identity
**Purpose:** Migrate the Investigation page route to own durable investigation identity via its route `[id]` segment, passing that ID through to ScenarioForm for hydration and persistence without migrating legacy singleton data or changing Portfolio/Report behaviour.
### What was implemented
| File | Change |
|---|---|
| `app/investigations/[id]/page.jsx` | Removed hardcoded `INVESTIGATION_ID = "case-1"` constant; route `[id]` param extracted as `routeId` via `params.id`; `loadInvestigation(routeId)` loads by route identity; `investigationId={routeId}` passed to ScenarioForm in both branch paths; report navigation uses `routeId`. |
| `components/scenario-form.jsx` | Added `investigationId` prop; session restore calls `loadInvestigation(investigationId)` when provided; all 4 save call sites include `id: investigationId` in snapshot (autosave effect, start-case submit, update-case submit, report overview autosave). |
### Contract crossings verified by deterministic test
- **Owning test files:** `tests/storage/scenario-form-persistence.test.js` (11 tests) + `tests/storage/investigation-storage.test.js` (23 tests, including v0.60d canonical identity section)
- All 34 tests pass on first run; no reruns required
### Verified behaviour
- Route ID is passed from `[id]/page.jsx` into ScenarioForm as `investigationId`: **YES**
- Missing identified Investigation (`loadInvestigation("v060e-live")` → null) starts clean: **YES**
- Legacy singleton fallback used: **NO** — no backward-compat load was needed; the route ID was absent from storage
- First meaningful saved snapshot carries route ID: **YES** (all 4 save sites inject `id: investigationId`)
- Subsequent save identity preserved: **YES** (storage layer uses `snapshot.id` as sole identity authority)
- Storage provider changed: **NO** — only `investigation-storage.js` wrapper, already-proved in v0.60d
### Portfolio
Not migrated. `app/page.jsx` retains hardcoded `INVESTIGATION_ID = "case-1"`. Create New navigation to a durable-ID route is later work.
### Report
Not migrated. `app/investigations/[id]/report/page.jsx` untouched. Remains a later caller migration increment.
### Restart
Untouched in this increment. All `clearInvestigation()` calls remain without an id argument (legacy singleton path). If identity-aware restart is needed, the next increment should pass `investigationId` through those clear calls.
## Next implementation boundary