lds_fuzz: guard --model-only/--keep/--only flags and enforce UTF-8 subprocess I/O #2269

Open
github-bot wants to merge 1 commit from github-bot/gh-2269 into main AGit
Owner

@⁠kirigayakazima on GitHub · 2026-11-26 11:53 UTC · original
kirigayakazima:fix/lds-fuzz-cli-safety → main · +113 −9 · 2 files · 1 commits · open

Claimed in the coordination issue as: LDS-FUZZ-CLI-KEEP-MODEL-ONLY-AND-ENCODING-SAFETY (#1608)

What and why

tools/lds_fuzz.py previously:

  • Defined main() with no argv parameter and skipped validating --keep / --perturb / --negative-control / --minimize whenever --model-only was also passed.
  • Accepted empty --keep "" or a regular file path for --keep, and ignored negative indices mixed into --only (such as 0,-1).
  • Invoked subprocess.run(..., text=True) in translate() and run_gpu() without encoding="utf-8", errors="replace" and read index.json without "utf-8-sig".

This adds argv=None to main(), enforces --oracle hw (without --model-only) and directory/non-empty validation for --keep, rejects negative --only indices, sets UTF-8 encoding/BOM handling in translate() and run_gpu(), and adds unit coverage in tests/test_lds_fuzz.py.

Tested

  • python -I tests/test_lds_fuzz.py -v (40 passed)
  • Detached upstream/main baseline negative control: failed with the new CLI tests 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.
**@⁠kirigayakazima** on GitHub · 2026-11-26 11:53 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2269) `kirigayakazima:fix/lds-fuzz-cli-safety` → `main` · +113 −9 · 2 files · 1 commits · open Claimed in the coordination issue as: LDS-FUZZ-CLI-KEEP-MODEL-ONLY-AND-ENCODING-SAFETY (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why `tools/lds_fuzz.py` previously: - Defined `main()` with no `argv` parameter and skipped validating `--keep` / `--perturb` / `--negative-control` / `--minimize` whenever `--model-only` was also passed. - Accepted empty `--keep ""` or a regular file path for `--keep`, and ignored negative indices mixed into `--only` (such as `0,-1`). - Invoked `subprocess.run(..., text=True)` in `translate()` and `run_gpu()` without `encoding="utf-8", errors="replace"` and read `index.json` without `"utf-8-sig"`. This adds `argv=None` to `main()`, enforces `--oracle hw` (without `--model-only`) and directory/non-empty validation for `--keep`, rejects negative `--only` indices, sets UTF-8 encoding/BOM handling in `translate()` and `run_gpu()`, and adds unit coverage in `tests/test_lds_fuzz.py`. ### Tested - `python -I tests/test_lds_fuzz.py -v` (40 passed) - Detached `upstream/main` baseline negative control: failed with the new CLI tests 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:58:33 +00:00
Author
Owner

@⁠real-rusher on GitHub · 2026-11-26 12:23 UTC · original

Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. With this PR, python -I tests/test_lds_fuzz.py: 40 tests OK. The PR's test file against main's tool: 3 errors, so the new tests fail on main and pass with the change. compileall clean.

AI-assisted: yes (Claude Code)

**@⁠real-rusher** on GitHub · 2026-11-26 12:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2269#issuecomment-7191939942) Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. With this PR, python -I tests/test_lds_fuzz.py: 40 tests OK. The PR's test file against main's tool: 3 errors, so the new tests fail on main and pass with the change. compileall clean. AI-assisted: yes (Claude Code)
Author
Owner

@⁠DeadlyChirp on GitHub · 2026-11-26 12:52 UTC · original

Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.

  • tests/test_lds_fuzz.py: 40 passed (main: 37 passed).

(AI-assisted test run; output checked by hand.)

**@⁠DeadlyChirp** on GitHub · 2026-11-26 12:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2269#issuecomment-7192571110) Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main. - `tests/test_lds_fuzz.py`: 40 passed (main: 37 passed). (AI-assisted test run; output checked by hand.)
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-27 04:37 UTC · original · approved these changes

Approving 9a678ef40.

--keep and the other hardware-only flags are refused with --model-only too (an empty --keep counted as unset before), --only rejects empty and negative indexes, and subprocess output is decoded as UTF-8 with the index read BOM-tolerant.

Merged onto main d1dff7949 in one batch with 22 other tool PRs of this series (no conflicts), on Linux with Python 3.13. tests/test_lds_fuzz.py: 40 passed (main: 37). AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠tiguan26** on GitHub · 2026-11-27 04:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2269#pullrequestreview-6083544876) · **approved these changes** Approving 9a678ef40. `--keep` and the other hardware-only flags are refused with `--model-only` too (an empty `--keep` counted as unset before), `--only` rejects empty and negative indexes, and subprocess output is decoded as UTF-8 with the index read BOM-tolerant. Merged onto `main` `d1dff7949` in one batch with 22 other tool PRs of this series (no conflicts), on Linux with Python 3.13. `tests/test_lds_fuzz.py`: 40 passed (main: 37). AI-assisted (Claude Code, Claude Opus 5.5).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2269/head:github-bot/gh-2269'
git switch 'github-bot/gh-2269'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2269'
git switch 'github-bot/gh-2269'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2269'
git switch 'github-bot/gh-2269'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2269'
git switch 'main'
git merge --squash 'github-bot/gh-2269'
git switch 'main'
git merge --ff-only 'github-bot/gh-2269'
git switch 'main'
git merge 'github-bot/gh-2269'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.