[PR #1623] buffer_format_fuzz: reject a negative --budget #1636

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

📋 Pull Request Information

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

Base: main ← Head: fix/buffer-arg-guards


📝 Commits (1)

  • 0294aed buffer_format_fuzz: validate --budget

📊 Changes

2 files changed (+121 additions, -1 deletions)

View changed files

➕ tests/test_buffer_format_fuzz.py (+115 -0)
📝 tools/buffer_format_fuzz.py (+6 -1)

📄 Description

Item ID: BUFFER-BUDGET-NEGATIVE (new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here)

Claimed as: BUFFER-BUDGET-NEGATIVE - a negative --budget is silently the run of 0, and --self-test ignores the value entirely. Reproduced on 42537e7b.

What and why

--budget went straight into range(budget), so -1, -100 and -1000000 produced exactly the run of 0 (1026 instead of 1106 elements for 8_8_8_8_UNORM) while every format still printed ok; --self-test builds its patterns with a hardcoded 2 and so ignores the option completely, making --budget -100 and --budget 1000000 identical in the same 1.4 s. A negative value is now ap.error("--budget cannot be negative") (exit 2, usage line), checked before --self-test and before the oracle opens, so it also wins over the exit-77 'hardware oracle unavailable'. 0 stays legal (sweeps only) and the help says so.

Found but left alone to keep this focused: --budget never reaches run_stores, so --mode store --budget N is a silent no-op.

Tested

  • New tests/test_buffer_format_fuzz.py (7 tests, CPU only, hw oracle stubbed): against the tool at 42537e7b 3 failed, 4 passed; with this branch 7 passed, and the 15 buffer-format tests together pass.

  • CLI: --self-test --budget -1 exits 2 with the message (was self-test: ok), --self-test --budget 0 still exits 0.

  • git diff --check clean; python3 -I scripts/check_no_game_data.py clean on the changed files.

GPUs tested: n/a - CPU only, no Vulkan device involved.

AI-assisted: Yes.

Checklist

  • Based on current main (42537e7b) and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption; synthetic inputs only.
  • A new translator rule in the contract table of docs/design.md - not applicable, no translator change.

🔄 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/1623 **Author:** [@xel1uz](https://github.com/xel1uz) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/buffer-arg-guards` --- ### 📝 Commits (1) - [`0294aed`](https://github.com/ubiquitarianism/leonida/commit/0294aed3ddc263d8698f46c9c9c2c225d5ab07a6) buffer_format_fuzz: validate --budget ### 📊 Changes **2 files changed** (+121 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `tests/test_buffer_format_fuzz.py` (+115 -0) 📝 `tools/buffer_format_fuzz.py` (+6 -1) </details> ### 📄 Description Item ID: `BUFFER-BUDGET-NEGATIVE` (new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here) Claimed as: `BUFFER-BUDGET-NEGATIVE` - a negative `--budget` is silently the run of `0`, and `--self-test` ignores the value entirely. Reproduced on 42537e7b. ### What and why `--budget` went straight into `range(budget)`, so `-1`, `-100` and `-1000000` produced exactly the run of `0` (1026 instead of 1106 elements for `8_8_8_8_UNORM`) while every format still printed `ok`; `--self-test` builds its patterns with a hardcoded 2 and so ignores the option completely, making `--budget -100` and `--budget 1000000` identical in the same 1.4 s. A negative value is now `ap.error("--budget cannot be negative")` (exit 2, usage line), checked before `--self-test` and before the oracle opens, so it also wins over the exit-77 'hardware oracle unavailable'. `0` stays legal (sweeps only) and the help says so. Found but left alone to keep this focused: `--budget` never reaches `run_stores`, so `--mode store --budget N` is a silent no-op. ### Tested - New `tests/test_buffer_format_fuzz.py` (7 tests, CPU only, hw oracle stubbed): against the tool at 42537e7b **3 failed, 4 passed**; with this branch **7 passed**, and the 15 buffer-format tests together pass. - CLI: `--self-test --budget -1` exits 2 with the message (was `self-test: ok`), `--self-test --budget 0` still exits 0. - `git diff --check` clean; `python3 -I scripts/check_no_game_data.py` clean on the changed files. GPUs tested: n/a - CPU only, no Vulkan device involved. AI-assisted: Yes. ### Checklist - [x] Based on current `main` (42537e7b) and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption; synthetic inputs only. - [ ] A new translator rule in the contract table of `docs/design.md` - not applicable, no translator change. --- <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#1636
No description provided.