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

Merged
leonida/mandy
quietfold merged 1 commit from fix/cvt-norm-mods-probe-json-and-guards into main 2026-11-28 11:43:43 +00:00

Pull request successfully merged and closed

quietfold commented 2026-11-25 06:42:38 +00:00

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
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
copilot-pull-request-reviewer[bot] reviewed 2026-11-25 06:42:46 +00:00
copilot-pull-request-reviewer[bot] left a comment
No description provided.
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.
whoalin1 commented 2026-11-25 10:01:41 +00:00

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.

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.
sodove commented 2026-11-28 11:27:01 +00:00

#1638 | head 61949ea7e90952d7b9a4d25ede9053b4cfcabd50 | python3 -I tests/test_cvt_norm_mods_probe.py -v | red: 17 run, 1 failure, 6 errors | green: 17 passed | Red → green

The merged file passed all CLI, report and reference-model tests, including the AMD clang and llvm-mc assembly checks.

Copied the PR tests onto clean main 4a54aedcb6b66525e0c9f72a6ea10263337c9141 for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. Batch claim.

#1638 | head `61949ea7e90952d7b9a4d25ede9053b4cfcabd50` | `python3 -I tests/test_cvt_norm_mods_probe.py -v` | red: 17 run, 1 failure, 6 errors | green: 17 passed | **Red → green** The merged file passed all CLI, report and reference-model tests, including the AMD clang and llvm-mc assembly checks. Copied the PR tests onto clean main `4a54aedcb6b66525e0c9f72a6ea10263337c9141` for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. [Batch claim](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7238450840).
DadaCap commented 2026-11-28 11:43:45 +00:00

Merged, thank you @IlyassRS3! This PR (cvt_norm_mods_probe: upfront atomic JSON validation, RuntimeError handling, and result count guard) passed its own tests with main merged in during sodove's verification of this shader batch, so it went in with the batch.

AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.

Merged, thank you @IlyassRS3! This PR (cvt_norm_mods_probe: upfront atomic JSON validation, RuntimeError handling, and result count guard) passed its own tests with main merged in during sodove's verification of this shader batch, so it went in with the batch. AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.
Sign in to join this conversation.
No description provided.