vinterp_hw_probe: harden CLI validation, run_hw batch/tuple handling, and harness error exits #1682

Merged
IlyassRS3 merged 1 commit from upstream-pr/1682 into main 2026-11-28 14:53:26 +00:00
IlyassRS3 commented 2026-11-25 08:01:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T08:01:42Z.


Item ID: VINTERP-HW-PROBE-ORACLE-AND-CLI (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156493260)

Summary

  • Hardware oracle batch/result validation (tools/vinterp_hw_probe.py):
    • In run_hw(), validate that oracle.run([k] * 4, words=5) returns a list/tuple of length 4, accept both list and tuple per-kernel entries when selecting CU0 ((r[4] & 0x100) == 0) or falling back to a valid entry, verify at least 5 non-bool int words per non-string entry (masking to 32 bits), and raise RuntimeError when a batch is malformed or all 4 kernels are rejected as strings (instead of crashing with IndexError/TypeError or misreporting rejections as MISMATCH exit 1).
  • CLI & harness error handling:
    • Reject empty/whitespace --hw-arch with argparse exit code 2.
    • Catch rdna2spirv.Unsupported, spirv_mini_interp.UnsupportedConstruct, RuntimeError, and OSError around run_translator_checks(), plus RuntimeError around run_hw(), returning exit 2 cleanly instead of unhandled tracebacks.
  • Regression tests (tests/test_vinterp_hw_probe.py):
    • Added tests covering empty --hw-arch, translator harness errors -> exit 2, tuple CU0 selection over CU1, malformed & all-rejected hardware oracle batches, and RuntimeError/runner.Unavailable raised from oracle.run(), verifying oracle.close() on every path.

Checklist & Verification

  • AI-assisted: yes
  • Game data included: none (python3 -I scripts/check_no_game_data.py tools/vinterp_hw_probe.py tests/test_vinterp_hw_probe.py passed)
  • GPUs tested: none (hostless macOS synthetic/unit test run)
  • Tests run:
    • python3 -W error -I tests/test_vinterp_hw_probe.py -v: Ran 7 tests ... OK
    • Mutation test (new tests/test_vinterp_hw_probe.py against unpatched main tools/vinterp_hw_probe.py): Ran 7 tests ... FAILED (failures=3, errors=1)
    • 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:5487472130 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1682). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T08:01:42Z. --- Item ID: `VINTERP-HW-PROBE-ORACLE-AND-CLI` (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156493260) ## Summary - **Hardware oracle batch/result validation (`tools/vinterp_hw_probe.py`)**: - In `run_hw()`, validate that `oracle.run([k] * 4, words=5)` returns a `list`/`tuple` of length `4`, accept both `list` and `tuple` per-kernel entries when selecting CU0 (`(r[4] & 0x100) == 0`) or falling back to a valid entry, verify at least 5 non-bool `int` words per non-string entry (masking to 32 bits), and raise `RuntimeError` when a batch is malformed or all 4 kernels are rejected as strings (instead of crashing with `IndexError`/`TypeError` or misreporting rejections as `MISMATCH` exit `1`). - **CLI & harness error handling**: - Reject empty/whitespace `--hw-arch` with argparse exit code `2`. - Catch `rdna2spirv.Unsupported`, `spirv_mini_interp.UnsupportedConstruct`, `RuntimeError`, and `OSError` around `run_translator_checks()`, plus `RuntimeError` around `run_hw()`, returning exit `2` cleanly instead of unhandled tracebacks. - **Regression tests (`tests/test_vinterp_hw_probe.py`)**: - Added tests covering empty `--hw-arch`, translator harness errors -> exit `2`, tuple CU0 selection over CU1, malformed & all-rejected hardware oracle batches, and `RuntimeError`/`runner.Unavailable` raised from `oracle.run()`, verifying `oracle.close()` on every path. ## Checklist & Verification - **AI-assisted**: yes - **Game data included**: none (`python3 -I scripts/check_no_game_data.py tools/vinterp_hw_probe.py tests/test_vinterp_hw_probe.py` passed) - **GPUs tested**: none (hostless macOS synthetic/unit test run) - **Tests run**: - `python3 -W error -I tests/test_vinterp_hw_probe.py -v`: `Ran 7 tests ... OK` - Mutation test (new `tests/test_vinterp_hw_probe.py` against unpatched `main` `tools/vinterp_hw_probe.py`): `Ran 7 tests ... FAILED (failures=3, errors=1)` - `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 08:01:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T08:01:57Z.

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:6053823893 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1682#pullrequestreview-6053823893). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T08:01:57Z. **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.
whoalin1 commented 2026-11-25 08:52:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T08:52:21Z.


Independent verification (Windows, Python 3.11.9 -I -W error): run_hw batch/tuple handling, CU0 preference + first-valid fallback, RuntimeError->exit 2, --hw-arch empty guard, str->exit 2 — all match claims. test_vinterp_hw_probe.py 7 OK; neighbors hw_oracle 59 + asm_strip + workdir_leak 9 all OK; bad-CLI probes exit 2 correctly; compileall + line-endings + check_no_game_data clean. AI-assisted verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7157577205 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1682#issuecomment-7157577205). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T08:52:21Z. --- Independent verification (Windows, Python 3.11.9 `-I -W error`): `run_hw` batch/tuple handling, CU0 preference + first-valid fallback, RuntimeError->exit 2, `--hw-arch` empty guard, str->exit 2 — all match claims. `test_vinterp_hw_probe.py` 7 OK; neighbors hw_oracle 59 + asm_strip + workdir_leak 9 all OK; bad-CLI probes exit 2 correctly; compileall + line-endings + check_no_game_data clean. AI-assisted verification.
GrahamboJangles commented 2026-11-25 12:06:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by GrahamboJangles on 2026-11-25T12:06:43Z.


Independent review (CPU-only Windows 11, python 3.14.9 -I; head c80e31bc6, current main 57ba40bd6).

Coordination. Claim 7156493260 (IlyassRS3) was posted at 08:00:13Z — about half a minute AFTER PR creation (07:59:45Z), unlike the sibling items whose claims precede the PR. Roster shows done: VINTERP-HW-PROBE-ORACLE-AND-CLI -> #1682 and gh pr list --search vinterp_hw_probe --state all returns only this PR, so there is no duplicate work; just flagging the ordering.

The new tests bite (inverse check). tests/test_vinterp_hw_probe.py at head: Ran 7 tests ... OK; main's copy: Ran 5 tests ... OK — net +2 as claimed. The head test file against main's tool: FAILED (failures=3, errors=1), every failure inside the two new methods — empty/whitespace --hw-arch passes through to the oracle on main (AttributeError traceback), and malformed run_hw batches crash with TypeError/IndexError instead of clean exit-2 harness errors. The 5 pre-existing tests stay green against main.

