Skip to content

make_game: refuse a translation index that lost carved shaders - #4582

Open
abilliontokens wants to merge 6 commits into
ItsNotRexed:mainfrom
abilliontokens:fh-translation-completeness
Open

abilliontokens wants to merge 6 commits into
ItsNotRexed:mainfrom
abilliontokens:fh-translation-completeness

Conversation

@abilliontokens

Copy link
Copy Markdown
Contributor

New BUILD item, claimed in #4257.

What and why

rdna2spirv.py drops a shader that is refused or whose module fails spirv-val (the module never reaches the
final path) and still exits 0, and nothing later in the build compares counts. Measured on a full end-to-end
make_game.py run at aa2988cc (own 1.0.2.1 copy, --wave64-emulate, 6 jobs): 26,503 carved, 26,503
translated, but the merged spirv/index.json held 26,473 — 30 modules had failed spirv-val (the aa2988cc
typed-buffer regression; per-shard deltas 5/5/7/5/1/7) — and the stage printed shaders: done, finished in 124 min, exit 0. A port assembled from that index silently lacks the dropped shaders.

The shaders stage now verifies the merged index against the carve and fails naming the gap, the same way the
disassembly step already refuses an incomplete listing set. Scope kept deliberately narrow:

This PR has no Depends on: but will fail builds loudly until a translator fix like #3902 lands for the current
regression class — intended: the alternative is a port missing shaders with no signal.

Tested

Windows 11, Python 3.12 (python -I), commit 118e3933 on main 03b09a08:

  • tests/test_make_game_translation_completeness.py — 5/5 OK. On unmodified main the same file errors 4/4
    (the function does not exist); the defect itself is the run above: --stages shaders exited 0 at aa2988cc
    with 26,473 of 26,503.
  • Real-work-folder verification: with this change, --stages shaders on the completed run's work folder exits 1
    with the translation index holds 26473 of the 26503 carved shaders (30 were refused or failed spirv-val…).
  • Neighbours: test_make_game_dry_run, test_make_game_resume, test_make_game_translate_cleanup,
    test_make_game_wave64, test_make_game_translator_flags, test_make_game_pipeline_preflight,
    test_make_game_platform, test_make_game_paths, test_make_game_argparse, test_make_game_interrupt,
    test_make_game_destinations, test_make_game_container, test_make_game_pick, test_make_game_submodule,
    test_make_game_assets_decoder, test_make_game_assets_pools, test_make_game_python_version — all OK.
  • python -m compileall -q make_game.py tests/test_make_game_translation_completeness.py.

Checklist

  • No game data, keys or decryption, including in logs or reports (counts and exit codes only).

AI-assisted (omp orchestrator).

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 118e393 on Windows, CPython 3.14.7, CPU only (no GPU, no game files). All files below are synthetic.

The new suite passes 5 of 5 tests, and the existing shader-stage resume suite passes 44 of 44.

One case stays. A stale entry can hide a missing shader: the stage accepts a translation index that has the correct number of entries but the wrong shader name.

python -I -c "import pathlib,runpy; case=runpy.run_path('tests/test_shader_stage_resume.py')['ShaderStageResumeTest'](); case.setUp(); case.run_stage(); p=pathlib.Path(case.spirv,'index.json'); p.write_text('{\u0022unrelated\u0022:{}}',encoding='utf8'); print(case.run_stage()); case.tearDown(); case.doCleanups()"

The fixture carves s0.dxbc. The saved translation index then contains only unrelated.
Actual result: the second call returns [], and the stage succeeds.
Expected result: the stage reports that s0 is missing.

The new guard corrects the case where the counts differ, but not this case where the counts are equal. The merge base also accepts this index.
Possible correction: compare the stems of the carved file names with the keys of the translation index. This also covers the names that the carver changes to prevent collisions.

AI-assisted.

@tupacfan04

Copy link
Copy Markdown
Contributor

PASS, with two issues worth deciding on.

Verified at the head: the new suite 5/5, all 19 neighbouring tests/test_make_game_*.py pass, compileall and check_no_game_data clean, git diff --check clean, merge clean. Negative control: this test file against main's make_game.py errors 5 times (no attribute 'verify_translation_completeness').

  • The equality is measured against the carve index, but this file deliberately tolerates carved containers that never yield a listing (tools/fssm_unpack.py:172-177 skips parse failures / no XBCH), and disassembly_status only demands listings <= active (make_game.py:882-890). Such a gap would be reported as "refused or failed spirv-val" (:1411-1413) and block an otherwise healthy build. The shipped corpus is 26,503/26,503 XBCH (docs/fssm_crosscheck.md:38), so it is latent, not observed - but the check should distinguish "carved but not listing" from "translation lost it".
  • A present-but-unparseable spirv/index.json returns silently (:1399-1403); on a resumed stage translate() is skipped, so nothing else ever reads it.

