[Bug] Bootstrap lock reclaims stale locks non-atomically, allowing concurrent venv rebuilds #1767
Adolanium
started this conversation in
Bug reports
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Affected area
Coding agent and CLI
What happened?
acquireBootstrapLockreclaims a stale lock withrmthenmkdir. Two processes can both decide the same lock is stale. One can delete a lock the other just created. Both think they hold it, so two venv rebuilds run at once and can corrupt the environment. This hits on fresh installs and fleet boots.Steps to reproduce
acquireBootstrapLock.Expected behavior
Acquire by creating a uniquely named candidate directory, writing the pid, and renaming it onto the lock path. Rename fails if the target exists. Reclaim a stale lock by renaming it aside before deleting it, so a live lock created in between is never touched. On Windows, treat
EPERMas lock-held too. This is the pattern the daemon launch lock already uses.Prime Agent version
0.7.1 / source as of 2026-08-08
Environment
Windows (directory rename onto an existing target returns EPERM) and POSIX.
Additional context
Original report: #1005
Tested patch, closed in the August 15 backlog sweep: #1006
All reactions