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

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

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


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
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5487250860 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1672). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T07:43:16Z. --- 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] commented 2026-11-25 07:43:26 +00:00 (Migrated from github.com)

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

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

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


#1672 | head c129c53b9c (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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238124168 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1672#issuecomment-7238124168). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T10:47:28Z. --- #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 (Migrated from github.com)

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


Red/green: pytest tests/test_fma_mix_literal_probe.py fails on main (6 failed, 7 passed, 6 subtests passed) and passes on head c129c53b9c 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)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7240958645 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1672#issuecomment-7240958645). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:49:25Z. --- 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 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!1672
No description provided.