make_game: rebuild empty compute shader modules on resume #1235

Merged
titoreinaldo merged 1 commit from upstream-pr/1235 into main 2026-11-29 19:00:44 +00:00
titoreinaldo commented 2026-11-24 20:40:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by titoreinaldo on 2026-11-24T20:40:42Z.


Claimed in the coordination issue as: BUILD-EMPTY-SPV-CACHE
Claim in #14

What and why

Both the FSPX and pipeline-library stages accepted a zero-byte .spv if its filename, index and settings marker were still present. Rerunning the shaders step skipped the rebuild and left an unusable module for the runtime. The shared cache check now requires every indexed module to be a nonempty regular file. It uses one stat per entry.

Tested

  • Before the change the two stage regressions both failed for an empty module. After the change both rebuild it, check the restored bytes, and reuse the repaired cache on the next run.
  • python -m pytest -q tests/test_fspx_shaders_stage.py tests/test_library_shaders_stage.py — 41 passed, plus 21 subtests passed.
  • Repeated the failure with each stage’s synthetic input builder and the real LLVM disassembler, translator and SPIR-V tools. Truncating the FSPX module (4,040 bytes) and pipeline-library module (4,192 bytes) regenerated the exact original bytes. Both passed spirv-val --target-env vulkan1.2, and the third invocation preserved each module’s modification time.
  • python -I make_game.py --help and python -m compileall -q make_game.py tools tests passed. The shared base 58be9cdf ran 6,168 translator tests in 470 files with zero failing files. Verified a clean merge with main at 705ea091.

GPUs tested: CPU-only build and recovery on Windows 11 Pro 26H2 build 26300.9974, Python 3.12.14.

