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

Merged
IlyassRS3 merged 1 commit from upstream-pr/1661 into main 2026-11-28 14:47:17 +00:00
IlyassRS3 commented 2026-11-25 07:26:48 +00:00 (Migrated from github.com)

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


Item ID: VREL-DIFF-CLI-COMPARE-AND-REF
Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155832832

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)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5487051756 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1661). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T07:26:48Z. --- Item ID: `VREL-DIFF-CLI-COMPARE-AND-REF` Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155832832 ## 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)
copilot-pull-request-reviewer[bot] commented 2026-11-25 07:26:58 +00:00 (Migrated from github.com)

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

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:6053446055 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1661#pullrequestreview-6053446055). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T07:26:58Z. **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.
whoalin1 commented 2026-11-25 09:27:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T09:27:54Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7158365959 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1661#issuecomment-7158365959). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T09:27:54Z. --- 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.
ShotTechOp commented 2026-11-25 16:33:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ShotTechOp on 2026-11-25T16:33:38Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7168175073 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1661#issuecomment-7168175073). Originally posted by [ShotTechOp](https://github.com/ShotTechOp) on 2026-11-25T16:33:38Z. --- 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\).
MoonEyes commented 2026-11-28 14:47:14 +00:00 (Migrated from github.com)

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


Red/green: pytest tests/test_vrel_diff.py fails on main (19 failed, 19 passed, 8 subtests passed) and passes on head 0f7b01b7cd merged with main (23 passed, 23 subtests passed).
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:7240930325 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1661#issuecomment-7240930325). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:47:14Z. --- Red/green: `pytest tests/test_vrel_diff.py` fails on main (19 failed, 19 passed, 8 subtests passed) and passes on head 0f7b01b7cd14 merged with main (23 passed, 23 subtests passed). 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!1661
No description provided.