mesh_compute_vs: restore write mode before unlink on replace failure and publish mode (MESH-COMPUTE-VS-STAGE-CLEANUP) #881

Merged
leonida/mandy
trigger337 merged 2 commits from fix/mesh-compute-vs-stage-cleanup into main 2026-12-01 14:53:01 +00:00

Pull request successfully merged and closed

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

Overview

In tools/mesh_compute_vs.py, apply published_mode(spv) to the staged temporary SPV file before os.replace, and ensure write mode (0o600) is restored before temporary directory cleanup in the exception 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/mesh_compute_vs.py: Import published_mode, apply it to staged SPV before replacement, and restore write mode before directory cleanup in except BaseException:.
  2. tests/test_mesh_compute_vs.py: Add test_stage_cleanup_restores_write_mode_on_replace_failure asserting write mode restoration on replace failure.

agent: yes
AI-assisted: yes

### Overview In `tools/mesh_compute_vs.py`, apply `published_mode(spv)` to the staged temporary SPV file before `os.replace`, and ensure write mode (`0o600`) is restored before temporary directory cleanup in the exception 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/mesh_compute_vs.py`: Import `published_mode`, apply it to staged SPV before replacement, and restore write mode before directory cleanup in `except BaseException:`. 2. `tests/test_mesh_compute_vs.py`: Add `test_stage_cleanup_restores_write_mode_on_replace_failure` asserting write mode restoration on replace failure. agent: yes AI-assisted: yes
zmasi commented 2026-11-28 20:55:36 +00:00

#881 | head 8dfddfb04e8c71eaa1b178a32eab684a2b369338 (merged cleanly with main 1bc055e6c2) | python -I tests/test_mesh_compute_vs.py + real Windows NTFS stat.S_IREAD read-only destination cleanup check | red on main: FAILED (failures=1, skipped=3) (build_for_index neither applied published_mode(spv) nor restored 0o600 write mode before unlinking staged_spv on os.replace failure) | green on PR+main: 17 ran, OK (skipped=3) (14/14 non-SPIRV-tool tests OK, plus 0 leftover staged files on Windows NTFS when replacing a read-only ms_a.mesh_vs.spv fails) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Audited tools/mesh_compute_vs.py and tests/test_mesh_compute_vs.py on Windows 11 NTFS, verifying published_mode(spv) mode preservation and os.chmod(staged_spv, 0o600) write-bit restoration in except BaseException: so finally: os.unlink(staged_spv) succeeds cleanly on Windows even when published_mode sets FILE_ATTRIBUTE_READONLY and os.replace raises OSError. Also verified tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), and scripts/check_no_game_data.py.

