Skip to content

ci(mutants): diff against the pull request's real base, read from the API - #1381

Merged
coderdan merged 2 commits into
nextfrom
ci/mutants-diff-against-pr-base
Oct 26, 2026
Merged

coderdan merged 2 commits into
nextfrom
ci/mutants-diff-against-pr-base

Conversation

@coderdan

Copy link
Copy Markdown
Contributor

Summary

The mutation-testing gate (Mutants workflow) runs cargo mutants over the lines a pull request changes in stack-auth and stack-encrypt. It found those lines with git diff origin/<base> where the base came from the workflow's github.base_ref. On the json_tree Go stack that variable was wrong: for a pull request whose base branch is itself the head of another open pull request, GitHub built the test merge commit against the other pull request's merge commit and reported the other pull request's base. PR #1369, which targets next, arrived with main as its base because next has an open pull request into main; the stacked pull requests above it arrived with their grandparents' bases. The gate then diffed everything between main and next, 670 to 800 files, and timed out at two hours on changes that touched no Rust.

This change makes the gate ask GitHub for the pull request's real base at run time and diff that against the pull request's head. A Go-only pull request yields no mutants again and finishes in minutes; a Rust pull request mutates exactly its own lines.

Changes

  • .github/workflows/mutants.yml: the "Compute the PR diff" step reads the base branch and commit with gh pr view, fetches that commit and the head, and diffs base...head. The log prints the base it used beside what the event payload said, and the list of files under mutation instead of the whole diff. The job's token already has the pull-request scope the sticky comment needs.

Verification

Related

https://claude.ai/code/session_01N7bCqa3ZVJMcEE99RzVqEu

… API

The gate scopes cargo-mutants to the PR's diff, which it took as
`git diff origin/$GITHUB_BASE_REF`. For a pull request whose base branch
is itself the head of another open pull request, GitHub has been seen to
build the test merge commit against that other PR's merge commit and to
report the other PR's base in `github.base_ref`: a PR into `next` while
`next` has a PR into `main` arrived here with `main` as its base, and the
stacked PRs above it with their grandparents' bases. The diff was then
everything between `main` and `next`, 670 to 800 files, and the gate hit
its two-hour timeout on changes that touched no Rust at all.

The step now asks `gh pr view` for the base the PR page shows, fetches
that commit and the PR head, and diffs the two with three dots, so the
diff holds the PR's own lines whatever GitHub checked out. The log names
the base it used beside what the payload said, and lists the files under
mutation instead of printing the whole diff.

Claude-Session: https://claude.ai/code/session_01N7bCqa3ZVJMcEE99RzVqEu
@changeset-bot

changeset-bot Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a849cac

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.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI; Enforced overrides: Organization
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 41b3fc72-6b65-4f0b-814f-c0548c87c6e4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Mutation testing (cargo-mutants, --in-diff, stack-auth + stack-encrypt)

No mutants were generated for the changed lines.

@coderdan
coderdan marked this pull request as ready for review October 26, 2026 08:14
@coderdan
coderdan requested a review from a team as a code owner October 26, 2026 08:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T08:17:06.245238Z 98edbe7 Draft marked ready
🔒 Security Review ✅ Completed 2026-10-26T08:23:25.290070Z 98edbe7 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cipherstash-agent cipherstash-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review attestation

Source: Claude Code /code-review medium, with company-skills:cross-check-review-findings run against head 98edbe7.

Critical/blocking issues: none.

Findings: 1 new minor, non-blocking finding (inline). The diff uses the PR head's line numbers, but mutants run on the checked-out merge commit, so --in-diff can mismatch lines when the base has diverged. Suggested fix: check out the head SHA.

Cross-check: there were no prior review threads or reviews. The bot comments contain no findings. Nothing was dropped as already covered.

Checked and fine:

  • fetch-depth: 0 makes the three-dot merge-base work.
  • pull-requests: write covers gh pr view.
  • The || echo "(none)" fallback works under the -eo pipefail shell GitHub uses for shell: bash.

Generated by Claude Code

Comment thread .github/workflows/mutants.yml Outdated

@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: 98edbe7215

ℹ️ 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".

Comment thread .github/workflows/mutants.yml Outdated
…e tree

The previous commit diffed the base against the PR head while
actions/checkout left GitHub's test merge commit in the tree. If the
base had moved and touched earlier lines of a file the PR changes, the
hunks' line numbers no longer matched the tree, and cargo-mutants 27.1.0
refuses such a diff ("Diff content doesn't match source file"), failing
the gate on a valid PR. The checkout now takes the PR head on a pull
request, the diff step asserts that is what it has, and diffs the base
against it. A manual dispatch checks out the default ref as before.

Claude-Session: https://claude.ai/code/session_01N7bCqa3ZVJMcEE99RzVqEu
@coderdan
coderdan merged commit 7a6d070 into next Oct 26, 2026
29 checks passed
@coderdan
coderdan deleted the ci/mutants-diff-against-pr-base branch October 26, 2026 08:28
coderdan added a commit that referenced this pull request Oct 26, 2026
Brings in the mutants gate fix from #1381, which reads the pull request's real base from the API and checks out the head, so the gate no longer diffs all of next and times out on this stack.

Claude-Session: https://claude.ai/code/session_01N7bCqa3ZVJMcEE99RzVqEu
coderdan added a commit that referenced this pull request Oct 26, 2026
…profile

Brings in the mutants gate fix from #1381, which reads the pull request's real base from the API and checks out the head, so the gate no longer diffs all of next and times out on this stack.

Claude-Session: https://claude.ai/code/session_01N7bCqa3ZVJMcEE99RzVqEu
coderdan added a commit that referenced this pull request Oct 26, 2026
Brings in the mutants gate fix from #1381, which reads the pull request's real base from the API and checks out the head, so the gate no longer diffs all of next and times out on this stack.

Claude-Session: https://claude.ai/code/session_01N7bCqa3ZVJMcEE99RzVqEu
coderdan added a commit that referenced this pull request Oct 26, 2026
Brings in the mutants gate fix from #1381, which reads the pull request's real base from the API and checks out the head, so the gate no longer diffs all of next and times out on this stack.

Claude-Session: https://claude.ai/code/session_01N7bCqa3ZVJMcEE99RzVqEu
coderdan added a commit that referenced this pull request Oct 26, 2026
Brings in the mutants gate fix from #1381, which reads the pull request's real base from the API and checks out the head, so the gate no longer diffs all of next and times out on this stack.

Claude-Session: https://claude.ai/code/session_01N7bCqa3ZVJMcEE99RzVqEu
coderdan added a commit that referenced this pull request Oct 26, 2026
Brings in the mutants gate fix from #1381, which reads the pull request's real base from the API and checks out the head, so the gate no longer diffs all of next and times out on this stack.

Claude-Session: https://claude.ai/code/session_01N7bCqa3ZVJMcEE99RzVqEu
coderdan added a commit that referenced this pull request Oct 26, 2026
Brings in the mutants gate fix from #1381, which reads the pull request's real base from the API and checks out the head.

Claude-Session: https://claude.ai/code/session_01N7bCqa3ZVJMcEE99RzVqEu
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.

2 participants