fix: continue question selection after graph updates
This commit is contained in:
@@ -229,6 +229,53 @@ function makeApplicationFixture() {
|
||||
};
|
||||
}
|
||||
|
||||
const COMMERCIAL_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.";
|
||||
|
||||
function makeCommercialUpdateFixture() {
|
||||
const parent = makeNode({
|
||||
id: "n-commercial-parent",
|
||||
label:
|
||||
"Commercial justification for whether continuing development is commercially justified",
|
||||
description:
|
||||
"Need to know whether this solves a genuine problem, whether people would value it enough to pay for it, and whether it is commercially justified before continuing development.",
|
||||
kind: "unknown",
|
||||
status: "unknown",
|
||||
confidence: "medium",
|
||||
});
|
||||
|
||||
return makeGraph({
|
||||
centralStatement: COMMERCIAL_SCENARIO,
|
||||
nodes: [parent],
|
||||
edges: [],
|
||||
activeUnknownNodeId: parent.id,
|
||||
resolvedNodeIds: [],
|
||||
currentSummary: "Commercial update fixture",
|
||||
});
|
||||
}
|
||||
|
||||
function makeMeaningfulNoOpProposal() {
|
||||
return {
|
||||
addedNodes: [
|
||||
makeNode({
|
||||
id: "n-anchor",
|
||||
label: "Update anchor",
|
||||
description:
|
||||
"Anchor state introduced by the answer because the update must contain a meaningful change.",
|
||||
kind: "state",
|
||||
status: "known",
|
||||
confidence: "low",
|
||||
}),
|
||||
],
|
||||
updatedNodes: [],
|
||||
addedEdges: [],
|
||||
removedEdgeIds: [],
|
||||
resolvedUnknownNodeIds: [],
|
||||
affectedNodeIds: [],
|
||||
selectedQuestion: null,
|
||||
};
|
||||
}
|
||||
|
||||
describe("applyValidatedProposal", () => {
|
||||
it("applies a valid proposal successfully", () => {
|
||||
const { graph, proposal, ids } = makeApplicationFixture();
|
||||
@@ -1318,4 +1365,74 @@ describe("applyValidatedProposal", () => {
|
||||
),
|
||||
).toHaveLength(firstResult.childNodeIds.length);
|
||||
});
|
||||
|
||||
it("reselects a remaining commercial sibling after resolving the first child", () => {
|
||||
const graph = makeCommercialUpdateFixture();
|
||||
|
||||
const firstResult = applyValidatedProposal({
|
||||
situationGraph: graph,
|
||||
proposal: makeMeaningfulNoOpProposal(),
|
||||
});
|
||||
|
||||
expect(firstResult.success).toBe(true);
|
||||
expect(firstResult.selectedQuestion?.question).toBe(
|
||||
"Who experiences this problem?",
|
||||
);
|
||||
|
||||
const secondResult = applyValidatedProposal({
|
||||
situationGraph: firstResult.updatedSituationGraph,
|
||||
proposal: {
|
||||
addedNodes: [],
|
||||
updatedNodes: [
|
||||
{
|
||||
nodeId: firstResult.selectedQuestion.nodeId,
|
||||
previousStatus: "unknown",
|
||||
newStatus: "resolved",
|
||||
previousValue: null,
|
||||
newValue:
|
||||
"I experience it myself when I am trying to decide whether a project, idea or investment is justified, but I do not yet know how common that problem is for other people.",
|
||||
reason: "The answer confirms a self-observed instance.",
|
||||
},
|
||||
],
|
||||
addedEdges: [],
|
||||
removedEdgeIds: [],
|
||||
resolvedUnknownNodeIds: [firstResult.selectedQuestion.nodeId],
|
||||
affectedNodeIds: [],
|
||||
selectedQuestion: null,
|
||||
},
|
||||
previousQuestion: firstResult.selectedQuestion.question,
|
||||
answer:
|
||||
"I experience it myself when I am trying to decide whether a project, idea or investment is justified, but I do not yet know how common that problem is for other people.",
|
||||
});
|
||||
|
||||
expect(secondResult.success).toBe(true);
|
||||
expect(secondResult.resolvedUnknownNodeIds).toContain(
|
||||
firstResult.selectedQuestion.nodeId,
|
||||
);
|
||||
expect(secondResult.newActiveUnknownNodeId).toBe(
|
||||
secondResult.selectedQuestion?.nodeId,
|
||||
);
|
||||
expect(secondResult.selectedQuestion?.question).toBe(
|
||||
"What makes you think other people experience this problem too?",
|
||||
);
|
||||
expect(secondResult.selectedQuestion?.reasoningPattern).toBe("decision");
|
||||
expect(secondResult.selectedQuestion?.questionFamily).toBe(
|
||||
"decision_foundation",
|
||||
);
|
||||
expect(secondResult.selectedQuestion?.nodeId).not.toBe(
|
||||
firstResult.selectedQuestion.nodeId,
|
||||
);
|
||||
expect(secondResult.unresolvedCandidateCount).toBeGreaterThan(0);
|
||||
expect(secondResult.eligibleCandidateCount).toBeGreaterThan(0);
|
||||
expect(secondResult.candidateNodeIds).toContain(
|
||||
secondResult.selectedQuestion?.nodeId,
|
||||
);
|
||||
expect(secondResult.resolvedCurrentTurnNodeIds).toContain(
|
||||
firstResult.selectedQuestion.nodeId,
|
||||
);
|
||||
expect(secondResult.noQuestionReason).toBeNull();
|
||||
expect(secondResult.selectedQuestion?.question.toLowerCase()).not.toMatch(
|
||||
/price|budget|market size|pilot metrics|benchmark|technical differentiation/,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user