Style nit: one blank line before the section header at :1414-1415 where main had two.

AI-assisted review, no game files, no GPU.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 118e393 merged with main d0835dd (merge 063158de8, no conflicts) on Linux (WSL2) Python 3.12.16 and native Windows 11 Python 3.13.1: concern (works as described; behaviour change to decide).

  • tests/test_make_game_translation_completeness.py: 5/5 OK on both. Negative control: make_game.py from main, same tests: 5 errors (no verify_translation_completeness) on Linux and on Windows.
  • Concern: the test's own docstring records a real run at aa2988c with 26,503 carved and 26,473 indexed shaders and exit 0. With this check the shaders stage now stops with fail(...) on that corpus, so every full run of make_game.py fails at the end of shaders until the 30 refused shaders are translated (and index.json is already published by then, so a re-run goes through fail again rather than passing). That fits "fix, don't skip" in AGENTS.md, but it turns a silent loss into a hard stop for anyone building today; worth the maintainers deciding, or a flag for the old behaviour.
  • Read the diff: an unreadable index or an empty one returns quietly (the PR says other code owns those cases); a non-object translation index or a non-list carve index fails.

@whattheflop whattheflop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted Windows CPU check at 118e3933 and parent 03b09a08, uv CPython 3.12.13. The synthetic fixture used real carve/unpack/translate tools and hand-written disassembly. It produced three DXBC translation entries from two native hashes. Case-colliding aliases kept distinct keys, and FSPX used its separate index. I found no path in the normal build for either to inflate the DXBC count.

A separate resume case has an intact, nonempty index naming exactly all three carved shaders, but one previously validated .spv is missing. With every resume marker unchanged, both revisions treated the DXBC cache as reusable, launched zero shader tools, and printed shaders: done. The file stayed missing. The real FSPX cache check rebuilt its module after equivalent file loss. This is a pre-existing DXBC resume gap outside the new count check and distinct from the equal-cardinality wrong-name case and #3328's empty-index recovery. The five stock completeness tests passed at head.

@whattheflop whattheflop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up to the missing-module report: #3665 (BUILD-1056) already handles that gap. AI-assisted Windows CPU check with uv CPython 3.12.13 at #3665 797ea022 plus #4582 118e3933. Both merge cleanly onto d0835dd9 (combined tree 59247095).

The real make_game.translate path translated nine synthetic listings in three shards with SPIRV-Tools. After deleting one output in shard 0, the cache inventory refused the hit. The retry rebuilt shard 0, reused shards 1 and 2 without rewriting their markers or part indexes, and restored the nine-entry merged index. This PR's count check then accepted nine carved entries, and separately reported 9 of 10 when the carve count exceeded the translated count. The test exercised the translation and check functions directly, bypassing the earlier carve/disassembly stages. Five focused suites passed 94 tests in the combined tree.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this at 118e3933 on Windows 11: pytest tests/test_make_game_translation_completeness.py tests/test_make_game_preflight.py -q -> 83 passed, 1 skipped, 27 subtests passed; git diff --check clean.

