fix: align mock responses with real UI contract

This commit is contained in:
2026-08-04 14:11:59 +01:00
parent 97a4847770
commit 6e4db76807
+11 -7
View File
@@ -129,10 +129,10 @@ var T5_nodes = [
var T5_edges = [mkEdge("e-1","obs-1","state-1"),mkEdge("e-2","obs-2","state-1"),mkEdge("e-3","rel-1","u-1"),mkEdge("e-4","obs-3","u-1"),mkEdge("e-5","rel-1","u-2"),mkEdge("e-6","obs-4","u-2"),mkEdge("e-7","obs-4","u-3"),mkEdge("e-8","obs-5","u-3"),mkEdge("e-9","rel-1","u-4"),mkEdge("e-10","obs-6","u-4")];
var TURNS = [
{ nodes:T0_nodes, edges:T0_edges, resolved:[], active:null, question:null, noQReason:null, summary:"Two changes have been reported, but we do not yet know whether the figures are directly comparable." },
{ nodes:T1_nodes, edges:T1_edges, resolved:["u-1"], active:"u-2", question:"Were both percentages calculated from comparable baseline counts?", noQReason:null, summary:"The timing basis is now clear." },
{ nodes:T2_nodes, edges:T2_edges, resolved:["u-1","u-2"], active:"u-3", question:"Did the complaint rate per unit produced improve or worsen?", noQReason:null, summary:"The absolute baselines are now known." },
{ nodes:T3_nodes, edges:T3_edges, resolved:["u-1","u-2","u-3"], active:"u-4", question:"Was there any change in how complaints were recorded during the period?", noQReason:null, summary:"The per-unit complaint rate improved slightly." },
{ nodes:T0_nodes, edges:T0_edges, resolved:[], active:"u-1", question:{ nodeId:"u-1", question:"Were the complaint and production figures measured over the same period?", reason:"If the figures cover different periods, comparing their movement could be misleading.", reasoningPattern:"comparability_check" }, noQReason:null, summary:"Two changes have been reported, but we do not yet know whether the figures are directly comparable." },
{ nodes:T1_nodes, edges:T1_edges, resolved:["u-1"], active:"u-2", question:{ nodeId:"u-2", question:"Were both percentages calculated from comparable baseline counts?", reason:"Establishing the reference point for both figures is essential before evaluating their relationship.", reasoningPattern:"baseline_comparability" }, noQReason:null, summary:"The timing basis is now clear." },
{ nodes:T2_nodes, edges:T2_edges, resolved:["u-1","u-2"], active:"u-3", question:{ nodeId:"u-3", question:"Did the complaint rate per unit produced improve or worsen?", reason:"Absolute changes in complaints and production are known; the relative rate determines whether the situation improved.", reasoningPattern:"rate_comparison" }, noQReason:null, summary:"The absolute baselines are now known." },
{ nodes:T3_nodes, edges:T3_edges, resolved:["u-1","u-2","u-3"], active:"u-4", question:{ nodeId:"u-4", question:"Was there any change in how complaints were recorded during the period?", reason:"The per-unit rate changed; we need to rule out recording artifacts before concluding a genuine shift.", reasoningPattern:"artifact_exclusion" }, noQReason:null, summary:"The per-unit complaint rate improved slightly." },
{ nodes:T4_nodes, edges:T4_edges, resolved:["u-1","u-2","u-3","u-4"], active:null, question:null, noQReason:"Additional external evidence is required before another justified question can be selected.", summary:"The available evidence has reached its current limit." },
{ nodes:T5_nodes, edges:T5_edges, resolved:["u-1","u-2","u-3","u-4"], active:null, question:null, noQReason:"All required investigation areas are resolved.", summary:"The figures cover the same period, use comparable baselines, show an improved complaint rate, and were recorded consistently." }
];
@@ -143,7 +143,7 @@ function buildDefaultFixture(idx) {
var d = TURNS[Math.min(idx, TURNS.length - 1)];
return {
situationGraph: { centralStatement:"Complaints increased by 35% while production increased by 40%.", currentSummary:d.summary, nodes:d.nodes, edges:d.edges, activeUnknownNodeId:d.active, resolvedNodeIds:d.resolved },
selectedQuestion: d.question ? { question: d.question } : null,
selectedQuestion: d.question || null,
noQuestionReason: d.noQReason,
newlySurfacedNodeIds: [],
diagnostics: { promptVersion:"v0.4", modelName:"mock-ollama", responseDurationMs:0, validationStatus:"valid", nodeCount:d.nodes.length, edgeCount:d.edges.length, unknownSelectionExplanation: d.active ? { status:"single_candidate" } : null }
@@ -184,10 +184,14 @@ function handleStartCase(scenario) {
function handleUpdateCase(data) {
var scenarioName = getScenario();
if (scenarioName === "error") return Promise.resolve({ success:true, data:buildUpdateFixture("error",0) });
if (scenarioName === "error") return delay(getDelay()).then(function() {
return Promise.resolve({ success:true, data:buildUpdateFixture("error",0) });
});
_turnIndex++;
var idx = scenarioName === "complete" ? 5 : Math.min(_turnIndex, 5);
return Promise.resolve({ success:true, data:buildUpdateFixture(scenarioName, idx) });
return delay(getDelay()).then(function() {
return Promise.resolve({ success:true, data:buildUpdateFixture(scenarioName, idx) });
});
}
/* ── public intercept function ──────────────────────────── */