The owner's first-level cache, realized on the carrier the index already had: DeclLines (name line + detail line) on every Decl/Def, computed at index time from the LineIndex the analysis already holds — tens of KB for 20k modules, FACTS_FORMAT 3->4, old stores discarded whole. A closed file's hover heading now costs zero I/O (it survives the file being deleted), and the snippet's one remaining read is served from a bounded FileView LRU (4 entries / 8 MiB, newest kept, dropped on set_document/close/update_one/rebuild): repeat hovers into a 12 MB file go 5.8 ms -> ~1 us, cross-file hover means 40/157 us -> 4.7/12.9 us. Ports ride the same member entries, so their lines came free. Stale-disk edits leave heading and snippet stale together, the spells_exactly guard still omits rather than lies, and QA pinned the pair. Measured and filed, not fixed here: the first request of a session waits 287-780 ms behind the startup scan (handshake for the next round). Co-Authored-By: Claude Fable 5 <[email protected]>
hover-declarations
Goal
Hovering a name declared in this file has always shown the declaration
itself — local_text prints the kind, the name and the source lines
decl_span covers. Hovering a name declared in another file showed only
**port** — declared in sub.sv:3``: enough to navigate to, not enough to read.
The owner's ask (2026-08-27) is that the cross-file card carry the declaration
too — for a port its direction, type and width, input logic [7:0] addr — so
that reading a connection list does not require jumping out of the file. This
round adds a fenced systemverilog snippet of the declaration's source line(s)
under each candidate's existing heading, fetched at hover time and omitted
entirely whenever it could be the wrong line.
Assumptions
- The index stays text-free.
Defis{file, name_span, kind}and the persisted facts andFACTS_FORMATare untouched (docs/features/workspace-index/README.md,docs/features/index-persistence/README.md). A hover is a rare, one-name, human-speed request; reading one file to answer it is the same tradelocate::line_numberhas always made for thefile:linehalf of the card. reference.nameis the declared name. EveryDefinition::Externalanswer comes from a reference (ExternalResolutions::definition_oflooks the target up byReferenceId), andresolve_externalfinds theDefby passing exactly thatnametoWorkspaceIndex::units/member. So the name is the bare declared spelling —WIDTHfor ap::WIDTHuse,clkfor a.clk(...)connection — never a qualified path. That is what makes it usable as the guard's expected text.- Disk text is what the index was built from.
Workspace::text_ofprefers an open buffer, which is right for a location and wrong for a snippet, so the open case is handled separately and never reachestext_of. - A
decl_spanmay be enormous. A module'sdecl_spanis its whole body (bind_modulepasses the item span), and one netlist line has no bound at all — hence the two caps below.
Handshakes
Consumed
crate::nav::indexed_def_for_symbol— raised from private topub(crate), behaviour byte-for-byte unchanged.nav.rswalks it live-symbol → indexedDef; this feature walks the same relation the other way (scan the open buffer's symbols for the one that maps to thisDef), which is precisely whatnav.rs's owninclude_declarationblock already does for the declaration location. One matcher, so a hover snippet and a go-to-definition can never disagree about which declaration is which.Workspace::document_for_path,Workspace::text_of,WorkspaceIndex::path.crate::convert::Positions::whole_lines,vlog_parser::LineIndex.vlog_semantic::{Def, Symbol}— read only; nothing added to either.
Promised
nav.rskeeps its behaviour: the visibility change is the only edit to it, and its whole test module stays green unmodified.- The
```systemverilogfence tag is used for the new block, as the fence-tag contract indocs/features/lucisv-server/README.mdrequires — it is the only thing that colours a hover card. - Nothing is added to
Def, to the facts file, or toFACTS_FORMAT; a cache written before this round is still current after it. Superseded 2026-08-28 bydocs/features/port-detail-spans/README.md, which addsDef::detail_span, writes it in every declaration record and bumpsFACTS_FORMAT2 → 3, so a store written before that round is discarded. This round's own promise held while it was this round's to make; the index is text-free either way (a span is not text). Superseded again 2026-08-28 bydocs/features/hover-line-index/README.md, which addsDef::lines(each declaration's line number) and bumpsFACTS_FORMAT3 → 4. Same reading: a line number is not text either, and it is what makes this feature's heading free. - The heading line
**label** — declared infile:line`` is unchanged, so a client (or a test) reading only that half sees exactly what it saw before.
How the snippet is fetched
declaration_snippet(ws, def, name) in hover.rs, once per candidate:
- The target file is open (
ws.document_for_path). The index's span is against that file's last saved text, so an unsaved edit above the declaration has already moved it and reading the buffer atdef.name_spanwould print whatever those offsets now cover. Match theDefto a live symbol logically instead — same name, andindexed_def_for_symbolmaps it back to this sameDef— and widen that symbol's livedecl_spanto whole lines. - Not open:
ws.text_of(path)(disk, since no buffer backs it), a freshLineIndex, anddef.name_spanwidened to whole lines. - Guard, both paths. Slice the chosen text at the chosen name span and
require it to equal the hovered name.
str::getreturnsNonefor a span that runs past the text or lands mid-character, so a stale or shifted span fails the check rather than panicking. Any failure — unreadable file, no live symbol, text that does not spell the name — drops the snippet and leaves today's card exactly as it was. A hover must never lie; less information beats wrong information.
Note the asymmetry, and that it is deliberate: the open path widens
decl_span (mirroring local_text, which is the only span a live symbol
offers that covers a whole multi-line declaration), the disk path widens
def.name_span (the only span the index holds). For the declarations the ask
is about — ports, parameters, typedefs, a module header — both are one line
and the two paths print the same thing.
Cutting it down
cut_to_size trims trailing blank space (as local_text does; leading
indentation stays, so the line reads as written) and then applies two caps,
each with its own note under the fence:
| Cap | Value | Why |
|---|---|---|
| lines | SNIPPET_LINES = 5 |
a module's decl_span is its whole body |
| characters | SNIPPET_CHARS = 400 |
one netlist line can be megabytes |
A cut appends … inside the fence and *shown to N lines* /
*shown to N characters* after it — the same shape as the macro card's
*truncated at N characters*, so the two footnotes read as one convention.
The character cap counts chars and cuts on a boundary.
Status / TODO
declaration_snippetwith the open-buffer and disk paths.- Guard on both paths; snippet omitted on any mismatch.
- Line and character caps with a note.
- One snippet per candidate for an ambiguous name.
indexed_def_for_symbolshared withnav.rs, behaviour unchanged.- Tests (9 new, in
hover.rs's own test module). - Hover row + hover section in
docs/features/lucisv-server/README.md. cargo fmt/cargo clippy --all-targets/cargo test --workspace.- Not done, deliberately: no facts/cache change, nothing in
vlog_semantic, no TODO.md edit (no existing checklist item covers this; §8's hover items are all already checked, and inventing one is out of scope). - 2026-08-28: one disk read per file per hover (
disk_viewmemo); QA finding 4 closed. - 2026-08-28:
live_symbol(andnav::indexed_references) look a name up instead of scanning every symbol, with the first-match tie-break pinned by test. - 2026-08-28: a CRLF file's snippet no longer carries an interior
\rinto the fence; QA finding 2 closed. - 2026-08-28 (
docs/features/hover-line-index/README.md): the disk path's heading costs no read at all (Def::lines) and its snippet's read is shared across hovers, so the second hover into a closed file is free.disk_viewis gone, subsumed byWorkspace::file_view.
Work log
2026-08-27 — dev
- Read the brief,
hover.rs,nav.rs,state.rsandconvert.rs. Confirmed the two facts the design rests on:set_documentdoes not rebuild the index (so an open buffer really can hold a span the index does not know about — the case step 1 exists for), andfollow_onelooks aDefup byreference.name, which is what licenses using that name as the guard's expected text rather than trying to recover a name fromDef. - Added
declaration_snippet,live_symbol,span_text,fencedandcut_to_sizetohover.rs, plus the two caps as consts.symbol_hover'sExternalarm now appends the snippet to each candidate's part; the heading it appends to is untouched. - Raised
nav::indexed_def_for_symboltopub(crate)with a doc line naming the second caller. No other change tonav.rs. - Decision: the open path uses
decl_spanand the disk pathname_span, per the brief. Considered usingname_spanon both for symmetry — it would make a big module's card one header line rather than five — but that would drop the live-buffer case's only handle on a multi-line declaration, and the line cap already bounds the damage. Recorded in How the snippet is fetched so the asymmetry is a decision and not an accident. - Decision: no fallback from the open path to disk text. If a file is open and no live symbol matches, the buffer has been edited past the index and the indexed span is exactly the thing that cannot be trusted; falling back would re-introduce the wrong-line risk the guard exists to remove.
- Nine tests added (listed below). Ran the gates: fmt
clean, clippy
--all-targetsclean,cargo test --workspacegreen at 2372 passed / 0 failed / 12 ignored.
Tests added (all in crates/lucisv_server/src/hover.rs, mod tests):
| Test | Pins |
|---|---|
a_cross_file_port_connection_shows_the_ports_own_declaration_line |
the ask: direction + type + width, and only that port's line |
a_cross_file_module_instance_shows_its_header_line |
the module header, disk path |
a_package_member_shows_its_declaration_line |
a localparam and a typedef through import p::* |
an_unsaved_edit_that_moved_the_declaration_is_read_at_its_live_span |
live line, not the stale-span line (asserts the new width and the absence of the old) |
a_stale_indexed_span_drops_the_snippet_rather_than_showing_the_wrong_line |
guard, disk half: file rewritten under a live index → no fence at all, heading intact |
an_open_buffer_that_no_longer_declares_the_name_drops_the_snippet |
guard, live half: the port renamed away in the buffer |
a_very_long_declaration_line_is_cut_with_a_note |
the character cap and its note |
a_declaration_spanning_many_lines_is_cut_at_the_line_limit |
the line cap, via an open module whose decl_span is its body |
two_files_declaring_one_name_each_get_their_own_snippet |
ambiguous name: both headings, both snippets |
2026-08-28 — dev (performance: one disk read, one name lookup)
Parts A2 and A3 of the "Improve LSP performance + hover accuracy" round.
Behavior of every card is unchanged; both items are the same answer, reached
with less work. Numbers in docs/perf/README.md.
- A2 — one read per file per hover. A hover into a closed file used to
read that file and build a
LineIndexover it twice: once inlocate::line_numberfor thefile:lineheading, once indeclaration_snippetfor the fenced lines. This is QA's finding 4 below, and it is now closed.symbol_hoverholds a per-request memo — one(path, text, LineIndex)indisk_view— that the heading and the snippet both read, anddeclaration_snippetno longer touches the disk at all: it is now the open-buffer path only, with the closed-file path inlined insymbol_hoverbeside the heading it shares a read with. Thespells_exactlyguard applies on both paths exactly as before. A card naming one file twice (two declarations in one file) now pays for one read, not two, which is why the memo is keyed by path rather than being a singleOptionper candidate.- Measured: 34 ms → 16.3 ms on QA's own 31.7 MB measurement, and 141 µs of
a 148 µs hover at 10 000 lines is that one read. See
docs/perf. - QA's measurement test was renamed
hovering_into_a_large_closed_file_reads_it_twice→..._reads_it_once, since the doubling it was named for is gone. The QA log below still names the old spelling; that section is QA's to amend.
- Measured: 34 ms → 16.3 ms on QA's own 31.7 MB measurement, and 141 µs of
a 148 µs hover at 10 000 lines is that one read. See
- A3 —
live_symbolstops scanning every symbol. Walking the whole buffer's symbol table and callingnav::indexed_def_for_symbol(two index lookups) on every symbol whose name happened to match — and reaching every symbol whose name did not — became a name-keyed lookup:vlog_semantic::Semantics::symbols_named(name), two binary searches over a side table of symbol ids sorted by name, built once duringanalyze. Only same-named declarations are probed. A side table rather than aHashMap<String, Vec<SymbolId>>so thatSemantics— which is cloned per document — does not carry a second copy of every name it already holds; four bytes per symbol against aStringper symbol.- The tie-break is preserved. The map's lists are built by walking the
symbols in order, so
symbols_namedyields declaration order — the same order, and the same first match, the oldsymbols().iter().find(..)made. Pinned bylooking_a_name_up_answers_exactly_what_scanning_every_symbol_wouldincrates/vlog_semantic/tests/semantics.rs, which compares the two answers directly and asserts the earlier declaration comes first. QA'sduplicate_live_declarations_of_one_name_pick_the_first_one_silently(finding 3 below) still passes, unchanged. nav.rs'sindexed_referenceshad the same scan-by-name for the declaration's live span; it is the same swap and was made in the same change, for the same reason.vlog_refactor::ports.rs:1154has a third one (symbols().iter() .position(|s| s.name == port && …)). It is not a trivial swap — the predicate carries a kind and a span test and the code wants the position as aSymbolId— and it is in another crate, so it is left alone and recorded here rather than done.- Cost: four bytes per symbol. Measured saving on the lookup alone:
8.41 µs → 133 ns over a 5 001-symbol file (
docs/perf/README.md).
- The tie-break is preserved. The map's lists are built by walking the
symbols in order, so
2026-08-28 — dev (the heading stops reading the file at all)
Round hover-line-index — full argument, measurements and tests in
docs/features/hover-line-index/README.md. What changed here:
- The
Externalarm's disk branch no longer reads anything for the heading.Defnow carrieslines: DeclLines, recorded when the file was indexed, so**port** — declared insub.sv:2`` is a field lookup. The live branch is untouched and still asks the open buffer's own line index, because that buffer may hold unsaved edits the index has not seen — the same reasondeclaration_snippetmatches aDefto a live symbol logically. disk_viewwas deleted. Its job — one read per file per hover — is nowWorkspace::file_view's, which does it once per file per generation of that file, so the next hover into the same file reads nothing. The four points that drop a held view are listed in that round's Handshakes.spells_exactlyand both caps are untouched, and a stale held view can only ever make a snippet vanish. Every existing test in this file passed unmodified.- One corner moved deliberately: a closed file that cannot be read now
still gets its line in the heading (
sub.sv:2rather than a baresub.sv), because the line no longer depends on the read. Pinned bya_closed_files_heading_line_comes_from_the_index_and_not_from_a_read. - Measured: a hover into a 12 MB closed file, 6.2 ms → 0.95 µs on the second hover; the 31.7 MB probe above, 17.0 ms → 4.4 µs on the second. The first touch is unchanged, because the snippet genuinely wants the text.
2026-08-28 — dev (CRLF, closing QA finding 2)
- Finding 2 below — a CRLF file's multi-line snippet keeping an interior
\rinside the fence — is fixed, as part ofport-detail-spans' PDS-4. Every line a card shows now goes throughattached_lines, which strips a trailing\ras it composes each line; that covers both this feature's snippet path andlocal_text's in-file path, which QA named as having the same property, because both reach it throughfenced_sections. Display text only: no buffer is written. - QA's pinned regression test was named for the old behaviour
(
a_crlf_multiline_snippet_keeps_interior_carriage_returns) and asserted it; it is nowa_crlf_multiline_snippet_carries_no_carriage_returnsand asserts the opposite, plus that the lines read as written. The QA log below still names the old spelling; that section is QA's to amend. - No other change to this feature.
spells_exactly, the caps and the disk/live split are untouched.
QA log
2026-08-27 — QA
Read the brief, the dev's Work log, and crates/lucisv_server/src/hover.rs /
nav.rs in full. Ran the gates first (all green before any probing): cargo fmt --check clean, cargo clippy --all-targets --workspace -- -D warnings
clean, cargo test --workspace green — 1173 passed / 0 failed / 12 ignored
(pre-existing) before this round's own probes were added.
Then attacked declaration_snippet, live_symbol, span_text and
cut_to_size along the seven angles in the charter. Eight probe tests added
to a new mod qa_hover_declarations in hover.rs (one #[ignore]d perf
measurement); one real defect found and fixed with a ninth test pinning it.
Finding 1 — MEDIUM, fixed. The guard was a fixed-length substring check,
not a whole-identifier check, so an edit that only extends a name defeats
it. declaration_snippet's guard (hover.rs:243 and :252, before the fix)
compared span_text(text, span) — a slice of exactly name.len() bytes at
the old, recorded offset — against name. def.name_span's length is
whatever the name was when the index was last built; it does not grow if the
file is edited without a reindex. So: index built on input logic [7:0] addr;, then the file is rewritten on disk to input logic [7:0] addr2;
without triggering a reindex (an ordinary edit-then-hover-before-save-event
race, exactly the staleness window this feature's guard exists for). The old
span still covers exactly the four bytes "addr" — a prefix of the new
"addr2" — so span_text returns Some("addr"), equals the hovered name,
and the guard passed. The card for .addr(...) then showed
input logic [7:0] addr2 under a heading that says addr's declaration,
one line pretending to be a name it is not — exactly the masked-corruption
shape CLAUDE.md's invariant 4 is about, applied to this round's new safety
net rather than verify.rs.
- Repro (was a failing/panicking assertion, now a passing regression test):
a_disk_edit_that_only_appends_to_the_name_defeats_the_guard,hover.rs:1060. - Fix: added
spells_exactly(hover.rs:293) andcontinues_a_name(hover.rs:306), and switched both guard call sites (declaration_snippet's live and disk branches) to it. It keeps the existing text-equality check and additionally requires that the character immediately outside the span on either side (if any) is not an identifier-continuation character ([A-Za-z0-9_$]) — turning a prefix/suffix match back into a miss. Applied to both branches for one guard, one guarantee, even though the live branch'ssymbol.name_span(a token span from a fresh parse) could not actually suffer this —symbol.name == namewas already checked before the span comparison, so the length always matched there. No behavior change for any span that is a genuine whole identifier, which is every case the dev's 9 tests and the existing corpus tests exercise — fullcargo test --workspacestayed green (1173 passed / 0 failed / 13 ignored, the 13th being this round's own perf probe) after the fix. - This does not close every staleness gap by design — a same-length edit that changes an identifier into a different same-length identifier, or that changes what a name's kind means without renaming it, is still the accepted risk window the Assumptions section already names ("a hover is a rare, one-name, human-speed request"). What the fix removes is specifically the case where the shown text visibly disagrees with the name in the heading — the one the guard's stated promise ("never show a wrong line") is about.
Finding 2 — LOW, filed, not fixed. A CRLF file's multi-line snippet
keeps the embedded \r on every interior line, only the last one is
trimmed. cut_to_size (hover.rs, unchanged by QA) calls trim_end() once
on the whole cut string, which strips a trailing \r (and \n) but not an
interior one before a kept newline. local_text (the in-file branch,
pre-existing, not part of this round) has the identical property via the same
whole_lines/trim_end shape, so this is not new behavior introduced by
this feature, just newly reachable from a second call site. Cosmetic, not a
correctness break: the bytes shown are exactly the file's own bytes, and a
fenced code block renders them close to verbatim either way. Pinned as a
permanent regression test rather than fixed, since a real fix (stripping
\r before every kept \n, in both local_text and here) is a
cross-cutting change to shared rendering, out of this round's stated scope
(hover.rs's External arm and its shared helper with nav.rs).
- Repro:
a_crlf_multiline_snippet_keeps_interior_carriage_returns,hover.rs:1156.
Finding 3 — LOW/accepted, pinned as a regression test, not a defect of this
round. Two live declarations of the same name+kind in one open buffer (a
transient mid-edit state, e.g. a duplicate line not yet deleted) make
live_symbol's .find() pick whichever comes first in Semantics::symbols()
order, silently. indexed_def_for_symbol (nav.rs:164, visibility-only
change this round) maps any live symbol with a matching name/kind/owner
back to the single persisted Def for that name when the index itself has
only one — it does not know or care that the live buffer momentarily has
two. This is inherited, unchanged behavior from nav.rs's existing
go-to-definition matcher (the Handshakes section calls this out on purpose:
"one matcher, so a hover snippet and a go-to-definition can never disagree").
Not a lie in the sense the guard is about — the guard still requires the
chosen symbol's own span to spell the name exactly, which it always does
here by construction — but it is a silent, unsignaled choice between two
candidates. Filed rather than fixed: fixing it means changing
indexed_def_for_symbol's matching rule, which is nav.rs's and explicitly
out of this round's scope ("nav tests must stay green," brief line 27).
- Repro:
duplicate_live_declarations_of_one_name_pick_the_first_one_silently,hover.rs:1126.
Finding 4 — perf note, not a defect, no action taken. A hover resolving
into a large closed file reads the file and builds a LineIndex over it
twice: once inside locate::line_number (for the file:line heading — this
predates this round) and again inside declaration_snippet (for the
snippet — new this round), independently, from the same disk path. Measured
in release mode: a 31.7 MB synthetic file (600k filler lines behind a small
port declaration, maxFileSize raised so it indexes at all) took 34 ms for
one hover — acceptable for a rare, single-shot request, but a real, avoidable
doubling of I/O and linear scan work per disk-path candidate. A fix would
mean threading one read/LineIndex through both line_number and
declaration_snippet, which touches locate.rs (also used by macro_hover)
and is a small refactor rather than a one-line change — noted per the
charter's "note it, don't redesign" rather than attempted.
- Measurement,
#[ignore]d (writes ~30 MB, not a correctness assertion):hovering_into_a_large_closed_file_reads_it_twice,hover.rs:1325. Run withcargo test --release -p lucisv_server large_closed -- --ignored --nocapture. - Amended 2026-08-28 — QA. Closed by A2 (
docs/perf/README.md):symbol_hover'sdisk_viewmemo now shares one read + oneLineIndexbetween the heading and the snippet. Re-ran the same measurement (now named..._reads_it_once): 17.0 ms, against the documented "34 ms → 16.3 ms" — matches within the run-to-run noisedocs/perf/ README.mditself calls out. No longer an open finding.
Verified, no finding (angles from the charter that turned up nothing):
UTF-8 multi-byte content before a declaration, on the same file, does not
panic span_text/whole_lines (multibyte_utf8_before_the_declaration_does_not_panic,
hover.rs) — both are .get()-based and this stayed a belt-and-braces pin.
A declaration at byte offset 0 and a declaration on the file's last line with
no trailing newline both render correctly, no underflow
(a_declaration_at_the_very_start_of_the_file_is_shown,
a_declaration_on_the_last_line_with_no_trailing_newline_is_shown). The line
cap (SNIPPET_LINES = 5) and character cap (SNIPPET_CHARS = 400) are both
exact-boundary-safe — 5 lines / 400 chars is not cut, 6 lines / 401 chars is,
and a 400-char boundary landing mid multi-byte character is not split because
cut_to_size counts with char_indices, never raw bytes
(exactly_the_line_cap_is_not_cut_one_more_is,
exactly_the_char_cap_is_not_cut_one_more_is_and_boundary_is_safe). A
case-mismatched open buffer (same file, different-case path on a
case-insensitive filesystem) is not recognized as "the target file open" by
document_for_path's exact PathBuf equality, so it falls back to the disk
path rather than mixing the two identities — the safe direction, confirmed
with unsaved edits in the mismatched buffer never leaking into the card
(a_case_mismatched_open_buffer_is_not_recognized_as_the_target_falls_back_to_disk,
macOS/Windows-gated). Multiple ambiguous candidates each render from their
own file with no cross-contamination — the dev's own
two_files_declaring_one_name_each_get_their_own_snippet already covers
this and reads fine without a divider between candidates (each fenced block
is its own visual unit).
Gates, final. cargo fmt --check clean. cargo clippy --all-targets --workspace -- -D warnings clean. cargo test --workspace: 1173 passed / 0
failed / 13 ignored (12 pre-existing + this round's one perf probe).
Review
2026-08-27 — lead. Reviewed the full diff after QA's SHIP verdict;
gates re-run independently (fmt clean, clippy silent, 1173 server tests
green). The shape is right: no widening of persisted facts, snippets
fetched at hover time from whichever text the span is valid against
(live logical match through nav.rs's one matcher, disk otherwise),
and a guard that prefers no snippet to a wrong one. QA's MEDIUM find —
the fixed-length substring guard passing on a name that had merely been
extended in place — is precisely the masked-corruption shape
invariant 4 exists for, applied correctly to a new forgiveness path
outside verify.rs; the spells_exactly boundary check closes it on
both the live and disk paths and the attack test pins it. The
deliberate asymmetry (live path shows decl_span, disk path the name's
line) is documented and bounded by the caps; the duplicate-live-symbol
tie-break is inherited from the shared matcher and correctly pinned
rather than re-designed. The CRLF interior-\r cosmetic and the
double-read of large closed files are accepted as filed. Accepted;
committed by the lead.