tools: chain_check.py, one page of counts for the whole shader chain (TOOL-CHAIN-CHECK) #2231
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2231
Loading…
Reference in a new issue
No description provided.
Delete branch "tools/chain-check"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: TOOL-CHAIN-CHECK
What and why
The shader chain (game files → llvm-mc → translator → SPIR-V → runtime pipelines) fails quietly link by link. On one Windows machine, llvm-mc 21.1.8 left 840 of the 2,684 compute programs of the pipeline library untranslated (839 "fall-through into undecodable words", 1
s_sethalt; #1923 measures the same gap). At boot the runtime then logged 843slot 67 ... failed with 0x80070057lines. Today nothing connects those two counts: the build prints no "N of M" for the library, andboot.ps1's digest shows neither slot failures nor failedCreatePipelineStatecalls.tools/chain_check.pyprints one page with one block per link, each with OK / WARN / FAIL and its most likely cause, then the weakest link:disasm.done,<family>_build.json) and its AMDGPU target, spirv-val, and the recorded translator digest against the same digest recomputed frommake_game.py'sTRANSLATION_SOURCES(a test pins it equal totranslation_sources_digest());invalid_words), translated (index entries with their.spv), up to 5 refusal reasons fromlogs/shaders.log;fspx_compute...);--log: modules loaded, failed slot calls by slot and HRESULT, failed D3D12 calls, compute builds, compile-gate waits, device faults, exit code.Counts and fixed words only. A refusal reason is printed only when it matches a message
rdna2spirv.pyraises (read from its source), with a variable part kept only when it is a mnemonic oftools/rdna2_isa_tables.pyor a built-in exception name; everything else counts asother. A D3D12 method name from a trace is printed only when it is a string literal of the runtime's sources (orInterface::Methodwith such an interface), and the end of a boot digest only in the three formsboot.ps1writes. Paths appear only with--show-paths. Standard library only. It reads files; probing runs onlyllvm-mc --version,spirv-val --versionandgit rev-parse(--no-proberuns nothing). Exit 0 (a report), 1 with--stricton FAIL, 2 for bad arguments. Documented indocs/dev-tools.md.Not done here (possible follow-up, separate PR): making
make_game.pyprint "N of M translated" for the library and FSPX and warn on llvm-mc older than 23, and adding the slot failures, failedCreatePipelineStatecalls and tagged/plain count toscripts/windows-boot/boot.ps1's digest. The tool reports; it does not fix, retranslate or change any threshold of the build.Sample report (real work folder after a full build with llvm-mc 21.1.8, and one 783 s boot; work folder path removed):
(abridged: the cause lines of the tools, game, fspx, bvh, exe, contract and runtime blocks and the fspx reasons line are left out, and the bvh/exe count lines are shortened)
Tested
python -I tests/test_chain_check.py: 23 tests OK (synthetic work folders built by the test: broken and clean chains, mixed llvm-mc versions, refusal reasons and trace method names closed to what the sources contain, an index entry without its.spvis not counted, the 1% threshold on both sides, no names/paths without--show-paths, empty and partial folders give n/a or a verdict,--strict,--helpthresholds, digest equal tomake_game.translation_sources_digest(), UTF-16 log with and without BOM). One test reads the runtime sources andboot.ps1and checks the 21 format-string fragments the log patterns depend on, so a reworded log line fails the test instead of silently reporting zero.tests/test_runner_calls_all_tests.py3 OK,tests/test_ci_registration.py16 OK, all 13tests/test_docs_*.pyOK.python -I scripts/check_no_game_data.py tools/chain_check.py tests/test_chain_check.py docs/dev-tools.md: exit 0;git diff --check origin/main..HEADclean.GPUs tested: n/a for the tool; the sample report comes from an NVIDIA RTX 4060, driver 610.88
AI-assisted: yes (Claude Code, Claude Opus 5.5, wrote the tool and its test; a second agent reviewed it)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
Ran the suite here rather than only reading it — Windows 11, CPython 3.14 (the author's runs were Linux/3.13), at head
044e27122vs basea73a57e13.tools/chain_check.py,tests/test_chain_check.py,docs/dev-tools.md.python -I tests/test_chain_check.py -vat head, branchpr2231: 23 tests, 23 OK, 6.6 s. The base has no chain_check files (git ls-tree a73a57e13finds none), so the delta is 0 → 23 — every test exercises the new tool; nothing pre-existing was displaced.python -I tools/chain_check.py /nonexistent-folder-xyz→ exit 2 (bad arguments);python -I tools/chain_check.py . --no-probeon a folder with no shader tree → all blocksn/a("not unpacked in this work folder"), exit 0 — the graceful partial-folder path works end to end, not just under unittest.python -I scripts/check_no_game_data.pyquiet, exit 0 (the new tool and docs pass the no-game-data scan, including the free-text-closing rules in its header);python3 -m compileall -qclean on both new files;python -I tests/test_ci_registration.py -v→ 16 tests OK, so the new tool doesn't desync the CI registration tests..spvis absent is not counted as translated (family_blockfilterspresentviaos.path.isfile, andtest_entry_without_module_is_not_translatedpins it); the FAIL_FRACTION boundary matches the docstring's "99 of 100 is WARN, 197 of 200 is FAIL" arithmetic andtest_threshold_boundscovers both edges; the deliberate broadexcept (Exception, SystemExit)around the LLVM_MC probe is the one noqa:ed spot, and it is the documented intent ("a broken LLVM_MC is reported, not raised").Merge state as read today:
mergeable=true,mergeStateStatus=unstablewithchange-scopeandno-game-databoth pending (no failures) — CI just hadn't settled when I checked.VERDICT: OK on the evidence I could run — 23/23 local, gates clean, live runs reproduce the documented contract; CPython 3.14 on Windows reproduces the same counts as the author's Linux/3.13 run. I read ~520 of the 775 tool lines closely (helpers, repo side, blocks); the runtime-log tail I lean on the closed-set regexes plus
test_utf16_log/test_no_names_or_log_text_printedfor, so the free-text closing is test-backed but not personally line-verified end to end.Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU, no game data). Merges cleanly. python -I tests/test_chain_check.py: 23 tests OK with this PR (the tool is new, so there is no main baseline to fail against). compileall clean.
AI-assisted: yes (Claude Code)
Thanks for this! One page of counts for the whole shader chain makes a gap easy to spot.
During maintainer testing (local, 2026-11-28) (head 1b1fb2db4, merged on main b1619e0a3 / 6dfca6428, Windows 11, Python tests via pytest/unittest) we found:
tests/test_text_encoding.pyfails:tools/chain_check.pyopens text files withoutencoding=(3 calls, e.g. around line 624), against the AGENTS.md convention.To get this merged:
encoding='utf-8'on everyopen()inchain_check.py, plusnewline='\n'where it writes.AI-assisted (Claude Code), posted for DadaCap (maintainer).
#2231 | head 1b1fb2db426f2ee76fa9a69ec7ee11b4794ed702 (merged cleanly onto origin/main 59e65849b0) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes
Independent Verification (Windows 11)
docs/dev-tools.md,tools/chain_check.py, andtests/test_chain_check.py(including the closed-vocabulary normalization againstrdna2spirv.pyUnsupported(...)AST patterns,rdna2_isa_tables.pymnemonics,runtime/{shims,src}string literals, andscripts/windows-boot/boot.ps1digest endings).python -I scripts/check_no_game_data.py docs/dev-tools.md tools/chain_check.py tests/test_chain_check.pypassed (rc=0).#2231 + origin/main59e65849b0):python -I tests/test_chain_check.py -v->23/23passed (0skipped,OK,7.693s), covering Windows backslash path suppression unless--show-pathsis passed, UTF-16 BOM / UTF-16LE / UTF-16BE PowerShell log decoding, live source-string pinning against currentmain(runtime/shims/*,runtime/src/*,scripts/windows-boot/boot.ps1), andmake_game.translation_sources_digest()parity.python -I tests/test_ci_registration.py->18/18passed (OK)test_docs_table_rows.py(2/2),test_docs_repo_paths.py(5/5),test_docs_encoding.py(1/1),test_docs_env_vars.py(5/5) -> allOK.Tested
2dd72a453merged (no commit) withmain4755667f5: Python 3.12, Windows 11 10.0.26300, CPU only. Ran the PR's tests plus every test file that imports the changed tool.python -I tests/test_chain_check.pypasses.tools/chain_check.pyis new in this PR, so the only red is the test failing to import it onmain.8db8335d2).AI-assisted (Claude Code).
RUN (independent run on Windows, #2231 head 8a2736fe6, tested as it is; it merges cleanly into main 8f41d7d01 per
git merge-tree --write-tree. CI on 8a2736fe6: change-scope, check, linux-python-and-viewer, no-game-data and semantic-tests all pass.)Commands, from the repository root:
python -I -m unittest discover -s tests -p test_chain_check.pyon the head: 23 tests OK.ImportError, nochain_check). That alone proves little.FAIL_FRACTIONtest removed) and the tests kept, 6 tests fail:test_broken_chain_names_each_link,test_empty_and_partial_folders_are_na,test_entry_without_module_is_not_translated,test_strict_exit_code,test_threshold_bounds,test_untranslated_without_build_log.make_game.py'sTRANSLATION_SOURCESand its digest, anddocs/dev-tools.mdchanges:test_shader_stage_resume.py47 OK,test_cmake_translator_deps.py5 OK andtest_boot_matrix.py36 OK on the head.Python 3.13.12 (
python -I), run at low priority.Machine: Windows 11 Pro 26300, i9-13900K, 64 GB, RTX 3090 24 GB (not used), NVIDIA 621.40.
Reviewed
tools/chain_check.py,tests/test_chain_check.py, anddocs/dev-tools.mdon head8a2736f. Standard-library-only, clean-room, with closed-set redaction for shader names, paths, log lines, refusal reasons, and trace methods, plus explicit UTF-8/UTF-16 handling (open(..., encoding="utf-8")fixes from prior review are in place). Mergeable cleanly with all 5 CI checks green. Approving and merging.(AI-assisted review.)