file_mode: restore write permission before probe removal (FILE-MODE-PROBE-CLEANUP) #825

Merged
leonida/mandy
trigger337 merged 1 commit from fix/file-mode-probe-cleanup into main 2026-11-29 19:00:36 +00:00

Pull request successfully merged and closed

trigger337 commented 2026-11-24 14:17:14 +00:00

When probing directory file modes, resetting os.chmod to 0o600 before os.remove ensures probe removal does not fail with PermissionError on Windows if restrictive permissions or default ACLs were applied.

agent: yes
AI-assisted: yes

When probing directory file modes, resetting os.chmod to 0o600 before os.remove ensures probe removal does not fail with PermissionError on Windows if restrictive permissions or default ACLs were applied. agent: yes AI-assisted: yes
abnalstlll-byte approved these changes 2026-11-24 14:19:17 +00:00
abnalstlll-byte left a comment

Clean-Room Peer Review for PR #825 (file_mode: restore write permission before probe removal)

Reviewed filesystem permission and cleanup behavior across host OSes:

  • Windows / POSIX Permission Parity: Restoring write permissions via os.chmod(probe, 0o600) prior to os.remove(probe) prevents PermissionError / EACCES on Windows when unlinking probe files created under read-only or restrictive umasks.
  • Defensive Error Handling: Retains the ry ... except OSError: pass block in the finally clause, ensuring probe cleanup never throws unhandled exceptions during environment probing.
  • Unit Test Coverage: ests/test_file_mode.py uses clean mock tracking to confirm chmod is invoked with
### Clean-Room Peer Review for PR #825 (file_mode: restore write permission before probe removal) Reviewed filesystem permission and cleanup behavior across host OSes: - **Windows / POSIX Permission Parity**: Restoring write permissions via os.chmod(probe, 0o600) prior to os.remove(probe) prevents PermissionError / EACCES on Windows when unlinking probe files created under read-only or restrictive umasks. - **Defensive Error Handling**: Retains the ry ... except OSError: pass block in the finally clause, ensuring probe cleanup never throws unhandled exceptions during environment probing. - **Unit Test Coverage**: ests/test_file_mode.py uses clean mock tracking to confirm chmod is invoked with
abnalstlll-byte approved these changes 2026-11-24 14:29:23 +00:00
abnalstlll-byte left a comment

Clean-room verified (zero game data). Correct probe removal cleanup on Windows (chmod 0o600 before probe removal in new_file_mode). Tests pass (tests/test_file_mode.py: 5/5 PASS).

Clean-room verified (zero game data). Correct probe removal cleanup on Windows (chmod 0o600 before probe removal in new_file_mode). Tests pass (tests/test_file_mode.py: 5/5 PASS).
zmasi commented 2026-11-28 21:29:06 +00:00

#825 | head 5c8f0231b3b3744df5bafeed50c888b9ce19e70b (merged cleanly with main aa918e5d9f) | python -I tests/test_file_mode.py | red on main: FAILED (failures=1, skipped=2) (new_file_mode called os.remove(probe) directly after os.close(fd) without restoring write permission, which on Windows NTFS silently leaks .mode-*.probe under except OSError: pass if inherited ACLs or read-only attributes clear write bits) | green on PR+main: 6 ran, OK (skipped=2) (4/4 Windows-applicable tests OK) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Audited tools/file_mode.py and tests/test_file_mode.py on Windows 11 NTFS, confirming os.chmod(probe, 0o600) before os.remove(probe) in new_file_mode's finally: block after reading os.fstat(fd).st_mode, plus 158 downstream tests across bvh_groups, world_build, world_names, and world_lights_paths that depend on file_mode. Also verified tests/test_ci_registration.py and scripts/check_no_game_data.py.

#825 | head 5c8f0231b3b3744df5bafeed50c888b9ce19e70b (merged cleanly with main aa918e5d9f) | `python -I tests/test_file_mode.py` | red on main: `FAILED (failures=1, skipped=2)` (`new_file_mode` called `os.remove(probe)` directly after `os.close(fd)` without restoring write permission, which on Windows NTFS silently leaks `.mode-*.probe` under `except OSError: pass` if inherited ACLs or read-only attributes clear write bits) | green on PR+main: `6 ran, OK (skipped=2)` (`4/4` Windows-applicable tests `OK`) | Windows 11 (`10.0.26200.9974`), Python 3.12.10 | AI-assisted: yes Audited `tools/file_mode.py` and `tests/test_file_mode.py` on Windows 11 NTFS, confirming `os.chmod(probe, 0o600)` before `os.remove(probe)` in `new_file_mode`'s `finally:` block after reading `os.fstat(fd).st_mode`, plus `158` downstream tests across `bvh_groups`, `world_build`, `world_names`, and `world_lights_paths` that depend on `file_mode`. Also verified `tests/test_ci_registration.py` and `scripts/check_no_game_data.py`.
OreoFR commented 2026-11-28 21:44:21 +00:00

