Prevent two tasks from colliding in one checkout
Status: Ready
Article ID: 058
Truth label: Limited
Audience: System designer
Reader outcome: Recognize that task-state isolation does not prevent two valid tasks from editing the same repository checkout.
Related articles: 033, 046, 057
Target week: 23
Last verified: 2026-09-13
Technical reviewer: Codex source audit
Editorial reviewer: Codex editorial audit
One tree, one run
Central prevents two workers from owning the same task, and it also refuses to put two runs into one working tree. A task whose project path is held by a live run (assigned or in progress) or by a checkpoint-held run is skipped when a worker polls, and the check is repeated inside the claim transaction, where a second worker that saw the tree free in the same second gets a 409 naming the holding task. A checkpoint counts as a hold on purpose: its edits sit in the tree awaiting review and its CLI session resumes into them, so a second run there would corrupt the reviewer's diff and change the ground under the resume.
Tree identity is normalized before comparison. Windows spellings fold to their
WSL form and are lowercased, so C:\repo, C:/repo, and /mnt/c/repo are
one tree, which matters because a WSL worker can open a Windows path.
Why the control lives in Central
The diff a run reports is the whole repository against HEAD. Two agents in
one checkout would interleave their edits and each would report the other's
changes as its own. With engine-distinct workers on one machine (a Claude Code
worker and a Codex worker, say) that collision is ordinary rather than rare,
so it is decided at routing and claim time rather than left to the operator.
What the hold does not cover
The hold keys on the registered project path. Two projects registered on overlapping paths, a worker that runs something by hand in a checkout, or a verification command that writes outside the tree are outside it. Git still cannot identify which process wrote an uncommitted line, so inspect the checkout before every retry.
Detect the problem
Compare run times, assigned workers, changed-file lists, captured diffs, and working-tree status. Unexpected files or a diff that changes during execution are collision evidence, and a task that stays pending while a worker is idle may simply be waiting for a held tree; the claim conflict names the holder.
Current limits
The hold serializes runs per tree; it does not create worktrees, clone checkouts, or queue merges. For real parallelism on one repository, register separate checkouts as separate projects.
Next lesson
Continue with Keep polling as worker liveness.
Derivative map
- Weekly package: WEEK-23
- Long video: VIDEO-W23-LONG
- Shorts: SHORT-W23-PROBLEM, SHORT-W23-MECHANISM, SHORT-W23-WARNING
- Email: EMAIL-W23
- LinkedIn: LI-W23-A, LI-W23-B
- X: X-W23-A, X-W23-B
- Visual: VISUAL-W23
Review record
- Task ownership and checkout concurrency checked against current source and audit.
- Missing checkout-lock and merge controls reviewed.
- Mitigation distinguishes serialization from isolated worktrees.
- Internal links and repository voice reviewed.
Review completed: 2026-08-27
Re-audited against the running product: 2026-09-13