Lazy codeAction/resolve for the port refactorings, definitions from the index, the inlayHint zero ruled correct

TODO §37 (docs/features/lazy-code-action). Closes the four §10 lines.

37.1 For a client whose resolveSupport lists "edit", the port actions are
offered over the buffer plus the instantiated module's declaration alone
(`ports::offers`, `offer_sources`), carrying `data {uri, position,
title}` and no edit; `codeAction/resolve` (`ports::resolve`) re-runs the
eager path and returns the matching action, matched on the title minus
its count phrase, erroring when the action is gone or the buffer is on
the large-file path. Clients without resolve support get today's eager
answer. Offer flat at ~55 µs from a 3- to a 128-file fan-out where the
eager path was linear; ~4.5 ms vs ~77 ms over the wire on opentitan's
128-file case.

37.2 The inlayHint zero at the default scope is correct: the hinted
module (`pins_if`) is declared outside what the scope reaches, and
definition/hover answer nothing there either. Pinned, not changed.

37.3 `locate::definition_location`: an index-only Location for a closed
file's file-scope declaration from its recorded `DeclPositions`; nav and
workspace symbols routed through it (0.4 µs vs 28 µs). Open buffers keep
the file-read path.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
lucioandClaude Fable 5.1 committed 2026-09-04 18:15:40 -05:00
1 parent 797ef86d47
commit 9604753b6c
16 files changed
+1817 -33

No files matched your search

