Scripts: pr_check takes the newest clean main smoke block as the baseline (#2226) #2230

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

@⁠Creaa on GitHub · 2026-11-25 10:46 UTC · original
Creaa:scripts/pr-check-main-baseline → main · +77 −8 · 2 files · 1 commits · open

The smoke check of pr_check.py let the author pick the main baseline: a main block with local changes counted as main (the PR's block already had to be clean), and with several matching main blocks the first pasted one was used, so an older, more favourable run could be put first. Fixes parts 2 and 3 of #2226; part 1 (how old a baseline may be) is reported, not judged.

What is in it

  • scripts/pr_check.py:
    • a main block whose commit: line says (uncommitted changes) is not a baseline; when only such a block is there, the check asks for a rerun on a clean checkout of main;
    • check(..., main_behind=...): with the distance of each main commit from main known, the baseline is the block of the newest main commit with the PR's title and time, wherever it is pasted; without it, or when any candidate's distance is unknown (a failed API call), the first block as before (main_baseline);
    • when the frames or peak-commit comparison fails against a baseline that is behind main, the message says how many commits behind it is;
    • main() gives that distance (git rev-list --count <sha>..origin/main with --local, compare/<sha>...main ahead_by on GitHub) and prints one line per main block, main regression run <sha>: N commit(s) behind main, without failing on it.
  • scripts/test_pr_check.py: test_a_main_run_with_uncommitted_changes_is_not_a_baseline, test_the_newest_main_block_is_the_baseline_whatever_its_place (both orders of an old and a current main block; without main_behind, or with an unknown distance, the first block is used; a failing comparison names the baseline's distance).

Tested

  • Windows 11 build 26300, Python 3.14.
  • python -m unittest discover -s scripts -p "test_pr_check.py": 15 tests, OK. With pr_check.py from main the two new tests fail (one failure, one error), the other 13 pass.
  • python scripts/pr_check.py --local on a body with two main blocks (cbc296a and current main) and a PR block: prints 54 commit(s) behind main and 0 commit(s) behind main, then description ok.

Regression run

  • None: only scripts/ changes, not the runtime.

Not tested

  • The GitHub path of main_behind (compare/...main ahead_by) against the real API in the workflow; the local path was run.
  • A cut-off for an old main baseline (part 1 of #2226): not chosen here.

AI use

  • Claude Code (Claude Opus 5.5) wrote the change and the tests, ran them, and drafted this description; I checked it.

🤖 Generated with Claude Code

**@⁠Creaa** on GitHub · 2026-11-25 10:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/2230) `Creaa:scripts/pr-check-main-baseline` → `main` · +77 −8 · 2 files · 1 commits · open The smoke check of `pr_check.py` let the author pick the `main` baseline: a main block with local changes counted as main (the PR's block already had to be clean), and with several matching main blocks the first pasted one was used, so an older, more favourable run could be put first. Fixes parts 2 and 3 of #2226; part 1 (how old a baseline may be) is reported, not judged. **What is in it** - `scripts/pr_check.py`: - a main block whose `commit:` line says `(uncommitted changes)` is not a baseline; when only such a block is there, the check asks for a rerun on a clean checkout of main; - `check(..., main_behind=...)`: with the distance of each main commit from main known, the baseline is the block of the newest main commit with the PR's title and time, wherever it is pasted; without it, or when any candidate's distance is unknown (a failed API call), the first block as before (`main_baseline`); - when the frames or peak-commit comparison fails against a baseline that is behind main, the message says how many commits behind it is; - `main()` gives that distance (`git rev-list --count <sha>..origin/main` with `--local`, `compare/<sha>...main` `ahead_by` on GitHub) and prints one line per main block, `main regression run <sha>: N commit(s) behind main`, without failing on it. - `scripts/test_pr_check.py`: `test_a_main_run_with_uncommitted_changes_is_not_a_baseline`, `test_the_newest_main_block_is_the_baseline_whatever_its_place` (both orders of an old and a current main block; without `main_behind`, or with an unknown distance, the first block is used; a failing comparison names the baseline's distance). **Tested** - Windows 11 build 26300, Python 3.14. - `python -m unittest discover -s scripts -p "test_pr_check.py"`: 15 tests, OK. With `pr_check.py` from `main` the two new tests fail (one failure, one error), the other 13 pass. - `python scripts/pr_check.py --local` on a body with two main blocks (`cbc296a` and current `main`) and a PR block: prints `54 commit(s) behind main` and `0 commit(s) behind main`, then `description ok`. **Regression run** - None: only `scripts/` changes, not the runtime. **Not tested** - The GitHub path of `main_behind` (`compare/...main` `ahead_by`) against the real API in the workflow; the local path was run. - A cut-off for an old main baseline (part 1 of #2226): not chosen here. **AI use** - Claude Code (Claude Opus 5.5) wrote the change and the tests, ran them, and drafted this description; I checked it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The PR's own smoke block already had to be free of "(uncommitted changes)",
but a main block with local changes counted as main. When several main blocks
had the PR's title and time, the first pasted one was the baseline, so an
older, more favourable run could be put first.

- A main block whose commit line says "(uncommitted changes)" is not a
  baseline; when it is the only one, the check says to rerun on a clean main.
- With the commit distance known (`main_behind`: git rev-list locally,
  compare/...main ahead_by on GitHub), the baseline is the matching block of
  the newest main commit; without it, the first block as before.
- How many commits behind main each main block is gets printed, not judged:
  the cut-off for an old baseline is the maintainer's call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:23:56 +00:00
Author
Owner

@⁠itsonewi on GitHub · 2026-11-25 10:51 UTC · original

The fix covers parts 2 and 3, and the tests read well. Two small things:

  1. When the chosen baseline is behind main and the frames/commit comparison fails, include the distance in that message. The standalone main regression run <sha>: N commit(s) behind main line is printed before the failure, but a reader who jumps to the failure will not connect the two. Something like the main block is 54 commits behind main; rerun it before comparing.
  2. In main_baseline, a candidate whose main_behind is None sorts as 1 << 30. If the newest block's compare call fails transiently but an older one succeeds, the older block wins - the opposite of the intent. Treat "any unknown distance" as "do not reorder" (fall back to candidates[0]), or fail the check with a message. The current behavior is only safe if the API never fails.

Neither blocks the merge for me. Part 1 (how old a baseline may be) is still open in #2226; the printed line is a good interim.

**@⁠itsonewi** on GitHub · 2026-11-25 10:51 UTC · [original](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7160269972) The fix covers parts 2 and 3, and the tests read well. Two small things: 1. When the chosen baseline is behind main and the frames/commit comparison fails, include the distance in that message. The standalone `main regression run <sha>: N commit(s) behind main` line is printed before the failure, but a reader who jumps to the failure will not connect the two. Something like `the main block is 54 commits behind main; rerun it before comparing`. 2. In `main_baseline`, a candidate whose `main_behind` is `None` sorts as `1 << 30`. If the newest block's compare call fails transiently but an older one succeeds, the older block wins - the opposite of the intent. Treat "any unknown distance" as "do not reorder" (fall back to `candidates[0]`), or fail the check with a message. The current behavior is only safe if the API never fails. Neither blocks the merge for me. Part 1 (how old a baseline may be) is still open in #2226; the printed line is a good interim.
Author
Owner

@⁠Creaa on GitHub · 2026-11-25 10:58 UTC · original

Thanks, both fixed in 4e4c508 (squashed into the PR's commit):

  1. When the frames or peak-commit comparison fails and the baseline is behind main, the message now ends with ; the main block is N commit(s) behind main: rerun it before comparing.
  2. You're right, a failed compare call made an older block win. main_baseline now keeps the first pasted block when the distance of any candidate is unknown. The test covers it (newest block's distance None, older one 40): it fails on the previous commit and passes now.

python -m unittest discover -s scripts -p "test_pr_check.py": 15 tests, OK. #2235 is rebased onto this.

AI use: Claude Code (Claude Opus 5.5) made the change and drafted this reply.

**@⁠Creaa** on GitHub · 2026-11-25 10:58 UTC · [original](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7160430264) Thanks, both fixed in `4e4c508` (squashed into the PR's commit): 1. When the frames or peak-commit comparison fails and the baseline is behind main, the message now ends with `; the main block is N commit(s) behind main: rerun it before comparing`. 2. You're right, a failed compare call made an older block win. `main_baseline` now keeps the first pasted block when the distance of any candidate is unknown. The test covers it (newest block's distance `None`, older one 40): it fails on the previous commit and passes now. `python -m unittest discover -s scripts -p "test_pr_check.py"`: 15 tests, OK. #2235 is rebased onto this. AI use: Claude Code (Claude Opus 5.5) made the change and drafted this reply.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 11:00 UTC · original

Code review on 3369021 (scripts/pr_check.py, scripts/test_pr_check.py):

  • Rejecting main xcl-smoke blocks tagged (uncommitted changes) and selecting min(candidates, key=behind) via main_baseline cleanly closes the stale/dirty baseline loophole from #2226 while preserving fallback behavior when main_behind is None, with 15/15 unit tests covering both orders.
  • Diff audited and CI workflow approved (45598235181).
  • Note: the GitHub compare/<sha>...main ahead_by branch (!o.local) will be exercised live by the PR workflow once CI completes.
**@⁠raylitebull** on GitHub · 2026-11-25 11:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7160466261) Code review on `3369021` (`scripts/pr_check.py`, `scripts/test_pr_check.py`): - Rejecting `main` `xcl-smoke` blocks tagged `(uncommitted changes)` and selecting `min(candidates, key=behind)` via `main_baseline` cleanly closes the stale/dirty baseline loophole from `#2226` while preserving fallback behavior when `main_behind` is `None`, with 15/15 unit tests covering both orders. - Diff audited and CI workflow approved (`45598235181`). - Note: the GitHub `compare/<sha>...main` `ahead_by` branch (`!o.local`) will be exercised live by the PR workflow once CI completes.
Author
Owner

@⁠itsonewi on GitHub · 2026-11-25 11:03 UTC · original

Re-read the new head (4e4c508): both points are addressed - an unknown distance now falls back to the first block instead of letting an older one win, and a failing comparison names how far the baseline is behind. The added assertions cover both orders, the unknown-distance case and the old-baseline message.

LGTM from me. The new head needs a fresh CI approval; the approved run (45598235181) was for 3369021.

**@⁠itsonewi** on GitHub · 2026-11-25 11:03 UTC · [original](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7160519903) Re-read the new head (`4e4c508`): both points are addressed - an unknown distance now falls back to the first block instead of letting an older one win, and a failing comparison names how far the baseline is behind. The added assertions cover both orders, the unknown-distance case and the old-baseline message. LGTM from me. The new head needs a fresh CI approval; the approved run (`45598235181`) was for `3369021`.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 11:03 UTC · original

Updated review on 4e4c508:

  • Returning candidates[0] when None in behind prevents transient API failures from letting an older baseline win, and appending the main block is N commit(s) behind main directly to the failing comparison messages makes stale baselines immediately actionable.
  • Diff audited and CI workflow approved (45600100113).
**@⁠raylitebull** on GitHub · 2026-11-25 11:03 UTC · [original](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7160524448) Updated review on `4e4c508`: - Returning `candidates[0]` when `None in behind` prevents transient API failures from letting an older baseline win, and appending `the main block is N commit(s) behind main` directly to the failing comparison messages makes stale baselines immediately actionable. - Diff audited and CI workflow approved (`45600100113`).
Author
Owner

@⁠throny on GitHub · 2026-11-26 00:58 UTC · original

Two contributors checked independently and found that #2406 solves the same problem (for #2226) in a different way: #1607, group D117. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

**@⁠throny** on GitHub · 2026-11-26 00:58 UTC · [original](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7179299155) <!-- xcl-1607-hint:D117 --> Two contributors checked independently and found that #2406 solves the same problem (for #2226) in a different way: #1607, group D117. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Author
Owner

@⁠RavenCurseBurg on GitHub · 2026-11-25 14:05 UTC · original · edited 2026-11-26 01:13 UTC

For D117, I also ran this same head and #2406 against identical fixtures using real local Git history. With a clean, one-commit-old baseline matching the PR’s frame count, #2230 passes and #2406 requires the recorded PR base. With an older high-frame block and a current clean block, both checkers select the current result in either order. Ten scenarios per checker, including dirty and duplicate blocks, are in the comparison report on #1056. OpenAI Codex (GPT-6) ran the comparison on Windows 11 with Python 3.14.3.

Earlier verification

Checked a156f8bbb737f79f9f63e594c9b39cb215c4a670 against a snapshot of the public GitHub Compare API. For 06c9f5505f63...main the API returned identical / 0; for its first parent afc5ee86ae3a...main it returned ahead / 2. I replayed those two responses at the gh api subprocess boundary of pr_check.py --repo xcl-dev/xcl --body <body> --files <files> --head <sha>, checking the compare path and both requested fields. The local machine has no gh binary, so this covers the non-local checker code and the API response fields, with no Actions run.

With synthetic frames of 1,000 on the parent, 100 on the tip, and 110 on the PR, both block orders selected the tip and passed. The parent alone failed and printed the two-commit distance. A dirty tip alone failed with the clean-checkout diagnostic. All four cases printed the expected baseline distances. python -B -m unittest discover -s scripts -p test_pr_check.py also passed all 15 tests.

Windows 11 26100.9711, i7-13700, RTX 4060, Python 3.14.3. No Rust build, GPU workload, or retail runs. OpenAI Codex (GPT-6) retrieved the API data, ran these script fixtures and wrote the report.

**@⁠RavenCurseBurg** on GitHub · 2026-11-25 14:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7164747386) · edited 2026-11-26 01:13 UTC For D117, I also ran this same head and #2406 against identical fixtures using real local Git history. With a clean, one-commit-old baseline matching the PR’s frame count, #2230 passes and #2406 requires the recorded PR base. With an older high-frame block and a current clean block, both checkers select the current result in either order. Ten scenarios per checker, including dirty and duplicate blocks, are in the [comparison report on #1056](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1056). OpenAI Codex (GPT-6) ran the comparison on Windows 11 with Python 3.14.3. <details> <summary>Earlier verification</summary> Checked `a156f8bbb737f79f9f63e594c9b39cb215c4a670` against a snapshot of the public GitHub Compare API. For `06c9f5505f63...main` the API returned `identical / 0`; for its first parent `afc5ee86ae3a...main` it returned `ahead / 2`. I replayed those two responses at the `gh api` subprocess boundary of `pr_check.py --repo xcl-dev/xcl --body <body> --files <files> --head <sha>`, checking the compare path and both requested fields. The local machine has no `gh` binary, so this covers the non-local checker code and the API response fields, with no Actions run. With synthetic frames of 1,000 on the parent, 100 on the tip, and 110 on the PR, both block orders selected the tip and passed. The parent alone failed and printed the two-commit distance. A dirty tip alone failed with the clean-checkout diagnostic. All four cases printed the expected baseline distances. `python -B -m unittest discover -s scripts -p test_pr_check.py` also passed all 15 tests. Windows 11 26100.9711, i7-13700, RTX 4060, Python 3.14.3. No Rust build, GPU workload, or retail runs. OpenAI Codex (GPT-6) retrieved the API data, ran these script fixtures and wrote the report. </details>
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/2230/head:github-bot/gh-2230'
git switch 'github-bot/gh-2230'

Merge

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