NAVMESH-TILE-STAGE-CLEANUP: harden staged OBJ output and cleanup #906

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

@⁠fitzypopper on GitHub · 2026-11-24 15:09 UTC · original
fitzypopper:navmesh-tile-stage-cleanup → main · +54 −1 · 2 files · 1 commits · open

Claimed in the coordination issue as: NAVMESH-TILE-STAGE-CLEANUP (claim comment).

tools/navmesh_tile_obj.py wrote its staged OBJ with NamedTemporaryFile's mode and, on a failed os.replace, deleted the staged file in finally without making it writable first. On Windows a staged file carrying a read-only destination's mode cannot be unlinked, so the cleanup error masks the real ERROR: line. This publishes the staged file with published_mode(out) and, on failure, chmods it to 0o600 before unlinking, with both cleanup failures suppressed so the original error survives.

New tests/test_navmesh_tile_stage_cleanup.py patches os.replace to fail and asserts the staged file is made writable, removed, and the previous output is left intact. Verified red on origin/main and green with this change.

No game data: synthetic navmesh archive only. python3 -I scripts/check_no_game_data.py passes; line-ending test passes.

AI-assisted: yes.

**@⁠fitzypopper** on GitHub · 2026-11-24 15:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/906) `fitzypopper:navmesh-tile-stage-cleanup` → `main` · +54 −1 · 2 files · 1 commits · open Claimed in the coordination issue as: `NAVMESH-TILE-STAGE-CLEANUP` ([claim comment](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)). `tools/navmesh_tile_obj.py` wrote its staged OBJ with `NamedTemporaryFile`'s mode and, on a failed `os.replace`, deleted the staged file in `finally` without making it writable first. On Windows a staged file carrying a read-only destination's mode cannot be unlinked, so the cleanup error masks the real `ERROR:` line. This publishes the staged file with `published_mode(out)` and, on failure, chmods it to `0o600` before unlinking, with both cleanup failures suppressed so the original error survives. New `tests/test_navmesh_tile_stage_cleanup.py` patches `os.replace` to fail and asserts the staged file is made writable, removed, and the previous output is left intact. Verified red on `origin/main` and green with this change. No game data: synthetic navmesh archive only. `python3 -I scripts/check_no_game_data.py` passes; line-ending test passes. AI-assisted: yes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:27:30 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 21:13 UTC · original

Reviewed d4019e4: navmesh_tile_obj now publishes with the destination's mode (file_mode.published_mode, like the ~20 tools already on main) and its failed-replace cleanup chmods the staged file 0o600 before unlink. I ran this on Linux with a synthetic archive only: the new test passes here and fails on main (no chmod recorded), test_navmesh_tile_obj.py and test_navmesh_decode.py pass on both, and an unmocked probe shows an existing 0o444 OBJ keeping its bits after export (main silently rewrote it to 0600) while a new OBJ gets the umask bits; failed replaces stay rc 2 with the real error, destination untouched, no leftovers on either tree. The Windows unlink-of-read-only claim is covered by the mocked call-order test only. No findings. AI-assisted review.

Recommendation: Merge

**@⁠PierreEbele** on GitHub · 2026-11-25 21:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/906#issuecomment-7174787038) Reviewed d4019e4: navmesh_tile_obj now publishes with the destination's mode (file_mode.published_mode, like the ~20 tools already on main) and its failed-replace cleanup chmods the staged file 0o600 before unlink. I ran this on Linux with a synthetic archive only: the new test passes here and fails on main (no chmod recorded), test_navmesh_tile_obj.py and test_navmesh_decode.py pass on both, and an unmocked probe shows an existing 0o444 OBJ keeping its bits after export (main silently rewrote it to 0600) while a new OBJ gets the umask bits; failed replaces stay rc 2 with the real error, destination untouched, no leftovers on either tree. The Windows unlink-of-read-only claim is covered by the mocked call-order test only. No findings. AI-assisted review. **Recommendation:** Merge
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/906/head:github-bot/gh-906'
git switch 'github-bot/gh-906'

Merge

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