[PR #1672] fma_mix_literal_probe: harden CLI parsing, hw oracle validation, and word masking #1686

Open
opened 2026-11-26 20:22:06 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1672
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/fma-mix-literal-probe-cli-and-oracle


📝 Commits (1)

  • c129c53 fma_mix_literal_probe: harden CLI parsing, hw oracle validation, and word masking

📊 Changes

2 files changed (+90 additions, -2 deletions)

View changed files

📝 tests/test_fma_mix_literal_probe.py (+65 -0)
📝 tools/fma_mix_literal_probe.py (+25 -2)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1672 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/fma-mix-literal-probe-cli-and-oracle` --- ### 📝 Commits (1) - [`c129c53`](https://github.com/ubiquitarianism/leonida/commit/c129c53b9cd45fe074f6321210b656fff65d4697) fma_mix_literal_probe: harden CLI parsing, hw oracle validation, and word masking ### 📊 Changes **2 files changed** (+90 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_fma_mix_literal_probe.py` (+65 -0) 📝 `tools/fma_mix_literal_probe.py` (+25 -2) </details> ### 📄 Description 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` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1686
No description provided.