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

Open
Creaa wants to merge 1 commit from upstream-pr/2230 into main
Creaa commented 2026-11-25 10:46:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Creaa on 2026-11-25T10:46:47Z.


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

<!-- greyfinch-sync:ivall/xcl:issue:5489816044 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2230). Originally posted by [Creaa](https://github.com/Creaa) on 2026-11-25T10:46:47Z. --- 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)
itsonewi commented 2026-11-25 11:09:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by itsonewi on 2026-11-25T10:51:40Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7160269972 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7160269972). Originally posted by [itsonewi](https://github.com/itsonewi) on 2026-11-25T10:51:40Z. --- 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.
Creaa commented 2026-11-25 11:09:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Creaa on 2026-11-25T10:58:59Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7160430264 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7160430264). Originally posted by [Creaa](https://github.com/Creaa) on 2026-11-25T10:58:59Z. --- 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.
raylitebull commented 2026-11-25 11:09:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T11:00:39Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7160466261 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7160466261). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-25T11:00:39Z. --- 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.
itsonewi commented 2026-11-25 11:09:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by itsonewi on 2026-11-25T11:03:02Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7160519903 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7160519903). Originally posted by [itsonewi](https://github.com/itsonewi) on 2026-11-25T11:03:02Z. --- 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`.
raylitebull commented 2026-11-25 11:09:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T11:03:15Z.


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).
<!-- greyfinch-sync:ivall/xcl:comment:7160524448 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7160524448). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-25T11:03:15Z. --- 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`).
RavenCurseBurg commented 2026-11-25 14:10:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-25T14:05:41Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7164747386 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7164747386). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T14:05:41Z. --- 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://github.com/xcl-dev/xcl/pull/1056#issuecomment-7179432645). 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>
throny commented 2026-11-26 01:05:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-26T00:58:30Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7179299155 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7179299155). Originally posted by [throny](https://github.com/throny) on 2026-11-26T00:58:30Z. --- <!-- 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.
github-actions[bot] commented 2026-11-30 08:40:51 +00:00 (Migrated from github.com)

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


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:7273209167 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7273209167). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T08:40:51Z. --- 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 07:38:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:38:09Z.


Triage (#1607) – head a156f8b

#2235 is stacked on this PR (it contains a156f8b). #1056 and #2406 also make pr_check refuse a main block with uncommitted changes: #1056 does only that (plus CONTRIBUTING wording), which this PR also does. #2406 does it differently and requires the main block to be on the PR's exact base commit instead of choosing the newest main block.
No problems found in the diff. main_behind is called a second time for the chosen baseline, which costs one more API call per run but is harmless.
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:7304297377 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2230#issuecomment-7304297377). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:38:09Z. --- **Triage (#1607)** – head a156f8b #2235 is stacked on this PR (it contains a156f8b). #1056 and #2406 also make pr_check refuse a main block with uncommitted changes: #1056 does only that (plus CONTRIBUTING wording), which this PR also does. #2406 does it differently and requires the main block to be on the PR's exact base commit instead of choosing the newest main block. No problems found in the diff. `main_behind` is called a second time for the chosen baseline, which costs one more API call per run but is harmless. 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/2230:upstream-pr/2230'
git switch 'upstream-pr/2230'

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