Scripts: reject invalid shader coverage counters #2526

Open
JiyouProt wants to merge 1 commit from upstream-pr/2536 into main
JiyouProt commented 2026-11-25 22:04:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JiyouProt on 2026-11-25T22:04:52Z.


The shader coverage gate can report success with NaN counters and can save invalid or inconsistent counts as its baseline. For example, total=10, translated=11 with the other outcomes zero passes comparison and update; a later genuine 10-of-10 sweep then looks like a regression.

Require non-negative integer stage counters and total == translated + unsupported + validator_failed + panicked + timeout, matching StageCounts::total in coverage.rs. Validate saved/live sweeps and comparison baselines before use. Invalid counters return 2 with the stage/field named; rejected updates preserve existing bytes and do not create an absent baseline.

What is in it

  • scripts/coverage_gate.py: counter type/range and total-consistency checks; valid comparison thresholds unchanged. Total check addresses review 6068816616.
  • scripts/test_coverage_gate_counts.py: synthetic regressions for saved and child output, baseline preservation, sums above/below total, every outcome, invalid baseline, valid mixed outcomes and zero/large counts. Extra metadata is not summed.
  • README.md: documents the report contract and rejected-update behavior. RavenCurseBurg also independently reproduced the total mismatch and proposed the same invariant; the results below are our own runs.
  • Separate scopes remain with #2099 (outer mappings), #2265 (child exit status), #2253 (empty stages), #2354 (new-stage failures).

Tested

  • Windows 11 Pro 10.0.26300, Ryzen 7 5800X, 64 GB, RTX 3080 Ti 12 GB / NVIDIA 616.92; Python 3.11.9, DXC 1.9.2609.5, portable Rust 1.100.0 Windows GNU / LLVM-MinGW 23.1.6. Session-local LLD/self-contained support libraries and -C target-feature=+fma on this FMA-capable CPU, as in the prior validation.
  • python -B -m unittest discover -s scripts -p 'test_*.py' -v: 36 passed, 0 failed. The review regression produces 16 failing subcases on original PR head 60bb165; all pass after the sum check. Original counter regressions also remain green.
  • 12 real CLI checks passed using saved JSON and a synthetic child command, compare and update, for valid counts and outcome sums both above/below total. Rejections return 2, name CS.total, and preserve baseline bytes.
  • Exact code revision 0452c949b6e5, clean tree: cargo build --locked --workspace -j 4 and cargo test --locked --workspace --no-fail-fast -j 4 -- --test-threads=4 --show-output, both Debug and Release (--release), pass. Each test run: 1,423 passed / 0 failed / 46 ignored. Session-local XCL_DXIL_CACHE points to a writable workspace directory; caching remains enabled. Final head b8a336de4332 differs only by the README paragraph documenting this input contract; its Python suite and Debug/Release builds were checked again. Native test sources and runtime are identical to the tested revision.
  • Each full run has 29 explicit SKIPPED lines: 21 native-wave64 cases, three unsupported per-lane f16 cases, three unavailable D3D12-debug-layer cases, one disabled opt-in heap-window case and one unavailable cold-driver-cache-control case. Harness passes include these skips and sample-dependent early returns; no XCL_SAMPLE_* files supplied.
  • Changed-file git diff --check and PR-description checks pass.

Regression run

  • Scripts/tests only; no runtime/build-input changes or title data.

Not tested

  • No retail shader sweeps/titles, MSVC, AMD/WARP parity, native wave64, D3D12 debug layer or controlled cold driver-cache run. No game data, system/driver setting change or GPU performance claim.
  • Upstream CI approval is still required; local results are not an upstream CI pass.

AI use

  • OpenAI Codex (GPT-6; exact model variant unavailable) investigated, implemented and reviewed the fix and review follow-up, ran the reported tests, and prepared this description. Publication authorized by the user.
