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

Closed
xel1uz wants to merge 1 commit from upstream-pr/1626 into main
xel1uz commented 2026-11-25 06:15:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by xel1uz on 2026-11-25T06:15:51Z.


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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5486227339 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1626). Originally posted by [xel1uz](https://github.com/xel1uz) on 2026-11-25T06:15:51Z. --- 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.
kaayzouee commented 2026-11-25 07:06:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kaayzouee on 2026-11-25T07:06:46Z.


Duplicate of #1615?

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7155501050 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1626#issuecomment-7155501050). Originally posted by [kaayzouee](https://github.com/kaayzouee) on 2026-11-25T07:06:46Z. --- Duplicate of #1615?
whoalin1 commented 2026-11-25 10:33:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T10:33:00Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7159848716 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1626#issuecomment-7159848716). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T10:33:00Z. --- 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.
MoonEyes commented 2026-11-28 03:03:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T03:03:41Z.


Hi @xel1uz, thanks for this pull request.

CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post claiming: <ID> there, or a one-line description if the item is not listed yet, and put the ID in the pull request. I could not find a claim from you for this one.

The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time.

Could you post the claim in #1608 and put its ID (or a link to it) on the pull request's "Claimed in the coordination issue as:" line? If you already claimed it in another form, a link to your comment is enough.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232768118 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1626#issuecomment-7232768118). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T03:03:41Z. --- Hi @xel1uz, thanks for this pull request. CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post `claiming: <ID>` there, or a one-line description if the item is not listed yet, and put the ID in the pull request. I could not find a claim from you for this one. The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time. Could you post the claim in #1608 and put its ID (or a link to it) on the pull request's "Claimed in the coordination issue as:" line? If you already claimed it in another form, a link to your comment is enough. AI-assisted (Claude Code, Claude Opus 5.5).
MoonEyes commented 2026-11-28 18:01:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T18:01:23Z.


Hi @xel1uz, thanks for this pull request. It currently conflicts with main (conflicting file(s): tests/test_cvt_diff.py, tools/cvt_diff.py), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7243468310 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1626#issuecomment-7243468310). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T18:01:23Z. --- Hi @xel1uz, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `tests/test_cvt_diff.py`, `tools/cvt_diff.py`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
MoonEyes commented 2026-11-29 13:23:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T13:23:21Z.


Closing: main already has this guard (tools/cvt_diff.py:846-851), and main keeps --programs 0 for the sweep-only run. Thanks!

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7256500899 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1626#issuecomment-7256500899). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T13:23:21Z. --- Closing: main already has this guard (tools/cvt_diff.py:846-851), and main keeps --programs 0 for the sweep-only run. Thanks!

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1626
No description provided.