Skip to content

chore(lsp): review follow-ups — per-file codecs, memoization tests, doc fixes - #4007

Merged
rossirpaulo merged 1 commit into
canaryfrom
paulo/lsp-followup-review-items
Jul 14, 2026
Merged

rossirpaulo merged 1 commit into
canaryfrom
paulo/lsp-followup-review-items

Conversation

@rossirpaulo

@rossirpaulo rossirpaulo commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #4000 (retargets to canary when it merges). Batches the four small items deferred from the #4000 review cycle so the approved, CI-green main PR stayed untouched.

  1. Per-file PositionCodec in references and workspace/symbol — CodeRabbit's one valid Major on fix(lsp): resolve the 0.14 mutex/latency regression — Phase 0 containment + Phase 1 bounded ingress #4000: codec construction scans the entire target file to build its line table, and both handlers built one per result; a symbol with N usages in one file did N identical scans. Now one codec per distinct file via a lazy map inside each handler (the same pattern document_symbol already used).
  2. Memoization contract tests (ported from the alternate implementation's test suite): file_annotations and semantic_tokens execute exactly once cold, zero times warm, and once again after a source edit — asserted by counting salsa WillExecute events, so future implementation rewrites (including the feat(lsp): resolution-first semantic tokens rework #3867 re-land) keep the tests meaningful. This also formally answers the stale "bypasses Salsa memoization" review claim on refactor(lsp): Phase 0 latency and mutex containment #3969 by pinning the invariant.
  3. TEST_INSTRUCTIONS.md: the "Verify all tests pass" section now includes cargo test --lib (previously the documented flow skipped the workspace unit tests entirely — where all of fix(lsp): resolve the 0.14 mutex/latency regression — Phase 0 containment + Phase 1 bounded ingress #4000's new tests live), and two case-sensitive UPDATE_EXPECT references fixed (lowercase update_expect=1 is a silent no-op for expect-test).

Validation: bex_project 45/45, baml_lsp2_actions_tests 377/377 (incl. the 2 new memoization tests), clippy -D warnings clean, wasm check clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VEMxti5WQ8bCgJUuX9AQvo

Summary by CodeRabbit

  • Performance

    • Improved responsiveness for “Find References” and workspace symbol searches, especially when results span multiple locations in the same file.
  • Bug Fixes

    • Strengthened language-server behavior verification to ensure cached results are reused correctly and refreshed after source changes.
  • Documentation

    • Clarified testing guidance for Rust changes and language-server snapshot updates.

@vercel

vercel Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview, Comment Jul 14, 2026 12:06am
promptfiddle Ready Ready Preview, Comment Jul 14, 2026 12:06am
promptfiddle2 Ready Ready Preview, Comment Jul 14, 2026 12:06am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds Salsa memoization tests and test workflow guidance, and changes LSP references and workspace symbol handlers to reuse PositionCodec instances per target file.

Changes

Memoization test coverage

Layer / File(s) Summary
Memoization test harness and coverage
baml_language/TEST_INSTRUCTIONS.md, baml_language/crates/baml_lsp2_actions_tests/...
Adds Salsa test support and verifies cold, warm, and source-edit-triggered execution of file_annotations and semantic_tokens. Updates Rust and LSP testing instructions.

LSP position codec caching

Layer / File(s) Summary
Per-file position codec caching
baml_language/crates/bex_project/src/bex_lsp/multi_project/request.rs
Reuses cached PositionCodec instances by file_id when converting references and workspace symbols to LSP ranges.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

Suggested reviewers: sxlijin, codeshaunted, aaronvg

Poem

I’m a rabbit with tests in my burrow tonight,
Salsa stays warm when the source stays right.
A changed file wakes queries anew,
Cached codecs make ranges zoom through.
Hop, hop—snapshots now guide the view!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main follow-up changes: per-file codec reuse, memoization tests, and documentation fixes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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 paulo/lsp-followup-review-items

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.

❤️ Share

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

@github-actions

Copy link
Copy Markdown

⏭️ Performance benchmarks were skipped

Perf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to canary/main.

To run them on this PR, do any of the following, then push a commit (or re-run CI):

  • Add RUN_CODSPEED=1 to the PR description, or
  • Include run-perf or /perf in the PR title or any commit message.

@vercel
vercel Bot temporarily deployed to Preview – beps July 13, 2026 22:12 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 13, 2026 22:19 Inactive
@github-actions

github-actions Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

Binary size checks passed

✅ 7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
✅ baml-cli Linux 🔒 22.1 MB 9.4 MB file 21.5 MB +537.5 KB (+2.5%) OK
✅ packed-program Linux 🔒 15.8 MB 6.7 MB file 15.6 MB +200.1 KB (+1.3%) OK
✅ baml-cli macOS 🔒 17.0 MB 8.2 MB file 16.6 MB +415.9 KB (+2.5%) OK
✅ packed-program macOS 🔒 12.2 MB 5.9 MB file 12.1 MB +117.2 KB (+1.0%) OK
✅ baml-cli Windows 🔒 18.5 MB 8.4 MB file 18.1 MB +420.4 KB (+2.3%) OK
✅ packed-program Windows 🔒 13.1 MB 6.0 MB file 13.0 MB +113.1 KB (+0.9%) OK
✅ bridge_wasm WASM 14.6 MB 🔒 4.1 MB gzip 4.1 MB +77.3 KB (+1.9%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.


Generated by cargo size-gate · workflow run

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 13, 2026 22:33 Inactive
Base automatically changed from paulo/lsp-latency-mutex-full to canary July 13, 2026 23:42
…oc fixes

Batches the four review items deferred from #4000's review cycle:

- references and workspace/symbol handlers build one PositionCodec per
  distinct target file instead of per result (codec construction scans
  the whole file for its line table; many results share a file).
- Port the salsa event-log memoization tests: file_annotations and
  semantic_tokens execute once cold, zero warm, and re-execute after a
  source edit (pins the B1 tracked-query contract; count-based so
  implementation rewrites keep the tests meaningful).
- TEST_INSTRUCTIONS.md: add `cargo test --lib` to the verification
  section; fix two case-sensitive UPDATE_EXPECT references (lowercase
  `update_expect=1` is a silent no-op).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VEMxti5WQ8bCgJUuX9AQvo
@rossirpaulo
rossirpaulo force-pushed the paulo/lsp-followup-review-items branch from 5329262 to d3cfa2c Compare July 13, 2026 23:43
@vercel
vercel Bot temporarily deployed to Preview – beps July 13, 2026 23:44 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 13, 2026 23:52 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
baml_language/crates/baml_lsp2_actions_tests/src/memoization.rs (1)

88-93: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Decouple invalidation checks from result inequality.

A query can be correctly invalidated and recomputed while producing the same observable result. The contract under test is the WillExecute == 1 assertion, so assert_ne! makes these tests unnecessarily brittle.

  • baml_language/crates/baml_lsp2_actions_tests/src/memoization.rs#L88-L93: remove assert_ne!(changed, cold) for file_annotations.
  • baml_language/crates/baml_lsp2_actions_tests/src/memoization.rs#L109-L114: remove assert_ne!(changed, cold) for semantic_tokens.
Suggested adjustment
-    assert_ne!(changed, cold);
     assert_eq!(query_execution_count(&db, &events, "file_annotations"), 1);
🤖 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 `@baml_language/crates/baml_lsp2_actions_tests/src/memoization.rs` around lines
88 - 93, Remove the result-inequality assertions from both memoization checks:
the file_annotations test at
baml_language/crates/baml_lsp2_actions_tests/src/memoization.rs:88-93 and the
semantic_tokens test at
baml_language/crates/baml_lsp2_actions_tests/src/memoization.rs:109-114. Keep
the WillExecute/query_execution_count assertions as the sole validation that
each query was invalidated and recomputed.
🤖 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.

Nitpick comments:
In `@baml_language/crates/baml_lsp2_actions_tests/src/memoization.rs`:
- Around line 88-93: Remove the result-inequality assertions from both
memoization checks: the file_annotations test at
baml_language/crates/baml_lsp2_actions_tests/src/memoization.rs:88-93 and the
semantic_tokens test at
baml_language/crates/baml_lsp2_actions_tests/src/memoization.rs:109-114. Keep
the WillExecute/query_execution_count assertions as the sole validation that
each query was invalidated and recomputed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a5fb1f8b-aaca-4259-8d5f-512ad86f56f9

📥 Commits

Reviewing files that changed from the base of the PR and between 30eb1c1 and d3cfa2c.

⛔ Files ignored due to path filters (1)
  • baml_language/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • baml_language/TEST_INSTRUCTIONS.md
  • baml_language/crates/baml_lsp2_actions_tests/Cargo.toml
  • baml_language/crates/baml_lsp2_actions_tests/src/lib.rs
  • baml_language/crates/baml_lsp2_actions_tests/src/memoization.rs
  • baml_language/crates/bex_project/src/bex_lsp/multi_project/request.rs

@rossirpaulo
rossirpaulo enabled auto-merge July 13, 2026 23:59
@rossirpaulo
rossirpaulo added this pull request to the merge queue Jul 14, 2026
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 14, 2026 00:06 Inactive
Merged via the queue into canary with commit 77f7efd Jul 14, 2026
54 checks passed
@rossirpaulo
rossirpaulo deleted the paulo/lsp-followup-review-items branch July 14, 2026 00:27

This branch was previously deployed

3 inactive deployments
Preview – promptfiddle — d3cfa2cf Deployed Jul 14, 2026 by vercel[bot]
Preview – promptfiddle2 — d3cfa2cf Deployed Jul 13, 2026 by vercel[bot]
Preview – beps — d3cfa2cf Deployed Jul 13, 2026 by vercel[bot]
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.

1 participant