Repository navigation
fix(lsp): scope line-local diagnostics to production Rust anchors (#2130) - #2158
Conversation
) The CLI review surface scopes findings to changed production files, but the LSP projected every seeded finding: diff probe seeding skips tests/ trees, yet the seeding predicate is narrower than the shared production classifier, so src/tests.rs, examples/, benches/, and other non-production trees still produced line-local diagnostics — the inverted-signal family where the editor shows only the out-of-scope file. The projection now partitions findings through the shared workspace::is_production_rust_path classifier (the same boundary review-comments and the seam inventory use; no parallel LSP-only matcher), dropping non-production Rust anchors before snapshot construction so diagnostics, hover, actions, lens, and status counts all agree. The suppressed count is disclosed on the snapshot and in workspace status rather than silenced. Gap-record diagnostics are untouched: their anchors are production files in every current producer and the ledger is the repair-loop authority.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Summary by CodeRabbit
WalkthroughLSP workspace diagnostics now exclude findings anchored outside production Rust paths, record the suppressed count in ChangesLSP diagnostic scoping
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant LSP as LSP workspace diagnostics
participant Scope as finding_anchor_is_out_of_scope_rust_path
participant Snapshot as AnalysisSnapshot
participant Status as workspace status
LSP->>Scope: classify finding anchors
Scope-->>LSP: in-scope findings and suppressed count
LSP->>Snapshot: store filtered findings and count
Snapshot->>Status: provide diagnostic suppression count
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 |
check-process-policy is CI-only (not in precommit), so the builder's local run missed that the new integration fixtures spawn git to build a real test repo. Allowlisted with owner and reason.
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/tests.rs`:
- Around line 4651-4663: Update init_lsp_test_scope_repo to configure the
fixture repository with local commit.gpgSign=false after git initialization and
before either commit runs. Keep commit_lsp_test_scope_change unchanged so both
fixture commits use the repository-local signing configuration.
🪄 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: f70b3902-55f2-4edf-aa19-2ced6ed01575
📒 Files selected for processing (9)
crates/ripr/src/analysis/mod.rscrates/ripr/src/lsp/actions.rscrates/ripr/src/lsp/backend.rscrates/ripr/src/lsp/diagnostics.rscrates/ripr/src/lsp/hover.rscrates/ripr/src/lsp/lens.rscrates/ripr/src/lsp/state.rscrates/ripr/src/lsp/tests.rspolicy/process_allowlist.txt
🔗 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)
…es (#2130) Review: the fixture commits inherited commit.gpgSign from the host, so a signing-enabled environment could fail during repo setup before the scoping assertions run. The fixture now sets commit.gpgSign=false locally, alongside the existing user identity pins.
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/tests.rs (1)
4722-4738: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winCheck every out-of-scope path in
snapshot.findings.The diagnostic loop covers both
src/tests.rsandtests/end_to_end.rs, but the snapshot assertion only checkssrc/tests.rs. A regression could leave atests/end_to_end.rsfinding in the snapshot while publishing zero diagnostics, violating the before-snapshot filtering contract.Proposed fix
- if diagnostics - .snapshot - .findings - .iter() - .any(|finding| finding.probe.location.file.ends_with("src/tests.rs")) - { - return Err( - "out-of-scope src/tests.rs finding must not remain in the snapshot".to_string(), - ); + for scoped_out in ["src/tests.rs", "tests/end_to_end.rs"] { + if diagnostics + .snapshot + .findings + .iter() + .any(|finding| finding.probe.location.file.ends_with(scoped_out)) + { + return Err(format!( + "out-of-scope {scoped_out} finding must not remain in the snapshot" + )); + } }🤖 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/tests.rs` around lines 4722 - 4738, Extend the snapshot.findings assertion in the diagnostic test to reject findings for both out-of-scope paths, src/tests.rs and tests/end_to_end.rs. Reuse the existing scoped path list or equivalent matching logic so each path checked by lsp_test_scope_diagnostic_count is also verified absent from the snapshot.
🤖 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/tests.rs`:
- Around line 4722-4738: Extend the snapshot.findings assertion in the
diagnostic test to reject findings for both out-of-scope paths, src/tests.rs and
tests/end_to_end.rs. Reuse the existing scoped path list or equivalent matching
logic so each path checked by lsp_test_scope_diagnostic_count is also verified
absent from the snapshot.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: b859ce34-4e61-46c4-9c7d-c000fca12b44
📒 Files selected for processing (1)
crates/ripr/src/lsp/tests.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! |
Summary
Fixes #2130: on the same commit,
ripr review-commentsscopes findings to changed production files (changed_production_files_plus_immediate_callers), but the LSP projected every seeded finding — so a test-only change could fill the editor with ~40 line-local diagnostics inside a test helper while the 3 production findings the CLI reported never appeared. Inverted signal on the surface developers read continuously.Investigation found the mechanism: diff probe seeding skips
tests/trees, but the seeding predicate is narrower than the shared production classifier, sosrc/tests.rs,examples/,benches/, and other non-production trees still seeded findings the LSP then projected.The fix is at the projection boundary, reusing the shared helper (no parallel classifier):
partition_out_of_scope_test_file_findingsinlsp/diagnostics.rsdrops findings whose anchor is a.rspath failing the sharedworkspace::is_production_rust_pathclassifier — the same boundaryreview-commentsand the seam inventory use. Paths are relativized against the workspace root first so an absolute anchor can't be misclassified by a checkout-prefix component. Applied only to.rsanchors; other languages keep adapter-owned test handling.is_consistent(), and status counts all agree; quarantine (slice(#1916/#1625): quarantine dirty buffers and withdraw stale line-local diagnostics #1970) and selection authority (slice(#1695): make push and pull consume one stored diagnostic selection authority #1973) are untouched.AnalysisSnapshot.out_of_scope_test_file_findingssurfaced in workspace status (diagnosticsobject, both JSON branches) plus an eprintln when non-zero. Run status unchanged — a scope note, not a limitation.Closes #2130
Tests
workspace_diagnostics_scope_changed_test_file_findings_out_of_projection— mixed diff (src/lib.rs + src/tests.rs + tests/end_to_end.rs): diagnostics only in src/lib.rs, disclosure count > 0 (proves the filter is non-vacuous)workspace_diagnostics_test_only_diff_publishes_no_line_local_diagnostics— test-only diff: zero published, disclosure presentworkspace_diagnostics_production_only_diff_keeps_full_projection— production regressionVerification (independent of builder)
cargo test -p ripr— 3570 passed, 0 failedcargo clippy -p ripr --all-targets -- -D warnings— cleancargo fmt --check— cleancargo xtask precommit/goldens check— exit 0, no golden driftNotes
tests/end_to_end.rs) is already skipped by probe seeding on main; this closes the wider residual family the CLI/LSP scoping mismatch actually allows through.origin/fix/lsp-production-scope-2130test branch (d3b8f11) is subsumed by the mixed-diff test here and can be closed when this lands.