diff options
| author | soryu <soryu@soryu.co> | 2026-02-18 17:20:32 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-02-18 17:20:32 +0000 |
| commit | 28b191cc0b0e69b864191673df9c141730c93e4f (patch) | |
| tree | e96fb3e21a37e5f3ef6c6937de13f87ad357d7d7 /makima/src/orchestration/directive.rs | |
| parent | 720ebdac2f64ce18e1de68d070cd3fe46f44547c (diff) | |
| download | soryu-28b191cc0b0e69b864191673df9c141730c93e4f.tar.gz soryu-28b191cc0b0e69b864191673df9c141730c93e4f.zip | |
fix: prevent directive step failure when PR branch is deleted after merge
Stop using pr_branch as base branch for step tasks since it may be
auto-deleted by GitHub after PR merge. Instead always use
continue_from_task_id or fall back to base_branch. Also add a safety
net in create_worktree that detects when a base branch ref no longer
exists and falls back to the repo's default branch.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'makima/src/orchestration/directive.rs')
| -rw-r--r-- | makima/src/orchestration/directive.rs | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/makima/src/orchestration/directive.rs b/makima/src/orchestration/directive.rs index a6bb85b..af6b18c 100644 --- a/makima/src/orchestration/directive.rs +++ b/makima/src/orchestration/directive.rs @@ -103,36 +103,25 @@ impl DirectiveOrchestrator { }; let mut continue_from_task_id = dep_tasks.first().map(|d| d.task_id); - // If no dependency tasks resolved, try to continue from previous work: - // 1) Use the directive's PR branch as base (contains all previous merged work) - // 2) Fall back to the last completed step's task for worktree continuation + // If no dependency tasks resolved, try to continue from the last completed step's worktree. + // We never use pr_branch as base because it may have been deleted after PR merge. let effective_base_branch = if continue_from_task_id.is_none() { - if step.pr_branch.is_some() { - tracing::info!( - step_id = %step.step_id, - pr_branch = ?step.pr_branch, - "Step has no deps — using directive PR branch as base" - ); - step.pr_branch.as_deref() - } else { - // No PR branch yet — try to continue from the last completed step's worktree - match repository::get_last_completed_step_task_id( - &self.pool, - step.directive_id, - ) - .await - { - Ok(Some(task_id)) => { - tracing::info!( - step_id = %step.step_id, - continue_from = %task_id, - "Step has no deps, no PR branch — continuing from last completed task" - ); - continue_from_task_id = Some(task_id); - step.base_branch.as_deref() - } - _ => step.base_branch.as_deref(), + match repository::get_last_completed_step_task_id( + &self.pool, + step.directive_id, + ) + .await + { + Ok(Some(task_id)) => { + tracing::info!( + step_id = %step.step_id, + continue_from = %task_id, + "Step has no deps — continuing from last completed task" + ); + continue_from_task_id = Some(task_id); + step.base_branch.as_deref() } + _ => step.base_branch.as_deref(), } } else { step.base_branch.as_deref() |
