Skip to content

navmesh_tile_obj: publish output with file_mode and preflight directory --out - #7843

Open
Batushn wants to merge 2 commits into
ItsNotRexed:mainfrom
Batushn:fix/navmesh-tile-obj-publish
Open

Batushn wants to merge 2 commits into
ItsNotRexed:mainfrom
Batushn:fix/navmesh-tile-obj-publish

Conversation

@Batushn

@Batushn Batushn commented Nov 23, 2026 •

Copy link
Copy Markdown

Claimed in the coordination issue as: #7599 (comment)

What and why

  • file_mode.published_mode on staged OBJ output: tools/navmesh_tile_obj.py stages output via tempfile.NamedTemporaryFile(..., delete=False) and replaces --out with os.replace, leaving newly published files with 0600 instead of umask/existing-destination bits (matching the other staged writers using tools/file_mode.py). publish_obj() now applies published_mode(dest) before os.replace, and restores 0o600 before unlinking the staging file in finally: so a failed replace against a read-only destination does not strand a temporary file on Windows.
  • Directory --out preflight: main() now rejects an existing directory --out before calling navmesh_resources(args.archive), avoiding a full archive scan before failing at os.replace.
  • Tests: Added regression tests in tests/test_navmesh_tile_obj.py covering directory preflight (without scanning the archive), published_mode application without flipping os.umask, read-only staging cleanup on failed os.replace, and POSIX umask/replacement permission bit checks.

Tested

CPU-only Python standard-library tool change (no GPU code touched; host: Windows 11, Python 3.12.10, NVIDIA GeForce RTX 4060 Laptop GPU 32.0.15.8186 / AMD Radeon 780M 32.0.11026.1):

  • python -I tests/test_navmesh_tile_obj.py -v ? 6 tests run, 4 passed, 2 skipped (POSIX permission-bit subtests skipped on nt)
  • python -I tests/test_file_mode.py -v ? 5 tests run, 3 passed, 2 skipped (nt)
  • python -I tests/test_navmesh_nodes.py ? 17 passed
  • python -I tests/test_report_paths.py ? 22 tests run, 21 passed, 1 skipped
  • python -I tests/test_no_game_data_workflow.py ? 3 passed
  • python -m compileall -q make_game.py tools tests ? exit 0

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (N/A ? not a shader translator change)

@azterixx

Copy link
Copy Markdown

checked: #7843 | with: python -I -m unittest discover -s tests -p test_navmesh_tile_obj.py | on: macOS 27.2.1, Apple M1 Pro, CPython 3.15.2, head 002f276, CPU only | result: pass (6 tests; main@dde82f27e has 1)

@NiHuShu

NiHuShu commented Nov 23, 2026

Copy link
Copy Markdown

Compared this head 002f276e1c5ec7e59a9682473ff9a5d0ed4e0e69 with #7848 at eba034aa5195d8a019fbdcabe351c1d561826926 using the same synthetic three-vertex archive on CachyOS x86-64, CPython 3.14.10, as an unprivileged user. Baseline bf85ff703c34223928a6a64822c19e9925e91793 has the same exporter blob as the parent of #7843.

Observable result Baseline #7843 #7848
New OBJ under umask 0027 / replacement of 0604 0600 / 0600 0640 / 0604 0640 / 0604
Output beneath a regular file: scans before exit 2 1 1 0
Real 0555 parent: scans before exit 2 1 1 1
One injected sharing refusal, then allow replace: attempts / exit 1 / 2 1 / 2 2 / 0

I called navmesh_tile_obj.main([archive, "--tile", "0", "--out", dest]) with a counting wrapper on the real scanner. For the transient row only, the first os.replace raised a synthetic PermissionError with winerror=32; this exercises the retry decision on Linux. With a persistent POSIX PermissionError, both PRs staged with mode 0444, returned 2, preserved the previous OBJ bytes and left no staging file. The 0555-directory case used actual filesystem permissions without an injected error.

python -I tests/test_navmesh_tile_obj.py -v: 6/6 passed on #7843, 3/3 on #7848; zero skips. CPU only; GPU not used. AI-assisted.

@Batushn

Batushn commented Nov 23, 2026 •

Copy link
Copy Markdown
Author

Thanks @NiHuShu for the detailed comparison! Updated head to b09b27089:

  • Preflight non-directory --out parents before scanning the archive (so --out <file>/tile.obj now exits 2 with 0 archive scans).
  • Switch os.replace to the shared tools/replace_retry.py helper so transient Windows sharing refusals (winerror 5/32) retry cleanly.
  • Added regression tests for both in tests/test_navmesh_tile_obj.py (8 run, 6 passed, 2 POSIX-only skipped on Windows 11, Python 3.12.10; test_replace_retry.py 10/10 passed).

AI-assisted.

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested b09b2708 on Linux, CPython 3.14, CPU only, synthetic inputs, merged onto main dde82f27: pass

  • python -I tests/test_navmesh_tile_obj.py: 8 tests OK.
  • With only tools/navmesh_tile_obj.py reverted to main: 2 failures and 5 errors.
  • compileall (where the change has Python files) and scripts/check_no_game_data.py on the changed files: clean.

#7848 fixes the same symptom in the same function; the two conflict with each other, so only one can land.

Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting; claimed in #8047.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants