BVH-REHYDRATE-STAGE-CLEANUP: harden staged BLAS output and cleanup #915

Manually merged
github merged 1 commit from gh-pr/915/head into gh-pr/915/base 2026-11-26 09:28:05 +00:00
Owner

@⁠fitzypopper on GitHub · 2026-11-24 15:10 UTC · original
fitzypopper:bvh-rehydrate-stage-cleanup → main · +47 −0 · 2 files · 1 commits · merged 2026-11-24 20:32 UTC

Claimed in the coordination issue as: BVH-REHYDRATE-STAGE-CLEANUP (claim comment).

tools/bvh_rehydrate.py's _publish wrote the staged BLAS with NamedTemporaryFile's mode and unlinked it on failure without making it writable first. On Windows a staged file carrying a read-only destination's mode cannot be unlinked, which masks the original error. This uses published_mode(dest) for the staged file and, on failure, chmods it to 0o600 before unlinking, with cleanup errors suppressed so the original exception survives.

New tests/test_bvh_rehydrate_stage_cleanup.py patches os.replace to fail, asserts the staged file is made writable and removed, and checks the previous output is intact. Verified red on origin/main and green with this change. The existing 18 test_bvh_rehydrate.py tests still pass.

No game data: synthetic bytes only. check_no_game_data.py and the line-ending test pass.

AI-assisted: yes.

**@⁠fitzypopper** on GitHub · 2026-11-24 15:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/915) `fitzypopper:bvh-rehydrate-stage-cleanup` → `main` · +47 −0 · 2 files · 1 commits · merged 2026-11-24 20:32 UTC Claimed in the coordination issue as: `BVH-REHYDRATE-STAGE-CLEANUP` ([claim comment](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)). `tools/bvh_rehydrate.py`'s `_publish` wrote the staged BLAS with `NamedTemporaryFile`'s mode and unlinked it on failure without making it writable first. On Windows a staged file carrying a read-only destination's mode cannot be unlinked, which masks the original error. This uses `published_mode(dest)` for the staged file and, on failure, chmods it to `0o600` before unlinking, with cleanup errors suppressed so the original exception survives. New `tests/test_bvh_rehydrate_stage_cleanup.py` patches `os.replace` to fail, asserts the staged file is made writable and removed, and checks the previous output is intact. Verified red on `origin/main` and green with this change. The existing 18 `test_bvh_rehydrate.py` tests still pass. No game data: synthetic bytes only. `check_no_game_data.py` and the line-ending test pass. AI-assisted: yes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:28:03 +00:00
github manually merged commit 687f51beca into gh-pr/915/base 2026-11-26 09:28:05 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 20:32 UTC · original

Merged. This was compared with #828 for BVH-REHYDRATE-STAGE-CLEANUP. The _publish change is the same in both and matches bvh_index and navmesh_index; this PR's test is the stronger one:

  • It checks the outcome: after a failed os.replace, no .bvh_rehydrate-* file is left and the previous output is intact.
  • It fails on main and passes here, locally on Linux. It merges cleanly.

Worth a follow-up: a test that an output with mode 0640 keeps it, and one for a read-only destination.

AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 20:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/915#issuecomment-7143699109) Merged. This was compared with #828 for BVH-REHYDRATE-STAGE-CLEANUP. The `_publish` change is the same in both and matches `bvh_index` and `navmesh_index`; this PR's test is the stronger one: - It checks the outcome: after a failed `os.replace`, no `.bvh_rehydrate-*` file is left and the previous output is intact. - It fails on `main` and passes here, locally on Linux. It merges cleanly. Worth a follow-up: a test that an output with mode 0640 keeps it, and one for a read-only destination. AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.