Repository navigation
feat(lsp): one stored diagnostic selection authority for push and pull (#1973) - #2134
Conversation
#1973) At refresh-transaction prepare time the backend now computes one immutable DiagnosticDeliverySelection (budget/profile identity, selection version, complete-evidence identity, selected ids, per-document selected sets, omitted ids+reasons, overflow, byte counts, retrieval route) and stores it on the committed AnalysisSnapshot. - Push publication reads the stored selection instead of re-evaluating the budget at publish time; disclosure behavior (bounded omission summary, zero-selection message, unavailable fallback) is preserved but driven from the stored outcome. - textDocument/diagnostic and workspace/diagnostic now serve the stored per-document selected sets (previously all snapshot diagnostics): pull-mode clients see exactly what push publishes — profile-filtered items are omitted-with-reason, never silently dropped. Pull result IDs (ripr-document-diagnostics-v2) hash the served payload plus the selection identity, so overflow is never hidden by an unchanged result. - The workspace-status diagnostic_budget projection mirrors the stored selection instead of re-running the budget. Five parity tests: identical selected sets on both transports, shared omitted identities/reasons, pull discloses the push overflow state and retrieval route, zero-selection serves nothing on both with disclosure, and pull provably reads the stored selection (ptr_eq, no re-evaluation).
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary by CodeRabbit
WalkthroughChangesThe LSP backend now computes diagnostic budget selection once per analysis snapshot. Push publication, document/workspace pull responses, workspace status, diagnostic result IDs, and fallback handling reuse that stored selection. Diagnostic delivery selection
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant RefreshTransaction
participant AnalysisSnapshot
participant PushPublisher
participant DocumentPull
participant WorkspacePull
RefreshTransaction->>AnalysisSnapshot: commit stored delivery selection
AnalysisSnapshot->>PushPublisher: serve selected diagnostics
AnalysisSnapshot->>DocumentPull: serve selected document diagnostics
AnalysisSnapshot->>WorkspacePull: serve selected workspace diagnostics
Possibly related issues
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.
Code Review
This pull request introduces a shared, immutable diagnostic delivery selection (DiagnosticDeliverySelection) computed during the refresh-transaction prepare phase and stored on the AnalysisSnapshot. Both push publication and pull handlers now read from this stored selection instead of independently re-evaluating the budget, ensuring transport parity. Additionally, pull-side disclosures have been added to report partial delivery states, and diagnostic result IDs have been updated to incorporate the selection identity to prevent selection changes from being hidden by unchanged reports. Extensive parity tests have been added to verify these behaviors. There are no review comments to address, so no further feedback is provided.
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
diagnostics_entry_for_uriintroduces fuzzy URI matching (file_uris_matchfallback) that the selection authority does not require and is unused elsewhere. Scope creep; the stored selection already keys on the stored URI string. Either justify the helper or remove and rely on direct BTreeMap lookup.- Replace string-prefix matching for unavailable-reason classification with a structured enum on DiagnosticDeliveryOutcome::Unavailable, or include the reason class explicitly in the selection. The current
starts_with('budget item serialization failed')check is brittle and leaks the human-readable detail into the result-ID hash, so rewording any log detail silently invalidates client cache identities.
Confirmed findings
- Stale selection risk: refresh_plan computes the selection from a batches-derived snapshot but the fallback at commit_refresh_snapshot recomputes if absent. If a code path mutates snapshot.diagnostics_by_uri between refresh_plan and commit_refresh_snapshot, the stored selection reflects the original batches, not the committed snapshot. Tests cover the normal path; an invariant that commit-time diagnostics_by_uri equals prepare-time diagnostics_by_uri is not asserted.
- delivery_filter_reuses_budget_ids_without_reserializing now compares stored selection against an independently re-serialized set; the original 'reuse path diverged from reserialization' check no longer tests reuse vs reserialize but stored-vs-reserialize. Rename/comment to reflect new contract, or add an explicit reuse-path vs cold-path cross-check at unit scope.
- Two compute guard sites (
refresh_plan,commit_refresh_snapshot) recompute selection defensively; acceptable but is duplication risk and obscures authority.
Verification questions
- Confirm delivery_selection field is populated before commit but commit_refresh_snapshot re-computes if None; this means a snapshot replaced via commit path can publish without the prepare-time selection.
- Confirm workspace_diagnostic lacks the once-per-report disclosure deduplication when a single-document workspace is reported.
- Confirm 'budget item serialization failed' detail string is used in two distinct DiagnosticDeliveryOutcome::Unavailable branches: build_budget_items_from_diagnostics failure vs evaluate_diagnostic_budget error.
- Confirm diagnostics.rs renames version prefixes to v2 and folds delivery_selection_identity into document_diagnostic_result_id; complete_diagnostic_evidence_identity rebuilt as ripr-complete-diagnostic-evidence-v1.
- Confirm commit_refresh_snapshot backfills snapshot.delivery_selection = Some(compute_delivery_selection(&snapshot)) if None; refresh_plan fills it before the plan is built, so two code paths compute the selection.
- Confirm boundary duplication in
commit_refresh_snapshot: bothrefresh_planandcommit_refresh_snapshotre-check and possibly recompute selection. Acceptable for fixtures but twois_none()guards is mild duplication risk.
Verification questions
Refuted
Evidence gaps
[review body truncated; see review artifacts]
…lookup Review on #2134: DiagnosticDeliveryOutcome::Unavailable now carries a typed DiagnosticDeliveryUnavailableReason (ItemSerialization/Evaluation) with as_status_reason() driving the workspace-status projection — no string-prefix classification. The result-id cache now does exact-key URI lookup only; the stored selection keys on the stored URI string, so fuzzy matching is not part of the authority contract.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/ripr/src/lsp/backend.rs (1)
641-646: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftBuild the push refresh plan from the served selection, not raw diagnostics.
last_diagnosticsretains the complete raw map, anddiagnostic_refresh_planis built from rawbatches. If only the budget/profile changes, raw diagnostics compare unchanged, so push publishes no update; pull immediately serves the new stored selection. Keep a prior delivered projection/selection for delta and rollback planning, and add a push-mode regression test for unchanged diagnostics with a changed selection.🤖 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 641 - 646, Update the push refresh planning flow around diagnostic_refresh_plan to compare the newly served delivery_selection projection rather than raw batches or last_diagnostics. Preserve the prior delivered selection/projection so delta and rollback planning use the previous served state, and add a push-mode regression test covering unchanged diagnostics with a changed budget/profile selection.
🤖 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.
Outside diff comments:
In `@crates/ripr/src/lsp/backend.rs`:
- Around line 641-646: Update the push refresh planning flow around
diagnostic_refresh_plan to compare the newly served delivery_selection
projection rather than raw batches or last_diagnostics. Preserve the prior
delivered selection/projection so delta and rollback planning use the previous
served state, and add a push-mode regression test covering unchanged diagnostics
with a changed budget/profile selection.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 2ccd021e-1636-4e17-b2c6-1e30f62a89fa
📒 Files selected for processing (3)
crates/ripr/src/lsp/backend.rscrates/ripr/src/lsp/diagnostic_budget.rscrates/ripr/src/lsp/diagnostics.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)
Summary
Fixes #1973. Standard push and pull diagnostic delivery now project from one immutable delivery selection computed once at refresh-transaction prepare time and stored on the committed
AnalysisSnapshot— no transport re-runs ranking or re-evaluates the budget.The stored selection (
DiagnosticDeliverySelectionindiagnostic_budget.rs) carries the issue's required set: budget/profile identity and selection version, complete-evidence identity (digest over full unfiltered payloads), selected canonical ids, per-document selected sets, omitted identities with per-item reasons, workspace/per-document overflow, selected and complete byte counts, and the retrieval route.What each transport reads:
snapshot.delivery_selectioninstead of callingevaluate_push_delivery_budgetat publish time. The disclosure behaviors from feat(lsp): disclose push-delivery budget omissions to the client (#1969) #2116/fix(lsp): push budget must distinguish empty-selected from computation-failed (#2042 follow-up) #2120 (bounded omission summary, zero-selection message, named unavailable fallback) are preserved, driven from the stored outcome.textDocument/diagnostic,workspace/diagnostic): now serve the stored per-document selected sets instead of all snapshot diagnostics. Intended user-visible change (per the issue): pull-mode clients now receive exactly what push publishes — budget-selected items only; profile-filtered items are omitted-with-reason, never silently dropped. Pull result IDs (ripr-document-diagnostics-v2) hash the served payload plus the selection identity, so a budget/profile/input change flips IDs and overflow is never hidden by anunchangedresult; theDiagnosticResultIdCacheis retained. A bounded pull disclosure (pull_delivery_disclosure) names partial/zero/fallback states once per workspace report.diagnostic_budgetprojection mirrors the stored selection instead of re-running the budget; unavailable states keep their schema values.Proof (independently re-verified after the builder run)
Parity tests: identical selected sets on both transports (item-level and per-document); shared omitted identities/reasons; pull discloses the same overflow state and
ripr/listActionableItemsroute (and repeats asunchanged); zero-selection serves nothing on both with disclosure; and a ptr_eq test proves pull serves the exact stored selection with no re-evaluation. One pre-existing pull test's fixture diagnostics were made budget-actionable since result IDs now derive from the served set.Claim boundary
Selection-authority unification only. No change to what the budget selects (same
evaluate_diagnostic_budgetmachinery, run once), to the snapshot analysis itself, or to any wire schema (the selection is in-memory). The pull serving change is the issue's explicit requirement, flagged in the PR body.Rollback
Revert the commit; push returns to publish-time evaluation and pull returns to serving all snapshot diagnostics.