cvt_diff: reject a zero or negative --max-ops and --programs #1626

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

@⁠xel1uz on GitHub · 2026-11-25 06:15 UTC · original
xel1uz:fix/cvt-diff-arg-guards → main · +54 −2 · 2 files · 1 commits · open

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

Claimed as: CVT-DIFF-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

cvt_diff validated neither count option: --max-ops 0 ended in ValueError: empty range in randint(1, 0) and --programs 0 / --programs -2 exited 0 after the sweep alone, so a caller could not tell the random stage had not run. Both are now rejected in main() right after parse_args, before any work: --max-ops must be at least 1 and --programs must be at least 1, via ap.error (exit 2, usage line, no traceback), matching the sibling cf_diff.py. Valid runs are unchanged.

Tested

  • pytest tests/test_cvt_diff.py -q with the tool at 42537e7b: 5 failed, 27 passed, 18 subtests passed - only the new guard cases fail.
  • With this branch: 32 passed, 18 subtests passed.
  • git diff --check clean; python3 -I scripts/check_no_game_data.py clean on both 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:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1626) `xel1uz:fix/cvt-diff-arg-guards` → `main` · +54 −2 · 2 files · 1 commits · open Item ID: `CVT-DIFF-ARG-GUARDS` (new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here) Claimed as: `CVT-DIFF-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 `cvt_diff` validated neither count option: `--max-ops 0` ended in `ValueError: empty range in randint(1, 0)` and `--programs 0` / `--programs -2` exited 0 after the sweep alone, so a caller could not tell the random stage had not run. Both are now rejected in `main()` right after `parse_args`, before any work: `--max-ops must be at least 1` and `--programs must be at least 1`, via `ap.error` (exit 2, usage line, no traceback), matching the sibling `cf_diff.py`. Valid runs are unchanged. ### Tested - `pytest tests/test_cvt_diff.py -q` with the tool at 42537e7b: **5 failed, 27 passed, 18 subtests passed** - only the new guard cases fail. - With this branch: **32 passed, 18 subtests passed**. - `git diff --check` clean; `python3 -I scripts/check_no_game_data.py` clean on both 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.
Before: --max-ops 0 (or negative) crashed after the sweep and edge grid
had already run, with ValueError: empty range in randint(1, 0) and exit
1; --programs 0 (or negative) silently skipped the random stage and
exited 0 on the sweep alone, which reads as a full pass.

After: both are checked right after argparse, like tools/cf_diff.py:
one usage line on stderr ('--max-ops must be at least 1' / '--programs
must be at least 1') and exit 2, before any work. main() now takes an
argv list for in-process testing. Valid runs are unchanged.

tests/test_cvt_diff.py gains ArgumentValidation: 0 and negative values
for each option exit 2 with the message and no stdout, a valid short
run still matches 4/4, and main(argv) raises SystemExit(2). The five
rejection tests fail on the unpatched tool and pass with it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:34 +00:00
Author
Owner

@⁠kaayzouee on GitHub · 2026-11-25 07:06 UTC · original

Duplicate of #1615?

**@⁠kaayzouee** on GitHub · 2026-11-25 07:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1626#issuecomment-7155501050) Duplicate of #1615?
Author
Owner

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

Independent verification (Windows, Python 3.11.9 -I -W error): main(argv=None) + ap.error guards right after parse_args, before all stages incl. self-test. test_cvt_diff.py 32 OK (matches body); probes --max-ops 0/-1/-5, --programs 0/-2/-3 all exit 2 with clean usage error, no traceback; --self-test ok; valid run 4/4 match; compileall + line-endings + check_no_game_data + diff-check clean. AI-assisted verification.

**@⁠whoalin1** on GitHub · 2026-11-25 10:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1626#issuecomment-7159848716) Independent verification (Windows, Python 3.11.9 `-I -W error`): `main(argv=None)` + `ap.error` guards right after parse_args, before all stages incl. self-test. `test_cvt_diff.py` 32 OK (matches body); probes `--max-ops 0/-1/-5`, `--programs 0/-2/-3` all exit 2 with clean usage error, no traceback; `--self-test` ok; valid run 4/4 match; compileall + line-endings + check_no_game_data + diff-check clean. 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/1626/head:github-bot/gh-1626'
git switch 'github-bot/gh-1626'

Merge

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