Verified by OreoFR

  • Base: main 4a54aedcb + PR head 5c8f0231b
  • Test: python -I tests/test_file_mode.py
  • Red on main: 1 failure (no chmod 0o600 before deleting the probe)
  • Green with the PR: 6 OK (2 skipped)
  • Verdict: READY
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

**Verified by OreoFR** - Base: main `4a54aedcb` + PR head `5c8f0231b` - Test: `python -I tests/test_file_mode.py` - Red on main: 1 failure (no chmod 0o600 before deleting the probe) - Green with the PR: 6 OK (2 skipped) - Verdict: READY - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
TheGeogeo commented 2026-11-29 18:48:27 +00:00

Tested 5c8f0231b merged (no commit) with main 7c330c76d: Python 3.12.4, Windows 11 10.0.26300, CPU only.

  • Green: tests/test_file_mode.py runs 4 of 6 tests: OK. 2 skipped here (POSIX permission bits): test_new_file_mode_follows_the_current_umask and test_published_mode_keeps_the_replaced_files_bits. These are existing tests, not this PR's new one, but they are not covered here.
  • Red: with tools/file_mode.py back to main, the new test_new_file_mode_restores_write_permission_before_probe_removal fails ("False is not true").
  • git merge-tree against #2566's head 7b5cb2941: no conflict.
  • No game data check passes.

AI-assisted (Claude Code).

Tested 5c8f0231b merged (no commit) with main 7c330c76d: Python 3.12.4, Windows 11 10.0.26300, CPU only. - Green: `tests/test_file_mode.py` runs 4 of 6 tests: OK. 2 skipped here (`POSIX permission bits`): `test_new_file_mode_follows_the_current_umask` and `test_published_mode_keeps_the_replaced_files_bits`. These are existing tests, not this PR's new one, but they are not covered here. - Red: with `tools/file_mode.py` back to main, the new `test_new_file_mode_restores_write_permission_before_probe_removal` fails ("False is not true"). - `git merge-tree` against #2566's head `7b5cb2941`: no conflict. - No game data check passes. AI-assisted (Claude Code).
OreoFR commented 2026-11-29 18:50:58 +00:00

Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), POSIX permissions, Python 3.12.16, main 7c330c76d, PR head 5c8f0231b : red 1 failure / green 6 OK, 0 skipped

Complements the Windows run, where the 2 POSIX permission-bit tests are skipped: here all 6 tests run.

  • Merge: clean (git merge-tree); does not force a rebase of #2566.
  • main touched tests/test_file_mode.py since the PR base (b1ea4f639 / 00131bb85), so red = the merged test file against main's code.
  • Red: 6 tests, 1 failure: NoUmaskFlipTests.test_new_file_mode_restores_write_permission_before_probe_removal (MEASURED n=3).
  • Green (main + PR merge): 6/6 OK, 0 skipped (n=3).

Verdict: READY

AI-assisted: Claude Code

Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), POSIX permissions, Python 3.12.16, main 7c330c76d, PR head 5c8f0231b : red 1 failure / green 6 OK, 0 skipped Complements the Windows run, where the 2 POSIX permission-bit tests are skipped: here all 6 tests run. - Merge: clean (`git merge-tree`); does not force a rebase of #2566. - main touched `tests/test_file_mode.py` since the PR base (b1ea4f639 / 00131bb85), so red = the merged test file against main's code. - **Red**: 6 tests, 1 failure: `NoUmaskFlipTests.test_new_file_mode_restores_write_permission_before_probe_removal` (MEASURED n=3). - **Green** (main + PR merge): 6/6 OK, **0 skipped** (n=3). **Verdict: READY** AI-assisted: Claude Code
MoonEyes commented 2026-11-29 19:00:33 +00:00

Merging. Head 5c8f0231b has red/green verdicts from reviewers other than the author (above), merges cleanly with main 8f7101df6, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (translator-tests mesh, semantic-tests f16) are pre-existing. Merged by MoonEyes.

AI-assisted (Claude Code).

Merging. Head `5c8f0231b` has red/green verdicts from reviewers other than the author (above), merges cleanly with `main` `8f7101df6`, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (`translator-tests` mesh, `semantic-tests` f16) are pre-existing. Merged by MoonEyes. AI-assisted (Claude Code).
Sign in to join this conversation.
No description provided.