feat: introduce reasoning pattern selection
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
assessUnknownAtomicity,
|
||||
formulateQuestion,
|
||||
formulateTieResolutionQuestion,
|
||||
selectReasoningPattern,
|
||||
selectInvestigationStrategy,
|
||||
} from "@/lib/graph/question-formulator.js";
|
||||
import { makeEdge, makeGraph, makeNode } from "@/lib/graph/schema.js";
|
||||
@@ -105,6 +106,8 @@ describe("formulateQuestion", () => {
|
||||
const result = formulateQuestion({ node: unknown, graph });
|
||||
|
||||
expect(result.strategy).toBe("decision_threshold");
|
||||
expect(result.reasoningPattern).toBe("decision");
|
||||
expect(result.questionFamily).toBe("decision_threshold");
|
||||
expect(result.question).toContain("What outcome");
|
||||
expect(result.question.toLowerCase()).toContain("justify");
|
||||
});
|
||||
@@ -144,6 +147,8 @@ describe("formulateQuestion", () => {
|
||||
});
|
||||
|
||||
expect(result.strategy).toBe("definition");
|
||||
expect(result.reasoningPattern).toBe("definition");
|
||||
expect(result.questionFamily).toBe("definition");
|
||||
expect(result.question).toMatch(/^What does /);
|
||||
});
|
||||
|
||||
@@ -213,9 +218,68 @@ describe("formulateQuestion", () => {
|
||||
});
|
||||
|
||||
expect(result.strategy).toBe("contradiction_resolution");
|
||||
expect(result.reasoningPattern).toBe("contradiction");
|
||||
expect(result.question).toContain("resolve the contradiction");
|
||||
});
|
||||
|
||||
it("reasoning pattern selection marks commercial validation as decision rather than explanation", () => {
|
||||
const unknown = makeNode({
|
||||
id: "n-commercial-pattern",
|
||||
label:
|
||||
"Whether the method addresses a genuine, high-priority problem for a specific audience",
|
||||
description:
|
||||
"Need to know whether this solves a real problem for a clear audience before continuing development.",
|
||||
kind: "unknown",
|
||||
status: "unknown",
|
||||
confidence: "high",
|
||||
});
|
||||
const graph = makeGraphFor(unknown, {
|
||||
centralStatement:
|
||||
"Before investing more, we need to know whether continuing development is commercially justified.",
|
||||
});
|
||||
|
||||
const result = selectReasoningPattern({ node: unknown, graph });
|
||||
|
||||
expect(result.pattern).toBe("decision");
|
||||
});
|
||||
|
||||
it("comparison scenario selects the comparison pattern", () => {
|
||||
const unknown = makeNode({
|
||||
id: "n-comparison-pattern",
|
||||
label: "How the two observations were measured",
|
||||
description:
|
||||
"Need evidence about the measure used for each observation, because that could help explain the difference.",
|
||||
kind: "unknown",
|
||||
status: "unknown",
|
||||
confidence: "medium",
|
||||
});
|
||||
const graph = makeGraphFor(unknown, {
|
||||
centralStatement: "Traffic increased, but sales stayed flat.",
|
||||
nodes: [
|
||||
makeNode({
|
||||
id: "n-traffic-observation",
|
||||
label: "Traffic increased.",
|
||||
description: "Traffic increased.",
|
||||
kind: "observation",
|
||||
status: "supported",
|
||||
confidence: "high",
|
||||
}),
|
||||
makeNode({
|
||||
id: "n-sales-observation",
|
||||
label: "Sales stayed flat.",
|
||||
description: "Sales stayed flat.",
|
||||
kind: "observation",
|
||||
status: "supported",
|
||||
confidence: "high",
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const result = selectReasoningPattern({ node: unknown, graph });
|
||||
|
||||
expect(result.pattern).toBe("comparison");
|
||||
});
|
||||
|
||||
it("constraint unknown uses evidence-gathering within the fixed strategy set", () => {
|
||||
const unknown = makeNode({
|
||||
id: "n-constraint",
|
||||
@@ -445,6 +509,7 @@ describe("formulateQuestion", () => {
|
||||
node: unknown,
|
||||
graph: makeGraphFor(unknown),
|
||||
});
|
||||
expect(result.reasoningPattern).toBe("diagnosis");
|
||||
expect(result.strategy).toBeNull();
|
||||
expect(result.question).toBe(
|
||||
"What would clarify possible causes of the divergence in this situation?",
|
||||
|
||||
Reference in New Issue
Block a user