Files
lucioandClaude Fable 5.1 a2a22adad8
ci / checks (push) Successful in 1m14s
ci / corpus (push) Successful in 36s
Cross-file references reach a module's nets, variables and instances (§64.1, QA task_d8afe80f of §63.1): nav.rs's two index questions (leaves_this_file, indexed_def_in_file, the latter shared with hover's live_symbol) asked WorkspaceIndex::member — the connection surface, ports and parameters — so a declaration only a hierarchical path can name (a bind connection's expression half, a u_x.sig tail) was judged unable to leave its file and references fell to the single-file answer, while a rename already edited both files; from a use that did resolve cross-file, the declaring buffer's own uses could not re-identify themselves. Both now ask member_in(…, Surface::Hierarchical); the connection answer comes first and whole from that read, so every port/parameter/package/class/struct answer is byte-identical (nav harness controls and a 948-declaration opentitan census). A hierarchical-only member has no Local postings by the §49 ruling, so nav::declaring_file_uses parses exactly the closed declaring file once per request (0.4–1.5 ms on state_q into a shut entropy_src_main_sm.sv), hierarchical_only asking the index's own table rather than restating surface_of. Three QA rounds (Sonnet, Sonnet, then Fable per the escalation rule): the closed-file path read a cached FileView and rendered against a fresh text_of (a stale offset on a wrong line) — now one fresh read per closed file threaded to the rendering step; every index-time span about a closed file, and the open-buffer declaration fallback (nav::declaration_site), guarded by hover::spells_exactly (pub(crate), shared not copied): a stale index may omit a location, never mislocate one. Accepted: +25 % on a local-net references in a 40 267-line buffer (1.22 → 1.54 ms), the guard is textual (a different exact token at a deleted declaration's old bytes). opentitan: entropy_masking_req from aes.sv now lists aes_bind.sv; state_q lists entropy_src_core.sv; checkout untouched. Tests 4422 → 4459 (11 dev + 1 hover + 1 e2e wire test; 19 QA attacks incl. escaped identifiers, UTF-8 boundaries, a deleted declaring file, oracle equivalence with vlog_refactor::find_references); fmt, clippy, workspace suite green through tools/guard.sh. Feature README docs/features/references-hierarchical-surface; references-nav, hierarchical-tail and hover-declarations READMEs, record.rs's postings comment and the topo row amended; perf entry in docs/perf/README.md. Release 0.55.0 left to the owner.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-12 14:50:16 -07:00
..
Cross-file references reach a module's nets, variables and instances (§64.1, QA task_d8afe80f of §63.1): nav.rs's two index questions (leaves_this_file, indexed_def_in_file, the latter shared with hover's live_symbol) asked WorkspaceIndex::member — the connection surface, ports and parameters — so a declaration only a hierarchical path can name (a bind connection's expression half, a u_x.sig tail) was judged unable to leave its file and references fell to the single-file answer, while a rename already edited both files; from a use that did resolve cross-file, the declaring buffer's own uses could not re-identify themselves. Both now ask member_in(…, Surface::Hierarchical); the connection answer comes first and whole from that read, so every port/parameter/package/class/struct answer is byte-identical (nav harness controls and a 948-declaration opentitan census). A hierarchical-only member has no Local postings by the §49 ruling, so nav::declaring_file_uses parses exactly the closed declaring file once per request (0.4–1.5 ms on state_q into a shut entropy_src_main_sm.sv), hierarchical_only asking the index's own table rather than restating surface_of. Three QA rounds (Sonnet, Sonnet, then Fable per the escalation rule): the closed-file path read a cached FileView and rendered against a fresh text_of (a stale offset on a wrong line) — now one fresh read per closed file threaded to the rendering step; every index-time span about a closed file, and the open-buffer declaration fallback (nav::declaration_site), guarded by hover::spells_exactly (pub(crate), shared not copied): a stale index may omit a location, never mislocate one. Accepted: +25 % on a local-net references in a 40 267-line buffer (1.22 → 1.54 ms), the guard is textual (a different exact token at a deleted declaration's old bytes). opentitan: entropy_masking_req from aes.sv now lists aes_bind.sv; state_q lists entropy_src_core.sv; checkout untouched. Tests 4422 → 4459 (11 dev + 1 hover + 1 e2e wire test; 19 QA attacks incl. escaped identifiers, UTF-8 boundaries, a deleted declaring file, oracle equivalence with vlog_refactor::find_references); fmt, clippy, workspace suite green through tools/guard.sh. Feature README docs/features/references-hierarchical-surface; references-nav, hierarchical-tail and hover-declarations READMEs, record.rs's postings comment and the topo row amended; perf entry in docs/perf/README.md. Release 0.55.0 left to the owner.
2026-09-12 14:50:16 -07:00

references-hierarchical-surface

TODO.md §64.1 — textDocument/references for a declaration that only a hierarchical path can reach. docs/topo.md §2.9 row for lucisv_server ──▶ vlog_semantic. Ships in 0.55.0.

Goal

With module leaf declaring logic sig and another file writing assign w = u_leaf.sig; (or a bind's connection expression naming it), textDocument/references answered leaf.sv alone. It could not list a use that a rename since 0.45.0 happily edits — the same asymmetry references-nav was written to remove, re-opened for one class of declaration by hierarchical-tail.

The cause was in crates/lucisv_server/src/nav.rs, in the two functions that map a name onto the index:

  • leaves_this_file asked WorkspaceIndex::member(owner, name) — the connection surface, a module's ports and parameters. A module's net, variable or instance is exported on the hierarchical surface only (workspace/hierarchy.rs::surface_of, since 2026-09-05), so the gate judged such a declaration unable to leave its file and the request degraded to the single-file answer.
  • indexed_def_in_file — wrapped by indexed_def_for_symbol, which hover.rs::live_symbol shares — mapped a live Symbol back to its persisted Def the same way. So even a request that did go cross-file (from a use the overlay resolved) could not re-identify an open buffer's own in-file uses of the net, and dropped them.

Both now ask member_in(owner, name, Surface::Hierarchical). The connection answer is a prefix of the hierarchical one (hierarchy::member consults the connection table first and returns it whole when it is non-empty), so a port, a parameter, a package member, a class field and a struct field keep their answers byte-for-byte.

A second, consequential gap had to close in the same change: the index deliberately records no Local reference posting for a use whose declaration is hierarchical-only (workspace/record.rs::facts_from_analysis, "the connection surface only"), so references_to(def) holds the cross-file External sites and nothing else. The declaring file's own uses came from indexed_references' open-documents loop — which only sees it while it is open. Requesting references from the bind file with leaf.sv closed would therefore have listed the cross-file sites and the declaration and silently omitted leaf.sv's own assign … = sig lines. indexed_references now analyses that one file once, on exactly that shape.

Assumptions

  • Reachability is judged on the surface a use can actually reach the declaration by. Not on the surface a connection list may name, which is what member answers. The two call sites ask Surface::Hierarchical because a references answer must cover every way another file can spell the name, and a hierarchical path is one of them (IEEE 1800 §23.6).
  • The hierarchical answer contains the connection one, first, whole — hierarchy::member's own contract, asserted there by a_tail_naming_a_port_is_one_answer_and_one_edit. That is what makes this a widening and not a change: every name the connection read answered is answered identically by the hierarchical read.
  • A name declared twice in one unit is not silently the port. For a unit declaring both a port x and a net x, the hierarchical read returns the port record (connection first). indexed_def_in_file's kind filter (def.kind == symbol.kind) then rejects the net symbol, so the net gets the honest single-file answer and the port keeps its cross-file one. The single-record rule (defs.len() != 1) and references_are_ambiguous keep their meaning unchanged over the wider answer.
  • A declaration on neither surface still never asks the workspace. A net declared inside a generate block belongs to the block's scope, not the module's (hierarchical-tail, "a unit's members are the symbols of its own scope"), so member_in answers nothing for it and the gate is false — the same honest single-file fallback u_x.gen_b.sig gets from a rename.
  • The closed-file re-analysis is a completeness repair, not a second authority. It runs only when the target declaration is hierarchical-only and its declaring file has no open buffer, it parses exactly that one file, and it contributes spans for exactly the one symbol that maps back to the same Def the request is about — the same logical identity check (path, owner, name, kind) indexed_def_in_file makes everywhere else. Its spans go through the same sort/dedup/empty-drop locations already applies, so it can add occurrences and never reorder or duplicate them.
  • One text per closed file per request, and it is a fresh one (added 2026-09-12 in rework; QA finding 1). A span means nothing except against the bytes it was computed from. declaring_file_uses reads with Workspace::text_of, which never caches, and returns that text so locations renders its spans against the same bytes instead of taking a second, independent read of the same path. Workspace::file_view is deliberately not used here: it is the right cache for hover, which reads a closed file once per generation of it and renders nothing but a snippet from that read, and it is the wrong input for a span that a different step in the same request turns into a line and column. An external edit to a closed file is none of the five events that drop a view, so the cached bytes and locations' fresh bytes can disagree — which is precisely how QA got a wrong line rather than an omission.
  • A closed file's index-time span is a claim, and it is checked. Every span about a closed file that did not come from this request's own read — a references_to posting, the include_declaration fallback — is emitted only if it still spells the target's name exactly in the text it is about to be rendered against (hover::spells_exactly, shared rather than copied, so the prefix/suffix lesson its QA taught applies here too). Otherwise it is dropped. A stale record can then only ever omit a location, never point at a wrong line — the same guarantee hover gives a stale snippet, and it holds for open buffers too (QA finding 4, fixed 2026-09-12). An open buffer's own spans pay nothing: they came from the very text they are rendered against. The one index-time span that can reach an open buffer is the include_declaration fallback, taken only when the buffer no longer declares the name at all (an unsaved rename); declaration_site emits it only if it still spells the name exactly in the live text, else omits the declaration. Cost: one slice compare plus two character tests per closed-file location, and the same once per request on that one fallback.
  • hierarchical_only reads the index, not a rule restated in the protocol layer. WorkspaceIndex::hierarchical_declarations(name) enumerates the hierarchical-only table, which is exactly where surface_of's Surface::Hierarchical tag routes a record (workspace/update.rs ~301). So the test cannot drift from surface_of the way a matches!(def.kind, Net | Var | Instance) restated in nav.rs would: that spelling would be wrong for an interface's net (connection) and would go stale the next time surface_of moves a kind.

Handshakes

Consumed from vlog_semantic (all already public before this change; no new API, no FACTS_FORMAT bump, no index field):

  • WorkspaceIndex::member_in(unit, name, Surface) and Surface — the two call sites' new question. member_in needed no new case; surface_of already tags a module's nets, variables and instances Surface::Hierarchical and an interface's instances likewise.
  • WorkspaceIndex::hierarchical_declarations(name) — the hierarchical-only census, previously read only by rename's fan-out. Used here to ask whether one Def is hierarchical-only. It iterates the units that have hierarchical-only members and probes each for name, with an early-out; this lane asks it at most once per references request, and only when the declaring file is closed.
  • parse_source_tolerant + analyze + Semantics::{symbols_named, references_of, symbol, scope, file_scope} — the one-file re-analysis, the same pair FileFacts::analyzed and rename's engine run.

Request (not taken here): a WorkspaceIndex query keyed by Def — say fn hierarchical_only(&self, def: &Def) -> bool beside references_are_ambiguous — would turn the census iteration above into one map probe. It belongs in crates/vlog_semantic/src/workspace/index.rs, which is outside this lane's file list, and the measured cost of the iteration did not justify asking for the widening now. Recorded so the next lane in that file can take it.

Promised to hover.rs: nav::indexed_def_for_symbol keeps its signature and its contract (a live symbol maps to the indexed Def that is it, by path/owner/name/kind). It now also answers for a hierarchical-only member, so hover's live_symbol finds a live net's declaration in an edited buffer and the card gains the snippet it used to drop. Nothing hover already answered changed. No production edit was needed in hover.rs.

Consumed from this crate's own hover.rs: spells_exactly, made pub(crate) (visibility only, no behaviour change) so the closed-file span guard is the same check hover applies to a closed-file snippet rather than a second copy of it — QA's prefix/suffix lesson lives in that function and must not be re-learned. Noted in docs/features/hover-declarations/README.md's work log.

Promised to vlog_semantic's record.rs: its "an answer nothing reads" comment is no longer true and now names this consumer and how it is served. Comment only; no code, no format change.

Unchanged by contract: documentHighlight stays a document answer even for a cross-file name (references-nav, 2026-08-28). It reads Semantics/the overlay, never the index's reachability gate, so it needed no change; it is pinned here from both ends anyway.

verify.rs: untouched. No normalization added or broadened, so no masked-corruption attack tests are owed.

Status / TODO

  • feature README skeleton before the work
  • the fixture sweep, asserting today's answers first and then flipped: definition, references (from the declaration and from each use, includeDeclaration both ways), hover, documentHighlight over (a) a bind connection's bare name, (b) a u_x.sig tail from an instantiating file, (c) a two-level tail, (d) a port of the same unit (unchanged), (e) a package member (unchanged), (f) a name declared twice in one unit (one symbol, one record — see the work log), (g) an untitled: buffer, (h) the open buffer's own in-file use seen from a cross-file use, (i) the declaring file closed
  • the fix in both call sites
  • the closed-declaring-file completeness repair
  • the §63.1 QA test renamed and its assertions flipped
  • a_local_signal_never_asks_the_workspace rewritten honestly
  • the attack cases pre-empted (generate-scoped net; a net shadowed by a port of the same name in another unit; both a port and a net of one unit; a class member; a package member; untitled:; two like-named modules)
  • opentitan, read-only: entropy_masking_req from aes.sv lists aes_bind.sv; state_q from entropy_src_main_sm.sv lists entropy_src_core.sv; the nav harness row before/after
  • gates: cargo fmt --all -- --check, cargo clippy --all-targets, cargo test --workspace, all through tools/guard.sh
  • TODO §64.1 ticked; the two neighbouring READMEs amended

Rework round (QA findings 1–3), 2026-09-12:

  • finding 1: declaring_file_uses reads with text_of (fresh, never cached) and returns that text; locations renders the declaring file's spans against it, so one closed file is read exactly once per request
  • finding 1: the declaration reported for a re-analysed closed file is its live span, not the index-time one
  • findings 2–3: every index-time span about a closed file is guarded with hover::spells_exactly against the text it is rendered in, and dropped if it no longer spells the name — open buffers pay nothing
  • hover::spells_exactly made pub(crate), noted in docs/features/hover-declarations/README.md's work log
  • qa_finding_1/2/3 flipped to the fixed answers and renamed to say what they pin; one new attack on the guard itself (qa_a_stale_span_that_now_spells_a_longer_name_is_dropped)
  • gates re-run; opentitan rows re-confirmed byte-identical

Rework round 2 (QA finding 4), 2026-09-12:

  • the include_declaration block lifted into declaration_site (a pure move plus the guard); an open buffer's index-time fallback span emitted only if hover::spells_exactly holds against the live text, else the declaration is omitted — the closed path still guarded exactly once
  • QA's finding-4 test flipped to the fixed answer and renamed (qa_recheck_a_renamed_open_buffers_stale_declaration_is_omitted_not_misreported), its unsaved-rename setup kept; one control test (an_open_buffer_edited_above_its_declaration_reports_the_live_declaration_line)
  • gates re-run through tools/guard.sh

Work log

2026-09-12 — dev

What changed, in production code. Three edits in crates/lucisv_server/src/nav.rs and nothing else:

  1. leaves_this_file — the member branch now asks member_in(&owner.name, &symbol.name, Surface::Hierarchical) where it asked member.
  2. indexed_def_in_file — the same swap, and its first parameter became &Semantics instead of &Document. It only ever read doc.semantics, and taking the analysis directly is what lets the closed-file repair below ask the identity question the same way, by construction rather than by a second copy of the rule. indexed_def_for_symbol (shared with hover.rs::live_symbol) keeps its signature.
  3. indexed_references gained one line — found.extend(declaring_file_uses(ws, &target)) — plus the two new functions it calls, declaring_file_uses (26 lines) and hierarchical_only (3).

Why the closed-file repair exists. The lead's second gap, confirmed on the real tree. With member_in in place but nothing else, references from entropy_src_core.sv's u_entropy_src_main_sm.state_q with the declaring file closed answered entropy_src_main_sm.sv: [42] — the declaration alone — and silently dropped lines 46, 49 and 60. The index posts no Local fact for a hierarchical-only declaration, so references_to holds only the cross-file External sites, and the open-documents overlay can only speak for a file that is open. declaring_file_uses closes it with one parse_source_tolerant + analyze of exactly that file, behind three gates in increasing cost order: the declaring file has no open buffer (one binary search), the declaration is hierarchical-only (the census below), and the file could be read. The spans go through locations' existing sort/dedup/empty-drop, so the repair can only add occurrences.

(Amended by the rework entry below: this first pass read the file through Workspace::file_view, a cache, which is what QA's finding 1 caught. It now reads once through text_of and hands the same bytes to the rendering step.)

The hierarchical_only test, and why this one. The brief offered two spellings. The member(unit, name).is_empty() && !member_in(…) pair needs the owner's unit name, which indexed_target has in its Definition::Local branch and does not have in its Definition::External branch — and the External branch is exactly the shape that matters (a request from the bind file or from top.sv). A matches!(def.kind, Net | Var | Instance) spelled in nav.rs needs no unit name but restates hierarchy::surface_of, and would already be wrong for an interface's net, which that rule puts on the connection surface. So the test asks the index's hierarchical-only table itself: hierarchical_declarations(name).any(|(_, held)| held == &target.def). A Def is in that table exactly when surface_of tagged it Surface::Hierarchical (workspace/update.rs routes on decl.surface), which is precisely "no Local posting was recorded for it" — the condition the repair is for. Cost: an iteration over the units that hold hierarchical-only members, with an early-out, taken at most once per request and only after the declaring file is known to be closed. Measured, not assumed: the nav harness's two references rows are 1.39–1.86 → 1.12–1.58 ms (aes, a unit) and 1.05–1.65 → 1.14–1.59 ms (.clk_i, a port whose declaring file is closed — the row that pays for the census and nothing else), with identical result counts. A WorkspaceIndex query keyed by Def would make it one map probe; that is filed as a Handshake request above rather than taken, because workspace/index.rs is outside this lane's files and the measurement does not justify asking.

What the fixture sweep found, in order. Written first against today's behaviour: the eleven new nav.rs tests were run before the production edits and exactly four failed, with exactly the incomplete answers §64.1 describes — from the declaration [leaf.sv 1, leaf.sv 2] (both tails missing); from a tail [leaf.sv 1, single.sv 3, top.sv 3] (the declaring file's own use missing); the same with the declaring file closed; and the shadowed-net attack [sb.sv 1, sb.sv 2]. The other seven — definition, documentHighlight, the port, the parameter, the class member, the redeclared name, the two like-named modules, the untitled: buffer — passed before the change and pass after it, which is the byte-identity claim asserted rather than argued. The new hover test and the new wire-level e2e test were each also run against a deliberately reverted binary and each failed there (no fence on the card; [leaf.sv 1, leaf.sv 2] over the wire).

Case (f) as posed cannot arise, and that is the finding. §64.1 asked that "a name declared both as a port and as an internal net of the same unit is ambiguous, not silently the port". vlog_semantic records one symbol per name per scope — a redeclaration becomes a Duplicate and a reference to the first declaration — so one (unit, name) never has two records from one file, and there is no port for the answer to silently become. Tried both spellings (module both (input logic x); wire x; and module pboth #(parameter int q = 1) (); wire q;): one symbol, one index record, one complete answer from either cursor position, before and after the change. Pinned as a_name_declared_twice_in_one_unit_is_one_symbol_and_one_record. What is reachable is the same name declared in two files — two records for one (unit, name) — and there the single-record rule (defs.len() != 1) declines exactly as before; pinned as two_modules_of_one_name_keep_a_hierarchical_net_on_the_in_file_answer. The port-versus-net asymmetry does still exist one level down, in indexed_def_in_file's kind filter, and is written up in Assumptions.

a_local_signal_never_asks_the_workspace, rewritten. Its !leaves_this_file assertion on a module's net was the old contract and is now false, so it flipped; the two truths it protected did not, and are asserted more sharply than before — other.sv's same-named net is still never listed, and a generate-block-scoped net and an undeclared name still never ask the workspace. ws.held_views() is now asserted empty in that test, so "no project read" is a witness rather than a claim.

opentitan, read-only. Both confirmations hold, through a scratch driver over tools/perf/lspclient.py (stdio, workspace scope, cache in the scratchpad; didOpen + references only, no edit request sent):

row before after
entropy_masking_req from aes.sv:89 aes.sv [89 137 140 203] + aes_bind.sv [45 54]
state_q from entropy_src_main_sm.sv:42 …sm.sv [42 46 49 60] + entropy_src_core.sv [3092]
state_q from the tail, declaring file closed core [3092], sm [42] core [3092], sm [42 46 49 60]
references on aes (control) 9 files, 14 locations identical
references on .clk_i (control) 9 files, 12 locations identical

Costs: 0.2 → 0.1–0.4 ms (row 1), 0.2 → 0.4–0.7 ms (row 2), 0.1–0.2 → 0.9–1.5 ms (row 3, the parse), controls within noise. git -C <opentitan> status --short lists the same three files, with the same Aug 29/30 mtimes, before and after every run — a pre-existing dirty state in the owner's checkout, not this lane's (reported, not touched).

Deviations from the brief. Two, both recorded above: the sweep's "today's answers" were captured as the four recorded failures of the post-fix assertions on the unmodified binary rather than as a committed intermediate set of stale assertions — the same evidence, in the same order, without a second edit of every test; and case (f) is pinned as "unrepresentable, here is why" rather than as an ambiguity fallback.

Not done, deliberately. verify.rs, the formatter and the corpus / opentitan byte-identity gates are untouched by this change and were not re-run: no normalization was added or broadened and no formatting code was edited, so nothing is owed there. docs/perf/README.md and docs/topo.md are §64.2's closing items and belong to the lead, not to this lane's file list; the numbers they need are in the table above.

Gates, all through tools/guard.sh, no kill:

tools/guard.sh -m 8  -t 900  -- cargo fmt --all -- --check     # clean
tools/guard.sh -m 10 -t 1200 -- cargo clippy --all-targets     # clean
tools/guard.sh -m 10 -t 1800 -- cargo test --workspace         # 4435 passed, 0 failed

Test counts: workspace 4422 → 4435 (+13); lucisv_server 1772 → 1785 (+11 in nav.rs, +1 in hover.rs, +1 in tests/e2e.rs); vlog_semantic 377 → 377 (comment only). nav.rs production lines 354 → 383, so the closed-file repair stayed in nav.rs rather than earning a module.

2026-09-12 — dev (rework: QA findings 1–3, the stale-closed-file hazard)

The lead ruled all three fixed in this lane. Three production changes in crates/lucisv_server/src/nav.rs and one visibility change in hover.rs; nothing else moved.

1. One text per closed file per request, and it is the fresh one (finding 1 — this lane's own defect). declaring_file_uses read the declaring file through ws.file_view, a cache, and threw the text away; locations then read the same path again through ws.text_of, which never caches, and rendered the first read's spans against the second read's bytes. An external edit to a closed file is none of the five events that drop a view, so the two reads disagreed and a stale offset landed on a wrong line — QA's leaf.sv "own use" at line 3 (// two). declaring_file_uses now reads once with text_of and returns a DeclaringFile { text, declaration, uses }; indexed_references hands that text to locations in a ClosedText, and closed_locations uses it instead of fetching the path again. Why not file_view: it is exactly right for hover, which reads a closed file once per generation of it and renders nothing but a snippet from that read, and exactly wrong as the input to a span that a different step of the same request turns into a line and column. The doc comment on declaring_file_uses says so, in those terms.

2. The declaration of a re-analysed closed file is its live span (finding 2). include_declaration fell straight from "is the file open?" to target.declaration_span, the index-time span. A file this request just re-analysed knows where the declaration is now, so DeclaringFile carries it and indexed_references prefers it; the index-time span is the last resort and the only declaration span the guard has to catch.

3. A closed file's index-time span is checked before it is rendered (findings 2–3). closed_locations emits a span only if it still spells target.name exactly in the text it is about to be rendered against — hover::spells_exactly, made pub(crate) and shared rather than copied, because the lesson inside it (a fixed-length span still spelling the old name as a prefix of a longer identifier passes a length-and-content check) is the thing a second copy would get wrong. A stale record can now only ever omit a location, never point at a wrong line. Open-buffer spans are not guarded at all: they came from the very text they are rendered against, so they would pay for nothing. Cost: one slice compare plus two character tests per closed-file location.

What the three QA tests assert now, each worked out from LEAF_MOVED, which is LEAF with three comment lines pushed in below the header — so line 0 is the module header, 4 is logic sig; and 5 is assign sig = clk_i;:

test (renamed) was is why
qa_finding_1_a_disk_edited_closed_declaring_file_reports_its_live_spans [1, 3] [4, 5] both spans come from the re-analysis of the fresh text
qa_finding_2_one_fresh_request_reports_the_live_declaration_line [1, 5] [4, 5] the declaration is the re-analysed span, not the index-time one
qa_finding_3_a_stale_index_span_in_a_closed_file_is_dropped_not_misreported [0, 3] [0] a port: no re-analysis runs, so both spans are index-time claims. The header at line 0 is untouched by the edit and still spells clk_i, so it is reported; the posted use's span now points into // two, so it is dropped. Inventing 5 was never an option — nothing re-analysed that file, so the request does not know 5, only that what it held is no longer true.

qa_finding_3 also gained a pre-edit sanity assertion ([0, 2]), so the test proves the guard drops a span that was being reported rather than one that never was.

One new attack on the guard itself, qa_a_stale_span_that_now_spells_a_longer_name_is_dropped: leafp declares one port and uses it nowhere, so the only closed-file span in the answer is the index-time declaration span; the disk edit renames clk_i to clk_i2 and changes nothing before it, leaving that span's bytes still reading exactly clk_i. A length-and-content check would emit it. The answer is the connection in the open buffer and nothing else.

Function sizes after the split (locations' closed branch moved into closed_locations, a pure extraction): locations 35 lines, closed_locations 22, declaring_file_uses 29 — all inside 10–50. nav.rs production lines 383 → 422 by this lane's counting method (QA's method reads one line higher throughout, as their log notes), still well under 600.

The regression the guard could have caused, and did not. Every pre-existing cross-file test passes unchanged, including the ones whose closed-file spans sit inside a qualified or hierarchical name — p::WIDTH in a closed b.sv, u_mid.u_leaf.sig in a closed top.sv, the bind fixture's connection expression. spells_exactly sees ., ( and : around those spans, none of which continues an identifier. The five opentitan rows are byte-identical to the pre-rework run, so the guard drops nothing on a real, in-sync workspace.

Accepted as-is per the ruling: QA's +25 % (1.22 → 1.54 ms median) on a references request for a purely local net in a 40 000-line file. The lead notes it in docs/perf/README.md at closing; no change made here.

Gates, all through tools/guard.sh, no kill:

tools/guard.sh -m 8  -t 900  -- cargo fmt --all -- --check     # clean
tools/guard.sh -m 10 -t 1200 -- cargo clippy --all-targets     # clean
tools/guard.sh -m 10 -t 1800 -- cargo test --workspace         # 4446 passed, 0 failed

Test counts: workspace 4445 (QA's post-attack count) → 4446 (+1, the guard attack); lucisv_server 1795 → 1796; nav.rs's mod tests 60 → 61 of the 64 non-ignored tests it runs. No test was deleted or weakened: the three qa_finding_* tests kept their fixtures and their disk edits and had their expected sets flipped, with the derivation of each set written into the test. fmt wanted one cargo fmt --all pass twice during the rework (a found.extend line, then the extraction), after which --check is clean.

2026-09-12 — dev (rework 2: QA finding 4, the open-buffer declaration fallback)

The lead confirmed the finding and asked for the minimal fix. One production change in crates/lucisv_server/src/nav.rs; nothing else moved.

The gap. indexed_references' include_declaration chain was: the open buffer's live symbol, else the re-analysed closed file's live declaration, else target.declaration_span — an index-time span. The closed path guards that last span in closed_locations. The open path never could: locations renders an open document's spans unguarded, correctly, because every span it normally sees came from that very buffer. The one that did not is this fallback, reached exactly when the live lookup fails — the user renamed the declaration in the buffer without saving, so the buffer no longer declares target.name while a cross-file use still names the persisted Def. QA's reproduction: a stale 3-byte sig rendered on the first three characters of the live sig2.

The fix. The block is lifted into declaration_site(ws, target, declaring) -> Option<TextRange> — a pure move of the three-way chain plus one guard. For an open buffer: the live symbol's span, else the index-time span only if hover::spells_exactly(&doc.text, span, &target.name) holds against the live text, else None and the declaration is omitted — the same rule and the same function the closed path applies, so QA's prefix/suffix lesson is not re-learned. For a closed file the chain is unchanged (re-analysed live span, else the index-time span) and the span still meets its one guard in closed_locations; declaration_site does not check it, so no closed span is guarded twice. locations is untouched.

Why omit rather than search. The buffer does not declare the name; there is nothing correct to point at. An honest omission is the guarantee the rest of this feature gives a stale record, now without an exception for the open case.

Tests. QA's qa_recheck_a_renamed_open_buffer_and_the_unguarded_declaration_fallback is flipped and renamed qa_recheck_a_renamed_open_buffers_stale_declaration_is_omitted_not_misreported: same fixture, same unsaved rename of sig to sig2 in the open leaf.sv, asked from single.sv's tail. It now asserts a pre-rename sanity answer (every_place_naming_sig) and, after the rename, [single.sv 3, top.sv 3] — leaf.sv absent, the two tails unchanged (the top.sv one is a closed-file posting that still spells sig and passes its own guard). The control, an_open_buffer_edited_above_its_declaration_reports_the_live_declaration_line: the open leaf.sv gets two comment lines pushed in above the header, unsaved, so the declaration only moved and still spells sig. The live-symbol path answers first, so leaf.sv reports (3, 8..11) and (4, 9..12), the whole answer is [leaf.sv 3, leaf.sv 4, single.sv 3, top.sv 3], and line 3 goes away with includeDeclaration: false — so it is the declaration and it came from the live path (the index-time offsets land inside the header line, which spells no sig; had the guard been consulted the line would be missing, not moved).

Sizes. indexed_references 86 → 71 lines (comments included); declaration_site 19. nav.rs production lines 423 → 433 (this lane's counting method), under 600.

Gates, all through tools/guard.sh, no kill — verbatim tails:

$ tools/guard.sh -m 8  -t 900  -- cargo fmt --all -- --check
(no output; exit 0)

$ tools/guard.sh -m 10 -t 1200 -- cargo clippy --all-targets
    Checking lucisv_server v0.54.0 (/Users/guoliangchen/repo/verilogrustformatter-d8afe80f/crates/lucisv_server)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.33s
(0 warnings)

$ tools/guard.sh -m 10 -t 1800 -- cargo test --workspace
   Doc-tests vlog_semantic
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
(exit 0; 60 `test result: ok` lines, summed: 4454 passed, 0 failed)

Test counts: workspace 4453 (QA's re-check count) → 4454 (+1, the control); nav.rs's mod tests 72 non-ignored (71 + 1; the flipped test kept its slot). No test deleted or weakened.

QA log

2026-09-12 — QA (task-d8afe80f)

Gates, re-run from a clean checkout of the lane, all through tools/guard.sh, no kill:

tools/guard.sh -m 8  -t 900  -- cargo fmt --all -- --check     # clean
tools/guard.sh -m 10 -t 1200 -- cargo clippy --all-targets     # clean
tools/guard.sh -m 10 -t 1800 -- cargo test --workspace         # 4435 passed, 0 failed

Sum of every crate's "passed" count verified by script, matches the dev's report exactly (4435). After adding the ten attack tests below (all in nav.rs's mod tests), re-ran fmt/clippy/test again: fmt needed one cargo fmt --all pass on the new tests (two for-loop line breaks), then clean; clippy clean; cargo test --workspace 4445 passed (4435 + 10), 0 failed.

Pins re-derived by hand. Walked every new/flipped assertion in nav.rs against its fixture text: every_place_naming_sig() (leaf.sv 1/2, single.sv 3, top.sv 3), the port/parameter test, the bind fixture's everywhere set (aes.sv 1/2, aes_bind.sv 2), the class-member test, the shadowed-net test, the redeclared-name test and the two-modules test — all correct against the literal fixture strings, both includeDeclaration values. No wrong-but-passing assertion found.

Size. nav.rs production lines (non-blank, non-comment, before mod tests): 384 (dev reported 383; the one-line difference is a counting-method artifact, not a discrepancy in the actual diff — confirmed byte-identical against 9d1eb16 up to the mod tests line). Well under 600.

Attack tests added (10, all passing, in nav.rs's mod tests, prefixed qa_):

  1. qa_a_generate_for_arrays_scoped_net_still_never_asks_the_workspace — an indexed generate array (for (genvar i...) begin : gen, u_g.gen[0].gsig), sharper than the dev's named-block case. Confirms the gate still declines and the single-file fallback still holds.
  2. qa_an_interface_signal_through_a_virtual_interface_handle_is_unchanged — vif.data from a class in another file. Confirmed unchanged (the dev's Assumptions bullet, verified rather than trusted).
  3. qa_document_highlight_over_the_bind_fixture_stays_same_file_only — the bind fixture specifically (the dev's own documentHighlight pin used the plain-tail fixture, not bind). Confirmed same-file-only from both the declaration and the bind file's connection.
  4. qa_reopening_the_declaring_file_with_an_unsaved_edit_gives_live_spans — closed → answered by the repair → opened with an unsaved edit above the declaration. Confirmed the live, shifted spans are reported (3, 4), not the closed-file repair's stale ones.
  5. qa_references_agrees_with_the_rename_oracle_over_a_plain_tail,
  6. qa_references_agrees_with_the_rename_oracle_over_the_bind_fixture,
  7. qa_an_instance_names_references_agree_with_the_rename_oracle — all three assert references(...) (sorted) equals vlog_refactor::find_references (sorted) over the same files. All pass: no disagreement found between references and the whole-scope rename oracle for the tail, the bind fixture, or the instance name itself (the instance segment of a hierarchical tail does count as a reference, and the answer is exactly what a rename would edit). 8–10. qa_finding_1/2/3 — see Findings below.

opentitan, read-only, independent of the dev's driver. Wrote a standalone script (tools/perf/lspclient.py's transport only, not bench.py/phases_*.py) driving a freshly-built release lucisv-server against the real checkout:

check result
entropy_masking_req from aes.sv, includeDeclaration: true 6 locations across ['aes.sv', 'aes_bind.sv'] — confirmed
state_q from entropy_src_main_sm.sv 5 locations across ['entropy_src_core.sv', 'entropy_src_main_sm.sv'] — confirmed

(Note: aes_bind.sv is at hw/ip/aes/dv/sva/aes_bind.sv, not hw/ip/aes/dv/aes_bind.sv as the briefs' shorthand path read; not a defect, just a path correction for the record.)

git -C /Users/guoliangchen/repo/opentitan status --short identical before and after every run (the same three pre-existing dirty files, untouched).

Census, over every .sv file in hw/ip/aes/rtl (40 files), every module-level logic/wire/reg declaration found by a QA-only regex (not a parser — see caveat): 948 declarations probed, 0 errors, 15 answered with more than one file, 933 stayed single-file. Spot-checked (by reading the source, not trusting the tool) four of the 15:

  • aes.sv's edn_data → aes_bind.sv line 35/57 (.entropy_i(edn_data)) — genuine, a bind connection expression. Confirmed correct.
  • aes_core.sv's key_touch_forces_reseed → aes_bind.sv line 40 (.key_touch_forces_reseed(u_aes_core.key_touch_forces_reseed)) — genuine, a hierarchical tail through the bind target's own instance. Confirmed correct.
  • aes_pkg.sv's alert_fatal_fault and input_ready/output_valid — not module-hierarchical hits at all: they are struct packed fields inside aes_pkg.sv (confirmed by reading the file, e.g. line 158–160), which were already on the connection surface before this lane (a package's members are one surface). My regex census cannot distinguish a module net from a struct field inside a package, so it over-counts; the genuinely new hierarchical-surface hits in this 948-declaration sample are the two above (and plausibly a handful more among the 15 I did not individually read) — the census's absolute "15" should not be read as "15 newly reachable module nets". Recorded as a methodology caveat, not a finding against the fix: both spot-checked module-net hits are correct, and 0 of 948 probes errored or produced an implausible file list.

Cost, independently measured (not the dev's numbers, a fresh measurement): references on reg_we — a purely local net used 576 times in pinmux_reg_top.sv (40 267 lines), never referenced from another file — with that file the only open buffer, 7 tries each, before this lane (9d1eb16, built fresh in a throwaway worktree, removed after) and after (this lane, freshly rebuilt release binary):

result count times (ms) min median
before 573 5.184, 1.349, 1.218, 1.163, 1.385, 1.163, 1.135 1.135 1.218
after 573 1.973, 1.613, 1.541, 1.449, 1.733, 1.449, 1.421 1.421 1.541

Result counts identical (correctness unaffected). Timing: a small, consistent increase (every "after" sample, first-run JIT/cache outlier excepted, sits above every "before" sample except its own outlier) — roughly +0.3 ms, about +25% relative, though both stay well under 2 ms absolute. This is the specific case the gate's cost argument is about (a name that never leaves its file now takes the indexed path anyway), and it is real, not noise, though small in absolute terms. Flagged for the closing review to note in docs/perf/README.md rather than as a blocking defect — the dev's own two opentitan rows (connection-surface controls) were correctly reported "within noise"; this specific local-net-in-a-huge-file shape was not previously measured and is not quite noise-level.

Findings.

  1. declaring_file_uses can render a wrong location, not just an omission, if Workspace::file_view's cache goes stale against an external disk edit to the closed declaring file. crates/lucisv_server/src/nav.rs::declaring_file_uses (~line 391) reads the declaring file's text through ws.file_view, a cache dropped only by set_document/close_document/update_one/ rebuild_index_with/begin_widen (state/mod.rs::file_view's own comment names these as the only four). An edit to a closed file made outside the editor (another tool, git checkout, a build step) is none of them. Reproduced: qa_finding_1_a_primed_file_view_cache_mislocates_after_a_disk_edit (nav.rs) — prime the cache with one references call, edit leaf.sv on disk (three lines pushed above the declaration, name/kind/owner unchanged), ask again: the answer reports leaf.sv's "own use" at line 3 (// two) instead of the correct 5, because declaring_file_uses recomputes the span against the stale cached text while locations() (same file, ~line 425) renders every span through Workspace::text_of, which re-reads the file fresh with no cache of its own — pairing a stale offset with new bytes exactly as the charter asked to check for. Expected: the live spans, or an honest omission (the same guarantee hover.rs::spells_exactly gives a stale view — "can only ever omit a snippet, never show a wrong line"); actual: a silent wrong line.
  2. The same closed-file mislocation happens with no cache priming at all, from the shared include_declaration fallback — not declaring_file_uses's own code. Reproduced: qa_finding_2_the_declaration_span_fallback_mislocates_with_no_priming_at_all. One fresh references call after the same disk edit: the declaration line is wrong (1, // one, instead of 4) while declaring_file_uses's own "own use" contribution is correct (5, freshly reparsed, nothing had cached leaf.sv yet). The wrong half comes from indexed_references's include_declaration tail (~line 342 in the pre-QA file, .unwrap_or(target.declaration_span)): for a closed file, target.declaration_span is a span fixed at the last index rebuild, and it is rendered the same way — through locations()'s text_of, a fresh read, with no check that the two agree.
  3. The hazard predates this lane and is general, not specific to a hierarchical-only net — filed for the closing record, not as a defect introduced here. Reproduced: qa_finding_3_the_same_hazard_predates_this_lane_for_a_port. Same disk edit, asked from a port connection (single.sv's .clk_i(1'b0), reachable before §64.1 too): the port's own in-file use in the closed file is also misrendered (3, wrong, instead of 5); its declaration survives at 0 only by coincidence (the module header line is unmoved by the edit). This confirms the mechanism is a pre-existing, general property of nav.rs's closed-file handling (a persisted or cached span rendered through a second, independent, always-fresh text read, with no spells_exactly-style agreement check) — §64.1 does not introduce it, it only widens who can reach it: every internal net in the workspace, where before only a port or a parameter could.

None of the three findings are verify.rs/formatter-facing (the hard invariants are unaffected — this is lucisv-server, not the formatter), and none are regressions the dev introduced in the sense of "worked before, broken now": finding 3 proves the underlying bug already existed. But finding 1 is materially new exposure (the closed-file repair's own cache read is a second, distinct way to hit the same class of bug, on top of the pre-existing one), and the widening in general (§64.1's whole point) makes findings 2 and 3's pre-existing hazard reachable for a vastly larger set of names than before. Recommend: either a spells_exactly-equivalent guard before nav.rs's locations() accepts a closed-file span (verify the span still spells the target name in the text it's about to be rendered against, drop silently if not — the same principle hover.rs already enforces), or documenting the gap explicitly in references-nav's README next to the "same staleness window every other cross-file answer already has" sentence, since right now that sentence undersells what "stale" can do here (a wrong line, not just a late one).

Verdict: rework needed — not because the widening's core logic is wrong (the pins, the fixture sweep, the oracle equivalence checks, and the opentitan confirmations all check out), but because of Finding 1 (this lane's own new code path can mislocate) and the closing review's need to decide how findings 2–3 (pre-existing, general) get tracked. Findings 2–3 could reasonably be filed as a separate backlog item instead of blocking this lane, at the lead's discretion, since they are not new; Finding 1 is this lane's own new surface and should be addressed or explicitly accepted with a documented reason before release.

2026-09-12 — QA re-check (task-d8afe80f, same worktree)

The lead ruled all three prior findings fixed; the dev's rework (work log above, same date) is in the tree: declaring_file_uses returns DeclaringFile { text, declaration, uses } from one text_of read; indexed_references hands that text to locations as ClosedText; closed_locations (a pure extraction from locations) guards every closed-file span with hover::spells_exactly, now pub(crate); the three qa_finding_* tests are renamed and flipped.

1. Findings 1–3 re-derived by hand from LEAF_MOVED (module header, three comment lines, then logic sig; at line 4, assign sig = clk_i; at line 5):

  • Finding 1 (qa_finding_1_a_disk_edited_closed_declaring_file_reports_its_live_spans): primed cache, disk edit, re-ask → [4, 5]. Confirmed: both spans now come from one fresh text_of re-analysis, not a second, independent read.
  • Finding 2 (qa_finding_2_one_fresh_request_reports_the_live_declaration_line): no priming at all → [4, 5]. Confirmed: the declaration is the re-analysed live span (DeclaringFile.declaration), not target.declaration_span.
  • Finding 3 (qa_finding_3_a_stale_index_span_in_a_closed_file_is_dropped_not_misreported, a port, no re-analysis runs at all): sanity [0, 2] before the edit, [0] after — the unmoved header still spells clk_i and is reported; the moved use's stale span no longer spells clk_i (it now sits in // two) and is dropped, not misreported and not invented at 5. Confirmed: this is an honest omission, exactly the guarantee hover.rs already gives a stale snippet.
  • The new guard attack, qa_a_stale_span_that_now_spells_a_longer_name_is_dropped (clk_i → clk_i2 in place, nothing before it moved — the prefix-match shape spells_exactly's own boundary check exists for): confirmed refused; only the live connection is reported.

All four ran against a real disk edit in every case (fs::write to the fixture's actual path) — none were weakened into an in-memory-only check. Re-ran cargo test -p lucisv_server --bin lucisv-server nav::tests::qa_finding and the guard-attack test directly: 4/4 pass.

2. New attacks against the guard and the one-read invariant (all added to nav.rs's mod tests, prefixed qa_recheck_, all run and green):

  • qa_recheck_a_disk_edit_that_moves_only_the_use_is_still_fully_reanalysed — only the use shifts, declaration line untouched. Since the target is hierarchical-only, declaring_file_uses re-analyses the whole file regardless of what moved: [1, 4], both live and correct.
  • qa_recheck_a_deleted_closed_declaring_file_is_an_honest_omission_not_a_panic — leaf.sv deleted after the index was built, no rescan. No panic. leaf.sv vanishes from the answer entirely (text_of fails in both declaring_file_uses and closed_locations, both handled with ?/Option, never a crash); single.sv — untouched, still readable — keeps answering normally, so only the one unreadable file is omitted, not the whole request. (My first draft of this test asserted the wrong expected set — top.sv only — before checking single.sv's own posted tail was still live and correct; fixed once I read the actual output.)
  • qa_recheck_a_stale_span_off_a_utf8_boundary_does_not_panic — a stale index-time port-use span (clk_i's own use in LEAF) engineered, via a disk edit, to land on the second byte of a 4-byte emoji in the new text — never a char boundary. No panic: spells_exactly/span_text go through str::get, which answers None off a boundary rather than panicking (Rust's own guarantee, not new code to trust) — the file is correctly dropped wholesale.
  • qa_recheck_two_closed_files_in_one_answer_are_independent — leaf.sv (re-analysed) and single.sv (a posted External site, never re-analysed) both closed, asked from a third open file (top.sv). Edited only single.sv's own tail line on disk: leaf.sv's answer ([1, 2]) is completely unaffected, and single.sv's own moved tail is dropped by the same guard a port's stale use would be — confirmed each closed file is rendered against its own, independently-read text, and an edit to one cannot leak into the other's answer.
  • qa_recheck_an_escaped_port_name_survives_the_guard and qa_recheck_an_escaped_net_survives_the_closed_file_reanalysis (added for the coordinator's specific follow-up on escaped identifiers): \my-clk as a port (closed sub.sv, connection from open top.sv) and \my-sig as a hierarchical-only net (closed eleaf.sv, tail u_leaf.\my-sig from open etop.sv, plus eleaf.sv's own assign \my-sig = …;). Both pass, unchanged. The lexer's contract (docs/features/escaped-identifiers/README.md: the token text is the \ through the last non-whitespace byte, matching src[span] exactly) means Symbol::name/name_span already carry the backslash consistently, so spells_exactly's span_text(text, span) == Some(name) compares backslash-inclusive strings correctly, and its boundary check (continues_a_name) is right to ignore the escaped name's terminating whitespace (not alnum/_/$) either side. No regression found here.
  • qa_recheck_a_renamed_open_buffer_and_the_unguarded_declaration_fallback — the direction not yet attacked: an open buffer, not a closed one.

3. One closed file, one read, per request — verified by code inspection, corroborated empirically. ws.text_of is called at exactly two static sites in this path: once in declaring_file_uses (only for a hierarchical-only target whose declaring file has no open buffer), and once in closed_locations, guarded by if held.is_none() — and held is Some exactly when the path equals the declaring path and declaring_file_uses ran, so the declaring file's second read is skipped by construction. locations groups found by path (sorted first, then partitioned) before calling closed_locations once per group, so a given path is never split across two calls and never read twice. No production change was needed to verify this — a read counter would have needed one (text_of is a plain fs::read_to_string, uninstrumented) — but qa_recheck_two_closed_files_in_one_answer_are_independent is the empirical corroboration: if either file's read leaked into or reused the other's, editing only single.sv could not have left leaf.sv's answer byte-identical while independently affecting single.sv's own.

4. FINDING 4 (new). An open buffer's include_declaration fallback can emit a stale index-time span with no guard at all — the same "wrong location, not omission" failure mode the rework just fixed for closed files, reopened for open ones. crates/lucisv_server/src/nav.rs, the include_declaration block in indexed_references (~line 339): the chain tries the live buffer's own symbol lookup, then declaring.declaration (only set when declaring_file_uses ran, which it does not for an open file — see its own early return), then falls to target.declaration_span — an index-time span. When this fallback fires for a file that is open, found.push((target.declaration_path, span)) puts that stale span under a path locations (~line 496) will render through the open branch (if let Some(doc) = ws.document_for_path(path) { … }), which never calls closed_locations and so never runs spells_exactly — no guard exists on this branch at all, for any span.

Reproduced: qa_recheck_a_renamed_open_buffer_and_the_unguarded_declaration_fallback. leaf.sv is open with sig renamed to sig2 (unsaved); the request comes from single.sv's tail, which still names the original Def by the persisted index. The live lookup and declaring_file_uses both correctly find nothing (no symbol named sig remains in the live buffer). The fallback reaches target.declaration_span — the original 3-byte span for sig — and it is rendered against leaf.sv's live line index unguarded: the answer includes leaf.sv:1:8-11, which is logic sig2;'s columns 8..11 — a strict prefix of the live token sig2 (columns 8..12), not a complete identifier at all. This is exactly the "prefix of a longer identifier" shape spells_exactly exists to refuse (qa_a_stale_span_that_now_spells_a_longer_name_is_dropped proves it does, for a closed file); for an open one, nothing is asked at all.

Likely lower real-world frequency than findings 1–3 (it needs an unsaved edit that removes the particular symbol the request's Def still points at, in a buffer some other open or closed file's cross-file reference still resolves to), but the failure shape is identical and arguably worse for user trust: a "go to references" that lands on sig2's first three characters looks like a real, if odd, location rather than an obvious non-answer. Suggest either running the same spells_exactly check on the include_declaration fallback's span unconditionally (open or closed — the guard is one slice compare plus two character tests, cheap enough to never special-case), or restricting the fallback to only ever apply when the file is closed (an open file with no live match should report nothing for that file instead of trusting target.declaration_span).

Gates, all through tools/guard.sh, no kill:

tools/guard.sh -m 8  -t 900  -- cargo fmt --all -- --check     # clean
tools/guard.sh -m 10 -t 1200 -- cargo clippy --all-targets     # clean
tools/guard.sh -m 10 -t 1800 -- cargo test --workspace         # 4453 passed, 0 failed

Test counts: dev's rework count (4446) → 4453 (+7, the re-check attacks: 5 new scenarios plus the 2 escaped-identifier tests). nav.rs production lines: 423 (dev's own count after the rework was 422; same one-line counting-method difference noted in the first QA pass, not a real discrepancy). Well under 600.

opentitan, read-only, re-confirmed against a freshly rebuilt release binary (the rework included): entropy_masking_req from aes.sv still lists aes_bind.sv (6 locations); state_q from entropy_src_main_sm.sv still lists entropy_src_core.sv (5 locations); the hw/ip/aes/rtl census (948 declarations, 40 files) is byte-identical to the pre-rework run (15 cross-file, 933 single-file, 0 errors). git -C /Users/guoliangchen/repo/opentitan status --short identical before and after (the same three pre-existing dirty files).

Verdict: rework needed, again — one new finding, findings 1–3 confirmed fixed. The rework correctly closes findings 1–3: re-derived by hand, attacked further (a use-only shift, a deleted file, a UTF-8 boundary, two independent closed files, both escaped-identifier shapes) and every one of those held. But the same underlying class of bug — a stale span rendered against text it was never checked against — has one more instance the rework did not cover: the open-buffer path's include_declaration fallback (Finding 4, above). Recommend fixing Finding 4 the same way findings 2–3 were fixed (apply spells_exactly, or drop the fallback to target.declaration_span entirely for an open file) before this ships.

2026-09-12 — QA, final (escalated, task-d8afe80f, same worktree)

Charter: verify the dev's rework 2 (finding 4) end to end, do not redesign. No production code touched; five qa_final_* tests added to nav.rs's mod tests, nothing else in the tree changed by this pass.

1. The flipped finding-4 test, re-derived by hand. Fixture hierarchical(.., &["single.sv", "leaf.sv"]), asked from single.sv's u_leaf.sig tail. Workspace::set_document re-analyses the buffer against the unchanged index (Document::new(path, text, &self.index)) and never touches the index, so the setup is a real unsaved rename: the persisted Def for (leaf, sig) survives and single.sv's external target still resolves to it. Walk: leaves_this_file → the tail's best(); indexed_target → Definition::External([def]), declaration_span = the index-time line 1 cols 8..11 (bytes 64..67); references_to posts top.sv's closed tail; the open loop finds single.sv's tail and nothing named sig in the renamed leaf.sv; declaring_file_uses declines (open); declaration_site: symbols_named("sig") empty → fallback, spells_exactly on bytes 64..67 of logic sig2; = sig followed by 2 (a name character) → false → None. Rendered: [single.sv 3, top.sv 3]. That is the honest omission: the declaration dropped, both tails unchanged (top.sv's through its own closed guard). leaf.sv 2 is also absent, and correctly so — the live buffer's own use spells sig2, so it is the overlay's answer, not the guard's. The sanity assertion (every_place_naming_sig before the rename) pins that the same request was complete when the buffer matched the disk.

The control (an_open_buffer_edited_above_its_declaration_reports_the_live_declaration_line) does discriminate: the index-time bytes 64..67 fall inside the header line of the shifted text (...input logic clk_i); cols 46..49 = c c), which spells no sig — so had the fallback been consulted the guard would have dropped line 3, and had it been consulted unguarded line 2 would have appeared; the asserted (3, 8..11) can only come from the live-symbol path. Confirmed.

2. The ladder, rung by rung. Existing tests cover (a) the control, (c)-prefix the flipped finding-4 test, (e) qa_finding_1/2, (f) qa_finding_3 and qa_a_stale_span_that_now_spells_a_longer_name_is_dropped. Added, all derived by hand first and green on the first run:

  • qa_final_b_a_failed_live_lookup_with_the_name_still_in_place_emits_the_index_span — rung (b). logic sig; → wire sig; (same length; Var → Net, bind/decl.rs:179), so the live lookup fails on indexed_def_in_file's kind filter while bytes 64..67 still read exactly sig. Emitted at (1, 8..11); the answer is [leaf.sv 1, single.sv 3, top.sv 3] (the buffer's own use resolves to the rejected live symbol and is consistently not listed); includeDeclaration: false → [single.sv 3, top.sv 3]. The missing leaf.sv 2 is what proves the fallback, not the live path, produced line 1.
  • qa_final_c_an_index_span_now_a_suffix_of_a_longer_live_name_is_dropped — rung (c), suffix half: wire _sig; puts _ at byte 63. Dropped; leaf.sv absent.
  • qa_final_d_an_open_buffers_span_off_a_utf8_boundary_is_dropped_without_a_panic — rung (d): line 1 becomes // 🙂🙂 so byte 64 is the last byte of the first emoji (!is_char_boundary(64) asserted), declaration renamed away below. No panic (str::get), leaf.sv absent.
  • qa_final_g_include_declaration_false_emits_no_declaration_on_the_closed_rungs — rung (g) over (e) and (f), before and after the LEAF_MOVED disk edit: sig → [2] / [4, 5] with, [5] without; clk_i → [2] / [0] with, [] without. The open rungs are pinned by the control and rung (b).
  • Rung (e) "guarded once, not twice": by inspection, declaration_site's closed branch (nav.rs:388) returns declaring.declaration or the index-time span with no check, and the single check is closed_locations (nav.rs:581–584); locations is unchanged by the rework. Empirically qa_finding_2 shows a re-analysed live declaration emitted where the index-time span would have failed the guard.

Observation (not a finding — pinned as qa_final_observation_a_different_exact_sig_at_the_old_bytes_is_reported for the lead to rule on). The fallback is a textual claim, on an open buffer exactly as on a closed file: with the declaration deleted and an unrelated whole token sig (buf b(sig, clk_i);, an undeclared gate output) now sitting at bytes 64..67, references reports (1, 8..11) as the declaration. spells_exactly is right to accept an exact token; whether it is the declaration is a question the guard was never designed to answer, and it is the same limit the closed path has had since rework 1. Accepting it as documented behaviour seems right; recording it so it is chosen, not overlooked.

3. nav.rs production read, whole file. 433 production lines (non-blank, non-comment, before mod tests at line 721; matches the dev's count). No unwrap/expect/panic!/unreachable! in production. Function sizes: indexed_references 71 (over 50, under 80 — the collection loop with its comment block; report, not a finding), definition 52 (pre-existing, untouched by this lane — no hunk in 19–70), every other function 3–35 (declaration_site 19, declaring_file_uses 29, locations 35, closed_locations 22). Doc comments say what/why throughout; declaration_site's names the finding it closes.

4. Gates, verbatim, all through tools/guard.sh, no kill:

$ tools/guard.sh -m 8  -t 900  -- cargo fmt --all -- --check
(exit 0 after one `cargo fmt --all` reflow of a single new-test assert_eq!)

$ tools/guard.sh -m 10 -t 1200 -- cargo clippy --all-targets
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 4.10s
(exit 0; 0 warnings)

$ tools/guard.sh -m 10 -t 1800 -- cargo test --workspace
   Doc-tests vlog_semantic
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
(exit 0; 60 `test result: ok` lines, summed: 4459 passed, 0 failed)

Test counts: 4454 (dev's rework-2 count) → 4459 (+5 qa_final_*); nav.rs's mod tests 80 #[test] items.

opentitan, read-only, a trimmed two-row driver over tools/perf/lspclient.py (didOpen + references only) against a release binary built from this tree (0-based lines):

row includeDeclaration answer
entropy_masking_req from aes.sv true aes.sv [88 136 139 202], aes_bind.sv [44 53]
false aes.sv [136 139 202], aes_bind.sv [44 53]
state_q from entropy_src_main_sm.sv true entropy_src_core.sv [3091], entropy_src_main_sm.sv [41 45 48 59]
false entropy_src_core.sv [3091], entropy_src_main_sm.sv [45 48 59]

Identical to the dev's 1-based table; false drops exactly the declaration line. git -C /Users/guoliangchen/repo/opentitan status --short before and after: the same three pre-existing dirty files (hw/ip/aes/dv/tb/tb.sv, hw/top_darjeeling/ip/ast/rtl/ast.sv, hw/top_earlgrey/ip/ast/rtl/ast.sv), diff empty.

Verdict: pass. Finding 4 is closed by declaration_site; every rung of the declaration-site ladder behaves as specified and is pinned; no new finding. One observation for the lead above.

Review

Lead review, 2026-09-12 — accepted. The diagnosis is the right one and the fix is the smallest true one: both index questions in nav.rs now ask the surface a use can reach a declaration by, and because the hierarchical read returns the connection records first and whole, nothing the gate admitted before is judged differently — the harness controls and the opentitan census bear that out. The consequential gap the lead raised (no Local posting for a hierarchical-only member, so a closed declaring file's own uses were nobody's to supply) is served the way the rename already serves it, by one parse of exactly that file on exactly that request shape, and hierarchical_only asks the index's own table rather than restating surface_of in the protocol layer. Two QA rounds earned their keep: the first found that the closed-file path read a cached text and rendered against a fresh one — this lane's own defect — and a pre-existing class of unguarded index-time spans that §64.1 multiplied the reach of; the second, after the one-read-per-file rule and the spells_exactly guard, found the same class on the open-buffer declaration fallback. All four are closed by one principle the README now states: a stale index may omit a location, never point at a wrong one. Accepted as-is, with the reason written down: the +25 % on a local-net references in a 40 000-line buffer (1.22 → 1.54 ms; the gate still saves the walk for names the index holds nowhere), and QA's final observation that the guard is textual — a different exact sig token at the old bytes of a deleted declaration is reported as the declaration. That is the same limit hover-declarations has carried since 2026-08-27, it needs an external edit the client's file watcher would have announced, and the alternative (drop the index-time fallback for an open buffer altogether) would lose the one honest case QA also pinned, a declaration whose kind changed in place. spells_exactly made pub(crate) rather than copied is the right call. Handshake request recorded (a Def-keyed hierarchical_only on the index) and left for the next lane in index.rs. Ships in 0.55.0.