Skip to main content

Module worktree

Module worktree 

Source
Expand description

Git worktree lifecycle for isolated phase runs.

Each batty work <phase> run gets a dedicated branch/worktree: <phase-slug>-run-<NNN>. The executor runs in that worktree. Cleanup is merge-aware:

  • merged runs are removed (worktree + branch)
  • rejected/failed/unmerged runs are retained for inspection

Structs§

AgentWorktree
DispatchBranchReset
IntegrationWorktree
MainStartRefSelection
PhaseWorktree

Enums§

CleanupDecision
PreserveFailureMode
RunOutcome
WorktreeResetReason

Functions§

branch_fully_merged
Check if all commits on branch since diverging from base are already present on base (e.g., via cherry-pick).
commits_ahead
Count commits on the current branch that are ahead of base (e.g. “main”). Returns 0 if the branch is at or behind base.
ensure_worktree_branch_for_dispatch
git_current_branch
Get the current branch name for a repository/worktree path.
has_uncommitted_changes
Check if a worktree has uncommitted changes (staged or unstaged).
prepare_agent_worktrees
Prepare (or reuse) one worktree per parallel agent slot for a phase.
prepare_integration_worktree
prepare_phase_worktree
Create an isolated git worktree for a phase run.
reset_worktree_to_base
Reset a worktree to point at its base branch. Used to clean up after a cherry-pick merge has made the task branch redundant.
reset_worktree_to_base_with_options
resolve_phase_worktree
Resolve the phase worktree for a run.
sync_phase_board_to_worktree
Sync the phase board from the source tree into the worktree.