Skip to content

v2.18.0 ·

A start that fails at any step can be run again

On 2026-10-15 autopilot tried to start two items and both failed inside git worktree add: "could not create leading directories". Most likely the sandbox around that session refused the folder. Fair enough. The retry two hours later failed on both items too, with a different message: "branch already exists".

That second failure was ours. git worktree add -b makes the branch first and the folder second. When the folder step fails, the branch stays. Nothing in aidlc start removed it, so every retry tripped over it, and the fix was git branch -D by hand.

This was the third fix for the same symptom. The first two each covered one step of the start. So this time I listed every step that writes something and checked what a failure at each one leaves.

What changed

A start whose worktree folder cannot be created now deletes the branch it just made. Run the same command again once the cause is gone and it gets as far as the first run did.

Two more steps leaked the same way. A blocking start action that failed kept the worktree, the branch, the registry entry and the roadmap move, so the retry hit "worktree target already exists". With --worktree that start is now undone too, and the item goes back to where it was. And a registry entry left over from an older run, whose worktree and branch are both gone, used to block the name until someone ran aidlc doctor. Now it is removed, with a note saying so.

Autopilot also checks that its agent command exists before it starts anything. If codex is not installed, it says so and starts nothing. Before, it created the worktree first and only noticed on the next pass.

Why this way

Every removal has to prove the thing is this start's. The branch is deleted only because the start checked it was absent a moment earlier. The registry entry is removed only on the same test aidlc doctor already prunes by. An entry whose branch still has commits is refused, because that could be someone's work.

What it does not fix

Branches leaked by runs before this release are still there. One with no registry entry looks exactly like a branch someone made by hand, so aidlc start keeps refusing it. Those take one git branch -D each, once.

Without --worktree, a failing start action still keeps the instance. The shipped branch action has already switched your checkout by then, and undoing that is not the start's call.