[PR #1656] vint_diff: restore globals, validate hardware oracle/shrink results and CLI options, and tighten RefError checks #1670

Open
opened 2026-11-26 20:22:03 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1656
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/vint-diff-oracle-cli-and-ref


📝 Commits (1)

  • 92ae998 vint_diff: restore globals, validate oracle/shrink results and CLI options, and enforce RefError checks

📊 Changes

2 files changed (+170 additions, -12 deletions)

View changed files

📝 tests/test_vint_diff.py (+98 -0)
📝 tools/vint_diff.py (+72 -12)

📄 Description

Item ID: VINT-DIFF-ORACLE-CLI-AND-REF
Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155721833

Summary

  • Module state restoration (tools/vint_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 (preventing AttributeError / IndexError on empty or short oracle responses); 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 misbehaviour or raw ValueError/KeyError/IndexError/TypeError on invalid operands, non-pair 64-bit sources/destinations, unknown or malformed v_cmp_* / v_cndmask_b32_e64 / s_mov_b32 forms, wrong source counts, and unsupported op_sel modifiers (non-OP_SEL_OPS, wrong length, or non-zero trailing selector bits).
  • Tests (tests/test_vint_diff.py): add 4 regression tests covering all of the above.

Verification

  • python3 -W error -I tests/test_vint_diff.py -v: 29 passed, 0 failed (2.718s).
  • Mutation check against unpatched main: ran=29, failures=9, errors=7.
  • python3 -m compileall -q tools/vint_diff.py tests/test_vint_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)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1656 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/vint-diff-oracle-cli-and-ref` --- ### 📝 Commits (1) - [`92ae998`](https://github.com/ubiquitarianism/leonida/commit/92ae99861a75cd904aab51e36b0a6b6cf722f5ca) vint_diff: restore globals, validate oracle/shrink results and CLI options, and enforce RefError checks ### 📊 Changes **2 files changed** (+170 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_vint_diff.py` (+98 -0) 📝 `tools/vint_diff.py` (+72 -12) </details> ### 📄 Description Item ID: `VINT-DIFF-ORACLE-CLI-AND-REF` Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155721833 ## Summary - **Module state restoration (`tools/vint_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` (preventing `AttributeError` / `IndexError` on empty or short oracle responses); 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 misbehaviour or raw `ValueError`/`KeyError`/`IndexError`/`TypeError` on invalid operands, non-pair 64-bit sources/destinations, unknown or malformed `v_cmp_*` / `v_cndmask_b32_e64` / `s_mov_b32` forms, wrong source counts, and unsupported `op_sel` modifiers (non-`OP_SEL_OPS`, wrong length, or non-zero trailing selector bits). - **Tests (`tests/test_vint_diff.py`)**: add 4 regression tests covering all of the above. ## Verification - `python3 -W error -I tests/test_vint_diff.py -v`: **29 passed, 0 failed** (2.718s). - Mutation check against unpatched `main`: **ran=29, failures=9, errors=7**. - `python3 -m compileall -q tools/vint_diff.py tests/test_vint_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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1670
No description provided.