Feature: Sandbox filesystem utilities Tests for the shared _fs_utils module used by CopyOnWriteSandbox and OverlaySandbox for pre-commit backup and atomic rollback. # backup_directory Scenario: backup_directory copies files preserving permissions and timestamps Given a source directory with files having varied permissions And an empty destination directory When I call backup_directory from source to destination Then the destination should contain all source files And file permissions should match between source and destination And file timestamps should match between source and destination Scenario: backup_directory preserves symlinks Given a source directory with a symlink And an empty destination directory When I call backup_directory from source to destination Then the destination should contain a symlink with the same target Scenario: backup_directory preserves root directory permissions Given a source directory with restricted permissions And an empty destination directory When I call backup_directory from source to destination Then the destination root permissions should match the source root permissions Scenario: backup_directory preserves directory timestamps Given a source directory with files having varied permissions And an empty destination directory When I call backup_directory from source to destination Then directory timestamps should match between source and destination # safe_restore Scenario: safe_restore atomically restores from backup Given an original directory with known content And a backup directory with different content When I call safe_restore from backup to original Then the original should contain the backup content And the backup directory should have been removed Scenario: safe_restore preserves original on rename failure Given an original directory with known content And a backup path that will cause rename to fail When I call safe_restore expecting an error Then the original directory should still contain its original content Scenario: safe_restore cleans up temporary rollback directory on success Given an original directory with known content And a backup directory with different content When I call safe_restore from backup to original Then the original should contain the backup content And no atomic-rollback-old directories should remain in the parent