+573
View File
@@ -0,0 +1,573 @@
# lazy-code-action
TODO §37 — the three server residues left over from §10: the lazy
`codeAction/resolve` for the port refactorings (§37.1), the `inlayHint` zero at
the default scope (§37.2), and `locate::location` onto `DeclPositions`
(§37.3). One README, one section each.
## Goal
**§37.1.** `textDocument/codeAction` arrives on nearly every cursor move, and
the port refactorings answered it by computing the *whole* edit — over the
instantiated module's entire fan-out plus every open buffer, each file read as
text. `docs/performance_take2.md` §6a measured what that costs on opentitan:
~1.4 ms per instantiating file plus a ~13 ms floor, **185–201 ms at a 128-file
fan-out, to offer zero actions**, above §3's "reads as a hang" line, on the hot
path. The *offer* is now local — the buffer, plus the instantiated module's own
declaration when the cursor is on an instantiation — and the edit is computed
by `codeAction/resolve` when the user picks the action. A client that cannot
resolve is unaffected: it still gets the edit up front.
**§37.2.** `inlayHint` returns 0 hints at the default (folder) scope where the
workspace scope returns 4 (`performance_take2.md` §4b, §8.9), the one §4b row
the `didOpen` widen did not fix. Investigated, and it is **not a bug** — the
finding is written out below, with two tests that pin it.
**§37.3.** Every file-scope declaration's client-side range is already in the
index (`DeclPositions`, added by the design-hierarchy round), so
`textDocument/definition` and `workspace/symbol` need not read a file to
convert an indexed span. They no longer do: **27.7 µs → 0.40 µs per
definition** on opentitan.
## Assumptions
- **The offer may be optimistic; the resolve is exact.** A refusal the engine
can only see over the fan-out — an instantiation elsewhere connecting `sub`'s
ports *by position*, which makes `remove_port` refuse whole — is invisible to
a one-file offer, so the lightbulb can appear and the resolve then decline
with "the action is no longer available". This is the trade LSP's resolve
model is for; the alternative is the 185 ms. The refusals cheap enough to
keep are kept: a module the index declares twice is checked through
`WorkspaceIndex::units` before anything is offered, exactly as the eager path
refuses over the two declaring files it reads.
- **The count in an offered title comes from the index and may be one behind.**
`instantiations_of(name)` records one edge per *written statement* with its
instances, and the title counts **instances** (`sub u1(), u2();` is two), to
match what the eager title counts — the instances the plan really rewrites.
The two disagree exactly where the index cannot know: an unsaved buffer's new
instantiation, a file-scope instantiation site (which records no edge at
all), an instance connecting with `.*`. So the offered and resolved actions
are matched on the title *without* its count phrase (`ports::key`), and the
resolved action carries the exact title.
- **`Def::lines.positions` is `Some` for every file-scope declaration and
`None` for every member**, as `DeclLines` documents. §37.3 relies on that:
members keep the file-read path, which is not a fallback nobody takes — it is
the only answer a port has.
- **`codeAction/resolve` carries no `textDocument`**, so the large-file fast
path's gate — which reads a URI out of the params — never sees it. `resolve`
refuses a buffer on that fast path itself: the mode's contract is that a
large buffer is never parsed, and one stale lightbulb is not a reason to
break it.
- An **open buffer** keeps the file-read path in §37.3 whatever the index
recorded, because the buffer's text may have moved since it was indexed and
every other answer about that buffer is computed against the text it holds
now.
## Handshakes
- **`vlog_refactor` → server.** `ports::sites_phrase` is now `pub` (re-exported
from the crate root as `vlog_refactor::sites_phrase`). The server writes the
same sentence with a count of its own, and one spelling of a user-visible
string is the point. Nothing else in `vlog_refactor` changed; `port_actions`,
`port_action_modules` and `module_definition` are consumed exactly as before.
- **`Workspace` → server.** `Workspace::held_views()` added, `#[cfg(test)]`
and `pub(crate)`: the view cache is how a test asserts that an answer read no
file. No production caller.
- **`main.rs` → `server`.** `ClientAbilities` gains `code_action_resolve`, read
at `initialize` from `textDocument.codeAction.resolveSupport.properties`
containing `"edit"`. The `initialize` result advertises
`codeActionProvider.resolveProvider: true` unconditionally — the server can
always answer a resolve, including for an action that already carries its
edit, which it hands straight back.
- **The wire.** New method answered: `codeAction/resolve`. New field on an
offered port action: `data` (`{uri, position, title}`), opaque to the client.
The quick fixes in `code_action.rs` are unchanged and still complete when
offered.
## Status / TODO
- [x] §37.1 `ports::offers` — the local offer, titles counted from the index,
`data` instead of an edit.
- [x] §37.1 `ports::resolve` — today's eager answer at the offer's position,
matched on `key(title)`; `RequestFailed` with "the action is no longer
available." when nothing matches, and a distinct sentence for an action
this server never offered.
- [x] §37.1 capability gate: `code_action_resolve_support` in `main.rs`,
`ClientAbilities::code_action_resolve`, the dispatch branch.
- [x] §37.1 `resolve_provider: Some(true)` advertised; `codeAction/resolve`
dispatch arm.
- [x] §37.1 tests: the offer's menu equals the eager one over `crowded(40)`;
the offer's source set is the buffer (+ the declaring file); the resolved
edit is byte-equal to the eager one at both cursor shapes; the unsaved
buffer answered by the resolve; a stale and a closed document refused; a
foreign action refused; a complete action returned untouched; the
duplicate-declaration refusal; a buffer that grew onto the large-file
fast path; `key`'s own unit test.
- [x] §37.1 e2e over the wire, both client shapes.
- [x] §37.1 perf: the "offer" column on `perf.rs`'s
`a_code_action_at_an_instantiation_before_and_after`, plus
`ports::tests::the_offer_is_flat_where_the_eager_answer_grows`
(3/40/128 instantiators, both cursor shapes).
- [x] §37.2 investigated; finding written below; two tests at the default
scope.
- [x] §37.3 `locate::definition_location`, routed through `nav::definition`
and `symbols::workspace_symbols`.
- [x] §37.3 pins: the encoding shapes, no `file_view` created, members keep
the read, the open-buffer case.
- [x] §37.3 opentitan timing, read-only
(`locate::tests::defining_over_a_real_project`).
- [ ] Not done, deliberately: **memoising `module_sources`** per (module, index
generation), take 1's other suggestion. The offer makes it unnecessary on
the hot path — the fan-out is now read once per *click* — and a cache
keyed on a generation is a staleness question this round did not need to
open.
- [ ] Not done, deliberately: **the quick fixes stay eager.** They are built
from the buffer's own violations, which the server has already computed
for the diagnostics; there is nothing to defer.
## §37.1 — how the offer stays local
`ports::offers` runs the engine's own `port_actions` over a source set built by
`ports::offer_sources`:
1. **the buffer the request names**, from the open document (no read);
2. **the declaring file of every module `port_action_modules` named**, via
`vlog_refactor::module_definition(index, name)` — the same two steps
`inlay.rs`'s `Plans::read` takes, and one file read at most.
A cursor on a **port declaration** names its own module, whose declaring file
*is* the buffer, so that case reads nothing at all. A cursor on an
**instantiation** names the instantiated module, and its declaration is what
`propagate_ports` needs to know which connections are missing — so the offer
is exact for that action, including its "connect N missing ports" count, which
is a count of edits in the cursor's own file.
The edits `port_actions` computes over those one or two files are thrown away.
Only the titles and the kind survive, plus `data`.
`ports::resolve` re-runs `ports::code_actions` — today's eager path, unchanged
— at the offer's position and returns the action whose `key(title)` matches.
### Measured
This machine, 2026-09-04, release.
`cargo test --release -p lucisv_server perf::a_code_action -- --ignored
--nocapture --test-threads=1` — the original probe (a port of a module
instantiated in 3 of 504 files, 200 lines each), now with the offer column
TODO §37.1 asked for:
| whole workspace | fan-out (eager) | **offer** | `sources()` alone |
|---:|---:|---:|---:|
| 776 ms | 433 µs | **58 µs** | 11.5 ms |
`cargo test --release -p lucisv_server --bin lucisv-server
ports::tests::the_offer_is_flat -- --ignored --nocapture --test-threads=1` —
200 noise modules plus `n` files instantiating `sub`, the shape §6a measured
on opentitan:
| fan-out | cursor | eager | **offer** | actions |
|---:|---|---:|---:|---:|
| 3 | a port declaration | 485 µs | **68 µs** | 1 |
| 3 | an instantiation | 172 µs | **72 µs** | 0 |
| 40 | a port declaration | 4.84 ms | **53 µs** | 1 |
| 40 | an instantiation | 1.45 ms | **55 µs** | 0 |
| 128 | a port declaration | 15.0 ms | **53 µs** | 1 |
| 128 | an instantiation | 4.60 ms | **55 µs** | 0 |
The eager column grows with the fan-out and the offer column does not: 53–72 µs
at every size, both cursors (the two 3-file rows are the first measurements
taken in the process and carry that much warm-up). The two "0 actions" rows are
§6a's own complaint — a cursor on a fully-connected instantiation, where the old
path spent its whole bill to offer nothing.
## §37.2 — the `inlayHint` zero at the default scope is correct
**Finding: not a bug. `performance_take2.md` §4b's last row compares a
different question from every row above it.**
Every other row of that table asks about `aes` — `definition`, `hover`,
`signatureHelp`, `references` on the `aes` instantiation in
`hw/ip/aes/dv/tb/tb.sv`. `aes` is declared in `hw/ip/aes/rtl/aes.sv`, which the
`didOpen` widen reaches: opening `hw/ip/aes/dv/tb/tb.sv` at the shipped
`scopeDepth` of 2 raises to `hw/ip/aes`, 124 files. So those rows answer.
`inlayHint` cannot ask about `aes` at all: that instantiation's connections are
**named** (`.clk_i(clk)`), and a named connection gets no hint by design — the
reader can already see which port is which. The only positional connections in
`tb.sv` are:
```systemverilog
pins_if #($bits(lc_escalate)) lc_escalate_if (lc_escalate);
pins_if #(1) idle_if (idle);
```
Two positional parameter overrides and two positional port connections — **the
4 hints the workspace scope returns**. `pins_if` is declared in
`hw/dv/sv/common_ifs/pins_if.sv`; there is no `pins_if` anywhere under
`hw/ip/aes` (checked). So at the default scope the module is genuinely not in
the index, `vlog_refactor::module_definition` has nothing to answer with, and
`Plans::read` declines — which is the documented contract: an instantiation
whose module the index does not hold gets no hints, because guessing port names
puts a wrong name on screen with no way for the reader to tell.
`inlay.rs` uses **the same lookup its neighbours use**. `signature.rs:28` and
`completion`'s module-header tier call `vlog_refactor::module_definition` on the
same index; hover and definition go through the same overlay. Asked about
`pins_if` at the default scope, every one of them answers nothing too. There is
no lookup inlay is missing.
Two tests pin it (`inlay.rs`), on an opentitan-shaped tree — `ip/aes/rtl`,
`ip/aes/dv/tb`, and a `dv/common` beside the block:
- `the_default_scope_hints_a_module_the_didopen_widen_reached` — at the
**default** scope (no `index.scope`, `scopeDepth` 2), the instantiation of the
block's own module is hinted. The default scope hints; §4b's row is not
evidence that it does not.
- `an_out_of_scope_module_is_unhinted_exactly_as_it_is_undefined` — the
instantiation of the module outside the block gets no hints, **and**
`textDocument/definition` and hover give nothing for it either; widening to
the workspace scope makes all three answer.
For the lead: if the wanted behaviour is that a hint pulls its module's
declaration in from outside the scope, that is a *scope* change (the widen
would have to follow instantiation edges), and it would change what
`definition`, `hover` and `completion` answer at the same time. It is not an
inlay-hint fix, and it is not what this round did.
## §37.3 — `locate::definition_location`
`Def::lines.positions` holds `{name, decl}` as `Utf16Range`s, converted through
the declaring file's own `LineIndex::utf16_position` while it was indexed —
which is the very converter `convert::Positions` uses on the wire, so the two
cannot disagree. `locate::definition_location(ws, path, def)` returns the name's
range straight from there when the file has no open buffer, and falls through to
`locate::location`'s read otherwise (an open buffer, or a member, which records
no positions).
Routed through: `nav::definition`'s `Definition::External` arm and
`symbols::workspace_symbols`. `nav`'s `` `define`` arm keeps the read — a
`DefineTable` entry is not a `Def` and has no recorded positions.
### Pins
- `locate::tests::the_two_paths_agree_over_multi_byte_astral_crlf_and_a_bom` —
one file with a BOM at offset 0, CRLF endings, two- and three-byte
characters and an astral character that is two UTF-16 code units; the
index-only `Location` equals the file-read one exactly.
- `locate::tests::a_file_scope_definition_is_located_without_reading_its_file`
and `nav::tests::a_cross_file_definition_reads_no_file` — asserted through
`Workspace::held_views()`, the view cache a read would land in. Empty after
the definition and after a `workspace/symbol`; one entry after the same
question is asked the old way.
- `locate::tests::a_member_keeps_the_file_read_path` — a port records no
positions and still answers, through the read.
- `locate::tests::an_open_buffer_still_answers_from_the_buffer`.
### Measured, over opentitan, read-only
`LUCISV_PERF_CORPUS=/Users/guoliangchen/repo/opentitan cargo test --release -p
lucisv_server --bin lucisv-server locate::tests::defining -- --ignored
--nocapture --test-threads=1`, 3 976 indexed files, 200 targets (modules the
corpus instantiates, each in a different file):
| | total, 200 definitions | per definition |
|---|---:|---:|
| file-read (before) | 5.54 ms | 27.7 µs |
| index-only (after) | 80.5 µs | **0.40 µs** |
69× on the conversion, and it is the whole of what a cross-file
`textDocument/definition` into a closed file was doing besides the lookup.
`git -C ~/repo/opentitan status --porcelain` unchanged after the run.
## Work log
### 2026-09-04 — dev agent (Opus)
- Read `CLAUDE.md`, TODO §37 and the §10 lines it closes,
`docs/performance_take2.md` §4b/§6a/§7/§8, and the code each item names.
- **§37.3 first** (smallest, independent). `locate::definition_location` plus
`locate::range`; `state.rs` gained `held_views()` (`#[cfg(test)]`,
`pub(crate)`) so a test can assert that no file was read. Routed
`nav::definition` and `symbols::workspace_symbols` through it. Four tests in
`locate.rs` (new test module) and one in `nav.rs`.
- Deviation from the plan's expectation, recorded: the plan said "no
`file_view` created for a file-scope definition"; the assertion is through
`Workspace::held_views()`, a new test-only accessor, rather than a
counter — the cache *is* the counter, and it is already what `state.rs`'s
own tests assert against.
- One thing the plan did not anticipate: an **open buffer** must keep the
file-read path. Its `Def` spans are the disk file's until the next
re-index, and converting them against the buffer's current text is what
every other answer about that buffer does. Pinned by
`an_open_buffer_still_answers_from_the_buffer`, which asserts the
(pre-existing, unchanged) stale-span behaviour rather than pretending this
round fixed it.
- **§37.2 second.** Investigated by reading `hw/ip/aes/dv/tb/tb.sv` and
locating `pins_if` in the opentitan checkout (read-only, `find`/`ls` only).
The zero is correct; the finding is written above, with two tests. No
production code changed for this item.
- **§37.1 last.** `ports::offers`, `ports::offer_sources`, `ports::resolve`,
`ports::key`, `ports::counted`, `ports::instances_of`,
`ports::declared_twice`; `ClientAbilities::code_action_resolve`;
`code_action_resolve_support` in `main.rs`; `resolve_provider: Some(true)`;
the dispatch branch and the `codeAction/resolve` arm.
- **Deviation, flagged:** `vlog_refactor::ports::sites_phrase` was made
`pub` and re-exported. The plan allowed a change to
`crates/vlog_refactor/src/ports/mod.rs` "only if the offer needs a new
one-file question", and this is not one — it is the alternative to writing
a second spelling of a user-visible sentence in the server and letting the
two drift. No behaviour changed in `vlog_refactor`.
- **Deviation, flagged:** the plan said resolve returns "the action whose
title matches". Exact title matching cannot work, because the offer's
count comes from the index and the eager count from the plan, and the
plan's own §37.1 requires the unsaved-buffer case (index 3, plan 4) to
resolve. Matching is therefore on `key(title)` — the title with its
trailing ` (…)` count phrase removed. An escaped identifier cannot contain
a space, so `" ("` never occurs inside a port name; `a_title_keys_on_
everything_but_its_count` pins it.
- **Deviation, flagged:** `resolve` returns an action that already carries an
`edit` unchanged instead of refusing it. A client that declares
`resolveSupport` may resolve anything it was offered, including the quick
fixes, and refusing those would break fix-on-save for exactly the clients
this feature is for.
- `resolve` refuses a large-file buffer, because the fast path's own gate
cannot see a request whose params are a `CodeAction`. Found by reading
`server/large_file.rs`'s `document_uri`, not by a test failing; pinned by
`a_resolve_against_a_buffer_on_the_large_file_fast_path_is_refused`.
- The existing eager pin `an_unsaved_buffer_contributes_the_instantiation_
the_index_has_not_seen` was **kept** rather than moved: the eager path is
still live code for a client without `resolveSupport`. Its lazy sibling
`the_resolved_edit_sees_an_unsaved_buffer_the_offer_could_not_count` is the
moved pin.
- **The two new perf probes live beside the code they measure**, not in
`perf.rs`: `perf.rs` is already the one file over the size rule with a
written reason (895 production lines, `docs/features/decomposition-server`),
and `perf::mean` is `pub(crate)` precisely so a probe can sit next to its
subject — `nav.rs`'s references probes already do. `perf.rs` grew by the
five lines of the offer column and nothing else (900 lines).
- Files touched outside the plan's expected set: **none**
(`crates/vlog_refactor/src/lib.rs` for the re-export is the only file not
named in it; `crates/vlog_refactor/src/ports/mod.rs` was named).
## Gates (dev, guarded, 2026-09-04)
- `cargo fmt -p lucisv_server`, `cargo fmt -p vlog_refactor` — clean
(`--check` verified).
- `cargo clippy --all-targets` — clean, no new `#[allow]`.
- `tools/guard.sh -- cargo test --workspace` — **3 734 passed, 0 failed,
44 ignored** (the ignored are the perf probes).
- `tools/guard.sh -- tools/corpus_check.sh` — **814/820 (99.3 %)**, the same
six failures, `verification-error: none`, `crash: none`.
- `cargo build --release -p lucisv_server` then `tools/guard.sh -- node
editors/vscode/smoke.js target/release/lucisv-server` — OK, 20 messages.
- No guard kill at any point. `git -C ~/repo/opentitan status --porcelain`
after every opentitan read: the same three pre-existing modifications
(`hw/ip/aes/dv/tb/tb.sv`, both `ast.sv`), nothing else.
## QA log
### 2026-09-04 — QA agent (Sonnet)
Read `CLAUDE.md`, TODO §37, the dev's account above in full (Goal, Assumptions,
Handshakes, work log — all five flagged deviations), then the diffs of every
touched file. Attacked the three items over the real code, not just the
dev's own tests; every scratch test below was added as a temporary `#[test]`,
run, and removed before this log was written (`git diff --stat` after cleanup
is byte-identical to the dev's own: 15 modified + this README).
**§37.1 — lazy `codeAction`/`resolve`.**
- Malformed `data` (scratch test in `ports.rs`): a wrong-typed `uri` (a JSON
number) fails to deserialize into `Offer` → `NOT_OURS`; a well-formed `data`
naming a document **never opened at all** (distinct from one that was open
and closed) → `GONE`; a `position` far past EOF → `Positions::offset` clamps
to the text length (confirmed by reading `convert.rs:44-59`) rather than
panicking, `code_actions` at the clamped offset finds nothing, → `GONE`. No
panic in any case.
- A closed document and a document whose port has since been removed: both
already pinned by the dev's `a_resolve_of_an_action_the_buffer_no_longer_
carries_is_refused`; reproduced by re-running it directly.
- The unsaved-buffer "different count" case (index says 3, buffer really has
4): the dev's `the_resolved_edit_sees_an_unsaved_buffer_the_offer_could_not_
see` is exactly this attack — re-run, still resolves with the corrected
title and the wider edit.
- A quick-fix action passed to `resolve`: `code_action.rs`'s `quick_fix`
(line ~76) always sets `edit: Some(...)`, so it always takes `resolve`'s
first branch (`action.edit.is_some()` → returned unchanged) regardless of
origin — confirmed by reading the function rather than by a redundant
integration test, since the logic path is identical to the dev's own
synthetic "complete" case in `a_resolve_of_something_this_server_never_
offered_says_so`.
- Title-key matching with an escaped identifier containing `(` and no interior
space (`\rst(a)`, IEEE 1800-2017 §5.6.1 — an escaped identifier ends at
whitespace): built a real module with this port name, instantiated it in
three files, and drove the actual engine (not a hand-built title) through
`offered`/`code_actions`/`resolve`. The offer's menu matched the eager
menu, the title genuinely carried the literal `` `\rst(a)` `` including the
paren, and `key()` still isolated the trailing count phrase correctly — the
dev's reasoning in the comment on `key` holds under an adversarial name.
(One test-authoring pitfall found and fixed on my own scratch test, not a
product bug: `ports.rs`'s pre-existing `qa_escaped_module_name_
instantiation_parity_with_whole_workspace` also builds a `Tree::new(
"qa_escaped")`, and reusing that same name in my own scratch test raced the
two tests over the same temp directory under parallel `cargo test`
execution, producing spurious failures in both. Renamed my scratch tree and
the collision was gone on repeated runs. `Tree::new` keys its temp directory
on the string name alone with no per-test-function salt, which is a latent
hazard for the *next* test added under the same name — not something this
feature's diff introduced or should fix, flagging it here rather than in
the diff.)
- Capability gate over the wire (scratch test in `tests/e2e.rs`, two shapes in
one loop): `resolveSupport` present but its `properties` list `["documentation"]`
(no `"edit"`), and `capabilities: {}` with no `codeAction` key at all. Both
got the eager shape — `data` null, `edit` inline with the real
`WorkspaceEdit` — over an actual `initialize` → `didOpen` →
`textDocument/codeAction` session, not just the unit test of
`code_action_resolve_support` in isolation.
- Large-file mode: confirmed by reading `server/large_file.rs`'s
`document_uri` (`params.get("textDocument")?...`) — a `codeAction/resolve`
request's params are a bare `CodeAction`, which has no `textDocument` key,
so `large_file_answer` returns `None` unconditionally for this method and
the request falls through to `dispatch.rs`'s normal arm, where `ports::
resolve`'s own `.filter(|doc| !doc.large)` refuses it. Re-ran the dev's
`a_resolve_against_a_buffer_on_the_large_file_fast_path_is_refused` — passes,
no panic.
- Cost/timing, re-derived independently over the wire against the real
opentitan checkout (confirmed still 128 files instantiate `prim_flop_2sync`
today via `grep`), read-only throughout:
- Built `lucisv-server` v0.40.0 in a scratch worktree
(`git worktree add /private/tmp/.../scratchpad/base v0.40.0`, `cargo build
--release -p lucisv_server`, then `git worktree remove` — the one git
command used outside status/diff), and wrote a small throwaway Node driver
(`scratchpad/time_code_action.js`, modeled on `editors/vscode/smoke.js`'s
framing) to time a real `textDocument/codeAction` at the
`prim_flop_2sync` instantiation in `hw/ip/aon_timer/rtl/aon_timer.sv`,
workspace-scoped via `initializationOptions.lucisv.index.scope`.
- v0.40.0 server, eager (no `resolveSupport`): 76.4 / 76.4 / 77.8 ms repeats.
- This branch's server, eager (no `resolveSupport`): 77.3 / 76.2 / 77.7 ms
repeats — statistically identical to v0.40.0, confirming no regression for
a client that cannot resolve.
- This branch's server, **offer** (`resolveSupport: ["edit"]`): 4.76 / 4.38
/ 4.25 ms repeats — about **16× faster**, both with 0 actions returned
(the same "worst case: full cost, nothing offered" shape §6a complained
about).
- Also re-ran the dev's own ignored perf probe
(`ports::tests::the_offer_is_flat_where_the_eager_answer_grows`) directly:
eager 656 µs–15.6 ms across 3/40/128 fan-out, offer 55–78 µs flat — closely
matches the table in this README (§37.1 "Measured").
- **Note, not a finding against this feature:** my repeat numbers (~76 ms
eager) are well under `performance_take2.md` §6a's originally recorded
184.9–186.2 ms for this exact shape. Both old and new servers agree with
each other on *this* machine, so it reads as a machine/measurement-harness
difference from whatever produced §6a's numbers, not a regression — the
relative number this feature is judged on (offer vs. eager, same server,
same request) is the clean ~16× and it holds.
- `offer_sources`'s read set: re-ran the dev's `the_offer_reads_the_buffer_
and_at_most_the_declaring_file` — one file at a port declaration, the buffer
plus the declaring file (never the instantiating tops or noise files) at an
instantiation.
**§37.2 — the `inlayHint` zero at the default scope.**
- Verified the finding independently against the **real** opentitan checkout,
read-only: `find . -iname pins_if.sv` → exactly one hit,
`hw/dv/sv/common_ifs/pins_if.sv`, confirmed outside `hw/ip/aes` entirely (a
sibling library folder the default scope's raise-to-`hw/ip/aes` widen does
not reach).
- Wrote a scratch, `#[ignore]`d test in `inlay.rs` (guarded, read-only) that
opens the real `hw/ip/aes/dv/tb/tb.sv` at the shipped default scope and
asserts: the widen reached files under `hw/ip/aes` but none under
`common_ifs`; `nav::definition`, `hover::hover` and `inlay_hints` all answer
nothing about the `pins_if` instantiation. All three held. Agree with the
dev's finding: this is a scope-reach question, not an inlay-hint bug, and
every neighbour using the same `module_definition` lookup is equally blind
to it at this scope.
- `git -C ~/repo/opentitan status --porcelain` unchanged after every read
(the same three pre-existing modifications).
**§37.3 — `locate::definition_location` index-only path.**
- Re-ran every pin in `locate.rs` and `nav.rs`; all pass.
- Extra encoding attacks beyond the dev's own (BOM, CRLF, multi-byte, astral):
a **tab-indented** declaration, and a declaration **after a lone `\r`**
(old-Mac line ending, not `\n`) — both agree between the index-only and
file-read paths exactly. (First attempt at the lone-`\r` case put it inside
a line comment and found zero declarations at all: `lexer.rs`'s line-comment
scanner runs to the next `\n` only, so a bare `\r` inside a comment does not
end it and the intended module got swallowed into the comment text — a
pre-existing, unrelated lexer property, not a locate.rs bug. Moved the `\r`
outside the comment and the equality attack ran as intended.)
- An open buffer with an edit above the definition still answers from the
buffer's own current text, confirmed via the dev's `an_open_buffer_still_
answers_from_the_buffer` (re-run) plus reasoning: `ws.document_for_path`
gates the index-only branch off whenever a buffer is open, whatever the
index recorded.
- `held_views()` is `#[cfg(test)]` — grep and the diff both confirm no
production caller; it cannot be reached outside a test build.
- Timing re-derived independently, read-only, over the real opentitan
checkout (3 976 indexed files, 200 targets): **index-only 390 ns/definition,
file-read 27.9 µs/definition** — matches the README's 0.40 µs / 27.7 µs
claim within run-to-run noise, same ~69–71× ratio.
`git -C ~/repo/opentitan status --porcelain` unchanged.
**Gates, re-run myself, guarded:**
- `cargo clippy --all-targets` — clean, no warnings (checked both with and
without my scratch tests present).
- `tools/guard.sh -- cargo test --workspace` — **3 734 passed, 0 failed, 44
ignored**, matching the dev's own gate exactly. No guard kill.
- `tools/guard.sh -- tools/corpus_check.sh` — **814/820 (99.3%)**, the same
six failures, `verification-error: none`, `crash: none`.
- `tools/guard.sh -- node editors/vscode/smoke.js target/release/lucisv-server`
— OK, 20 messages.
- `git -C ~/repo/opentitan status --porcelain` after every opentitan read,
throughout the session: unchanged, the same three pre-existing
modifications every time.
- Scratch worktree at `/private/tmp/.../scratchpad/base` (v0.40.0) removed
with `git worktree remove` after use; `git worktree list` shows only the
main tree.
**Findings.** None at HIGH or MEDIUM severity. Two LOW, informational, neither
in this feature's own diff:
- LOW — `ports.rs`'s test-scratch `Tree::new` keys its temp directory on the
caller-supplied string alone, with no per-test salt; two tests choosing the
same name race under parallel execution (reproduced against the pre-existing
`qa_escaped_module_name_instantiation_parity_with_whole_workspace`). Not
part of this diff and not blocking; worth a name-collision guard (e.g.
salt with the test's `#[test]` function name) if it bites again.
- LOW — the offer/eager repeat-timing numbers measured this session (~76 ms
eager, ~4.5 ms offer, both machines) are well under `performance_take2.md`
§6a's recorded 184.9–186.2 ms for the identical 128-file-fan-out shape;
old and new servers agree with each other on this machine, so it reads as
environment drift from whatever produced §6a's numbers rather than a
regression this feature introduced. Recorded for whoever next revisits
§6a's absolute numbers.
**Verdict: PASS.**
## Review
**2026-09-04 — lead.** Accepted; ships in 0.41.0. 37.1 is the shape §10
asked for and the numbers say why: the offer is flat (53–68 µs from a
3-file to a 128-file fan-out, on both cursor shapes) where the eager path
is linear, and over the wire on opentitan's worst case QA measured the
offer at ~4.5 ms against ~77 ms eager — the cursor-move request is off the
fan-out. The dev's five deviations are all right: matching on the title's
key rather than the exact title is forced by the plan's own unsaved-buffer
requirement, and the escaped-identifier attack (`\rst(a)`) shows the key
holds; refusing a resolve on a large buffer closes a gate the fast path's
URI check cannot see; keeping the eager unsaved-buffer pin beside its
lazy sibling is correct because the eager path is still live for clients
that cannot resolve. 37.2 is ruled as the dev framed it: the zero is
correct — `pins_if` is declared outside what the default scope reaches
from `tb.sv`, definition and hover answer nothing there either, and QA
confirmed it on the real tree — so this is a *scope* question, not an
inlay defect, and the §10 line is closed as investigated. 37.3 is a pure
fast path (index-only Location equal to the file-read one over every
encoding shape QA and the dev tried, 69× cheaper, no view created), with
the honest exclusion of open buffers whose indexed spans may be stale.
QA's two LOWs are noted, not actioned: `Tree::new` takes a per-test name
and the existing names are distinct, and §6a's absolute numbers were
measured on a different day's machine state — both servers agree with
each other here, which is what the comparison needed.