fix: reselect after reasoning pattern filtering

This commit is contained in:
2026-08-03 12:39:01 +01:00
parent c27320984c
commit 34c25fcb43
4 changed files with 317 additions and 46 deletions
+76
View File
@@ -92,6 +92,49 @@ function makeCommercialAnalysisResult(overrides = {}) {
});
}
function makeCommercialTieAnalysisResult(overrides = {}) {
return makeAnalysisResult({
reconstruction: {
summary:
"A new reasoning method may become a commercial product, but multiple broad decision unknowns remain unresolved.",
actors: [],
systemsOrObjects: [],
expectedStates: [],
observedStates: [],
differences: [],
knownTransitions: [],
unexplainedTransitions: [],
contradictions: [],
importantUnknowns: [
{
id: "unk-fit-pay",
label:
"Evidence of genuine problem-solution fit and actual willingness to pay among target users",
description:
"Need to know whether there is real problem-solution fit and willingness to pay among target users before continuing development.",
confidence: "high",
},
{
id: "unk-distinction",
label:
"Clear, measurable distinction between the method and existing AI tools that justifies separate commercial value",
description:
"Need to know whether there is a clear measurable distinction from existing AI tools before continuing development.",
confidence: "high",
},
],
plausibleInterpretations: [],
},
nextQuestion: {
id: "q-commercial-tie",
question:
"What specific validation metrics, pilot feedback, or competitive benchmarking results have you collected?",
reason: "Model-proposed broad validation question",
},
...overrides,
});
}
function makeCommercialUpdateGraph() {
const parent = makeNode({
id: "n-commercial-parent",
@@ -512,6 +555,39 @@ describe("lib/graph/orchestrator startCase", () => {
);
});
it("reselects and decomposes a tied commercial start-case candidate instead of returning a silent null question", async () => {
mockAnalyseScenario.mockResolvedValue(makeCommercialTieAnalysisResult());
const { startCase } = await import("@/lib/graph/orchestrator.js");
const result = await startCase({
scenario:
"I have developed a new reasoning method that aims to help people determine whether they have enough justified confidence to make a decision. I believe it could become a commercial product, but I do not yet know whether it solves a genuine problem, whether people would value it enough to pay for it, or whether it is fundamentally different from existing AI tools. Before investing significant time and money into building it further, I want to determine whether continuing development is commercially justified.",
});
expect(result.success).toBe(true);
expect(
result.situationGraph.nodes.some((node) => node.kind === "unknown"),
).toBe(true);
expect(result.selectedQuestion).not.toBeNull();
expect(result.selectedQuestion?.question).toBe(
"Who experiences this problem?",
);
expect(result.selectedQuestion?.nodeId).toBe(
result.situationGraph.activeUnknownNodeId,
);
expect(result.diagnostics.noQuestionReason).toBeNull();
expect(result.diagnostics.selectedContainerUnknown).toBeTruthy();
expect(result.diagnostics.selectedChildUnknown).toBeTruthy();
expect(result.diagnostics.decompositionApplied).toBe(true);
expect(result.diagnostics.reasoningPatternValidation).toMatchObject({
activePattern: "decision",
valid: true,
});
expect(result.selectedQuestion?.question.toLowerCase()).not.toMatch(
/pay|price|pricing|budget|benchmark/,
);
});
it("includes compatibility diagnostics when provided by analysis", async () => {
mockAnalyseScenario.mockResolvedValue(
makeAnalysisResult({