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

Merged
leonida/mandy
xel1uz merged 1 commit from fix/sad-arg-guards into main 2026-11-29 19:02:32 +00:00

Pull request successfully merged and closed

xel1uz commented 2026-11-25 06:11:42 +00:00

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

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.

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.
MoonEyes commented 2026-11-28 03:03:19 +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).
TheGeogeo commented 2026-11-29 00:16:59 +00:00

Tested e55d9b7fc merged (no commit) with main 829530dbd: Python 3.12.4, Windows 11 10.0.26300, CPU only. check_no_game_data.py is clean.

  • Green: tests/test_sad_diff.py, it passes (exit 0).
  • Red: with tools/sad_diff.py back to main, it exits 1: test_zero_or_negative_counts_are_usage_errors_before_any_work fails for --max-o... and --progr....

No blocker from my side.

AI-assisted (Claude Code).

Tested `e55d9b7fc` merged (no commit) with `main` `829530dbd`: Python 3.12.4, Windows 11 10.0.26300, CPU only. `check_no_game_data.py` is clean. - Green: `tests/test_sad_diff.py`, it passes (exit 0). - Red: with `tools/sad_diff.py` back to `main`, it exits 1: `test_zero_or_negative_counts_are_usage_errors_before_any_work` fails for `--max-o...` and `--progr...`. No blocker from my side. AI-assisted (Claude Code).
zmasi commented 2026-11-29 00:22:25 +00:00

Native Windows 11 Verification (e55d9b7fc1) — PASS

Diff-audited tools/sad_diff.py (+4/-0) and tests/test_sad_diff.py (+27/-0) and verified Red -> Green merged onto origin/main (48bae6cad) on Windows 11 (10.0.26200, Python 3.12.10 with -I).

Results

  • Red (origin/main 48bae6cad): python -I tools/sad_diff.py --no-sweep --max-ops 0 crashed with an unhandled traceback (ValueError: empty range in randrange(1, 1), rc=1).
  • Green (PR #1624 merged onto origin/main):
    • python -I tests/test_sad_diff.py: rc=0 (OK) — 0 and -1 on both --max-ops and --programs exit 2 cleanly with --max-ops must be at least 1 / --programs must be at least 1 before any sweep runs, and seeded runs (2/2 and 6 programs) continue to match.
    • tests/test_ci_registration.py (18/18), tests/test_text_write_line_endings.py (3/3), and scripts/check_no_game_data.py: OK.

AI-assisted.

### Native Windows 11 Verification (`e55d9b7fc1`) — PASS Diff-audited `tools/sad_diff.py` (`+4/-0`) and `tests/test_sad_diff.py` (`+27/-0`) and verified Red -> Green merged onto `origin/main` (`48bae6cad`) on Windows 11 (`10.0.26200`, Python `3.12.10` with `-I`). #### Results - **Red (`origin/main` `48bae6cad`)**: `python -I tools/sad_diff.py --no-sweep --max-ops 0` crashed with an unhandled traceback (`ValueError: empty range in randrange(1, 1)`, `rc=1`). - **Green (`PR #1624` merged onto `origin/main`)**: - `python -I tests/test_sad_diff.py`: **`rc=0` (`OK`)** — `0` and `-1` on both `--max-ops` and `--programs` exit `2` cleanly with `--max-ops must be at least 1` / `--programs must be at least 1` before any sweep runs, and seeded runs (`2/2` and `6` programs) continue to match. - `tests/test_ci_registration.py` (`18/18`), `tests/test_text_write_line_endings.py` (`3/3`), and `scripts/check_no_game_data.py`: **`OK`**. AI-assisted.
TheGeogeo commented 2026-11-29 11:51:51 +00:00

Tested green here earlier on this same head (see my comment above). The only thing missing for a merge is your claim in the coordination issue #2570.

AI-assisted (Claude Code).

Tested green here earlier on this same head (see my comment above). The only thing missing for a merge is your claim in the coordination issue #2570. AI-assisted (Claude Code).
TheGeogeo commented 2026-11-29 18:58:47 +00:00

Tested e55d9b7fc merged (no commit) with main 7c330c76d: Python 3.12.4, Windows 11 10.0.26300, CPU only.

  • Green: python -I tests/test_sad_diff.py gives 14 tests OK.
  • Red: with tools/sad_diff.py back to main, test_zero_or_negative_counts_are_usage_errors_before_any_work fails for --max-ops and --programs at 0 and -1 (4 subtests).
  • Base: main's own version of that test gives 12 tests OK. check_no_game_data.py is clean.

AI-assisted (Claude Code).

Tested `e55d9b7fc` merged (no commit) with `main` `7c330c76d`: Python 3.12.4, Windows 11 10.0.26300, CPU only. - Green: `python -I tests/test_sad_diff.py` gives 14 tests OK. - Red: with `tools/sad_diff.py` back to `main`, `test_zero_or_negative_counts_are_usage_errors_before_any_work` fails for `--max-ops` and `--programs` at 0 and -1 (4 subtests). - Base: `main`'s own version of that test gives 12 tests OK. `check_no_game_data.py` is clean. AI-assisted (Claude Code).
MoonEyes commented 2026-11-29 19:02:30 +00:00

Merging. Head e55d9b7fc has red/green verdicts from reviewers other than the author (above), merges cleanly with main 79f89c490, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (translator-tests mesh, semantic-tests f16) are pre-existing. Merged by MoonEyes.

AI-assisted (Claude Code).

Merging. Head `e55d9b7fc` has red/green verdicts from reviewers other than the author (above), merges cleanly with `main` `79f89c490`, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (`translator-tests` mesh, `semantic-tests` f16) are pre-existing. Merged by MoonEyes. AI-assisted (Claude Code).
Sign in to join this conversation.
No description provided.