AI-assisted: yes, OpenAI Codex. All inputs were synthetic.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5479973133 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1235). Originally posted by [titoreinaldo](https://github.com/titoreinaldo) on 2026-11-24T20:40:42Z. --- Claimed in the coordination issue as: BUILD-EMPTY-SPV-CACHE [Claim in #14](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143476751) ### What and why Both the FSPX and pipeline-library stages accepted a zero-byte `.spv` if its filename, index and settings marker were still present. Rerunning the shaders step skipped the rebuild and left an unusable module for the runtime. The shared cache check now requires every indexed module to be a nonempty regular file. It uses one stat per entry. ### Tested - Before the change the two stage regressions both failed for an empty module. After the change both rebuild it, check the restored bytes, and reuse the repaired cache on the next run. - `python -m pytest -q tests/test_fspx_shaders_stage.py tests/test_library_shaders_stage.py` — 41 passed, plus 21 subtests passed. - Repeated the failure with each stage’s synthetic input builder and the real LLVM disassembler, translator and SPIR-V tools. Truncating the FSPX module (4,040 bytes) and pipeline-library module (4,192 bytes) regenerated the exact original bytes. Both passed `spirv-val --target-env vulkan1.2`, and the third invocation preserved each module’s modification time. - `python -I make_game.py --help` and `python -m compileall -q make_game.py tools tests` passed. The shared base `58be9cdf` ran 6,168 translator tests in 470 files with zero failing files. Verified a clean merge with `main` at `705ea091`. GPUs tested: CPU-only build and recovery on Windows 11 Pro 26H2 build 26300.9974, Python 3.12.14. AI-assisted: yes, OpenAI Codex. All inputs were synthetic.
xel1uz commented 2026-11-24 20:48:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by xel1uz on 2026-11-24T20:48:12Z.

Review: APPROVED


Reviewed the shared cache check and both callers. I ran the PR tests against upstream 66d4f5aa first: truncating the cached module to zero bytes made both stages reuse the empty file. On a clean trial merge of bb68bb93 into that same base, both stages rebuilt the module, restored the expected bytes, and reused it on the next run.

On Ubuntu 26.04.1, python3 -I -B tests/test_fspx_shaders_stage.py -v passed 24/24 and python3 -I -B tests/test_library_shaders_stage.py -v passed 17/17, including the real SPIR-V tools case. The changed-file game-data check passed. Synthetic inputs, CPU only. AI-assisted review.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6047148857 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1235#pullrequestreview-6047148857). Originally posted by [xel1uz](https://github.com/xel1uz) on 2026-11-24T20:48:12Z. **Review:** APPROVED --- Reviewed the shared cache check and both callers. I ran the PR tests against upstream `66d4f5aa` first: truncating the cached module to zero bytes made both stages reuse the empty file. On a clean trial merge of `bb68bb93` into that same base, both stages rebuilt the module, restored the expected bytes, and reused it on the next run. On Ubuntu 26.04.1, `python3 -I -B tests/test_fspx_shaders_stage.py -v` passed 24/24 and `python3 -I -B tests/test_library_shaders_stage.py -v` passed 17/17, including the real SPIR-V tools case. The changed-file game-data check passed. Synthetic inputs, CPU only. AI-assisted review.
DadaCap commented 2026-11-28 07:21:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T07:21:00Z.


Thanks for this! Treating a zero-length or non-regular cached compute .spv as missing on resume is a good catch.

During maintainer testing (local, 2026-11-28) (head bb68bb93a, merged on main b1619e0a3 / 6dfca6428, Windows 11, Python tests via pytest/unittest) we found:

  • tests/test_bvh_shaders_stage and tests/test_exe_shaders_stage fail with this PR alone on main: fspx_unpack.py and rdna2spirv.py rerun when only an unrelated DLL or the executable changed.

To get this merged:

  • Limit the empty-module rebuild so an unchanged translator does not rerun the FSPX and translate steps.
  • Run both stage tests before pushing.

AI-assisted (Claude Code), posted for DadaCap (maintainer).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7235876801 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1235#issuecomment-7235876801). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T07:21:00Z. --- Thanks for this! Treating a zero-length or non-regular cached compute `.spv` as missing on resume is a good catch. During maintainer testing (local, 2026-11-28) (head bb68bb93a, merged on main b1619e0a3 / 6dfca6428, Windows 11, Python tests via pytest/unittest) we found: - `tests/test_bvh_shaders_stage` and `tests/test_exe_shaders_stage` fail with this PR alone on main: `fspx_unpack.py` and `rdna2spirv.py` rerun when only an unrelated DLL or the executable changed. To get this merged: - Limit the empty-module rebuild so an unchanged translator does not rerun the FSPX and translate steps. - Run both stage tests before pushing. _AI-assisted (Claude Code), posted for DadaCap (maintainer)._
zmasi commented 2026-11-29 00:46:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T00:46:51Z.


#1235 | head bb68bb93ae (merged cleanly onto origin/main e66c65b950) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Independent Verification (Windows 11)

  • Diff & safety audit: Inspected 100% of the diff across make_game.py, tests/test_fspx_shaders_stage.py, and tests/test_library_shaders_stage.py. python -I scripts/check_no_game_data.py make_game.py tests/test_fspx_shaders_stage.py tests/test_library_shaders_stage.py passed (rc=0).
  • Red -> Green on Windows 11 (origin/main e66c65b950 vs #1235 + origin/main):
    • Red (origin/main): With a valid index.json (stage: "cs" + 64-hex fspx_code_sha256) and a truncated 0-byte u0.spv on disk, make_game.fspx_cache_complete(...) returned True (os.path.isfile(...) accepts empty files).
    • Green (#1235 + origin/main): make_game.fspx_cache_complete(...) checks stat.S_ISREG(module.st_mode) and module.st_size == 0, returning False for 0-byte files and directory collisions and True for non-empty regular .spv modules (matching library_cache_complete on main).
  • Test suites run on Windows 11:
    • python -I tests/test_fspx_shaders_stage.py -> 24/24 passed (OK, including damage="missing" and damage="empty" subtests)
    • python -I tests/test_library_shaders_stage.py -> 17 ran, OK (skipped=1), including damage="missing" and damage="empty" subtests.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248345409 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1235#issuecomment-7248345409). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T00:46:51Z. --- #1235 | head bb68bb93ae5e40b9e4f5b7893cce410e6cfe9b09 (merged cleanly onto origin/main e66c65b950) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes ### Independent Verification (Windows 11) - **Diff & safety audit**: Inspected 100% of the diff across `make_game.py`, `tests/test_fspx_shaders_stage.py`, and `tests/test_library_shaders_stage.py`. `python -I scripts/check_no_game_data.py make_game.py tests/test_fspx_shaders_stage.py tests/test_library_shaders_stage.py` passed (`rc=0`). - **Red -> Green on Windows 11 (`origin/main` `e66c65b950` vs `#1235 + origin/main`)**: - **Red (`origin/main`)**: With a valid `index.json` (`stage: "cs"` + 64-hex `fspx_code_sha256`) and a truncated `0`-byte `u0.spv` on disk, `make_game.fspx_cache_complete(...)` returned `True` (`os.path.isfile(...)` accepts empty files). - **Green (`#1235 + origin/main`)**: `make_game.fspx_cache_complete(...)` checks `stat.S_ISREG(module.st_mode)` and `module.st_size == 0`, returning `False` for `0`-byte files and directory collisions and `True` for non-empty regular `.spv` modules (matching `library_cache_complete` on `main`). - **Test suites run on Windows 11**: - `python -I tests/test_fspx_shaders_stage.py` -> `24/24` passed (`OK`, including `damage="missing"` and `damage="empty"` subtests) - `python -I tests/test_library_shaders_stage.py` -> `17 ran, OK (skipped=1)`, including `damage="missing"` and `damage="empty"` subtests.
TheGeogeo commented 2026-11-29 18:49:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T18:49:56Z.


Tested bb68bb93a merged (no commit) with main 7c330c76d: Python 3.12.4, Windows 11 10.0.26300, CPU only.

  • Green: tests/test_fspx_shaders_stage.py gives 24 tests OK, and tests/test_library_shaders_stage.py gives 17 tests OK.
  • Red: with make_game.py back to main, test_missing_or_empty_cached_module_is_rebuilt (damage='empty') fails in both files: nothing is rebuilt.
  • Base: main's own versions give 24 and 17 tests OK. check_no_game_data.py is clean.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260793857 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1235#issuecomment-7260793857). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T18:49:56Z. --- Tested `bb68bb93a` merged (no commit) with `main` `7c330c76d`: Python 3.12.4, Windows 11 10.0.26300, CPU only. - Green: `tests/test_fspx_shaders_stage.py` gives 24 tests OK, and `tests/test_library_shaders_stage.py` gives 17 tests OK. - Red: with `make_game.py` back to `main`, `test_missing_or_empty_cached_module_is_rebuilt` (`damage='empty'`) fails in both files: nothing is rebuilt. - Base: `main`'s own versions give 24 and 17 tests OK. `check_no_game_data.py` is clean. AI-assisted (Claude Code).
MoonEyes commented 2026-11-29 19:00:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T19:00:41Z.


Merging. Head bb68bb93a has red/green verdicts from reviewers other than the author (above), merges cleanly with main cf6e55921, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (translator-tests mesh, semantic-tests f16) are pre-existing. Merged by MoonEyes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260934326 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1235#issuecomment-7260934326). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T19:00:41Z. --- Merging. Head `bb68bb93a` has red/green verdicts from reviewers other than the author (above), merges cleanly with `main` `cf6e55921`, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (`translator-tests` mesh, `semantic-tests` f16) are pre-existing. Merged by MoonEyes. AI-assisted (Claude Code).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1235
No description provided.