Repository navigation
fix(lsp): push budget must distinguish empty-selected from computation-failed (#2042 follow-up) - #2120
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
Next review available in: 1 minute Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughPush diagnostic delivery now distinguishes unavailable budget results from successful empty selections. Unavailable budgets publish diagnostics unfiltered, while successful empty selections publish none. Regression coverage verifies all-profile-filtered budget input behavior. ChangesDiagnostic budget delivery
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request fixes a bug in the LSP diagnostic delivery budget application where a successfully computed empty budget (e.g., when all diagnostics are filtered out) was conflated with a failed budget computation. By changing budget_selected_ids to an Option, the code now correctly distinguishes between a failed computation (falling back to publishing everything) and a successful computation that legitimately selected zero items (publishing nothing). A regression test has also been added to verify this behavior. I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
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 `@crates/ripr/src/lsp/diagnostic_budget.rs`:
- Around line 765-793: The regression test currently covers only
evaluate_diagnostic_budget, so it must be extended or complemented with a
backend-level test exercising the push publication path in backend.rs. Build an
all-ProfileFiltered batch, invoke the relevant push flow, and observe
publish_diagnostics receiving an empty vector rather than falling back to
publishing all diagnostics; retain assertions for the evaluator result and any
applicable output or metric contract.
🪄 Autofix (Beta)
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: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: db0fd4db-f68a-49fb-b0b4-214d9190a9ab
📒 Files selected for processing (2)
crates/ripr/src/lsp/backend.rscrates/ripr/src/lsp/diagnostic_budget.rs
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
EffortlessMetrics/ripr(auto-detected)EffortlessMetrics/perl-lsp(auto-detected)EffortlessMetrics/unsafe-review(auto-detected)EffortlessMetrics/ub-review(auto-detected)
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
c371261 to
99ef0ac
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (5)
crates/ripr/src/lsp/backend.rs (5)
1-1: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winMultiple comments/test name still describe the pre-fix "empty selection = publish everything" semantics. This PR's whole point is to stop conflating budget failure with a successful empty selection, but the surrounding prose in four spots wasn't updated to match: only
Unavailable/Nonenow falls back to publishing everything; a successfulAppliedresult with an empty selection publishes nothing.
crates/ripr/src/lsp/backend.rs#L2582-2613: update the doc comment onpush_diagnostics_for_batch— it still says "An empty selected set keeps the#1911fallback semantics: publish everything," contradicting the special-case removal in the function body directly below it.crates/ripr/src/lsp/backend.rs#L463-474: update the inline comment — it says the "publish-everything fallback rule fires" when selection collapses, but this branch (Some(empty_set)) now publishes nothing.crates/ripr/src/lsp/backend.rs#L2678-2695: move the "every diagnostic is published unfiltered" doc comment offpush_budget_zero_selection_log_message(whose own message says "published nothing") and ontopush_budget_unavailable_log_message, which actually has that behavior.crates/ripr/src/lsp/backend.rs#L4730-4776: renamezero_selection_publishes_everything_and_names_the_fallback, whose body (Lines 4757-4767) asserts the opposite — that publishing is empty.🤖 Prompt for 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. In `@crates/ripr/src/lsp/backend.rs` at line 1, Update the stale documentation and test naming around diagnostic selection to reflect current semantics: only Unavailable/None falls back to publishing every diagnostic, while Applied with an empty selection publishes nothing. Revise the push_diagnostics_for_batch doc comment and inline Some(empty_set) comment, move the unfiltered-publication documentation from push_budget_zero_selection_log_message to push_budget_unavailable_log_message, and rename zero_selection_publishes_everything_and_names_the_fallback to describe empty publication.
2582-2613: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winDoc comment on
push_diagnostics_for_batchcontradicts the behavior it documents.Line 2582-2583 says "An empty selected set keeps the
#1911fallback semantics: publish everything," but the function body right below it (explicitly changed in this diff) removed that special case — an emptybudget_selected_idsnow filters to nothing. The doc needs to describe the current contract so callers relying on this comment don't reintroduce the old fallback here.🤖 Prompt for 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. In `@crates/ripr/src/lsp/backend.rs` around lines 2582 - 2613, The doc comment for push_diagnostics_for_batch must match its current filtering behavior: remove the claim that an empty budget_selected_ids publishes everything, and document that diagnostics are returned only when their IDs are selected. Leave the function implementation unchanged.
463-474: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winStale comment: says "publish-everything fallback" but this branch now publishes nothing.
This comment describes the old
#1911semantics. With this fix,result.selected.is_empty()(a successfulAppliedoutcome) causesbudget_selected_idsto beSome(empty_set), which the publish loop (Lines 501-513) filters to zero diagnostics — not "publish everything". Only theUnavailablebranch (None) still publishes everything.🤖 Prompt for 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. In `@crates/ripr/src/lsp/backend.rs` around lines 463 - 474, Update the comment above the result.selected.is_empty() warning in the publishing flow to describe the current behavior: an Applied result with an empty selection publishes no diagnostics, while only an Unavailable result triggers publish-everything behavior. Remove the stale fallback wording without changing the surrounding logging or selection logic.
4730-4776: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winTest name contradicts its own assertions.
zero_selection_publishes_everything_and_names_the_fallbackasserts the opposite of what its name says: Lines 4757-4767 fail the test ifpublishedis not empty, i.e. it verifies that a legitimate empty selection publishes nothing. The name is left over from the pre-fix behavior this PR is replacing.📝 Proposed fix
- fn zero_selection_publishes_everything_and_names_the_fallback() -> Result<(), String> { + fn zero_selection_publishes_nothing_and_names_the_collapse() -> Result<(), String> {🤖 Prompt for 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. In `@crates/ripr/src/lsp/backend.rs` around lines 4730 - 4776, Rename the test function zero_selection_publishes_everything_and_names_the_fallback to reflect its current behavior: a legitimate empty selection publishes nothing while the fallback message identifies omitted items. Keep the test assertions and implementation unchanged.
2678-2695: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winDoc comment is attached to the wrong function.
The doc comment at Lines 2678-2680 ("every diagnostic is published unfiltered, so no delivery limit was enforced") describes the budget-unavailable fallback, but it sits above
push_budget_zero_selection_log_message, whose own message body (Line 2685, changed in this diff) says the opposite: "published nothing for this round." That description belongs onpush_budget_unavailable_log_messagebelow it, which currently has no doc comment at all.📝 Proposed fix
-/// Disclosure for the budget-error fallback: every diagnostic is published -/// unfiltered, so no delivery limit was enforced — a partial state that must -/// be named rather than presented as a normal complete publication. +/// Disclosure for a successful evaluation that legitimately selected zero +/// items: nothing is published this round — a partial state that must be +/// named rather than presented as a normal complete publication. fn push_budget_zero_selection_log_message( result: &crate::lsp::diagnostic_budget::DiagnosticBudgetResult, ) -> String { format!( "ripr push diagnostic delivery budget selected zero of {} items; published nothing for this round: every item was omitted by the budget (profile filtering or delivery limits)", result.total_canonical_items ) } +/// Disclosure for the budget-error fallback: every diagnostic is published +/// unfiltered, so no delivery limit was enforced — a partial state that must +/// be named rather than presented as a normal complete publication. fn push_budget_unavailable_log_message(detail: &str) -> String {🤖 Prompt for 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. In `@crates/ripr/src/lsp/backend.rs` around lines 2678 - 2695, Move the existing doc comment describing unfiltered publication and unenforced delivery limits from push_budget_zero_selection_log_message to push_budget_unavailable_log_message. Keep push_budget_zero_selection_log_message without that misleading comment, and preserve both function bodies unchanged.
🤖 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 `@crates/ripr/src/lsp/backend.rs`:
- Around line 437-449: Extract the duplicated budget-to-selection conversion
into a `PushDeliveryBudgetOutcome::selected_ids` helper returning
`Option<BTreeSet<String>>`, preserving `Some(empty)` for an applied empty
selection and `None` for unavailable budgets. Replace both the production
`budget_selected_ids` match and the corresponding test match with
`push_budget.selected_ids()` so the test uses the shared implementation.
---
Outside diff comments:
In `@crates/ripr/src/lsp/backend.rs`:
- Line 1: Update the stale documentation and test naming around diagnostic
selection to reflect current semantics: only Unavailable/None falls back to
publishing every diagnostic, while Applied with an empty selection publishes
nothing. Revise the push_diagnostics_for_batch doc comment and inline
Some(empty_set) comment, move the unfiltered-publication documentation from
push_budget_zero_selection_log_message to push_budget_unavailable_log_message,
and rename zero_selection_publishes_everything_and_names_the_fallback to
describe empty publication.
- Around line 2582-2613: The doc comment for push_diagnostics_for_batch must
match its current filtering behavior: remove the claim that an empty
budget_selected_ids publishes everything, and document that diagnostics are
returned only when their IDs are selected. Leave the function implementation
unchanged.
- Around line 463-474: Update the comment above the result.selected.is_empty()
warning in the publishing flow to describe the current behavior: an Applied
result with an empty selection publishes no diagnostics, while only an
Unavailable result triggers publish-everything behavior. Remove the stale
fallback wording without changing the surrounding logging or selection logic.
- Around line 4730-4776: Rename the test function
zero_selection_publishes_everything_and_names_the_fallback to reflect its
current behavior: a legitimate empty selection publishes nothing while the
fallback message identifies omitted items. Keep the test assertions and
implementation unchanged.
- Around line 2678-2695: Move the existing doc comment describing unfiltered
publication and unenforced delivery limits from
push_budget_zero_selection_log_message to push_budget_unavailable_log_message.
Keep push_budget_zero_selection_log_message without that misleading comment, and
preserve both function bodies unchanged.
🪄 Autofix (Beta)
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: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: fbe681db-c70f-4a1a-91a5-b66f0c51e942
📒 Files selected for processing (1)
crates/ripr/src/lsp/backend.rs
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
EffortlessMetrics/ripr(auto-detected)EffortlessMetrics/perl-lsp(auto-detected)EffortlessMetrics/unsafe-review(auto-detected)EffortlessMetrics/ub-review(auto-detected)
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 `@crates/ripr/src/lsp/backend.rs`:
- Around line 465-487: Update the diagnostics filtering branch around
budget_selected_ids and diagnostic_canonical_id to handle serialization failure
without unwrap_or_default. If serializing any diagnostic fails, treat the budget
as unavailable and publish batch.diagnostics unfiltered; otherwise continue
filtering by canonical IDs. Preserve the existing behavior for None and
successfully computed budgets.
🪄 Autofix (Beta)
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: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 0c7f29fd-42f0-4932-bbb6-28abe6ad91c2
📒 Files selected for processing (2)
crates/ripr/src/lsp/backend.rscrates/ripr/src/lsp/diagnostic_budget.rs
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
EffortlessMetrics/ripr(auto-detected)EffortlessMetrics/perl-lsp(auto-detected)EffortlessMetrics/unsafe-review(auto-detected)EffortlessMetrics/ub-review(auto-detected)
… zero Rebased onto #2116's structure. The empty-selected check conflated two opposite cases: budget computation FAILED (publish everything is the honest fallback) versus computation SUCCEEDED with an empty selection (every item legitimately dropped by profile filtering or limits — publishing anything defeats the budget). Selected ids are now Option: None (unavailable) publishes everything with the named fallback disclosure; Some(set) filters strictly, so a legitimately empty selection publishes nothing and the zero-selection disclosure says so. The budget-error fallback test now exercises the call-site Option semantics.
99ef0ac to
c2ab3e3
Compare
|
Merged after reconciliation with #2116 (which landed first with the disclosure structure). Adopted semantic: selected ids are now Option — None (budget computation failed) publishes everything with the named fallback disclosure; Some(set) filters strictly, so a legitimately empty selection (all items profile-filtered or limit-dropped) publishes NOTHING, and the zero-selection disclosure says exactly that. Review note from the earlier round: the #2116 publish-everything-on-zero-selection behavior this PR corrects was preserved there deliberately as out-of-scope; this PR completes the fix. Zero-selection and fallback tests updated to the Option semantics; 22 backend tests + full precommit green. |
Problem (found in post-merge review of #2042)
The push-delivery budget application in
backend.rsusedbudget_selected_ids.is_empty()as the fallback signal. That check conflated two opposite cases:.ok()chain returnedNone→ fallback). Falling back to 'publish everything' is correct here — there is no honest budget to apply.ProfileFiltered, or the per-document/workspace cap dropped everything). The honest result is 'publish nothing for these items.' Theis_empty()check instead published everything — the exact opposite of what the budget intended.This is on the user-facing diagnostic delivery path: a tight budget that correctly selected zero items would silently publish all the diagnostics the budget was supposed to suppress.
Change
Return
Option<BTreeSet<String>>from the budget step:An empty
Some(set)now correctly publishes only items in the set (nothing), which is what a tight budget means.Test
Add
all_profile_filtered_yields_empty_selected_not_an_errortocrates/ripr/src/lsp/diagnostic_budget.rs. It constructs twoProfileFiltereditems, evaluates the budget, and asserts:Ok, notErr)selected_idsis emptyeligible_itemsis 0overflowedis falseThis pins the contract the
backend.rsfix depends on: empty-selected is a legitimate result, not a fallback signal.Evidence
Scope
Two-file change:
crates/ripr/src/lsp/backend.rs: budget step returnsOption, match replacesis_emptycheck (~20 lines changed in the push block).crates/ripr/src/lsp/diagnostic_budget.rs: one new regression test (~25 lines).No schema change. No behavior change for the common case (budget succeeds with non-empty selected). Fixes the inversion bug for the empty-selected edge case. Follow-up to #2042 (merged).
Non-goals
Backendfixture; the unit test at the budget layer pins the contract the fix depends on).