Repository navigation
refactor(lsp): one filter implementation, shared republish, leaner publishes - #144
Conversation
Delete dead code: the FolderRoot alias, workspace_context_for_path, folder_config_for_path, the ServerCounters::filter_compile_count accessor, and the workspace_contexts field those functions orphaned. Untangle Vec<(ProjectCheckResult,)> into Vec<ProjectCheckResult>. Repair two log strings corrupted by broken line continuations. Drop PR-review and stage-tag bookkeeping from comments; the invariants they annotated stay. Replace the clippy-quiet comment in hints.rs with the real reason for the arm shape. Collapse the one remaining collapsible_if in scope_for and remove the crate-level allow. Rename edited_return_type_updates_dependent_diagnostics (was editing_utils_updates_cross_file_analysis_diagnostics) to say what it checks.
Wire enable: a folder whose settings set enable: false is skipped in eligibility_for_path, so the server analyzes nothing and publishes an empty diagnostics set for it, on disk files as well as open documents. Drop the five FolderSettings fields nothing on the server reads (check_test_fixtures, log_level, path, import_strategy, add_executable_to_terminal_path): the extensions own them, and the server ignores unknown keys either way. Fix the select doc: the field is consumed by compute_folder_filter and an explicit empty list disables default-enabled rules. Add an integration test for enable.
Structural dedup and hot-path clone trims; no behavior change. - one filter implementation: delete the test-only State::merge_filter twin; effective_filter now calls compute_folder_filter. Drop the duplicate config parameter every call site passed twice. - one republish path: extract republish_all_open_documents for did_change_configuration and did_change_watched_files. did_change_workspace_folders keeps its filtered republish: documents under removed roots were just cleared and fall back to root-level eligibility, so a blanket reschedule would re-publish results for them. - drop the legacy workspace_folders field. It was derived from folder_contexts under the same lock at every write, so its two readers were unreachable: the eligibility fallback only ran when no context root matched (the same root set), and the indexer branch only ran when folder_contexts was empty (which implied the derived vector was empty too). - trim publish clones: snapshot only the eligible documents' versions instead of the whole map; clone each disk entry once straight into the check input instead of HashMap-then-push; pass each folder partition to check_with_workspace by value; consume check results so per-file diagnostic vecs are taken, not cloned. - scope_for: drop the pre-check version capture; the single post-check (parse cache still holds this Arc, tag equals the live version) proves the same invariant, because record_parse stamps the pairing and a superseded entry is never re-installed with an older Arc. - tests: remove fixed settle sleeps (1s x2, 300ms) in configuration_refresh and fallback_isolation. The indexer publishes nothing on completion and open documents shadow disk files, so the existing bounded waits are the synchronization. The inlayHint wait gains a 2s timeout so failure stays diagnosable. Verification: cargo fmt -p ry-lsp; cargo clippy -p ry-lsp --all-targets -- -D warnings; cargo test -p ry-lsp full suite green; the two former sleep-test files run 5/5 stable.
|
Warning Review limit reachedNext included review available in 57 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
ℹ️ No critical issues — one doc-consistency nitpick below.
Reviewed changes
Every behavior-preservation claim in the PR body was traced against the code, and the full verification suite was re-run locally (all green).
- Filter dedup: deleted the test-only
State::merge_filterand routedeffective_filterthroughcompute_folder_filter; dropped the redundantfile_configparameter. Verified all five base call sites ofcompute_folder_filterpassed the same config twice, and that the merge body is semantically identical (sameerror/warn/ignore/select/extend_selectfallbacks), so theeffective_filter_*unit tests keep their meaning. The addedfilter_compile_countbump in the test helper is harmless — no unit test asserts compile counts on a bareState. - Shared republish: extracted
republish_all_open_documentsfordid_change_configurationanddid_change_watched_files. Thedid_change_workspace_foldersexception is correct: removed-root documents are explicitly cleared and then excluded from the reschedule, and a blanket reschedule would re-eligible them through the root fallback ineligibility_for_path— the new comment at the site matches the code. workspace_foldersfield removal: confirmed both readers were dead. All three base write sites derived the vector fromfolder_contextsinside the same lock section, soeligibility_for_path's fallback could never match when thefolder_contextsscan missed, andspawn_background_index's middle branch could never run whenfolder_contextswas empty.- Publish trims: all four verified equivalent. In particular, the
doc_versionsjoin is safe becausedocs/versionsare only ever written and removed in pairs under one lock, and the old post-parseversions.getre-check read the snapshot clone rather than live state, so it never filtered anything the new join doesn't. scope_forsingle post-check: the equivalence argument holds. Parse entries are only written byrecord_parse, which production only reaches with a freshly constructedArc;versionsonly changes viaupdate_doc, which removes the entry first — so "the cache holds thisArcby identity, tagged equal to the live version" proves exactly what the removed pre-check proved. The interleaving analysis in the PR body matches the code.- Test sleep removals: sound.
spawn_background_indexpublishes nothing on completion (no schedule/publish call in its body), inlay hints resolve throughscope_for(open-document parse + folder stubs only), andpublished_diagnostics_afteralready carries a 5s deadline in the testkit. The new 2s bound on thefallback_isolationhint wait is an improvement — the oldreceive_untilhad only a message cap, no time bound.
Verification re-run at head: cargo fmt -p ry-lsp --check clean; cargo clippy -p ry-lsp --all-targets -- -D warnings clean; cargo test -p ry-lsp all targets green with 50 unit + 36 integration results — matching the PR body's counts.
ℹ️ Nitpicks
- The new comment in
configuration_refresh.rs("its completion publishes nothing") now sits opposite the pre-existing doc onspawn_background_index(crates/ry-lsp/src/backend.rs:1758), which says "a diagnostic refresh is triggered so cross-file calls into unopened files resolve on the next check". The old doc is defensible at the caller-flow level (did_change_watched_filesrepublishes after the reindex completes), but the two comments make opposite-sounding claims about the same function — worth a one-line clarification whenever this file is next touched.
openai-compatible/glm-5.3 | 𝕏
…al-dedup # Conflicts: # CHANGELOG.md # crates/ry-lsp/src/backend.rs # crates/ry-lsp/src/settings.rs # crates/ry-lsp/tests/configuration_refresh.rs
There was a problem hiding this comment.
✅ No new issues found — the
origin/mainmerge was verified against both parents and the full gate suite is green at the merged head.
Reviewed changes
The only delta since the prior review (611c6f9) is a merge commit bringing origin/main in after base PR #140 landed in main (95a4913, alongside #132–#142), so this run verified the merge resolution rather than new authored code: the PR diff is now purely this PR's refactor (3 files, +113/−207) instead of #140's content stacked underneath.
- Merged
origin/maininto the branch, un-stacking the PR now that #140 has landed; the diff versusmainshrank to exactly the three refactor files. - Resolved four conflicted files (
CHANGELOG.md,backend.rs,settings.rs,configuration_refresh.rs): took main's evolved #140 (theinlay_hinteligibility gate, thespawn_disabled_sessionhelper with itsenable: falsetests, settings doc clarifications) while preserving every change of this PR — sleep removals, filter/republish dedup, publish trims, and thescope_forsingle post-check. - Verified the resolution against both parents: versus
main(196850f) the merge result differs in exactly the PR's 3 files; versus the pre-merge tip the onlyry-lspdelta is main's new content — nothing dropped, and the CHANGELOG carries the #140 entry exactly once. - Confirmed the one new interaction point: main's
inlay_hintgate (crates/ry-lsp/src/backend.rs:1162) calls theeligibility_for_paththis PR restructured (crates/ry-lsp/src/backend.rs:500); the restructured order (folder contexts → server-wideenablecheck → inside-root fallback) still returnsfalsefor disabled folders, and main's newenable_false_skips_inlay_hints_for_the_foldertest pins it. - Re-ran the gates at the merged head:
cargo fmt -p ry-lsp --checkclean,cargo clippy -p ry-lsp --all-targets -- -D warningsclean,cargo test -p ry-lspgreen — 50 unit + 38 integration results (up two from main's new inlay-hint tests), with the formerly sleep-settled test files still passing on bounded waits only.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using openai-compatible/glm-5.3 | 𝕏
The doc claimed the function 'triggers a diagnostic refresh'. It does not: it only stores results in state.disk_files. Callers await it and then republish (did_change_watched_files, did_change_configuration, did_change_workspace_folders), which is what resolves cross-file calls into unopened files. State that on the function and mirror one clause in the configuration_refresh.rs comment that previously sounded like the opposite claim.
|
Reconciled the two comments in 875c5f4. On the UNSTABLE merge state: no check failed. |
There was a problem hiding this comment.
✅ No new issues found — the delta resolves the initial review's only open nitpick, and the reconciled docs check out against the code.
Reviewed changes
Since the prior review (2f9e38c) the only change is 875c5f4, a documentation-only commit reconciling the spawn_background_index docs with its callers.
- Rewrote the
spawn_background_indexdoc (crates/ry-lsp/src/backend.rs:1768) to state that the function never publishes diagnostics itself and that callers await it and then republish. Verified against the code: the body (crates/ry-lsp/src/backend.rs:1774–1901) only writesstate.disk_files, updates folder workspace contexts, and logs — no publish or schedule call — and the three state-change callers (did_change_configuration,did_change_workspace_folders,did_change_watched_files) all await-then-republish, while the startup call site ininitializedruns before any document is open, so the mechanism claim holds at every call site. - Aligned the
spawn_sessioncomment (crates/ry-lsp/tests/configuration_refresh.rs:27) to the same caller-republishes framing, replacing "its completion publishes nothing" so the two comments no longer read as opposite claims about the same function. - Confirmed
cargo fmt -p ry-lsp --checkis clean at the new head; the delta touches no executable code, so the gate results from2f9e38ccarry over.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using openai-compatible/glm-5.3 | 𝕏

Summary
Removes structural duplication and hot-path clones the base PR left alone. No behavior change. Stacked on #140; merge after it.
Changes
One filter implementation. Deleted the test-only
State::merge_filter, a near-verbatim copy ofcompute_folder_filterminus excludes and the counter.effective_filternow callscompute_folder_filterand keeps the filter. Also dropped thefile_configparameter: every call site passed the same config twice, so the folder config is now both the exclude source and the severity fallback by construction.One republish path. Extracted
republish_all_open_documentsand use it indid_change_configurationanddid_change_watched_files.did_change_workspace_folderskeeps its filtered republish on purpose: documents under removed roots were just cleared, they fall back to root-level eligibility, and a blanket reschedule would re-publish check results for them. A comment at the site states this.Legacy state removed (item 4 decision: collapse). Dropped the
workspace_folders: Vec<(PathBuf, Config)>field. Every write derived it fromfolder_contextsinside the same lock section (initialize, folder mutation, watched-files reload), so the root sets were identical at all times. That made both readers unreachable: theeligibility_for_pathfallback only ran when no context root matched the path — the same root set could not match there either — and thespawn_background_indexbranch only ran whenfolder_contextswas empty, which implied the derived vector was empty too. There is no startup window where the vector is populated and the contexts are not; the two are written together.Leaner publishes. Four trims on the path that runs after every debounced edit:
versionsmap.check_with_workspaceby value. It already re-collects its own snapshot.Generation guards and version stamping are untouched.
scope_for(item 6 decision: simplified, single check). Dropped the pre-checkparsed_versioncapture; one post-check remains: the parse cache still holds this exactArcand its tag equals the live document version. Interleavings considered:update_docremoves the entry,Arc::ptr_eqfails, no cache write. Same outcome before and after.Arc, identity fails, no cache write. Same outcome.record_parsewith a freshly parsedArc, and the cache-hit fast path returns the storedArcwithout re-installing. A supersededArcnever returns. So the pre-check could only re-derive what the post-check already proves, and the stored set is identical.Test sleeps. Removed the two 1s settles in
configuration_refresh.rsand the 300ms settle infallback_isolation.rs. The background indexer publishes nothing on completion and open documents shadow disk files, so the tests' existing bounded waits are the only synchronization they need. Thefallback_isolationhint wait gains a 2s timeout so a failure stays diagnosable.No CHANGELOG entry: internal only.
Verification
cargo fmt -p ry-lspcargo clippy -p ry-lsp --all-targets -- -D warningscargo test -p ry-lspfull suite green: 50 unit, 36 integration (including the folder-mutation convergence tests that pin the removed-root clearing the filtered republish preserves)