Guard pr-reviewer READY sentinel on CI and mergeability#48
Conversation
|
CodeAnt AI is reviewing your PR. |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe PR adds verification logic to validate that a PR is actually mergeable and all required status checks are passing/completed before allowing the READY state. A new ChangesPR Readiness Verification
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
| const checks = Array.isArray(state.statusCheckRollup) ? state.statusCheckRollup : []; | ||
| return checks.every(checkPassedAndComplete); |
There was a problem hiding this comment.
Suggestion: statusCheckRollup is treated as optional and silently coerced to an empty array when missing or in an unexpected shape, and every() on an empty array returns true. That can incorrectly mark a PR as human-ready and send Slack READY notifications even when check data is unavailable/unknown. Treat missing or non-array check data as not-ready instead of ready. [incorrect condition logic]
Severity Level: Major ⚠️
- ⚠️ Slack channel pings even when CI status data missing.
- ⚠️ Humans may review before confirming all required checks passed.Steps of Reproduction ✅
1. Trigger any GitHub event handled by the agent (e.g., `pull_request.synchronize`) so the
default handler in `review/agent.ts:66-108` calls `reviewAndFix(ctx, pr)` at
`review/agent.ts:208-246` for an open PR.
2. Let the review harness complete successfully and emit output whose last line is exactly
`READY`, so `reviewAndFix` sets `harnessReady` to true and calls
`verifyReadyForHumanReview(ctx, pr)` at `review/agent.ts:223-232`.
3. Ensure the runtime's `gh pr view --json mergeable,statusCheckRollup` invocation in
`verifyReadyForHumanReview` (`review/agent.ts:279-289`) returns JSON where `mergeable` is
`"MERGEABLE"` but `statusCheckRollup` is missing or `null` (e.g., due to an older `gh`
version or an API shape change), so `parsePrReadyState` (`review/agent.ts:317-320`)
produces `{ mergeable: 'MERGEABLE' }` with `statusCheckRollup` undefined.
4. Observe `prReadyStateAllowsHumanReview` at `review/agent.ts:322-325` treat the missing
`statusCheckRollup` as an empty array (`checks = []`), so
`checks.every(checkPassedAndComplete)` returns `true`; `verifyReadyForHumanReview` returns
`true`, causing `reviewAndFix` to set `ready` to `true` and send the READY Slack
notification at `review/agent.ts:233-245`, even though the code had no usable check-rollup
data to confirm CI status.Fix in Cursor | Fix in VSCode Claude
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** review/agent.ts
**Line:** 324:325
**Comment:**
*Incorrect Condition Logic: `statusCheckRollup` is treated as optional and silently coerced to an empty array when missing or in an unexpected shape, and `every()` on an empty array returns `true`. That can incorrectly mark a PR as human-ready and send Slack READY notifications even when check data is unavailable/unknown. Treat missing or non-array check data as not-ready instead of ready.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| if (state) return state === 'SUCCESS' || state === 'NEUTRAL'; | ||
| const status = normalizeState(record.status); | ||
| const conclusion = normalizeState(record.conclusion); | ||
| return status === 'COMPLETED' && (conclusion === 'SUCCESS' || conclusion === 'NEUTRAL'); |
There was a problem hiding this comment.
Suggestion: Check runs with conclusion: SKIPPED are currently treated as failing because only SUCCESS and NEUTRAL are accepted. In GitHub check semantics, skipped checks are non-failing (and this file already treats skipped as non-failure in ciFailed), so this logic can wrongly downgrade READY and suppress valid human-review notifications. [api mismatch]
Severity Level: Critical 🚨
- ❌ READY Slack notification suppressed when checks finish with SKIPPED.
- ⚠️ Humans may not be notified about review-ready pull requests.Steps of Reproduction ✅
1. Configure a GitHub check or workflow that can legitimately finish with `conclusion:
"skipped"` (e.g., via a conditional job), so GitHub's `statusCheckRollup` for a PR can
contain entries with `status: "COMPLETED"` and `conclusion: "SKIPPED"`.
2. For that PR, trigger the agent (e.g., with `pull_request.opened` or
`pull_request.synchronize`) so the handler in `review/agent.ts:66-108` calls
`reviewAndFix(ctx, pr)` at `review/agent.ts:208-246`, and ensure the harness emits output
ending in `READY` so `verifyReadyForHumanReview(ctx, pr)` is invoked
(`review/agent.ts:223-232`).
3. When `verifyReadyForHumanReview` runs `gh pr view --json mergeable,statusCheckRollup`
and parses the result via `parsePrReadyState` (`review/agent.ts:279-320`), it passes the
`statusCheckRollup` list to `prReadyStateAllowsHumanReview` (`review/agent.ts:322-325`),
which calls `checkPassedAndComplete` for each check at `review/agent.ts:328-335`; for a
`COMPLETED`/`SKIPPED` check, `normalizeState` (`review/agent.ts:338-340`) yields `status
=== 'COMPLETED'` and `conclusion === 'SKIPPED'`, causing `checkPassedAndComplete` to
return `false` because it only accepts `SUCCESS` or `NEUTRAL`.
4. Because at least one check returns `false` from `checkPassedAndComplete`,
`prReadyStateAllowsHumanReview` returns `false`, `verifyReadyForHumanReview` logs a
`pr-reviewer.ready-sentinel.downgraded` warning at `review/agent.ts:292-299`, and
`reviewAndFix` sets `ready` to `false` at `review/agent.ts:231-245`; as a result, even
though all checks are non-failing (consistent with `ciFailed` treating `skipped` as
non-failure at `review/agent.ts:525-528`), the READY Slack notification is never sent for
this PR.Fix in Cursor | Fix in VSCode Claude
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** review/agent.ts
**Line:** 335:335
**Comment:**
*Api Mismatch: Check runs with `conclusion: SKIPPED` are currently treated as failing because only `SUCCESS` and `NEUTRAL` are accepted. In GitHub check semantics, skipped checks are non-failing (and this file already treats skipped as non-failure in `ciFailed`), so this logic can wrongly downgrade READY and suppress valid human-review notifications.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix|
CodeAnt AI finished reviewing your PR. |
|
Fixed one readiness-gate bug: Validation passed locally:
I did not verify remote CI or GitHub mergeability from here. |
|
Fixed the validated review findings in the checked-out PR code:
Validation passed locally:
I also checked the public PR page and it now shows PR #48 as merged on June 5, 2026, so I’m not ending with |
|
Fixed the validated review findings in the checked-out PR code:
Validation passed locally:
I also checked the public PR page and it now shows PR #48 as merged on June 5, 2026, so I’m not ending with |
User description
Summary
Tests
Summary by cubic
Guard the READY sentinel so we only ping Slack when the PR is mergeable and all required checks are complete and passing. READY is now verified against GitHub mergeability and
statusCheckRollup; if not satisfied, we downgrade and log instead of notifying.Bug Fixes
mergeable,statusCheckRollup) usinggh pr view; suppress Slack ping and log a warning when checks are pending/in‑progress/failed or the PR isn’t mergeable.Migration
gh) installed and authenticated; the agent callsgh pr view --json mergeable,statusCheckRollup.Written for commit cfba4f1. Summary will update on new commits.
CodeAnt-AI Description
Only send READY when the PR is actually mergeable and checks are finished
What Changed
Impact
✅ Fewer premature READY alerts✅ Fewer Slack pings on blocked PRs✅ Clearer handoff only when review can move forward💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.