fix: stabilise multi-turn question progression
This commit is contained in:
@@ -1083,6 +1083,77 @@ describe("lib/graph/orchestrator startCase", () => {
|
||||
expect(result.selectedQuestion?.nodeId).toBe("n-value");
|
||||
});
|
||||
|
||||
it("keeps a follow-up question when a resolved child still has an eligible sibling", async () => {
|
||||
const { updateCase } = await import("@/lib/graph/orchestrator.js");
|
||||
const initialGraph = makeCommercialUpdateGraph();
|
||||
const firstPass = applyValidatedProposal({
|
||||
situationGraph: initialGraph,
|
||||
proposal: {
|
||||
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,
|
||||
},
|
||||
});
|
||||
|
||||
expect(firstPass.success).toBe(true);
|
||||
|
||||
const provider = {
|
||||
generateReconstruction: vi.fn().mockResolvedValue({
|
||||
addedNodes: [],
|
||||
updatedNodes: [
|
||||
{
|
||||
nodeId: firstPass.selectedQuestion.nodeId,
|
||||
previousStatus: "unknown",
|
||||
newStatus: "resolved",
|
||||
previousValue: null,
|
||||
newValue:
|
||||
"I experience it myself when deciding whether a project or investment is justified.",
|
||||
reason: "The answer resolves the first child.",
|
||||
},
|
||||
],
|
||||
addedEdges: [],
|
||||
removedEdgeIds: [],
|
||||
resolvedUnknownNodeIds: [firstPass.selectedQuestion.nodeId],
|
||||
affectedNodeIds: [],
|
||||
selectedQuestion: null,
|
||||
}),
|
||||
};
|
||||
|
||||
const result = await updateCase(
|
||||
{
|
||||
situationGraph: firstPass.updatedSituationGraph,
|
||||
previousQuestion: firstPass.selectedQuestion.question,
|
||||
answer:
|
||||
"I experience it myself when deciding whether a project or investment is justified.",
|
||||
promptVersion: "v0.4",
|
||||
},
|
||||
{
|
||||
provider,
|
||||
config: MOCK_CONFIG,
|
||||
applyProposal: true,
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.selectedQuestion).toBeTruthy();
|
||||
expect(result.newActiveUnknownNodeId).toBe(result.selectedQuestion?.nodeId);
|
||||
expect(result.diagnostics.noQuestionReason).toBeNull();
|
||||
});
|
||||
|
||||
it("defaults to proposal-only mode", async () => {
|
||||
const { updateCase } = await import("@/lib/graph/orchestrator.js");
|
||||
const applyValidatedProposal = vi.fn();
|
||||
|
||||
Reference in New Issue
Block a user