interp_hw_probe: harden CLI parsing, oracle batch/word validation, and error lifecycle #1680

Merged
leonida/mandy
quietfold merged 1 commit from fix/interp-hw-probe-cli-and-oracle into main 2026-11-28 11:45:11 +00:00

Pull request successfully merged and closed

quietfold commented 2026-11-25 07:59:32 +00:00

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

Summary

  • CLI validation & seed deduplication (tools/interp_hw_probe.py):
    • Reject empty/whitespace --arch, non-positive --kernels < 1, and empty/trailing-comma --seeds tokens with argparse exit code 2.
    • Deduplicate repeated --seeds while preserving order so identical random kernel batches are not run twice.
  • Hardware oracle batch/word validation & lifecycle:
    • Added _validate_batch() used for both the random kernel batches and the tie kernel to verify that o.run() returns a list/tuple matching the exact kernel count and that each non-string entry is a list/tuple of at least expected_words non-bool int words (masking to 32 bits), preventing false passes on empty/short responses and uncaught IndexError/TypeError.
    • Catch runner.Unavailable (exit 77) and RuntimeError (exit 2) raised during o.run() inside try ... finally: o.close().
    • Fail with exit 2 if tally is empty (no checks executed).
    • Mask (o[i2] & 0xFFFFFFFF) >> 16 == 0xDEAD in check_random().
  • Regression tests (tests/test_interp_hw_probe.py):
    • Added tests covering empty --arch, non-positive --kernels, malformed/deduplicated --seeds, malformed oracle batch/word responses, runner.Unavailable -> exit 77, RuntimeError -> exit 2, and 32-bit canary masking in check_random().

Checklist & Verification

  • AI-assisted: yes
  • Game data included: none (python3 -I scripts/check_no_game_data.py tools/interp_hw_probe.py tests/test_interp_hw_probe.py passed)
  • GPUs tested: none (hostless macOS synthetic/unit test run)
  • Tests run:
    • python3 -W error -I tests/test_interp_hw_probe.py -v: Ran 24 tests ... OK
    • Mutation test (new tests/test_interp_hw_probe.py against unpatched main tools/interp_hw_probe.py): Ran 24 tests ... FAILED (failures=8, errors=5)
    • 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: `INTERP-HW-PROBE-CLI-AND-ORACLE` (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156453676) ## Summary - **CLI validation & seed deduplication (`tools/interp_hw_probe.py`)**: - Reject empty/whitespace `--arch`, non-positive `--kernels < 1`, and empty/trailing-comma `--seeds` tokens with argparse exit code `2`. - Deduplicate repeated `--seeds` while preserving order so identical random kernel batches are not run twice. - **Hardware oracle batch/word validation & lifecycle**: - Added `_validate_batch()` used for both the random kernel batches and the tie kernel to verify that `o.run()` returns a `list`/`tuple` matching the exact kernel count and that each non-string entry is a `list`/`tuple` of at least `expected_words` non-bool `int` words (masking to 32 bits), preventing false passes on empty/short responses and uncaught `IndexError`/`TypeError`. - Catch `runner.Unavailable` (exit `77`) and `RuntimeError` (exit `2`) raised during `o.run()` inside `try ... finally: o.close()`. - Fail with exit `2` if `tally` is empty (no checks executed). - Mask `(o[i2] & 0xFFFFFFFF) >> 16 == 0xDEAD` in `check_random()`. - **Regression tests (`tests/test_interp_hw_probe.py`)**: - Added tests covering empty `--arch`, non-positive `--kernels`, malformed/deduplicated `--seeds`, malformed oracle batch/word responses, `runner.Unavailable` -> exit `77`, `RuntimeError` -> exit `2`, and 32-bit canary masking in `check_random()`. ## Checklist & Verification - **AI-assisted**: yes - **Game data included**: none (`python3 -I scripts/check_no_game_data.py tools/interp_hw_probe.py tests/test_interp_hw_probe.py` passed) - **GPUs tested**: none (hostless macOS synthetic/unit test run) - **Tests run**: - `python3 -W error -I tests/test_interp_hw_probe.py -v`: `Ran 24 tests ... OK` - Mutation test (new `tests/test_interp_hw_probe.py` against unpatched `main` `tools/interp_hw_probe.py`): `Ran 24 tests ... FAILED (failures=8, errors=5)` - `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:59:39 +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.
