fix(reasoning): reconcile closure selection state

This commit is contained in:
2026-08-14 11:02:00 +01:00
parent a00112e157
commit 54e2e2186b
4 changed files with 386 additions and 3 deletions
+25
View File
@@ -356,6 +356,31 @@ function reconcileResolutionSemantics(graph, proposal) {
}
}
for (const update of nextProposal.updatedNodes) {
const existingNode = graphNodeById.get(update.nodeId);
if (
existingNode?.kind === "unknown" &&
update.newStatus === "resolved" &&
!nextProposal.resolvedUnknownNodeIds.includes(update.nodeId)
) {
nextProposal.resolvedUnknownNodeIds.push(update.nodeId);
}
}
if (nextProposal.selectedQuestion?.nodeId) {
const selectedQuestionNodeId = nextProposal.selectedQuestion.nodeId;
const selectedQuestionUpdate = updatedNodeById.get(selectedQuestionNodeId);
const selectedQuestionResolvedByStatus =
selectedQuestionUpdate?.newStatus === "resolved";
const selectedQuestionResolvedById = nextProposal.resolvedUnknownNodeIds.includes(
selectedQuestionNodeId,
);
if (selectedQuestionResolvedByStatus || selectedQuestionResolvedById) {
nextProposal.selectedQuestion = null;
}
}
for (const update of nextProposal.updatedNodes) {
const existingNode = graphNodeById.get(update.nodeId);
if (
+1 -1
View File
@@ -117,7 +117,7 @@ The JSON object must contain exactly these top-level fields:
14. Do not invent evidence.
15. Do not create unsupported causal edges.
16. When your proposal adds one or more new unresolved unknowns (status !== 'resolved'), you MUST include a selectedQuestion identifying one of those as a candidate unknown node. The engine validates your candidate and retains deterministic prerequisite ordering, fallback selection, and formulation authority; prefer nodes with no unresolved depends_on prerequisites from same-proposal additions. Your candidate does not need to be the highest-scoring unknown — it only needs to be a valid unresolved unknown that exists in the graph or in addedNodes.
17. selectedQuestion.nodeId must reference an unresolved unknown node that exists either already in the graph or in addedNodes.
17. selectedQuestion.nodeId must reference an unknown node that remains unresolved after applying this same proposal and that exists either already in the graph or in addedNodes. If the proposal resolves all consequential unknowns, selectedQuestion must be null.
18. selectedQuestion.question must be one narrow non-compound question about that one unknown.
19. Do not prioritise downstream implementation, pricing, optimisation, or speculative branches ahead of prerequisite definitions, actors, success criteria, constraints, measures, or terminology.
20. Return selectedQuestion as null only when no consequential unresolved unknown remains.