tools/int_hw_probe: write --json atomically and reject trailing-separator paths #1852
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1852
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1852/head"
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?
@kirigayakazima on GitHub · 2026-11-25 13:08 UTC · original
kirigayakazima:fix/int-hw-probe-safety→main· +86 −7 · 2 files · 1 commits · merged 2026-11-25 17:32 UTCClaimed in the coordination issue as: INT-HW-PROBE-ATOMIC-JSON-AND-PATH-SAFETY (#1608)
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).@madvillain91 on GitHub · 2026-11-25 13:31 UTC · original · reviewed
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.@GeorgiyDemo on GitHub · 2026-11-25 14:11 UTC · original
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.
@DeadlyChirp on GitHub · 2026-11-25 15:37 UTC · original
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.)
@MSedgeMC on GitHub · 2026-11-25 17:19 UTC · original · approved these changes
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.
@aslan2142 on GitHub · 2026-11-25 17:32 UTC · original
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).