-
-
Notifications
You must be signed in to change notification settings - Fork 40
The documented unstick for a rate-limited CodeRabbit (Require positive evidence for bot review gate items review) DEFEATS the bot-review gate: its auto-reply counts as a real review, flipping the gate green with zero review content
#3100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ### Fixed | ||
| - Bot-review gate no longer treats CodeRabbit's auto-reply notice (`<!-- This is an auto-generated reply by CodeRabbit -->`) as a real review. The notice is posted when a `@coderabbitai review` trigger is acknowledged but the review has not yet run (rate-limit recovery). Previously this auto-reply flipped the gate green with zero review content. | ||
| - `is_real_item()` now requires positive evidence of review content (APPROVED/CHANGES_REQUESTED state, walkthrough with Run ID + signals, inline findings, or structured review body with code/finding markers). The fail-open fallback that counted any unrecognised non-empty CodeRabbit comment as real has been removed. | ||
| - Added `is_coderabbit_auto_reply()` detector and folded it into `is_coderabbit_scaffolding()` as a third per-fragment detector, maintaining detector isolation so one regressing cannot mask another. | ||
| - The `bot-review-allow` waiver label continues to work for deliberate lead overrides of stub-only verdicts. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,8 +72,10 @@ | |
|
|
||
| # HTML comment markers and phrases that identify CodeRabbit auto-generated | ||
| # scaffolding that must never read as a real review: the acknowledgement | ||
| # reply posted when a @coderabbitai full review trigger is accepted but | ||
| # produces no review, and the failure notice posted when a review run fails. | ||
| # reply posted when a @coderabbitai review trigger is accepted but | ||
| # produces no review, the failure notice posted when a review run fails, | ||
| # and the auto-reply notice posted when a @coderabbitai review trigger is | ||
| # acknowledged but the review has not yet run (rate-limit recovery notice). | ||
| # The auto-summary marker is intentionally NOT listed here: in this repo it | ||
| # is the walkthrough issue comment, the only review artifact on a clean PR, | ||
| # and is handled by the walkthrough detector below. | ||
|
|
@@ -88,12 +90,16 @@ | |
| r"failure by coderabbit\.ai|Review failed", | ||
| re.IGNORECASE, | ||
| ) | ||
| CODERABBIT_AUTO_REPLY_RE = re.compile( | ||
| r"<!-- This is an auto-generated reply by CodeRabbit -->", | ||
| re.IGNORECASE, | ||
| ) | ||
| CODERABBIT_AUTO_SUMMARY_RE = re.compile( | ||
| r"<!-- This is an auto-generated comment: summarize by coderabbit\.ai -->", | ||
| re.IGNORECASE, | ||
| ) | ||
| CODERABBIT_SCAFFOLDING_RE = re.compile( | ||
| rf"{CODERABBIT_ACKNOWLEDGEMENT_RE.pattern}|{CODERABBIT_FAILURE_RE.pattern}", | ||
| rf"{CODERABBIT_ACKNOWLEDGEMENT_RE.pattern}|{CODERABBIT_FAILURE_RE.pattern}|{CODERABBIT_AUTO_REPLY_RE.pattern}", | ||
| re.IGNORECASE, | ||
| ) | ||
|
|
||
|
|
@@ -248,7 +254,11 @@ def is_coderabbit_scaffolding(body: str | None) -> bool: | |
| single stub check see the same coverage; internal callers should prefer the | ||
| per-fragment detectors so a regression in one cannot be hidden by the other. | ||
| """ | ||
| return is_coderabbit_acknowledgement(body) or is_coderabbit_failure_notice(body) | ||
| return ( | ||
| is_coderabbit_acknowledgement(body) | ||
| or is_coderabbit_failure_notice(body) | ||
| or is_coderabbit_auto_reply(body) | ||
| ) | ||
|
|
||
|
|
||
| def is_coderabbit_acknowledgement(body: str | None) -> bool: | ||
|
|
@@ -281,6 +291,16 @@ def is_coderabbit_failure_notice(body: str | None) -> bool: | |
| return bool(CODERABBIT_FAILURE_RE.search(body)) | ||
|
|
||
|
|
||
| def is_coderabbit_auto_reply(body: str | None) -> bool: | ||
| """Return True if a body is CodeRabbit's auto-reply notice -- posted when | ||
| a @coderabbitai review trigger is acknowledged but the review has not yet | ||
| run (rate-limit recovery notice). This announces that a review has NOT | ||
| happened yet and must not read as a real review.""" | ||
| if not body: | ||
| return False | ||
| return bool(CODERABBIT_AUTO_REPLY_RE.search(body)) | ||
|
|
||
|
|
||
| def is_coderabbit_walkthrough(body: str | None) -> bool: | ||
| """Return True if a body is a CodeRabbit walkthrough issue comment that | ||
| represents a real review. | ||
|
|
@@ -371,23 +391,49 @@ def is_real_item(item: CRItem) -> bool: | |
| A rate-limit stub is never real. Review objects with state APPROVED or | ||
| CHANGES_REQUESTED are real regardless of body content (the review state | ||
| itself is the substantive signal). CodeRabbit scaffolding (acknowledgement | ||
| reply / failure notice) is never real. For issue comments carrying the | ||
| auto-summary marker, the walkthrough detector applies: a Run ID plus at | ||
| least one signal (quota-decrement line, no-actionable phrase, or | ||
| Files-processed list) means a real review ran. Other comments are real | ||
| when they carry non-empty, non-stub body text. | ||
| reply / failure notice / auto-reply) is never real. For issue comments | ||
| carrying the auto-summary marker, the walkthrough detector applies: a Run | ||
| ID plus at least one signal (quota-decrement line, no-actionable phrase, | ||
| or Files-processed list) means a real review ran. Review comments | ||
| (line-level discussion threads) with non-empty body are inline findings | ||
| and count as real. Other comments require positive evidence of review | ||
| content -- substantive body text that is not marker-only scaffolding. | ||
| """ | ||
| if is_rate_limit_stub(item.body): | ||
| return False | ||
| if item.is_review: | ||
| state = (item.review_state or "").upper() | ||
| if state in ("APPROVED", "CHANGES_REQUESTED"): | ||
| return True | ||
| # COMMENTED reviews fall through to body evidence checks below | ||
| if is_coderabbit_scaffolding(item.body): | ||
| return False | ||
| if not item.is_review and is_coderabbit_auto_summary(item.body): | ||
| return is_coderabbit_walkthrough(item.body) | ||
| return bool(item.body and item.body.strip()) | ||
| # Review comments (line-level) with non-empty body are inline findings. | ||
| # Other comments need positive evidence: substantive body that is not | ||
| # just a marker or short automated notice. | ||
| if item.body and item.body.strip(): | ||
| body = item.body.strip() | ||
| # Skip if body is only an HTML comment marker (scaffolding that | ||
| # wasn't caught by the specific detectors above). | ||
| if body.startswith("<!--") and body.endswith("-->") and "\n" not in body: | ||
| return False | ||
| # Positive evidence: body contains code references, line numbers, | ||
| # file paths, finding keywords, or structured review sections. | ||
| # Scaffolding (status notices, action confirmations) lacks these. | ||
| if re.search( | ||
| r"(line\s+\d+|`[^`]+`|\[.*\]\(|#\d+|\.py|\.js|\.ts|\.json|" | ||
| r"suggest|fix|issue|bug|error|warn|TODO|FIXME|" | ||
| r"##\s*(Review|Findings|Summary|Changes|Walkthrough)|" | ||
| r"###\s*(Line|File|Change|Issue|Finding))", | ||
| body, | ||
| re.IGNORECASE, | ||
| ): | ||
| return True | ||
| # No positive evidence found -- likely scaffolding or status notice. | ||
| return False | ||
| return False | ||
|
Comment on lines
+428
to
+436
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: sed -n '80,112p' scripts/check_bot_review.py
sed -n '300,450p' scripts/check_bot_review.py
rg -n -C 4 'REVIEW_EVIDENCE|error|collect_coderabbit_items|is_real_item|classify|issue.*comment|review.*comment' scripts/check_bot_review.py tests/scripts/test_check_bot_review.pyRepository: jaylfc/taOS Length of output: 50368 🏁 Script executed: sed -n '165,185p' scripts/check_bot_review.py
sed -n '461,526p' scripts/check_bot_review.py
sed -n '549,580p' scripts/check_bot_review.py
rg -n -C 3 'error occurred|starting the review|status|failure|Review failed|auto-generated|is_review=False|is_review=True' tests/scripts/test_check_bot_review.py scripts/check_bot_review.pyRepository: jaylfc/taOS Length of output: 50368 Restrict top-level evidence to review structure. CodeRabbit issue comments enter 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| def _is_coderabbit(user: dict | None) -> bool: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Preserve the line-level comment kind before applying body heuristics.
collect_coderabbit_items()marks both top-level issue comments and line-level review comments asis_review=False.is_real_item()then applies the same body-evidence check to both types. A valid inline finding such asAvoid this allocation.matches none of the current evidence terms and is rejected. If an auto-reply is also present,classify()can returnEXIT_STUBdespite the inline finding.Store the item kind when collecting each comment type. After the stub checks, accept a non-empty line-level comment as a real item. Apply this exception only to line-level comments. Add regression coverage for the terse inline finding.
🤖 Prompt for AI Agents