Recover sync after watcher overflow - #29
Open
raphaeldelio wants to merge 8 commits into
Open
Conversation
This was referenced Sep 10, 2026
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.
Problem
AFS sync watches local file changes and queues notifications for the sync daemon. The queue holds 1,024 events by default. A burst of changes, such as installing Python packages, can fill it and cause notifications to be dropped. The operating system watcher can also lose events.
AFS did not recover those missed changes automatically. Files could remain missing or outdated in Redis even though they existed locally, leaving an incomplete environment when restored in a new session.
Solution
When events are lost, request a scan of the current local and remote trees to synchronize the missed changes. The recovery signal has its own single slot, so it can still be recorded when the event queue is full. Repeated requests are combined, new losses during a scan trigger another pass, and failed scans are retried. Recovery also restores directory watches.
The scan coordinates with uploads and renames already in progress. The added checks address races that created unnecessary conflict copies or deleted local files after a failed remote rename. Actual file conflicts still preserve the local version.
Add
sync.watcherQueueCapacityso users can tune the event queue without changing code. The default remains 1,024.Validation
The full CLI race suite passed three times; builds and static checks passed. Linux ARM64 regressions passed 51 tests twice.
An AgentCore build combining this PR with #28 restored all 1,750 stress files and the complete 7,081 entry pandas and NumPy environment. All 4,142 package hashes passed, with no manual reconciliation or unwanted conflict copies.
The PRs can merge in either order. This change does not add a save completion API or protect local writes that have not reached Redis before a runtime stops.