feat(confidence-engine): v0.60j preserve investigation on restart

This commit is contained in:
2026-09-04 10:18:22 +01:00
parent 4bc998ee3f
commit cc3a5dabd4
7 changed files with 551 additions and 7 deletions
+35
View File
@@ -175,6 +175,41 @@ export function listInvestigations() {
return summaries;
}
// ── restartInvestigation (semantic reset within container) ───────────
/**
* Resets the Investigation to a clean state suitable for a new reasoning pass.
*
* Preserved: id, scenario, schemaVersion (container-level identity/framing).
* Reset: situationGraph → null, selectedQuestion → null, summary → null,
* focusedContributions → [], findings → [], investigationReport → null,
* investigationRevision → 0, updatedAt → new ISO timestamp.
*/
export function restartInvestigation(id) {
const storage = _getTargetStorage();
if (!storage) return;
try {
const key = id != null ? `${INVESTIGATION_PREFIX}${id}` : CANONICAL_KEY;
const raw = safeGet(storage, key);
if (raw === null) return; // nothing to restart
const record = JSON.parse(raw);
if (!isPlainObject(record)) return;
// Preserve container fields, reset reasoning-state fields
record.situationGraph = null;
record.selectedQuestion = null;
record.summary = null;
record.focusedContributions = [];
record.findings = [];
record.investigationReport = null;
record.investigationRevision = 0;
record.updatedAt = new Date().toISOString();
_persist(storage, key, JSON.stringify(record));
} catch (_) { /* storage errors must not crash caller */ }
}
// ── internals ────────────────────────────────────────────────────────
function _persist(storage, key, value) {