fma_mix_probe: harden CLI parsing, hw oracle validation, and Vulkan/translator error handling #1670

Merged
IlyassRS3 merged 1 commit from upstream-pr/1670 into main 2026-11-28 14:49:02 +00:00
IlyassRS3 commented 2026-11-25 07:41:20 +00:00 (Migrated from github.com)

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


Item ID: FMA-MIX-PROBE-CLI-AND-ORACLE (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156111455)

Summary

  • Hardware oracle validation & Unavailable handling (tools/fma_mix_probe.py):
    • In run_hw(), validate that oracle.run() returns a list/tuple matching len(cases) and that every non-string entry is a non-empty list/tuple whose first element is an int (not bool), raising RuntimeError (exit 2) instead of silently truncating via zip() or crashing with uncaught IndexError/TypeError.
    • Catch runner.Unavailable inside the run_hw() try/finally block in main() so ModeUnavailable during oracle.run() exits 77 cleanly while closing the oracle.
  • CLI validation:
    • Reject empty/whitespace --hw-arch and --build, and reject empty or trailing-comma --oracle tokens ("", "hw,", ",translator") with argparse exit code 2.
  • Vulkan, translator, and word-masking hardening:
    • Catch rdna2spirv.Unsupported alongside spirv_mini_interp.UnsupportedConstruct in main() (exit 2 harness error).
    • Pass errors="replace" to spirv-as and vk_compute_test subprocess runs in run_vulkan() to prevent uncaught UnicodeDecodeError on non-UTF-8 output, and avoid duplicating runtime/test/shaders in sys.path.
    • Mask word &= 0xFFFFFFFF in half() so high-bit masking is exact.
  • Regression tests (tests/test_fma_mix_probe.py):
    • Added 3 tests covering malformed/empty CLI flags, malformed hw oracle payloads + Unavailable during run() + rdna2spirv.Unsupported, and half() masking + run_vulkan(..., errors="replace").

Checklist & Verification

  • AI-assisted: yes
  • Game data included: none (python3 -I scripts/check_no_game_data.py tools/fma_mix_probe.py tests/test_fma_mix_probe.py passed)
  • GPUs tested: none (hostless macOS synthetic/unit test run)
  • Tests run:
    • python3 -W error -I tests/test_fma_mix_probe.py -v: Ran 21 tests ... OK
    • Mutation test (new tests/test_fma_mix_probe.py against unpatched main tools/fma_mix_probe.py): Ran 21 tests ... FAILED (failures=12, errors=3)
    • python3 -m compileall -q make_game.py tools tests: passed
    • python3 -I tests/test_text_write_line_endings.py: Ran 3 tests ... OK
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5487227658 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1670). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T07:41:20Z. --- Item ID: `FMA-MIX-PROBE-CLI-AND-ORACLE` (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156111455) ## Summary - **Hardware oracle validation & `Unavailable` handling (`tools/fma_mix_probe.py`)**: - In `run_hw()`, validate that `oracle.run()` returns a `list`/`tuple` matching `len(cases)` and that every non-string entry is a non-empty `list`/`tuple` whose first element is an `int` (not `bool`), raising `RuntimeError` (exit `2`) instead of silently truncating via `zip()` or crashing with uncaught `IndexError`/`TypeError`. - Catch `runner.Unavailable` inside the `run_hw()` `try/finally` block in `main()` so `ModeUnavailable` during `oracle.run()` exits `77` cleanly while closing the oracle. - **CLI validation**: - Reject empty/whitespace `--hw-arch` and `--build`, and reject empty or trailing-comma `--oracle` tokens (`""`, `"hw,"`, `",translator"`) with argparse exit code `2`. - **Vulkan, translator, and word-masking hardening**: - Catch `rdna2spirv.Unsupported` alongside `spirv_mini_interp.UnsupportedConstruct` in `main()` (exit `2` harness error). - Pass `errors="replace"` to `spirv-as` and `vk_compute_test` subprocess runs in `run_vulkan()` to prevent uncaught `UnicodeDecodeError` on non-UTF-8 output, and avoid duplicating `runtime/test/shaders` in `sys.path`. - Mask `word &= 0xFFFFFFFF` in `half()` so high-bit masking is exact. - **Regression tests (`tests/test_fma_mix_probe.py`)**: - Added 3 tests covering malformed/empty CLI flags, malformed hw oracle payloads + `Unavailable` during `run()` + `rdna2spirv.Unsupported`, and `half()` masking + `run_vulkan(..., errors="replace")`. ## Checklist & Verification - **AI-assisted**: yes - **Game data included**: none (`python3 -I scripts/check_no_game_data.py tools/fma_mix_probe.py tests/test_fma_mix_probe.py` passed) - **GPUs tested**: none (hostless macOS synthetic/unit test run) - **Tests run**: - `python3 -W error -I tests/test_fma_mix_probe.py -v`: `Ran 21 tests ... OK` - Mutation test (new `tests/test_fma_mix_probe.py` against unpatched `main` `tools/fma_mix_probe.py`): `Ran 21 tests ... FAILED (failures=12, errors=3)` - `python3 -m compileall -q make_game.py tools tests`: passed - `python3 -I tests/test_text_write_line_endings.py`: `Ran 3 tests ... OK`
copilot-pull-request-reviewer[bot] commented 2026-11-25 07:41:32 +00:00 (Migrated from github.com)

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

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:6053605708 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1670#pullrequestreview-6053605708). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T07:41:32Z. **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.
zmasi commented 2026-11-28 10:47:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T10:47:26Z.


