diff --git a/scripts/test_approved_plan_continuity_gate.mjs b/scripts/test_approved_plan_continuity_gate.mjs index 593fc54..3e714e5 100644 --- a/scripts/test_approved_plan_continuity_gate.mjs +++ b/scripts/test_approved_plan_continuity_gate.mjs @@ -174,6 +174,47 @@ stdout=${result.stdout}`); } }, }, + + { + name: 'continuity: passes when task is complete, next action is known, no dispatch receipt exists, and closure is waiting_user', + run() { + const fixture = createFixture({ + 'input.json': { + planId: 'plan-waiting-user-closure', + currentTask: 'task-8', + taskState: 'complete', + nextDerivedAction: { + type: 'message_subagent', + task: 'continue with task-9', + }, + replyClosureState: 'waiting_user', + 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} +${result.stderr || result.stdout}`); + } + + if (!result.json || typeof result.json !== 'object') { + throw new Error(`expected JSON output +stdout=${result.stdout}`); + } + + if (result.json.ok !== true) { + throw new Error(`expected continuity pass ok=true when closure is waiting_user, got ${JSON.stringify(result.json)}`); + } + } finally { + fixture.cleanup(); + } + }, + }, ]; const results = [];