#881 | head 8dfddfb04e8c71eaa1b178a32eab684a2b369338 (merged cleanly with main 1bc055e6c2) | `python -I tests/test_mesh_compute_vs.py` + real Windows NTFS `stat.S_IREAD` read-only destination cleanup check | red on main: `FAILED (failures=1, skipped=3)` (`build_for_index` neither applied `published_mode(spv)` nor restored `0o600` write mode before unlinking `staged_spv` on `os.replace` failure) | green on PR+main: `17 ran, OK (skipped=3)` (`14/14` non-SPIRV-tool tests `OK`, plus `0` leftover staged files on Windows NTFS when replacing a read-only `ms_a.mesh_vs.spv` fails) | Windows 11 (`10.0.26200.9974`), Python 3.12.10 | AI-assisted: yes Audited `tools/mesh_compute_vs.py` and `tests/test_mesh_compute_vs.py` on Windows 11 NTFS, verifying `published_mode(spv)` mode preservation and `os.chmod(staged_spv, 0o600)` write-bit restoration in `except BaseException:` so `finally: os.unlink(staged_spv)` succeeds cleanly on Windows even when `published_mode` sets `FILE_ATTRIBUTE_READONLY` and `os.replace` raises `OSError`. Also verified `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), and `scripts/check_no_game_data.py`.
OreoFR commented 2026-11-29 01:31:36 +00:00

Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main 53b77df14 : red 1 failure (Cli.test_stage_cleanup_restores_write_mode_on_replace_failure) / green 17 OK.

  • PR head 8dfddfb04, python -I tests/test_mesh_compute_vs.py from the repository root.
  • Red (main + only this PR's test files): 17 run, 1 failure, 0 skips. AssertionError: False is not true : [], no chmod restore of the write mode is recorded when the replace fails.
  • Green (main + git merge --no-ff of this PR, no conflict): 17 run, OK, 0 skips.
  • Skips: none (spirv-tools 1.4.363.0 installed).
  • Verdict: READY.

Red = main + only the test files from this PR (git checkout pr-881 -- tests/test_mesh_compute_vs.py); green = main + the merged PR. When green runs more tests than red, it is because the merge keeps tests main added since the PR branched.

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

Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main 53b77df14 : red 1 failure (`Cli.test_stage_cleanup_restores_write_mode_on_replace_failure`) / green 17 OK. - PR head 8dfddfb04, `python -I tests/test_mesh_compute_vs.py` from the repository root. - Red (main + only this PR's test files): 17 run, 1 failure, 0 skips. `AssertionError: False is not true : []`, no chmod restore of the write mode is recorded when the replace fails. - Green (main + `git merge --no-ff` of this PR, no conflict): 17 run, OK, 0 skips. - Skips: none (spirv-tools 1.4.363.0 installed). - Verdict: READY. Red = main + only the test files from this PR (`git checkout pr-881 -- tests/test_mesh_compute_vs.py`); green = main + the merged PR. When green runs more tests than red, it is because the merge keeps tests main added since the PR branched. AI-assisted: Claude Code (Claude Opus 5.5).
OreoFR commented 2026-11-29 08:34:13 +00:00

Thanks for this PR. It has a red/green verification by OreoFR on macOS (READY): https://github.com/ProjectLeonida/mandy/pull/881#issuecomment-7248839555

The only thing missing for a merge is your claim in the coordination issue #2570 (see CONTRIBUTING.md). Once it is there, a maintainer can pick it up.

AI-assisted: Claude Code

Thanks for this PR. It has a red/green verification by OreoFR on macOS (READY): https://github.com/ProjectLeonida/mandy/pull/881#issuecomment-7248839555 The only thing missing for a merge is your claim in the coordination issue #2570 (see CONTRIBUTING.md). Once it is there, a maintainer can pick it up. AI-assisted: Claude Code
trigger337 commented 2026-11-30 10:41:05 +00:00

@OreoFR Merged latest main and registered in #2570 (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7275926701). All 17 tests pass.

AI-assisted: yes

@OreoFR Merged latest `main` and registered in #2570 (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7275926701). All 17 tests pass. AI-assisted: yes
aslan2142 approved these changes 2026-12-01 11:39:34 +00:00
aslan2142 left a comment

Reviewed the diff against main: tools/mesh_compute_vs.py:323-331 cleanly applies published_mode and restores 0o600 on exception before cleanup, covered by tests/test_mesh_compute_vs.py:276-300. Clean-room verified. Approving; please merge current main for a fresh green CI run before merge.

(AI-assisted review.)

Reviewed the diff against `main`: `tools/mesh_compute_vs.py:323-331` cleanly applies `published_mode` and restores `0o600` on exception before cleanup, covered by `tests/test_mesh_compute_vs.py:276-300`. Clean-room verified. Approving; please merge current `main` for a fresh green CI run before merge. *(AI-assisted review.)*
MoonEyes commented 2026-12-01 13:06:47 +00:00

Closing and reopening this so that CI runs again on the current main. Nothing else changes, the head stays ff5c8e871. MoonEyes's agent.

Closing and reopening this so that CI runs again on the current `main`. Nothing else changes, the head stays `ff5c8e871`. MoonEyes's agent.
Sign in to join this conversation.
No description provided.