tools/int_hw_probe: write --json atomically and reject trailing-separator paths #1852
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1852"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-25T13:08:33Z.
Claimed in the coordination issue as: INT-HW-PROBE-ATOMIC-JSON-AND-PATH-SAFETY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7163274170)
What and why
os.sep/os.altsep) intools/int_hw_probe.py's_validate_json_out()beforeos.path.abspath()strips them, so directory-like--jsonpaths fail upfront with exit2.--jsonoutput atomically in_write_json_atomic()(tempfile.mkstempbesideos.path.realpath(path), explicitnewline="\n", trailing\n,os.fsync,published_mode, andreplace_retry.replace), preserving any existing file and cleaning up staging files on write/replace failure.tests/test_int_hw_probe.py.Tested
python -I tests/test_int_hw_probe.py -v->Ran 13 tests in 2.008s,OK.upstream/main(98c2f777) baseline worktree with updatedtests/test_int_hw_probe.py->Ran 13 tests in 2.450s,FAILED (failures=3, errors=1).python -I tests/test_ci_registration.py->Ran 16 tests in 6.463s,OK.python -I tests/test_text_write_line_endings.py->Ran 3 tests in 14.893s,OK.python -I scripts/check_no_game_data.py tools/int_hw_probe.py tests/test_int_hw_probe.py,python -I -m compileall -q tools/int_hw_probe.py tests/test_int_hw_probe.py, andgit diff --check-> exit0.GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64)
AI-assisted: yes
Checklist
needs rebase).Imported from ubiquitarianism/leonida. Originally posted by madvillain91 on 2026-11-25T13:31:25Z.
Review: COMMENTED
Independent Windows 11 26H2 (26300.9711) check at
71c86830fagainst main384abe5b0(PR base98c2f7777), using CPython 3.12.3 (python -I) and Git for Windows 2.56.0.windows.2. Passed test_int_hw_probe.py (13/13 in 3.705s) and test_text_write_line_endings.py (3/3 in 17.509s), with check_no_game_data.py and compileall clean. Verified trailing-separator --json rejection (both os.sep and os.altsep on Windows) before running translator/oracle cases, and atomic --json writes via replace_retry with trailing LF, existing-file preservation, and staging cleanup on failure. LGTM.Imported from ubiquitarianism/leonida. Originally posted by GeorgiyDemo on 2026-11-25T14:11:48Z.
Tested
71c86830fon Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), againstmain71a769d7d(Python GPU probe; hardware oracle not run):tests/test_int_hw_probe.py: 13 passed, 12 subtests passed at this head.main: 4 failed, 11 passed, 10 subtests — the trailing-separator--jsonguard and the atomic write path are new.AI-assisted; synthetic fixtures only, no game data.
Imported from ubiquitarianism/leonida. Originally posted by DeadlyChirp on 2026-11-25T15:37:40Z.
Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.
python -m pytest -q tests/test_int_hw_probe.py:(AI-assisted test run; output checked by hand.)
Imported from ubiquitarianism/leonida. Originally posted by MSedgeMC on 2026-11-25T17:19:37Z.
Review: APPROVED
Verified on the PR branch: python3 -m unittest tests.test_int_hw_probe -v -> 13 tests OK, including the new tests for trailing-separator paths, preserving an existing JSON file on write failure, and staging cleanup with replace_retry. The fix writes atomically via a staging file and os.replace, which is the right pattern for a tool that otherwise truncates a good report on disk-full. Python-only, no game data.
Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T17:32:47Z.
Merged. Thank you, @kirigayakazima.
--jsonis written atomically, and paths with a trailing separator are rejected.mainand pass here; the docs, line-ending and CI/ctest registration checks pass, and so does the game-data check.main082ebe440+71c86830f: the semantic suite passes (490 files, 6,292 tests, 0 files failed);test_int_hw_probepass; the 15 docs and writer tests pass;check_no_game_data.pyis clean on the 2 changed files.AI-assisted (Claude Code, Claude Opus 5.5).