fix: handle unjustified unknown selection ties
This commit is contained in:
@@ -456,6 +456,7 @@ describe("selectActiveUnknownCandidate", () => {
|
||||
|
||||
const result = selectActiveUnknownCandidate(graph, []);
|
||||
expect(result.nodeId).toBe("unknown-a"); // Has more dependents (score 2 vs 0)
|
||||
expect(result.status).toBe("selected");
|
||||
});
|
||||
|
||||
it("returns one candidate (not array)", () => {
|
||||
@@ -619,6 +620,72 @@ describe("selectActiveUnknownCandidate", () => {
|
||||
const childScore = scoreUnknownCandidate(graph, childUnknown, []);
|
||||
expect(parentScore.score).toBeGreaterThan(childScore.score);
|
||||
});
|
||||
|
||||
it("returns ambiguous for a complete unresolved tie instead of label-based winner", () => {
|
||||
const unknownA = makeNode({
|
||||
id: "tie-a",
|
||||
label: "Magnitude and nature of cash outflows",
|
||||
description: "Magnitude and nature of cash outflows.",
|
||||
kind: "unknown",
|
||||
status: "unknown",
|
||||
confidence: "high",
|
||||
});
|
||||
const unknownB = makeNode({
|
||||
id: "tie-b",
|
||||
label:
|
||||
"Whether revenue recognition timing differs from cash collection timing",
|
||||
description:
|
||||
"Whether revenue recognition timing differs from cash collection timing.",
|
||||
kind: "unknown",
|
||||
status: "unknown",
|
||||
confidence: "high",
|
||||
});
|
||||
const graph = makeGraph({
|
||||
centralStatement:
|
||||
"Revenue increased by 18%, but cash in the bank fell over the same period.",
|
||||
nodes: [unknownA, unknownB],
|
||||
edges: [],
|
||||
activeUnknownNodeId: null,
|
||||
resolvedNodeIds: [],
|
||||
currentSummary: "Tie case",
|
||||
});
|
||||
|
||||
const result = selectActiveUnknownCandidate(graph, []);
|
||||
expect(result).toMatchObject({
|
||||
selectedNode: null,
|
||||
status: "ambiguous",
|
||||
tieType: "complete_unresolved_tie",
|
||||
tiedCandidateIds: ["tie-a", "tie-b"],
|
||||
});
|
||||
expect(result.nodeId).toBeUndefined();
|
||||
});
|
||||
|
||||
it("alphabetical renaming does not resolve a complete tie", () => {
|
||||
const unknownA = makeNode({
|
||||
id: "tie-a",
|
||||
label: "Unknown B",
|
||||
description: "Unknown factor one.",
|
||||
kind: "unknown",
|
||||
});
|
||||
const unknownB = makeNode({
|
||||
id: "tie-b",
|
||||
label: "Unknown A",
|
||||
description: "Unknown factor two.",
|
||||
kind: "unknown",
|
||||
});
|
||||
const graph = makeGraph({
|
||||
centralStatement: "Two conflicting signals remain unresolved.",
|
||||
nodes: [unknownA, unknownB],
|
||||
edges: [],
|
||||
activeUnknownNodeId: null,
|
||||
resolvedNodeIds: [],
|
||||
currentSummary: "Tie case",
|
||||
});
|
||||
|
||||
const result = selectActiveUnknownCandidate(graph, []);
|
||||
expect(result.status).toBe("ambiguous");
|
||||
expect(result.tiedCandidateIds.sort()).toEqual(["tie-a", "tie-b"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyGraphUpdate", () => {
|
||||
|
||||
Reference in New Issue
Block a user