verify_translation_completeness runs after the translate block in the shaders stage, so it also covers an incremental run that skips translation. It compares the carve index list length with the merged translation index object length and fails naming the gap; missing/unreadable files and an empty index return early (owned by the translate and #3328 paths). The new tests cover the short index, the equal index and the unreadable cases. No blocking issue.

shdann's case: an index of the right size with the wrong names hid the
missing shader behind a matching count. The expected set is now the
disassembly's own listings — fssm_unpack.py deliberately tolerates carved
containers that never yield one, so those do not block a healthy build
(tupacfan04) — and the failure names both directions, capped at eight
names, pointing at the shard logs and the fixes for today's regression
class. A present-but-unparseable index now fails: on a resumed stage
nothing else ever reads it. Resume-test fixtures write the JSON their
markers always implied.
@abilliontokens

Copy link
Copy Markdown
Contributor Author

Review responses — head now f7585f8e (parent 03b09a08; 118e3933 was the first revision).

@shdann — fixed by comparing sets, not counts. The expected set is the merged index's counterpart exactly as you suggested: the disassembly listing stems; the check now reports both directions by name, capped at eight with a total. Your repro (s0 carved, index {"unrelated":{}}) now fails the stage with 1 listing(s) with no module in the index: s0; 1 index entry no listing backs: unrelated, and the equal-cardinality-wrong-name case is a test (test_the_right_count_with_the_wrong_names_fails_naming_both). tests/test_shader_stage_resume.py 44/44 with the fixture's translation index now naming what its listings always implied.

@tupacfan04 — both points taken. The equality is now measured against the disassembly listings, not the carve index, so a carved container that fssm_unpack.py:172-177 tolerates without a listing no longer blocks a healthy build (test: test_a_carved_container_without_a_listing_is_not_expected). And a present-but-unparseable spirv/index.json now fails (the translation index is not valid JSON …): as you noted, a resumed stage skips translate(), so this check is the only reader. A merely absent index still returns — that stays with the paths that fail first. Style nit fixed (two blank lines before the section header).

@kapitche — kept as a hard failure with no opt-out: the silent loss is exactly the bug this PR exists to catch, and AGENTS.md's "fix, don't skip" points the same way. The message is now actionable: it names the missing stems (sampled, with counts), points at the stage output and shard logs where each spirv-val failure is printed, and names today's class (aa2988cc typed-buffer regression, fixed by #3902/#4466). Yes, every full build fails at the end of shaders until that lands — intended; the alternative is a port missing shaders with finished in N min and exit 0, which is what the end-to-end run that found this actually printed.

@whattheflop — thanks for the resume and cache-inventory checks. Agreed on both: the missing-.spv-on-resume gap stays with #3665 (BUILD-1056) — noted here, no change in this PR; your equal-cardinality and DXBC/FSPX-partition observations are what the set comparison now covers.

@Kam471 — thanks; the check you verified is now a set comparison with the same placement.

Tested at f7585f8e (Windows 11, python -I)

  • tests/test_make_game_translation_completeness.py 9/9 (adds the wrong-names, no-listing-container, unparseable-index and capped-sample cases).
  • tests/test_shader_stage_resume.py 44/44; all 20 tests/test_make_game_*.py suites OK; compileall over make_game.py tests/ clean; git diff --check clean.
  • shdann's repro script: stage now exits 1 naming s0 (was [], success).
  • One pre-existing failure on this machine, unchanged by this PR (fails on plain 03b09a08 too): tests/test_check_no_game_data.py tearDown hits WinError 5 removing the temp git repo's read-only objects — the TEST-861 class.

AI-assisted (omp orchestrator).

@kapitche

Copy link
Copy Markdown
Contributor

Tested f7585f8 merged with main 98fa503 on Linux (Python 3.12.16): pass - tests/test_make_game_translation_completeness.py 9 OK, test_make_game_translator_flags.py 26 OK, test_shader_stage_resume.py 44 OK; negative control: upstream/main make_game.py with the new completeness test: 9/9 error (no verify_translation_completeness). The two edited tests (flags, stage_resume) still pass on main's make_game.py, so they only prove the fixtures were adapted to the new check, not the check itself. No issue found in the diff.

@abilliontokens

abilliontokens commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Status for the merge decision (re @kapitche's hard-fail concern): the regression class this check caught is fixed on main. At d974c88a the translator turns all 81 previously dropped modules (the Operand requires a previous definition class from aa2988cc; #4466 closed) into valid SPIR-V: 81 translated, 81 pass spirv-val, both with and without --wave64-emulate (81/81 each), own 1.0.2.1 carve, Windows 11, Python 3.12, SPIRV-Tools v2026.4. So on current main a healthy full build passes this check, and it only fails when modules are actually dropped. The PR is still mergeable at f7585f8e. AI-assisted (omp orchestrator).

@memorypressure

Copy link
Copy Markdown

FAIL, reproduced against main 3faac55: the completeness check is valuable and its own suite passes 9/9, and seven make_game suites stay green — but tests/test_fspx_shaders_stage.py goes red on this branch (errors=1, green on main, re-verified both ways): its fake_translate leaves an empty index.json and verify_translation_completeness now exits with the not-valid-JSON message. You fixed the same fake in translator_flags and shader_stage_resume; fspx_shaders_stage needs the same touch — an empty file where a minimal index is expected. Also note the fail() text defers empty-index refusal to #3328, which is still open. Checks pending; the fix is mechanical, worth a CI trigger once updated. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

ItsNotRexed added a commit that referenced this pull request Nov 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… their listing

- verify_translation_completeness (ItsNotRexed#4582) fails on an index it cannot parse and compares the index keys with the listing stems, so a fake translate() that leaves an empty index.json (test_fspx_shaders_stage.py) or names a shader no listing backs (test_make_game_empty_translation.py, from ItsNotRexed#3328) failed the stage it is there to see pass.
- Each fake now writes what the real merge publishes: one entry per listing present, as test_shader_stage_resume.py and test_make_game_translator_flags.py already do.
- Reported by memorypressure on ItsNotRexed#4582 (fspx); the empty-index one appeared when ItsNotRexed#3328 merged.
@abilliontokens

Copy link
Copy Markdown
Contributor Author

@memorypressure — fixed; head now ba3ce77ff (GitHub reports it mergeable; its two checks are queued). f7585f8e, the commit you tested, stays an ancestor.

The fix you asked for. tests/test_fspx_shaders_stage.py: its fake translate no longer leaves an empty index.json. It writes one entry per .s listing in the disassembly folder it is handed, the same way the fakes in test_shader_stage_resume.py and test_make_game_translator_flags.py already do.

One more of the same class, not in your review. #3328 merged at 11:36Z (9613d3361), after you looked, and brought ShadersStageTest in tests/test_make_game_empty_translation.py. Its fake index named shader_0 while its only listing is shader.s, so this PR's set comparison failed that stage on the merged tree (1 listing(s) with no module in the index: shader; 1 index entry no listing backs: shader_0; errors=2, green on main). The fake and its assertion now name shader. Both changes are one commit, 3cb679c5b.

The #3328 reference. It is merged, and this head merges it, so the comment now describes what main does: shaders() drops a saved {} together with its shard plan and translates again, and the pipelines stage refuses an empty index (require_translated_shaders). The check itself did not change: an empty index still returns without a comparison, because it is neither a partial index nor a stale one. No wording changed.

Merges. Four merges of main (e6190e7b5, 2fe59273b, d239fd855, b66e184eb), none with conflicts, each pushed as a normal fast-forward. Against main the PR differs only in its six files (line sets checked both ways after each merge).

Results at ba3ce77ff, Windows 11, CPython 3.12.10, CPU only, python -I <file>. Each file was also run on a pristine checkout of main b66e184eb.

File This branch Pristine main b66e184eb
tests/test_fspx_shaders_stage.py 22/22 22/22
tests/test_make_game_translation_completeness.py 9/9 5/5 (the count-based file)
tests/test_shader_stage_resume.py 46/46 46/46
tests/test_make_game_translator_flags.py 26/26 26/26
tests/test_make_game_empty_translation.py 12/13 12/13

The 23 tests/test_make_game_*.py plus the two stage files: 481 tests, 22 of 25 files green, and no file differs from main. Three are red on both sides, with the same tests and the same errors on pristine main, so none is this PR's and none is touched here:

Negative checks

  • test_fspx_shaders_stage.py before the fixture change, at merge commit bcc34c576 (branch plus main e6190e7b5, test file untouched): Ran 14 tests … FAILED (errors=1), the translation index is not valid JSON.
  • The same with the merged tree a66d8c988 and the test file exactly as main 2fe59273b has it (by then including make_game: treat an empty FSPX translation index as unfinished #6846's FSPX half of the same test): Ran 22 tests … FAILED (errors=1), same message. With the fixed fixture: 22/22.
  • test_make_game_empty_translation.py before its change at bcc34c576: Ran 9 tests … FAILED (errors=2). After the change, at that commit: 9/9.

Wider sweep (at a66d8c988, against main 2fe59273b). Twelve more files that run make_game.py: ten green; test_text_write_line_endings.py and test_tool_stdout_encoding.py fail one test each with the same entries on pristine main, in files this PR does not touch.

AI-assisted (omp orchestrator).

@lucas-tafuri

Copy link
Copy Markdown
Contributor

Independent Windows / CPython 3.12 verification of ba3ce77ff: FSPX shader stage 22/22, translation completeness 9/9, stage resume 46/46, and translator flags 26/26. Empty translation was 12/13 with the Exited fixture error, which also reproduces on upstream snapshot 8575d36e. Applying only the Exited.poll() change from #7214 locally on this PR brought that suite to 13/13, so the remaining error is covered there. Synthetic tests only. AI-assisted (OpenAI Codex).

@AGInformatique81

Copy link
Copy Markdown
Contributor

Rechecked ba3ce77 applied to current main dde82f2. A synthetic index with one entry and one listing but the wrong name is accepted by main's count check. With this PR the build check exits 1 and reports both the missing listing and the unexpected index entry. The matching-name control passes on both revisions.

On Windows (CPython 3.15.2), FSPX (22), completeness (9), translator flags (31), and stage resume (46) passed. Empty translation ran 13 tests with the same one Exited test-double error on main and with the patch, already tracked by #7214. On WSL2 (CPython 3.14.7), FSPX, completeness and stage resume passed (77 tests).

One diagnostic nit: the wrong-name case also tells the user that today's failure is the old aa2988c typed-buffer regression, even though a stale index alone can trigger it. A generic message pointing to the shard logs when translation failed would fit both cases. Synthetic fixtures, CPU-only. AI-assisted (Codex).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants