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

Merged
trigger337 merged 1 commit from upstream-pr/825 into main 2026-11-29 19:00:36 +00:00
trigger337 commented 2026-11-24 14:17:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by trigger337 on 2026-11-24T14:17:14Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5473877114 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/825). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-24T14:17:14Z. --- 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 commented 2026-11-24 14:19:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:19:17Z.

Review: APPROVED


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
<!-- greyfinch-sync:ubiquitarianism/leonida:review:6040873256 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/825#pullrequestreview-6040873256). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:19:17Z. **Review:** APPROVED --- ### 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 commented 2026-11-24 14:29:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:29:23Z.

Review: APPROVED


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041069721 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/825#pullrequestreview-6041069721). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:29:23Z. **Review:** APPROVED --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T21:29:06Z.


#825 | head 5c8f0231b3 (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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246051686 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/825#issuecomment-7246051686). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T21:29:06Z. --- #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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:44:21Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246236083 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/825#issuecomment-7246236083). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:44:21Z. --- **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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T18:48:27Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260773981 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/825#issuecomment-7260773981). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T18:48:27Z. --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T18:50:58Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260807203 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/825#issuecomment-7260807203). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T18:50:58Z. --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T19:00:33Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260932483 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/825#issuecomment-7260932483). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T19:00:33Z. --- 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 reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!825
No description provided.