dot_diff: reject a zero or negative --max-ops and --programs #1629

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

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

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

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

dot_diff validated neither count option: --max-ops 0 ended in ValueError: empty range in randint(1, 0) and --programs 0 / --programs -3 exited 0 after sweep statistics only (cases per op, results outside the 32-bit range), so a caller could not tell the random stage never ran. 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. Side effect worth naming: the guards sit before the --list-ops/--self-test early returns, so --list-ops --max-ops 0 now also fails - deliberate, arguments are validated up front.

Tested

  • pytest tests/test_dot_diff.py -q with the tool at 42537e7b: 4 failed, 18 passed, 15 subtests passed - only the new guard cases fail.
  • With this branch: 22 passed, 15 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:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1629) `xel1uz:fix/dot-diff-arg-guards` → `main` · +43 −0 · 2 files · 1 commits · open Item ID: `DOT-DIFF-ARG-GUARDS` (new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here) Claimed as: `DOT-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 `dot_diff` validated neither count option: `--max-ops 0` ended in `ValueError: empty range in randint(1, 0)` and `--programs 0` / `--programs -3` exited 0 after sweep statistics only (`cases per op`, `results outside the 32-bit range`), so a caller could not tell the random stage never ran. 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. Side effect worth naming: the guards sit before the `--list-ops`/`--self-test` early returns, so `--list-ops --max-ops 0` now also fails - deliberate, arguments are validated up front. ### Tested - `pytest tests/test_dot_diff.py -q` with the tool at 42537e7b: **4 failed, 18 passed, 15 subtests passed** - only the new guard cases fail. - With this branch: **22 passed, 15 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.
Both options feed counts that must be positive, but neither was checked.

Before:
  $ python3 -I tools/dot_diff.py --max-ops 0
  ValueError: empty range in randint(1, 0)   (rc 1, traceback)
  $ python3 -I tools/dot_diff.py --max-ops -3
  same traceback
  $ python3 -I tools/dot_diff.py --programs 0     (also -3)
  printed the sweep statistics only, no random program, rc 0

A zero/negative --programs therefore looked like a pass while nothing of the
suite it names had run.

After:
  both are refused right after argument parsing with one usage line on stderr
  and exit 2, the same shape as tools/cf_diff.py:
  "dot_diff.py: error: --max-ops must be at least 1" (likewise --programs).

Valid runs are unchanged; tests/test_dot_diff.py covers 0 and negative for
both options (rc 2, message, no traceback, no stdout) and a one-program run
(rc 0). The four rejection cases fail on the previous tool.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:39 +00:00
Author
Owner

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

Duplicate of #1613?

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

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

Independent verification (Windows, Python 3.11.9): guards correct — ap.error after parse_args before all early returns; test_dot_diff.py 22 OK; --max-ops 0/--programs 0 --no-sweep exit 2 cleanly. Coordination flag: this conflicts in intent with open #1613 (IlyassRS) — #1613 rejects --max-ops < 1 too but allows --programs 0 as "no random stage" (errors only with --no-sweep), while this rejects --programs 0 outright. Maintainers should pick one policy before merge. AI-assisted verification.

**@⁠whoalin1** on GitHub · 2026-11-25 11:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1629#issuecomment-7161025901) Independent verification (Windows, Python 3.11.9): guards correct — `ap.error` after parse_args before all early returns; `test_dot_diff.py` 22 OK; `--max-ops 0`/`--programs 0 --no-sweep` exit 2 cleanly. **Coordination flag**: this conflicts in intent with open #1613 (IlyassRS) — #1613 rejects `--max-ops < 1` too but allows `--programs 0` as "no random stage" (errors only with `--no-sweep`), while this rejects `--programs 0` outright. Maintainers should pick one policy before merge. 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/1629/head:github-bot/gh-1629'
git switch 'github-bot/gh-1629'

Merge

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