feat(confidence-engine): v0.60g1 list investigation summaries
Recover to clean v0.60f then implement only the storage listing contract. - Add listInvestigations() to provider: enumerate by prefix, project lightweight summary (id, scenario, updatedAt, investigationRevision, reportExists, reportGeneratedFromRevision), sort by updatedAt desc - Add application-facing wrapper in investigation-storage.js - Add 8 deterministic tests covering all listing invariants (coexistence, correct IDs, lightweight projection, legacy exclusion, unrelated exclusion, independent update, ordering, malformed skip) - Fix MockStorageMap WebStorage API compatibility (.length + .key(i)) - Portfolio NOT migrated — that is v0.60g2
This commit is contained in:
+52
-1
@@ -461,7 +461,58 @@ Untouched in this increment. All `clearInvestigation()` calls remain without an
|
||||
|
||||
Next increment: migrate Portfolio card links ("Continue investigation", "View report") to use the first existing Investigation's durable ID — or migrate Portfolio to `listInvestigations()` with the four-operation storage contract. Do not proceed until both are addressed.
|
||||
|
||||
## Next implementation boundary
|
||||
## v0.60g1 — List Investigation Summaries
|
||||
|
||||
**Purpose:** The previous v0.60g stalled attempt was discarded. This increment cleanly implements only the `listInvestigations()` storage contract: durable-ID listing returning lightweight summaries, excluding legacy/unrelated state.
|
||||
|
||||
### What was implemented
|
||||
|
||||
| File | Change |
|
||||
|---|---|
|
||||
| `lib/storage/providers/local-storage.js` | Added `listInvestigations()` — enumerates provider records by prefix match, parses each record, projects lightweight summary (explicitly excludes situationGraph, findings, investigationReport), sorts by updatedAt descending |
|
||||
| `lib/storage/investigation-storage.js` | Imported and re-exported `listInvestigations` as the application-facing public API |
|
||||
| `tests/storage/investigation-storage.test.js` | 8 new deterministic tests covering all listing invariants; fixed MockStorageMap to implement `.length` and `.key(i)` for WebStorage API compatibility |
|
||||
|
||||
### Listing contract details
|
||||
|
||||
- **Operation:** `listInvestigations()` — no arguments, returns `InvestigationSummary[]`
|
||||
- **Summary fields (explicitly projected):** `id`, `scenario`, `updatedAt`, `investigationRevision`, `reportExists`, `reportGeneratedFromRevision`
|
||||
- **Excluded fields:** situationGraph, findings, full investigationReport, reasoning history, Open Questions, graph nodes
|
||||
- **Records included:** only keys matching `INVESTIGATION_PREFIX` (durable-ID entries)
|
||||
- **Records excluded:** legacy singleton (`confidence-engine-investigation`), sessionStorage state, unrelated keys, malformed entries
|
||||
- **Ordering:** updatedAt descending (most recent first); deterministic fallback by id for equal timestamps
|
||||
- **Malformed handling:** skip silently — one malformed entry never blocks valid records
|
||||
|
||||
### Deterministic test evidence (8 tests, all pass on first run)
|
||||
|
||||
| Invariant | Result |
|
||||
|---|---|
|
||||
| Two durable-ID Investigations coexist → 2 summaries | ✅ PASS |
|
||||
| Each summary carries correct durable ID | ✅ PASS |
|
||||
| Lightweight projection: portfolio fields present, payload fields absent | ✅ PASS |
|
||||
| Legacy singleton excluded from listing | ✅ PASS |
|
||||
| Unrelated localStorage key excluded | ✅ PASS |
|
||||
| Independent update preserves other Investigation | ✅ PASS |
|
||||
| Deterministic ordering by updatedAt descending | ✅ PASS |
|
||||
| Malformed durable-ID entry skipped, valid records still listed | ✅ PASS |
|
||||
|
||||
### Portfolio scope bounded
|
||||
|
||||
- Portfolio has **NOT** been migrated to consume `listInvestigations()` — that is v0.60g2
|
||||
- `app/page.jsx` unchanged from v0.60f
|
||||
- No rendering or interactive behaviour changes
|
||||
|
||||
### Production files changed
|
||||
|
||||
| File | Purpose |
|
||||
|---|---|
|
||||
| `lib/storage/providers/local-storage.js` | Provider implements record enumeration + lightweight projection |
|
||||
| `lib/storage/investigation-storage.js` | Application-facing wrapper re-exports listing operation |
|
||||
| `tests/storage/investigation-storage.test.js` | 8 new listing contract tests; MockStorageMap WebStorage API fix |
|
||||
|
||||
### Next restart point
|
||||
|
||||
v0.60g2: Migrate Portfolio to consume `listInvestigations()` for collection rendering — replace the hardcoded singleton card with a rendered list of Investigation summaries.
|
||||
|
||||
Smallest next increment: implement the four-operation storage contract in `lib/storage/investigation-storage.js` as a re-export of a provider-backed interface whose signatures accept/return domain Investigation objects keyed by durable ID — without committing to any specific localStorage or database representation. This means defining the exported function signatures and the Investigation shape that flows through them, while deferring key scheme, row schema, and collection structure to a later implementation decision.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user