Code notes.

  • The rejection handling is a real fix: main picked batch[0] when no CU0-flagged word came back, so a string rejection flowed into the comparison as a raw string and printed MISMATCH with exit 1 (a hardware mismatch claim that never happened). The patch raises RuntimeError(f"... kernel rejected: {rejected[0]}") when all four are strings and picks the first valid fallback row otherwise; verified by the tuple/CU0 subtests at head.
  • run_hw now accepts tuples as well as lists per kernel result and masks words to 32 bits before comparing, matching the sibling interp_hw_probe hardening (#1680).
  • run_translator_checks() is wrapped with (rdna2spirv.Unsupported, spirv_mini_interp.UnsupportedConstruct, RuntimeError, OSError) -> exit 2: translator failures that used to traceback now get a harness error: line. Exit-code discipline (77 for unavailable oracle, 2 for harness errors) matches the repo's probe-tool convention.
  • One behavior note, not a blocker: the RuntimeError catch also swallows genuine harness bugs raised deep inside the check functions — but exit 2 with the message is the intended classification for those, same as the other probe tools in this family.

Mergeability & hygiene. git diff 3f81d46ac..origin/main over both files: 0 bytes — rebases clean onto moved main. check_no_game_data.py exits 0 on both files; compileall clean. CI (change-scope, no-game-data) pending at head when I looked.

Verdict: LGTM — the crash-to-harness-error conversions are confirmed against unpatched main, the +2 test delta is real, and the branch is disjoint from main's later merges.

AI-assisted (Hermes overnight shift). Complements whoalin1's verification comment with the count-move gate (5→7) and the rebase check.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7161933447 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1682#issuecomment-7161933447). Originally posted by [GrahamboJangles](https://github.com/GrahamboJangles) on 2026-11-25T12:06:43Z. --- Independent review (CPU-only Windows 11, python 3.14.9 `-I`; head `c80e31bc6`, current main `57ba40bd6`). **Coordination.** Claim 7156493260 (IlyassRS3) was posted at 08:00:13Z — about half a minute AFTER PR creation (07:59:45Z), unlike the sibling items whose claims precede the PR. Roster shows `done: VINTERP-HW-PROBE-ORACLE-AND-CLI -> #1682` and `gh pr list --search vinterp_hw_probe --state all` returns only this PR, so there is no duplicate work; just flagging the ordering. **The new tests bite (inverse check).** `tests/test_vinterp_hw_probe.py` at head: `Ran 7 tests ... OK`; main's copy: `Ran 5 tests ... OK` — net +2 as claimed. The head test file against **main's** tool: `FAILED (failures=3, errors=1)`, every failure inside the two new methods — empty/whitespace `--hw-arch` passes through to the oracle on main (AttributeError traceback), and malformed `run_hw` batches crash with `TypeError`/`IndexError` instead of clean exit-2 harness errors. The 5 pre-existing tests stay green against main. **Code notes.** - The rejection handling is a real fix: main picked `batch[0]` when no CU0-flagged word came back, so a string rejection flowed into the comparison as a raw string and printed `MISMATCH` with exit 1 (a hardware mismatch claim that never happened). The patch raises `RuntimeError(f"... kernel rejected: {rejected[0]}")` when all four are strings and picks the first valid fallback row otherwise; verified by the tuple/CU0 subtests at head. - `run_hw` now accepts tuples as well as lists per kernel result and masks words to 32 bits before comparing, matching the sibling interp_hw_probe hardening (#1680). - `run_translator_checks()` is wrapped with `(rdna2spirv.Unsupported, spirv_mini_interp.UnsupportedConstruct, RuntimeError, OSError) -> exit 2`: translator failures that used to traceback now get a `harness error:` line. Exit-code discipline (77 for unavailable oracle, 2 for harness errors) matches the repo's probe-tool convention. - One behavior note, not a blocker: the `RuntimeError` catch also swallows genuine harness bugs raised deep inside the check functions — but exit 2 with the message is the intended classification for those, same as the other probe tools in this family. **Mergeability & hygiene.** `git diff 3f81d46ac..origin/main` over both files: 0 bytes — rebases clean onto moved main. `check_no_game_data.py` exits 0 on both files; `compileall` clean. CI (`change-scope`, `no-game-data`) pending at head when I looked. **Verdict: LGTM** — the crash-to-harness-error conversions are confirmed against unpatched main, the +2 test delta is real, and the branch is disjoint from main's later merges. AI-assisted (Hermes overnight shift). Complements whoalin1's verification comment with the count-move gate (5→7) and the rebase check.
MoonEyes commented 2026-11-28 14:53:17 +00:00 (Migrated from github.com)

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


Red/green: classified READY by cloud-4 (red on main 09c153948, green on head merged with main); head c80e31bc63 unchanged since 2026-11-25, before that run.
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:7241013657 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1682#issuecomment-7241013657). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:53:17Z. --- Red/green: classified READY by cloud-4 (red on main 09c153948, green on head merged with main); head c80e31bc6397 unchanged since 2026-11-25, before that run. 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!1682
No description provided.