whoalin1 commented 2026-11-25 08:52:23 +00:00

Independent verification (Windows, Python 3.11.9 -I -W error): _validate_batch enforces kernel count + per-result non-bool int words (masked 32-bit, expected_words = nout*LANES verified), CLI rejects empty --arch/--kernels<1/bad --seeds with dedup, Unavailable->77 / RuntimeError->2 with close() in finally, canary check mask fix correct. test_interp_hw_probe.py 24 OK; all bad-CLI probes -> SystemExit 2; compileall + line-endings + check_no_game_data clean. AI-assisted verification.

Independent verification (Windows, Python 3.11.9 `-I -W error`): `_validate_batch` enforces kernel count + per-result non-bool int words (masked 32-bit, `expected_words` = nout*LANES verified), CLI rejects empty `--arch`/`--kernels<1`/bad `--seeds` with dedup, Unavailable->77 / RuntimeError->2 with close() in finally, canary check mask fix correct. `test_interp_hw_probe.py` 24 OK; all bad-CLI probes -> SystemExit 2; compileall + line-endings + check_no_game_data clean. AI-assisted verification.
GrahamboJangles commented 2026-11-25 12:06:41 +00:00

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

Coordination. Claim 7156453676 (IlyassRS3, 2026-11-25T07:58:05Z) predates the PR (07:59:32Z); roster shows done: INTERP-HW-PROBE-CLI-AND-ORACLE -> #1680. gh pr list --search interp_hw_probe --state all returns only this PR.

