f64_diff: harden CLI guards, validate hw oracle batch/word counts, and propagate HarnessError out of shrink() #1663

Merged
IlyassRS3 merged 1 commit from upstream-pr/1663 into main 2026-11-28 14:47:41 +00:00
IlyassRS3 commented 2026-11-25 07:30:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T07:30:19Z.


Item ID: F64-DIFF-CLI-ORACLE-AND-SHRINK
Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155892025

Summary

  • CLI validation (tools/f64_diff.py): reject empty/whitespace/trailing-comma --ops (previously --ops "" silently ran all 47 ops), deduplicate --ops tokens, reject empty --hw-arch/--exe (previously --exe "" silently fell back to default vk_harness), and reject zero-case runs (--no-sweep --programs 0 without --known) with exit 2.
  • Hardware oracle result & shrink validation: guard hw is None, exact batch length in run_batch(), exact single-result return in run_one(), and 4-word list/tuple payloads (previously a short word list like [0, 1] produced a false shader mismatch exit 1 instead of HarnessError exit 2). Propagate HarnessError out of shrink() instead of swallowing it.
  • GPU subprocess safety: add errors="replace" and OSError -> HarnessError handling to glslc, spirv-as, and vk_harness invocations in prepare_gpu() / run_gpu().
  • Tests (tests/test_f64_diff.py): add 2 regression tests covering all of the above (keeping existing all-skipped-exits-0 tests intact).

Verification

  • python3 -W error -I tests/test_f64_diff.py -v: 34 passed, 0 failed (1.112s).
  • Mutation check against unpatched main: ran=34, failures=12, errors=0.
  • python3 -m compileall -q tools/f64_diff.py tests/test_f64_diff.py, python3 -I tests/test_text_write_line_endings.py, python3 -I scripts/check_no_game_data.py: all pass.

AI-assisted: yes
GPUs tested: none (CPU unit tests with stubbed hardware oracle and SPIR-V interpreter; no game data)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5487093085 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1663). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T07:30:19Z. --- Item ID: `F64-DIFF-CLI-ORACLE-AND-SHRINK` Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155892025 ## Summary - **CLI validation (`tools/f64_diff.py`)**: reject empty/whitespace/trailing-comma `--ops` (previously `--ops ""` silently ran all 47 ops), deduplicate `--ops` tokens, reject empty `--hw-arch`/`--exe` (previously `--exe ""` silently fell back to default `vk_harness`), and reject zero-case runs (`--no-sweep --programs 0` without `--known`) with exit `2`. - **Hardware oracle result & shrink validation**: guard `hw is None`, exact batch length in `run_batch()`, exact single-result return in `run_one()`, and 4-word list/tuple payloads (previously a short word list like `[0, 1]` produced a false shader mismatch exit `1` instead of `HarnessError` exit `2`). Propagate `HarnessError` out of `shrink()` instead of swallowing it. - **GPU subprocess safety**: add `errors="replace"` and `OSError` -> `HarnessError` handling to `glslc`, `spirv-as`, and `vk_harness` invocations in `prepare_gpu()` / `run_gpu()`. - **Tests (`tests/test_f64_diff.py`)**: add 2 regression tests covering all of the above (keeping existing all-skipped-exits-0 tests intact). ## Verification - `python3 -W error -I tests/test_f64_diff.py -v`: **34 passed, 0 failed** (1.112s). - Mutation check against unpatched `main`: **ran=34, failures=12, errors=0**. - `python3 -m compileall -q tools/f64_diff.py tests/test_f64_diff.py`, `python3 -I tests/test_text_write_line_endings.py`, `python3 -I scripts/check_no_game_data.py`: all pass. AI-assisted: yes GPUs tested: none (CPU unit tests with stubbed hardware oracle and SPIR-V interpreter; no game data)
copilot-pull-request-reviewer[bot] commented 2026-11-25 07:30:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T07:30:31Z.

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:6053482525 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1663#pullrequestreview-6053482525). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T07:30:31Z. **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 09:27:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T09:27:52Z.


Independent verification (Windows, Python 3.11.9 -I -W error): --ops/--hw-arch/--exe empty-token guards, dedup via dict.fromkeys, zero-case guard placement verified (after --list-ops/--self-test, before oracle open), run_batch/run_one payload validation, shrink() HarnessError propagation, subprocess errors="replace"+OSError->HarnessError — all match claims. test_f64_diff.py 34 OK (matches claim); --self-test 11 invariants ok; all bad-CLI probes exit 2; compileall + line-endings + check_no_game_data clean. AI-assisted verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7158365309 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1663#issuecomment-7158365309). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T09:27:52Z. --- Independent verification (Windows, Python 3.11.9 `-I -W error`): `--ops`/`--hw-arch`/`--exe` empty-token guards, dedup via dict.fromkeys, zero-case guard placement verified (after --list-ops/--self-test, before oracle open), run_batch/run_one payload validation, shrink() HarnessError propagation, subprocess errors="replace"+OSError->HarnessError — all match claims. `test_f64_diff.py` 34 OK (matches claim); `--self-test` 11 invariants ok; all bad-CLI probes exit 2; compileall + line-endings + check_no_game_data clean. AI-assisted verification.
MoonEyes commented 2026-11-28 14:47:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T14:47:38Z.


Red/green: classified READY by cloud-6 (red on main 09c153948, green on head merged with main); head 2ddbf4b48b unchanged since 2026-11-25, before that run.
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7240935120 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1663#issuecomment-7240935120). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:47:38Z. --- Red/green: classified READY by cloud-6 (red on main 09c153948, green on head merged with main); head 2ddbf4b48b52 unchanged since 2026-11-25, before that run. Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure. AI-assisted (Claude Code, Claude Opus 5.5)
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!1663
No description provided.