cvt_norm_mods_probe: upfront atomic JSON validation, RuntimeError handling, and result count guard #1638

Open
github-bot wants to merge 1 commit from github-bot/gh-1638 into main AGit
Owner

@⁠IlyassRS3 on GitHub · 2026-11-25 06:42 UTC · original
IlyassRS3:fix/cvt-norm-mods-probe-json-and-guards → main · +188 −18 · 2 files · 1 commits · open

Item ID: CVT-NORM-MODS-PROBE-JSON-AND-GUARDS
Claim: #1608

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
**@⁠IlyassRS3** on GitHub · 2026-11-25 06:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1638) `IlyassRS3:fix/cvt-norm-mods-probe-json-and-guards` → `main` · +188 −18 · 2 files · 1 commits · open Item ID: `CVT-NORM-MODS-PROBE-JSON-AND-GUARDS` Claim: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608 ### 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
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:59:01 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 06:42 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 06:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1638#pullrequestreview-6053008961) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-25 10:01 UTC · original

Independent verification (Windows, Python 3.11.9 -I -W error): --json validated before open_oracle (test asserts oracle never opened), --hw-arch empty guard, oracle RuntimeError -> harness error exit 2 with finally-close, result-count mismatch now yields a harness_errors entry instead of silent zip truncation, atomic write pattern identical to the verified series. test_cvt_norm_mods_probe.py 17 OK (2 env skips, matches body); bad-CLI probes exit 2; compileall + line-endings + check_no_game_data clean. AI-assisted verification.

**@⁠whoalin1** on GitHub · 2026-11-25 10:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1638#issuecomment-7159124106) Independent verification (Windows, Python 3.11.9 `-I -W error`): `--json` validated before `open_oracle` (test asserts oracle never opened), `--hw-arch` empty guard, oracle RuntimeError -> harness error exit 2 with finally-close, result-count mismatch now yields a `harness_errors` entry instead of silent zip truncation, atomic write pattern identical to the verified series. `test_cvt_norm_mods_probe.py` 17 OK (2 env skips, matches body); bad-CLI probes exit 2; compileall + line-endings + check_no_game_data clean. AI-assisted verification.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1638/head:github-bot/gh-1638'
git switch 'github-bot/gh-1638'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1638'
git switch 'github-bot/gh-1638'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1638'
git switch 'github-bot/gh-1638'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1638'
git switch 'main'
git merge --squash 'github-bot/gh-1638'
git switch 'main'
git merge --ff-only 'github-bot/gh-1638'
git switch 'main'
git merge 'github-bot/gh-1638'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.