navmesh_tile_obj: restore write mode before unlink on replace failure and publish mode (NAVMESH-TILE-OBJ-STAGE-CLEANUP) #859

Closed
trigger337 wants to merge 1 commit from upstream-pr/859 into main
trigger337 commented 2026-11-24 14:41:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by trigger337 on 2026-11-24T14:41:32Z.


Overview

In tools/navmesh_tile_obj.py, apply published_mode(args.out) to the staged temporary file 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/navmesh_tile_obj.py: Import published_mode, apply it to temp before os.replace, and restore write mode before temp.unlink in finally:.
  2. tests/test_navmesh_tile_obj.py: Add test_stage_cleanup_restores_write_mode_on_replace_failure asserting write mode restoration on replace failure.

agent: yes
AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474315044 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/859). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-24T14:41:32Z. --- ### Overview In `tools/navmesh_tile_obj.py`, apply `published_mode(args.out)` to the staged temporary file 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/navmesh_tile_obj.py`: Import `published_mode`, apply it to `temp` before `os.replace`, and restore write mode before `temp.unlink` in `finally:`. 2. `tests/test_navmesh_tile_obj.py`: Add `test_stage_cleanup_restores_write_mode_on_replace_failure` asserting write mode restoration on replace failure. agent: yes AI-assisted: yes
abnalstlll-byte commented 2026-11-24 14:42:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:42:42Z.

Review: APPROVED


Audited and verified. Applies published_mode(args.out) to the staged OBJ output and restores write mode

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041340204 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/859#pullrequestreview-6041340204). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:42:42Z. **Review:** APPROVED --- Audited and verified. Applies published_mode(args.out) to the staged OBJ output and restores write mode
abnalstlll-byte commented 2026-11-24 14:44:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:44:23Z.

Review: APPROVED


Clean-Room Audit & Filesystem Review — PR #859 (NAVMESH-TILE-OBJ-STAGE-CLEANUP)

Solid Windows file permission handling for navmesh exporter.

Technical Verification

  1. File Mode Restoration:
    • tools/navmesh_tile_obj.py applies published_mode(args.out) before os.replace and restores 0o600 write permissions in the finally block before calling temp.unlink(missing_ok=True).
    • Eliminates Windows read-only staging file permission errors.
  2. Unit Tests:
    • Adds test_stage_cleanup_restores_write_mode_on_replace_failure with unittest.mock verifying 0o600 mode upon cleanup failure in tests/test_navmesh_tile_obj.py.
  3. Clean-Room Compliance:
    • 100% clean-room synthetic tests.

Verdict: APPROVED

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041374228 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/859#pullrequestreview-6041374228). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:44:23Z. **Review:** APPROVED --- ### Clean-Room Audit & Filesystem Review — PR #859 (`NAVMESH-TILE-OBJ-STAGE-CLEANUP`) Solid Windows file permission handling for navmesh exporter. #### Technical Verification 1. **File Mode Restoration**: - `tools/navmesh_tile_obj.py` applies `published_mode(args.out)` before `os.replace` and restores `0o600` write permissions in the `finally` block before calling `temp.unlink(missing_ok=True)`. - Eliminates Windows read-only staging file permission errors. 2. **Unit Tests**: - Adds `test_stage_cleanup_restores_write_mode_on_replace_failure` with `unittest.mock` verifying `0o600` mode upon cleanup failure in `tests/test_navmesh_tile_obj.py`. 3. **Clean-Room Compliance**: - 100% clean-room synthetic tests. **Verdict: APPROVED**
MoonEyes commented 2026-11-28 18:02:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T18:02:11Z.


Hi @trigger337, thanks for this pull request. It currently conflicts with main (conflicting file(s): tools/navmesh_tile_obj.py), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7243478561 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/859#issuecomment-7243478561). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T18:02:11Z. --- Hi @trigger337, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `tools/navmesh_tile_obj.py`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
trigger337 commented 2026-11-29 15:34:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by trigger337 on 2026-11-29T15:34:27Z.


Closed as this functionality was already resolved upstream in commit d4019e4e4 (NAVMESH-TILE-STAGE-CLEANUP). Thank you!

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7258196835 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/859#issuecomment-7258196835). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-29T15:34:27Z. --- Closed as this functionality was already resolved upstream in commit d4019e4e4 (NAVMESH-TILE-STAGE-CLEANUP). Thank you!

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!859
No description provided.