mode_diff: reject empty/unjudged runs, invalid counts, and malformed --ops; accept argv (MODE-DIFF-CLI-AND-EMPTY-RUN-GUARDS) #1617

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

@⁠IlyassRS3 on GitHub · 2026-11-25 06:08 UTC · original
IlyassRS3:fix/mode-diff-cli-and-empty-run-guards → main · +94 −4 · 2 files · 1 commits · open

Item ID: MODE-DIFF-CLI-AND-EMPTY-RUN-GUARDS (unlisted; coordination issue #14 is at GitHub's 2,500-comment cap with no open successor at submission time, and no open PR touches tools/mode_diff.py).

What changed

  • Reject zero-program / all-unjudged runs and invalid counts (tools/mode_diff.py, main, run_suite, run_invariance):
    • Previously --no-sweep --programs 0 --invariance 0 and runs where every program was unjudged printed 0/0 judged programs match, 0 mismatch and exited 0 (false pass). Now empty configurations are refused upfront and judged == 0 exits 2.
    • Reject --programs < 0, --invariance < 0, and --max-ops < 1 (previously --max-ops 0 crashed inside rng.randint(1, max_ops)), and validate programs / max_ops in run_suite() and run_invariance() against negative and bool values.
  • Harden --ops parsing and accept argv=None in main(argv=None): reject empty/blank/comma-only/trailing-comma --ops (previously --ops "" and --ops "," silently ran all ops or fell back to empty list) and deduplicate repeated op names so sweep/random counts aren't skewed.
  • Synthetic regression tests (tests/test_mode_diff.py): 4 new tests in CliGuards covering all of the above (no game files, no GPU).

Verification

  • AI-assisted: yes
  • GPUs tested: none (CPU-only Python tool on macOS)
  • python3 -W error -I tests/test_mode_diff.py -v: 20 passed
  • python3 -W error -I tests/test_text_write_line_endings.py: passed
  • python3 -I scripts/check_no_game_data.py tools/mode_diff.py tests/test_mode_diff.py: clean
  • python3 -m compileall -q tools/mode_diff.py tests/test_mode_diff.py: clean
  • Mutation test (CliGuards suite of tests/test_mode_diff.py against unpatched main:tools/mode_diff.py): 16 failures, 3 errors across the 4 CLI tests.
**@⁠IlyassRS3** on GitHub · 2026-11-25 06:08 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1617) `IlyassRS3:fix/mode-diff-cli-and-empty-run-guards` → `main` · +94 −4 · 2 files · 1 commits · open Item ID: `MODE-DIFF-CLI-AND-EMPTY-RUN-GUARDS` (unlisted; coordination issue #14 is at GitHub's 2,500-comment cap with no open successor at submission time, and no open PR touches `tools/mode_diff.py`). ## What changed - **Reject zero-program / all-unjudged runs and invalid counts (`tools/mode_diff.py`, `main`, `run_suite`, `run_invariance`)**: - Previously `--no-sweep --programs 0 --invariance 0` and runs where every program was `unjudged` printed `0/0 judged programs match, 0 mismatch` and exited `0` (false pass). Now empty configurations are refused upfront and `judged == 0` exits `2`. - Reject `--programs < 0`, `--invariance < 0`, and `--max-ops < 1` (previously `--max-ops 0` crashed inside `rng.randint(1, max_ops)`), and validate `programs` / `max_ops` in `run_suite()` and `run_invariance()` against negative and `bool` values. - **Harden `--ops` parsing and accept `argv=None` in `main(argv=None)`**: reject empty/blank/comma-only/trailing-comma `--ops` (previously `--ops ""` and `--ops ","` silently ran all ops or fell back to empty list) and deduplicate repeated op names so sweep/random counts aren't skewed. - **Synthetic regression tests (`tests/test_mode_diff.py`)**: 4 new tests in `CliGuards` covering all of the above (no game files, no GPU). ## Verification - AI-assisted: yes - GPUs tested: none (CPU-only Python tool on macOS) - `python3 -W error -I tests/test_mode_diff.py -v`: **20 passed** - `python3 -W error -I tests/test_text_write_line_endings.py`: passed - `python3 -I scripts/check_no_game_data.py tools/mode_diff.py tests/test_mode_diff.py`: clean - `python3 -m compileall -q tools/mode_diff.py tests/test_mode_diff.py`: clean - Mutation test (`CliGuards` suite of `tests/test_mode_diff.py` against unpatched `main:tools/mode_diff.py`): **16 failures, 3 errors** across the 4 CLI tests.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:16 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 06:09 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 06:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1617#pullrequestreview-6052656209) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-25 06:20 UTC · original

Tested 741b5fe59 on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main 42537e7b6 (Python GPU differential tool; no campaign run):

  • pytest 9.2.0 on tests/test_mode_diff.py: 20 passed, 20 subtests passed at this head.
  • The same file on main: 19 failed, 17 passed, 4 subtests — the empty/all-unjudged run guards, count validation and argv handling are not there.
  • Not run: an actual mode_diff campaign on the GPU; only the unit tests.

AI-assisted; synthetic fixtures only, no game data.

**@⁠GeorgiyDemo** on GitHub · 2026-11-25 06:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1617#issuecomment-7154686216) Tested `741b5fe59` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `42537e7b6` (Python GPU differential tool; no campaign run): - pytest 9.2.0 on `tests/test_mode_diff.py`: **20 passed, 20 subtests passed** at this head. - The same file on `main`: **19 failed**, 17 passed, 4 subtests — the empty/all-unjudged run guards, count validation and argv handling are not there. - Not run: an actual `mode_diff` campaign on the GPU; only the unit tests. AI-assisted; synthetic fixtures only, no game data.
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/1617/head:github-bot/gh-1617'
git switch 'github-bot/gh-1617'

Merge

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