Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1d345da. Configure here.
Replace hand-rolled fcntl.flock with the filelock package (flock on POSIX, msvcrt on Windows), with SoftFileLock available via VERIFIERS_LIMITER_SOFT_LOCK=1 for filesystems where flock is unreliable (e.g. NFS). State and lock now live in separate files, since SoftFileLock deletes its lock file on release. Lock acquisition is capped at 60s so a wedged holder surfaces as an error instead of an endless hang, and a corrupt bucket cursor resets instead of failing every create. filelock is declared as an explicit dependency.
samsja
force-pushed
the
filelock-creation-limiter
branch
from
September 16, 2026 02:18
1d345da to
5a84cc8
Compare
Member
Author
|
Addressed in e0d3f3b: native and soft locks now use distinct paths, filelock is pinned to the first published version with PID/hostname stale-marker recovery, and regression tests cover mode switching plus a process exiting while holding the soft lock. |
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.

Motivation
CreationLimiter(verifiers/v1/runtimes/limiters.py) hand-rolls cross-process mutual exclusion withfcntl.flockon the shared bucket file.flockmay not provide reliable cross-host exclusion on shared/NFS filesystems. If two writers enter together, the cursor can become corrupt and every later sandbox creation fails.Changes
Replace hand-written
fcntl.flockcalls withSoftFileLockunconditionally. There is no mode switch or environment variable: every process coordinates through the same NFS-safe atomic marker.Keep bucket state and mutual exclusion in separate paths:
{name}.bucket{name}.bucket.lockSoftFileLockremoves its marker on release, so it cannot share the cursor file.Require
filelock>=3.28, the first published release with PID/hostname ownership and same-host stale-marker recovery forSoftFileLock.Cap acquisition at 60 seconds rather than hanging indefinitely. A marker left by a failed process on another host cannot be proven stale from the current host, so this fails closed after 60 seconds instead of silently breaking mutual exclusion.
Recover a malformed bucket cursor by resetting it instead of failing every subsequent creation.
The leaky-bucket behavior is otherwise unchanged: the cursor advances while holding the exclusive lock, waiting happens after releasing it, a backlog above five minutes raises, and cursor timestamps remain comparable wall-clock values.
Note
Medium Risk
Changes mutual exclusion for shared rate limiting used by Modal and Prime tunnel creation; incorrect locking could still allow cursor corruption or spurious timeouts under NFS or crashed workers.
Overview
Replaces
fcntl.flockon the shared creation-rate limiter bucket withfilelock.SoftFileLockso cross-process coordination works on local and shared/NFS filesystems (used by Modal sandbox and Prime tunnel creation).Bucket cursor state stays in
{name}.bucketwhile the lock marker uses a separate{name}.bucket.lockpath, becauseSoftFileLockdeletes its marker on release. Addsfilelock>=3.28for stale-marker recovery, a 60s lock acquisition timeout instead of indefinite blocking, and resets corrupt bucket cursor values instead of failing permanently.Leaky-bucket semantics are unchanged: reserve under lock, sleep after release, and still fail when backlog exceeds five minutes.
Reviewed by Cursor Bugbot for commit fe6843a. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Replace
fcntl.flockwithSoftFileLockinCreationLimiter._reservefcntl.flockon the bucket file to a sidecarSoftFileLockwith a.locksuffix, so releasing the lock marker does not delete the cursor state file.ValueError. The five-minute backlog check is unchanged.filelock>=3.28as a project dependency to support staleSoftFileLockmarker recovery.filelockor a shared filesystem lacking comparable wall clocks may see lock acquisition failures or stale marker recovery issues.Macroscope summarized fe6843a.