#1670 | head 5e8a78e5a8 (merged cleanly with main 95b2e6c67) | python -I tests/test_fma_mix_probe.py | red on main: FAILED (failures=12, errors=3) (malformed --oracle/--hw-arch/--build flags accepted, unmasked bits above bit 31 in half(), and uncaught IndexError/TypeError/Unsupported on malformed oracle/translator runs) | green on PR+main: 21 tests OK | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited half 32-bit masking, run_vulkan (sys.path dedup + errors="replace"), run_hw batch-length and strict integer word validation, upfront --oracle/--hw-arch/--build validation, and runner.Unavailable -> exit 77 + rdna2spirv.Unsupported -> exit 2 handling in tools/fma_mix_probe.py. Also passed tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), tests/test_runner_calls_all_tests.py (3 OK), and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238123779 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1670#issuecomment-7238123779). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T10:47:26Z. --- #1670 | head 5e8a78e5a8cfaca491640db12faef7cd151077df (merged cleanly with main 95b2e6c67) | `python -I tests/test_fma_mix_probe.py` | red on main: `FAILED (failures=12, errors=3)` (malformed `--oracle`/`--hw-arch`/`--build` flags accepted, unmasked bits above bit 31 in `half()`, and uncaught `IndexError`/`TypeError`/`Unsupported` on malformed oracle/translator runs) | green on PR+main: `21 tests OK` | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `half` 32-bit masking, `run_vulkan` (`sys.path` dedup + `errors="replace"`), `run_hw` batch-length and strict integer word validation, upfront `--oracle`/`--hw-arch`/`--build` validation, and `runner.Unavailable -> exit 77` + `rdna2spirv.Unsupported -> exit 2` handling in `tools/fma_mix_probe.py`. Also passed `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), `tests/test_runner_calls_all_tests.py` (`3 OK`), and `scripts/check_no_game_data.py`.
MoonEyes commented 2026-11-28 14:48:59 +00:00 (Migrated from github.com)

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


Red/green: pytest tests/test_fma_mix_probe.py fails on main (15 failed, 19 passed, 10 subtests passed) and passes on head 5e8a78e5a8 merged with main (21 passed, 23 subtests passed).
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:7240952638 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1670#issuecomment-7240952638). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:48:59Z. --- Red/green: `pytest tests/test_fma_mix_probe.py` fails on main (15 failed, 19 passed, 10 subtests passed) and passes on head 5e8a78e5a8cf merged with main (21 passed, 23 subtests passed). 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!1670
No description provided.