Skip to content

shader_library: reject an unknown --stages name instead of writing nothing - #8728

Open
MarchalMaxim wants to merge 2 commits into
ItsNotRexed:mainfrom
MarchalMaxim:shader-library-unknown-stages
Open

MarchalMaxim wants to merge 2 commits into
ItsNotRexed:mainfrom
MarchalMaxim:shader-library-unknown-stages

Conversation

@MarchalMaxim

Copy link
Copy Markdown

Claimed in the coordination issue as: a new item, claim

What and why

tools/shader_library.py split --stages on commas with no validation and kept a program only if its stages intersected that set. --stages px wrote 0 programs and exited 0 ("4 programs; 0 written"), and --stages "cs, ps" wrote only the cs program because the second token was " ps".

Each token is now stripped and checked against the names the tool can produce: cs, plus SLOTS.get(slot, f"slot{slot}") for the 7 graphics slots (ps, vs, ms, slot3 to slot6). An unknown or empty name is a parser error (exit 2) before the input is opened or a folder is created: --stages: unknown stage 'px' (give 'all' alone, or some of cs,ms,ps,slot3,slot4,slot5,slot6,vs).

Behaviour notes: all (surrounding spaces ignored) still writes every program, including unused ones. all combined with other names (all,cs) is a usage error. unused is rejected; it could never match a program under the old filter either. --stages is now checked even when only --save is given, where an invalid value used to be ignored.

Tested

Windows 11, CPython 3.11.9, CPU only, no game files or GPU. Every input is built by hand in the test.

  • python -I tests/test_shader_library.py: with the new tests on unmodified code (clean worktree of main, only the test file copied in), 12 tests, 1 failure and 5 errors; with the fix, all tests in the file pass.
  • python -I tests/test_text_write_line_endings.py fails here on tools/leonida_tui.py:753 and tools/wave_diff.py:373, the same on unmodified main; this branch touches neither.
  • python -I -m compileall -q and python -I scripts/check_no_game_data.py on both changed files: exit 0.

Other open PRs near this code: #8201 (--save paths that overlap extraction outputs), #6478 and #5787 (input checks) edit the same part of main(); none of them validates --stages. Expect a small textual conflict with whichever lands first. The new usage-error test uses a missing input file on purpose, to show the check runs before the input is opened.

AI-assisted: yes (Claude Code; the fix was written by one agent and re-verified red/green by a second, independent one)

Checklist

  • 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. (Not applicable: no translator rule.)

🤖 Generated with Claude Code

MarchalMaxim and others added 2 commits November 23, 2026 20:14
…thing

--stages was split on commas with no check: a typo such as "--stages px"
wrote zero programs and exited 0, and "--stages \"cs, ps\"" silently
dropped ps because the token was " ps".

Each token is now stripped and checked against the stage names the tool
gives (cs, ps, vs, ms, slot6 and the slotN fallback for slots 3-5). An
unknown or empty name is a usage error (exit 2) before the input is read
or the output folder is made. "all" works as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous commit strips each --stages token but compared the whole
value with "all" unstripped, so " all" was refused as "unknown stage
'all' (give 'all' or ...)", and "all,cs" got the same self-contradicting
message. Strip before the "all" check and say 'all' is given alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant