pknorm_probe: harden CLI parsing, hw oracle validation, and error lifecycle #1675

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

@⁠IlyassRS3 on GitHub · 2026-11-25 07:48 UTC · original
IlyassRS3:fix/pknorm-probe-cli-and-oracle → main · +127 −3 · 2 files · 1 commits · open

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

Summary

  • Hardware oracle result validation (tools/pknorm_probe.py):
    • In run_hw(), validate that oracle.run() returns a list/tuple matching len(case_list) and that every non-string entry is a non-empty list/tuple whose first element is an int (not bool), preventing false passes on empty/short sweep outputs (zip() truncation) and uncaught IndexError/TypeError on malformed payloads.
  • Oracle exception handling & CLI validation:
    • Catch runner.Unavailable (exit 77) and RuntimeError (exit 2) raised during oracle.run() inside try ... finally: oracle.close().
    • Check string kernel errors before diffing.
    • Reject empty/whitespace --hw-arch and empty/trailing-comma --oracle tokens ("", "hw,", ",translator") with argparse exit code 2.
  • Regression tests (tests/test_pknorm_probe.py):
    • Added CliAndOracleTests covering malformed/empty CLI flags, empty/short/long/malformed oracle payloads, string rejection entries, runner.Unavailable -> exit 77, and RuntimeError -> exit 2, verifying oracle.close() on every path.

Checklist & Verification

  • AI-assisted: yes
  • Game data included: none (python3 -I scripts/check_no_game_data.py tools/pknorm_probe.py tests/test_pknorm_probe.py passed)
  • GPUs tested: none (hostless macOS synthetic/unit test run)
  • Tests run:
    • python3 -W error -I tests/test_pknorm_probe.py -v: Ran 6 tests ... OK
    • Mutation test (new tests/test_pknorm_probe.py against unpatched main tools/pknorm_probe.py): Ran 6 tests ... FAILED (failures=10, errors=4)
    • 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:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1675) `IlyassRS3:fix/pknorm-probe-cli-and-oracle` → `main` · +127 −3 · 2 files · 1 commits · open Item ID: `PKNORM-PROBE-CLI-AND-ORACLE` (claimed in https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ## Summary - **Hardware oracle result validation (`tools/pknorm_probe.py`)**: - In `run_hw()`, validate that `oracle.run()` returns a `list`/`tuple` matching `len(case_list)` and that every non-string entry is a non-empty `list`/`tuple` whose first element is an `int` (not `bool`), preventing false passes on empty/short sweep outputs (`zip()` truncation) and uncaught `IndexError`/`TypeError` on malformed payloads. - **Oracle exception handling & CLI validation**: - Catch `runner.Unavailable` (exit `77`) and `RuntimeError` (exit `2`) raised during `oracle.run()` inside `try ... finally: oracle.close()`. - Check string kernel errors before diffing. - Reject empty/whitespace `--hw-arch` and empty/trailing-comma `--oracle` tokens (`""`, `"hw,"`, `",translator"`) with argparse exit code `2`. - **Regression tests (`tests/test_pknorm_probe.py`)**: - Added `CliAndOracleTests` covering malformed/empty CLI flags, empty/short/long/malformed oracle payloads, string rejection entries, `runner.Unavailable` -> exit `77`, and `RuntimeError` -> exit `2`, verifying `oracle.close()` on every path. ## Checklist & Verification - **AI-assisted**: yes - **Game data included**: none (`python3 -I scripts/check_no_game_data.py tools/pknorm_probe.py tests/test_pknorm_probe.py` passed) - **GPUs tested**: none (hostless macOS synthetic/unit test run) - **Tests run**: - `python3 -W error -I tests/test_pknorm_probe.py -v`: `Ran 6 tests ... OK` - Mutation test (new `tests/test_pknorm_probe.py` against unpatched `main` `tools/pknorm_probe.py`): `Ran 6 tests ... FAILED (failures=10, errors=4)` - `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:23 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 07:48 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:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1675#pullrequestreview-6053684857) · **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.
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/1675/head:github-bot/gh-1675'
git switch 'github-bot/gh-1675'

Merge

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