OLD-7087: restore old upstream PR 7087 - audit_shader4_regs: --limit must be at least 1; 0 audited nothing and printed a zero report #713

Manually merged
github merged 1 commit from gh-pr/713/head into gh-pr/713/base 2026-11-26 09:17:36 +00:00
Owner

@⁠aslan2142 on GitHub · 2026-11-24 12:40 UTC · original
aslan2142:audit-shader4-limit-zero → main · +41 −20 · 2 files · 1 commits · merged 2026-11-25 22:23 UTC

Claimed in the coordination issue as: OLD-7087 #14

Restoration of my original pull request, old upstream PR 7087 in ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bca8c. The one commit cherry-picked cleanly and is unchanged. The tool is still scripts/audit_shader4_regs.py, as it was in the original. Main has no shared helper for checking that a count is positive, so the PR keeps its own shader_count type function, written like the byte_count in tools/anim_index.py.

What and why

  • On main, --limit 0 passes the non-negative check, and files[:0] keeps no listing.
  • The tool then prints === CS (0 shaders; ...) === for every stage and exits 0. A typo gives an empty audit that looks real.
  • --limit now takes a shader_count type: a value below 1 or a non-number is an argparse error that names the option, with exit 2 and no report or JSON written.
  • audit() raises ValueError for a limit below 1, so callers that bypass the command line get the same check.
  • No limit (the default None) still audits everything.

Tested

Linux, Python 3.14.10, CPU only, synthetic inputs (hand-written .s listings in temporary folders, no game files).

  • python -I tests/test_audit_shader4_regs.py: 20 tests, OK. On main the same 20 pass, but with this PR's test changes 5 subtests fail (--limit 0, -1 and x; audit() with 0 and -1).
  • New cases: --limit 0, -1 and x exit 2 with nothing on stdout and no JSON. --limit 1 on a folder with two listings audits one. --limit 2 and --limit 3 audit both.
  • The JSON-refusal test used --limit 0 to leave the listing out. It now adds a second listing that sorts first and uses --limit 1.
  • python -m compileall -q tools tests scripts, git diff --check and python -I scripts/check_no_game_data.py on the two changed files: all clean.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 12:40 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/713) `aslan2142:audit-shader4-limit-zero` → `main` · +41 −20 · 2 files · 1 commits · merged 2026-11-25 22:23 UTC Claimed in the coordination issue as: OLD-7087 https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 Restoration of my original pull request, old upstream PR 7087 in `ItsNotRexed/Leonida`, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bca8c675c62f9dbffc318ce6a59d57faf31. The one commit cherry-picked cleanly and is unchanged. The tool is still `scripts/audit_shader4_regs.py`, as it was in the original. Main has no shared helper for checking that a count is positive, so the PR keeps its own `shader_count` type function, written like the `byte_count` in `tools/anim_index.py`. ### What and why - On main, `--limit 0` passes the non-negative check, and `files[:0]` keeps no listing. - The tool then prints `=== CS (0 shaders; ...) ===` for every stage and exits 0. A typo gives an empty audit that looks real. - `--limit` now takes a `shader_count` type: a value below 1 or a non-number is an argparse error that names the option, with exit 2 and no report or JSON written. - `audit()` raises `ValueError` for a limit below 1, so callers that bypass the command line get the same check. - No limit (the default `None`) still audits everything. ### Tested Linux, Python 3.14.10, CPU only, synthetic inputs (hand-written `.s` listings in temporary folders, no game files). - `python -I tests/test_audit_shader4_regs.py`: 20 tests, OK. On main the same 20 pass, but with this PR's test changes 5 subtests fail (`--limit 0`, `-1` and `x`; `audit()` with 0 and -1). - New cases: `--limit 0`, `-1` and `x` exit 2 with nothing on stdout and no JSON. `--limit 1` on a folder with two listings audits one. `--limit 2` and `--limit 3` audit both. - The JSON-refusal test used `--limit 0` to leave the listing out. It now adds a second listing that sorts first and uses `--limit 1`. - `python -m compileall -q tools tests scripts`, `git diff --check` and `python -I scripts/check_no_game_data.py` on the two changed files: all clean. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) AI-assisted (Claude Code, Claude Opus 5.5).
