# code-lens ## Goal `textDocument/codeLens` puts one line of true, computed information above every module and interface declaration in the open buffer: **"N instantiations"** — how many times the whole workspace instantiates that module — with "1 instantiation" and "no instantiations" spelled the way a person would. It is the single most Verilog-shaped thing a lens can say: a module's fan-in is the number an RTL engineer actually wants when they open a file, and until now it took opening the call hierarchy to learn it. Clicking a lens answers with every instantiation site, and — for a client that advertised `window/showDocument` — jumps to the first of them. The count is not a second census: it is computed by the very walk `callHierarchy/incomingCalls` is computed by, so the lens and the hierarchy view can never disagree (TODO.md §9c). ## Assumptions - **The population is `incomingCalls`'s population, and nothing else.** N is the number of instantiation *sites* — the sum of every `fromRanges` entry `callHierarchy/incomingCalls` would list for that module, not the number of instantiating modules. A module instantiated twice inside one `top` reads "2 instantiations", because that is what a user counting instances means. `the_count_is_exactly_what_incoming_calls_would_list` asserts the equality directly rather than restating the arithmetic. - **An instantiation at file scope is not counted**, because it has no enclosing module to be a caller. That is inherited, not decided here: it is the rule `hierarchy::callers_in` already applied, and the whole point of reusing the census is that this feature does not get to have its own opinion. Such a file is illegal SystemVerilog anyway and only reachable through the tolerant parser. - **The census is by name.** Two modules named `fifo` in one workspace get the same count on both their lenses, and clicking either shows every site of either. Same limitation `callHierarchy/incomingCalls` has, for the same reason: an instantiation names a module, and nothing in the source says which of two same-named declarations it meant. - **The lens's range is the declaration's own name span.** Clients draw a lens on the line *above* `range.start`, so the name span puts it directly over the header and nowhere else. A declaration whose name span is empty — what the tolerant parser produces for `module ;` — gets no lens: there is no line to sit on, and an invented one would decorate the wrong code. - **An interface is a module declaration.** `interface bus; ... endinterface` parses to the same `ast::Module` node with `kw == "interface"`, so it is reached by `instantiations::declarations` and instantiated through the same `ItemKind::Instantiation`. No branch was written for it; a test pins that it works. - **`resolveProvider: false`, and every lens is complete.** Title, command and arguments are all computed up front, matching what completion, inlay hints and document links do in this server. The count is the expensive part and it is exactly what a resolve would have to compute, so a two-stage protocol would buy nothing. - **A module with no instantiations gets a display-only lens** — a `Command` whose `command` is the empty string, which is what rust-analyzer ships for the same case and what clients render as plain text. There is nothing to open; a click that led to an empty list would be worse than no click. It also carries no `arguments`. - **`window/showDocument` shows only the first site.** LSP has no server-initiated "peek these seven places" — that is VS Code's `editor.action.showReferences`, a *client-side* command, and this repo's extension declares none (and this round did not touch `editors/`). The honest portable behaviour is: the command's result is the full list of `Location`s, for any caller that wants it, and the push opens the first one for a client that can be pushed to. A client without the capability still gets the list. - **`workspace/codeLens/refresh` is sent from `reindex()` only.** Not at startup: no buffer is open there, so there are no stale lenses to invalidate. Not on a keystroke either — a `didChange` cannot change any count, since the census is over instantiations in *other* files and a client re-requests lenses for the buffer it just edited anyway. - **The count is computed against `Workspace::sources()`**, which reads every in-scope file from disk with open buffers overriding it. So an unsaved instantiation typed into another open buffer *is* counted, and a file changed on disk that no watcher reported is counted as of this request. - **The cost is one workspace walk per request, not one per module.** `hierarchy::callers_of_each` takes a batch precisely because `sources()` re-reads the whole file set: measured over the 860-file corpus, a three-module file costs 133 ms against 93 ms for a single name (debug build) — amortized, not tripled. The absolute number is the honest cost of having no instantiation-edge table in the index; see Status / TODO. ## Handshakes ### Request to `vlog_semantic` — an instantiation-edge table in the index Filed by the lead (2026-08-26) on QA's recommendation, since **two** shipped features now pay the same cost: every `textDocument/codeLens` request and every `callHierarchy/incomingCalls` walks `Workspace::sources()` — a re-read and tolerant re-parse of every in-scope file — because `WorkspaceIndex` records what a file *declares* and never what it *instantiates*. The ask: at index build time (the same rebuild `reindex()` already pays for), record the instantiation edges, e.g. ```rust /// Every instantiation of `name` across the indexed files: /// (file, instantiating-module name span, instance site span). pub fn instantiations_of(&self, name: &str) -> &[InstantiationEdge] ``` so `hierarchy::callers_of_each` becomes a lookup and its whole walk-and-parse body is deleted. The census policies (multi-instance statements = one site, textual not elaborated, both `ifdef` arms) must carry over unchanged — `lens.rs`'s QA tests pin the numbers that must not move. ### `lucisv_server::hierarchy` — **changed, deliberately** `incoming` was split so the census has exactly one implementation: - **New public** `hierarchy::callers_of_each(ws, names: &[&str]) -> Vec>` — the same walk, asked about a batch of names, answering one list per name in the order asked. It is now the primitive. - `hierarchy::incoming(ws, item)` is a one-line call into it with a one-element batch. **Its behaviour is unchanged**, empty-name guard included: the guard moved into the batch's per-name filter, where an empty name matches no file rather than every file. - The private `callers_in` now takes an already-parsed file (`&Uri`, `&Positions`, `&[Site]`) instead of a path and text, so one file is parsed once for a whole batch rather than once per name. The `Positions` for a file is now built whenever any name matches, rather than only when a caller was found — a `LineIndex::new` per candidate file, which the batch more than pays back. Nothing else in `hierarchy.rs` moved, and its own tests are untouched and green. ### `lucisv_server::server` - `ClientAbilities` gains **two** fields, both filled in `main.rs`: `code_lens_refresh` (from `workspace.codeLens.refreshSupport`) and `show_document` (from `window.showDocument.support`). Every existing test that builds `ClientAbilities { ..Default::default() }` is unaffected. - `request()` gains a `CodeLensRequest` arm, and its `ExecuteCommand` arm now routes `lucisv.showInstantiations` to `lens::execute` before falling through to `ports::execute`. - New private `show_instantiations(Vec) -> Result` (the answer, plus the optional push) and `refresh_code_lenses()` (the gated server-initiated request). - `reindex()` calls `refresh_code_lenses()` immediately after `end_indexing(bar)` and before the generation bump, the scope warnings and the republishes. Pinned by `the_refresh_rides_after_the_indexing_bar_comes_down`. - `response()`'s doc comment now names four ignorable answers rather than two. Its code is unchanged: the refresh's and the showDocument's ids are never in `applying`, so they fall through the existing lookup. ### `lucisv_server::main` - `capabilities()` gains `code_lens_provider: Some(CodeLensOptions { resolve_provider: Some(false) })`. - `execute_command_provider.commands` is now a new local `commands()` — `ports::commands()` plus `lens::commands()` — rather than `ports::commands()` alone. A lens whose command is not advertised is a lens no client will run, so `every_advertised_command_is_one_the_server_runs` now checks both halves. ### `state::Workspace`, `vlog_parser`, `vlog_semantic`, `vlog_refactor` **Untouched.** No signature moved and nothing was plumbed. The declarations come from `instantiations::declarations`, which already existed for the hierarchy, and the counts from `Workspace::sources()`, which already existed for it too. ### `editors/vscode` **No extension change**, and none was made. `vscode-languageclient` requests code lenses and renders them with no help from `extension.js`; it advertises `workspace.codeLens.refreshSupport` and `window.showDocument` itself. `smoke.js` sends `capabilities: {}`, so it takes the no-refresh, no-showDocument path — verified by running it. ## Status / TODO - [x] `codeLensProvider` advertised with `resolveProvider: false` - [x] `textDocument/codeLens` dispatched; one lens per module/interface declaration, on the name span, in source order - [x] Count reuses the `incomingCalls` census (`hierarchy::callers_of_each`), with an equality test against `hierarchy::incoming` - [x] Pluralization: "no instantiations" / "1 instantiation" / "N instantiations" - [x] `lucisv.showInstantiations` advertised and dispatched; answers every site as a `Location`; declines arguments it cannot read as `RequestFailed` - [x] `window/showDocument` pushed for the first site, gated on the client capability - [x] `workspace/codeLens/refresh` from `reindex()`, gated on `workspace.codeLens.refreshSupport`, after the progress bar comes down - [x] Unopened buffer → `null`; unnamed declaration → no lens; a buffer that parses to nothing → empty list - [x] Tests: 33 (19 in `lens.rs`, 9 in `server.rs`, 3 in `main.rs`, 2 e2e) - [x] TODO.md §9c checkbox, `docs/features/lucisv-server/README.md` capability table - [ ] **Not done, deliberately:** no second lens kind. A "top module" indicator, a parameter count, a "run this testbench" action are all plausible and none was asked for; one lens kind done well beats three guessed at. - [ ] **Not done, deliberately:** no `codeLens/resolve`. Everything a resolve could defer is the one expensive thing the lens *is*. - [ ] **Not done, deliberately:** no peek-references behaviour. It needs a client-side command declared in `editors/vscode/package.json`, which is out of this round's scope; `window/showDocument` is the portable substitute and reaches Neovim as well. - [ ] **Open, filed here:** the request costs one full `Workspace::sources()` read — 133 ms over the 860-file corpus in a debug build. That is the same cost `callHierarchy/incomingCalls` has always had, but a lens request arrives far more often than a hierarchy question. The real fix is an instantiation-edge table in `WorkspaceIndex`, built once per rescan, which would make both this and `incomingCalls` a lookup. That is a `vlog_semantic` change and belongs in its own round; **request recorded here, not made.** ## Work log ### 2026-08-26 — dev agent, §9c - **The click-behaviour decision, and why.** The brief left this open with a fallback to display-only. I built the real jump, because reading `hierarchy::incoming` showed the locations were *already there* — every `fromRanges` entry is a site, paired with its file's URI — so `lucisv.showInstantiations` is a flatten and nothing more. The chain the brief worried might be heavy is about fifteen lines: `lens::execute` returns `Vec`, `Server::show_instantiations` pushes a `window/showDocument` for the first when the client advertised it, and the answer is the list either way. Display-only survives as the honest answer for the **zero** case only, where there is nothing to open — which is exactly where rust-analyzer uses the same empty-command trick. So: real behaviour everywhere it can mean something, display-only where it cannot. - **The arguments are `[module-name]`, not `[uri, name]`.** The brief suggested the URI first, in the style of the port commands. I dropped it after establishing that the census is *purely* by name — `hierarchy::incoming` reads only `item.name` and nothing else off its item — so a URI would be an argument the handler receives and ignores, and this repo does not ship those. One argument, all of it used. - **A name the workspace does not declare is not an error.** The brief asked for one. I did not build it, and the reason is a real failure mode rather than taste: the only index-backed way to ask "is this a module?" is `WorkspaceIndex::units`, and the index is rebuilt on *save*, so a module just typed into an open buffer is genuinely absent from it. Gating on that would make the command refuse the very lens that is on screen. Malformed arguments (missing, non-string, empty) are still declined as `RequestFailed`, per `ports.rs`; a well-formed name with no sites answers `[]`, which is the truth. - **The census was extracted rather than duplicated, and the batch is why.** Naively, `code_lenses` would call `hierarchy::incoming` once per module in the buffer — but `Workspace::sources()` re-reads every in-scope file from disk on *each* call, so a three-module file would read the workspace three times. So `incoming`'s body became `callers_of_each(ws, names)`, which reads the file set once and parses each candidate file once for the whole batch; `incoming` is now that function with a one-element batch. Measured over the 860-file corpus: three names 133 ms, one name 93 ms — amortized, and pinned by `code_lenses_for_a_whole_file_cost_about_one_workspace_walk`, which fails if the ratio ever goes linear. - **The empty-name guard moved and got stricter.** It used to be an early return in `incoming`; it is now a per-name filter inside the batch, so one empty name in a batch of five costs nothing and cannot make the prefilter match every file. Same behaviour for `incoming`, which is still the only caller that could ever be handed one. - **The lens sits on the name span, not the header line.** Clients draw the lens on the line above `range.start`; the name span and the header line have the same start line, but the name span is the one that stays right when a declaration is written with attributes or a leading comment on the same line. - **Refresh placement.** Straight after `end_indexing(bar)` in `reindex()`, following the progress round's own precedent that the bar names the scan and everything after it is work on the scan's result. Order pinned by a test (`create, begin, end, refresh`) so it cannot drift silently. Nothing is sent at startup — there is no open buffer holding lenses there. - **A buffer with no named declarations returns before the workspace walk.** Otherwise opening a package or a header file would read every file in the project to produce an empty list. - Files touched: `crates/lucisv_server/src/lens.rs` (new), `crates/lucisv_server/src/hierarchy.rs`, `crates/lucisv_server/src/server.rs`, `crates/lucisv_server/src/main.rs`, `crates/lucisv_server/tests/e2e.rs`, `TODO.md`, `docs/features/lucisv-server/README.md`, this README. No engine crate, no `editors/`, no new dependency, no version bump. **Verification.** `cargo fmt --all -- --check`: clean. `cargo clippy --all-targets`: zero warnings. `cargo test --workspace`: **1943 passed, 0 failed** (1910 on `HEAD` `34938fb`, measured — 33 new). `cargo build && node editors/vscode/smoke.js target/debug/lucisv-server`: `smoke: OK`, exit 0. No commits. The 33 tests, and what each group is for: | tests | pin | |---|---| | `lens.rs` — `a_lens_counts_every_instantiation_in_the_workspace`, `the_title_counts_in_the_users_own_arithmetic` | the cross-file count, and 0/1/N pluralization including "not `1 instantiations`" | | `lens.rs` — `the_count_is_exactly_what_incoming_calls_would_list` | the agreement with `hierarchy::incoming`, asserted against its live answer rather than against a number | | `lens.rs` — `an_instantiation_at_file_scope_is_not_counted_because_no_one_calls_it` | the inherited caller rule, stated so a future change to it is visible here | | `lens.rs` — `the_lens_sits_on_the_declarations_own_name`, `every_module_in_a_file_gets_its_own_lens_in_source_order` | the range is the name span; one lens per declaration, source order | | `lens.rs` — `an_interface_is_a_module_declaration_and_gets_its_own_lens` | interfaces, which needed no branch | | `lens.rs` — `a_module_nothing_instantiates_gets_a_lens_that_does_not_click`, `a_clickable_lens_carries_the_module_name_as_its_only_argument`, `no_lens_is_ever_left_for_a_resolve_to_fill_in` | the two command shapes, and that nothing is left unresolved | | `lens.rs` — `a_buffer_this_server_was_never_shown_has_no_lenses_at_all`, `a_buffer_that_declares_no_module_gets_an_empty_list`, `a_buffer_that_is_not_verilog_at_all_gets_no_lenses_and_does_not_panic`, `a_declaration_the_parser_could_not_name_gets_no_lens` | the four refusals: `null`, empty, total on junk, no lens without a name span | | `lens.rs` — `the_command_answers_one_location_per_site`, `..._nothing_for_a_module_nothing_instantiates`, `..._declines_arguments_it_cannot_read`, `the_command_list_is_what_the_server_advertises` | the command: one location per site in file-then-position order, the empty answers, the refusals | | `lens.rs` — `code_lenses_for_a_whole_file_cost_about_one_workspace_walk` | the batch really is one walk (corpus, skipped when absent) | | `server.rs` — `a_code_lens_request_counts_the_workspaces_instantiations`, `..._for_an_unopened_buffer_answers_null` | dispatch, and the `null` | | `server.rs` — `the_show_instantiations_command_answers_every_site`, `..._pushes_a_show_document_when_it_can`, `a_module_with_no_instantiations_pushes_nothing_and_shows_nothing`, `..._declines_arguments_it_cannot_read` | the command over the dispatch, both `showDocument` gate states, and the `RequestFailed` code | | `server.rs` — `a_rescan_asks_a_capable_client_to_refresh_its_code_lenses`, `a_client_that_cannot_refresh_code_lenses_is_never_asked_to`, `the_refresh_rides_after_the_indexing_bar_comes_down` | both polarities of the refresh gate, all three rescan paths, no refresh at startup, and the order against the progress bar | | `main.rs` — `code_lenses_resolve_nothing_because_every_lens_is_complete`, `code_lens_refresh_support_...`, `show_document_support_...` | the advertised option, and both capability readers at absent/false/true | | `e2e.rs` — `code_lenses_and_their_command_round_trip_over_the_wire` | the capability's JSON shape, the lens JSON (title, command, arguments, range, no `data`), the command's locations, the `null`, and that the lens's command is in `executeCommandProvider.commands` | | `e2e.rs` — `a_save_asks_a_capable_client_to_refresh_its_code_lenses_over_the_wire` | the refresh on the wire, both gate states, against the real binary | ## QA log - **2026-08-26 (QA)** — read this README, `hierarchy/README.md` (its QA log especially — the `ifdef` and generate-replication findings there turned out to answer several questions this round would otherwise have raised fresh), `instantiations.rs`, `hierarchy.rs` end to end (diffed function-by-function against `34938fb`), `lens.rs`, and the `server.rs`/`main.rs` diffs, before touching anything. **Gates, independently re-run.** `cargo fmt --all -- --check`: clean. `cargo clippy --all-targets --workspace`: zero warnings. `cargo test --workspace`: **1943 passed, 0 failed** before any QA change, matching the dev's number exactly; **1952 passed, 0 failed** after adding 9 QA tests (6 in `lens.rs`, 3 in `server.rs` — see below). `cargo build && node editors/vscode/smoke.js target/debug/lucisv-server`: `smoke: OK`, exit 0, run twice (before and after the QA tests). **1. The `hierarchy.rs` refactor.** Diffed `git show 34938fb:crates/lucisv_server/src/hierarchy.rs` against the working tree function by function. `incoming` is now `callers_of_each(ws, &[item.name.as_str()]).pop().unwrap_or_default()` — a one-element batch. Confirmed by construction that `callers_of_each`'s per-file loop is unchanged in substance: same `parse_source_tolerant` (not the strict parser — a mode change would have silently changed counts on broken files, and it did not happen), same `site.inst.module != name` filter inside `callers_in`, same final sort. The only real change is *where* the prefilter and the parse happen: once per name before (`callers_in` took `path: &Path, text: &str`), once per **file** now, with the parsed `sites` reused across every name the batch is asking about. - *Empty name in a batch.* Traced by hand: `wanted` filters out any index whose name is empty or absent from the file's text, so an empty name never reaches `callers_in` and its slot in `answers` stays `Vec::new()`. Byte-identical to the old early-return in `incoming`. No new test needed — the dev's own doc comment states this and it holds. - *Duplicate names in one batch, `["m", "m"]`.* New test `qa_two_declarations_of_the_same_name_in_one_file_each_get_their_own_lens_same_count` (`lens.rs`) — a file with two `module m` declarations (reachable through the tolerant parser) instantiated once, opened as a buffer. Both indices are processed independently (the loop does not deduplicate `wanted`), so neither aliases nor corrupts the other — both lenses read "1 instantiation". Redundant work (the same file is walked twice for the same name), not a correctness bug. - *A name that is a package, not a module.* Not a distinct code path: `callers_of_each` matches purely on `site.inst.module`, a string, with no knowledge of what kind of thing owns that name. Nothing to test beyond what `hierarchy.rs`'s own `qa_instantiation_in_a_package_does_not_crash` already covers. - **Verdict: behavior-preserving.** `incoming`'s own 25 tests are untouched and green, which is necessary but — per the brief — not sufficient; the above traces the edge cases a black-box test-pass rerun cannot see, and none of them diverge. **2. Count honesty.** The Assumptions section already states the load-bearing facts: *the population is `incomingCalls`'s, by name, and one `Instantiation` is one site "however many instances it declares"* — that last part is `hierarchy.rs`'s own documented policy (2026-08-25 QA round), inherited rather than decided here. Checked whether the fixture agreement test would actually catch a divergence: it cannot, structurally — `lens.rs` and `hierarchy::incoming` both bottom out in the literal same `hierarchy::callers_of_each` call, so "agreement" is guaranteed by construction, not by the fixture's shape. What the fixture's shape *does* affect is whether **this feature's own test suite** would notice if that shared implementation's semantics ever changed under it — e.g. if `callers_of_each` started counting instances instead of AST nodes, no existing `lens.rs` test using `TOP` (two separate statements) would catch it, because two separate statements give the same answer either way. Added 6 tests to `lens.rs` pinning the number itself over shapes the fixture never exercises, each with expected output derived independently (by reading `instantiations.rs`'s `walk`, not by running the code first): - `qa_a_multi_instance_statement_is_one_site_not_two` — `sub u1 (), u2 ();` is **one** `Instantiation` node with two `Instance` entries, and reads "1 instantiation", one `Location`. Matches `hierarchy/README.md`'s stated policy exactly (it names this exact source shape). Not a finding — a confirmed, disclosed design decision — but it was untested at the code-lens layer, where a user is more likely to notice the number than in a hierarchy view. - `qa_a_module_that_instantiates_itself_counts_its_own_instantiation` — self-recursion reads "1 instantiation", one site, no hang. Consistent with `hierarchy.rs`'s own self-instantiation and cycle handling (each request answers one hop). - `qa_two_files_declaring_the_same_module_name_get_the_same_count_on_both` — two files each declaring `module m`, one real instantiation of `m` elsewhere: opening *either* declaration reads "1 instantiation" — the workspace-wide total, not zero and not partitioned. Matches the documented "census is by name" Assumption; confirms it holds in both directions (the fixture I found only tried one file, not the other). - `qa_two_declarations_of_the_same_name_in_one_file_each_get_their_own_lens_same_count` — described above under the hierarchy refactor; also a code-lens-level consequence of the same policy: **two lenses**, same count on both, in one buffer. - `qa_a_generate_replicated_instantiation_counts_the_written_statement_once` — a `generate for` loop wrapping one instantiation reads "1 instantiation" regardless of the genvar's range (textual, not elaborated), matching `hierarchy.rs`'s own precedent for the identical shape. - `qa_an_ifdef_guarded_instantiation_counts_both_arms` — `` `ifdef``/`` `else`` both arms read "2 instantiations". This is `hierarchy.rs`'s disclosed `ifdef` policy (2026-08-25 finding, fixed by documentation then) surfacing on a second, more visible feature. Not re-litigated here since the underlying behavior was already reviewed and accepted by the lead; pinned so a change to it is visible from `lens.rs` too, not only `hierarchy.rs`. None of the six disagreed with `hierarchy::incoming` (they structurally cannot), and none exposed a new corruption or miscount — every number above is the intentional, already-documented arithmetic. The value added is regression coverage at the layer users actually read the number from. **3. Cost / request amplification.** Traced `code_lenses` in `lens.rs`: one call to `hierarchy::callers_of_each(ws, &names)` with the *whole* buffer's declared names, which itself calls `ws.sources()` exactly once inside its single `for (path, text) in ws.sources()` loop — confirmed by reading the loop body, not by profiling. No per-lens or per-module `sources()` call exists anywhere in the path from `CodeLensRequest` to the answer. The **index-table follow-up**: filed in Status/TODO ("an instantiation-edge table in `WorkspaceIndex`... request recorded here, not made"), in the same style as `hierarchy/README.md`'s own equivalent backlog bullet from the prior round — consistent with house precedent, but neither one is written as a *concrete* Handshake (a proposed `vlog_semantic` function signature and contract) the way CLAUDE.md's Handshakes section is meant to capture a cross-module request. **Minor, LOW severity, not fixed**: recommend the lead decide whether a backlog TODO bullet is sufficient here (matching existing house style) or whether, now that *two* features would benefit from the same index change, it is worth promoting to an actual Handshakes-section proposal with a named function shape. Not fixed unilaterally — this is a documentation-structure judgment call, not a typo. **4. `showDocument` push.** Read `show_instantiations` and `deliver` side by side: `deliver` is the only function that inserts into `self.applying`; `show_instantiations` calls `send_request(ShowDocument::METHOD, ...)` directly and never touches `applying`, so its response id always falls through `response()`'s `let Some(command) = self.applying.remove(...) else { return }` — exactly the mechanism the doc comment claims. Confirmed via the dev's own tests that the gate (`self.abilities.show_document`) is checked before the push, that a client without it still gets the full location list, and that the pushed request's shape (`uri` of the first site, `takeFocus: true`, `selection` = that site's range) is correct. **New test** `qa_a_showdocument_push_and_an_applyedit_push_stay_independent_when_both_are_outstanding` (`server.rs`) — one `PROPAGATE_PORTS` command outstanding (an `applyEdit` push, tracked in `applying`) and one `SHOW_INSTANTIATIONS` command outstanding (a `showDocument` push, not tracked) at the same time, answered in reverse send order. The showDocument answer produces no message (correctly ignored even though it carries no `applied` field at all, which would be a type-mismatch panic risk if `response()` ever tried to interpret it as an `ApplyWorkspaceEditResponse`); the applyEdit answer is still routed to its own command correctly afterward. This was asked for explicitly in the brief and had no existing test — ids are allocated by a strictly increasing counter (`send_request`), so collision was never actually possible, but the mechanism is now pinned rather than just argued. Also confirmed by reading the `ExecuteCommand` dispatch arm: `lucisv.showInstantiations` returns from inside the `if` before `ports::execute`'s `Ok((edit, warnings)) => self.deliver(...)` branch is ever reached, so `deliver()` cannot fire for it — no test needed beyond the existing `the_show_instantiations_command_answers_every_site` asserting `session.requests().is_empty()` for a client without `apply_edit` either. **5. Refresh discipline.** Verified independently: `refresh_code_lenses` gates only on `self.abilities.code_lens_refresh`, never on `work_done_progress` — the dev's own `a_rescan_asks_a_capable_client_to_refresh_its_code_lenses` already uses `ClientAbilities { code_lens_refresh: true, ..Default::default() }` (so `work_done_progress` is `false`) and gets three refreshes, which is the independent-gates case the brief asked about, already covered. Never at startup (`reindex` is not called there). **New test** `qa_a_rescan_with_several_open_buffers_still_sends_exactly_one_refresh` (`server.rs`) — two open buffers, one save: exactly one `workspace/codeLens/refresh`, confirming the call sits before the per-buffer republish loop in `reindex()` rather than inside it (the dev's existing test only ever opened one buffer, so this distinction was argued from reading the code, not from a test, before now). Order-pinned by the dev's own `the_refresh_rides_after_the_indexing_bar_comes_down`; re-verified by hand against `reindex()`'s body. Response ignored: same `applying`-lookup mechanism as `showDocument`, covered by the new interleaving test's reasoning (refresh never inserts into `applying` either). **6. Command surface.** `execute_command_provider.commands` is `commands()` = `ports::commands()` ++ `lens::commands()`; `main.rs`'s own `every_advertised_command_is_one_the_server_runs` now checks both halves are contained, not just equality with the concatenation (equality alone would not have caught one list silently dropping an entry the other didn't add back). `git diff --stat -- crates/lucisv_server/src/ports.rs` confirms it is untouched. Confirmed by reading the `ExecuteCommand` arm (see point 4) that `lucisv.showInstantiations` never reaches `deliver()`. **7. CLAUDE.md compliance.** `grep` for `unwrap()`/`expect(`/`panic!` in `lens.rs` and `hierarchy.rs` outside `#[cfg(test)]`: none. Same check against the added lines in `server.rs`/`main.rs`: every hit is inside `mod tests`. No `#[allow(...)]`, no `unsafe`, anywhere in the diff. Every public item in `lens.rs` carries a one-line doc comment. `TODO.md`'s §9c item text is untouched — only the checkbox flipped to `[x]`, with a "→ delivered" paragraph appended below it, matching the rule ("leave the item text intact"). This README's seven sections are each present exactly once. **C. Corpus, machine-checked.** New test `qa_corpus_counts_agree_with_grep_derived_ground_truth` (`lens.rs`), against `corpus/common_cells/src/cdc_fifo_gray.sv` (three module declarations, same file the dev's own perf test already uses). Ground truth built by hand with `grep -rnE '\bNAME\b' corpus --include='*.sv' --include='*.svh'`, read line by line to exclude the declaration itself and doc-comment mentions (`cdc_fifo_gray_clearable.sv` has several, e.g. "In contrast to the cdc_fifo_gray version..." — a real risk if the walk ever matched comment text, which `instantiations::sites` structurally cannot): | module | grep-derived instantiation sites | lens read | |---|---|---| | `cdc_fifo_gray` | 1 (`common_cells/test/cdc_fifo_tb.sv:49`, `i_dut`) | "1 instantiation" | | `cdc_fifo_gray_src` | 1 (`cdc_fifo_gray.sv:130`, inside `cdc_fifo_gray` itself) | "1 instantiation" | | `cdc_fifo_gray_dst` | 1 (`cdc_fifo_gray.sv:145`, inside `cdc_fifo_gray` itself) | "1 instantiation" | All three agree. Run in release (`cargo test -p lucisv_server --release qa_corpus_counts_agree_with_grep_derived_ground_truth -- --nocapture`); skips cleanly when `corpus/` is not checked out, matching the dev's own corpus test's pattern. **Everything else tried to break, and did not:** - A workspace root fixture helper (`Tree::write` in `lens.rs`'s tests) did not create parent directories, so a nested relative path (`"a/m.sv"`) failed with `NotFound` the first time this round's cross-file-collision test tried to use one. **Fixed directly** (`fs::create_dir_all` on the parent before `fs::write`) — an unambiguous test-infrastructure gap, not a behavior change, and it was blocking test C's fixture from being written at all. - Malformed `executeCommand` arguments (missing, non-string, empty string) for `lucisv.showInstantiations`: all three still answer `RequestFailed` with a message naming "module name" — re-verified against the dev's own `the_command_declines_arguments_it_cannot_read` and `the_show_instantiations_command_declines_arguments_it_cannot_read`. - A name the workspace does not declare (`"never-heard-of-it"`): `[]`, not an error, as documented and tested by the dev. - `resolveProvider: false` and every lens carrying a complete `Command` with no `data`: re-verified against `no_lens_is_ever_left_for_a_resolve_to_fill_in`. **Verdict: committable as-is.** No corruption, no idempotency risk (this feature touches no formatter output), no dropped comments — none of those invariants are in this feature's blast radius at all, since it only reads and answers LSP requests. The one open item (point 3, the index-table request's concreteness) is a documentation-polish question for the lead, not a defect, and does not block shipping. 9 new tests added, all green; gates re-run clean before and after. No commits made. ## Review ### 2026-08-26 — lead Reviewed the diff, the work log and the QA log; re-ran all gates myself, clean. The round's two judgment calls were both right. Building the real jump instead of the display-only fallback cost ~15 lines because the locations already existed — exactly the "check what the code makes clean" outcome the brief asked for — and the zero-count lens staying display-only matches rust-analyzer's precedent. The hierarchy.rs refactor is the correct shape: one census with the batch as the primitive, `incoming` as a one-element batch, and the corpus ratio test making the amortization a tested property instead of a hope. I read the refactor diff myself and concur with QA's function-by-function verdict — same parse mode, same filters, the empty-name guard equivalent in its new position. QA's count-honesty tests were the right instinct: the agreement test alone cannot catch semantic drift when both paths share one function, so pinning the absolute policies (multi-instance = one site, textual recursion, both ifdef arms) at the lens layer is what actually holds the numbers still. On QA's LOW finding, I agreed and promoted the index-table request to a concrete Handshakes entry with a named shape — two features now pay the sources() walk, which is exactly when a backlog bullet stops being enough. Accepted as shipped.