Skip to content

fix(review): review a pull request at the merge base of its base branch - #5387

Merged
dan-petty merged 3 commits into
mainfrom
fix/5346-review-pr-merge-base
Nov 13, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/5346-review-pr-merge-base

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

devops review pr and devops ai analyze pr read the files of a pull request from the compare of the tip of its base branch and its head commit. This is the diff that a squash merge applies. The review reads the diff from the merge base of that compare. It reads the base text and the base conventions at that merge base, and makes the base worktree there.

Before, both commands read the pulls files endpoint, and the review read the pulls diff and the payload's base.sha. GitHub does not move these when a merge of the base branch into the pull request moves its merge base. Thus the review read the changes of main as changes of the pull request.

GitHub lists at most 300 files of one compare. At that limit, devops review pr stops and names devops review branch, and devops ai analyze pr warns.

Closes #5346

Change: openspec/changes/archive/2026-11-13-5346-review-pr-merge-base/

devops review pr read the files of a pull request from the pulls files
endpoint, its diff from the pulls endpoint, and its base text at the
merge base of the payload's base.sha. GitHub does not move base.sha when
a merge commit moves the merge base, so after a merge of main into a
pull request branch the review read the changes of main as changes of
the pull request. devops ai analyze pr read the same stale file list.

Both commands now read the compare of the tip of the base branch and the
head commit, which is the diff that the squash merge applies. The review
reads the diff, the base text, the conventions and the base worktree at
the merge base of that compare. A compare at the 300-file limit ends the
review with a message that names devops review branch, and gives the
analysis a warning. GitHubClient.get_compare_files returns the merge
base, GitHubClient.get_compare_diff reads the compare diff, and the
change deletes get_pull_files and get_merge_base, which have no caller.

Refs #5346
BaseRevision.revision now holds the merge base of a pull request, so its
docstring tells that. The diff media type is also the media type of a
comparison diff. The test of the posted comment shows that the command
reads the file list of the compare one time only.
Move the change of #5346 to the archive and add the living capability pr-squash-diff.
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/review Multi-persona code review engine, verification, and findings labels Nov 13, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test and check results

Builder (commit 46ab2fc77):

  • Premise check, live on 2026-11-13: pulls/2509 gave base.sha 0137f23 and 184 changed files. compare/0137f231...344adba9 gave 184 files. compare/main...344adba9 gave merge base 5c4d24e and 11 files. The pulls diff held 184 file headers and the compare diff held 11. The proposal ## Feasibility section records this.
  • uv run devops ci test on the changed test files before the fix: 29 failed, 166 passed.
  • uv run devops ci fail-to-pass --base origin/main: 30 tests failed on the base and pass on the head, for example test_a_pr_review_reads_the_changes_at_the_merge_base_of_its_base_branch, test_a_pr_review_refuses_a_comparison_at_the_file_limit, test_run_pr_review_workflow_with_worktree and test_analyze_pr_reads_the_files_at_the_merge_base_of_its_base_branch.
  • uv run devops ci test on 50 covering test files and the contract, worktree, invariant, change-folder, living-spec and MCP tests: 2188 passed.

Review (commit 03b6aac40):

  • The BaseRevision.revision docstring said that a pull request base has no revision. It now names the merge base. The comment of CONST_GITHUB_DIFF_MEDIA_TYPE now also names a comparison diff.
  • The test of the posted comment now shows that the command reads the compare file list one time only, as the spec scenario says.
  • docs/SELF_IMPROVEMENT.md: the edited paragraph is wrapped at 100 columns again.
  • uv run devops ci test on the 13 covering test files (review scope, review post, runner, path routing, analyze, GitHub client, contract, merge readiness, draft readiness, pr command, worktree regression, task metadata, batch 2 review defects): 374 passed.
  • uv run devops ci --check --only lint,format,domain,constructs,docs,openspec,test-tree,swallowed-failures,startup-imports,typecheck: all pass. uv run devops openspec check: pass.

Render diff

The branch changes no path under k8s/ and no chart values. No render diff exists, and no pod restarts.

@dan-petty

Copy link
Copy Markdown
Owner Author

Check results

Head commit: 99b6f10605c6ca3d372487f4d9490bab8779b4b3

Check Conclusion Link
Tests & Coverage success run
devops-cli success run
zizmor success run
trivy-config success run
CodeQL success run
Plan Check skipped run
Dependency Freshness skipped run
Tests on Main skipped run
Test Job Duration skipped run
Analyze (python) success run
Analyze (actions) success run
Changed-Test Independence success run
MCP Server Image success run
Tests & Coverage (shard 3 of 4) success run
Tests & Coverage (shard 2 of 4) success run
Design Tokens success run
Runner Image success run
Service Image success run
Tests & Coverage (shard 4 of 4) success run
Tests & Coverage (shard 1 of 4) success run
Static Analysis success run
Docs Site Build success run
Fail-to-Pass Check success run
Semantic PR title success run

Fail-to-pass run: https://github.com/dan-petty/devops-cli/actions/runs/43391201661/job/131771254031

Skipped check: Plan Check
Skipped check: Dependency Freshness
Skipped check: Tests on Main
Skipped check: Test Job Duration

@dan-petty
dan-petty marked this pull request as ready for review November 13, 2026 08:17
@dan-petty
dan-petty merged commit 351ba2a into main Nov 13, 2026
24 checks passed
@dan-petty
dan-petty deleted the fix/5346-review-pr-merge-base branch November 13, 2026 11:35
dan-petty added a commit that referenced this pull request Nov 13, 2026
…base (#5401)

The Jev completeness check of the row `stage_ready` read the diff of the
pulls endpoint, and the pick of the scheduled release merge read the
pulls files list. GitHub can keep a stale `base.sha` after a merge
commit moves the merge base of a pull request. Then these reads hold
files of other changes: Jev judges a plan with files that the plan does
not change, and the release guard refuses a release pull request for a
file of `main`.

Both readers now read the compare of the base branch and the head
commit, which is the diff that the squash merge applies. The new
`GitHubClient.get_compare_diff` reads that diff and shares one diff read
with `get_pr_diff`. The pick reads the files with `get_compare_files`.

Item 2 of the issue, the review of a pull request that a merge commit
merged, moves to #5397: the compare read of `devops review pr` is only
in the open pull request #5387.

Closes #5388

Change:
`openspec/changes/archive/2026-11-13-5388-pr-change-reads-merge-base/`
dan-petty added a commit that referenced this pull request Nov 13, 2026
PR #5387 and PR #5401 merged two minutes apart, and each added
`GitHubClient.get_compare_diff` to `src/devops_cli/github/client.py`
with the same body. Git merged both with no conflict, so `main` defines
the method twice: ruff F811 and mypy `no-redef` fail, the Static
Analysis check of `main` fails, and the pre-push hook refuses every
branch that holds this `main` (#5389 and #5400 wait for this fix). This
change keeps one method and names both callers (#5346, #5388) in its
docstring. The body does not change, so no behavior changes.

Closes #5404
Change:
`openspec/changes/archive/2026-11-13-5404-main-defines-get-compare-diff-twice/`
dan-petty pushed a commit that referenced this pull request Nov 13, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.127.1](v0.127.0...v0.127.1)
(2026-11-13)


### Bug Fixes

* **ci:** alarm at 360 s, one P0 issue, shards by recorded time
([#5377](#5377))
([2abd6ff](2abd6ff))
* **github:** read the plan diff and the release files from the merge
base ([#5401](#5401))
([c54e14c](c54e14c))
* **infra:** turn off the Ansible color of every playbook run
([#5381](#5381))
([5bafb1a](5bafb1a)),
closes [#5352](#5352)
* install-tools --check passes an older openspec binary
([#5355](#5355))
([625c89d](625c89d))
* **k8s:** allow only the Ingress origins in Open WebUI
([#5357](#5357))
([fdab229](fdab229))
* **pr:** count only the latest run of each check
([#5393](#5393))
([634dc91](634dc91))
* **review:** drop the fixed gateway URL of the review dry run
([#5399](#5399))
([0666d3d](0666d3d))
* **review:** review a pull request at the merge base of its base branch
([#5387](#5387))
([351ba2a](351ba2a)),
closes [#5346](#5346)
* **roadmap:** end fix-plan at a time budget with a result line
([#5380](#5380))
([20468f4](20468f4)),
closes [#5363](#5363)
* **roadmap:** refine skips an item that changed during the write
([#5392](#5392))
([a863dda](a863dda))
* **roadmap:** stage writes RENAMED and REMOVED spec deltas
([#5367](#5367))
([4abbbd2](4abbbd2))
* **roadmap:** title the delivery by the summary of its plan
([#5376](#5376))
([10e1069](10e1069))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/review Multi-persona code review engine, verification, and findings type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(review): Review a pull request at the merge base of its base branch

1 participant