feat(file-sync): sync remote changes back to host on teardown (+2 bugfixes) - #27091
Closed
Master-Rensei wants to merge 3 commits into
Closed
Master-Rensei wants to merge 3 commits into
Master-Rensei wants to merge 3 commits into
Conversation
Add sync_back() to FileSyncManager — on sandbox cleanup, downloads the remote .hermes/ directory as a tar archive, diffs against SHA-256 hashes of what was originally pushed, and applies only changed files. - SHA-256 content hashing on push for accurate change detection - Retry with exponential backoff (3 attempts, 2s/4s/8s) - SIGINT deferred during sync-back to prevent partial writes - fcntl.flock serialization for concurrent gateway sandboxes - Last-write-wins conflict resolution with logged warnings - New files created on remote are pulled back via path inference - Backend implementations: SSH (tar cf over pipe), Modal (exec tar cf, read stdout), Daytona (exec tar cf, SDK download_file) - Wired into cleanup() for all three backends (runs before ControlMaster close / sandbox terminate / sandbox stop) 28 new tests (10 FSM core + 18 backend-specific), 72 total passing.
1. Tar paths now match _pushed_hashes keys — backends tar from / so entries have full absolute paths (e.g. root/.hermes/skills/f.py) instead of relative ./skills/f.py that never matched hash lookups 2. _infer_host_path simplified — removed broken grandparent match that computed garbled suffixes for new remote files 3. Lock path uses get_hermes_home() instead of Path.home() — fixes wrong lock path when HERMES_HOME is overridden or using profiles 4. SIGINT trap guarded by threading.current_thread() check — skips signal.signal() on non-main threads (gateway workers) instead of crashing with ValueError on every retry attempt
Snapshot _pushed_hashes alongside _synced_files before the try block so both are restored atomically on failure. Previously a mid-sync exception (e.g. host file deleted between upload and hash) would leave _pushed_hashes partially updated while _synced_files rolled back, causing sync_back() to make wrong change-detection decisions.
Contributor
|
Duplicate of #11291 (already merged). This PR reopens a previously closed fork branch, but the feature (file-sync back on teardown) was already landed via a salvage PR. |
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.
Summary
Re-opens the file-sync-back feature (previously PR #8018, closed 2026-04-17) with two additional bugfix commits addressing BugBot findings and failure rollback handling.
Replaces closed PR #8018.
Changes (3 commits ahead)
feat(file-sync): sync remote changes back to host on teardown — On sandbox teardown,
FileSyncManagerdownloads the remote.hermes/directory, diffs against SHA-256 hashes, and applies only changed files back to the host. Backends: SSH (tar over pipe), Modal (exec tar), Daytona (SDK download).fix(file-sync): resolve 4 bugbot findings in sync-back — Addresses BugBot-flagged issues in the sync-back implementation.
fix(file-sync): rollback _pushed_hashes on sync failure — Ensures
_pushed_hashesis properly rolled back when sync-back fails, preventing inconsistent state.Branch is 4575 commits behind main.