Scripts: harden coverage_gate CLI argument validation and error paths #2099
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2099
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@heditrigui on GitHub · 2026-11-25 03:59 UTC · original
heditrigui:scripts/coverage-gate-cli-hardening→main· +131 −4 · 2 files · 1 commits · openSummary
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
@JJAutoCompare on GitHub · 2026-11-25 04:12 UTC · original
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.@DavidM1911 on GitHub · 2026-11-25 05:43 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. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@raylitebull on GitHub · 2026-11-25 11:03 UTC · original
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).@ettehn on GitHub · 2026-11-25 11:04 UTC · original
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.
@ettehn on GitHub · 2026-11-25 11:10 UTC · original
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.
@RavenCurseBurg on GitHub · 2026-11-25 18:35 UTC · original · edited 2026-11-26 10:39 UTC
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.@luckyteagirl on GitHub · 2026-11-26 09:52 UTC · original · reviewed
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.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.