diff --git a/scripts/test_approved_plan_continuity_gate.mjs b/scripts/test_approved_plan_continuity_gate.mjs index e3775d7..d828900 100644 --- a/scripts/test_approved_plan_continuity_gate.mjs +++ b/scripts/test_approved_plan_continuity_gate.mjs @@ -84,6 +84,48 @@ const tests = [ } }, }, + { + name: 'continuity: fails when task is complete, next action is known, no dispatch receipt exists, and closure is not in an allowed terminal state', + run() { + const fixture = createFixture({ + 'input.json': { + planId: 'plan-missing-dispatch', + currentTask: 'task-6', + taskState: 'complete', + nextDerivedAction: { + type: 'message_subagent', + task: 'continue with task-7', + }, + replyClosureState: 'completed', + dispatchReceipt: null, + }, + }); + + try { + const result = runGate({ + args: ['--compact', '--input', fixture.path('input.json')], + }); + + if (result.status !== 0 && result.status !== null) { + throw new Error(`expected controlled execution, got status=${result.status}\n${result.stderr || result.stdout}`); + } + + if (!result.json || typeof result.json !== 'object') { + throw new Error(`expected JSON output\nstdout=${result.stdout}`); + } + + if (result.json.ok !== false) { + throw new Error(`expected continuity failure ok=false, got ${JSON.stringify(result.json)}`); + } + + if (result.json.verdict !== 'continuity_failure') { + throw new Error(`expected verdict=continuity_failure, got ${JSON.stringify(result.json.verdict)}`); + } + } finally { + fixture.cleanup(); + } + }, + }, ]; const results = [];