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

Merged
leonida/mandy
quietfold merged 1 commit from fix/fma-mix-probe-cli-and-oracle into main 2026-11-28 14:49:02 +00:00

Pull request successfully merged and closed

quietfold commented 2026-11-25 07:41:20 +00:00

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
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] reviewed 2026-11-25 07:41:32 +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.
zmasi commented 2026-11-28 10:47:26 +00:00

#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.

#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

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)

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 description provided.