Repository navigation
fix(lsp): enforce diagnostic budget on push delivery (#1911) - #2042
Conversation
…ase audit (2026-07-19) Add 9 entries to LEARNINGS.md covering: - Gate blocking is non-functional (hardcoded seam_id None) - Static receipts are advisory (fabrication is trivial) - Every save re-runs the full pipeline (cache not wired in) - continue-on-error on every CI step makes green meaningless - Result<_, String> is the highest-leverage refactor target - Cross-language consistency needs a shared vocabulary layer - File-policy gate breaks main on new file types - Duplicate run-status logic drifts - The session's structural learnings document Each entry follows the existing LEARNINGS.md format: date, title, load-bearing lesson, and concrete evidence references.
…ed diagnostics to budget-selected IDs (#1911) The diagnostic budget selector (evaluate_diagnostic_budget) was computed for workspace status reporting only. The push publication loop published every batch unbounded. Now the push loop: 1. Builds budget items from all publish batches 2. Evaluates the budget to get the selected canonical IDs 3. Filters each batch diagnostics to only include selected IDs 4. Falls back to unfiltered publish if budget computation fails Also lifts diagnostic_canonical_id from private to pub(crate) so the push loop can compute the canonical ID for filtering. Proof: cargo check --lib (exit 0); cargo clippy --all-targets -D warnings (exit 0); cargo test -p ripr --lib lsp:: (365 passed).
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary by CodeRabbit
WalkthroughPush diagnostic refresh publication now evaluates the default diagnostic budget, selects canonical diagnostic IDs, and filters each published batch. If budget computation produces no selection, the existing full-batch publication behavior remains. The canonical ID helper is crate-visible for backend use. ChangesPush Diagnostic Budget Filtering
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Backend
participant DiagnosticBudget
participant LSPClient
Backend->>DiagnosticBudget: Evaluate push_delivery budget
DiagnosticBudget-->>Backend: Return selected canonical IDs
Backend->>LSPClient: Publish filtered diagnostic batches
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 428-445: The delivery-budget filtering is applied only to forward
diagnostics publication, while rollback republishes the full previous
diagnostics. Extract the filtering logic from the visible diagnostics
publication block into a shared helper, then reuse it in
rollback_refresh_transaction when restoring previous_diagnostics so rollback
emits the same budget-filtered vectors and does not reintroduce omitted
diagnostics.
- Around line 403-416: Update the budget selection computation around
evaluate_diagnostic_budget to preserve the distinction between evaluation
failure and a successful empty selection. Return None when building or
evaluating the budget fails, but wrap the collected selected IDs in Some even
when empty; ensure the later publication logic only bypasses filtering for None
and publishes no diagnostics for Some(empty).
🪄 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: 0dc103e8-5349-43ed-b57a-8d4b59c379b9
📒 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)
There was a problem hiding this comment.
Code Review
This pull request integrates the diagnostic delivery budget into the LSP backend's push path, filtering diagnostics based on evaluated budget items. Feedback highlights a performance concern regarding redundant serialization and canonical ID computation. Additionally, using JSON serialization for deterministic hashing is discouraged due to potential key ordering issues, and the error handling for serialization failures should be made consistent to prevent diagnostics from being silently dropped.
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.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- No test exercises the new push-path budget filter. Add a test asserting that with
DiagnosticBudgetoverridden to a tight per-document cap,publish_diagnosticsreceives a strict subset sized to the cap and that fully-filtered budgets publish zero items, distinguishingSome(empty)(valid empty selection) from budget failure (full publish). - rollback_refresh_transaction republishes full previous_diagnostics unfiltered; if budget filter is authoritative for push, rollback reintroduces omitted diagnostics. Extract shared filter helper and apply in rollback, or document rollback scope explicitly.
- Distinguish eval failure (None -> publish all) from a successful empty selection (Some(empty) -> publish nothing). Replace unwrap_or_default with Option<BTreeSet> and gate the fallback on is_none, not is_empty.
- Replace unwrap_or_default with Option; only None (computation failure) should publish unfiltered. A legitimate empty selected set must publish zero diagnostics, not fall through to the is_empty() branch at line 428.
Confirmed findings
- unwrap_or_default confuses eval failure (None) with successful empty selection (Some(empty)) so an all-ProfileFiltered batch falls back to unfiltered publish, contradicting the budget contract.
- unwrap_or_default at line 410 conflates evaluation failure with valid empty selection; empty selection then falls into the .is_empty() branch at line 428 and publishes unfiltered.
- rollback_refresh_transaction republishes previous_diagnostics unmodified, so after filtering is introduced, omitted diagnostics reappear post-cancel/workspace-transition.
- diagnostic_canonical_id uses serde_json::to_vec for hashing; JSON map key ordering non-determinism can yield unstable canonical IDs across runs/features, undermining budget set membership.
- Two serialized-to-canonical-ID passes per publish plus non-deterministic serde_json map ordering could produce unstable IDs across clients; not blocked but warrants a perf+determinism microbench before merge.
Verification questions
- Confirm no test in diff covers new push-path budget filtering; green claim rests on pre-existing lsp:: suite.
- Confirm coderabbit flagged two material test gaps already in seeded thread (empty-selection vs None, rollback path).
Verification questions
Refuted
Evidence gaps
[review body truncated; see review artifacts]
[review body truncated; see review artifacts]
…n-failed (#2042 follow-up) The push-delivery budget application in backend.rs used `budget_selected_ids.is_empty()` as the fallback signal. That check conflated two opposite cases: 1. Budget computation failed (.ok() chain returned None → fallback). Falling back to 'publish everything' is correct here — there is no honest budget to apply. 2. Budget computation SUCCEEDED but selected zero items (all ProfileFiltered, or the per-document/workspace cap dropped everything). The honest result is 'publish nothing for these items.' The is_empty() check instead published everything — the exact opposite of what the budget intended. ## Change Return Option<BTreeSet<String>> from the budget step: - None → computation failed → fall back to publishing everything - Some(set) → computation succeeded → apply the set (even if empty) 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_error` to diagnostic_budget.rs. It constructs two ProfileFiltered items, evaluates the budget, and asserts: - evaluation SUCCEEDS (returns Ok, not Err) - selected_ids is EMPTY - eligible_items is 0 - overflowed is false This pins the contract the backend.rs fix depends on: empty-selected is a legitimate result, not a fallback signal. Verified: cargo build -p ripr PASS cargo clippy -p ripr -D warnings PASS cargo test -p ripr --lib diagnostic_budget PASS (12 tests, 1 new) This is a follow-up to #2042 (merged) flagged in the post-merge review.
Summary
The diagnostic budget selector was computed for status reporting only. The push publication loop published every batch unbounded. Now the push loop filters published diagnostics to only budget-selected IDs.
Change
backend.rs (+47): Before publishing each batch, compute the workspace-wide budget, collect selected canonical IDs, then filter each batch diagnostics to only include items whose canonical ID is in the selected set. Falls back to unfiltered publish on budget computation error.
diagnostic_budget.rs (+1): Lift diagnostic_canonical_id from private to pub(crate) so the push loop can compute canonical IDs for filtering.
Proof
cargo check --lib (exit 0); cargo clippy --all-targets -D warnings (exit 0); cargo test -p ripr --lib lsp:: (365 passed, 0 failed).
Non-goals