[PR #1616] div_fixup_diff: reject empty/unjudged runs, invalid counts, and malformed --ops; accept argv (DIV-FIXUP-DIFF-CLI-AND-EMPTY-RUN-GUARDS) #1630

Open
opened 2026-11-26 20:21:55 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1616
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/div-fixup-diff-cli-and-empty-run-guards


📝 Commits (1)

  • 5cb80be div_fixup_diff: reject empty/unjudged runs, invalid counts, and malformed --ops; accept argv

📊 Changes

2 files changed (+83 additions, -5 deletions)

View changed files

📝 tests/test_div_fixup_diff.py (+63 -1)
📝 tools/div_fixup_diff.py (+20 -4)

📄 Description

Item ID: DIV-FIXUP-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/div_fixup_diff.py).

What changed

  • Reject zero-program / all-unjudged runs and invalid counts (tools/div_fixup_diff.py, main, run_suite):
    • Previously --no-sweep --programs 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 and --max-ops < 1 (previously --max-ops 0 crashed inside rng.randint(1, max_ops)), and validate programs / max_ops in run_suite() 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/grid/random counts aren't skewed.
  • Synthetic regression tests (tests/test_div_fixup_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_div_fixup_diff.py -v: 29 passed
  • python3 -W error -I tests/test_text_write_line_endings.py: passed
  • python3 -I scripts/check_no_game_data.py tools/div_fixup_diff.py tests/test_div_fixup_diff.py: clean
  • python3 -m compileall -q tools/div_fixup_diff.py tests/test_div_fixup_diff.py: clean
  • Mutation test (CliGuards suite of tests/test_div_fixup_diff.py against unpatched main:tools/div_fixup_diff.py): 12 failures, 3 errors across the 4 CLI tests.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1616 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/div-fixup-diff-cli-and-empty-run-guards` --- ### 📝 Commits (1) - [`5cb80be`](https://github.com/ubiquitarianism/leonida/commit/5cb80bec7242891e6546cfd942b678ca3f651243) div_fixup_diff: reject empty/unjudged runs, invalid counts, and malformed --ops; accept argv ### 📊 Changes **2 files changed** (+83 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_div_fixup_diff.py` (+63 -1) 📝 `tools/div_fixup_diff.py` (+20 -4) </details> ### 📄 Description Item ID: `DIV-FIXUP-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/div_fixup_diff.py`). ## What changed - **Reject zero-program / all-unjudged runs and invalid counts (`tools/div_fixup_diff.py`, `main`, `run_suite`)**: - Previously `--no-sweep --programs 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` and `--max-ops < 1` (previously `--max-ops 0` crashed inside `rng.randint(1, max_ops)`), and validate `programs` / `max_ops` in `run_suite()` 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/grid/random counts aren't skewed. - **Synthetic regression tests (`tests/test_div_fixup_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_div_fixup_diff.py -v`: **29 passed** - `python3 -W error -I tests/test_text_write_line_endings.py`: passed - `python3 -I scripts/check_no_game_data.py tools/div_fixup_diff.py tests/test_div_fixup_diff.py`: clean - `python3 -m compileall -q tools/div_fixup_diff.py tests/test_div_fixup_diff.py`: clean - Mutation test (`CliGuards` suite of `tests/test_div_fixup_diff.py` against unpatched `main:tools/div_fixup_diff.py`): **12 failures, 3 errors** across the 4 CLI tests. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1630
No description provided.