Skip to content

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

Open
microwave805 wants to merge 1 commit into
xcl-dev:mainfrom
microwave805:pr-check-hex-commits
Open

microwave805 wants to merge 1 commit into
xcl-dev:mainfrom
microwave805:pr-check-hex-commits

Conversation

@microwave805

@microwave805 microwave805 commented Nov 24, 2026 •

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown

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.

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)

@GonZiin GonZiin left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

off-goal Does not bear on the current goal (world loading); waits until it is reached

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants