Skip to content

bug: Copilot plan approval fails — integration worktree never created #10

@nigel-dev

Description

@nigel-dev

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

  1. Create a plan in copilot mode:
    mc_plan(name: "test", mode: "copilot", jobs: [{name: "job1", prompt: "..."}])
    
  2. Approve the plan:
    mc_plan_approve()
    
  3. 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 Orchestrator and calls startPlan(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:

  1. Have mc_plan_approve call orchestrator.startPlan(plan) instead of resumePlan() for pending plans (preferred — keeps plan creation lazy).
  2. Have copilot mode in mc_plan create the integration branch/worktree before saving.

Files Involved

  • src/tools/plan.ts:119-145 — copilot path skips integration setup
  • src/tools/plan-approve.ts:52-59 — approval calls resumePlan() for pending plans
  • src/lib/orchestrator.ts:846resumePlan() assumes integrationWorktree exists

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0: criticalMust fix immediately — blocks core functionalitybugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions