Skip to content

feat(alpha): refuse merge on a stale base - #336

Open
tbhb-agent wants to merge 3 commits into
mainfrom
agent/tools-merge-stale-base
Open

tbhb-agent wants to merge 3 commits into
mainfrom
agent/tools-merge-stale-base

Conversation

@tbhb-agent

@tbhb-agent tbhb-agent commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Pull requests that each pass CI can break main together when they change the same package. CI ran against the old base, and alpha merge didn't look at what main gained since.

Behavior change

alpha merge fetches the base and the pull request head, then lists changed paths with local git diff --name-status -M -z from the merge base to each side. The listing uses null-byte separators and includes rename and copy sources. If the base gained commits in a directory the pull request also changes, the command refuses, names the directories, and says to rerun CI against current main. If the base moved only in other directories, it warns on stderr and merges. The command stops when a git read fails, when the fetched head differs from the pull request's head, or when the pull request has an empty file list. It fetches the base again right before the merge call and refuses if the tip moved.

Risk

The command doesn't check a push to the base after that last fetch, so the remaining window is the time between the fetch and gh pr merge, a few seconds. GitHub's own merge checks and the head match cover that window. A pull request that touches a busy directory needs a CI rerun more often. The directory match is coarse, so a refusal can happen with no real conflict.

Verification

pytest passes the merge test file with 100% line and branch coverage for squash_merge.py. ruff, pyrefly and complexipy pass. CI runs the full Bazel suite.

Opened-by: LLM effort=medium;harness=claude-code:2.1.322;model=anthropic:claude-sonnet-5-5;session=sha-256-64:24ed779d56b187de;surface=cli
Generated-by: LLM effort=medium;harness=claude-code:2.1.322;model=anthropic:claude-sonnet-5-5;session=sha-256-64:24ed779d56b187de;started_at=2026-11-15T16:51:11Z;surface=cli

Generated-by: LLM effort=medium;harness=claude-code:2.1.322;model=anthropic:claude-sonnet-5-5;session=sha-256-64:24ed779d56b187de;started_at=2026-11-15T16:51:11Z;surface=cli
@tbhb-agent
tbhb-agent requested a review from tbhb as a code owner November 23, 2026 13:52
Generated-by: LLM effort=medium;harness=claude-code:2.1.322;model=anthropic:claude-sonnet-5-5;session=sha-256-64:24ed779d56b187de;started_at=2026-11-15T16:51:11Z;surface=cli
Generated-by: LLM effort=medium;harness=claude-code:2.1.322;model=anthropic:claude-sonnet-5-5;session=sha-256-64:24ed779d56b187de;started_at=2026-11-15T16:51:11Z;surface=cli

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant