Skip to content

fix(mcp): anchor PR context at merge base#397

Merged
ScriptedAlchemy merged 1 commit into
masterfrom
codex/pr-context-merge-base
Jul 9, 2026
Merged

fix(mcp): anchor PR context at merge base#397
ScriptedAlchemy merged 1 commit into
masterfrom
codex/pr-context-merge-base

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Summary

  • make pr_context use true three-dot PR semantics by diffing the merge base against the head
  • enumerate commits reachable from head but hidden by the merge base instead of walking first-parent until the moving base tip
  • detect the repository default branch when base_ref is omitted
  • expose the resolved merge-base hash in the result

Dogfood failure

Reviewing #389 from a branch whose origin/master had advanced made tracedecay tool pr_context report 299 files and up to 100 unrelated historical commits for a two-file PR. The same defect inflated another two-file review to 11 files. Raw git diff origin/master...HEAD showed the correct scope.

Tests

  • merge-base regression with a diverged feature branch: pass
  • git handler unit tests: 5 passed
  • MCP pr_context integration tests: 2 passed
  • cargo clippy --workspace --all-targets --locked -- -D warnings: pass

@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: b624387

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b624387028

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

fn default_pr_base_ref(project_root: &std::path::Path) -> String {
crate::branch::detect_default_branch(project_root).unwrap_or_else(|| "main".to_string())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Prefer the fetched remote default for omitted bases

When origin/HEAD is present, branch::detect_default_branch() strips refs/remotes/origin/ and returns only master/main. In repositories where the local default branch is stale but origin/<default> has been fetched, this omitted-base path passes the stale local ref into git_pr_comparison, so the merge base can move back before the PR fork point and pr_context again includes unrelated default-branch changes. Prefer the remote ref when that is what was detected, or otherwise verify the local ref is current.

Useful? React with 👍 / 👎.

@ScriptedAlchemy ScriptedAlchemy merged commit d93643b into master Jul 9, 2026
16 of 17 checks passed
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