Expand description
Taking a branch over from an earlier attempt at the same task.
A retried task can reopen a branch (magi/f82f/A) that the previous
run still has checked out in its own worktree. Git holds a branch in one
worktree at a time, so the new run’s review cannot start, and the only way
forward used to be an agent asking the operator whether the old worktree
may be deleted. Auto-fold cannot help: it only folds terminal runs, and an
unfinished run keeps its worktrees on purpose so it can be resumed.
When the run holding the branch is an earlier attempt at the same task
(crate::queue::Task::earlier_attempts) - superseded or not: blocked,
failed, stale or parked alike - and nothing is driving it, its worktree
(and only its worktree) is released before the review starts. The
branch, every commit and any pull request stay exactly where they were.
A branch held by a run of another task is released on the same terms when magi can prove the worktree is its own: the path is a candidate worktree one run’s record names, laid under that record’s own worktree root, and the run is not being driven. Anything else - a path magi did not make, a live run, uncommitted files - is left alone and the refusal names which.
decide is pure; release is the only function here that touches git
or disk. A hand-run magi review has no task, so it carries a Takeover
with no earlier attempts and can only release a worktree of a run magi
itself recorded.
Structs§
- Holder
- What is known about the run and worktree holding the branch.
- Released
- A worktree that was released, with what is needed to put it back if the review that took the branch over never starts.
- Takeover
- The earlier attempts at a task a new run may take a branch over from.
Enums§
- Decision
- The verdict of
decide. - Owner
- Whose worktree holds the branch, as far as magi can prove.
- Refused
- The operator has to decide: the takeover was refused, and the text says why.
Functions§
- decide
- Whether
holder’s worktree may be released to a new run. - release
- Release the worktree holding
branchtonew_run, when an earlier attempt at the same task, or a run magi itself recorded, holds it and it is safe. Returns the run whose worktree was released (seeReleased), orNonewhen nothing needed (or was allowed) to happen.