Skip to content

bvh_tri_probe: stage --json so a write failure keeps the previous report - #9036

Open
Grimkeh wants to merge 1 commit into
ItsNotRexed:mainfrom
Grimkeh:fix/bvh-tri-probe-preserve-json
Open

Grimkeh wants to merge 1 commit into
ItsNotRexed:mainfrom
Grimkeh:fix/bvh-tri-probe-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

  • python3 -I -m unittest discover -s tests -p test_bvh_tri_probe.py — OK

Made with Cursor

Publish the probe report 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_bvh_tri_probe.py → 18 tests OK. No game files. AI-assisted (Devin).

@YordiLorenzo

Copy link
Copy Markdown

Tested 4cf76c4 on Linux, Python 3.14.4: pass

python3 -I tests/test_bvh_tri_probe.py: 18 of 18 pass
with main's bvh_tri_probe.py the new test errors (no write_json_report there), and main did truncate the old report
a mutant that truncates the destination before replace_retry: the new test fails

Nit: no flush and fsync before the replace, the fog_volumes version (#9040) has them.

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested 4cf76c4a on Linux, CPython 3.14, CPU only, synthetic inputs, merged onto main 867d922f: pass

  • python -I tests/test_bvh_tri_probe.py: Ran 18 tests, OK. With only the non-test files reverted to main: FAILED (errors=1), so the new tests exercise the change.
  • compileall and scripts/check_no_game_data.py on the changed files: clean.

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.

@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 4cf76c4a5 on Windows 11 (CPython 3.14.0, CPU only): pass.

What was verified:

  1. Preservation on write failure: Verified write_json_report() stages --json through .bvh_tri_probe-*.tmp and atomically replaces the destination with replace_retry. Tested that when replace_retry raises an OSError, any previous complete report remains unmodified.
  2. Missing parent directory creation: Verified that parent directories are created cleanly with os.makedirs(parent, exist_ok=True).
  3. Existing regular vs non-regular files: Verified regular files check writability without truncation via os.close(os.open(destination, os.O_WRONLY)), while non-regular files write directly.
  4. Test suite: python -I -m unittest discover -s tests -p test_bvh_tri_probe.py passes all 18 tests (was 17 on main).
  5. Hygiene: compileall, check_no_game_data.py, and git diff --check all exit 0 without warnings or formatting issues.

Negative control:

Restoring tools/bvh_tri_probe.py from origin/main while running test_bvh_tri_probe.py reliably failed with:
AttributeError: <module 'bvh_tri_probe' ...> does not have the attribute 'replace_retry'
confirming the new test exercises the staged publication logic.

No game files used. AI-assisted.

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.

5 participants