<!-- greyfinch-sync:ivall/xcl:issue:6614693229 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2536). Originally posted by [JiyouProt](https://github.com/JiyouProt) on 2026-11-25T22:04:52Z. --- The shader coverage gate can report success with `NaN` counters and can save invalid or inconsistent counts as its baseline. For example, `total=10, translated=11` with the other outcomes zero passes comparison and update; a later genuine 10-of-10 sweep then looks like a regression. Require non-negative integer stage counters and `total == translated + unsupported + validator_failed + panicked + timeout`, matching `StageCounts::total` in `coverage.rs`. Validate saved/live sweeps and comparison baselines before use. Invalid counters return 2 with the stage/field named; rejected updates preserve existing bytes and do not create an absent baseline. **What is in it** - `scripts/coverage_gate.py`: counter type/range and total-consistency checks; valid comparison thresholds unchanged. Total check addresses [review 6068816616](https://github.com/xcl-dev/xcl/pull/2536#pullrequestreview-6068816616). - `scripts/test_coverage_gate_counts.py`: synthetic regressions for saved and child output, baseline preservation, sums above/below total, every outcome, invalid baseline, valid mixed outcomes and zero/large counts. Extra metadata is not summed. - `README.md`: documents the report contract and rejected-update behavior. RavenCurseBurg also [independently reproduced the total mismatch](https://github.com/xcl-dev/xcl/pull/2536#issuecomment-7176549096) and proposed the same invariant; the results below are our own runs. - Separate scopes remain with #2099 (outer mappings), #2265 (child exit status), #2253 (empty stages), #2354 (new-stage failures). **Tested** - Windows 11 Pro 10.0.26300, Ryzen 7 5800X, 64 GB, RTX 3080 Ti 12 GB / NVIDIA 616.92; Python 3.11.9, DXC 1.9.2609.5, portable Rust 1.100.0 Windows GNU / LLVM-MinGW 23.1.6. Session-local LLD/self-contained support libraries and `-C target-feature=+fma` on this FMA-capable CPU, as in the prior validation. - `python -B -m unittest discover -s scripts -p 'test_*.py' -v`: **36 passed, 0 failed**. The review regression produces **16 failing subcases** on original PR head `60bb165`; all pass after the sum check. Original counter regressions also remain green. - **12 real CLI checks passed** using saved JSON and a synthetic child command, compare and update, for valid counts and outcome sums both above/below total. Rejections return 2, name `CS.total`, and preserve baseline bytes. - Exact code revision `0452c949b6e5`, clean tree: `cargo build --locked --workspace -j 4` and `cargo test --locked --workspace --no-fail-fast -j 4 -- --test-threads=4 --show-output`, both Debug and Release (`--release`), pass. Each test run: **1,423 passed / 0 failed / 46 ignored**. Session-local `XCL_DXIL_CACHE` points to a writable workspace directory; caching remains enabled. Final head `b8a336de4332` differs only by the README paragraph documenting this input contract; its Python suite and Debug/Release builds were checked again. Native test sources and runtime are identical to the tested revision. - Each full run has **29 explicit SKIPPED lines**: 21 native-wave64 cases, three unsupported per-lane f16 cases, three unavailable D3D12-debug-layer cases, one disabled opt-in heap-window case and one unavailable cold-driver-cache-control case. Harness passes include these skips and sample-dependent early returns; no `XCL_SAMPLE_*` files supplied. - Changed-file `git diff --check` and PR-description checks pass. **Regression run** - Scripts/tests only; no runtime/build-input changes or title data. **Not tested** - No retail shader sweeps/titles, MSVC, AMD/WARP parity, native wave64, D3D12 debug layer or controlled cold driver-cache run. No game data, system/driver setting change or GPU performance claim. - Upstream CI approval is still required; local results are not an upstream CI pass. **AI use** - OpenAI Codex (GPT-6; exact model variant unavailable) investigated, implemented and reviewed the fix and review follow-up, ran the reported tests, and prepared this description. Publication authorized by the user.
DavidM1911 commented 2026-11-25 23:09:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T22:17:48Z.


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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7176184206 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2536#issuecomment-7176184206). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T22:17:48Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
RavenCurseBurg commented 2026-11-25 23:09:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-25T22:35:22Z.


I tested 60bb165ab20756a6d5c7d9b2ede307b68060cd59 alongside #2253 (4b29d00). git merge-tree --write-tree 60bb165 4b29d00 gave a clean combined tree 71f1fe88b85d86fa9b2d0d297128de84fd0d7dea. I used a private copy of the checked-in five-stage baseline for each case.

I ran 20 CLI checks on each of the two heads and on the combined tree, 60 in all. Each input went through both --run-json <file> and --xcl <stand-in.cmd> --rpf synthetic.

  • On the combined tree, an empty stage map and each of five invalid CS.translated values (boolean, fractional, negative, NaN and missing) returned 2 on update. Every rejected update preserved the original bytes. A malformed baseline also returned 2 on comparison and stayed unchanged.
  • The standalone heads isolated their respective fixes. The counter patch alone allowed the empty update; the empty-stage patch alone allowed those five invalid non-empty updates. On all three trees an identical report passed, one fewer CS translation returned 1, and a valid update wrote the expected counts.
  • python -B -m unittest discover -s scripts -p "test_*.py" passed 33 tests on this head, 27 on #2253 and 35 on the combination.

Windows 11 26100.9711, Core i7-13700, Python 3.14.3. Synthetic inputs and child process only. OpenAI Codex (GPT-6) prepared and ran this compatibility check.

Follow-up on the latest review

I reproduced review 6068816616 with a saved stage whose five outcomes add to 10. On the PR head, totals of both 9 and 11 passed comparison and update. Each update replaced the baseline.

The candidate returns 2 for both mismatches in compare and update, and all four invocations preserved the existing baseline bytes. A balanced 10-of-10 run still passed, a balanced regression returned 1, and a valid update with all five outcomes represented succeeded. All 35 Python script tests passed. These were saved-input CLI runs, with no real shader pack.

Candidate commit 5b290526 is based directly on 60bb165ab207. Reproduce with python -B -m unittest discover -s scripts -p test_*.py. OpenAI Codex (GPT-6) prepared the fix and ran these Windows CPU fixtures. No game, GPU benchmark or workspace build.

Recheck after the update

I rechecked the revised head b8a336de4332499dffa023614871bf4832fdea10 with synthetic saved reports. Stage totals one below and one above the sum each returned 2 on compare and update, with the baseline unchanged. On the previous head all four returned 0 and both updates replaced the baseline. All 36 Python script tests passed on the revised head.

The new head still merges cleanly with #2253 at 4b29d00cbeaa (tree 2d2a01055d0a17940de8a8a9bb54972bee577238). I ran the same four cases on the combined script, plus an empty-stage update. All five returned 2 and preserved the file. The standalone revised head still accepts the empty-stage update, which is the separate case covered by #2253.

OpenAI Codex (GPT-6) ran the checks and prepared this update. No game or GPU workload.

<!-- greyfinch-sync:ivall/xcl:comment:7176549096 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2536#issuecomment-7176549096). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T22:35:22Z. --- I tested `60bb165ab20756a6d5c7d9b2ede307b68060cd59` alongside #2253 (`4b29d00`). `git merge-tree --write-tree 60bb165 4b29d00` gave a clean combined tree `71f1fe88b85d86fa9b2d0d297128de84fd0d7dea`. I used a private copy of the checked-in five-stage baseline for each case. I ran 20 CLI checks on each of the two heads and on the combined tree, 60 in all. Each input went through both `--run-json <file>` and `--xcl <stand-in.cmd> --rpf synthetic`. - On the combined tree, an empty stage map and each of five invalid CS.translated values (boolean, fractional, negative, NaN and missing) returned 2 on update. Every rejected update preserved the original bytes. A malformed baseline also returned 2 on comparison and stayed unchanged. - The standalone heads isolated their respective fixes. The counter patch alone allowed the empty update; the empty-stage patch alone allowed those five invalid non-empty updates. On all three trees an identical report passed, one fewer CS translation returned 1, and a valid update wrote the expected counts. - `python -B -m unittest discover -s scripts -p "test_*.py"` passed 33 tests on this head, 27 on #2253 and 35 on the combination. Windows 11 26100.9711, Core i7-13700, Python 3.14.3. Synthetic inputs and child process only. OpenAI Codex (GPT-6) prepared and ran this compatibility check. **Follow-up on the latest review** I reproduced review 6068816616 with a saved stage whose five outcomes add to 10. On the PR head, totals of both 9 and 11 passed comparison and update. Each update replaced the baseline. The candidate returns 2 for both mismatches in compare and update, and all four invocations preserved the existing baseline bytes. A balanced 10-of-10 run still passed, a balanced regression returned 1, and a valid update with all five outcomes represented succeeded. All 35 Python script tests passed. These were saved-input CLI runs, with no real shader pack. [Candidate commit 5b290526](https://github.com/RavenCurseBurg/xcl/commit/5b2905263077a4a6053c9a7a050eeb1b610cc896) is based directly on `60bb165ab207`. Reproduce with `python -B -m unittest discover -s scripts -p test_*.py`. OpenAI Codex (GPT-6) prepared the fix and ran these Windows CPU fixtures. No game, GPU benchmark or workspace build. **Recheck after the update** I rechecked the revised head `b8a336de4332499dffa023614871bf4832fdea10` with synthetic saved reports. Stage totals one below and one above the sum each returned 2 on compare and update, with the baseline unchanged. On the previous head all four returned 0 and both updates replaced the baseline. All 36 Python script tests passed on the revised head. The new head still merges cleanly with #2253 at `4b29d00cbeaa` (tree `2d2a01055d0a17940de8a8a9bb54972bee577238`). I ran the same four cases on the combined script, plus an empty-stage update. All five returned 2 and preserved the file. The standalone revised head still accepts the empty-stage update, which is the separate case covered by #2253. OpenAI Codex (GPT-6) ran the checks and prepared this update. No game or GPU workload.
luckyteagirl commented 2026-11-26 06:06:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T05:04:57Z.

Review: COMMENTED


Could validate_counts also check that each stage's total equals the sum of its five outcome counters after validating their types? The producer in coverage.rs computes the JSON total from exactly those five values. Against a baseline with total=10 and translated=10, a saved report with total=10, translated=11, and the other counters zero currently passes comparison and can replace the baseline with --update. A later genuine 10-of-10 sweep then appears to regress. A fixture could check that compare and update reject the inconsistent report and that update preserves the existing baseline bytes. Source review only at head 60bb165a; no test run. AI-assisted with Codex (GPT-6.2 Sol).

<!-- greyfinch-sync:ivall/xcl:review:6068816616 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2536#pullrequestreview-6068816616). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T05:04:57Z. **Review:** COMMENTED --- Could `validate_counts` also check that each stage's `total` equals the sum of its five outcome counters after validating their types? The producer in `coverage.rs` computes the JSON total from exactly those five values. Against a baseline with `total=10` and `translated=10`, a saved report with `total=10`, `translated=11`, and the other counters zero currently passes comparison and can replace the baseline with `--update`. A later genuine 10-of-10 sweep then appears to regress. A fixture could check that compare and update reject the inconsistent report and that update preserves the existing baseline bytes. Source review only at head `60bb165a`; no test run. AI-assisted with Codex (GPT-6.2 Sol).
Foniass commented 2026-12-01 08:18:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:18:34Z.


Triage (#1607) – head b8a336d

No open or merged PR validates the counters: #2099 checks only that stages is a mapping and file/IO errors, #2253 refuses empty sweeps, #2265 failed sweeps, #2645 atomic baseline writes. validate_counts matches what coverage.rs emits (total = sum of the five outcomes in StageCounts::total) and the committed baseline passes it.
No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7305147519 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2536#issuecomment-7305147519). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:18:34Z. --- **Triage (#1607)** – head b8a336d No open or merged PR validates the counters: #2099 checks only that `stages` is a mapping and file/IO errors, #2253 refuses empty sweeps, #2265 failed sweeps, #2645 atomic baseline writes. `validate_counts` matches what `coverage.rs` emits (`total` = sum of the five outcomes in `StageCounts::total`) and the committed baseline passes it. No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2536:upstream-pr/2536'
git switch 'upstream-pr/2536'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2536'
git switch 'upstream-pr/2536'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2536'
git switch 'upstream-pr/2536'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2536'
git switch 'main'
git merge --squash 'upstream-pr/2536'
git switch 'main'
git merge --ff-only 'upstream-pr/2536'
git switch 'main'
git merge 'upstream-pr/2536'
git push origin 'main'
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
xcl-dev/xcl!2526
No description provided.