Skip to content

Add deletion tracking and directory fd support (v0.10.0)#84

Merged
corv89 merged 4 commits intomainfrom
add-deletion-tracking-and-directory-fd-support
Jan 6, 2026
Merged

Add deletion tracking and directory fd support (v0.10.0)#84
corv89 merged 4 commits intomainfrom
add-deletion-tracking-and-directory-fd-support

Conversation

@corv89
Copy link
Owner

@corv89 corv89 commented Jan 6, 2026

Summary

  • Deletion tracking: shutil.rmtree() and file deletions are now queued for approval instead of being blocked
  • Full support for fd-based directory operations required by Python 3.6+ shutil
  • New SHANNOT_SANDBOX=1 environment variable for scripts to detect sandbox mode

Changes

New syscalls

  • fdopendir, dirfd, rewinddir - directory stream operations
  • openat, unlinkat, fstatat64 - fd-relative file operations
  • dup, rpy_dup_noninheritable - file descriptor duplication

Fixes

  • RealDir/RealFile now return real filesystem inodes for os.path.samestat() compatibility
  • closedir properly closes underlying fd per POSIX (prevents fd leaks)
  • Detect file vs directory from actual filesystem, not just syscall flags

Integration

  • Deletions displayed in approve TUI with success/failure status
  • Audit logging for deletion events
  • Session summary shows deletion count

Test plan

  • All 191 tests pass
  • Demo script (cleanup.py) successfully queues deletions
  • shannot approve execute deletes files and directories correctly

corv89 added 2 commits January 6, 2026 21:58
- Add s_unlink and s_rmdir handlers that queue deletions for approval
- Support opening directories with O_RDONLY for fd-based operations
- Implement fdopendir, rewinddir, dirfd for directory enumeration
- Add *at syscalls: openat, unlinkat, fstatat64
- Fix RealDir/RealFile stat() to return real filesystem inodes
  (required for os.path.samestat compatibility)
- Add dup/rpy_dup_noninheritable for os.listdir(fd)
- Fix closedir to close underlying fd per POSIX (prevents fd leaks)
- Increase fd limits for deep recursive directory trees
- Add PendingDeletion dataclass and session integration
- Update approve TUI to display pending deletions
- Add audit logging for deletion events
- Show deletion count in session summary
- Move verbose DRY-RUN output to --debug mode only
- Add SHANNOT_SANDBOX=1 environment variable for sandbox detection
- Fix unlinkat to detect file vs directory from actual filesystem
@corv89 corv89 self-assigned this Jan 6, 2026
@corv89 corv89 added bug Something isn't working enhancement New feature or request labels Jan 6, 2026
corv89 added 2 commits January 6, 2026 22:14
- Add type annotations to s_rewinddir in virtualizedproc.py and mix_vfs.py
  to fix incompatible base class method signature errors
- Add mixin attribute declarations (debug_errors, virtual_cwd, remote_target)
  to MixVFS class for type checking
- Simplify hasattr checks to direct attribute access now that defaults exist
- Import Ptr in mix_vfs.py for type annotation
Address CodeQL warnings about empty except blocks by adding comments
explaining why errors are intentionally ignored:
- File size is optional metadata when tracking deletions
- Original file content may be unreadable for new/permission-restricted files
@corv89 corv89 merged commit 53a0d92 into main Jan 6, 2026
14 checks passed
@corv89 corv89 deleted the add-deletion-tracking-and-directory-fd-support branch January 6, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant