[PR #1638] cvt_norm_mods_probe: upfront atomic JSON validation, RuntimeError handling, and result count guard #1652

Open
opened 2026-11-26 20:21:59 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1638
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/cvt-norm-mods-probe-json-and-guards


📝 Commits (1)

  • 61949ea cvt_norm_mods_probe: upfront atomic JSON validation, RuntimeError handling, and result count guard

📊 Changes

2 files changed (+188 additions, -18 deletions)

View changed files

📝 tests/test_cvt_norm_mods_probe.py (+66 -0)
📝 tools/cvt_norm_mods_probe.py (+122 -18)

📄 Description

Item ID: CVT-NORM-MODS-PROBE-JSON-AND-GUARDS
Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155043403

Summary

Harden JSON reporting, CLI validation, and harness error handling in tools/cvt_norm_mods_probe.py:

  • Upfront --json validation (validate_json_path): reject empty/whitespace paths, directories, trailing path separators, non-directory parent blockers, and unwritable existing files with exit 2 before opening hw_oracle (previously --json " " created a literal whitespace file and non-directory parent blockers only failed after running all GPU sweeps).
  • Atomic JSON writes (write_json_report): serialize upfront with allow_nan=False and LF endings, handle non-regular targets like /dev/null directly, resolve symlinks before staging to preserve symlink targets, apply file_mode.published_mode, and publish via replace_retry.replace.
  • CLI & harness guards:
    • Reject empty/whitespace --hw-arch upfront (exit 2).
    • Catch RuntimeError from oracle.run() cleanly (harness error: ..., exit 2) while still closing the oracle in finally.
    • Detect len(raw_results) != len(meta) in evaluate_results() as a harness error instead of silently truncating via zip() and reporting mismatches=0.
  • Tests (tests/test_cvt_norm_mods_probe.py): added 3 test methods covering upfront --json/--hw-arch validation, atomic/symlink/NaN//dev/null writes, result count mismatch, and RuntimeError handling.

Verification

  • AI-assisted: yes
  • GPUs tested: none (CPU synthetic unit tests + FakeOracle on macOS; no GPU, LLVM, or game data present)
  • python3 -W error -I tests/test_cvt_norm_mods_probe.py -v: 15 passed, 2 skipped (AMD clang / llvm-mc absent)
  • Mutation check against unpatched main: ran=17 failures=1 errors=6 (skipped=2)
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed
  • python3 -I scripts/check_no_game_data.py tools/cvt_norm_mods_probe.py tests/test_cvt_norm_mods_probe.py: passed
  • python3 -m compileall -q tools/cvt_norm_mods_probe.py tests/test_cvt_norm_mods_probe.py: passed

🔄 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/1638 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/cvt-norm-mods-probe-json-and-guards` --- ### 📝 Commits (1) - [`61949ea`](https://github.com/ubiquitarianism/leonida/commit/61949ea7e90952d7b9a4d25ede9053b4cfcabd50) cvt_norm_mods_probe: upfront atomic JSON validation, RuntimeError handling, and result count guard ### 📊 Changes **2 files changed** (+188 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_cvt_norm_mods_probe.py` (+66 -0) 📝 `tools/cvt_norm_mods_probe.py` (+122 -18) </details> ### 📄 Description Item ID: `CVT-NORM-MODS-PROBE-JSON-AND-GUARDS` Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155043403 ### Summary Harden JSON reporting, CLI validation, and harness error handling in `tools/cvt_norm_mods_probe.py`: - **Upfront `--json` validation (`validate_json_path`)**: reject empty/whitespace paths, directories, trailing path separators, non-directory parent blockers, and unwritable existing files with exit `2` *before* opening `hw_oracle` (previously `--json " "` created a literal whitespace file and non-directory parent blockers only failed after running all GPU sweeps). - **Atomic JSON writes (`write_json_report`)**: serialize upfront with `allow_nan=False` and LF endings, handle non-regular targets like `/dev/null` directly, resolve symlinks before staging to preserve symlink targets, apply `file_mode.published_mode`, and publish via `replace_retry.replace`. - **CLI & harness guards**: - Reject empty/whitespace `--hw-arch` upfront (exit `2`). - Catch `RuntimeError` from `oracle.run()` cleanly (`harness error: ...`, exit `2`) while still closing the oracle in `finally`. - Detect `len(raw_results) != len(meta)` in `evaluate_results()` as a harness error instead of silently truncating via `zip()` and reporting `mismatches=0`. - **Tests (`tests/test_cvt_norm_mods_probe.py`)**: added 3 test methods covering upfront `--json`/`--hw-arch` validation, atomic/symlink/NaN/`/dev/null` writes, result count mismatch, and `RuntimeError` handling. ### Verification - AI-assisted: yes - GPUs tested: none (CPU synthetic unit tests + FakeOracle on macOS; no GPU, LLVM, or game data present) - `python3 -W error -I tests/test_cvt_norm_mods_probe.py -v`: 15 passed, 2 skipped (AMD clang / llvm-mc absent) - Mutation check against unpatched `main`: `ran=17 failures=1 errors=6 (skipped=2)` - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed - `python3 -I scripts/check_no_game_data.py tools/cvt_norm_mods_probe.py tests/test_cvt_norm_mods_probe.py`: passed - `python3 -m compileall -q tools/cvt_norm_mods_probe.py tests/test_cvt_norm_mods_probe.py`: passed --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#1652
No description provided.