reasoning: prevent unsupported comparison decomposition
This commit is contained in:
@@ -225,7 +225,7 @@ describe("decomposition stopping conditions", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("stops once a directly answerable child is selected", () => {
|
||||
it("does not manufacture comparison children for a generic explanatory parent", () => {
|
||||
const { parent, graph } = makeParentGraph({
|
||||
centralStatement: "Traffic increased, but sales stayed flat.",
|
||||
parentLabel:
|
||||
@@ -259,15 +259,82 @@ describe("decomposition stopping conditions", () => {
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.decompositionAttempted).toBe(true);
|
||||
expect(result.decompositionAccepted).toBe(true);
|
||||
expect(result.selectedQuestion).toMatchObject({
|
||||
nodeId: expect.any(String),
|
||||
question:
|
||||
"What evidence would clarify how the two observations were measured?",
|
||||
});
|
||||
expect(result.selectedChildNodeId).toBe(result.selectedQuestion?.nodeId);
|
||||
expect(result.decompositionAccepted).toBe(false);
|
||||
expect(result.childUnknownCount).toBe(0);
|
||||
expect(
|
||||
result.updatedSituationGraph.nodes.some(
|
||||
(node) => node.parentId === parent.id,
|
||||
),
|
||||
).toBe(false);
|
||||
expect(
|
||||
result.updatedSituationGraph.nodes.some(
|
||||
(node) => node.label === "How the two observations were measured",
|
||||
),
|
||||
).toBe(false);
|
||||
expect(
|
||||
result.updatedSituationGraph.nodes.some(
|
||||
(node) =>
|
||||
node.label ===
|
||||
"Whether the two observations reflect different timing",
|
||||
),
|
||||
).toBe(false);
|
||||
expect(result.decompositionStoppedReason).toBe(
|
||||
"Selected child is atomic and directly answerable.",
|
||||
"Decomposition stopped because no meaning-preserving child family was justified for this parent.",
|
||||
);
|
||||
expect(result.selectedQuestion?.question || "").not.toContain(
|
||||
"two observations",
|
||||
);
|
||||
});
|
||||
|
||||
it("still decomposes a genuine comparison/measurement parent into valid comparison children", () => {
|
||||
const { graph } = makeParentGraph({
|
||||
centralStatement:
|
||||
"Revenue increased by 18%, but cash in the bank fell over the same period.",
|
||||
parentLabel: "Timing or measurement basis",
|
||||
parentDescription:
|
||||
"Need evidence about whether a timing or measurement-basis difference could explain the observations, because that would change how they should be interpreted.",
|
||||
observations: [
|
||||
makeNode({
|
||||
id: "n-revenue",
|
||||
label: "Revenue increased by 18%.",
|
||||
description: "Revenue increased by 18%.",
|
||||
kind: "observation",
|
||||
status: "supported",
|
||||
confidence: "high",
|
||||
}),
|
||||
makeNode({
|
||||
id: "n-cash",
|
||||
label: "Cash in the bank decreased over the same period.",
|
||||
description: "Cash in the bank decreased over the same period.",
|
||||
kind: "observation",
|
||||
status: "supported",
|
||||
confidence: "high",
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const result = applyValidatedProposal({
|
||||
situationGraph: graph,
|
||||
proposal: makeMeaningfulNoOpProposal(),
|
||||
});
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.decompositionPerformed).toBe(true);
|
||||
expect(result.childUnknownCount).toBe(2);
|
||||
expect(
|
||||
result.updatedSituationGraph.nodes.some(
|
||||
(node) => node.label === "How the two observations were measured",
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
result.updatedSituationGraph.nodes.some(
|
||||
(node) =>
|
||||
node.label ===
|
||||
"Whether the two observations reflect different timing",
|
||||
),
|
||||
).toBe(true);
|
||||
expect(result.selectedQuestion?.question).toBe(
|
||||
"What evidence would clarify how the two observations were measured?",
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user