SHADER-INDEX-RECOVERY: rebuild damaged translation indexes from shards #494

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

@⁠bobcatchris on GitHub · 2026-11-24 06:21 UTC · original
bobcatchris:shader-index-recovery → main · +159 −53 · 6 files · 1 commits · open

Claimed in the coordination issue as: SHADER-INDEX-RECOVERY

What and why

A truncated or malformed shaders/spirv/index.json could let the shaders stage report success while the pipeline stage later rejected the same file and asked for another full translation. This treats a readable but malformed index as recoverable from the already completed shards, keeps a UTF-8 BOM index reusable, and still rejects a genuine empty merge. It also halves jobs correctly when shaders and assets overlap during free-space preflight.

Carried from the source patch in Sigtryggur-Mani-Gudmundsson's graphics-runtime-patches collection:
github.com/Sigtryggur-Mani-Gudmundsson/graphics-runtime-patches@33ab48d3ea/README.md (recovering-a-damaged-shader-index)

No game data, keys, or decryption are included.

Tested

  • python -I tests/test_make_game_argparse.py — 38 tests OK
  • python -I tests/test_make_game_empty_translation.py — 20 tests OK
  • python -I tests/test_make_game_preflight.py — 98 tests OK, 1 skipped
  • python -I tests/test_make_game_translator_flags.py — 33 tests OK
  • python -I tests/test_shader_stage_resume.py — 46 tests OK
  • baseline source + patched tests fails the new damaged-index cases (6 failures, 2 errors); patched source passes
  • python -I tests/test_docs_links.py — 16 tests OK
  • python -I tests/test_docs_cli_flags.py — 4 tests OK
  • python -I tests/test_ci_registration.py — 15 tests OK
  • python -m compileall -q make_game.py tools tests — OK
  • git diff --check clean
  • security sweep of the diff: 0 hits

The source report rebuilt a truncated merged index from two synthetic pixel shards with matching original bytes. I reproduced the regression locally with the new tests; no game files were involved.

GPUs tested: n/a (CPU-only pipeline/tooling change)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.
  • Regression tests added for damaged, BOM, non-object, locked-index and real-shard cases.
**@⁠bobcatchris** on GitHub · 2026-11-24 06:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/494) `bobcatchris:shader-index-recovery` → `main` · +159 −53 · 6 files · 1 commits · open Claimed in the coordination issue as: SHADER-INDEX-RECOVERY ### What and why A truncated or malformed `shaders/spirv/index.json` could let the shaders stage report success while the pipeline stage later rejected the same file and asked for another full translation. This treats a readable but malformed index as recoverable from the already completed shards, keeps a UTF-8 BOM index reusable, and still rejects a genuine empty merge. It also halves jobs correctly when shaders and assets overlap during free-space preflight. Carried from the source patch in Sigtryggur-Mani-Gudmundsson's graphics-runtime-patches collection: https://github.com/Sigtryggur-Mani-Gudmundsson/graphics-runtime-patches/blob/33ab48d3ea90f9925351aeee8708181a71fb9634/README.md#recovering-a-damaged-shader-index No game data, keys, or decryption are included. ### Tested - `python -I tests/test_make_game_argparse.py` — 38 tests OK - `python -I tests/test_make_game_empty_translation.py` — 20 tests OK - `python -I tests/test_make_game_preflight.py` — 98 tests OK, 1 skipped - `python -I tests/test_make_game_translator_flags.py` — 33 tests OK - `python -I tests/test_shader_stage_resume.py` — 46 tests OK - baseline source + patched tests fails the new damaged-index cases (6 failures, 2 errors); patched source passes - `python -I tests/test_docs_links.py` — 16 tests OK - `python -I tests/test_docs_cli_flags.py` — 4 tests OK - `python -I tests/test_ci_registration.py` — 15 tests OK - `python -m compileall -q make_game.py tools tests` — OK - `git diff --check` clean - security sweep of the diff: 0 hits The source report rebuilt a truncated merged index from two synthetic pixel shards with matching original bytes. I reproduced the regression locally with the new tests; no game files were involved. GPUs tested: n/a (CPU-only pipeline/tooling change) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. - [x] Regression tests added for damaged, BOM, non-object, locked-index and real-shard cases.
A truncated or malformed shaders/spirv/index.json could let the shaders stage report success and then leave the pipeline stage asking for another full translation. Treat a readable but malformed index as recoverable from completed shards, keep accepting a UTF-8 BOM index, and still reject a real empty merge. Also account for shaders/assets overlap in preflight free-space checks when both stages run.

Carried from the source patch in Sigtryggur-Mani-Gudmundsson's graphics-runtime-patches collection:
33ab48d3ea/README.md (recovering-a-damaged-shader-index)

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:04:02 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-24 21:53 UTC · original

