-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Description
When a plan is created in copilot mode, mc_plan saves the plan spec with status: 'pending' but does not create the integration branch or worktree. When the user later approves the plan via mc_plan_approve, it calls orchestrator.resumePlan(), which immediately accesses plan.integrationWorktree! — a field that was never populated.
This means copilot mode plans cannot be started after approval.
Steps to Reproduce
- Create a plan in copilot mode:
mc_plan(name: "test", mode: "copilot", jobs: [{name: "job1", prompt: "..."}]) - Approve the plan:
mc_plan_approve() - Observe failure when orchestrator tries to access
plan.integrationWorktree.
Expected Behavior
After mc_plan_approve, the integration branch and worktree should be created (if they don't exist), and the plan should begin execution normally.
Actual Behavior
resumePlan() at src/lib/orchestrator.ts:846 accesses plan.integrationWorktree! which is undefined because copilot mode skips integration setup at src/tools/plan.ts:119-145.
Root Cause
In src/tools/plan.ts:
- Autopilot/supervisor (line 148+): Creates an
Orchestratorand callsstartPlan(spec), which internally creates the integration branch + worktree. - Copilot (line 120-144): Only calls
savePlan(spec)and returns — no integration setup.
Then in src/tools/plan-approve.ts:59:
- Calls
orchestrator.resumePlan()which assumes integration infrastructure exists.
Proposed Fix
Either:
- Have
mc_plan_approvecallorchestrator.startPlan(plan)instead ofresumePlan()for pending plans (preferred — keeps plan creation lazy). - Have copilot mode in
mc_plancreate the integration branch/worktree before saving.
Files Involved
src/tools/plan.ts:119-145— copilot path skips integration setupsrc/tools/plan-approve.ts:52-59— approval callsresumePlan()for pending planssrc/lib/orchestrator.ts:846—resumePlan()assumesintegrationWorktreeexists
Additional Context
Discovered during audit cross-reference (Feb 11, 2026). Related to issue #3 (supervisor checkpoint loop) — both stem from the plan approval path not properly bootstrapping the orchestrator state.