Skip to content

navmesh_nodes: stage --out so a write failure keeps the previous report - #8884

Open
Grimkeh wants to merge 1 commit into
ItsNotRexed:mainfrom
Grimkeh:fix/navmesh-nodes-preserve-json
Open

Grimkeh wants to merge 1 commit into
ItsNotRexed:mainfrom
Grimkeh:fix/navmesh-nodes-preserve-json

Conversation

@Grimkeh

@Grimkeh Grimkeh commented Nov 23, 2026

Copy link
Copy Markdown

Summary

Claim: #8504 (comment)

Synthetic; no game files. AI-assisted (Cursor / Composer).

Test plan

  • test_json_write_failure_preserves_previous_report OK
  • test_cli_refuses_an_unwritable_out_before_the_archives_are_read is already red on main when run as root (chmod 0444 does not make the file unwritable) — unchanged by this PR

Made with Cursor

Publish through a temp file + replace so a mid-write OSError leaves any prior complete JSON intact.

Co-authored-by: Cursor <cursoragent@cursor.com>
@catminou4

Copy link
Copy Markdown

Tested on Apple M1 Max, macOS 27.2.1 arm64, Python 3.12.16: python -I tests/test_navmesh_nodes.py → 18 tests OK. No game files. AI-assisted (Devin).

@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Independent verification on Windows 11 x64 (CPython 3.14.0rc2, CPU-only, zero game data). Tested at commit 37c12b417.

Test Results & Negative Controls

  1. Test Suite Verification on HEAD (37c12b417):

    • python -I tests/test_navmesh_nodes.py: 18/18 tests OK (2.81s).
    • Confirms that write_json_text() stages through a hidden temporary file (.navmesh_nodes-*.tmp) in the destination directory, validates writeability upfront via os.open(destination, os.O_WRONLY), and atomically commits via replace_retry.
    • test_json_write_failure_preserves_previous_report verifies that a simulated failure during replace_retry preserves the pre-existing complete report byte-for-byte.
  2. Negative Control against origin/main:

    • Reverting tools/navmesh_nodes.py to origin/main while keeping the PR tests failed with:
      ERROR: test_json_write_failure_preserves_previous_report (__main__.ArchiveTest.test_json_write_failure_preserves_previous_report)
      AttributeError: module 'navmesh_nodes' has no attribute 'replace_retry'
      FAILED (errors=1)
      
      confirming the new test discriminates cleanly against the direct open(a.out, "w") implementation.
  3. Hygiene:

    • python -m compileall -q tools/navmesh_nodes.py tests/test_navmesh_nodes.py: clean.
    • python -I scripts/check_no_game_data.py tools/navmesh_nodes.py tests/test_navmesh_nodes.py: clean (exit 0).
    • git diff --check origin/main: clean (exit 0). Line endings strictly LF.

LGTM. Approved.

AI-assisted.

@sds-228 sds-228 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Focused suite passes 18/18 at this head; the new write-failure case fails against the pre-change source. The staged publish leaves an existing complete JSON report untouched when the final replace fails.

AI-assisted (OpenCode).

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