pk16_diff: restore globals, validate hardware oracle/shrink results and CLI options, and tighten RefError checks #1654

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

@⁠IlyassRS3 on GitHub · 2026-11-25 07:18 UTC · original
IlyassRS3:fix/pk16-diff-oracle-cli-and-ref → main · +158 −8 · 2 files · 1 commits · open

Item ID: PK16-DIFF-ORACLE-CLI-AND-REF
Claim: #1608

Summary

  • Module state restoration (tools/pk16_diff.py): restore KNOWN and LITERALS in main()'s finally block (and handle --list-ops/--self-test before mutating them) so in-process runs do not leak flags.
  • Hardware oracle & shrink guards: add hw_run() validating oracle is not None and exact result-list length across both run_suite() and shrink check_fn (avoiding AttributeError / IndexError on empty or short oracle returns); validate 4-word tuples/lists in _diff(); catch transient Skip during final shrunk recheck and fall back to problem.
  • CLI validation: reject empty/whitespace --hw-arch, --build, and --work.
  • Reference validation: raise RefError instead of silent ignores or raw ValueError/IndexError/TypeError on invalid operands, non-SGPR/non-VGPR destinations, wrong source counts, mismatched op_sel/op_sel_hi lengths, op_sel_hi on non-packed OPS_16 ops, and clamp on ops without clamp support.
  • Tests (tests/test_pk16_diff.py): add 4 regression tests covering all of the above.

Verification

  • python3 -W error -I tests/test_pk16_diff.py -v: 20 passed, 0 failed (2.612s).
  • Mutation check against unpatched main: ran=20, failures=7, errors=6.
  • python3 -m compileall -q tools/pk16_diff.py tests/test_pk16_diff.py, python3 -I tests/test_text_write_line_endings.py, python3 -I scripts/check_no_game_data.py: all pass.

AI-assisted: yes
GPUs tested: none (CPU unit tests with stubbed hardware oracle and spirv_mini_interp; no game data)

**@⁠IlyassRS3** on GitHub · 2026-11-25 07:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1654) `IlyassRS3:fix/pk16-diff-oracle-cli-and-ref` → `main` · +158 −8 · 2 files · 1 commits · open Item ID: `PK16-DIFF-ORACLE-CLI-AND-REF` Claim: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608 ## Summary - **Module state restoration (`tools/pk16_diff.py`)**: restore `KNOWN` and `LITERALS` in `main()`'s `finally` block (and handle `--list-ops`/`--self-test` before mutating them) so in-process runs do not leak flags. - **Hardware oracle & shrink guards**: add `hw_run()` validating `oracle is not None` and exact result-list length across both `run_suite()` and shrink `check_fn` (avoiding `AttributeError` / `IndexError` on empty or short oracle returns); validate 4-word tuples/lists in `_diff()`; catch transient `Skip` during final shrunk recheck and fall back to `problem`. - **CLI validation**: reject empty/whitespace `--hw-arch`, `--build`, and `--work`. - **Reference validation**: raise `RefError` instead of silent ignores or raw `ValueError`/`IndexError`/`TypeError` on invalid operands, non-SGPR/non-VGPR destinations, wrong source counts, mismatched `op_sel`/`op_sel_hi` lengths, `op_sel_hi` on non-packed `OPS_16` ops, and `clamp` on ops without clamp support. - **Tests (`tests/test_pk16_diff.py`)**: add 4 regression tests covering all of the above. ## Verification - `python3 -W error -I tests/test_pk16_diff.py -v`: **20 passed, 0 failed** (2.612s). - Mutation check against unpatched `main`: **ran=20, failures=7, errors=6**. - `python3 -m compileall -q tools/pk16_diff.py tests/test_pk16_diff.py`, `python3 -I tests/test_text_write_line_endings.py`, `python3 -I scripts/check_no_game_data.py`: all pass. AI-assisted: yes GPUs tested: none (CPU unit tests with stubbed hardware oracle and `spirv_mini_interp`; no game data)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:59:35 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 07:18 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:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1654#pullrequestreview-6053359442) · **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 09:32 UTC · original

Independent verification (Windows, Python 3.11.9 -I -W error): same restore-globals pattern confirmed (KNOWN/LITERALS finally-restored, mutation after oracle connect), hw_run/_diff guards, shrink Skip fallback, CLI empty-string rejection, RefError tightening incl. op_sel_hi rejected on OPS_16 and clamp-without-cl rejected. test_pk16_diff.py 20 OK (matches body); --self-test/bad-CLI(2)/hw-unavailable(77) all correct; compileall + line-endings + check_no_game_data clean. AI-assisted verification.

**@⁠whoalin1** on GitHub · 2026-11-25 09:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1654#issuecomment-7158471693) Independent verification (Windows, Python 3.11.9 `-I -W error`): same restore-globals pattern confirmed (`KNOWN`/`LITERALS` finally-restored, mutation after oracle connect), `hw_run`/`_diff` guards, shrink Skip fallback, CLI empty-string rejection, RefError tightening incl. op_sel_hi rejected on OPS_16 and clamp-without-cl rejected. `test_pk16_diff.py` 20 OK (matches body); `--self-test`/bad-CLI(2)/hw-unavailable(77) all correct; compileall + line-endings + check_no_game_data clean. AI-assisted verification.
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/1654/head:github-bot/gh-1654'
git switch 'github-bot/gh-1654'

Merge

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