-
Notifications
You must be signed in to change notification settings - Fork 9
bug: rr sync does not acquire lock, can overwrite files during active execution #181
Description
Summary
The standalone rr sync command does not acquire a lock before syncing files to the remote host. This means a rr sync from one terminal can overwrite source files on the remote while another terminal's rr run or rr <task> is actively executing against those files.
Expected behavior
rr sync should respect the lock system, same as rr run / rr exec / rr <task>. If a lock is held, rr sync should wait for it to release before syncing.
Current behavior
rr sync connects and syncs directly without checking or acquiring a lock. The SetupWorkflow path (used by rr run, rr exec, task execution) correctly acquires the lock before syncing:
Connect -> Lock -> Sync -> Execute -> Release
But rr sync (in internal/cli/sync.go) skips locking entirely:
Connect -> Sync
Reproduction
- Terminal 1:
rr run "sleep 30"(acquires lock, syncs, runs) - Terminal 2 (different worktree or after modifying files):
rr sync - Terminal 2's sync overwrites source files on remote while Terminal 1's command is still running
Suggested fix
Add lock acquisition to the Sync() function in internal/cli/sync.go, matching the pattern used by SetupWorkflow. The lock should be acquired before syncing and released after sync completes.
Found while reviewing #176.