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

Merged
leonida/mandy
quietfold merged 1 commit from fix/vrel-diff-cli-compare-and-ref into main 2026-11-28 14:47:17 +00:00

Pull request successfully merged and closed

quietfold commented 2026-11-25 07:26:48 +00:00

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)

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] reviewed 2026-11-25 07:26:58 +00:00
copilot-pull-request-reviewer[bot] left a comment
No description provided.
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

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.

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

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

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

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)

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 description provided.