Skip to content

bug: Plan job branches can collide with standalone jobs — no plan-scoped naming #34

@nigel-dev

Description

@nigel-dev

Description

Plan jobs default to branch name mc/<jobName>. Standalone mc_launch jobs also use mc/<jobName>. If a plan job has the same name as a previous standalone job (or a job from a different plan), createWorktree() will reuse the existing branch instead of creating a fresh one.

This can lead to:

  • Stale code from a previous job leaking into the new job
  • Unexpected merge results when the branch has commits from unrelated work
  • Silent failures that are hard to debug

Expected Behavior

Plan job branches should be scoped to the plan to avoid collisions:

mc/plan/<planId-short>/<jobName>

Example: mc/plan/a1b2c3d4/api-endpoints

Current Behavior

// src/lib/orchestrator.ts — launchJob()
const branch = job.branch ?? `mc/${job.name}`;

And in createWorktree():

const branchCheckResult = await gitCommand(['branch', '--list', opts.branch]);
const branchExists = branchCheckResult.stdout.includes(opts.branch);
if (branchExists) {
  createResult = await gitCommand(['worktree', 'add', worktreePath, opts.branch]);
  // Reuses the existing branch with all its old commits!
}

Proposed Fix

  1. Default plan job branches to mc/plan/<planId-short>/<jobName> in orchestrator.ts
  2. Keep standalone mc_launch branches as mc/<jobName> (backward compatible)
  3. Optionally: warn or error if a branch already exists when creating a plan job

Files

  • src/lib/orchestrator.ts — branch naming in launchJob()
  • Status/overview output may need updating to display the longer branch names

Risk

  • Longer branch names in tmux displays
  • Existing users may have scripts that assume mc/<name> format — only change default for plan jobs

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2: mediumShould fix — improves reliability or DXbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions