tools: guard ps_helper_probe.py empty coverage and atomic --json writes #1793

Manually merged
github merged 1 commit from gh-pr/1793/head into gh-pr/1793/base 2026-11-26 10:05:35 +00:00
Owner

@⁠kirigayakazima on GitHub · 2026-11-25 12:14 UTC · original
kirigayakazima:fix/ps-helper-probe-safety → main · +198 −31 · 2 files · 1 commits · merged 2026-11-25 17:35 UTC

Claimed in the coordination issue as: PS-HELPER-PROBE-EMPTY-COVERAGE-AND-ATOMIC-JSON (#1608)

What and why

  • Handle zero covered pixels cleanly in tools/ps_helper_probe.py's analyze(): avoid ValueError: max() iterable argument is empty and report False for coverage-dependent checks (entry EXEC, s_wqm, quad packing, lane order, interpolation accuracy, and without s_wqm EXEC) instead of vacuously passing on empty sets.
  • Preflight-validate --json before opening the GPU oracle (measure()), rejecting empty/whitespace strings, trailing directory separators, existing directories, and non-directory ancestors with exit code 2.
  • Publish --json atomically (tempfile.mkstemp beside the resolved symlink target, explicit newline="\n", trailing \n, fsync, published_mode, and replace_retry), preserving any existing file and cleaning up staging files on failure (exit 2, no traceback).
  • Add regression tests in tests/test_ps_helper_probe.py.

Tested

  • python -I tests/test_ps_helper_probe.py -v -> Ran 10 tests in 0.068s, OK (skipped=1) (hardware test skipped without GPU runtime build; verified in a detached upstream/main worktree that the new tests fail before the fix: FAILED (failures=5, errors=2, skipped=1)).
  • python -I tests/test_ci_registration.py -> Ran 16 tests in 4.522s, OK.
  • python -I tests/test_text_write_line_endings.py -> Ran 3 tests in 12.592s, OK.
  • python -I scripts/check_no_game_data.py tools/ps_helper_probe.py tests/test_ps_helper_probe.py -> exit 0.
  • python -I -m compileall -q tools/ps_helper_probe.py tests/test_ps_helper_probe.py and git diff --check -> clean.

GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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)
**@⁠kirigayakazima** on GitHub · 2026-11-25 12:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1793) `kirigayakazima:fix/ps-helper-probe-safety` → `main` · +198 −31 · 2 files · 1 commits · merged 2026-11-25 17:35 UTC Claimed in the coordination issue as: PS-HELPER-PROBE-EMPTY-COVERAGE-AND-ATOMIC-JSON (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why - Handle zero covered pixels cleanly in `tools/ps_helper_probe.py`'s `analyze()`: avoid `ValueError: max() iterable argument is empty` and report `False` for coverage-dependent checks (entry EXEC, `s_wqm`, quad packing, lane order, interpolation accuracy, and without `s_wqm` EXEC) instead of vacuously passing on empty sets. - Preflight-validate `--json` before opening the GPU oracle (`measure()`), rejecting empty/whitespace strings, trailing directory separators, existing directories, and non-directory ancestors with exit code `2`. - Publish `--json` atomically (`tempfile.mkstemp` beside the resolved symlink target, explicit `newline="\n"`, trailing `\n`, `fsync`, `published_mode`, and `replace_retry`), preserving any existing file and cleaning up staging files on failure (exit `2`, no traceback). - Add regression tests in `tests/test_ps_helper_probe.py`. ### Tested - `python -I tests/test_ps_helper_probe.py -v` -> `Ran 10 tests in 0.068s`, `OK (skipped=1)` (hardware test skipped without GPU runtime build; verified in a detached `upstream/main` worktree that the new tests fail before the fix: `FAILED (failures=5, errors=2, skipped=1)`). - `python -I tests/test_ci_registration.py` -> `Ran 16 tests in 4.522s`, `OK`. - `python -I tests/test_text_write_line_endings.py` -> `Ran 3 tests in 12.592s`, `OK`. - `python -I scripts/check_no_game_data.py tools/ps_helper_probe.py tests/test_ps_helper_probe.py` -> exit `0`. - `python -I -m compileall -q tools/ps_helper_probe.py tests/test_ps_helper_probe.py` and `git diff --check` -> clean. GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64) AI-assisted: yes ### Checklist - [x] Based on current main and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] 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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:05:32 +00:00
github manually merged commit a759e1ebc6 into gh-pr/1793/base 2026-11-26 10:05:35 +00:00
Author
Owner

@⁠madvillain91 on GitHub · 2026-11-25 13:19 UTC · original · reviewed

Independent Windows 11 26H2 (26300.9711) check at a759e1ebc against main 384abe5b0 (PR base 0d80bc5df), using CPython 3.12.3 (python -I) and Git for Windows 2.56.0.windows.2. Passed test_ps_helper_probe.py (8 passed, 2 skipped -- symlink WinError 1314 without SeCreateSymbolicLinkPrivilege and AMD OnHardware gate, 0.077s), test_ci_registration.py (16/16 in 6.279s), and test_text_write_line_endings.py (3/3 in 15.168s), with check_no_game_data.py and compileall clean. Verified empty-coverage analyze() safety (no max() crash or vacuous passes), preflight --json path validation before measure(), and atomic replace_retry JSON writes with trailing LF and cleanup on failure. LGTM.

**@⁠madvillain91** on GitHub · 2026-11-25 13:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1793#pullrequestreview-6058350446) · **reviewed** Independent Windows 11 26H2 (26300.9711) check at a759e1ebc against main 384abe5b0 (PR base 0d80bc5df), using CPython 3.12.3 (python -I) and Git for Windows 2.56.0.windows.2. Passed test_ps_helper_probe.py (8 passed, 2 skipped -- symlink WinError 1314 without SeCreateSymbolicLinkPrivilege and AMD OnHardware gate, 0.077s), test_ci_registration.py (16/16 in 6.279s), and test_text_write_line_endings.py (3/3 in 15.168s), with check_no_game_data.py and compileall clean. Verified empty-coverage analyze() safety (no max() crash or vacuous passes), preflight --json path validation before measure(), and atomic replace_retry JSON writes with trailing LF and cleanup on failure. LGTM.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 17:35 UTC · original

Merged. Thank you, @⁠kirigayakazima. Empty coverage is guarded, and --json writes are atomic.

  • The new tests fail on main and pass here; the docs, line-ending and CI/ctest registration checks pass, and so does the game-data check.
  • Checked on main fd33a31a2 + a759e1ebc: the semantic suite passes (490 files, 6,292 tests, 0 files failed); test_ps_helper_probe pass; the 15 docs and writer tests pass; check_no_game_data.py is clean on the 2 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 17:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1793#issuecomment-7169718539) Merged. Thank you, @⁠kirigayakazima. Empty coverage is guarded, and `--json` writes are atomic. - The new tests fail on `main` and pass here; the docs, line-ending and CI/ctest registration checks pass, and so does the game-data check. - **Checked on `main` `fd33a31a2` + `a759e1ebc`:** the semantic suite passes (490 files, 6,292 tests, 0 files failed); `test_ps_helper_probe` pass; the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 2 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.