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

Closed
leonida/mandy
xel1uz wants to merge 0 commits from fix/dot-diff-arg-guards into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

xel1uz commented 2026-11-25 06:19:54 +00:00

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.
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.
whoalin1 commented 2026-11-25 11:25:22 +00:00

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.

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.
MoonEyes commented 2026-11-28 03:03:51 +00:00

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).

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:18 +00:00

Hi @xel1uz, thanks for this pull request. It currently conflicts with main (conflicting file(s): tests/test_dot_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).

Hi @xel1uz, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `tests/test_dot_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:19 +00:00

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

Closing: main already has this guard (tools/dot_diff.py:647-652), and main keeps --programs 0 for the sweep-only run. Thanks!
Sign in to join this conversation.
No description provided.