Skip to content

rdna2spirv.py: check --limit and --shard before translating anything - #591

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
BBareth:fix/rdna2spirv-limit-shard-args
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
BBareth:fix/rdna2spirv-limit-shard-args

Conversation

@BBareth

@BBareth BBareth commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Claim: #374 (comment) (new item, CLI only)

Bug. AGENTS.md tells contributors to check a translator change with --limit 200 and --shard 0/8. Neither value was checked:

Value What happened
--limit 0 files[: a.limit] if a.limit else files read 0 as "no limit" and translated the whole corpus, the longest step of the build.
--limit -5 Silently dropped the last 5 shaders.
--shard 0/0 ValueError: slice step cannot be zero traceback.
--shard 9/8 Translated nothing, exited 0, and wrote an empty index.part9.json into --out. --merge then picks it up.
--shard a/b, --shard 0 Tracebacks.

Fix. Two small argparse types:

  • --limit must be at least 1.
  • --shard must be i/n with n >= 1 and 0 <= i < n.

A bad value is a usage error (exit 2) before --out is created. The slice test becomes is not None. The translation code is untouched, and every --shard i/{jobs} that make_game.py passes is valid.

Tested. New tests/test_rdna2spirv_cli.py, standard library only, needing no llvm-mc or SPIRV-Tools:

  • Both types on good and bad values.
  • The CLI with --limit 0, --limit -5, --shard 0/0, --shard 9/8 and --shard a/b. Each must exit 2 with no traceback and leave no --out folder. Against main's tool all five CLI cases fail. On main, --shard 9/8 exits 0 and writes index.part9.json.

Results:

AI-assisted (Claude Code).

Checklist

  • No game data, keys or decryption, including in logs or reports.
  • Not a translator rule (command-line checks only), so there's no contract-table row.

🤖 Generated with Claude Code

`files[: a.limit] if a.limit else files` read --limit 0 as "no limit"
and translated the whole corpus, and a negative --limit dropped the
last shaders instead of being refused. --shard was split and used
unchecked: 0/0 ended in "slice step cannot be zero", 9/8 translated
nothing and wrote an empty index.part9.json that --merge then reads,
and anything that isn't i/n was a traceback.

Both are now argparse types: --limit must be at least 1, and --shard
must be i/n with n >= 1 and 0 <= i < n. A bad value is a usage error
(exit 2) before --out is created. The translation itself is unchanged,
and make_game.py's own "--shard i/jobs" values are all valid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@IAmNotSiob IAmNotSiob left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_shard_arg catches 0/0, 3/2, 1 and a/b/c (the unpack raises ValueError), and --limit 0 is now an error instead of quietly meaning the whole corpus. tests/test_rdna2spirv_cli.py passes after merging with main. LGTM. AI-assisted review (Claude Code).

@ItsNotRexed
ItsNotRexed merged commit 905b6af into ItsNotRexed:main Nov 22, 2026
5 of 9 checks passed
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.

3 participants