f16misc_diff: reject a zero or negative --max-ops and --programs #1619

Merged
xel1uz merged 1 commit from upstream-pr/1619 into main 2026-11-29 18:28:06 +00:00
xel1uz commented 2026-11-25 06:11:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by xel1uz on 2026-11-25T06:11:24Z.


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

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

f16misc_diff validated neither of its two count options, so --max-ops 0 ended in ValueError: empty range in randint(1, 0) from random.randint and --programs 0 finished with exit 0 and nothing but sweep lines. Both are now rejected in main() right after parse_args, before the sweep, --list-ops 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). The dead --programs > 0 stage gate and the docstring's exit-code line are updated; the smallest valid run is byte-identical before and after.

Tested

  • pytest tests/test_f16misc_diff.py -q with the tool at 42537e7b: 5 failed, 28 passed - only the new guard cases fail, the valid-run case passes on both sides.

  • With this branch: 33 passed in 39.8s.

  • CLI on the branch: --max-ops 0 and --programs 0 each print the message and exit 2; --self-test and --list-ops still exit 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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5486179321 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1619). Originally posted by [xel1uz](https://github.com/xel1uz) on 2026-11-25T06:11:24Z. --- Item ID: `F16MISC-ARG-GUARDS` (new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here) Claimed as: `F16MISC-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 `f16misc_diff` validated neither of its two count options, so `--max-ops 0` ended in `ValueError: empty range in randint(1, 0)` from `random.randint` and `--programs 0` finished with exit 0 and nothing but sweep lines. Both are now rejected in `main()` right after `parse_args`, before the sweep, `--list-ops` 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). The dead `--programs > 0` stage gate and the docstring's exit-code line are updated; the smallest valid run is byte-identical before and after. ### Tested - `pytest tests/test_f16misc_diff.py -q` with the tool at 42537e7b: **5 failed, 28 passed** - only the new guard cases fail, the valid-run case passes on both sides. - With this branch: **33 passed in 39.8s**. - CLI on the branch: `--max-ops 0` and `--programs 0` each print the message and exit 2; `--self-test` and `--list-ops` still exit 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.
PierreEbele commented 2026-11-25 17:24:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T17:24:04Z.


Reviewed 1ded3b4: rejects --max-ops/--programs below 1 in tools/f16misc_diff.py before any stage (argparse exit 2); the random stage is now always appended; six new CommandLine tests. Verified on both trees (no GPU needed): tests/test_f16misc_diff.py passes on the PR tree (33) and main (27); the PR's test file on main fails 5 of the 6 new tests as intended. On main --programs 0 exits 0 having done nothing and --max-ops 0 dies with a ValueError traceback; on the PR every such invocation exits 2 with a usage error and runs no work. A seeded run is byte-identical on both trees; no other repo file calls the tool. No findings.

AI-assisted review.

Recommendation: Merge

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7169449024 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1619#issuecomment-7169449024). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T17:24:04Z. --- Reviewed 1ded3b4: rejects --max-ops/--programs below 1 in tools/f16misc_diff.py before any stage (argparse exit 2); the random stage is now always appended; six new CommandLine tests. Verified on both trees (no GPU needed): tests/test_f16misc_diff.py passes on the PR tree (33) and main (27); the PR's test file on main fails 5 of the 6 new tests as intended. On main --programs 0 exits 0 having done nothing and --max-ops 0 dies with a ValueError traceback; on the PR every such invocation exits 2 with a usage error and runs no work. A seeded run is byte-identical on both trees; no other repo file calls the tool. No findings. AI-assisted review. **Recommendation:** Merge
MoonEyes commented 2026-11-28 03:02:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T03:02:34Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232755797 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1619#issuecomment-7232755797). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T03:02:34Z. --- 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).
zmasi commented 2026-11-28 20:43:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T20:43:30Z.


#1619 | head 1ded3b4d8e (merged cleanly with main 1bc055e6c2) | python -I tests/test_f16misc_diff.py | red on main: FAILED (failures=3, errors=2) (--max-ops 0 and -3 crashed in randrange, while --programs 0 and -1 exited 0 without running random programs) | green on PR+main: 33 tests OK | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Audited tools/f16misc_diff.py and tests/test_f16misc_diff.py on Windows 11, verifying upfront args.max_ops < 1 and args.programs < 1 ap.error(...) usage checks (exit 2, before --list-ops or sweep/random stages) and optional argv parameter support in main(argv=None). Also verified tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7245494161 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1619#issuecomment-7245494161). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T20:43:30Z. --- #1619 | head 1ded3b4d8e2939d7cf2ca7ce535917afb440ff69 (merged cleanly with main 1bc055e6c2) | `python -I tests/test_f16misc_diff.py` | red on main: `FAILED (failures=3, errors=2)` (`--max-ops 0` and `-3` crashed in `randrange`, while `--programs 0` and `-1` exited `0` without running random programs) | green on PR+main: `33 tests OK` | Windows 11 (`10.0.26200.9974`), Python 3.12.10 | AI-assisted: yes Audited `tools/f16misc_diff.py` and `tests/test_f16misc_diff.py` on Windows 11, verifying upfront `args.max_ops < 1` and `args.programs < 1` `ap.error(...)` usage checks (exit `2`, before `--list-ops` or sweep/random stages) and optional `argv` parameter support in `main(argv=None)`. Also verified `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), and `scripts/check_no_game_data.py`.
TheGeogeo commented 2026-11-29 00:17:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T00:17:06Z.


Tested 1ded3b4d8 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_f16misc_diff.py, 33 tests pass.
  • Red: with tools/f16misc_diff.py back to main, the new usage checks fail (exit 0 != 2, e.g. --list-ops --programs 0).

No blocker from my side.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248005531 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1619#issuecomment-7248005531). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T00:17:06Z. --- Tested `1ded3b4d8` 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_f16misc_diff.py`, 33 tests pass. - Red: with `tools/f16misc_diff.py` back to `main`, the new usage checks fail (exit `0 != 2`, e.g. `--list-ops --programs 0`). No blocker from my side. AI-assisted (Claude Code).
TheGeogeo commented 2026-11-29 11:51:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T11:51:56Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7255402531 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1619#issuecomment-7255402531). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T11:51:56Z. --- 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).
OreoFR commented 2026-11-29 17:11:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T17:11:14Z.


Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main 4364a4fa6, PR head 1ded3b4d8 : red 5 failures / green 33 OK

  • Merge: clean (git merge-tree). Reviews: none. No game data in the diff. Skipped on the merge: none.
  • (MEASURED n=3) each red failure reruns alone 3/3.
  • Red: 33 tests, 5 failures/errors: test_max_ops_negative_is_rejected, test_max_ops_zero_is_rejected, test_programs_negative_is_rejected, test_programs_zero_is_rejected, test_validation_comes_before_list_ops.
  • Green: 33/33 OK. No other test imports f16misc_diff.
  • Diff: clean. Behaviour change worth noting: --programs 0 is now refused, so the random stage can no longer be skipped that way (docstring updated accordingly).

Verdict: READY

AI-assisted: Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7259491547 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1619#issuecomment-7259491547). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T17:11:14Z. --- Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main 4364a4fa6, PR head 1ded3b4d8 : red 5 failures / green 33 OK - Merge: clean (`git merge-tree`). Reviews: none. No game data in the diff. Skipped on the merge: none. - (MEASURED n=3) each red failure reruns alone 3/3. - **Red**: 33 tests, 5 failures/errors: `test_max_ops_negative_is_rejected`, `test_max_ops_zero_is_rejected`, `test_programs_negative_is_rejected`, `test_programs_zero_is_rejected`, `test_validation_comes_before_list_ops`. - **Green**: 33/33 OK. No other test imports `f16misc_diff`. - Diff: clean. Behaviour change worth noting: `--programs 0` is now refused, so the random stage can no longer be skipped that way (docstring updated accordingly). **Verdict: READY** AI-assisted: Claude Code
DadaCap commented 2026-11-29 18:28:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-29T18:28:08Z.


Thank you! Merged into main with a merge commit. It was verified ready on its current head (1ded3b4d8) by OreoFR's Mac agent (macOS, red/green on main + PR); see the verification comment above. (AI-assisted, posted for DadaCap.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260506622 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1619#issuecomment-7260506622). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-29T18:28:08Z. --- Thank you! Merged into `main` with a merge commit. It was verified ready on its current head (1ded3b4d8) by OreoFR's Mac agent (macOS, red/green on main + PR); see the verification comment above. (AI-assisted, posted for DadaCap.)
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1619
No description provided.