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

Open
microwave805 wants to merge 1 commit from upstream-pr/1141 into main
microwave805 commented 2026-11-24 12:28:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by microwave805 on 2026-11-24T12:28:06Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5472146553 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1141). Originally posted by [microwave805](https://github.com/microwave805) on 2026-11-24T12:28:06Z. --- `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.
DavidM1911 commented 2026-11-24 13:03:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T12:52:18Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7132032668 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1141#issuecomment-7132032668). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T12:52:18Z. --- 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.
futurepro62 commented 2026-11-24 15:05:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T14:15:56Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7134097266 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1141#issuecomment-7134097266). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T14:15:56Z. --- 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.
GonZiin commented 2026-11-24 17:50:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by GonZiin on 2026-11-24T17:50:57Z.

Review: COMMENTED


I checked whether #834 still needs a separate merge. All four of its SmokeBlockCommitTests pass with this PR's checker, including acceptance of valid abbreviations and rejection of dirty and short-head blocks. This PR also validates the baseline's commit token. I would consolidate the work here and retain any additional test cases from #834 in the same branch.

Tested

  • Linux x86_64, Python 3.14.4. python3 -B -m unittest discover -s scripts -p 'test_*.py' ran 13 tests on #834 at f0bc702589cd694ca37db95c7f7268cedc095aec and 19 tests on #1141 at eebd2849f4e8305198cc92e66518e76a33d7cda2. Both passed.
  • git merge-tree --write-tree combined #1141 with main at 9e3831e1f570d3646e53ab753b19ec07eb8f1485 without conflicts. I copied only #834's four regression tests into the temporary merged tree. The same Python command reported 23 passed, 0 failed, 0 ignored.

Not tested

The Windows workspace and live GitHub Actions execution of the checker.

AI use

Codex (gpt-6.2-sol) compared the diffs, ran the tests and drafted this review.

<!-- greyfinch-sync:ivall/xcl:review:6044504801 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1141#pullrequestreview-6044504801). Originally posted by [GonZiin](https://github.com/GonZiin) on 2026-11-24T17:50:57Z. **Review:** COMMENTED --- I checked whether #834 still needs a separate merge. All four of its `SmokeBlockCommitTests` pass with this PR's checker, including acceptance of valid abbreviations and rejection of dirty and short-head blocks. This PR also validates the baseline's commit token. I would consolidate the work here and retain any additional test cases from #834 in the same branch. **Tested** - Linux x86_64, Python 3.14.4. `python3 -B -m unittest discover -s scripts -p 'test_*.py'` ran 13 tests on #834 at `f0bc702589cd694ca37db95c7f7268cedc095aec` and 19 tests on #1141 at `eebd2849f4e8305198cc92e66518e76a33d7cda2`. Both passed. - `git merge-tree --write-tree` combined #1141 with `main` at `9e3831e1f570d3646e53ab753b19ec07eb8f1485` without conflicts. I copied only #834's four regression tests into the temporary merged tree. The same Python command reported 23 passed, 0 failed, 0 ignored. **Not tested** The Windows workspace and live GitHub Actions execution of the checker. **AI use** Codex (`gpt-6.2-sol`) compared the diffs, ran the tests and drafted this review.
microwave805 commented 2026-11-24 19:07:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by microwave805 on 2026-11-24T19:01:57Z.


@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).)

<!-- greyfinch-sync:ivall/xcl:comment:7141495705 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1141#issuecomment-7141495705). Originally posted by [microwave805](https://github.com/microwave805) on 2026-11-24T19:01:57Z. --- @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).)*
DavidM1911 commented 2026-11-26 04:07:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T03:40:57Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7181931764 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1141#issuecomment-7181931764). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T03:40:57Z. --- 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
github-actions[bot] commented 2026-11-30 08:42:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:42:23Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7273240986 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1141#issuecomment-7273240986). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T08:42:23Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 04:54:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:54:20Z.


Triage (#1607) – head eebd284

#834 fixes part of the same pr_check.py bug. Both take a smoke block's commit from the first word of its commit: line, so 1 some other no longer counts as the head's run. This PR also requires that first word to be a 7-40 digit hex SHA, so refs such as origin/main or main~0 never reach is_main_ancestor, and it compares case-insensitively. That covers everything #834 does. Main still has the old length check.
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:7301222243 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1141#issuecomment-7301222243). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:54:20Z. --- **Triage (#1607)** – head eebd284 #834 fixes part of the same `pr_check.py` bug. Both take a smoke block's commit from the first word of its `commit:` line, so `1 some other` no longer counts as the head's run. This PR also requires that first word to be a 7-40 digit hex SHA, so refs such as `origin/main` or `main~0` never reach `is_main_ancestor`, and it compares case-insensitively. That covers everything #834 does. Main still has the old length check. 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/1141:upstream-pr/1141'
git switch 'upstream-pr/1141'

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/1141'
git switch 'upstream-pr/1141'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1141'
git switch 'upstream-pr/1141'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1141'
git switch 'main'
git merge --squash 'upstream-pr/1141'
git switch 'main'
git merge --ff-only 'upstream-pr/1141'
git switch 'main'
git merge 'upstream-pr/1141'
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!1132
No description provided.