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

Merged
IlyassRS3 merged 1 commit from upstream-pr/1675 into main 2026-11-28 14:51:27 +00:00
IlyassRS3 commented 2026-11-25 07:48:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T07:48:46Z.


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

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
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5487315854 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1675). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T07:48:46Z. --- Item ID: `PKNORM-PROBE-CLI-AND-ORACLE` (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156255931) ## 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`
copilot-pull-request-reviewer[bot] commented 2026-11-25 07:48:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T07:48:59Z.

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:6053684857 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1675#pullrequestreview-6053684857). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T07:48:59Z. **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.
zmasi commented 2026-11-28 11:25:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T11:25:05Z.


#1675 | head 64e7a1ba2e (merged cleanly with main 4a54aedcb) | python -I tests/test_pknorm_probe.py | red on main: FAILED (failures=10, errors=4) (false 0 exit on empty/short oracle batches, bool words accepted, malformed --oracle/--hw-arch flags accepted, and uncaught IndexError/TypeError/Unavailable in run_hw / main) | green on PR+main: 6 tests OK | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited run_hw batch-length and strict integer/non-bool 32-bit word validation, string-rejection checking before diffs / nan_halves bit-shifts, upfront --oracle/--hw-arch validation, and runner.Unavailable -> exit 77 + RuntimeError -> exit 2 under finally: oracle.close() in tools/pknorm_probe.py. Also passed tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), tests/test_runner_calls_all_tests.py (3 OK), and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238537504 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1675#issuecomment-7238537504). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T11:25:05Z. --- #1675 | head 64e7a1ba2e72e62ea26a4344013f99bdd660aa2a (merged cleanly with main 4a54aedcb) | `python -I tests/test_pknorm_probe.py` | red on main: `FAILED (failures=10, errors=4)` (false `0` exit on empty/short oracle batches, `bool` words accepted, malformed `--oracle`/`--hw-arch` flags accepted, and uncaught `IndexError`/`TypeError`/`Unavailable` in `run_hw` / `main`) | green on PR+main: `6 tests OK` | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `run_hw` batch-length and strict integer/non-`bool` 32-bit word validation, string-rejection checking before `diffs` / `nan_halves` bit-shifts, upfront `--oracle`/`--hw-arch` validation, and `runner.Unavailable -> exit 77` + `RuntimeError -> exit 2` under `finally: oracle.close()` in `tools/pknorm_probe.py`. Also passed `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), `tests/test_runner_calls_all_tests.py` (`3 OK`), and `scripts/check_no_game_data.py`.
MoonEyes commented 2026-11-28 14:51:21 +00:00 (Migrated from github.com)

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


Red/green: classified READY by cloud-5 (red on main 09c153948, green on head merged with main); head 64e7a1ba2e 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:7240988705 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1675#issuecomment-7240988705). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:51:21Z. --- Red/green: classified READY by cloud-5 (red on main 09c153948, green on head merged with main); head 64e7a1ba2e72 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!1675
No description provided.