bvh_match: restore write mode before unlink on replace failure and publish mode on Windows (BVH-MATCH-STAGE-CLEANUP) #759

Merged
leonida/mandy
trigger337 merged 1 commit from fix/bvh-match-stage-cleanup into main 2026-11-28 11:02:49 +00:00

Pull request successfully merged and closed

trigger337 commented 2026-11-24 13:32:32 +00:00

In tools/bvh_match.py write_json_report:

  1. os.chmod(staged.name, published_mode(destination)) was skipped on Windows (if os.name != "nt":) because unlinking a temporary file chmod'd to read-only mode in finally: failed with PermissionError on Windows. As a result, Windows output files retained NamedTemporaryFile's private 0600 permissions.
  2. Ensure os.chmod(staged.name, 0o600) before os.unlink in finally:, enabling published_mode(destination) on all platforms and ensuring that temporary staging files are never leaked on failed replacements.
  3. Added regression tests in tests/test_bvh_match.py verifying read-only replacement failure staging cleanup with strict Windows unlink emulation, and Windows published mode application.

agent: yes
AI-assisted: yes

In `tools/bvh_match.py` `write_json_report`: 1. `os.chmod(staged.name, published_mode(destination))` was skipped on Windows (`if os.name != "nt":`) because unlinking a temporary file chmod'd to read-only mode in `finally:` failed with `PermissionError` on Windows. As a result, Windows output files retained `NamedTemporaryFile`'s private `0600` permissions. 2. Ensure `os.chmod(staged.name, 0o600)` before `os.unlink` in `finally:`, enabling `published_mode(destination)` on all platforms and ensuring that temporary staging files are never leaked on failed replacements. 3. Added regression tests in `tests/test_bvh_match.py` verifying read-only replacement failure staging cleanup with strict Windows unlink emulation, and Windows published mode application. agent: yes AI-assisted: yes
abnalstlll-byte approved these changes 2026-11-24 13:33:53 +00:00
abnalstlll-byte left a comment

Audited and verified. Clean-room compliant.

  • Restores 0o600 file mode before unlinking staging file on replace failure in tools/bvh_match.py.
  • Applies published_mode across all platforms.
  • Regression tests in tests/test_bvh_match.py PASS.
Audited and verified. Clean-room compliant. - Restores 0o600 file mode before unlinking staging file on replace failure in tools/bvh_match.py. - Applies published_mode across all platforms. - Regression tests in tests/test_bvh_match.py PASS.
tiguan26 approved these changes 2026-11-25 04:01:48 +00:00
tiguan26 left a comment

Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Same pattern as the rest of the *-STAGE-CLEANUP series: on a failed replace the staged file gets 0o600 back before os.unlink, so a staged copy left read-only (the published mode on Windows) is still removed; and the published mode now also applies on Windows (the os.name guard is gone), using file_mode.published_mode. Only the staging/permission lines change.

AI-assisted (Claude).

Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Same pattern as the rest of the *-STAGE-CLEANUP series: on a failed replace the staged file gets 0o600 back before os.unlink, so a staged copy left read-only (the published mode on Windows) is still removed; and the published mode now also applies on Windows (the os.name guard is gone), using file_mode.published_mode. Only the staging/permission lines change. AI-assisted (Claude).
MoonEyes commented 2026-11-28 11:02:45 +00:00

Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 23 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)

Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18). Targeted batch of 23 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13. AI-assisted (Claude Code, Claude Opus 5.5)
Sign in to join this conversation.
No description provided.