vrel_diff: reject malformed --ops tokens, guard compare() lane/word counts, handle shrink Skip, and tighten RefError checks #1661

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

@⁠IlyassRS3 on GitHub · 2026-11-25 07:26 UTC · original
IlyassRS3:fix/vrel-diff-cli-compare-and-ref → main · +103 −11 · 2 files · 1 commits · open

Item ID: VREL-DIFF-CLI-COMPARE-AND-REF
Claim: #1608

Summary

  • CLI --ops validation (tools/vrel_diff.py): check args.ops is not None (previously --ops "" silently ran all ops and --ops " , " crashed with IndexError), reject empty/trailing comma tokens, and deduplicate op tokens preserving order.
  • Comparison bounds (compare()): reject mismatched lane counts (previously got == [] silently returned None as a false pass) and non-32-word lane payloads (previously IndexError).
  • Shrink stability (run_suite()): catch transient Skip when re-evaluating the shrunk program and fall back to the original mismatch detail.
  • Reference & event validation (State, step(), rel(), events()): raise RefError instead of IndexError/ValueError/TypeError on empty tokens, wrong operand counts, non-integer v_writelane_b32 lane indices, and uninitialized m0 in events().
  • Tests (tests/test_vrel_diff.py): add 4 regression tests covering all of the above.

Verification

  • python3 -W error -I tests/test_vrel_diff.py -v: 23 passed, 0 failed (2.569s).
  • Mutation check against unpatched main: ran=23, failures=8, errors=11.
  • python3 -m compileall -q tools/vrel_diff.py tests/test_vrel_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 spirv_wave_interp; no game data)

**@⁠IlyassRS3** on GitHub · 2026-11-25 07:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1661) `IlyassRS3:fix/vrel-diff-cli-compare-and-ref` → `main` · +103 −11 · 2 files · 1 commits · open Item ID: `VREL-DIFF-CLI-COMPARE-AND-REF` Claim: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608 ## Summary - **CLI `--ops` validation (`tools/vrel_diff.py`)**: check `args.ops is not None` (previously `--ops ""` silently ran all ops and `--ops " , "` crashed with `IndexError`), reject empty/trailing comma tokens, and deduplicate op tokens preserving order. - **Comparison bounds (`compare()`)**: reject mismatched lane counts (previously `got == []` silently returned `None` as a false pass) and non-32-word lane payloads (previously `IndexError`). - **Shrink stability (`run_suite()`)**: catch transient `Skip` when re-evaluating the shrunk program and fall back to the original mismatch detail. - **Reference & event validation (`State`, `step()`, `rel()`, `events()`)**: raise `RefError` instead of `IndexError`/`ValueError`/`TypeError` on empty tokens, wrong operand counts, non-integer `v_writelane_b32` lane indices, and uninitialized `m0` in `events()`. - **Tests (`tests/test_vrel_diff.py`)**: add 4 regression tests covering all of the above. ## Verification - `python3 -W error -I tests/test_vrel_diff.py -v`: **23 passed, 0 failed** (2.569s). - Mutation check against unpatched `main`: **ran=23, failures=8, errors=11**. - `python3 -m compileall -q tools/vrel_diff.py tests/test_vrel_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 `spirv_wave_interp`; no game data)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:59:49 +00:00
Author
Owner

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

Independent verification (Windows, Python 3.11.9 -I -W error): --ops gated on is not None (empty/blank/comma tokens now exit 2, order-preserving dedup), compare() lane/word-count guards replace IndexError/false-pass, transient Skip fallback in run_suite, RefError tightening across scalar/vreg/set_scalar/rel/events — all match claims. test_vrel_diff.py 23 OK; --self-test canaries ok; bad-CLI probes exit 2; compileall + line-endings + check_no_game_data clean. (Minor pre-existing nit: malformed internal rel line could ValueError in events(), unreachable from user input.) AI-assisted verification.

**@⁠whoalin1** on GitHub · 2026-11-25 09:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1661#issuecomment-7158365959) Independent verification (Windows, Python 3.11.9 `-I -W error`): `--ops` gated on `is not None` (empty/blank/comma tokens now exit 2, order-preserving dedup), compare() lane/word-count guards replace IndexError/false-pass, transient Skip fallback in run_suite, RefError tightening across scalar/vreg/set_scalar/rel/events — all match claims. `test_vrel_diff.py` 23 OK; `--self-test` canaries ok; bad-CLI probes exit 2; compileall + line-endings + check_no_game_data clean. (Minor pre-existing nit: malformed internal rel line could ValueError in events(), unreachable from user input.) AI-assisted verification.
Author
Owner

@⁠ShotTechOp on GitHub · 2026-11-25 16:33 UTC · original

Spotted one pre-existing bug in \ ools/vrel_diff.py's
el()\ while auditing the *_diff.py\ references: \dst = st.index(st.vreg(d) + do)\ runs unconditionally before \elif op == 'v_movrels_b32':, even though \ _movrels_b32\ is in \WHOLE_M0\ (\do = so = m0) and only offsets the source VGPR, never the destination. So a valid \ _movrels_b32 v25, v5\ with \m0 = 10\ raises \RefError: VGPR index 35 outside v0..v31\ instead of reading \ 15\ into \ 25. Worth moving \dst = st.index(st.vreg(d) + do)\ into the branches that actually offset \d\ (or setting \do = 0\ for \ _movrels_b32).

**@⁠ShotTechOp** on GitHub · 2026-11-25 16:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1661#issuecomment-7168175073) Spotted one pre-existing bug in \ ools/vrel_diff.py\'s \ el()\ while auditing the \*_diff.py\ references: \dst = st.index(st.vreg(d) + do)\ runs unconditionally before \elif op == 'v_movrels_b32':\, even though \ _movrels_b32\ is in \WHOLE_M0\ (\do = so = m0\) and only offsets the source VGPR, never the destination. So a valid \ _movrels_b32 v25, v5\ with \m0 = 10\ raises \RefError: VGPR index 35 outside v0..v31\ instead of reading \ 15\ into \ 25\. Worth moving \dst = st.index(st.vreg(d) + do)\ into the branches that actually offset \d\ (or setting \do = 0\ for \ _movrels_b32\).
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/1661/head:github-bot/gh-1661'
git switch 'github-bot/gh-1661'

Merge

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