Reviewed 43f73d7: ran the five touched test files in a no-network sandbox on the PR and on main (all OK on the PR, including the real two-shard re-merge under SPIRV-Tools), plus adjacent tests and compileall. Reproduced the fix with a synthetic work folder: on current main a truncated spirv/index.json still passes shader_outputs_reusable(), skips translation, leaves the index damaged, and fails in native_pso_hashes (with pipelines also refusing it; silent "shaders: done" only occurs on the PR's base or with a newer native_hashes.txt), whereas with the PR the stage rebuilds it from the completed shards (merge only, "keeping 2 of 2 shards") and restores it byte-identically. Two items: the branch conflicts with current main in tests/test_make_game_translator_flags.py and tests/test_shader_stage_resume.py, and after merging main's new native_pso_hashes step (tools/native_pso_hashes.py:48) reads spirv/index.json with strict utf-8, so the PR's own test_utf8_bom_index_remains_reusable fails on the merged tree. Please rebase and switch that reader to utf-8-sig too. AI-assisted review.

Recommendation: Fix first

**@⁠PierreEbele** on GitHub · 2026-11-24 21:53 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/494#issuecomment-7145526439) Reviewed 43f73d7: ran the five touched test files in a no-network sandbox on the PR and on main (all OK on the PR, including the real two-shard re-merge under SPIRV-Tools), plus adjacent tests and `compileall`. Reproduced the fix with a synthetic work folder: on current main a truncated `spirv/index.json` still passes `shader_outputs_reusable()`, skips translation, leaves the index damaged, and fails in `native_pso_hashes` (with `pipelines` also refusing it; silent `"shaders: done"` only occurs on the PR's base or with a newer `native_hashes.txt`), whereas with the PR the stage rebuilds it from the completed shards (merge only, `"keeping 2 of 2 shards"`) and restores it byte-identically. Two items: the branch conflicts with current main in `tests/test_make_game_translator_flags.py` and `tests/test_shader_stage_resume.py`, and after merging main's new `native_pso_hashes` step (`tools/native_pso_hashes.py:48`) reads `spirv/index.json` with strict `utf-8`, so the PR's own `test_utf8_bom_index_remains_reusable` fails on the merged tree. Please rebase and switch that reader to `utf-8-sig` too. AI-assisted review. **Recommendation:** Fix first
Author
Owner

@⁠bobcatchris on GitHub · 2026-11-24 23:42 UTC · original

Rebased on current main; resolved newer shader-stage/native-PSO integration conflicts and made native_pso_hashes accept UTF-8 BOM indexes. Verified: 442 make_game tests, 47 shader-stage resume tests, 10 native-PSO tests, no-game-data and security checks clean.

**@⁠bobcatchris** on GitHub · 2026-11-24 23:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/494#issuecomment-7147710287) Rebased on current main; resolved newer shader-stage/native-PSO integration conflicts and made native_pso_hashes accept UTF-8 BOM indexes. Verified: 442 make_game tests, 47 shader-stage resume tests, 10 native-PSO tests, no-game-data and security checks clean.
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 00:07 UTC · original

Follow-up on 8a5be5ce: both items from the previous review are fixed. The branch merges cleanly into current main, and tools/native_pso_hashes.py:48 now reads spirv/index.json as utf-8-sig. In a no-network sandbox (Linux, with SPIRV-Tools) on the PR merged with main, these all pass: test_make_game_empty_translation 20/20 (including test_utf8_bom_index_remains_reusable and the real two-shard re-merge), test_native_pso_hashes 10/10, test_make_game_preflight 98, test_make_game_argparse 38, test_make_game_translator_flags 33 and test_shader_stage_resume 47. The last two are no longer touched by the PR and still pass. check_no_game_data is clean. With the PR's test_make_game_empty_translation.py dropped onto current main, 6 failures and 3 errors show up, so the tests do cover the change. AI-assisted review.

Recommendation: Merge

**@⁠PierreEbele** on GitHub · 2026-11-25 00:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/494#issuecomment-7148169717) Follow-up on 8a5be5ce: both items from the previous review are fixed. The branch merges cleanly into current main, and `tools/native_pso_hashes.py:48` now reads `spirv/index.json` as `utf-8-sig`. In a no-network sandbox (Linux, with SPIRV-Tools) on the PR merged with main, these all pass: `test_make_game_empty_translation` 20/20 (including `test_utf8_bom_index_remains_reusable` and the real two-shard re-merge), `test_native_pso_hashes` 10/10, `test_make_game_preflight` 98, `test_make_game_argparse` 38, `test_make_game_translator_flags` 33 and `test_shader_stage_resume` 47. The last two are no longer touched by the PR and still pass. `check_no_game_data` is clean. With the PR's `test_make_game_empty_translation.py` dropped onto current main, 6 failures and 3 errors show up, so the tests do cover the change. AI-assisted review. **Recommendation:** Merge
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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