feat(confidence-engine): reopen clarified questions

This commit is contained in:
2026-09-01 16:07:22 +01:00
parent a23da2b727
commit cd895a33ff
4 changed files with 342 additions and 1 deletions
+35
View File
@@ -0,0 +1,35 @@
/**
* Deterministically reopen a resolved unknown node in a SituationGraph.
*
* Transition: node.status "resolved" → "unknown", and removes the node's ID
* from resolvedNodeIds. This reverses canonical resolution so the question
* reappears among Open Questions for further investigation.
*
* Idempotent — if the target is not a currently-resolved unknown, returns the
* original graph unchanged (no mutation). Does NOT create nodes, delete edges,
* or touch contributions/findings/historical evidence.
*/
export function reopenResolvedUnknown(situationGraph, nodeId) {
if (!situationGraph || !nodeId) return situationGraph;
const nodeIndex = situationGraph.nodes.findIndex((n) => n.id === nodeId);
if (nodeIndex === -1) return situationGraph;
const node = situationGraph.nodes[nodeIndex];
if (node.kind !== "unknown" || node.status !== "resolved") return situationGraph;
const newNode = { ...node, status: "unknown" };
const newNodes = [...situationGraph.nodes];
newNodes[nodeIndex] = newNode;
const newResolvedNodeIds = [
...(situationGraph.resolvedNodeIds || []),
].filter((id) => id !== nodeId);
return {
...situationGraph,
nodes: newNodes,
resolvedNodeIds: newResolvedNodeIds,
};
}