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

Merged
bobcatchris merged 1 commit from upstream-pr/494 into main 2026-11-28 10:56:26 +00:00
bobcatchris commented 2026-11-24 06:21:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-24T06:21:36Z.


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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5467209042 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/494). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-11-24T06:21:36Z. --- 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.
PierreEbele commented 2026-11-24 21:53:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-24T21:53:33Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7145526439 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/494#issuecomment-7145526439). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-24T21:53:33Z. --- 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
bobcatchris commented 2026-11-24 23:42:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-24T23:42:45Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7147710287 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/494#issuecomment-7147710287). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-11-24T23:42:45Z. --- 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.
PierreEbele commented 2026-11-25 00:07:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T00:07:28Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7148169717 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/494#issuecomment-7148169717). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T00:07:28Z. --- 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
DadaCap commented 2026-11-28 07:21:09 +00:00 (Migrated from github.com)

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


Thanks for this! Rebuilding a damaged spirv/index.json from the finished shards, and reading it BOM-tolerant, closes a nasty resume failure.

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

  • Review finding: the new translation_plan() calls translator_digest(), which #452 removes. Once both land this is a NameError, and git may not flag it as a conflict.

To get this merged:

  • Rebase after #452 lands and call translation_sources_digest() instead.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7235878387 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/494#issuecomment-7235878387). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T07:21:09Z. --- Thanks for this! Rebuilding a damaged `spirv/index.json` from the finished shards, and reading it BOM-tolerant, closes a nasty resume failure. During maintainer testing (local, 2026-11-28) (head 8a5be5ce7, merged on main b1619e0a3 / 6dfca6428, Windows 11, Python tests via pytest/unittest) we found: - Review finding: the new `translation_plan()` calls `translator_digest()`, which #452 removes. Once both land this is a NameError, and git may not flag it as a conflict. To get this merged: - Rebase after #452 lands and call `translation_sources_digest()` instead. _AI-assisted (Claude Code), posted for DadaCap (maintainer)._
MoonEyes commented 2026-11-28 10:56:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T10:56:23Z.


Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 23 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238219888 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/494#issuecomment-7238219888). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T10:56:23Z. --- Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18). Targeted batch of 23 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13. AI-assisted (Claude Code, Claude Opus 5.5)
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!494
No description provided.