Scripts: harden coverage_gate CLI argument validation and error paths #2089
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2099"
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?
Imported from ivall/xcl. Originally posted by heditrigui on 2026-11-25T03:59:21Z.
Summary
Hardens CLI argument handling and validation in
scripts/coverage_gate.pyand expands test coverage inscripts/test_coverage_gate.py:--run-jsonpath exists before reading; handles missing files, malformed JSON, and missing"stages"mapping cleanly (reporting error diagnostic on stderr and exiting code 2) instead of raising unhandled Python exceptions.--xclbinary and--rpfarchive exist before executing subprocess; handles missing files and process spawn errors cleanly with exit code 2.--baselineJSON syntax and"stages"structure when comparing; reports clean error diagnostic on stderr and exits code 2 if invalid.scripts/test_coverage_gate.pyfrom 9 to 22 tests covering CLI error handling (missing args, missing files, corrupt JSON, invalid schema mappings), baseline updates, pass status (code 0), and detected regressions (code 1).Tested
python scripts/test_coverage_gate.py(22 passed in 0.18s).python -m pytest scripts/(38 passed in 0.66s).scripts/pr_check.py --local.Not tested
scripts/tools are non-runtime code).AI use
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T04:12:21Z.
22 passed, 0 failed, 0 ignored, 0 skipped in 0.084 seconds on STOR-WINLAB. I verified that PR #2099 was open at
c52af79a0e80eaf3d94491ebc7342ebc9b8df424before and after the run. The assigned checkout was clean and detached. The visible PR discussion contained no independent test report.Tested. Windows 11 Enterprise Evaluation x64 build 26200, AMD Ryzen 7 3800X, portable CPython 3.13.7 AMD64 (MSC v.1944). The direct command
& 'L:/XclTooling/pr1999-coverage-52a120f7/portable/python.exe' -B scripts/test_coverage_gate.py -vexited 1 before running any tests because the interpreter’spython313._pthexcluded the script directory. The same interpreter ran the unchanged fixture successfully with a process-local import path, privateTEMPandTMP, andPYTHONDONTWRITEBYTECODE=1.The CLI fixtures returned
2for missing required arguments or files, malformed JSON, and missingstagesmappings. A matching baseline returned0, a translation regression returned1, and--updatereturned0and created a baseline in a new subdirectory with the expected stage counts.Not tested. Real XCL subprocess execution, shader packs, GPU, Cargo/workspace tests, smoke runs, and other Python suites.
AI use. T3 Code / Codex (
gpt-6.2-sol) ran the fixtures and wrote the report.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T05:43: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!
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T11:03:23Z.
Code review on
c52af79(scripts/coverage_gate.py,scripts/test_coverage_gate.py):--run-jsonand--baselinefiles (JSONDecodeError,OSError, missingstagesdict), missing--xcl/--rpfpaths, andOSErroron spawn, exiting2consistently; both CI checks are green and@JJAutoCompareverified22 passed, 0 failedonc52af79.Remaining before merge: One additional independent verification of
scripts/test_coverage_gate.pyonc52af79(--libruns do not exercise the Python script tests).Imported from ivall/xcl. Originally posted by ettehn on 2026-11-25T11:04:18Z.
Independent Windows check on exact
c52af79: all 22test_coverage_gate.pytests passed. I also reproduced two inherited cases with only temporary baseline copies.{"stages":{}}is rejected against the committed baseline (exit 1), but--run-json empty.json --update --baseline <copy>exits 0 and replaces that copy with an empty baseline. The next comparison of the same report exits 0 and printscoverage gate: no regressions. A live call with an empty synthetic9FPRpack also reproduced the replacement.{"stages":{"CS":{"translated":1636}}}reachescompare()and raisesKeyError: validator_failedinstead of getting a clean invalid-report diagnostic.The empty-update behavior also reproduces on
main. A follow-up could reject an empty baseline or sweep before update or comparison, and verify each stage has the counters the gate reads. No shipped baseline was touched.AI use — OpenAI Codex (GPT-6.2 Sol) ran the checks and wrote this report.
Imported from ivall/xcl. Originally posted by ettehn on 2026-11-25T11:10:30Z.
I put the report-validation follow-up on a single commit directly on
c52af79, in case you want to cherry-pick it.On Windows, the Python script suite passed 40/40. The temporary-baseline CLI checks reject an empty saved report, an empty live synthetic pack and a missing counter, all with exit 2 and the baseline bytes preserved. The saved validated 22,445-program report still passes.
AI use — OpenAI Codex (GPT-6.2 Sol) prepared the follow-up and ran the checks.
Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-25T18:35:59Z.
Independently compared this head
c52af79a0e80eaf3d94491ebc7342ebc9b8df424with @ettehn's follow-up on Windows 11 build 26100.9711, i7-13700, Python 3.14.3.I ran
python scripts/coverage_gate.py --run-json <run.json> --baseline <temporary copy>and its--updateform. The eight invalid inputs included an empty stage map, all-zero totals, a missing counter and five invalid values distributed over the second stage's counters (boolean, string, negative integer, fraction and null). For each input I tried comparison, update, and comparison with the invalid data on the baseline side.1a079ab, all 24 invalid cases exited 2 with a diagnostic and preserved the baseline byte-for-byte. Three controls passed on both revisions: a valid comparison, a valid update retaining the supplied counts, and a real decrease in translations returning 1.python -B -m unittest discover -s scripts -p "test_*.py"passed all 40 tests on the follow-up in a writable temporary environment.Only saved synthetic reports and temporary baseline copies were used. No shader compilation, retail pack or GPU workload. OpenAI Codex (GPT-6) ran these checks and wrote the report.
Follow-up on the review at
c52af79a0e80. Tested candidate b24d26580. I ran the real coverage-gate CLI with a dummy pack and a uniquely named executable in a temporary PATH directory outside its working directory. This head returned 2 before launching it. The candidate returned 0 and wrote exactly the supplied stage counts. The existing missing-executable and missing-pack tests still passed. All 39 script tests passed.Command on the candidate:
python -B -m unittest discover -s scripts -p "test_*.py". Windows 11 build 26100, Core i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) prepared the patch and ran the tests with synthetic inputs. I did not run the full Rust/GPU suite.Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T09:52:54Z.
Review: COMMENTED
On
c52af79, the newargs.xcl.is_file()check rejects a bare executable name that the OS can find onPATH, beforesubprocess.rungets a chance to resolve it. I reproduced this withfake-xcl.cmdplaced only on the child process'sPATH(outside its cwd), an existing dummy pack, and--update: current main exited 0, while this head exited 2 withxcl binary not found. Supplying the same stand-in by absolute path worked on both. This changes an already supported way to invoke the coverage gate.Could the executable be left to
subprocess.run(the newOSErrorhandler already diagnoses a genuine launch failure), or resolve bare names throughshutil.whichwhile retaining explicit-path checks? A regression fixture with the stand-in only onPATHwould cover it. This was a CPU-only exact-head CLI comparison; I did not run a shader sweep or GPU test.Imported from ivall/xcl. Originally posted by throny on 2026-11-28T21:07:37Z.
merge-check claim
head:
c52af79a0eImported from ivall/xcl. Originally posted by throny on 2026-11-28T21:37:00Z.
merge-check
base:
beeb81behead:
c52af79a0emerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2594 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at
beeb81be(main after the merge of nvidia-dev): 2594 passed, 0 failed, 49 ignored. The suite does not run this script, so the counts only show that nothing else moved.review: script only. One regression from the thread is unanswered:
--xclwith a bare program name that is found on PATH worked before and now exits with an error, because the new check wants an existing file path; resolving the name on PATH first would keep it. Smaller, also from the thread: a file with invalid UTF-8 still ends in a traceback, and the follow-up for an empty baseline is not in.performance: none.
verdict: not yet: keep
--xcl <name on PATH>working (small fix), then it is fine.hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T11:48:34Z.
merge-check claim
head:
c52af79a0eImported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T11:56:32Z.
merge-check
base:
9dfbe3ea66head:
c52af79a0emerge: clean
build: cargo build --workspace -> ok
tests: python scripts/test_coverage_gate.py -v -> 22 passed, 0 failed; cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2884 passed, 3 failed, 51 ignored; SKIPPED: 27 (22 no wave64, 2 no heap windows, 2 no xgameruntime.dll, 1 cannot disable the driver cache 0x887A002D); failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16 (also fails on base
9dfbe3eaalone) and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs in gpu_two_pass_cache_e2e (unrelated to this Python-only PR)review: read the full +131/-4 diff across scripts/coverage_gate.py (+29/-4) and scripts/test_coverage_gate.py (+102/-0). Blocking regression: args.xcl.is_file() in scripts/coverage_gate.py rejects bare executable names on PATH (e.g. --xcl xcl) that previously worked via subprocess.run; resolving via shutil.which before checking is_file() would preserve that. Smaller gaps: (1) read_text(encoding="utf-8") only catches (json.JSONDecodeError, OSError), leaving UnicodeDecodeError uncaught on invalid UTF-8 files; (2) --run-json with empty stages ({}) or missing per-stage counters is not validated before --update or compare().
performance: none (Python script only)
verdict: not yet: preserve --xcl via shutil.which before the file check
hardware / tool and model: NVIDIA GeForce RTX 4070 SUPER (32.0.16.2140), AMD Ryzen 7 7800X3D, Windows 11 Pro 26300, rustc 1.100.0, debug / Antigravity (Gemini 4 Hydrogen)
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:22:38Z.
Triage (#1607) – head
c52af79No open or merged PR makes the same change (#1999 added coverage_gate.py; #2354 changes the stage comparison, not the CLI error paths). The new checks return 2 with a message for a missing or malformed run-json / baseline, a missing xcl binary or pack, and a failed subprocess launch, and the tests exercise each path through
main().Minor:
args.xcl.is_file()refuses a bare command name that would have been found on PATH (e.g.--xcl xcl); worth a note in the help text if that use is intended.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.