f16misc_diff: reject a zero or negative --max-ops and --programs #1619

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

@⁠xel1uz on GitHub · 2026-11-25 06:11 UTC · original
xel1uz:fix/f16misc-arg-guards → main · +62 −7 · 2 files · 1 commits · open

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

Claimed as: F16MISC-ARG-GUARDS - --max-ops 0 dies in numpy's randint and --programs 0 exits 0 having run no random program. Reproduced on 42537e7b.

What and why

f16misc_diff validated neither of its two count options, so --max-ops 0 ended in ValueError: empty range in randint(1, 0) from random.randint and --programs 0 finished with exit 0 and nothing but sweep lines. Both are now rejected in main() right after parse_args, before the sweep, --list-ops and --self-test: --max-ops must be at least 1 and --programs must be at least 1, via ap.error (exit 2, usage line, no traceback). The dead --programs > 0 stage gate and the docstring's exit-code line are updated; the smallest valid run is byte-identical before and after.

Tested

  • pytest tests/test_f16misc_diff.py -q with the tool at 42537e7b: 5 failed, 28 passed - only the new guard cases fail, the valid-run case passes on both sides.

  • With this branch: 33 passed in 39.8s.

  • CLI on the branch: --max-ops 0 and --programs 0 each print the message and exit 2; --self-test and --list-ops still exit 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.
**@⁠xel1uz** on GitHub · 2026-11-25 06:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1619) `xel1uz:fix/f16misc-arg-guards` → `main` · +62 −7 · 2 files · 1 commits · open Item ID: `F16MISC-ARG-GUARDS` (new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here) Claimed as: `F16MISC-ARG-GUARDS` - `--max-ops 0` dies in numpy's randint and `--programs 0` exits 0 having run no random program. Reproduced on 42537e7b. ### What and why `f16misc_diff` validated neither of its two count options, so `--max-ops 0` ended in `ValueError: empty range in randint(1, 0)` from `random.randint` and `--programs 0` finished with exit 0 and nothing but sweep lines. Both are now rejected in `main()` right after `parse_args`, before the sweep, `--list-ops` and `--self-test`: `--max-ops must be at least 1` and `--programs must be at least 1`, via `ap.error` (exit 2, usage line, no traceback). The dead `--programs > 0` stage gate and the docstring's exit-code line are updated; the smallest valid run is byte-identical before and after. ### Tested - `pytest tests/test_f16misc_diff.py -q` with the tool at 42537e7b: **5 failed, 28 passed** - only the new guard cases fail, the valid-run case passes on both sides. - With this branch: **33 passed in 39.8s**. - CLI on the branch: `--max-ops 0` and `--programs 0` each print the message and exit 2; `--self-test` and `--list-ops` still exit 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.
A zero --programs ran the sweep and nothing else with exit 0, and a zero --max-ops reached random.randint(1, 0)'s ValueError traceback. Both are now usage errors: --max-ops and --programs must be at least 1, checked right after parsing and before any work, and argparse exits 2 with the message. main() takes argv so the tests can drive it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:20 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 17:24 UTC · original

Reviewed 1ded3b4: rejects --max-ops/--programs below 1 in tools/f16misc_diff.py before any stage (argparse exit 2); the random stage is now always appended; six new CommandLine tests. Verified on both trees (no GPU needed): tests/test_f16misc_diff.py passes on the PR tree (33) and main (27); the PR's test file on main fails 5 of the 6 new tests as intended. On main --programs 0 exits 0 having done nothing and --max-ops 0 dies with a ValueError traceback; on the PR every such invocation exits 2 with a usage error and runs no work. A seeded run is byte-identical on both trees; no other repo file calls the tool. No findings.

AI-assisted review.

Recommendation: Merge

**@⁠PierreEbele** on GitHub · 2026-11-25 17:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1619#issuecomment-7169449024) Reviewed 1ded3b4: rejects --max-ops/--programs below 1 in tools/f16misc_diff.py before any stage (argparse exit 2); the random stage is now always appended; six new CommandLine tests. Verified on both trees (no GPU needed): tests/test_f16misc_diff.py passes on the PR tree (33) and main (27); the PR's test file on main fails 5 of the 6 new tests as intended. On main --programs 0 exits 0 having done nothing and --max-ops 0 dies with a ValueError traceback; on the PR every such invocation exits 2 with a usage error and runs no work. A seeded run is byte-identical on both trees; no other repo file calls the tool. No findings. AI-assisted review. **Recommendation:** Merge
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/1619/head:github-bot/gh-1619'
git switch 'github-bot/gh-1619'

Merge

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