reasoning: suppress explanation question without relationship structure

This commit is contained in:
2026-08-10 10:17:35 +01:00
parent 1a31949a48
commit 4c5666dfb3
3 changed files with 184 additions and 1 deletions
@@ -128,6 +128,69 @@ describe("comparability assessment", () => {
]);
});
it("returns questionRequired=false for fallback (no meaningful relationship structure)", () => {
// Two non-measurement-like observations with no shared concept and no known direction.
// They pass comparability (confirmed) but fall through all classification conditions:
// - not duplicate, no available+unavailable, no revenue/cash pair, no all-known-directions
// → hits the fallback which now returns questionRequired=false
const graph = {
centralStatement:
"Temperature was measured. Ice was observed.",
nodes: [
{
id: "obs-temperature",
label: "Temperature was measured.",
description: "Temperature was measured.",
kind: "observation",
status: "supported",
confidence: "high",
value: null,
unit: null,
evidenceIds: [],
dependsOn: [],
affects: [],
parentId: null,
childIds: [],
},
{
id: "obs-ice",
label: "Ice was observed.",
description: "Ice was observed.",
kind: "observation",
status: "supported",
confidence: "high",
value: null,
unit: null,
evidenceIds: [],
dependsOn: [],
affects: [],
parentId: null,
childIds: [],
},
],
edges: [],
activeUnknownNodeId: null,
resolvedNodeIds: [],
currentSummary: "Fallback regression fixture",
};
const relationship = classifyObservationRelationship(graph);
expect(relationship.relationshipStatus).toBe("insufficient_information");
expect(relationship.questionRequired).toBe(false);
// Verify reasoning stages exist and have correct status
const stages = relationship.reasoningStages;
expect(stages.length).toBe(2);
expect(stages[0].stage).toBe("comparability");
expect(stages[0].status).toBe("confirmed");
expect(stages[1].stage).toBe("relationship");
expect(stages[1].status).toBe("insufficient_information");
// questionRequired=false means buildEmergentReasoningUnknown returns early,
// so no "Explanation for why..." unknown is created — the engine preserves
// uncertainty rather than fabricating an explanation problem.
});
it("allows contradiction reasoning only for genuine contradictions", () => {
const serviceGraph = {
centralStatement: