Shaders: identify direct translation artifacts in dump manifests #2553

Open
github-bot wants to merge 4 commits from github-bot/gh-2553 into main AGit
Owner

@⁠mokkamokacaffe on GitHub · 2026-11-25 22:45 UTC · original
mokkamokacaffe:diagnostics/dxil-dump-identity → main · +223 −5 · 3 files · 4 commits · draft

Part of #2541.

What is in it

  • xcl shaders --direct --dump <dir> writes a versioned .manifest.json beside each program's guest.bin and direct.dxil or direct.err.txt. The files share a prefix so a report can be matched to its artifacts.
  • The manifest records the source record hash, FSSM index, program offset, guest-code hash, shader stage, wave settings, memory-window count, validation request, translation wall time, and either the emitted DXIL hash or translator error.
  • Before replacing artifacts, XCL invalidates any manifest for the previous generation. Required artifacts are then written before the new manifest. If invalidation or an artifact write fails, XCL reports the exact path and no manifest remains that can authenticate stale or incomplete files.
  • scripts/verify_shader_dump.py verifies saved bundles without the source shader pack or a GPU: it recomputes the guest/DXIL FNV-1a hashes or compares rejected-translation diagnostic bytes exactly.
  • scripts/test_verify_shader_dump.py covers successful and rejected translations, large binary inputs, mismatches, absent files/fields, invalid schemas, malformed JSON, and multi-manifest failure handling.

translation_wall_us measures elapsed time around the translation worker call, including the wait for its result. Driver PSO creation is outside that interval.

Tested

  • Current clean head b0d2fb814b92148710d0f91e590d6c1f9fe26cd2:
    • python3 -B -m unittest discover -s scripts -p 'test_*.py': 30 passed, 0 failed.
    • cargo check -p xcl --tests --target x86_64-pc-windows-msvc: passed in a Linux cross-check environment using a local lib.exe-compatible archive wrapper. This was compile-only; Windows test binaries were not executed.
    • git diff --check: passed.
  • The new two-generation regression first writes a valid bundle, makes the replacement error-artifact path unwritable, and checks that the failed rerun has already removed the previous manifest.
  • Previous head 76e7793, independently checked on Windows 11 / RTX 3060 Ti after merging then-current main: cargo test -p xcl --lib reported all tests that ran passed, 0 failed and 27 ignored. This predates the stale-manifest fix and is supporting evidence, not exact-head validation.
  • The offline checker was independently exercised on Windows 11 with Python 3.14.3 using 12 two-manifest CLI cases, including a 131,073-byte guest file. Both valid outcome types passed; ten mismatch, missing-file/field, schema, and malformed-JSON cases returned failure while still processing the following valid manifest and leaving all inputs unchanged.

Regression run

Pending paired xcl-smoke blocks from current main and this PR's clean head b0d2fb814b92148710d0f91e590d6c1f9fe26cd2, with the same title and duration.

Not tested

  • The new stale-manifest regression executed natively on Windows; it is included in the Windows-target test build but was not run in this environment.
  • End-to-end dump generation from an actual shader pack on current head, including one successful and one rejected translation.
  • AMD, NVIDIA, or Intel shader execution on current head.
  • Retail-title smoke.

AI use

  • OpenAI Codex (GPT-6.2 Astra Ultra) implemented the manifest generation, review-requested artifact-write handling, stale-generation invalidation and regressions; ran the Windows-target compile and script tests; reviewed the external reports; and drafted this description.
  • RavenCurseBurg contributed the offline checker and its tests in commit 38cdb20f, assisted by OpenAI Codex (GPT-6); the commit was cherry-picked with its original authorship preserved.
**@⁠mokkamokacaffe** on GitHub · 2026-11-25 22:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553) `mokkamokacaffe:diagnostics/dxil-dump-identity` → `main` · +223 −5 · 3 files · 4 commits · draft Part of #2541. **What is in it** - `xcl shaders --direct --dump <dir>` writes a versioned `.manifest.json` beside each program's `guest.bin` and `direct.dxil` or `direct.err.txt`. The files share a prefix so a report can be matched to its artifacts. - The manifest records the source record hash, FSSM index, program offset, guest-code hash, shader stage, wave settings, memory-window count, validation request, translation wall time, and either the emitted DXIL hash or translator error. - Before replacing artifacts, XCL invalidates any manifest for the previous generation. Required artifacts are then written before the new manifest. If invalidation or an artifact write fails, XCL reports the exact path and no manifest remains that can authenticate stale or incomplete files. - `scripts/verify_shader_dump.py` verifies saved bundles without the source shader pack or a GPU: it recomputes the guest/DXIL FNV-1a hashes or compares rejected-translation diagnostic bytes exactly. - `scripts/test_verify_shader_dump.py` covers successful and rejected translations, large binary inputs, mismatches, absent files/fields, invalid schemas, malformed JSON, and multi-manifest failure handling. `translation_wall_us` measures elapsed time around the translation worker call, including the wait for its result. Driver PSO creation is outside that interval. **Tested** - Current clean head `b0d2fb814b92148710d0f91e590d6c1f9fe26cd2`: - `python3 -B -m unittest discover -s scripts -p 'test_*.py'`: 30 passed, 0 failed. - `cargo check -p xcl --tests --target x86_64-pc-windows-msvc`: passed in a Linux cross-check environment using a local `lib.exe`-compatible archive wrapper. This was compile-only; Windows test binaries were not executed. - `git diff --check`: passed. - The new two-generation regression first writes a valid bundle, makes the replacement error-artifact path unwritable, and checks that the failed rerun has already removed the previous manifest. - Previous head `76e7793`, independently checked on Windows 11 / RTX 3060 Ti after merging then-current `main`: `cargo test -p xcl --lib` reported all tests that ran passed, 0 failed and 27 ignored. This predates the stale-manifest fix and is supporting evidence, not exact-head validation. - The offline checker was independently exercised on Windows 11 with Python 3.14.3 using 12 two-manifest CLI cases, including a 131,073-byte guest file. Both valid outcome types passed; ten mismatch, missing-file/field, schema, and malformed-JSON cases returned failure while still processing the following valid manifest and leaving all inputs unchanged. **Regression run** Pending paired `xcl-smoke` blocks from current `main` and this PR's clean head `b0d2fb814b92148710d0f91e590d6c1f9fe26cd2`, with the same title and duration. **Not tested** - The new stale-manifest regression executed natively on Windows; it is included in the Windows-target test build but was not run in this environment. - End-to-end dump generation from an actual shader pack on current head, including one successful and one rejected translation. - AMD, NVIDIA, or Intel shader execution on current head. - Retail-title smoke. **AI use** - OpenAI Codex (GPT-6.2 Astra Ultra) implemented the manifest generation, review-requested artifact-write handling, stale-generation invalidation and regressions; ran the Windows-target compile and script tests; reviewed the external reports; and drafted this description. - RavenCurseBurg contributed the offline checker and its tests in commit `38cdb20f`, assisted by OpenAI Codex (GPT-6); the commit was cherry-picked with its original authorship preserved.
Check the guest hash and the result selected by the manifest. Compare exact diagnostic bytes for rejected translations so saved artifacts can be verified without the source pack or a GPU.

Assisted-by: OpenAI Codex (GPT-6)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:33:38 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 23:06 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-25 23:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#issuecomment-7177163924) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 26 ignored. Thanks! — Devin
Author
Owner

@⁠RavenCurseBurg on GitHub · 2026-11-25 23:06 UTC · original · edited 2026-11-26 13:49 UTC

Verified 76e7793dbb5ec337a0b30aa832d25f2fa2d1e5ee after the cherry-pick. The offline checker and its tests match the original files from 38cdb20f byte-for-byte. python -B -m unittest discover -s scripts -p "test_*.py" passed 30/30. All 12 two-manifest CLI cases passed again: a valid second manifest was processed after an invalid first one, and none of the saved file snapshots changed. This verifies the adopted offline checker. I did not execute XCL’s Rust dump writer or load a retail pack. Windows 11, Core i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) ran the checks.

Earlier verification

I prepared an offline artifact checker and tests on effef6719d431ac360ce9d6f46c55e87b1bd486a for the success/error checks listed in this PR. Run python -B scripts/verify_shader_dump.py FILE.manifest.json on a saved dump. It reads the sibling guest file and the result selected by the manifest, recomputes the FNV-1a hashes, and compares a rejected translation's UTF-8 error bytes exactly. It also accepts multiple manifests and returns a failure status if any comparison fails.

I ran 12 two-manifest CLI cases using synthetic files, including a 131,073-byte binary guest with independently computed hash 9fd6a807c893b7df. Both outcome types passed. The ten mismatch, missing-file/field, schema and malformed-JSON cases returned 1, still processed the following valid manifest and left all files byte-identical. A rejection with an old DXIL file present selected the error file. python -B -m unittest discover -s scripts -p "test_*.py" passed all 30 tests, including five for the checker.

Windows 11 26100.9711, i7-13700, Python 3.14.3. I tested the offline checker only. End-to-end generation with XCL and a shader pack remains unverified here. OpenAI Codex (GPT-6) prepared the checker and ran the tests.

Rechecked the offline verifier on b0d2fb814b92148710d0f91e590d6c1f9fe26cd2 following the writer change. With unchanged guest/DXIL files and a directory blocking the error-file path, a retained old manifest still verified. After I removed that manifest to represent an interrupted replacement, the CLI returned 1 and still verified a second intact bundle. Publishing a new error manifest selected its exact error text even with the old DXIL present. The verifier left all three fixture states unchanged.

I ran python -B scripts/verify_shader_dump.py sample.manifest.json other.manifest.json on those synthetic states, reran the 12 earlier CLI cases, and ran python -B -m unittest discover -s scripts -p "test_*.py" (30 passed). Windows 11 build 26100, Core i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) ran these checks. I constructed the file states directly. The native Rust writer regression and paired retail smoke were outside this run.

**@⁠RavenCurseBurg** on GitHub · 2026-11-25 23:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#issuecomment-7177146260) · edited 2026-11-26 13:49 UTC Verified `76e7793dbb5ec337a0b30aa832d25f2fa2d1e5ee` after the cherry-pick. The offline checker and its tests match the original files from `38cdb20f` byte-for-byte. `python -B -m unittest discover -s scripts -p "test_*.py"` passed 30/30. All 12 two-manifest CLI cases passed again: a valid second manifest was processed after an invalid first one, and none of the saved file snapshots changed. This verifies the adopted offline checker. I did not execute XCL’s Rust dump writer or load a retail pack. Windows 11, Core i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) ran the checks. <details> <summary>Earlier verification</summary> I prepared an [offline artifact checker and tests](https://github.com/RavenCurseBurg/xcl/commit/38cdb20f38aac4d600af05272659f3f364dd8f76) on `effef6719d431ac360ce9d6f46c55e87b1bd486a` for the success/error checks listed in this PR. Run `python -B scripts/verify_shader_dump.py FILE.manifest.json` on a saved dump. It reads the sibling guest file and the result selected by the manifest, recomputes the FNV-1a hashes, and compares a rejected translation's UTF-8 error bytes exactly. It also accepts multiple manifests and returns a failure status if any comparison fails. I ran 12 two-manifest CLI cases using synthetic files, including a 131,073-byte binary guest with independently computed hash `9fd6a807c893b7df`. Both outcome types passed. The ten mismatch, missing-file/field, schema and malformed-JSON cases returned 1, still processed the following valid manifest and left all files byte-identical. A rejection with an old DXIL file present selected the error file. `python -B -m unittest discover -s scripts -p "test_*.py"` passed all 30 tests, including five for the checker. Windows 11 26100.9711, i7-13700, Python 3.14.3. I tested the offline checker only. End-to-end generation with XCL and a shader pack remains unverified here. OpenAI Codex (GPT-6) prepared the checker and ran the tests. </details> Rechecked the offline verifier on `b0d2fb814b92148710d0f91e590d6c1f9fe26cd2` following [the writer change](https://git.gtahub.st/github/xcl-dev--xcl/pulls/2553). With unchanged guest/DXIL files and a directory blocking the error-file path, a retained old manifest still verified. After I removed that manifest to represent an interrupted replacement, the CLI returned 1 and still verified a second intact bundle. Publishing a new error manifest selected its exact error text even with the old DXIL present. The verifier left all three fixture states unchanged. I ran `python -B scripts/verify_shader_dump.py sample.manifest.json other.manifest.json` on those synthetic states, reran the 12 earlier CLI cases, and ran `python -B -m unittest discover -s scripts -p "test_*.py"` (30 passed). Windows 11 build 26100, Core i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) ran these checks. I constructed the file states directly. The native Rust writer regression and paired retail smoke were outside this run.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 01:36 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 01:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#issuecomment-7179943203) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
@ -2374,3 +2415,1 @@
match &r {
Ok(dxil) => dump("direct.dxil", dxil),
Err(e) => dump("direct.err.txt", e.as_bytes()),
if let Some(dir) = &dump_dir {
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 23:39 UTC · original

The manifest is written even if the earlier dump("guest.bin", ...) or DXIL/error dump failed; that closure discards each write error. In that case this new record can advertise hashes for artifacts that were not saved, and the run gives no immediate clue which file failed. Could the artifact writes return/report their errors (or record which artifacts were persisted) before emitting the manifest? A small test can make one sibling path unwritable while allowing the manifest write and assert the failure is visible.

**@⁠luckyteagirl** on GitHub · 2026-11-25 23:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#discussion_r4702171080) The manifest is written even if the earlier `dump("guest.bin", ...)` or DXIL/error dump failed; that closure discards each `write` error. In that case this new record can advertise hashes for artifacts that were not saved, and the run gives no immediate clue which file failed. Could the artifact writes return/report their errors (or record which artifacts were persisted) before emitting the manifest? A small test can make one sibling path unwritable while allowing the manifest write and assert the failure is visible.
@ -2374,3 +2415,1 @@
match &r {
Ok(dxil) => dump("direct.dxil", dxil),
Err(e) => dump("direct.err.txt", e.as_bytes()),
if let Some(dir) = &dump_dir {
Author
Owner

@⁠mokkamokacaffe on GitHub · 2026-11-26 00:04 UTC · original

Addressed in b6bd0c0. The required guest.bin and DXIL/error artifact writes now return their errors and complete before the manifest is written. A failed sibling write reports its exact path and prevents publication of the manifest.

I also added direct_dump_does_not_publish_a_manifest_for_a_missing_artifact, which makes sample.guest.bin unwritable and verifies that the error is visible and neither the result artifact nor manifest is created. The Windows MSVC-target test build passes.

**@⁠mokkamokacaffe** on GitHub · 2026-11-26 00:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#discussion_r4702354445) Addressed in `b6bd0c0`. The required `guest.bin` and DXIL/error artifact writes now return their errors and complete before the manifest is written. A failed sibling write reports its exact path and prevents publication of the manifest. I also added `direct_dump_does_not_publish_a_manifest_for_a_missing_artifact`, which makes `sample.guest.bin` unwritable and verifies that the error is visible and neither the result artifact nor manifest is created. The Windows MSVC-target test build passes.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-26 05:13 UTC · original

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of direct_dump_does_not_publish_a_manifest_for_a_missing_artifact: passed.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-26 05:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#issuecomment-7183292716) **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). `gpu_` suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. Targeted run of `direct_dump_does_not_publish_a_manifest_for_a_missing_artifact`: passed. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 06:55 UTC · original · reviewed

Reusing a --dump directory can leave a manifest that still verifies after a rerun fails. The prefix is stable for the same record and program. If the first run writes DXIL and a later run produces a translation error, a failed write to .direct.err.txt returns before the old manifest is replaced. The unchanged guest and old DXIL still match that manifest.

I reproduced the file sequence on Windows by placing a directory at the error artifact path. The sibling write raised PermissionError and the exact-head verifier exited 0 with “guest and translated DXIL match.”

Could the writer invalidate the existing manifest before it starts replacing artifacts, or use separate names for each generation? A regression can seed a valid bundle, force an artifact write failure on the rerun, and check that the old manifest cannot be mistaken for its result.

**@⁠luckyteagirl** on GitHub · 2026-11-26 06:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#pullrequestreview-6069735105) · **reviewed** Reusing a `--dump` directory can leave a manifest that still verifies after a rerun fails. The prefix is stable for the same record and program. If the first run writes DXIL and a later run produces a translation error, a failed write to `.direct.err.txt` returns before the old manifest is replaced. The unchanged guest and old DXIL still match that manifest. I reproduced the file sequence on Windows by placing a directory at the error artifact path. The sibling write raised `PermissionError` and the exact-head verifier exited 0 with “guest and translated DXIL match.” Could the writer invalidate the existing manifest before it starts replacing artifacts, or use separate names for each generation? A regression can seed a valid bundle, force an artifact write failure on the rerun, and check that the old manifest cannot be mistaken for its result.
Remove an existing manifest before replacing any of its sibling artifacts. A failed rerun can then leave incomplete files, but cannot make the verifier accept the previous generation as the new result.

Add a two-generation regression that forces the replacement error artifact to be unwritable and checks that the old manifest is gone.

Assisted-by: OpenAI Codex (GPT-6.2 Astra Ultra)
Author
Owner

@⁠mokkamokacaffe on GitHub · 2026-11-26 13:01 UTC · original

Fixed in b0d2fb8.

write_direct_dump now removes the existing manifest before replacing any sibling artifact. Failure to invalidate the manifest aborts before changing the bundle; failure of any later artifact write leaves no manifest that can authenticate the previous generation.

The new direct_dump_invalidates_an_old_manifest_before_replacing_artifacts regression reproduces the reported sequence: it writes a valid bundle, makes the next .direct.err.txt path unwritable, runs a failing replacement, and asserts that the old manifest is gone.

Checked

  • python3 -B -m unittest discover -s scripts -p 'test_*.py': 30 passed, 0 failed.
  • cargo check -p xcl --tests --target x86_64-pc-windows-msvc: passed as a compile-only Linux cross-check with a local archive wrapper.
  • git diff --check: passed.

Not tested

  • Native Windows execution of the new Rust regression.
  • Exact-head workspace GPU suite or paired retail smoke.

AI use

  • OpenAI Codex (GPT-6.2 Astra Ultra) reproduced the state transition from the review, implemented the invalidation and regression, ran the listed checks, and drafted this reply.
**@⁠mokkamokacaffe** on GitHub · 2026-11-26 13:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#issuecomment-7192763738) Fixed in [`b0d2fb8`](https://github.com/mokkamokacaffe/xcl/commit/b0d2fb814b92148710d0f91e590d6c1f9fe26cd2). `write_direct_dump` now removes the existing manifest before replacing any sibling artifact. Failure to invalidate the manifest aborts before changing the bundle; failure of any later artifact write leaves no manifest that can authenticate the previous generation. The new `direct_dump_invalidates_an_old_manifest_before_replacing_artifacts` regression reproduces the reported sequence: it writes a valid bundle, makes the next `.direct.err.txt` path unwritable, runs a failing replacement, and asserts that the old manifest is gone. **Checked** - `python3 -B -m unittest discover -s scripts -p 'test_*.py'`: 30 passed, 0 failed. - `cargo check -p xcl --tests --target x86_64-pc-windows-msvc`: passed as a compile-only Linux cross-check with a local archive wrapper. - `git diff --check`: passed. **Not tested** - Native Windows execution of the new Rust regression. - Exact-head workspace GPU suite or paired retail smoke. **AI use** - OpenAI Codex (GPT-6.2 Astra Ultra) reproduced the state transition from the review, implemented the invalidation and regression, ran the listed checks, and drafted this reply.
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/2553/head:github-bot/gh-2553'
git switch 'github-bot/gh-2553'

Merge

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