Skip to content

fix(lsp): scope line-local diagnostics to production Rust anchors (#2130) - #2158

Merged
EffortlessSteven merged 3 commits into
mainfrom
codex/lsp-test-file-scoping
Jul 21, 2026
Merged

EffortlessSteven merged 3 commits into
mainfrom
codex/lsp-test-file-scoping

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

Fixes #2130: on the same commit, ripr review-comments scopes 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, so src/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_findings in lsp/diagnostics.rs drops findings whose anchor is a .rs path failing the shared workspace::is_production_rust_path classifier — the same boundary review-comments and 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 .rs anchors; other languages keep adapter-owned test handling.
  • Filtering happens before snapshot construction, so diagnostics, hover, actions, lens, 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.
  • Disclosure, not silence: AnalysisSnapshot.out_of_scope_test_file_findings surfaced in workspace status (diagnostics object, both JSON branches) plus an eprintln when non-zero. Run status unchanged — a scope note, not a limitation.
  • Gap-record diagnostics intentionally not filtered: their anchors are production files in every current producer, and the ledger is the repair-loop authority.

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 present
  • workspace_diagnostics_production_only_diff_keeps_full_projection — production regression

Verification (independent of builder)

  • cargo test -p ripr — 3570 passed, 0 failed
  • cargo clippy -p ripr --all-targets -- -D warnings — clean
  • cargo fmt --check — clean
  • cargo xtask precommit / goldens check — exit 0, no golden drift

Notes

  • The issue's exact file (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.
  • The unmerged origin/fix/lsp-production-scope-2130 test branch (d3b8f11) is subsumed by the mixed-diff test here and can be closed when this lands.

)

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.
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

Summary by CodeRabbit

  • Bug Fixes

    • LSP diagnostics now exclude findings anchored in out-of-scope test files.
    • Test-file changes no longer produce line-local diagnostics.
    • Workspace status reports include the number of findings suppressed due to diagnostic scoping.
  • Tests

    • Added integration coverage for production vs. test-file diagnostic scoping scenarios.
    • Updated diagnostic/hover/lens snapshot fixtures and test helpers to include the new suppressed-findings count field.

Walkthrough

LSP workspace diagnostics now exclude findings anchored outside production Rust paths, record the suppressed count in AnalysisSnapshot, expose it in workspace status, and add integration coverage for production and test-file changes.

Changes

LSP diagnostic scoping

Layer / File(s) Summary
Scope predicate and snapshot contract
crates/ripr/src/analysis/mod.rs, crates/ripr/src/lsp/state.rs
Re-exports is_production_rust_path and adds out_of_scope_test_file_findings to AnalysisSnapshot.
Diagnostic partitioning
crates/ripr/src/lsp/diagnostics.rs
Partitions findings by Rust anchor path, publishes in-scope findings, and records suppressed findings.
Status propagation and scope tests
crates/ripr/src/lsp/backend.rs, crates/ripr/src/lsp/tests.rs, crates/ripr/src/lsp/actions.rs, crates/ripr/src/lsp/hover.rs, crates/ripr/src/lsp/lens.rs, policy/process_allowlist.txt
Exposes the suppression count in workspace status, updates snapshot fixtures, and adds git-backed scope tests.

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
Loading

Possibly related PRs

Poem

A bunny sorts the findings neat,
Production paths stay on their feet.
Test trails hide, their count is shown,
Snapshots mark what’s filtered down.
The LSP hops with scope just right! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed but omits most required template sections, including source boundary, scope classification, rollback, and proof. Fill in the template sections for swarm boundary, linked links, scope/acceptance, non-goals, proof, rollback, traceability, policy impact, and checks.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: scoping LSP diagnostics to production Rust anchors.
Linked Issues check ✅ Passed The code matches #2130 by filtering out non-production Rust anchors and keeping the disclosure counts and tests aligned.
Out of Scope Changes check ✅ Passed No clearly unrelated changes are evident; the snapshot field, status JSON, tests, and allowlist update all support the scoping fix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/lsp-test-file-scoping

Comment @coderabbitai help to get the list of available commands.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between da0cd3c and f9805f3.

📒 Files selected for processing (9)
  • crates/ripr/src/analysis/mod.rs
  • crates/ripr/src/lsp/actions.rs
  • crates/ripr/src/lsp/backend.rs
  • crates/ripr/src/lsp/diagnostics.rs
  • crates/ripr/src/lsp/hover.rs
  • crates/ripr/src/lsp/lens.rs
  • crates/ripr/src/lsp/state.rs
  • crates/ripr/src/lsp/tests.rs
  • policy/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)

Comment thread crates/ripr/src/lsp/tests.rs Resolved
…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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Check every out-of-scope path in snapshot.findings.

The diagnostic loop covers both src/tests.rs and tests/end_to_end.rs, but the snapshot assertion only checks src/tests.rs. A regression could leave a tests/end_to_end.rs finding 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

📥 Commits

Reviewing files that changed from the base of the PR and between f9805f3 and 948dddd.

📒 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

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/ripr/src/lsp/diagnostics.rs 94.11% 2 Missing ⚠️
crates/ripr/src/lsp/backend.rs 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(lsp): diagnostics analyze test-only files that review-comments excludes from changed_production_files

1 participant