diff --git a/scripts/test_approved_plan_continuity_gate.mjs b/scripts/test_approved_plan_continuity_gate.mjs index 24409b2..3183ced 100644 --- a/scripts/test_approved_plan_continuity_gate.mjs +++ b/scripts/test_approved_plan_continuity_gate.mjs @@ -126,6 +126,51 @@ const tests = [ } }, }, + { + name: 'continuity: fails when planner returns derivedAction without any bound dispatch receipt', + run() { + const fixture = createFixture({ + 'input.json': { + planId: 'plan-derived-action-without-bound-dispatch', + currentTask: 'task-6b', + taskState: 'complete', + derivedAction: { + type: 'message_subagent', + task: 'continue with task-7b', + }, + 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} +${result.stderr || result.stdout}`); + } + + if (!result.json || typeof result.json !== 'object') { + throw new Error(`expected JSON output +stdout=${result.stdout}`); + } + + if (result.json.ok !== false) { + throw new Error(`expected continuity failure ok=false for derivedAction without dispatch receipt, got ${JSON.stringify(result.json)}`); + } + + if (result.json.verdict !== 'continuity_failure') { + throw new Error(`expected verdict=continuity_failure for derivedAction without dispatch receipt, got ${JSON.stringify(result.json.verdict)}`); + } + } finally { + fixture.cleanup(); + } + }, + }, + { name: 'continuity: passes when task is complete, next action is known, and a dispatch receipt already exists', run() { @@ -216,6 +261,47 @@ stdout=${result.stdout}`); }, }, + { + name: 'continuity: passes when task is complete, next action is known, no dispatch receipt exists, and closure is pending_verification', + run() { + const fixture = createFixture({ + 'input.json': { + planId: 'plan-pending-verification-closure', + currentTask: 'task-8b', + taskState: 'complete', + nextDerivedAction: { + type: 'message_subagent', + task: 'continue with task-9', + }, + replyClosureState: 'pending_verification', + 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 pending_verification, got ${JSON.stringify(result.json)}`); + } + } finally { + fixture.cleanup(); + } + }, + }, + { name: 'continuity: passes when task is complete, next action is known, no dispatch receipt exists, and closure is blocked', run() {