[PR #1663] f64_diff: harden CLI guards, validate hw oracle batch/word counts, and propagate HarnessError out of shrink() #1675

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

📋 Pull Request Information

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

Base: main ← Head: fix/f64-diff-cli-oracle-and-shrink


📝 Commits (1)

  • 2ddbf4b f64_diff: harden --ops/--hw-arch/--exe/zero-case CLI guards, validate hw oracle results, and propagate shrink HarnessError

📊 Changes

2 files changed (+105 additions, -7 deletions)

View changed files

📝 tests/test_f64_diff.py (+62 -0)
📝 tools/f64_diff.py (+43 -7)

📄 Description

Item ID: F64-DIFF-CLI-ORACLE-AND-SHRINK
Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155892025

Summary

  • CLI validation (tools/f64_diff.py): reject empty/whitespace/trailing-comma --ops (previously --ops "" silently ran all 47 ops), deduplicate --ops tokens, reject empty --hw-arch/--exe (previously --exe "" silently fell back to default vk_harness), and reject zero-case runs (--no-sweep --programs 0 without --known) with exit 2.
  • Hardware oracle result & shrink validation: guard hw is None, exact batch length in run_batch(), exact single-result return in run_one(), and 4-word list/tuple payloads (previously a short word list like [0, 1] produced a false shader mismatch exit 1 instead of HarnessError exit 2). Propagate HarnessError out of shrink() instead of swallowing it.
  • GPU subprocess safety: add errors="replace" and OSError -> HarnessError handling to glslc, spirv-as, and vk_harness invocations in prepare_gpu() / run_gpu().
  • Tests (tests/test_f64_diff.py): add 2 regression tests covering all of the above (keeping existing all-skipped-exits-0 tests intact).

Verification

  • python3 -W error -I tests/test_f64_diff.py -v: 34 passed, 0 failed (1.112s).
  • Mutation check against unpatched main: ran=34, failures=12, errors=0.
  • python3 -m compileall -q tools/f64_diff.py tests/test_f64_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 SPIR-V interpreter; 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/1663 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/f64-diff-cli-oracle-and-shrink` --- ### 📝 Commits (1) - [`2ddbf4b`](https://github.com/ubiquitarianism/leonida/commit/2ddbf4b48b52073b8131daf9ca82e0ffd0ef3a4a) f64_diff: harden --ops/--hw-arch/--exe/zero-case CLI guards, validate hw oracle results, and propagate shrink HarnessError ### 📊 Changes **2 files changed** (+105 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_f64_diff.py` (+62 -0) 📝 `tools/f64_diff.py` (+43 -7) </details> ### 📄 Description Item ID: `F64-DIFF-CLI-ORACLE-AND-SHRINK` Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155892025 ## Summary - **CLI validation (`tools/f64_diff.py`)**: reject empty/whitespace/trailing-comma `--ops` (previously `--ops ""` silently ran all 47 ops), deduplicate `--ops` tokens, reject empty `--hw-arch`/`--exe` (previously `--exe ""` silently fell back to default `vk_harness`), and reject zero-case runs (`--no-sweep --programs 0` without `--known`) with exit `2`. - **Hardware oracle result & shrink validation**: guard `hw is None`, exact batch length in `run_batch()`, exact single-result return in `run_one()`, and 4-word list/tuple payloads (previously a short word list like `[0, 1]` produced a false shader mismatch exit `1` instead of `HarnessError` exit `2`). Propagate `HarnessError` out of `shrink()` instead of swallowing it. - **GPU subprocess safety**: add `errors="replace"` and `OSError` -> `HarnessError` handling to `glslc`, `spirv-as`, and `vk_harness` invocations in `prepare_gpu()` / `run_gpu()`. - **Tests (`tests/test_f64_diff.py`)**: add 2 regression tests covering all of the above (keeping existing all-skipped-exits-0 tests intact). ## Verification - `python3 -W error -I tests/test_f64_diff.py -v`: **34 passed, 0 failed** (1.112s). - Mutation check against unpatched `main`: **ran=34, failures=12, errors=0**. - `python3 -m compileall -q tools/f64_diff.py tests/test_f64_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 SPIR-V interpreter; 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#1675
No description provided.