[PR #1793] [MERGED] tools: guard ps_helper_probe.py empty coverage and atomic --json writes #1807

Closed
opened 2026-11-26 21:19:01 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1793
Author: @kirigayakazima
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: fix/ps-helper-probe-safety


📝 Commits (1)

  • a759e1e tools: guard ps_helper_probe.py empty coverage and atomic --json writes

📊 Changes

2 files changed (+198 additions, -31 deletions)

View changed files

📝 tests/test_ps_helper_probe.py (+88 -0)
📝 tools/ps_helper_probe.py (+110 -31)

📄 Description

Claimed in the coordination issue as: PS-HELPER-PROBE-EMPTY-COVERAGE-AND-ATOMIC-JSON (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162059721)

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)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1793 **Author:** [@kirigayakazima](https://github.com/kirigayakazima) **Created:** 11/25/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `fix/ps-helper-probe-safety` --- ### 📝 Commits (1) - [`a759e1e`](https://github.com/ubiquitarianism/leonida/commit/a759e1ebc6950449cdbb3399b429cae32561b947) tools: guard ps_helper_probe.py empty coverage and atomic --json writes ### 📊 Changes **2 files changed** (+198 additions, -31 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_ps_helper_probe.py` (+88 -0) 📝 `tools/ps_helper_probe.py` (+110 -31) </details> ### 📄 Description Claimed in the coordination issue as: PS-HELPER-PROBE-EMPTY-COVERAGE-AND-ATOMIC-JSON (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162059721) ### 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:19:01 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1807
No description provided.