opencode-mission-control icon indicating copy to clipboard operation
opencode-mission-control copied to clipboard

feat: Activate needs_rebase job status for early conflict detection in plans

Open nigel-dev opened this issue 9 months ago • 1 comments

Description

plan-types.ts defines a needs_rebase job status with the transition merged → needs_rebase, but the orchestrator never uses it. This status was scaffolded for early conflict detection but never implemented.

Current State

// src/lib/plan-types.ts
export type JobStatus = ... | 'needs_rebase' | ...;

export const VALID_JOB_TRANSITIONS: Record<JobStatus, JobStatus[]> = {
  merged: ['needs_rebase'],              // defined
  needs_rebase: ['ready_to_merge', ...], // defined
};

The orchestrator goes directly from completed → ready_to_merge → merging → merged without any pre-merge conflict check.

Proposed Design

Before enqueueing a ready_to_merge job into the merge train, attempt a trial rebase:

  1. In the reconciler, when a job reaches ready_to_merge:

    • Attempt git rebase <integrationBranch> in the job's worktree (dry-run or real)
    • If conflicts → set status to needs_rebase, emit notification with conflict details
    • If clean → proceed to merging as normal
  2. needs_rebase jobs can be resolved by:

    • Running mc_sync (targeting the integration branch) to resolve conflicts
    • Then transitioning back to ready_to_merge
  3. In supervisor mode, needs_rebase could trigger a checkpoint for manual review.

Benefits

  • Catches conflicts before the merge train, not during it
  • Gives clearer error messages (conflict in job X vs. merge train failure)
  • Makes the existing type system actually functional

Files

  • src/lib/orchestrator.ts — add pre-merge rebase check in reconciler
  • src/tools/sync.ts — extend to accept explicit baseRef for syncing against integration branch
  • src/lib/plan-types.ts — already has the types, no changes needed

Depends On

  • mc_sync fix (targeting correct base ref) — needed so mc_sync can target the integration branch
  • Plan jobs from integration HEAD — reduces the likelihood of needing rebase in the first place

nigel-dev avatar Feb 12 '26 06:02 nigel-dev

Dependency note: If the trial rebase fails and the job is marked needs_rebase, the user currently has no way to fix the branch and retry within the plan. #39 adds the retry mechanism (mc_plan_approve(retry: "job-name")) that makes this status actionable. Without #39, needs_rebase is a dead-end — the plan fails with a better error message but still dies.

nigel-dev avatar Feb 12 '26 11:02 nigel-dev