frexp_ldexp_f16_mods_probe: harden CLI tokens, upfront atomic JSON writes, and result count guard #1644

Merged
IlyassRS3 merged 1 commit from upstream-pr/1644 into main 2026-11-28 11:43:26 +00:00
IlyassRS3 commented 2026-11-25 06:52:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T06:52:49Z.


Item ID: FREXP-LDEXP-F16-MODS-PROBE-JSON-AND-CLI
Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155228780

Summary

Harden CLI argument parsing, JSON report writing, and harness error handling in tools/frexp_ldexp_f16_mods_probe.py:

  • --ops / --waves / --hw-arch guards: reject empty/trailing comma tokens (32,, ,v_frexp_mant_f16, 32,,64) while preserving whitespace-trimmed first-seen deduplication, and reject empty/whitespace --hw-arch.
  • Upfront --json validation: reject empty/whitespace paths, trailing separators, directories, non-directory parent blockers, and unwritable existing targets before opening hw_oracle.
  • Atomic write_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.
  • Harness guards: return a harness_errors entry when len(raw_results) != len(meta) in evaluate_results() (preventing KeyError after zip() truncation), and catch ValueError from asm.family(oracle.arch) cleanly (exit 77).
  • Tests (tests/test_frexp_ldexp_f16_mods_probe.py): added 3 test methods covering malformed comma tokens, empty --hw-arch/--json, upfront blocker/trailing-sep rejection, atomic/symlink/NaN//dev/null writes, result count mismatch, and unknown arch family.

Verification

  • AI-assisted: yes
  • GPUs tested: none (CPU synthetic unit tests + FakeOracle on macOS; no GPU, AMD clang, or game data present)
  • python3 -W error -I tests/test_frexp_ldexp_f16_mods_probe.py -v: 21 passed, 1 skipped (AMD clang absent)
  • Mutation check against unpatched main: ran=22 failures=0 errors=11 (skipped=1)
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed
  • python3 -I scripts/check_no_game_data.py tools/frexp_ldexp_f16_mods_probe.py tests/test_frexp_ldexp_f16_mods_probe.py: passed
  • python3 -m compileall -q tools/frexp_ldexp_f16_mods_probe.py tests/test_frexp_ldexp_f16_mods_probe.py: passed
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5486658965 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1644). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T06:52:49Z. --- Item ID: `FREXP-LDEXP-F16-MODS-PROBE-JSON-AND-CLI` Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155228780 ### Summary Harden CLI argument parsing, JSON report writing, and harness error handling in `tools/frexp_ldexp_f16_mods_probe.py`: - **`--ops` / `--waves` / `--hw-arch` guards**: reject empty/trailing comma tokens (`32,`, `,v_frexp_mant_f16`, `32,,64`) while preserving whitespace-trimmed first-seen deduplication, and reject empty/whitespace `--hw-arch`. - **Upfront `--json` validation**: reject empty/whitespace paths, trailing separators, directories, non-directory parent blockers, and unwritable existing targets *before* opening `hw_oracle`. - **Atomic `write_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`. - **Harness guards**: return a `harness_errors` entry when `len(raw_results) != len(meta)` in `evaluate_results()` (preventing `KeyError` after `zip()` truncation), and catch `ValueError` from `asm.family(oracle.arch)` cleanly (exit `77`). - **Tests (`tests/test_frexp_ldexp_f16_mods_probe.py`)**: added 3 test methods covering malformed comma tokens, empty `--hw-arch`/`--json`, upfront blocker/trailing-sep rejection, atomic/symlink/NaN/`/dev/null` writes, result count mismatch, and unknown arch family. ### Verification - AI-assisted: yes - GPUs tested: none (CPU synthetic unit tests + FakeOracle on macOS; no GPU, AMD clang, or game data present) - `python3 -W error -I tests/test_frexp_ldexp_f16_mods_probe.py -v`: 21 passed, 1 skipped (AMD clang absent) - Mutation check against unpatched `main`: `ran=22 failures=0 errors=11 (skipped=1)` - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed - `python3 -I scripts/check_no_game_data.py tools/frexp_ldexp_f16_mods_probe.py tests/test_frexp_ldexp_f16_mods_probe.py`: passed - `python3 -m compileall -q tools/frexp_ldexp_f16_mods_probe.py tests/test_frexp_ldexp_f16_mods_probe.py`: passed
copilot-pull-request-reviewer[bot] commented 2026-11-25 06:53:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T06:53:04Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6053103607 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1644#pullrequestreview-6053103607). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T06:53:04Z. **Review:** COMMENTED --- 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 08:16:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T08:16:29Z.


Independent verification (Windows, Python 3.11.9 -I): diff reviewed — --ops/--waves token guards, empty --hw-arch, upfront --json validation before hw_oracle opens, atomic write_report with symlink-preserving staging, harness_errors -> exit 2 propagation confirmed, asm.family ValueError -> exit 77 — all present. test_frexp_ldexp_f16_mods_probe.py 22 tests OK (1 skip, matches body), --self-test ok (1733 synthetic words), CLI probes reject bad --ops/--waves/--json inputs, compileall + check_no_game_data clean. AI-assisted verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7156824188 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1644#issuecomment-7156824188). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T08:16:29Z. --- Independent verification (Windows, Python 3.11.9 `-I`): diff reviewed — `--ops/--waves` token guards, empty `--hw-arch`, upfront `--json` validation before `hw_oracle` opens, atomic `write_report` with symlink-preserving staging, `harness_errors` -> exit 2 propagation confirmed, `asm.family` ValueError -> exit 77 — all present. `test_frexp_ldexp_f16_mods_probe.py` 22 tests OK (1 skip, matches body), `--self-test` ok (1733 synthetic words), CLI probes reject bad `--ops`/`--waves`/`--json` inputs, compileall + `check_no_game_data` clean. AI-assisted verification.
sodove commented 2026-11-28 11:27:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T11:27:19Z.


#1644 | head 7e2c52a9ccc2a4752560acb4251369a06baec76f | python3 -I tests/test_frexp_ldexp_f16_mods_probe.py -v | red: 22 run, 11 errors | green: 22 passed | Red → green

The suite covers CLI and report guards, result counts and synthetic reference cases. All 22 tests passed after the merge.

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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238562388 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1644#issuecomment-7238562388). Originally posted by [sodove](https://github.com/sodove) on 2026-11-28T11:27:19Z. --- #1644 | head `7e2c52a9ccc2a4752560acb4251369a06baec76f` | `python3 -I tests/test_frexp_ldexp_f16_mods_probe.py -v` | red: 22 run, 11 errors | green: 22 passed | **Red → green** The suite covers CLI and report guards, result counts and synthetic reference cases. All 22 tests passed after the merge. 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:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T11:43:28Z.


Merged, thank you @IlyassRS3! This PR (frexp_ldexp_f16_mods_probe: harden CLI tokens, upfront atomic JSON writes, 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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238740641 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1644#issuecomment-7238740641). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T11:43:28Z. --- Merged, thank you @IlyassRS3! This PR (frexp_ldexp_f16_mods_probe: harden CLI tokens, upfront atomic JSON writes, 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 reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1644
No description provided.