bvh_slot_check: restore write mode before unlink on replace failure and publish mode (BVH-SLOT-CHECK-STAGE-CLEANUP) #855

Open
github-bot wants to merge 1 commit from github-bot/gh-855 into main AGit
Owner

@⁠trigger337 on GitHub · 2026-11-24 14:39 UTC · original
trigger337:fix/bvh-slot-check-stage-cleanup → main · +26 −1 · 2 files · 1 commits · open

Overview

In tools/bvh_slot_check.py, apply published_mode(path) in save_evidence before os.replace, and ensure write mode (0o600) is restored before unlinking in the finally block if replacement fails.

On Windows, unlinking a read-only staged file or cleaning up on os.replace failure causes a PermissionError [WinError 5], leaving stranded temporary files behind and masking underlying exceptions.

Changes

  1. tools/bvh_slot_check.py: Import published_mode, apply it to temporary before os.replace, and restore write mode before temporary.unlink in finally:.
  2. tests/test_bvh_slot_check.py: Add test_save_evidence_cleanup_restores_write_mode_on_replace_failure asserting write mode restoration on replace failure.

agent: yes
AI-assisted: yes

**@⁠trigger337** on GitHub · 2026-11-24 14:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/855) `trigger337:fix/bvh-slot-check-stage-cleanup` → `main` · +26 −1 · 2 files · 1 commits · open ### Overview In `tools/bvh_slot_check.py`, apply `published_mode(path)` in `save_evidence` before `os.replace`, and ensure write mode (`0o600`) is restored before unlinking in the finally block if replacement fails. On Windows, unlinking a read-only staged file or cleaning up on `os.replace` failure causes a `PermissionError` [WinError 5], leaving stranded temporary files behind and masking underlying exceptions. ### Changes 1. `tools/bvh_slot_check.py`: Import `published_mode`, apply it to `temporary` before `os.replace`, and restore write mode before `temporary.unlink` in `finally:`. 2. `tests/test_bvh_slot_check.py`: Add `test_save_evidence_cleanup_restores_write_mode_on_replace_failure` asserting write mode restoration on replace failure. agent: yes AI-assisted: yes
Apply published_mode(path) to temporary file before atomic replacement,
and restore write permission (0o600) before unlinking in finally block
when replace fails, preventing Windows PermissionError [WinError 5] and
stranded temporary files.

agent: yes
AI-assisted: yes
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:24:41 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 14:42 UTC · original · approved these changes

Clean-Room Audit & Test Review — PR #855 (BVH-SLOT-CHECK-STAGE-CLEANUP)

Consistent, solid Windows filesystem hygiene fix.

Technical Verification

  1. File Mode Restoration:
    • save_evidence in tools/bvh_slot_check.py now sets published_mode(path) before replacement, and restores 0o600 write permissions in the finally block before calling unlink(missing_ok=True).
    • Prevents AccessDenied / PermissionError on Windows when removing read-only temporary staging artifacts.
  2. Test Coverage:
    • Adds test_save_evidence_cleanup_restores_write_mode_on_replace_failure in tests/test_bvh_slot_check.py using unittest.mock.
    • Verified clean execution.
  3. Clean-Room Compliance:
    • 100% clean-room tooling and synthetic mock tests.

Verdict: APPROVED

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 14:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/855#pullrequestreview-6041328240) · **approved these changes** ### Clean-Room Audit & Test Review — PR #855 (`BVH-SLOT-CHECK-STAGE-CLEANUP`) Consistent, solid Windows filesystem hygiene fix. #### Technical Verification 1. **File Mode Restoration**: - `save_evidence` in `tools/bvh_slot_check.py` now sets `published_mode(path)` before replacement, and restores `0o600` write permissions in the `finally` block before calling `unlink(missing_ok=True)`. - Prevents `AccessDenied` / `PermissionError` on Windows when removing read-only temporary staging artifacts. 2. **Test Coverage**: - Adds `test_save_evidence_cleanup_restores_write_mode_on_replace_failure` in `tests/test_bvh_slot_check.py` using `unittest.mock`. - Verified clean execution. 3. **Clean-Room Compliance**: - 100% clean-room tooling and synthetic mock tests. **Verdict: APPROVED**
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 14:43 UTC · original · approved these changes

Audited and verified. Correctly applies published_mode(path) prior to atomic file replacement in save_evidence() and restores write permission

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 14:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/855#pullrequestreview-6041347877) · **approved these changes** Audited and verified. Correctly applies published_mode(path) prior to atomic file replacement in save_evidence() and restores write permission
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/855/head:github-bot/gh-855'
git switch 'github-bot/gh-855'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-855'
git switch 'github-bot/gh-855'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-855'
git switch 'github-bot/gh-855'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-855'
git switch 'main'
git merge --squash 'github-bot/gh-855'
git switch 'main'
git merge --ff-only 'github-bot/gh-855'
git switch 'main'
git merge 'github-bot/gh-855'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.