[PR #2270] valu_fuzz: prevent oracle leak, validate CLI options upfront, and add stdlib tests #2275

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2270
Author: @kirigayakazima
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: fix/valu-fuzz-cli-safety


📝 Commits (1)

  • 2c0ed64 valu_fuzz: prevent oracle leak, validate CLI options upfront, and add stdlib tests

📊 Changes

2 files changed (+160 additions, -40 deletions)

View changed files

➕ tests/test_valu_fuzz_cli.py (+116 -0)
📝 tools/valu_fuzz.py (+44 -40)

📄 Description

Claimed in the coordination issue as: VALU-FUZZ-ORACLE-LEAK-CLI-VALIDATION-AND-TESTS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7191306204)

What and why

tools/valu_fuzz.py previously:

  • Defined main() with no argv parameter and opened runner.open_oracle() before validating --show, while also omitting try/finally oracle cleanup across hw_family_skip_reason, --gfx10-word3, and show().
  • Accepted --keep and --negative-control under --model-only, and accepted empty --keep "" or a regular file path for --keep.
  • Called subprocess.run(..., text=True) in translate() and run_gpu() without encoding="utf-8", errors="replace", and read index.json without "utf-8-sig".

This validates --show, --keep, and --negative-control upfront before opening the hardware oracle, wraps all post-open oracle usage in one try/finally so oracle.close() always runs, uses UTF-8 (errors="replace" / utf-8-sig) in translate() and run_gpu(), and adds stdlib unittest CLI coverage in tests/test_valu_fuzz_cli.py.

Tested

  • python -I tests/test_valu_fuzz_cli.py -v (5 passed)
  • Detached upstream/main baseline negative control: failed with tests/test_valu_fuzz_cli.py before the fix
  • python -I tests/test_ci_registration.py, python -I tests/test_text_write_line_endings.py, python -I scripts/check_no_game_data.py, python -I -m compileall -q, and git diff --cached --check

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

🔄 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/2270 **Author:** [@kirigayakazima](https://github.com/kirigayakazima) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/valu-fuzz-cli-safety` --- ### 📝 Commits (1) - [`2c0ed64`](https://github.com/ubiquitarianism/leonida/commit/2c0ed64ae44d81bfab40cb9c9438fb75f12bca1a) valu_fuzz: prevent oracle leak, validate CLI options upfront, and add stdlib tests ### 📊 Changes **2 files changed** (+160 additions, -40 deletions) <details> <summary>View changed files</summary> ➕ `tests/test_valu_fuzz_cli.py` (+116 -0) 📝 `tools/valu_fuzz.py` (+44 -40) </details> ### 📄 Description Claimed in the coordination issue as: VALU-FUZZ-ORACLE-LEAK-CLI-VALIDATION-AND-TESTS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7191306204) ### What and why `tools/valu_fuzz.py` previously: - Defined `main()` with no `argv` parameter and opened `runner.open_oracle()` before validating `--show`, while also omitting `try/finally` oracle cleanup across `hw_family_skip_reason`, `--gfx10-word3`, and `show()`. - Accepted `--keep` and `--negative-control` under `--model-only`, and accepted empty `--keep ""` or a regular file path for `--keep`. - Called `subprocess.run(..., text=True)` in `translate()` and `run_gpu()` without `encoding="utf-8", errors="replace"`, and read `index.json` without `"utf-8-sig"`. This validates `--show`, `--keep`, and `--negative-control` upfront before opening the hardware oracle, wraps all post-open oracle usage in one `try/finally` so `oracle.close()` always runs, uses UTF-8 (`errors="replace"` / `utf-8-sig`) in `translate()` and `run_gpu()`, and adds stdlib `unittest` CLI coverage in `tests/test_valu_fuzz_cli.py`. ### Tested - `python -I tests/test_valu_fuzz_cli.py -v` (5 passed) - Detached `upstream/main` baseline negative control: failed with `tests/test_valu_fuzz_cli.py` before the fix - `python -I tests/test_ci_registration.py`, `python -I tests/test_text_write_line_endings.py`, `python -I scripts/check_no_game_data.py`, `python -I -m compileall -q`, and `git diff --cached --check` GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. --- <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#2275
No description provided.