fma_mix_literal_probe: harden CLI parsing, hw oracle validation, and word masking #1672

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

Pull request successfully merged and closed

quietfold commented 2026-11-25 07:43:16 +00:00

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

Summary

  • Hardware oracle validation & Unavailable handling (tools/fma_mix_literal_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 & word masking:
    • Reject empty/whitespace --hw-arch and empty/trailing-comma --oracle tokens ("", "hw,", ",translator") with argparse exit code 2.
    • Mask word &= 0xFFFFFFFF in verdict() before exact 32-bit comparison.
  • Regression tests (tests/test_fma_mix_literal_probe.py):
    • Added tests covering malformed/empty CLI flags, malformed hw oracle payloads + Unavailable during run() + oracle closure, and 32-bit word masking in verdict().

Checklist & Verification

  • AI-assisted: yes
  • Game data included: none (python3 -I scripts/check_no_game_data.py tools/fma_mix_literal_probe.py tests/test_fma_mix_literal_probe.py passed)
  • GPUs tested: none (hostless macOS synthetic/unit test run)
  • Tests run:
    • python3 -W error -I tests/test_fma_mix_literal_probe.py -v: Ran 10 tests ... OK
    • Mutation test (new tests/test_fma_mix_literal_probe.py against unpatched main tools/fma_mix_literal_probe.py): Ran 10 tests ... FAILED (failures=9, 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-LITERAL-PROBE-CLI-AND-ORACLE` (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156151636) ## Summary - **Hardware oracle validation & `Unavailable` handling (`tools/fma_mix_literal_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 & word masking**: - Reject empty/whitespace `--hw-arch` and empty/trailing-comma `--oracle` tokens (`""`, `"hw,"`, `",translator"`) with argparse exit code `2`. - Mask `word &= 0xFFFFFFFF` in `verdict()` before exact 32-bit comparison. - **Regression tests (`tests/test_fma_mix_literal_probe.py`)**: - Added tests covering malformed/empty CLI flags, malformed hw oracle payloads + `Unavailable` during `run()` + oracle closure, and 32-bit word masking in `verdict()`. ## Checklist & Verification - **AI-assisted**: yes - **Game data included**: none (`python3 -I scripts/check_no_game_data.py tools/fma_mix_literal_probe.py tests/test_fma_mix_literal_probe.py` passed) - **GPUs tested**: none (hostless macOS synthetic/unit test run) - **Tests run**: - `python3 -W error -I tests/test_fma_mix_literal_probe.py -v`: `Ran 10 tests ... OK` - Mutation test (new `tests/test_fma_mix_literal_probe.py` against unpatched `main` `tools/fma_mix_literal_probe.py`): `Ran 10 tests ... FAILED (failures=9, 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:43:26 +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:28 +00:00

#1672 | head c129c53b9cd45fe074f6321210b656fff65d4697 (merged cleanly with main 95b2e6c67) | python -I tests/test_fma_mix_literal_probe.py | red on main: FAILED (failures=9, errors=3) (malformed --oracle/--hw-arch flags accepted, unmasked >32-bit words in verdict(), and uncaught IndexError/TypeError/Unavailable in run_hw / main) | green on PR+main: 10 tests OK | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited verdict 32-bit masking, run_hw batch-length and strict integer/non-bool word validation, upfront --oracle/--hw-arch CLI validation, and runner.Unavailable -> exit 77 with guaranteed oracle.close() in tools/fma_mix_literal_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.

#1672 | head c129c53b9cd45fe074f6321210b656fff65d4697 (merged cleanly with main 95b2e6c67) | `python -I tests/test_fma_mix_literal_probe.py` | red on main: `FAILED (failures=9, errors=3)` (malformed `--oracle`/`--hw-arch` flags accepted, unmasked `>32`-bit words in `verdict()`, and uncaught `IndexError`/`TypeError`/`Unavailable` in `run_hw` / `main`) | green on PR+main: `10 tests OK` | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `verdict` 32-bit masking, `run_hw` batch-length and strict integer/non-`bool` word validation, upfront `--oracle`/`--hw-arch` CLI validation, and `runner.Unavailable -> exit 77` with guaranteed `oracle.close()` in `tools/fma_mix_literal_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:49:25 +00:00

Red/green: pytest tests/test_fma_mix_literal_probe.py fails on main (6 failed, 7 passed, 6 subtests passed) and passes on head c129c53b9cd4 merged with main (10 passed, 17 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_literal_probe.py` fails on main (6 failed, 7 passed, 6 subtests passed) and passes on head c129c53b9cd4 merged with main (10 passed, 17 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.