Feature: CopyOnWriteSandbox coverage round 3
  Covers remaining uncovered lines in copy_on_write.py:
    - Lines 263-265: backup_directory failure during commit cleans up and re-raises
    - Lines 297-302: safe_restore failure during commit error recovery logs warning
    - Lines 430-432: cleanup removes pre_commit_backup when it exists

  Scenario: Commit fails when backup_directory raises during pre-commit backup
    Given a cowcov3 test directory is set up
    And a cowcov3 sandbox is created and has changes
    And cowcov3 backup_directory is patched to raise an OSError
    When cowcov3 commit is attempted
    Then cowcov3 a SandboxCommitError should be raised
    And cowcov3 the temporary backup dir should have been cleaned up

  Scenario: Commit error recovery logs warning when safe_restore fails
    Given a cowcov3 test directory is set up
    And a cowcov3 sandbox is created and has changes
    And cowcov3 copy phase is patched to fail after backup succeeds
    And cowcov3 safe_restore is patched to raise an OSError
    When cowcov3 commit is attempted
    Then cowcov3 a SandboxCommitError should be raised
    And cowcov3 the safe_restore failure should have been logged as a warning
    And cowcov3 the pre_commit_backup should be preserved for manual recovery

  Scenario: Cleanup removes an existing pre_commit_backup directory
    Given a cowcov3 test directory is set up
    And a cowcov3 sandbox is created and has changes
    And cowcov3 the sandbox has a pre_commit_backup directory
    When cowcov3 cleanup is called
    Then cowcov3 the pre_commit_backup directory should be removed
    And cowcov3 the sandbox status should be CLEANED_UP
