fix(reasoning): preserve investigation ownership across selection and question rejection

This commit is contained in:
2026-08-17 17:58:45 +01:00
parent d908f3746d
commit 772ae495c6
7 changed files with 850 additions and 4429 deletions
+15 -5
View File
@@ -249,7 +249,7 @@ function semanticSignature(candidate) {
);
}
function classifyCandidateOrdering(candidates) {
function classifyCandidateOrdering(candidates, activeNodeId = null) {
const displayOrder = buildCandidateDisplayOrder(candidates);
const best = displayOrder[0] ?? null;
if (!best) {
@@ -319,15 +319,21 @@ function classifyCandidateOrdering(candidates) {
}
if (topStructuralCandidates.length > 0) {
const activeTiedCandidate = activeNodeId
? topStructuralCandidates.find((candidate) => candidate.nodeId === activeNodeId)
: null;
return {
displayOrder,
best,
best: activeTiedCandidate || best,
leadingCandidates: topStructuralCandidates,
status: "selected",
tieType: "complete_unresolved_tie",
usedAlphabeticalOrdering: true,
usedAlphabeticalOrdering: activeTiedCandidate ? false : true,
reason:
"Leading candidates remained tied after score, structural, and semantic checks, so the stable deterministic display order was used as the final fallback.",
activeTiedCandidate
? "Leading candidates remained tied after score, structural, and semantic checks, so existing active investigation ownership was preserved."
: "Leading candidates remained tied after score, structural, and semantic checks, so the stable deterministic display order was used as the final fallback.",
};
}
@@ -624,6 +630,7 @@ export function selectActiveUnknownCandidate(graph, resolvedNodeIds) {
...candidate,
node,
})),
graph?.activeUnknownNodeId ?? null,
);
if (selection.status === "ambiguous") {
@@ -690,7 +697,10 @@ export function explainUnknownSelection(graph, resolvedNodeIds = []) {
...scoreUnknownCandidate(graph, node, resolvedNodeIds),
}));
const selection = classifyCandidateOrdering(candidates);
const selection = classifyCandidateOrdering(
candidates,
graph?.activeUnknownNodeId ?? null,
);
const orderedCandidates = selection.displayOrder;
const selected = selection.best;
const competitors = orderedCandidates