532ba48927
A fresh run started from a repository's main checkout gets its own worktree and branch next to the repository, so runs never share a tree or see the operator's uncommitted work, and several can run at once. Retries and runs started in a linked worktree keep their directory. A clean, landed run tree is removed after success; anything else is kept. The delivery gate commits what the land stage left uncommitted in a run worktree, and no longer requires the operator's main checkout to be clean: Git's fast-forward refuses safely when a local change conflicts.
1.7 KiB
1.7 KiB
Every run in its own worktree (2026-11-10)
Why
Code-change runs almost never shipped. Most failures were delivery mechanics, not code: runs started from the shared checkout edited it directly, so
- only one run could use a repository at a time;
- the delivery gate refused because the operator's checkout had unrelated modified or untracked files (runs 257, 260), or found no linked item worktree at all (256);
- the land stage, a model committing from an incomplete changed-file list, committed part of the work or stopped as blocked (268, 291, 298).
What changed
internal/server/run_worktree.go: a fresh run whose workspace is a repository's main checkout gets<repo>-runs/<slug>on branchpipelines/run-<slug>fromHEAD(a subdirectory maps to the same subdirectory). Linked worktrees and retries are used as they are. A refused or duplicate admission discards the new tree. After a successful run, a clean tree whose branch is onmainis removed with its branch.internal/server/delivery_gate.go: in a run worktree the gate commits what the land stage left uncommitted (<title>\n\nPipelines run N.), so a partial file list can no longer drop work. The main checkout no longer has to be clean;git merge --ff-onlyrefuses on its own, changing nothing, when a local change would be overwritten (the error says the item is checked and ready on its branch).- Tests:
run_worktree_test.go; two diff-capture tests now start from a linked worktree, since their fake stages edit the original directory.
Not changed
- Untracked environment files (
.envrc,.tool-versions) are not copied into run trees; this repository has none. - Merge conflicts with a moved main still fail the gate with the branch kept.