PR checks: require hex commit hashes in xcl-smoke blocks #1141

Open
github-bot wants to merge 1 commit from github-bot/gh-1141 into main AGit
Owner

@⁠microwave805 on GitHub · 2026-11-24 12:28 UTC · original
microwave805:pr-check-hex-commits → main · +75 −3 · 2 files · 1 commits · open

scripts/pr_check.py accepted any 7+ character token on an xcl-smoke block's commit: line and passed it verbatim to gh api repos/<repo>/compare/<sha>...main (running under pull_request_target) and git merge-base --is-ancestor.

As a result, symbolic refs and rev expressions such as refs/heads/main and main~00 returned identical from GitHub's compare API (and origin/main / HEAD~000 exited 0 locally), passing the main-baseline check without naming any commit hash. Untrusted path segments (../../pulls, query strings) and leading-dash git flags (--version) were also interpolated directly into those calls.

Note on overlap with #834: #834 checks the first word's length (≥ 7) to reject short prefixes like 1 some other, but still allows non-hex refs, paths, and options through to is_main_ancestor(). Validating 7–40 hex digits handles both.

What is in it

  • scripts/pr_check.py: add COMMIT_SHA ([0-9a-f]{7,40}, case-insensitive) and commit_sha() to extract and lowercase valid hex SHAs before matching head or calling is_main_ancestor(), plus the same check inside is_main_ancestor() as defense-in-depth.
  • scripts/test_pr_check.py: cover non-hex refs, path traversal, query strings, leading-dash flags, out-of-range lengths, short/non-hex PR head commits, and valid 7–40 character lowercase/uppercase hex SHAs.

Tested

  • NVIDIA GeForce RTX 3070 (driver 32.0.16.1742), AMD Ryzen 5 5600X, Windows 11 Pro (build 22631), DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), Rust 1.100.0 (stable-x86_64-pc-windows-msvc, debug), Python 3.11.3
  • On PR head eebd284 (rebased onto main b7aa9f3):
    • python -I -m unittest discover -s scripts -p "test_*.py" -v: 19 passed, 0 failed
    • .\scripts\test.ps1 (cargo build --workspace && cargo test --workspace -- --test-threads=4): 770 passed, 0 failed, 41 ignored
    • SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64)
  • Previously on b00fd33 (base 47efa2e): before the fix all 3 new tests failed with 12 subtest failures; python -I scripts/pr_check.py --local rejected origin/main, refs/heads/main, HEAD~000, and --version (exit 1) and accepted 47efa2e (description ok); checked commit_sha() against 25 recently merged PRs on xcl-dev/xcl (16 PRs, 32 xcl-smoke blocks, 0 false positives)

Regression run

  • Not needed: changes only scripts/pr_check.py and scripts/test_pr_check.py (no runtime or build-input files).

Not tested

  • Live GitHub Actions pull_request_target execution (uses main's copy of scripts/pr_check.py until merged)
  • AMD / wave64 GPUs and retail titles

AI use

  • Antigravity (Gemini 4 Neon): audited scripts/pr_check.py, wrote the fix, unit tests, rebase conflict resolution, and this PR description, and ran the verification commands above.
**@⁠microwave805** on GitHub · 2026-11-24 12:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/1141) `microwave805:pr-check-hex-commits` → `main` · +75 −3 · 2 files · 1 commits · open `scripts/pr_check.py` accepted any 7+ character token on an `xcl-smoke` block's `commit:` line and passed it verbatim to `gh api repos/<repo>/compare/<sha>...main` (running under `pull_request_target`) and `git merge-base --is-ancestor`. As a result, symbolic refs and rev expressions such as `refs/heads/main` and `main~00` returned `identical` from GitHub's compare API (and `origin/main` / `HEAD~000` exited `0` locally), passing the main-baseline check without naming any commit hash. Untrusted path segments (`../../pulls`, query strings) and leading-dash git flags (`--version`) were also interpolated directly into those calls. Note on overlap with #834: #834 checks the first word's length (≥ 7) to reject short prefixes like `1 some other`, but still allows non-hex refs, paths, and options through to `is_main_ancestor()`. Validating 7–40 hex digits handles both. **What is in it** - `scripts/pr_check.py`: add `COMMIT_SHA` (`[0-9a-f]{7,40}`, case-insensitive) and `commit_sha()` to extract and lowercase valid hex SHAs before matching `head` or calling `is_main_ancestor()`, plus the same check inside `is_main_ancestor()` as defense-in-depth. - `scripts/test_pr_check.py`: cover non-hex refs, path traversal, query strings, leading-dash flags, out-of-range lengths, short/non-hex PR head commits, and valid 7–40 character lowercase/uppercase hex SHAs. **Tested** - NVIDIA GeForce RTX 3070 (driver 32.0.16.1742), AMD Ryzen 5 5600X, Windows 11 Pro (build 22631), DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`, debug), Python 3.11.3 - On PR head `eebd284` (rebased onto `main` `b7aa9f3`): - `python -I -m unittest discover -s scripts -p "test_*.py" -v`: 19 passed, 0 failed - `.\scripts\test.ps1` (`cargo build --workspace && cargo test --workspace -- --test-threads=4`): 770 passed, 0 failed, 41 ignored - SKIPPED GPU tests: `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware` (no wave64) - Previously on `b00fd33` (base `47efa2e`): before the fix all 3 new tests failed with 12 subtest failures; `python -I scripts/pr_check.py --local` rejected `origin/main`, `refs/heads/main`, `HEAD~000`, and `--version` (exit 1) and accepted `47efa2e` (`description ok`); checked `commit_sha()` against 25 recently merged PRs on `xcl-dev/xcl` (16 PRs, 32 `xcl-smoke` blocks, 0 false positives) **Regression run** - Not needed: changes only `scripts/pr_check.py` and `scripts/test_pr_check.py` (no runtime or build-input files). **Not tested** - Live GitHub Actions `pull_request_target` execution (uses `main`'s copy of `scripts/pr_check.py` until merged) - AMD / wave64 GPUs and retail titles **AI use** - Antigravity (Gemini 4 Neon): audited `scripts/pr_check.py`, wrote the fix, unit tests, rebase conflict resolution, and this PR description, and ran the verification commands above.
check() accepted any 7+ character token on an xcl-smoke block's commit
line and passed it verbatim to gh api repos/<repo>/compare/<sha>...main
(under pull_request_target) and git merge-base --is-ancestor.

Symbolic refs and rev expressions such as refs/heads/main and main~00
return identical from GitHub's compare API (and origin/main / HEAD~000
exit 0 locally), so a smoke block could satisfy the main-baseline check
without naming a real commit hash. Arbitrary path segments (../../pulls,
query strings) and leading-dash git options (--version) were also passed
through unvalidated.

Validate commit tokens as 7-40 hex digits via commit_sha() before
matching head or calling is_main_ancestor(), normalize to lowercase for
comparison, and guard is_main_ancestor() with the same pattern.

Assisted-by: Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:44:54 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 12:52 UTC · original

Independent verification on current main 384f7f7 (branch already contains it — clean).

Machine: Windows 11, Ryzen 9 7900X; Python 3.

  • python scripts/test_pr_check.py: 12 tests OK.
  • Logic check: commit_sha() now requires a 7–40 hex commit: token, and both the PR-head match (head_sha.startswith(sha)) and the baseline selection go through it — a smoke block with a non-hex or missing commit no longer counts as a valid run. The uncommitted check still applies to the matched block.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

**@⁠DavidM1911** on GitHub · 2026-11-24 12:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/1141#issuecomment-7132032668) Independent verification on current `main` `384f7f7` (branch already contains it — clean). **Machine:** Windows 11, Ryzen 9 7900X; Python 3. - `python scripts/test_pr_check.py`: **12 tests OK**. - Logic check: `commit_sha()` now requires a 7–40 hex `commit:` token, and both the PR-head match (`head_sha.startswith(sha)`) and the baseline selection go through it — a smoke block with a non-hex or missing commit no longer counts as a valid run. The `uncommitted` check still applies to the matched block. AI use: test runs by Devin (Cognition, SWE-2); no code changes.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 14:15 UTC · original

Tested exact head b00fd33, script tests only, since this PR has no test report yet.

Tested

  • Windows 11 Home 26300, Python 3.14.3 with pytest 9.0.3, Windows PowerShell 5.1.26100.9818 (no PowerShell 7 here).
  • python -m pytest scripts/test_pr_check.py at the head: 12 passed, 25 subtests passed.
  • The PR's test file(s) against current main's script (930e8b4): 12 subtests fail across test_non_hex_main_commits_are_refused_before_ancestor_check and test_short_or_non_hex_head_commits_are_refused (e.g. main~00, HEAD~000, ../../pulls). So the new test catches the problem the PR fixes.

Not tested

  • PowerShell 7, the CI workflow itself, a game (no runtime code changed).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 14:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1141#issuecomment-7134097266) Tested exact head `b00fd33`, script tests only, since this PR has no test report yet. **Tested** - Windows 11 Home 26300, Python 3.14.3 with pytest 9.0.3, Windows PowerShell 5.1.26100.9818 (no PowerShell 7 here). - `python -m pytest scripts/test_pr_check.py` at the head: 12 passed, 25 subtests passed. - The PR's test file(s) against current main's script (`930e8b4`): 12 subtests fail across `test_non_hex_main_commits_are_refused_before_ancestor_check` and `test_short_or_non_hex_head_commits_are_refused` (e.g. `main~00`, `HEAD~000`, `../../pulls`). So the new test catches the problem the PR fixes. **Not tested** - PowerShell 7, the CI workflow itself, a game (no runtime code changed). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠microwave805 on GitHub · 2026-11-24 19:01 UTC · original

@⁠GonZiin Thanks for cross-checking #834 against eebd284 and verifying the merge! I also ran .\scripts\test.ps1 directly on eebd284 (770 passed, 0 failed, 41 ignored; 2 SKIPPED for no wave64) and updated Tested. Happy to pull #834's remaining two test cases (uncommitted head / unrelated commit) into this branch too if maintainers prefer consolidating here.

(Comment drafted with Antigravity (Gemini 4 Neon).)

**@⁠microwave805** on GitHub · 2026-11-24 19:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/1141#issuecomment-7141495705) @⁠GonZiin Thanks for cross-checking #834 against `eebd284` and verifying the merge! I also ran `.\scripts\test.ps1` directly on `eebd284` (770 passed, 0 failed, 41 ignored; 2 `SKIPPED` for `no wave64`) and updated **Tested**. Happy to pull #834's remaining two test cases (uncommitted head / unrelated commit) into this branch too if maintainers prefer consolidating here. *(Comment drafted with Antigravity (Gemini 4 Neon).)*
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 03:40 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 03:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/1141#issuecomment-7181931764) 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
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/1141/head:github-bot/gh-1141'
git switch 'github-bot/gh-1141'

Merge

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