refactor(lsp): drop test-only counter threading, fold folder_projects into contexts - #158
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughChangesThe LSP backend now stores one Folder cache ownership
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 new issues found.
Reviewed changes — this PR's full diff (3 files, 1 commit): the two judgment-call cleanups split out from the backend.rs diet.
- Test-only counter threading removed:
filter_compile_count/compile_during_last_publish/ServerCounters/run_with_countersare gone andrun_withis now the single server-construction path for production and tests; a repo-wide grep finds no stale references to any removed symbol. The lost "zero filter compiles during publish" tripwire is a documented, by-design trade — and the disk-behavior counters (BASELINE_DISK_READS,parse_count) stay. folder_projectsfolded intoFolderAnalysisContext: the per-folderProjectCachenow lives atbackend.rs:163, and the parallel map plus its sync sites are gone. I independently confirmed the three claims in the description: the removedunwrap_or_else(root_project)fallback was unreachable on base (per_folderkeys derive fromfolder_contextsitself atbackend.rs:1325, and every base mutation of the two maps was atomic under one state lock — the config-reload path preserves roots, so keys stayed stable);rebuild_folder_contextclones the old cacheArc(backend.rs:1863) so incremental check state survives config reloads exactly as before; and lock ordering (state lock released before any project-cache lock) is unchanged atdid_close(backend.rs:899) and the publish loop (backend.rs:1307). The new comment atbackend.rs:775accurately describes the workspace-folder mutation semantics.- Test updated honestly:
many_files_flat_filter_constructionkeeps the RY090 sentinel, field-by-field equality, and first/last path assertions, and the triple-unwrapchain matches the newJoinHandle<LspResult<()>>shape.
Gates verified locally: cargo build -p ry-cli, cargo test -p ry-lsp (all targets — all suites green including the modified test), cargo clippy -p ry-lsp --all-targets -- -D warnings, and cargo fmt --check.
openai-compatible/glm-5.3 | 𝕏
7ea3b47 to
a36d033
Compare

Cleanup sprint, PR 2b (stacks on #156). Net −139 lines. These are the two "judgment call" cleanups split out from the backend.rs diet so they can be accepted or rejected independently — they are the only changes in this sprint that remove instrumentation and a defensive structure rather than pure duplication.
1. Test-only filter-compile counter threading (−~80)
filter_compile_count/compile_during_last_publish/ServerCounters/run_with_countersexisted solely so one integration test could assert "zero filter compiles during a publish cycle" — production signatures (compute_folder_filter,build_folder_contexts,rebuild_folder_context(s),refresh_cached_folder_filters) carried a counter parameter purely for it. Deleted the threading; the test keeps all its real assertions (RY090 sentinels, field-by-field equality, paths) and loses only the counter assertion.Coverage lost by design: the "zero compiles during publish" property. It is structural — filters are precomputed when folder contexts are built (
build_folder_contexts/refresh_cached_folder_filters), never inside the publish loop — but the counter was a tripwire against future regressions of that structure. If you want the tripwire back, the honest place is a debug log or adebug_assert!, not six threaded parameters.Kept:
BASELINE_DISK_READSand its three no-I/O-during-publish tests — that counter guards actual disk behavior and stays.2. folder_projects mirror folded into FolderAnalysisContext (−~59)
Statekept two parallel maps keyed by folder URI (folder_contexts,folder_projects) that were built together, synchronized at four sites, and looked up together — a desync bug class for no benefit. The project cache now lives insideFolderAnalysisContext(Arc<Mutex<ProjectCache>>), and the parallel map plus its sync code is gone.Details verified by independent review: the removed
unwrap_or_else(root_project)fallback was unreachable on base (no divergence window between the maps — every mutation was atomic under one lock);rebuild_folder_contextcarries the old cache Arc so incremental check state survives config reloads (a fresh cache there would have forced full re-installs — same diagnostics, wasted work); lock ordering (state lock released before any project-cache lock) is unchanged at all three sites.Gates
cargo test --workspace(all LSP integration suites green: protocol_contract, session_state_machine, session, protocol, fallback_isolation, configuration_refresh), clippy-D warnings, fmt.Summary by CodeRabbit
Improvements
Testing