make_game: a saved translated index that names a shader not carved here is translated again (BUILD-SHADER-RESUME-IDENTITY) #1372

Merged
Mykolas009 merged 1 commit from upstream-pr/1372 into main 2026-12-01 15:15:22 +00:00
Mykolas009 commented 2026-11-24 22:47:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Mykolas009 on 2026-11-24T22:47:28Z.


Claimed in the coordination issue as: BUILD-SHADER-RESUME-IDENTITY (claim, from sxnistxr's finding).

What and why

On a resumed shader stage, make_game.shaders kept a saved shaders/spirv/index.json that names other shaders than this work folder's, as long as it had the right number of entries: verify_translation_completeness compares only the counts. The build then reports the stage done while the shaders the runtime will ask for were never translated.

Reproduced on main with ShaderStageResumeTest's fixture: after one run, replace the index's only key with an unrelated name; the second run executes no step.

A shader keeps its carved file's stem through unpacking, disassembly and translation (fssm_unpack.py and shader_disasm.py keep the stem, rdna2spirv.py names each entry after its listing), so the stage now compares names:

  • translated_index_strangers(index, carved) returns the names in the translated index that are no carved shader of this folder (nothing when a file is missing, unreadable or malformed: other checks own those cases).
  • On resume, a stranger drops the index and its shard plan, and the translation runs again.
  • After a translation, a stranger fails the stage with the first such name.

tests/test_make_game_empty_translation.py: its fixture carved shader but translated shader_0; it now uses one name, as the real tools do.

Tested

Windows 11, Python 3.14.3, standard library only, no game files, no GPU:

  • python -I tests/test_shader_stage_resume.py: 50 tests, OK. The three new tests fail with make_game.py from main (2 failures, 1 error) and pass with this change.
  • python -I on every tests/test_make_game*.py, tests/test_*shaders_stage*.py and tests/test_text_write_line_endings.py: all OK.
  • python -I scripts/check_no_game_data.py on the three changed files: clean.

Not covered

  • The finding also mentions missing module files. An entry whose <name>.spv is gone is not detected here: the stage fixtures in six test files publish an index without modules, so that check needs them changed first and is left for a separate pull request.
  • No run against a real work folder (no game files here), so the corpus-sized cost of the check is not measured; it is two JSON reads.

GPUs tested: n/a

AI-assisted: yes (Claude Code, Claude Fable 5.2, wrote the change and the tests and ran them; I reviewed it)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5481613297 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1372). Originally posted by [Mykolas009](https://github.com/Mykolas009) on 2026-11-24T22:47:28Z. --- Claimed in the coordination issue as: BUILD-SHADER-RESUME-IDENTITY ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7146036301), from sxnistxr's [finding](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7145787151)). ### What and why On a resumed shader stage, `make_game.shaders` kept a saved `shaders/spirv/index.json` that names other shaders than this work folder's, as long as it had the right number of entries: `verify_translation_completeness` compares only the counts. The build then reports the stage done while the shaders the runtime will ask for were never translated. Reproduced on `main` with `ShaderStageResumeTest`'s fixture: after one run, replace the index's only key with an unrelated name; the second run executes no step. A shader keeps its carved file's stem through unpacking, disassembly and translation (`fssm_unpack.py` and `shader_disasm.py` keep the stem, `rdna2spirv.py` names each entry after its listing), so the stage now compares names: - `translated_index_strangers(index, carved)` returns the names in the translated index that are no carved shader of this folder (nothing when a file is missing, unreadable or malformed: other checks own those cases). - On resume, a stranger drops the index and its shard plan, and the translation runs again. - After a translation, a stranger fails the stage with the first such name. `tests/test_make_game_empty_translation.py`: its fixture carved `shader` but translated `shader_0`; it now uses one name, as the real tools do. ### Tested Windows 11, Python 3.14.3, standard library only, no game files, no GPU: - `python -I tests/test_shader_stage_resume.py`: 50 tests, OK. The three new tests fail with `make_game.py` from `main` (2 failures, 1 error) and pass with this change. - `python -I` on every `tests/test_make_game*.py`, `tests/test_*shaders_stage*.py` and `tests/test_text_write_line_endings.py`: all OK. - `python -I scripts/check_no_game_data.py` on the three changed files: clean. **Not covered** - The finding also mentions missing module files. An entry whose `<name>.spv` is gone is not detected here: the stage fixtures in six test files publish an index without modules, so that check needs them changed first and is left for a separate pull request. - No run against a real work folder (no game files here), so the corpus-sized cost of the check is not measured; it is two JSON reads. GPUs tested: n/a AI-assisted: yes (Claude Code, Claude Fable 5.2, wrote the change and the tests and ran them; I reviewed it) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
PierreEbele commented 2026-11-25 15:11:07 +00:00 (Migrated from github.com)

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


Reviewed 318e76b: traced the naming chain the check relies on (carve file_name, fssm_unpack stem, disasm output_path, rdna2spirv index keys all equal splitext of the carved file name), and disassembly completion already forces listings to be carved stems, so the after-translate failure cannot fire on a clean pipeline. Ran: both touched test files pass (50 + 14 tests); the three new tests each fail on main as they must; 12 further make_game/shader-stage suites pass; a standalone probe reproduces both cases (main resumes a same-size stranger index with no step, and completes silently when translate publishes one; this branch retranslates with the stale shards.json dropped, and exits 1 with "not carved here"). check_no_game_data clean. No blocking findings, only a cosmetic wrap on line 156 of the new test.

AI-assisted review.

Recommendation: Merge

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7166437888 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1372#issuecomment-7166437888). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T15:11:07Z. --- Reviewed 318e76b: traced the naming chain the check relies on (carve `file_name`, fssm_unpack stem, disasm `output_path`, rdna2spirv index keys all equal `splitext` of the carved file name), and disassembly completion already forces listings to be carved stems, so the after-translate failure cannot fire on a clean pipeline. Ran: both touched test files pass (50 + 14 tests); the three new tests each fail on main as they must; 12 further make_game/shader-stage suites pass; a standalone probe reproduces both cases (main resumes a same-size stranger index with no step, and completes silently when translate publishes one; this branch retranslates with the stale shards.json dropped, and exits 1 with "not carved here"). check_no_game_data clean. No blocking findings, only a cosmetic wrap on line 156 of the new test. AI-assisted review. **Recommendation:** Merge
Mykolas009 commented 2026-11-27 23:31:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Mykolas009 on 2026-11-27T23:31:50Z.


Re-tested against current main (d44285197, after the 27 Nov merge of local work), as asked in #contributor-announcements:

  • merges with no conflicts (make_game.py auto-merges; the two test files are untouched on main);
  • with the PR merged: tests/test_make_game_empty_translation.py 14/14 and tests/test_shader_stage_resume.py 50/50 pass, and all 26
    test_make_game* / test_shader_stage* files pass;
  • the PR's new tests still fail on main's make_game.py without the fix (2 failures, 1 error), so they still cover the case.

Run on Windows 11, Python 3.14, each file with python -I <file>. No game files involved. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7230211350 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1372#issuecomment-7230211350). Originally posted by [Mykolas009](https://github.com/Mykolas009) on 2026-11-27T23:31:50Z. --- Re-tested against current main (`d44285197`, after the 27 Nov merge of local work), as asked in #contributor-announcements: - merges with no conflicts (`make_game.py` auto-merges; the two test files are untouched on main); - with the PR merged: `tests/test_make_game_empty_translation.py` 14/14 and `tests/test_shader_stage_resume.py` 50/50 pass, and all 26 `test_make_game*` / `test_shader_stage*` files pass; - the PR's new tests still fail on main's `make_game.py` without the fix (2 failures, 1 error), so they still cover the case. Run on Windows 11, Python 3.14, each file with `python -I <file>`. No game files involved. AI-assisted (Claude Code).
kirigayakazima commented 2026-11-28 04:01:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-28T04:01:57Z.


#1372 | head 318e76bcf0 | python -I tests/test_shader_stage_resume.py & python -I tests/test_make_game_empty_translation.py | red: test_shader_stage_resume Ran 50 tests in 15.629s - FAILED (failures=2, errors=1); test_make_game_empty_translation Ran 14 tests - OK | green: test_shader_stage_resume Ran 50 tests in 16.398s - OK; test_make_game_empty_translation Ran 14 tests in 0.400s - OK | full suite: same as main (514/521 standalone stdlib tests passed, 0 new failures vs main 02f71ccfe7; compileall=0; node viewer_streaming=0) | Windows 11, Python 3.14.7, no game files | AI-assisted: yes, Antigravity (Gemini)

  • Clean merge onto main 02f71ccfe7; scripts/check_no_game_data.py passed (0).
  • On clean main, both end-to-end tests in test_shader_stage_resume.py fail with AssertionError (SystemExit not raised / [] != ['translate']) and the unit helper test fails with AttributeError (translated_index_strangers added by this PR); all 50 pass once merged.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7233616714 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1372#issuecomment-7233616714). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-28T04:01:57Z. --- #1372 | head 318e76bcf09a9723a4fec04f2a2d0886a8d6e491 | python -I tests/test_shader_stage_resume.py & python -I tests/test_make_game_empty_translation.py | red: test_shader_stage_resume Ran 50 tests in 15.629s - FAILED (failures=2, errors=1); test_make_game_empty_translation Ran 14 tests - OK | green: test_shader_stage_resume Ran 50 tests in 16.398s - OK; test_make_game_empty_translation Ran 14 tests in 0.400s - OK | full suite: same as main (514/521 standalone stdlib tests passed, 0 new failures vs main 02f71ccfe7; compileall=0; node viewer_streaming=0) | Windows 11, Python 3.14.7, no game files | AI-assisted: yes, Antigravity (Gemini) - Clean merge onto `main` `02f71ccfe7`; `scripts/check_no_game_data.py` passed (`0`). - On clean `main`, both end-to-end tests in `test_shader_stage_resume.py` fail with `AssertionError` (`SystemExit not raised` / `[] != ['translate']`) and the unit helper test fails with `AttributeError` (`translated_index_strangers` added by this PR); all 50 pass once merged.
DadaCap commented 2026-11-28 07:21:13 +00:00 (Migrated from github.com)

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


Thanks for this! Retranslating when a saved index names shaders not carved in this work folder guards well against reused or copied work folders.

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

  • Review finding: it conflicts with #452 in make_game.py and its test (about 145 lines), so it could not go into our candidate.

To get this merged:

  • Rebase after #452 lands (and after #494 if that one merges first).
  • Use read_translation_index for the index read.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7235879387 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1372#issuecomment-7235879387). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T07:21:13Z. --- Thanks for this! Retranslating when a saved index names shaders not carved in this work folder guards well against reused or copied work folders. During maintainer testing (local, 2026-11-28) (head 318e76bcf, merged on main b1619e0a3 / 6dfca6428, Windows 11, Python tests via pytest/unittest) we found: - Review finding: it conflicts with #452 in `make_game.py` and its test (about 145 lines), so it could not go into our candidate. To get this merged: - Rebase after #452 lands (and after #494 if that one merges first). - Use `read_translation_index` for the index read. _AI-assisted (Claude Code), posted for DadaCap (maintainer)._
Mykolas009 commented 2026-11-29 18:26:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Mykolas009 on 2026-11-29T18:26:52Z.


Rebased on main 4364a4fa6 (after #494 merged) and pushed to my branch; new head 98b219eb28. One commit, the same three files.

  • The saved index is read through read_translation_index, as asked. Main's block from #494 in shaders() is unchanged and the check follows it.
  • #452 has not landed. git merge-tree of this head with #452's head 805d47615: one conflict, in translate() (the plan dict); main with #452 conflicts in the same hunk, and this change adds no other. I will rebase again when #452 lands.
  • Changes since the earlier head 318e76bcf:
    • the carve is read with shader_stems, as the other steps read it (a UTF-8 BOM included; covered by a new test case);
    • after a translation the names are checked before the counts, and a stranger index is removed together with its shard plan, so a later --stages pipelines run does not take the index as finished and the next run does not merge the same parts again;
    • shader_outputs_reusable returns False for a folder whose index names a stranger (the disk-space check);
    • the fixture in tests/test_make_game_empty_translation.py renames the translated side to shader and leaves the carved side as on main; git merge-tree with #2553's head aee75f002 is clean.

Tested on Windows 11, Python 3.14.3, no game files, each file with python -I:

  • tests/test_shader_stage_resume.py 51/51, tests/test_make_game_empty_translation.py 20/20.
  • On plain main 4364a4fa6 with this branch's two test files: test_shader_stage_resume.py has 4 failures and 1 error (the four new or extended tests); test_make_game_empty_translation.py 20/20.
  • All 29 tests/test_make_game*.py and tests/test_shader_stage*.py files: OK (584 tests).
  • scripts/check_no_game_data.py on the three files, tests/test_text_write_line_endings.py, python -m compileall -q make_game.py tools tests: clean.

The test counts in the description above are from the earlier head; the ones here are for 98b219eb28.

GPUs tested: n/a
AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260489660 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1372#issuecomment-7260489660). Originally posted by [Mykolas009](https://github.com/Mykolas009) on 2026-11-29T18:26:52Z. --- Rebased on main 4364a4fa6 (after #494 merged) and pushed to my branch; new head 98b219eb28. One commit, the same three files. - The saved index is read through `read_translation_index`, as asked. Main's block from #494 in `shaders()` is unchanged and the check follows it. - #452 has not landed. `git merge-tree` of this head with #452's head 805d47615: one conflict, in `translate()` (the plan dict); main with #452 conflicts in the same hunk, and this change adds no other. I will rebase again when #452 lands. - Changes since the earlier head 318e76bcf: - the carve is read with `shader_stems`, as the other steps read it (a UTF-8 BOM included; covered by a new test case); - after a translation the names are checked before the counts, and a stranger index is removed together with its shard plan, so a later `--stages pipelines` run does not take the index as finished and the next run does not merge the same parts again; - `shader_outputs_reusable` returns False for a folder whose index names a stranger (the disk-space check); - the fixture in `tests/test_make_game_empty_translation.py` renames the translated side to `shader` and leaves the carved side as on main; `git merge-tree` with #2553's head aee75f002 is clean. Tested on Windows 11, Python 3.14.3, no game files, each file with `python -I`: - `tests/test_shader_stage_resume.py` 51/51, `tests/test_make_game_empty_translation.py` 20/20. - On plain main 4364a4fa6 with this branch's two test files: `test_shader_stage_resume.py` has 4 failures and 1 error (the four new or extended tests); `test_make_game_empty_translation.py` 20/20. - All 29 `tests/test_make_game*.py` and `tests/test_shader_stage*.py` files: OK (584 tests). - `scripts/check_no_game_data.py` on the three files, `tests/test_text_write_line_endings.py`, `python -m compileall -q make_game.py tools tests`: clean. The test counts in the description above are from the earlier head; the ones here are for 98b219eb28. GPUs tested: n/a AI-assisted (Claude Code).
Mykolas009 commented 2026-11-30 22:32:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Mykolas009 on 2026-11-30T22:32:32Z.


@DadaCap, an update, since this has been parked for three days:

  • It no longer conflicts. The sweep of 29 Nov in #2570 still has it under CONFLICT; I rebased it that evening (head 98b219eb28) and re-checked on 30 Nov: git merge main at 407f71a23 gives no conflict, and the change is still these three files.
  • Tests on that main: tests/test_shader_stage_resume.py 51 of 51 with this change, and the same test file on plain main fails (4 failures, 1 error); tests/test_make_game_empty_translation.py 20 of 20. Windows 11, Python 3.14.3, no GPU or game files.
  • #452, which you asked me to wait for, now conflicts with main itself (needs rebase since 28 Nov, no answer from its author). The two overlapped in one hunk of translate(); if it comes back, whichever of us is second takes that rebase.
  • CI has never run on this branch ("no checks reported"). I think the workflows are waiting for a maintainer's approval, since my account has no merged pull request here yet. Could someone approve the run?

AI-assisted (Claude Code, Fable 5.2).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7293982431 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1372#issuecomment-7293982431). Originally posted by [Mykolas009](https://github.com/Mykolas009) on 2026-11-30T22:32:32Z. --- @DadaCap, an update, since this has been parked for three days: - It no longer conflicts. The sweep of 29 Nov in #2570 still has it under CONFLICT; I rebased it that evening (head 98b219eb28) and re-checked on 30 Nov: `git merge main` at 407f71a23 gives no conflict, and the change is still these three files. - Tests on that `main`: `tests/test_shader_stage_resume.py` 51 of 51 with this change, and the same test file on plain `main` fails (4 failures, 1 error); `tests/test_make_game_empty_translation.py` 20 of 20. Windows 11, Python 3.14.3, no GPU or game files. - #452, which you asked me to wait for, now conflicts with `main` itself (`needs rebase` since 28 Nov, no answer from its author). The two overlapped in one hunk of `translate()`; if it comes back, whichever of us is second takes that rebase. - CI has never run on this branch ("no checks reported"). I think the workflows are waiting for a maintainer's approval, since my account has no merged pull request here yet. Could someone approve the run? AI-assisted (Claude Code, Fable 5.2).
aslan2142 commented 2026-12-01 11:41:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:41:02Z.

Review: APPROVED


Reviewed the diff against main: make_game.py:1302-1350,1452-1488 cleanly detects saved or freshly merged spirv/index.json entries not present in the carved dxbc/index.json, drops stale shard plans on mismatch, and updates/adds tests in tests/test_make_game_empty_translation.py and tests/test_shader_stage_resume.py. Clean-room verified. Approving; awaiting a green CI run before merge.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130505881 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1372#pullrequestreview-6130505881). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:41:02Z. **Review:** APPROVED --- Reviewed the diff against `main`: `make_game.py:1302-1350,1452-1488` cleanly detects saved or freshly merged `spirv/index.json` entries not present in the carved `dxbc/index.json`, drops stale shard plans on mismatch, and updates/adds tests in `tests/test_make_game_empty_translation.py` and `tests/test_shader_stage_resume.py`. Clean-room verified. Approving; awaiting a green CI run before merge. *(AI-assisted review.)*
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!1372
No description provided.