fix(ci): revalidate readiness when CodeRabbit finds new issues - #1175
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR enables findings-gate reruns from authorized CodeRabbit pull-request comments. It adds stable outside-diff finding tracking, clean-review clearing, legacy count fallback, and workflow and state tests. ChangesCodeRabbit revalidation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CodeRabbit as CodeRabbit review
participant GitHub as GitHub issue_comment event
participant Actions as GitHub Actions job
participant Gate as PR findings gate
CodeRabbit->>GitHub: Publish review or status comment
GitHub->>Actions: Emit pull-request comment event
Actions->>Actions: Validate pull request and commenter
Actions->>Gate: Recheck unresolved findings
Gate->>CodeRabbit: Read latest live-head review markers
CodeRabbit-->>Gate: Return deduplicated finding state
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 |
|
✅ Deterministic PR hygiene checks passed. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/pr-coderabbit-readiness-revalidation.test.ts`:
- Around line 38-42: Strengthen the script-content assertions in the readiness
revalidation test so they verify the actual issue_comment rejection condition,
requiring !isCanonicalMaintainer within the branch where !isCodeRabbit is true.
Keep the existing symbol-presence checks, but add a focused assertion tied to
the authorization expression rather than merely matching predicates
independently.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 774eba9c-f2d6-4b8d-bd62-bf87b1ab63cc
📒 Files selected for processing (2)
.github/workflows/enforce-pr-target.ymltests/pr-coderabbit-readiness-revalidation.test.ts
cba3840 to
be5857f
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/enforce-pr-target.yml:
- Around line 45-48: Update the CodeRabbit-triggered issue_comment path in
enforce-pr-target.yml so the .github/scripts checkout uses
github.event.repository.default_branch (falling back to dev only when
appropriate) instead of the pull request base SHA. Make this selection
conditional on an explicit branch-policy decision, ensuring privileged script
execution is sourced from the repository’s default branch or otherwise blocked
until scripts are promoted there.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c99d4175-a40a-4a0c-be42-a16f56d307b1
📒 Files selected for processing (2)
.github/workflows/enforce-pr-target.ymltests/zz-pr-coderabbit-readiness-revalidation.test.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/scripts/pr-quality-state.cjs:
- Around line 252-272: Update the sort comparator in
latestCodeRabbitReviewForHead to handle non-finite submittedAt values without
producing NaN: only subtract timestamps when both are finite, otherwise proceed
to the numeric review-ID tie-breaker. Add a regression case covering two
live-head CodeRabbit reviews with missing or invalid submitted_at values and
verify the higher review ID is selected deterministically.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 47c4ae59-5113-47b5-ab75-1215d526d945
📒 Files selected for processing (2)
.github/scripts/pr-quality-outside-diff.test.cjs.github/scripts/pr-quality-state.cjs
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/zz-pr-coderabbit-readiness-revalidation.test.ts`:
- Around line 36-38: Update the checkout ref assertion in the readiness
revalidation test to match the current enforce-pr-target workflow expression,
including its fallback to the documented dev integration branch. Preserve the
test’s validation of the remaining gate behavior and use the existing workflow
contract rather than introducing a different checkout expectation.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: b5656ab0-7c6e-41ee-af13-a7467b75d322
📒 Files selected for processing (3)
.github/scripts/pr-quality-outside-diff.test.cjs.github/scripts/pr-quality-state.cjstests/zz-pr-coderabbit-readiness-revalidation.test.ts
43d1567 to
9d43c05
Compare
b2c6cbb to
b093eac
Compare
Summary
issue_commentpath restricted to CodeRabbit or canonical maintainerscr-comment:v1:<id>identitiesRoot cause
PR #1163 was marked ready around 01:32 UTC. CodeRabbit then posted a new unresolved finding at 01:35:10 UTC and updated its normal PR status comment at 01:35:33 UTC.
The gate already listens for
issue_commentedits and already knows how to invalidate the "Codex and CodeRabbit findings" checklist claim. However, its write-capable issue-comment guard only admitted canonical maintainers, so CodeRabbit's status-comment update was ignored. With no later privileged gate run, the PR stayed Ready for Review withreview-readydespite the new finding.A second edge case is tracked in #1182. CodeRabbit findings that cannot attach inline live in the review body. The previous gate supplemented those immutable review-body findings only while an unrelated bot review thread remained unresolved, so a standalone outside-diff finding could disappear from the gate when the last inline thread was resolved.
Why this signal
Direct
pull_request_review_commenthandling is not sufficient for contributor fork PRs because that event'sGITHUB_TOKENis read-only for forks. CodeRabbit's regular PR status comment produces anissue_commentevent in the base repository, where the existing trusted gate can re-read the live review threads and reviews and perform its normal draft/label/checklist mutations.The CodeRabbit status-comment body is not used as evidence. Its create/edit event is only a trigger signal; the gate verifies live review state through the existing trusted-base code.
Durable outside-diff findings
CodeRabbit embeds each finding that cannot be posted inline with a stable marker such as
cr-comment:v1:<id>. The gate now reads those markers from the latest CodeRabbit review for the live head independently of normal review-thread state.That means:
Actionable comments posted: Nvalue is not used as the identity/count for marker-aware outside-diff findings, avoiding double-counting normal inline findingsThis keeps the resolution path entirely in trusted bot review state: no PR-head review workflow and no new privileged maintainer command are required.
Addresses #1182.
Behavior after this change
When CodeRabbit updates its PR status comment after a review:
review-readyis removedNormal non-maintainer comments still cannot invoke the write-capable gate.
Deployment note
GitHub only triggers
issue_commentworkflows when the workflow file exists on the repository's default branch. The repository default ismain, while contributions targetdev, so this new CodeRabbit path becomes active when this workflow revision is promoted tomain.Test plan
issue_commentstill handlescreatedandeditedcr-commentidentity parsing, standalone outside-diff blocking, no aggregate double-count, same-head clean-review resolution, head scoping, human-review exclusion, and marker de-duplicationSummary by CodeRabbit
Bug Fixes
Tests