translate_pipeline_compute: harden index parsing, published .spv mode, and worker cleanup #1686

Open
github-bot wants to merge 1 commit from github-bot/gh-1686 into main AGit
Owner

@⁠IlyassRS3 on GitHub · 2026-11-25 08:10 UTC · original
IlyassRS3:fix/translate-pipeline-compute-io-and-worker → main · +191 −27 · 2 files · 1 commits · open

Item ID: TRANSLATE-PIPELINE-COMPUTE-IO-AND-WORKER (claimed in #1608)

Summary

  • Input index validation (scripts/translate_pipeline_compute.py):
    • Extracted load_compute_names(index_path) supporting UTF-8 BOM (utf-8-sig), validating JSON list/dict structure and stage/file types, rejecting empty-stem ".dxbc" filenames and path separators (/ and \), and reporting errors via ap.error() instead of raw tracebacks.
    • Validate tools and index.json before mutating process priority (os.setpriority) or RLIMIT_AS (resource.setrlimit), and accept argv=None in main().
    • Include args.compact_spirv explicitly in cache settings.
  • Published .spv permissions & cache directory creation:
    • Ensure out / ".compute-cache" is created with parents=True, exist_ok=True in both build_one() and build().
    • Apply file_mode.published_mode() before replacing published .spv files so they do not inherit 0o600 permissions from tempfile.TemporaryDirectory.
  • Forked worker lifecycle in build():
    • When the parent worker raises an exception (including KeyboardInterrupt), send SIGTERM to the forked child before os.waitpid(pid, 0) and do not raise "second translation worker failed" inside finally, preventing the child's exit status from masking the parent exception.
  • Cross-platform POSIX unit tests (tests/test_translate_pipeline_compute.py):
    • Added ComputePipelineUnitTests (runs on macOS & Linux without requiring spirv-as/spirv-val) covering BOM & malformed index.json, build_one() cache creation + published_mode, parent-exception preservation + SIGTERM/waitpid cleanup vs child-only failure, and upfront validation before setrlimit/setpriority.

Checklist & Verification

  • AI-assisted: yes
  • Game data included: none (python3 -I scripts/check_no_game_data.py scripts/translate_pipeline_compute.py tests/test_translate_pipeline_compute.py passed)
  • GPUs tested: none (hostless macOS POSIX unit test run; Linux SPIRV-Tools integration test skipped cleanly)
  • Tests run:
    • python3 -W error -I tests/test_translate_pipeline_compute.py -v: Ran 5 tests ... OK (skipped=1)
    • Mutation test (ComputePipelineUnitTests against unpatched main scripts/translate_pipeline_compute.py): Ran 4 tests ... FAILED (errors=4)
    • python3 -m compileall -q make_game.py tools tests scripts: passed
    • python3 -I tests/test_text_write_line_endings.py: Ran 3 tests ... OK
**@⁠IlyassRS3** on GitHub · 2026-11-25 08:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1686) `IlyassRS3:fix/translate-pipeline-compute-io-and-worker` → `main` · +191 −27 · 2 files · 1 commits · open Item ID: `TRANSLATE-PIPELINE-COMPUTE-IO-AND-WORKER` (claimed in https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ## Summary - **Input index validation (`scripts/translate_pipeline_compute.py`)**: - Extracted `load_compute_names(index_path)` supporting UTF-8 BOM (`utf-8-sig`), validating JSON list/dict structure and `stage`/`file` types, rejecting empty-stem `".dxbc"` filenames and path separators (`/` and `\`), and reporting errors via `ap.error()` instead of raw tracebacks. - Validate tools and `index.json` before mutating process priority (`os.setpriority`) or `RLIMIT_AS` (`resource.setrlimit`), and accept `argv=None` in `main()`. - Include `args.compact_spirv` explicitly in cache `settings`. - **Published `.spv` permissions & cache directory creation**: - Ensure `out / ".compute-cache"` is created with `parents=True, exist_ok=True` in both `build_one()` and `build()`. - Apply `file_mode.published_mode()` before replacing published `.spv` files so they do not inherit `0o600` permissions from `tempfile.TemporaryDirectory`. - **Forked worker lifecycle in `build()`**: - When the parent worker raises an exception (including `KeyboardInterrupt`), send `SIGTERM` to the forked child before `os.waitpid(pid, 0)` and do not raise `"second translation worker failed"` inside `finally`, preventing the child's exit status from masking the parent exception. - **Cross-platform POSIX unit tests (`tests/test_translate_pipeline_compute.py`)**: - Added `ComputePipelineUnitTests` (runs on macOS & Linux without requiring `spirv-as`/`spirv-val`) covering BOM & malformed `index.json`, `build_one()` cache creation + `published_mode`, parent-exception preservation + `SIGTERM`/`waitpid` cleanup vs child-only failure, and upfront validation before `setrlimit`/`setpriority`. ## Checklist & Verification - **AI-assisted**: yes - **Game data included**: none (`python3 -I scripts/check_no_game_data.py scripts/translate_pipeline_compute.py tests/test_translate_pipeline_compute.py` passed) - **GPUs tested**: none (hostless macOS POSIX unit test run; Linux SPIRV-Tools integration test skipped cleanly) - **Tests run**: - `python3 -W error -I tests/test_translate_pipeline_compute.py -v`: `Ran 5 tests ... OK (skipped=1)` - Mutation test (`ComputePipelineUnitTests` against unpatched `main` `scripts/translate_pipeline_compute.py`): `Ran 4 tests ... FAILED (errors=4)` - `python3 -m compileall -q make_game.py tools tests scripts`: passed - `python3 -I tests/test_text_write_line_endings.py`: `Ran 3 tests ... OK`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:00:49 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 08:11 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 08:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1686#pullrequestreview-6053933664) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
This pull request has changes conflicting with the target branch.
  • scripts/translate_pipeline_compute.py
  • tests/test_translate_pipeline_compute.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1686/head:github-bot/gh-1686'
git switch 'github-bot/gh-1686'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1686'
git switch 'github-bot/gh-1686'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1686'
git switch 'github-bot/gh-1686'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1686'
git switch 'main'
git merge --squash 'github-bot/gh-1686'
git switch 'main'
git merge --ff-only 'github-bot/gh-1686'
git switch 'main'
git merge 'github-bot/gh-1686'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.