The new tests bite (inverse check). tests/test_interp_hw_probe.py at head: Ran 24 tests ... OK (main's copy runs 22, so +2 exactly as claimed). The same file against main's tools/interp_hw_probe.py: FAILED (failures=8, errors=5) — every failure is inside the two new CliTest methods (subTest inflates the count): empty/whitespace --arch, --kernels 0/-2, malformed --seeds all exit 0/77 instead of 2 on main, and the malformed-oracle cases raise uncaught TypeError/IndexError/AttributeError tracebacks on main where the patched tool returns clean exit-2 harness error: lines. All 22 pre-existing tests stay green against main, so the delta is fully localized.

Code notes.

  • _validate_batch covers empty/None batch, short rows, bool words, and string rejections; the string-rejection check comes before the type check, so an assembler rejection still prints kernel failed:-equivalent as harness error: kernel failed: ... with exit 2. Fine, but note the old code's print("kernel failed: ...") path now folds into the generic harness-error text — a message change, not a behavior regression.
  • Seed dedup uses dict.fromkeys, preserving order — --seeds "7, 7" runs one seed batch plus the tie kernel (test asserts calls == [1, 1]), verified at head.
  • --seeds validation rejects any empty token ("1,", ",2", ""), exit 2; --kernels gets its own < 1 guard since argparse type=int already rejects non-numeric.
  • New if not tally: harness error: no checks were executed prevents a vacuous exit 0.

Mergeability. git diff 3f81d46ac..origin/main over the PR's two files is 0 bytes — main's later merges touch disjoint files, so this rebases clean. check_no_game_data.py on both files exits 0; compileall clean. CI (change-scope, no-game-data) pending at head when I looked.

Verdict: LGTM — hardening is real against unpatched main (crashes turn into clean exit-2 harness errors), tests localize to the new code, and the branch rebases onto current main.

AI-assisted (Hermes overnight shift). Note whoalin1's independent verification comment above already covers the oracle-behavior probes; mine adds the count-move gate (22→24) and the rebase check against moved main.

Independent review (CPU-only Windows 11, python 3.14.9 `-I`; head `73e962741`, current main `57ba40bd6`). **Coordination.** Claim 7156453676 (IlyassRS3, 2026-11-25T07:58:05Z) predates the PR (07:59:32Z); roster shows `done: INTERP-HW-PROBE-CLI-AND-ORACLE -> #1680`. `gh pr list --search interp_hw_probe --state all` returns only this PR. **The new tests bite (inverse check).** `tests/test_interp_hw_probe.py` at head: `Ran 24 tests ... OK` (main's copy runs 22, so +2 exactly as claimed). The same file against **main's** `tools/interp_hw_probe.py`: `FAILED (failures=8, errors=5)` — every failure is inside the two new CliTest methods (subTest inflates the count): empty/whitespace `--arch`, `--kernels 0/-2`, malformed `--seeds` all exit 0/77 instead of 2 on main, and the malformed-oracle cases raise uncaught `TypeError`/`IndexError`/`AttributeError` tracebacks on main where the patched tool returns clean exit-2 `harness error:` lines. All 22 pre-existing tests stay green against main, so the delta is fully localized. **Code notes.** - `_validate_batch` covers empty/None batch, short rows, bool words, and string rejections; the string-rejection check comes before the type check, so an assembler rejection still prints `kernel failed:`-equivalent as `harness error: kernel failed: ...` with exit 2. Fine, but note the old code's `print("kernel failed: ...")` path now folds into the generic harness-error text — a message change, not a behavior regression. - Seed dedup uses `dict.fromkeys`, preserving order — `--seeds "7, 7"` runs one seed batch plus the tie kernel (test asserts `calls == [1, 1]`), verified at head. - `--seeds` validation rejects any empty token (`"1,"`, `",2"`, `""`), exit 2; `--kernels` gets its own `< 1` guard since argparse `type=int` already rejects non-numeric. - New `if not tally: harness error: no checks were executed` prevents a vacuous exit 0. **Mergeability.** `git diff 3f81d46ac..origin/main` over the PR's two files is 0 bytes — main's later merges touch disjoint files, so this rebases clean. `check_no_game_data.py` on both files exits 0; `compileall` clean. CI (`change-scope`, `no-game-data`) pending at head when I looked. **Verdict: LGTM** — hardening is real against unpatched main (crashes turn into clean exit-2 harness errors), tests localize to the new code, and the branch rebases onto current main. AI-assisted (Hermes overnight shift). Note whoalin1's independent verification comment above already covers the oracle-behavior probes; mine adds the count-move gate (22→24) and the rebase check against moved main.
sodove commented 2026-11-28 11:27:47 +00:00

#1680 | head 73e962741df29d97dade8213e52f631124fdeee0 | python3 -I tests/test_interp_hw_probe.py -v | red: 24 run, 8 failures, 5 errors | green: 24 passed | Red → green

The tests exercised CLI parsing, malformed oracle batches and word counts, and failure cleanup. All 24 passed after merging.

Copied the PR tests onto clean main 4a54aedcb6b66525e0c9f72a6ea10263337c9141 for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. Batch claim.

#1680 | head `73e962741df29d97dade8213e52f631124fdeee0` | `python3 -I tests/test_interp_hw_probe.py -v` | red: 24 run, 8 failures, 5 errors | green: 24 passed | **Red → green** The tests exercised CLI parsing, malformed oracle batches and word counts, and failure cleanup. All 24 passed after merging. Copied the PR tests onto clean main `4a54aedcb6b66525e0c9f72a6ea10263337c9141` for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. [Batch claim](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7238450840).
DadaCap commented 2026-11-28 11:45:13 +00:00

Merged, thank you @IlyassRS3! This PR (interp_hw_probe: harden CLI parsing, oracle batch/word validation, and error lifecycle) passed its own tests with main merged in during sodove's verification of this shader batch, so it went in with the batch.

AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.

Merged, thank you @IlyassRS3! This PR (interp_hw_probe: harden CLI parsing, oracle batch/word validation, and error lifecycle) passed its own tests with main merged in during sodove's verification of this shader batch, so it went in with the batch. AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.
Sign in to join this conversation.
No description provided.