Repository navigation
fix(runtime): never replace a published uv script - #2777
Open
faresobeid wants to merge 2 commits into
Open
faresobeid wants to merge 2 commits into
faresobeid wants to merge 2 commits into
Conversation
faresobeid
marked this pull request as ready for review
October 13, 2026 17:49
Contributor
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused one-file fix to publish content-addressed uv scripts without replacing an existing file, preserving stable execution for concurrent workers while leaving dependency setup unchanged. The behavior change is limited to correcting the publication race and does not introduce a new capability or schema/infrastructure change. No code changes detected at You can add or adjust custom eligibility rules. Learn more. |
faresobeid
force-pushed
the
fix/uv-script-link-if-absent
branch
from
October 16, 2026 17:27
5751883 to
9c98de9
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Runtime.prepare_uv_scriptpublished a content-addressed script withmv -f <tmp> <path>, even when the file already existed. On a shared filesystem (the subprocess runtime keeps scripts in~/.cache/verifiers/runtimes/scripts, shared across nodes) that rename swaps the file under workers that are running it, and they fail withENOENT.What
ln <tmp> <path>.link(2)is atomic and fails if the path exists, so a published script is never replaced. The path is content-addressed, so an existing file has the same bytes.test -f <path>checks a copy is in place beforeuv sync.Validation
uv run pytest tests/unit: 217 passed, 19 skipped (Docker/Prime/harbor). ruff check/format clean.SubprocessRuntime.run_uv_scripton the same script on the shared FS: all exited 0, one file left, no temp files.Note
Medium Risk
Changes shared-filesystem publication semantics for all
prepare_uv_scriptcallers; if the destination exists but is not a regular file, bootstrap may be skipped while execution still proceeds from cache.Overview
Fixes a race when multiple workers publish the same content-addressed UV script on a shared filesystem.
prepare_uv_scriptno longer usesmv -fto install the script. It writes a unique temp file, trieslninto the stable path (fails silently if another worker already published), removes the temp, then runstest -fbeforeuv sync/ interpreter resolution. That way an in-use script is never replaced and concurrent execs avoid ENOENT from rename.The
run_uv_scriptdocstring is updated to describe hard-link publication instead of temp + atomic move.Reviewed by Cursor Bugbot for commit 9c98de9. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
Runtime.prepare_uv_scriptto never replace a published uv scriptChanges script publication from an atomic move (forced replace) to a hard-link from a unique temp file, so concurrent workers preparing the same content-addressed script do not clobber each other. The temp file is removed after the link attempt, and dependency/bootstrap setup only proceeds when the destination is a regular file. Also updates the docstring of
Runtime.run_uv_scriptto match. Risk: if the destination exists but is not a regular file (e.g. a dangling symlink on a shared filesystem), setup in base.py is skipped — check callers that assume setup always runs.Macroscope summarized 9c98de9.