sad_diff: reject a zero or negative --max-ops and --programs #1624

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

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

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

Claimed as: SAD-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

sad_diff validated neither count option: --max-ops 0 ended in ValueError: empty range in randint(1, 0) and --programs 0 exited 0 after printing only sweep statistics and SAD family: 785/785 programs match. Both are now rejected in main() right after parse_args, before the sweep 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). Valid runs are unchanged.

Tested

  • pytest tests/test_sad_diff.py -q with the tool at 42537e7b: 4 failed, 14 passed.

  • With this branch: 14 passed, 4 subtests passed.

  • CLI: --max-ops 0 and --programs 0 each print the message and exit 2; --self-test 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.
**@⁠xel1uz** on GitHub · 2026-11-25 06:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1624) `xel1uz:fix/sad-arg-guards` → `main` · +31 −0 · 2 files · 1 commits · open Item ID: `SAD-ARG-GUARDS` (new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here) Claimed as: `SAD-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 `sad_diff` validated neither count option: `--max-ops 0` ended in `ValueError: empty range in randint(1, 0)` and `--programs 0` exited 0 after printing only sweep statistics and `SAD family: 785/785 programs match`. Both are now rejected in `main()` right after `parse_args`, before the sweep 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). Valid runs are unchanged. ### Tested - `pytest tests/test_sad_diff.py -q` with the tool at 42537e7b: **4 failed, 14 passed**. - With this branch: **14 passed, 4 subtests passed**. - CLI: `--max-ops 0` and `--programs 0` each print the message and exit 2; `--self-test` 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:31 +00:00
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-25 10:33 UTC · original

Independent verification (Windows, Python 3.11.9 -I -W error): +4-line guard, tests via subprocess CLI. test_sad_diff.py 14 OK; probes without --no-sweep all exit 2 before any stage; --self-test ok; valid run 2/2 match; hygiene checks clean. (Note: main() takes no argv param unlike siblings — harmless, tests cover via subprocess.) AI-assisted verification.

**@⁠whoalin1** on GitHub · 2026-11-25 10:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1624#issuecomment-7159862919) Independent verification (Windows, Python 3.11.9 `-I -W error`): +4-line guard, tests via subprocess CLI. `test_sad_diff.py` 14 OK; probes without `--no-sweep` all exit 2 before any stage; `--self-test` ok; valid run 2/2 match; hygiene checks clean. (Note: `main()` takes no argv param unlike siblings — harmless, tests cover via subprocess.) AI-assisted verification.
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/1624/head:github-bot/gh-1624'
git switch 'github-bot/gh-1624'

Merge

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