Skip to content

fix(github-bot): supersede prior CHANGES_REQUESTED on re-review#661

Open
donnfelker wants to merge 1 commit into
ColeMurray:mainfrom
donnfelker:upstream-github-bot-supersede-changes-requested
Open

fix(github-bot): supersede prior CHANGES_REQUESTED on re-review#661
donnfelker wants to merge 1 commit into
ColeMurray:mainfrom
donnfelker:upstream-github-bot-supersede-changes-requested

Conversation

@donnfelker
Copy link
Copy Markdown
Contributor

@donnfelker donnfelker commented May 20, 2026

Summary

  • When the bot is re-reviewing a PR, establish a baseline from its most recent opinionated review (APPROVED or CHANGES_REQUESTED) and weigh activity since that baseline rather than the full PR history.
  • After CHANGES_REQUESTED, if activity since baseline resolves the blocking issues, submit a follow-up APPROVE that supersedes the prior CHANGES_REQUESTED and unblocks the PR.
  • If new commits since baseline introduce a new blocking issue, submit REQUEST_CHANGES — a stale APPROVED is not auto-dismissed unless "Dismiss stale pull request approvals" is enabled in branch protection, so an explicit REQUEST_CHANGES is required.
  • Pass the configured bot username (GITHUB_BOT_USERNAME) into the prompt so the baseline lookup queries the correct author.
  • Mark GitHub comments as a "request" treatment in the untrusted-content envelope so the bot can act on them while still refusing instructions that try to override the prompt's safety rules.

Test plan

  • npm test -w @open-inspect/github-bot

Summary by CodeRabbit

  • New Features

    • Bot now establishes a baseline from its most recent review decision (approval or change request) and intelligently assesses subsequent activity to determine whether to provide feedback, approve, or request changes.
  • Tests

    • Extended test coverage to verify baseline review filtering and updated prompt generation behavior for improved decision-making logic.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 735bfb2d-6fa3-46cd-b7c1-759b977f3309

📥 Commits

Reviewing files that changed from the base of the PR and between 377b195 and c9234c0.

📒 Files selected for processing (4)
  • packages/github-bot/src/handlers.ts
  • packages/github-bot/src/prompts.ts
  • packages/github-bot/test/handlers.test.ts
  • packages/github-bot/test/prompts.test.ts

📝 Walkthrough

Walkthrough

The PR enhances the GitHub bot's comment-action prompt with a baseline-review mechanism. The bot now requires its own username to query its most recent opinionated review, establish a re-review baseline, assess activity since that point, and decide whether to reply, approve, or request changes. Handlers now pass the bot username through to the updated prompt builder, and comprehensive tests verify the new behavior.

Changes

Bot baseline re-review feature

Layer / File(s) Summary
API contract and content treatment updates
packages/github-bot/src/prompts.ts
buildCommentActionPrompt signature now requires botUsername: string parameter; buildUntrustedUserContentBlock accepts optional treatment parameter ("request" | "context") with conditional safety warning text.
Baseline re-review prompt logic
packages/github-bot/src/prompts.ts
Comment-action prompt now includes expanded instructions using botUsername to query and establish a re-review baseline from the bot's most recent opinionated review (APPROVED/CHANGES_REQUESTED), assess activity since that baseline, and guide the model to decide between reply, approval, or request-changes; reply-to-review-thread instruction step renumbered from 5 to 7.
Handler pass-through of bot username
packages/github-bot/src/handlers.ts
handleIssueComment and handleReviewComment now extract and pass env.GITHUB_BOT_USERNAME to buildCommentActionPrompt.
Test assertions and comprehensive validation
packages/github-bot/test/handlers.test.ts, packages/github-bot/test/prompts.test.ts
Handler tests verify baseline-review jq selector (select(.author.login=="test-bot[bot]")) is included in prompt content; prompt tests add botUsername to all test parameters, update expected instruction text about treating comments as user requests, and introduce comprehensive test coverage for baseline selection rules, activity weighting since baseline, new-blocker enforcement, code re-reading verification, and decision guidance ordering.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • ColeMurray

Poem

🐰 A baseline bloom, the bot now knows—
Where once it stood, to that place it goes.
Fresh eyes on changes since its last review,
Smart decisions made, decisions true!
Re-review refined, with username as guide. 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: enabling the bot to supersede a prior CHANGES_REQUESTED review on re-review, which is the core functionality added across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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