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

Open
github-bot wants to merge 1 commit from github-bot/gh-1680 into main AGit
Owner

@⁠IlyassRS3 on GitHub · 2026-11-25 07:59 UTC · original
IlyassRS3:fix/interp-hw-probe-cli-and-oracle → main · +145 −11 · 2 files · 1 commits · open

Item ID: INTERP-HW-PROBE-CLI-AND-ORACLE (claimed in #1608)

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
**@⁠IlyassRS3** on GitHub · 2026-11-25 07:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1680) `IlyassRS3:fix/interp-hw-probe-cli-and-oracle` → `main` · +145 −11 · 2 files · 1 commits · open Item ID: `INTERP-HW-PROBE-CLI-AND-ORACLE` (claimed in https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ## 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`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:00:34 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 07:59 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 07:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1680#pullrequestreview-6053799804) · **reviewed** 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.
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-25 08:52 UTC · original

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.

**@⁠whoalin1** on GitHub · 2026-11-25 08:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1680#issuecomment-7157577689) 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.
Author
Owner

@⁠GrahamboJangles on GitHub · 2026-11-25 12:06 UTC · original

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.

**@⁠GrahamboJangles** on GitHub · 2026-11-25 12:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1680#issuecomment-7161932930) 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1680/head:github-bot/gh-1680'
git switch 'github-bot/gh-1680'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1680'
git switch 'github-bot/gh-1680'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1680'
git switch 'github-bot/gh-1680'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1680'
git switch 'main'
git merge --squash 'github-bot/gh-1680'
git switch 'main'
git merge --ff-only 'github-bot/gh-1680'
git switch 'main'
git merge 'github-bot/gh-1680'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.