`--limit 0` passed the non-negative check, `files[:0]` kept no listing, and the
tool printed `=== CS (0 shaders; ...) ===` for every stage with exit 0: a typo
gave a plausible empty audit. 0 is distinguishable from no limit (the default
is None), so it is now an argparse error naming the option, exit 2, the same
type function and wording as `anim_index`'s `byte_count`. A negative value and
a non-number are rejected the same way; `audit()` raises ValueError below 1.

Tests: `--limit 0`, `-1` and `x` exit 2 with no report and no JSON;
`--limit 1` on a two-listing folder audits one. The JSON-refusal test that
used `--limit 0` to exclude the listing now uses a second listing and
`--limit 1`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:17:34 +00:00
github manually merged commit 165402ddeb into gh-pr/713/base 2026-11-26 09:17:36 +00:00
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-24 12:42 UTC · original

Ran 165402dde on Apple M5 Pro, macOS 26.7.3 (25G342), Python 3.15.2, against main d42773d07:

  • tests/test_audit_shader4_regs.py: 20 tests OK at this head.
  • The same file against main's scripts/audit_shader4_regs.py fails 5 of 20, so the --limit behaviour is actually covered by the new tests.

No GPU leg (the tool is CPU-only). AI-assisted.

**@⁠GeorgiyDemo** on GitHub · 2026-11-24 12:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/713#issuecomment-7131806993) Ran `165402dde` on Apple M5 Pro, macOS 26.7.3 (25G342), Python 3.15.2, against `main` `d42773d07`: - `tests/test_audit_shader4_regs.py`: 20 tests OK at this head. - The same file against `main`'s `scripts/audit_shader4_regs.py` fails 5 of 20, so the `--limit` behaviour is actually covered by the new tests. No GPU leg (the tool is CPU-only). AI-assisted.
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 12:44 UTC · original · approved these changes

Reviewed and verified OLD-7087 restoration. Enforcing --limit\ must be at least 1 via \shader_count\ argument type prevents empty audits from outputting misleading zero reports. Comprehensive standard-library test coverage in \ ests/test_audit_shader4_regs.py\ validates argument parsing, programmatic \udit()\ bounds checks, and JSON output behavior. Approved.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 12:44 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/713#pullrequestreview-6039401384) · **approved these changes** Reviewed and verified OLD-7087 restoration. Enforcing \--limit\ must be at least 1 via \shader_count\ argument type prevents empty audits from outputting misleading zero reports. Comprehensive standard-library test coverage in \ ests/test_audit_shader4_regs.py\ validates argument parsing, programmatic \udit()\ bounds checks, and JSON output behavior. Approved.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 22:23 UTC · original

Merged: audit_shader4_regs: --limit must be at least 1.

  • Changed since review: Nothing. It merges cleanly with main, and no review point is open.
  • Tested: tests/test_audit_shader4_regs.py passes on main + this head (Linux, CPython 3.14).
  • Checked on main 7359f21b2 + 165402dde: the semantic suite passes (492 files, 6,315 tests, 0 files failed); test_audit_shader4_regs pass; the 15 docs and writer tests pass; check_no_game_data.py is clean on the 2 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 22:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/713#issuecomment-7176304253) Merged: `audit_shader4_regs`: `--limit` must be at least 1. - **Changed since review:** Nothing. It merges cleanly with `main`, and no review point is open. - **Tested:** `tests/test_audit_shader4_regs.py` passes on `main` + this head (Linux, CPython 3.14). - **Checked on `main` `7359f21b2` + `165402dde`:** the semantic suite passes (492 files, 6,315 tests, 0 files failed); `test_audit_shader4_regs` pass; the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 2 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.