tools/spirv_stubs.py: preflight stub targets and harden CLI parsing #2280
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2280
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/spirv-stubs-safety"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: SPIRV-STUBS-CLI-RECURSION-AND-TARGET-DIR-GUARD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7191999362)
What and why
<spirv dir>/stubs(not a non-directory file) and every planned<stub>.spvtarget path (not a pre-existing directory) upfront ingenerate_for_index()(tools/spirv_stubs.py) before creating directories or writing any stub so a partial stub set is never emitted on collision.-*) and blank<spirv dir>arguments with clear errors inmain(argv=None).RecursionErroralongside(OSError, ValueError)when callingjson.load()on deeply nestedindex.jsoninputs.tests/test_spirv_stubs.pycovering unknown flags, blank arguments,RecursionErrorhandling, pre-existing target directory collision aborting before writing other stubs, and non-directorystubspath rejection.Tested
python -I tests/test_spirv_stubs.py -v: 19 tests (18 passed, 1 skipped on Windows:test_rebuild_preserves_existing_mode, POSIX-only). Detachedupstream/mainbaseline with the updated test file fails with 4 failures and 3 errors.python -I tests/test_ci_registration.py: 16 passed.python -I tests/test_text_write_line_endings.py: 3 passed.python -I scripts/check_no_game_data.py,python -I -m compileall -q tools/spirv_stubs.py tests/test_spirv_stubs.py, andgit diff --cached --check: passed.GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.
tests/test_spirv_stubs.py: 18 passed, 1 skipped (POSIX file mode), 20 subtests passed (main: 14 passed).(AI-assisted test run; output checked by hand.)
Approving fcedc33eb.
The stubs folder and every stub target are checked before anything is written (a directory where a stub goes is an error up front), and a leading
-or blank folder argument is refused.Merged onto
maind1dff7949in one batch with 15 other tool PRs of this series (no conflicts), on Linux with Python 3.13.tests/test_spirv_stubs.py: 18 passed, 1 skipped (main: 14). AI-assisted (Claude Code, Claude Opus 5.5).Red/green: classified READY by oreo-lot3 (red on main b1619e0a3, green on head merged with main); head fcedc33eb082 unchanged since 2026-11-26, before that run.
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)