Files
lucisv/docs/features/references-nav/README.md
T
lucioandClaude Fable 5 cf32e92e58
ci / checks (push) Successful in 46s
ci / corpus (push) Successful in 21s
A rescan reuses what open buffers already analyzed
A scope-widening didOpen re-parsed every open buffer's text twice —
once for its index facts, once for its completion words — 210 ms of a
223 ms rescan for one 1.4 MB top.sv. FileFacts::of and words_in each
split so their post-parse half is callable on a finished analysis
(facts_from_analysis, words_of_tokens; one implementation per path, so
the routes cannot drift), and collect_sources hands the index and
candidates builds each open buffer's held analysis instead of its
text, on the whole-rebuild path and didSave's. ~228 ms -> ~23 ms.
Equivalence pinned: encoded facts and fingerprints byte-identical
between the two routes over the corpus and 16 crafted non-corpus
shapes; unsaved-edit, didClose-revert, size-cap and large-file
threshold boundaries tested both directions. IndexEvent::Analyzed
keeps "from cache" meaning the persistent store.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-28 15:28:27 -07:00

915 lines
54 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# references-nav
M7 of the refactoring plan (`docs/features/refactor/README.md`), the first
milestone taken from that plan's "LSP-parity and plumbing gaps" triage.
## Goal
Three navigation capabilities that were all wiring over machinery the tree
already had. **Cross-file find-all-references**: `textDocument/references`
answered in-file only, while M2's rename had been collecting cross-file
reference sets since it shipped — so lucisv could *change* references it could
not *list*. **Document highlight for symbols**: the cursor on a signal now
highlights its declaration and every use in the file, where before only a
`begin`/`end` pair answered and everything else fell through to the editor's
word matching. **Folding ranges**: `pairs.rs` already matches every
`begin`/`end`-family pair for the rainbow, and `textDocument/foldingRange` is
that same data on a standard capability. No new analysis was written for any
of the three; the whole milestone is one shared collection function, one
predicate, and three handlers.
## Assumptions
- **The workspace index is the authority on what can be named from another
file.** `nav::leaves_this_file` decides whether a references request walks
the workspace by asking `WorkspaceIndex::units` / `::member` about the name
under the cursor — not by re-deriving `is_unit`/`is_exported`, which are
private to `vlog_semantic` and would be language knowledge in the protocol
layer. Consequence: a declaration the index has not seen yet (a buffer
edited but not saved, when the file is new) is answered in-file until the
next rebuild. That is the same staleness window every other cross-file
answer already has, documented in `docs/features/lucisv-server/README.md`.
- **A references answer is an indexed lookup.** Each `FileFacts` record stores
compact facts for references to externally reachable declarations. The
finished `WorkspaceIndex` resolves those facts once into declaration-to-use
postings, and a request reads only that posting list. Open documents replace
their saved postings with live `Semantics`, preserving unsaved additions and
deletions. The old `Workspace::sources()` + refactor walk remains rename's
correctness engine but is no longer on the references request path.
- **A refusal degrades to the in-file answer, it is not an error.** The shared
engine refuses an ambiguous name (declared in two indexed files) exactly as
a rename does. `textDocument/references` is a read-only convenience, so the
handler sends the file's own occurrences rather than a `RequestFailed`: a
highlight the editor can draw beats a shrug, and the refusal the user
actually needs to see is the one on the rename they then attempt.
- **Reference spans are produced by the semantic analysis and versioned with
the file facts.** A cache entry is content-addressed, so a saved span cannot
be paired with different bytes; an open file contributes live spans instead.
Location conversion fetches and line-indexes each touched file once, however
many occurrences it contains.
- **Read/write is not distinguished** in `documentHighlight`. LSP permits a
plain `Text` kind, and telling a read from a write in Verilog means
classifying continuous vs. procedural assignment, port direction and
`inout` — an analysis worth building for a lint rule, not for a highlight
colour.
- **Folding is line-based.** No `startCharacter`/`endCharacter`: editors
default to whole-line folding, and a character-precise range for
`begin`/`end` would buy nothing a reader can see.
## Handshakes
**The original public API in `vlog_refactor`**, retained for rename and as the
equivalence oracle in tests:
```rust
pub fn find_references(
files: &[(PathBuf, String)],
file: &Path,
offset: u32,
include_declaration: bool,
) -> Result<Vec<(PathBuf, TextRange)>, String>
```
`files` is the same in-scope set `rename`/`prepare_rename` take (path and
current text, open buffers already overlaying disk). The result is sorted by
path then by position; an `Err` is the sentence a rename at that position
would refuse with.
**Where the original sharing lives.** The collection walk is
`Scope::collect_occurrences` in `crates/vlog_refactor/src/rename.rs` — lifted
out of `collect_edits`, which now calls it and turns the spans into edits.
`find_references` (`crates/vlog_refactor/src/references.rs`) calls the same
`Scope::build` → `locate` → `collect_occurrences` sequence and keeps the
spans. The alternative considered was lifting the walk into `vlog_semantic`;
it was rejected because the walk is not a semantic query — it needs the
`Scope` cache, the workspace overlay *per file*, and the ambiguity policy,
all of which are refactor-crate concerns, and `lucisv_server` already depends
on `vlog_refactor`. The indexed implementation is compared directly with this
walk in the server tests, so moving the hot path does not create a second
semantic answer.
**New public API in `vlog_semantic`:** `WorkspaceIndex::{file_id,
references_to, references_are_ambiguous}`, plus `DefinitionKey` and
`ReferenceSite`. `FileFacts`' encoded shape now includes local and unresolved
external reference facts, and `FACTS_FORMAT` is **2**. A changed file rebuilds
the merged postings from compact in-memory facts; it does not reread or parse
the other files. `Semantics::{symbol_at, reference_at, reference_id_at}` and
`Document::token_at` now use start-sorted position tables and binary search.
**Consumed from `vlog_semantic`:**
`Semantics::{reference_at, reference_id_at, references_of, symbol, symbol_at,
scope}`, `Scope::owner`, `Symbol::{name, scope, name_span}`,
`ExternalResolutions::get`, `ExternalTarget::best`,
`WorkspaceIndex::{units, member, file_id, references_to,
references_are_ambiguous}`.
**Consumed from `vlog_parser`**: `token::Comment { span }` trivia and
`LineIndex::line_col` for folding.
**Consumed from this crate's own `pairs.rs`**: `analyze(&[Token]) ->
ScopeAnalysis`, unchanged. `folding.rs` is its fourth consumer
(`documentHighlight`, the missing-closer warnings, `lucisv/scopePairs`, folding)
and reads only `pairs`, never `unmatched_open`/`unmatched_close`.
**Promised to the editors**: nothing new to configure. `foldingRange` is a
standard capability both VS Code's built-in client and Neovim's `vim.lsp`
consume on their own once it is advertised; no extension change was needed
and none was made.
**Requested of other modules (2026-08-28) — DELIVERED 2026-08-28** by the
index-scope round; see `docs/features/index-scope/README.md`, work log
"a rescan stops re-parsing what is already analyzed". An open buffer's index
facts and completion words now come from the analysis it already holds
(`FileFacts::from_analysis`, `words_of_tokens`), on the whole-rebuild path and
on `update_one`'s: **~228 ms → ~23 ms** on this feature's own probe. The request
as it was written:
**Requested of other modules (2026-08-28):** a scope-widening `didOpen`
re-parses every open buffer. `Workspace::collect_sources`
(`crates/lucisv_server/src/state.rs`) clones each open document's text into the
list the index is rebuilt from, so a rescan triggered by opening some *other*
file pays a full lex-and-parse of every buffer the user has open — measured at
**210 ms of a 223 ms rescan** for one 1.4 MB `top.sv`, against 13 ms for the
same 401-file scope with that buffer closed. Every open buffer already holds a
finished parse and `Semantics`; `FileFacts::of` re-does both from the text.
This is `index-scope` / `state.rs` territory, not this feature's, and the
2026-08-28 brief said measure it and stop — so it is written here rather than
changed. The obvious shape (an `IndexBuilder::add_facts` path fed from the
buffer's existing analysis instead of its text) is a real option and a separate
decision.
## Status / TODO
- [x] **References latency with a big buffer open (2026-08-28):** measure both
directions of a cross-file references request while a 1.4 MB, 40 000-line
`top.sv` is an open document, then fix what the numbers convict. Landed:
a **spelled-name prefilter** and a **hoisted `file_id`** in
`indexed_references`'s open-document overlay loop, and **walker-batched**
span conversion in the two in-file fallbacks. Release probes:
**3.20 ms → 110 µs** from the use site, **3.18 ms → 110 µs** from the
declaration (29×); the in-file fallback for a signal used 10 001 times,
**1.76 ms → 1.18 ms**, and `documentHighlight` on it **1.54 ms → 917 µs**.
No answer changes — the equivalence test against
`vlog_refactor::find_references` and the whole nav suite are untouched
and green.
- [x] **Not this feature's to fix, measured and filed (2026-08-28) — fixed
elsewhere the same day:** the owner-reported *asymmetry* is not in
`references` at all — both directions cost the same, before and after.
What is expensive is the `didOpen` that jumping into another folder's
file triggers: **220 ms**, of which **210 ms** is re-parsing the open big
buffer during the scope-widening rescan. See the work log and
Handshakes. Landed by `index-scope` on 2026-08-28 — the open buffer's
facts and words now come from its own finished analysis — and this
feature's `qa_didopen_latency_when_a_new_folder_widens_the_scope` probe
reads **~228 ms → ~23 ms**, with its closed-buffer floor unmoved at
~12 ms. The probe now also prints the buffer's own share of a rescan,
before and after, on every run.
- [x] **Indexed navigation performance (2026-08-27):** persist each file's
externally reachable reference facts beside its declarations, merge them
into declaration-to-occurrence postings in `WorkspaceIndex`, and route
hover/definition/references through indexed cursor and location lookups.
Preserve ambiguity refusals and unsaved open-buffer overlays; prove the
indexed answer equals the existing refactor walk before removing that
walk from the request path. Release probe: **0.064 ms/request** over 820
synthetic files and five returned locations, versus **23.431 ms** for
the old walk on the same workspace.
- [x] `Scope::collect_occurrences` factored out of `collect_edits`, with
`collect_edits` rewritten on top of it (no behaviour change; the rename
suite is the regression test).
- [x] `vlog_refactor::find_references`, new module `references.rs`, 7 tests.
- [x] `nav::references` routes through `WorkspaceIndex` postings when the
symbol can leave the file; the refactor walk remains its tested oracle.
- [x] `nav::leaves_this_file` — the index-only gate that keeps a local signal
off the workspace walk.
- [x] `nav::document_highlights` — symbol occurrences in this file.
- [x] `server.rs`: `documentHighlight` tries the scope pair first, the symbol
second, and still declines both with `null`.
- [x] `folding.rs` — one range per matched pair, plus multi-line block
comments, 15 tests.
- [x] `foldingRangeProvider` advertised in `main.rs`.
- [x] e2e: one session covering cross-file references (both
`includeDeclaration` values), `foldingRange` and `documentHighlight`.
- [x] `docs/features/lucisv-server/README.md`: capability table, the "not done"
list, and Handshakes updated.
- [ ] **Not done, deliberately:** line-comment run folding (`//` blocks). The
token stream carries each `//` comment separately, so folding a *run* of
them means deciding what counts as one run (blank lines? indentation
changes? a comment after code on its line?). That is a judgement call
with no obviously right answer, and the brief said skip it if it is not
trivial. Block comments, which have their own delimiters, are done.
- [ ] **Not done, deliberately:** a references answer for an ambiguous name.
It falls back to the file's own occurrences; returning both declarations'
reference sets, the way `definition` returns both locations, is a real
option and a separate decision.
- [ ] TODO.md and the `refactor` umbrella checklist were **not** touched, per
the milestone brief — the lead owns the two backlog checkboxes this
closes ("Cross-file find-all-references", "Folding ranges", "Document
highlight" in `docs/features/refactor/README.md`).
## Work log
### 2026-08-28 — references latency with a big buffer open
The owner reported find-references from a *use site* in a big open `top.sv`
toward a module as "still very slow", and the same request from the module's
*declaration* toward its uses as fast. Both run the same
`indexed_references`, so the asymmetry was unexplained. Measured first.
**The fixture.** Two `#[ignore]`d probes in `nav.rs`'s own test module, beside
the `qa_indexed_references_latency_over_a_large_workspace` probe that has been
there since 2026-08-27, and taken with `perf::mean` (now `pub(crate)`) so every
number in this repo is timed the same way. `generated_top(10_000, 4)` is a
40 000-line, 1 374 KB module of ordinary RTL blocks — a wire, an assign, a
register and its update — carrying **70 024 references**, four instantiations
of a small `sub`, and one local `acc` used by every block so the file also has
a *local* name with 10 001 occurrences. Both files are open documents; the
index is built over the directory.
```text
cargo test --release -p lucisv_server nav::tests::qa_ -- --ignored --nocapture --test-threads=1
```
Machine: the one `docs/perf/README.md` records — Apple M1 Max, macOS 27.0,
`--release`. Means of 20 runs (5 for the rescan rows).
| what | before | after |
|---|---|---|
| `references` from the **use site** in `top.sv`, `includeDeclaration` | **3.20 ms** | **110 µs** |
| `references` from the **declaration** in `sub.sv`, same | **3.18 ms** | **110 µs** |
| `definition` from the use site | 1.21 µs | 1.13 µs |
| `references` on a local wire used 3× (the in-file fallback) | 1.49 µs | 1.20 µs |
| `references` on a local wire used 10 001× | **1.76 ms** | **1.18 ms** |
| `documentHighlight` on that same wire | **1.54 ms** | **917 µs** |
**Hypothesis 1 is convicted, and it is symmetric.** The open-document overlay
loop was the whole 3.2 ms: for every one of the 70 024 references in the open
buffer it ran either `indexed_def_for_symbol` — a `file_id` binary search whose
comparisons are whole-path `cmp`s, plus a `units`/`member` `BTreeMap` lookup,
plus a scope-and-owner chase — or a `doc.external` hash lookup, to discard all
but five of them. It cost that whichever end the cursor was on, which is the
first thing the measurement says: **the two directions are within 1 % of each
other, before and after.** The owner's asymmetry is not in `references`.
**Hypothesis 2 registers, but only for a common local name.** The in-file
fallback and `documentHighlight` convert their spans one at a time with
`positions.range`, which re-measures a line per span. On three occurrences that
is 1.5 µs and invisible; on 10 001 it is 1.76 ms. Both now batch-convert with
`positions.walker()` over the already-sorted span list, exactly as `locations`
has done for the cross-file answer since this feature shipped — 1.5× and 1.7×.
The rest of those two figures is collecting, sorting and allocating 10 001
spans, which is the answer's own size and not something to shave here.
**Hypothesis 3 is where the felt latency actually is** — measured, and
deliberately not redesigned this round (see Handshakes). With the same 1.4 MB
buffer open and 401 files in scope:
| `didOpen` | cost |
|---|---|
| a file the folder scope **already covers** | **8.4 µs** |
| a file in a **new folder** (`didOpen` + the rescan `server.rs` then runs) | **220 ms** |
| — the rescan alone | 223 ms |
| — the same rescan with the big buffer **closed** | **13 ms** |
So the scope-widening rescan is 223 ms, and **210 ms of it is the open big
buffer**: `Workspace::collect_sources` clones every open document's text into
the source list and the index re-parses it, at full lex-and-parse cost, on a
rescan that was triggered by an entirely different file. That is the shape that
matches the owner's report: F12 or a references result *from* `top.sv` opens the
module's file, and when that file lives in a folder the folder scope had not
reached, the `didOpen` widens the scope and pays a whole rescan. The reverse
direction — standing on the declaration and listing its uses — opens nothing
new and pays nothing. Filed as a Handshake request against `index-scope` /
`state.rs`; no scope code was touched.
**The prefilter, and why it changes no answer.** The new first line of the
overlay loop is `if reference.name != target.name { continue }`. It is sound
because *a `Def` in this index determines the name it is filed under*, and both
sides of the old comparison are filed under a name the code already has in
hand:
- Every indexed `Def` is pushed into `units[name]` or `members[unit][name]`
under its own declaration's `name`, and both `facts_of` and `collect_members`
skip any declaration whose `name_span` is empty. A non-empty byte range in
one file is one identifier, spelling one name — so two different keys cannot
hold one `Def` value, and `target.def`'s key is `target.name` in both
`indexed_target` arms (the `Local` arm looks the def up *by* `symbol.name`
and stores that as `name`; the `External` arm stores the cursor reference's
own `name`, which is the only key `follow_one` looks a def up under).
- A reference that would have matched is filed under `reference.name`. In the
Local arm, a `Resolution::Resolved` comes from `lookup_local(name)` (or an
end label the binder checked spells the declaration's name), so
`symbol.name == reference.name`, and `indexed_def_in_file` looks up
`units[symbol.name]` / `members[owner][symbol.name]`. In the External arm,
`resolve_external` calls `follow_one(index, reference.name, path)`, which
only ever reads `units[reference.name]` or `member(unit, reference.name)`.
So `def == target.def` implies `reference.name == target.name`, and skipping
the name-mismatched references skips only work whose answer was `false`.
**The `Ambiguous` refusal survives it**, by the same step: the candidates in
`ExternalTarget::Ambiguous(defs)` all come out of the bucket keyed by
`reference.name`, so `defs.contains(&target.def)` can only be true for a
reference spelling `target.name` — which the prefilter always lets through. The
`name_span.is_empty()` guard was deliberately *not* hoisted into the prefilter
for the same reason: an ambiguous use aborts the whole collection whether or not
it has a span, and moving that check earlier would have been a real behaviour
change.
**The hoist.** `indexed_def_for_symbol` is now two functions: the public one
(unchanged signature, still `hover.rs`'s) resolves the document's `FileId` and
calls `indexed_def_in_file`, which takes it as an argument. The overlay loop
takes the `file_id` once per open buffer instead of once per reference.
**What is left at 110 µs** is the loop itself: 70 024 string comparisons plus
the iteration. Making that sublinear means a name-keyed reference side table in
`Semantics` — the shape `symbols_named` already has for declarations — which is
a `vlog_semantic` change this round's brief put out of scope. Not needed at
110 µs; worth naming as the next lever if a file ten times this size shows up.
**Tests added** (permanent, all three green before and after the change, which
is the point — the prefilter must change cost and not answers):
- `a_same_named_port_in_another_open_buffer_is_a_different_symbol` — two
modules declare a port `clk`, all three files open; each port's references
are its own. The prefilter's risk case, from both sides.
- `two_packages_declaring_one_name_keep_their_references_apart` — the same
attack through the member table: `p::WIDTH` and `q::WIDTH` used on adjacent
lines of one open file, asked from the declaration and from the use.
- `every_in_file_occurrence_is_converted_against_its_own_line` — 41
occurrences over 40 lines each carrying a multi-byte and an astral character;
every reported range is checked to point at the name, and
`documentHighlight`'s ranges are asserted equal to `references`'. A walker
handed spans out of order would answer stale columns here.
**Gates.** `cargo fmt --all -- --check` clean; `cargo clippy --all-targets`
zero warnings; `cargo test --workspace` **2 406 passed, 0 failed** (3 ignored
probes in `nav.rs`, one of them pre-existing). Files edited:
`crates/lucisv_server/src/nav.rs` and one `pub(crate)` on `perf::mean`. No new
dependencies, no `unsafe`, no `unwrap`/`expect` outside `#[cfg(test)]`, no new
`#[allow]`. `TODO.md` untouched — this round closes no backlog item; M7 is
already checked. Did not `git commit`/`git push`.
### 2026-08-27 — indexed navigation performance
- Began replacing the per-request `Workspace::sources()` +
`vlog_refactor::find_references` rebuild with reference facts stored in the
existing semantic index. The chosen shape is deliberately not a second
project model: `FileFacts` remains the per-file persistence and incremental
update unit, while `WorkspaceIndex` gains the merged inverted postings.
`FACTS_FORMAT` will bump because the persistent record gains fields; the
cache's version handshake therefore drops old records rather than reading a
partial shape.
- Scope remains the scope ladder's decision (filelist exactly when configured,
otherwise the folder/workspace setting already in force). This round changes
the cost of navigation inside that scope, not which files the user asked the
server to index.
- Completed the inverted index in the existing `FileFacts` /
`WorkspaceIndex` lifecycle. `FACTS_FORMAT` moved from 1 to 2, so an old cache
is discarded safely. Incremental save updates rebuild the postings from
compact facts already in memory; adding/removing files still follows the
index's path-sorted `FileId` contract.
- `nav::references` now resolves the live cursor to one indexed declaration,
reads its posting list, overlays every open buffer's current semantics, and
batches byte-span-to-LSP conversion per touched file. Duplicate declarations
and ambiguous uses still fall back to the in-file answer. Permanent tests
cover module, package-member and port references, cache round trips,
incremental equivalence, ambiguity, unsaved deletions/additions, moved live
declarations, and direct equality with `vlog_refactor::find_references`.
- Cursor hot paths no longer sweep the whole open file: semantic declaration
and reference lookup, plus macro-token hover, use binary-searched position
tables. Include definition inspects only the cursor's line.
- The ignored release latency probe builds 820 files and returns five
locations: **0.064 ms/request** averaged over 200 indexed requests; the old
source collection + refactor walk took **23.431 ms** once on the same files
(about **366×** slower). Command:
`cargo test --release -p lucisv_server
qa_indexed_references_latency_over_a_large_workspace -- --ignored --nocapture`.
### 2026-08-24 — dev agent (M7)
- **Read first**: `CLAUDE.md`, `docs/features/refactor/README.md`'s triage,
`docs/features/lucisv-server/README.md` in full, then `nav.rs`, `pairs.rs`,
`state.rs`, `server.rs`, `main.rs`, `vlog_refactor/src/rename.rs` and
`vlog_semantic`'s `workspace.rs`/`model.rs`. The design decisions below all
came out of that reading rather than out of the brief.
- **The sharing shape.** `collect_edits` was two things in one function: the
walk that finds every occurrence, and the conversion of spans into checked
edits. Splitting it at that seam gave `collect_occurrences` with no new
logic and no change to the rename's behaviour — the ambiguity refusal, the
`text.contains(&name)` prefilter and the on-demand analysis cache all stayed
exactly where they were. `find_references` is 30 lines on top of it.
`vlog_semantic` was left alone; the reasoning is in Handshakes.
- **The gate was the interesting part, not the collection.** A naive wiring
would call `find_references` for every references request, which re-reads
the workspace to answer "where else is this `wire`" — 218 ms instead of
1 ms, on every request, for the commonest case. The predicate asks the
*index* whether the name is reachable from outside (`units`, or `member`
under the unit that owns the declaring scope), which needs no file I/O and
no duplicated visibility rules. It falls out of that construction that a
module's **ports** are cross-file referenceable — the index exports exactly
what a connection list can name — so `.clk(...)` connections in other files
now show up as references to the port, which is right and is tested.
- **`documentHighlight` gained a second answer rather than a second
handler.** `pairs::highlights` is tried first and `nav::document_highlights`
second; both return `Option`, and both `None` means `null`, which is what
keeps the editor's own word highlighting alive where lucisv knows nothing.
The two never compete: a scope keyword is never an identifier.
- **Folding stops one line short of the closer** (`endLine = close line - 1`).
LSP hides `startLine + 1 ..= endLine`, so this leaves `end`/`endmodule` on
screen — the convention that lets a reader see *what* was collapsed. Block
comments do the opposite and fold through their last line, because a `*/`
alone on screen tells nobody anything. A pair that opens and closes with
nothing between the two lines produces no range at all.
- **An unmatched opener produces no fold**, for free: `analyze` puts it on
`unmatched_open`, not on `pairs`. This is the failure mode that makes people
switch folding off — a missing `end` folding the rest of the file away — and
it is pinned by its own test rather than left to the data structure.
- **Trailing trivia was nearly missed.** The first draft of `folding.rs`
walked `token.leading` only, which silently drops every comment written
after code on its own line. Caught by writing the test before believing the
code; both halves are now iterated and both have a test.
- **Perf, measured on the corpus** (release binary, real stdio session,
best of three, `initialize` + `didOpen` + one request + `shutdown`):
`references` on `prim_lfsr` (declared once, instantiated in 4 other files,
820 source files indexed) — **218 ms** for the request, 535 ms for the whole
session against a 317 ms session baseline. `references` on a local `logic`
in the same file — **1 ms**, i.e. the gate is shut and no walk happens. Well
inside the 1 s budget the brief set.
- **No new dependencies.** No `unsafe`, no `unwrap`/`expect`/`panic!` outside
`#[cfg(test)]`, no new `#[allow]`.
- Did not touch `vlog_parser`, `vlog_formatter`, `vlog_linter`, `lucisv_core`,
`crates/lucisv`, `editors/`, `TODO.md` or the umbrella plan. Did not run
`git commit`/`git push`. No version bump (0.5.0 is M14's).
**Results.** `cargo fmt --all -- --check`: clean. `cargo clippy --all-targets`:
0 warnings. `cargo test --workspace`: **1329 passed, 0 failed**, of which **34 are new**:
15 in `folding.rs`, 11 added to `nav.rs` (20 there in total), 7 in
`references.rs`, and 1 e2e (18 in that file now).
`node editors/vscode/smoke.js target/release/lucisv-server`: OK.
Files added: `crates/vlog_refactor/src/references.rs`,
`crates/lucisv_server/src/folding.rs`, this README. Files edited:
`crates/vlog_refactor/src/{lib.rs,rename.rs}`,
`crates/lucisv_server/src/{main.rs,server.rs,nav.rs}`,
`crates/lucisv_server/tests/e2e.rs`, `docs/features/lucisv-server/README.md`.
## QA log
### 2026-08-28 — QA agent, references-latency round
Adversarial charter: try to make the new spelled-name prefilter (`nav.rs:248`,
`indexed_references`) **change an answer**. Slower-but-right was already true;
only a changed answer is a defect this round.
#### Soundness of the prefilter — traced by construction, not just trusted
Read the dev's write-up's claim against the actual code that makes it true,
rather than the prose alone:
- `Def` (`crates/vlog_semantic/src/workspace.rs:33`) derives `PartialEq` over
`(file, name_span, kind, detail_span)` — it carries no name at all. Its
identity is "this declaration, right here," so `def == target.def` can only
be decided by the site it points at, never by a spelling.
- Every `Decl` is filed under exactly one key, its own declared name:
`self.units.entry(decl.name.clone())...push(decl.def(file))`
(`workspace.rs:529`) and `self.members.entry(unit.clone())...entry(decl.name.clone())...push(decl.def(file))`
(`workspace.rs:535-540`). `decl.name` traces back to `Symbol.name`
(`Decl::of`, `workspace.rs:654`), and `Symbol.name`/the scope's `names` map
key are the same `name.to_string()` written in one `declare` call
(`bind.rs:141` and `bind.rs:151`) — so a `Def` cannot be filed under a name
it wasn't declared with, and cannot be filed under two names.
- `Scope::lookup_local` (`model.rs:215`) is a plain `HashMap<String,
SymbolId>` `get` — no case-folding, no normalization. Every
`Resolution::Resolved(id)` in `resolve.rs` comes from `lookup_local(&p.name)`
(or `Target::Declaration(id)`, an end label the binder already matched to
its opener's name). `Reference.name` is `p.name.clone()` at the exact
construction site (`lib.rs:78-79`). So a **locally** resolved reference's
`.name` is *definitionally* `symbol.name` — the prefilter reads the same
field the binder used to decide the match, not a second, potentially
divergent, source of truth.
- The **external** arm is the same shape one level up: `resolve_external`
(`workspace.rs:1097`) always calls `follow_paths(index, &reference.name,
paths)`, and `follow_one` (`workspace.rs:1132`) always queries
`index.units(name)` or `index.member(unit, name)` with that same `name` —
`path` only picks *which* table, never the key. So both `Resolved(def)` and
`Ambiguous(defs)` for a reference are always drawn from the bucket keyed by
that reference's own `.name`, which makes the dev's ambiguity-survives
argument mechanical rather than incidental: `defs.contains(&target.def)`
can only be true when `defs` came from the `target.name` bucket, which only
happens when `reference.name == target.name` — exactly what the prefilter
already let through.
No escaped-identifier or case-folding attack survives this: the lexer
(`crates/vlog_parser/src/lexer.rs:304-318`) keeps an escaped identifier's
leading backslash in the token text (`\sub` and `sub` are different strings
at the token level already), and nothing between the lexer and
`Scope::names` ever folds case or strips it — so whatever the binder already
does or doesn't unify, the prefilter reads the identical field the binder
matched on. There is no code path where `reference.name` and the spelling the
binder used to resolve it can diverge, so there is no daylight for the
prefilter to exploit. Traced, not fuzzed — I did not find a construction
worth writing as a failing-if-regressed test beyond what's below, because the
invariant is enforced by there being exactly one string in play, not by a
check that could later be weakened unnoticed.
**Verdict on the prefilter: sound, no answer-changing case found.**
#### Attempts to break it anyway
- **Port connection vs. declared name, member-table variant.** Extended the
attack beyond the dev's own two tests (`a_same_named_port_in_another_open_buffer_is_a_different_symbol`,
`two_packages_declaring_one_name_keep_their_references_apart`) with a name
that is a **unit in one file and a member in another** — `module W` and
`package p; localparam W = 4;` — plus a **live unsaved edit** to the file
using both (a second instantiation added post-open, never saved). Added as
`indexed_references_equal_the_refactor_walk_for_a_name_thats_both_a_unit_and_a_member`
(`nav.rs:662`), asserted equal to `vlog_refactor::find_references` on
`ws.sources()` (which itself overlays the unsaved edit) in both directions.
Passed first try — no answer conflation between the `units` and `members`
buckets, and the unsaved instantiation is correctly counted.
- **Walker ordering/multi-byte/astral attack** on the two newly-batched
conversion sites (`in_file_references` and `document_highlights`, now both
walker-based per `nav.rs:347` and `nav.rs:374`). The dev's own
`every_in_file_occurrence_is_converted_against_its_own_line` already covers
this shape well (41 occurrences over 40 lines, each preceded by a
multi-byte and an astral character, every reported range checked against
the actual byte); I did not find a shape it misses. The walker itself
(`crates/lucisv_server/src/convert.rs`, `PositionWalker`) is pre-existing,
general-purpose infrastructure (`locations()` has used it since the
2026-08-27 round) with its own dedicated tests for out-of-order offsets,
ping-ponging between far-apart lines, and an empty document
(`the_walker_agrees_with_the_per_call_converter_on_every_shape`,
`a_walker_handed_offsets_out_of_order_still_answers_the_per_call_position`,
`a_walker_ping_ponged_between_two_far_apart_lines_still_answers_correctly`,
`a_walker_over_an_empty_document_answers_the_one_position_there_is`, all in
`convert.rs`) — so the only new risk this round is whether
`in_file_references`/`document_highlights` feed it spans in order, and they
do: both consume `occurrences()`, which sorts by `span.start`
(`nav.rs:413`) before the walker ever sees them. No out-of-order feed
exists on either path.
- **Ambiguous-abort still aborts.** Re-ran
`a_name_declared_in_two_files_degrades_references_to_the_in_file_answer`
(already in the suite, unmodified by the dev this round) and traced the
`Ambiguous(defs) if defs.contains(&target.def) => return None` arm
(`nav.rs:258-260`) by hand against the bucket argument above: an ambiguous
external use can only carry `target.def` in its candidate set when it
spells `target.name`, which is exactly when the prefilter lets it reach
this arm. Confirmed by construction, not just by the still-green test.
- **Equivalence, existing test.** `indexed_references_equal_the_refactor_walk_they_replace`
(`nav.rs:648`, pre-dating this round) still passes unmodified.
#### Measurements reproduced (release, `--release`, this machine)
```
cargo test --release -p lucisv_server nav::tests::qa_ -- --ignored --nocapture --test-threads=1
```
| what | work log | reproduced here |
|---|---|---|
| references, use site | 110 µs | 109.8 µs |
| references, declaration | 110 µs | 108.9 µs |
| definition, use site | 1.13 µs | 0.82 µs |
| in-file, wire used 3× | 1.20 µs | 1.12 µs |
| in-file, wire used 10 001× | 1.18 ms | 1.17 ms |
| documentHighlight, same wire | 917 µs | 916 µs |
| didOpen, scope already covers | 8.4 µs | 7.3 µs |
| didOpen, new folder (+ rescan) | 220 ms | 214.6 ms |
| rescan alone | 223 ms | 217.7 ms |
| rescan, big buffer closed | 13 ms | 12.5 ms |
All within the charter's 2-3× tolerance (most within 5%) — no contradiction
of the work log's order-of-magnitude claims. The pre-existing
`qa_indexed_references_latency_over_a_large_workspace` probe (2026-08-27,
untouched by this round) also still ran clean: 0.068 ms/request vs. 31.35 ms
for the old walk on this machine, consistent with that round's own numbers.
#### Gates
- `cargo fmt --all -- --check` — clean.
- `cargo clippy --all-targets --all-features` — clean, zero warnings (forced
re-check by `touch`ing the changed files first, not a cache hit).
- `cargo test --workspace` — **2 406 passed, 0 failed** before my addition,
matching the work log's count exactly; **2 407** after adding the one
permanent equivalence test above. 24 ignored across the workspace (3 in
`nav.rs`, one of those pre-existing, matching the work log).
**All gates: pass, claims confirmed.**
#### Verdict
**SHIP.** No corruption, no answer change, no crash found under the
adversarial charter. The prefilter's soundness holds by construction (one
string, read by both the binder and the prefilter, never normalized or
duplicated anywhere in between), not merely by the tests passing. One
permanent regression test added
(`indexed_references_equal_the_refactor_walk_for_a_name_thats_both_a_unit_and_a_member`,
`nav.rs:662`) for the nastier unit/member name-collision case with a live
unsaved edit, requested by the round's brief; no other findings warranted a
fix or a new test. Review section left untouched.
### 2026-08-24 — QA agent
#### Gates
- `cargo fmt --all -- --check` — clean.
- `cargo clippy --all-targets` — clean, zero warnings (forced re-check after
`touch`ing every changed/new file, not a cache hit).
- `cargo test --workspace` — **1329 passed, 0 failed**, matching the Work
log's count exactly, before I added one regression test (see below); 1330
after.
- `node editors/vscode/smoke.js target/release/lucisv-server` — OK.
- `cargo test -p vlog_refactor` standalone — **48/48** rename behavior tests
green (`tests/rename.rs`), confirming the `collect_edits`/
`collect_occurrences` split changed nothing rename depends on.
**All gates: pass, claims confirmed.**
#### The factoring (`collect_occurrences` out of `collect_edits`)
Read the diff of `crates/vlog_refactor/src/rename.rs` line by line rather
than trusting the green suite alone. `collect_occurrences` is exactly the old
`collect_edits` walk with `edits_from_spans` peeled off the end;
`collect_edits` now calls it and applies `edits_from_spans` to every
`(file, spans)` pair, filtering empty results exactly as before
(`if !edits.is_empty()`). No reordering, no new dedup, no change to the
ambiguity refusal or the substring prefilter. `find_references` shares the
same `(usize, Vec<TextRange>)` shape and does its own sort/dedup/declaration
handling on top — it does not lean on any rename-specific step. Verdict:
**behavior-identical**, confirmed both by the diff and by 48/48 green.
#### Attempts to break it (`vlog_refactor::find_references`, API level)
Wrote a scratch test file (`crates/vlog_refactor/tests/qa_probe_refs.rs`,
removed after the round, not committed) exercising the public API directly:
- **`bind`**: `bind top leaf b_leaf ();` correctly appears as a reference to
`leaf` alongside the declaration.
- **Instance arrays** (`sub u[3:0] ();`): found, alongside the declaration.
- **Ambiguous declaration** (two files declare `dup`): `find_references`
returns the same refusal sentence a rename at that position would
(`` `dup` is declared in more than one indexed file... ``) — verbatim
reuse of the rename refusal message, as the Handshakes section promises.
- **`import p::*` glob in a third file**: the package member is found at the
glob-import site in a file that is neither the declaring file nor the file
the cursor started in.
- **End labels**: `begin : blk ... end : blk`, asking for references to
`blk`, returns **2** occurrences (the `begin` label and the `end` label) —
end labels **do** appear in a references answer. Assessed, not a bug: M2
already made end labels *references* of their declaration
(`docs/features/refactor-rename/README.md`), and since references and
rename share one walk, hiding them from `references` while a rename edits
them would be exactly the "two answers about one symbol" lie the
Handshakes section says this feature refuses to tell. Correct as built.
- **Rename ↔ references consistency**: for a cross-file port case (module
`sub` with port `clk`, instantiated by name in two other files), the set of
`(file, start-offset)` pairs from `rename`'s edits and from
`find_references(..., include_declaration: true)` are **identical** after
sorting. Spot-checked in code, not just eyeballed.
#### Attempts to break it (`lucisv_server::nav`, handler level)
Six scratch tests added temporarily to `nav.rs`'s own test module, run, then
removed (`git diff --stat` on `nav.rs` returned to the dev's exact
344/-20 shape before I added the one permanent test below):
- **Ambiguous name degrades to in-file, not error, not empty.** Two files
declare `dup`; `leaves_this_file` correctly says "yes, ask the workspace"
(the index holds `dup` as a unit), `find_references` refuses it as
ambiguous, and `references()` falls back to exactly one location — the
in-file declaration. This is the claim in Assumptions ("a refusal degrades
to the in-file answer, it is not an error") and it holds. **This had no
dedicated regression test among the 34 new ones** (the only ambiguity test
in `nav.rs`, `an_ambiguous_workspace_name_returns_every_location`, is for
`definition`, not `references`) — see "Fix applied" below.
- **Cursor on a comment, or a keyword.** `document_highlights` returns `None`
(not an empty list); `references` returns an empty `Vec` (not an error) —
both correct, both matching the null-not-error contract the README states.
- **Sibling scope, same signal name** (`n` declared inside `begin : b1` and
independently inside a sibling `begin : b2`): `document_highlights` on
`b1`'s `n` returns exactly `b1`'s declaration and use, never touching
`b2`'s unrelated `n`. Correct isolation.
- **Unsaved buffer overlay, two shapes.** (1) A file already known to the
index (`sub.sv`, module `sub` already indexed at `open_roots` time) gets an
unsaved `didChange`-style edit to `top.sv` adding a *new* instantiation of
`sub`. `references` on `sub` **does** see the new instantiation —
`Workspace::sources()` picks up the live buffer text even though the index
has not rebuilt. (2) A brand-new file (`sub.sv`, never written to disk,
never scanned by `open_roots`) is opened as a pure buffer, while an
on-disk `top.sv` genuinely instantiates it. `references` on `sub` sees
**only** the in-file declaration — the gate (`WorkspaceIndex`, save-
triggered) has never heard of `sub` as a unit, so `leaves_this_file` stays
shut, and `top.sv`'s real instantiation is invisible until a save rebuilds
the index. Both outcomes match the documented staleness window exactly
(Assumptions: "a declaration the index has not seen yet ... is answered
in-file until the next rebuild").
- **Port referenceable from both sides, on the real binary** (see below).
**Fix applied (small, unambiguous per CLAUDE.md's QA license):** added
`a_name_declared_in_two_files_degrades_references_to_the_in_file_answer` to
`crates/lucisv_server/src/nav.rs` (permanent, not a probe) — the one claim
above that had behavior verified correct but zero regression coverage.
Workspace test count is now 1330 (was 1329), gates re-run green after the
addition.
#### documentHighlight, on the real binary
Independent stdio session (own script, not `tests/e2e.rs`) against a
2-file fixture (`leaf.sv`/`top.sv`, port `clk_i`, an `always_ff` block):
- Cursor on `clk_i` inside the sensitivity list → highlights the port
declaration (line 1) and this in-file use (line 5), `kind: Text` (`1`).
- Cursor on the `begin` keyword → `pairs::highlights` answers first: `begin`
and its matching `end`, not the symbol path. Fallthrough order confirmed
live, not just read from the diff.
- Cursor on the `always_ff` keyword → `null`.
#### Folding, independent attacks
Six scratch tests added temporarily to `folding.rs`'s own test module (run,
then removed — file back to its original 249 lines):
- **A 2-line `begin`/`end`** (`initial begin\nend`): produces **no** range —
`through = close_line - 1 == open_line`, so `push` drops it. Only the
enclosing module folds. Matches the documented "opens and closes with
nothing between the two lines produces no range at all."
- **CRLF file**, module + `initial begin`/`end` + a 2-line block comment, all
with `\r\n` line endings: every fold lands on the right line, no
off-by-one from the `\r` bytes.
- **An unmatched opener sitting between two *matched* pairs**
(`begin` (unmatched) between a matched `begin/end` before it and another
matched `begin/end` after it, all inside one module): the unmatched
`begin` produces no fold, the two real pairs fold correctly, and —
significant — the *later* `begin` matches its own `end` rather than the
earlier, orphaned one picking it up. Confirms the pair-matcher is a proper
LIFO stack per keyword family, not a naive first-open/first-close scan, so
an interior unmatched opener cannot cause a *later*, unrelated pair to be
misattributed. No fold reached past the file's own last line either.
- The "unmatched-begin file from the rainbow QA" round itself does not exist
as a checked-in fixture (searched the tree; no `rainbow` feature README, no
saved fixture file) — reconstructed the shape described in the M7 QA brief
(an opener with no closer, amid otherwise-valid code) rather than reusing a
file that isn't in this tree.
- One-line block comment already covered by the dev's own
`a_one_line_comment_of_either_spelling_folds_nothing` — read and confirmed
correct rather than re-proven.
#### Independent e2e: cross-file references + folding round trip
Own hand-rolled Python stdio client (`write-then-read-all`, same rationale
`tests/e2e.rs` documents at its own top, not the dev's script or fixture) —
`leaf.sv` (a clocked module) instantiated twice by `top.sv`:
- `references` on `leaf`'s declaration, `includeDeclaration: true` → 3 hits
(declaration + both instantiations); `false` → 2 hits, declaration
correctly dropped and nothing else lost.
- `references` on the **connection-side** `.clk_i(...)` name in `top.sv`
(not the declaration, not the expression) → resolves to the *port*'s full
reference set: the port declaration, its in-file use inside the
`always_ff` sensitivity list, and both connection sites across the two
instantiations. Confirms ports are reachable **from a connection**, not
only from the declaration side (the corpus perf run below confirms the
declaration-side direction).
- `foldingRange` on `leaf.sv` → exactly two ranges, the module (0–8) and the
`always_ff` block (5–7), both boundaries correct.
#### Performance
Reconfirmed the dev's corpus measurement independently (own Python driver,
release binary, real stdio session, `initialize` → `didOpen` → one
`references` request → `shutdown`): `references` on `prim_lfsr`'s module
name — **528.5 ms** whole-session wall time. A 3-run baseline session with no
request (`initialize`/`initialized`/`shutdown`/`exit` only) measured
**~317 ms**, so the request itself costs **~211 ms** — matches the Work
log's 218 ms / 535 ms / 317 ms triad closely enough to call it the same
number, measured twice.
**New measurement: a common name, the text-prefilter's worst case.** Ports
named `clk_i` appear (as a substring) in **360 of 860** corpus files — every
one of those pays the "does the text contain the name" check and, on a hit,
a full re-analysis. `references` on `prim_lfsr`'s own `clk_i` port — **3–4
runs, 612–627 ms** whole-session, i.e. **~295–310 ms** for the request alone.
That is only ~1.4× the already-cross-file `prim_lfsr` case above, not a
blowup, even though the prefilter had roughly 8× more files to look past
(45 files spelling `prim_lfsr` vs. an estimated few hundred spelling
`clk_i`, not counted exactly). Comfortably inside any reasonable request
budget. **This scenario was not in the dev's own perf writeup** — worth
having on record since "a port named like every other port in the codebase"
is a completely ordinary real-world query, not an edge case.
**Corpus file count, a documentation-only discrepancy.** The Work log says
"820 source files indexed"; the Assumptions section separately says "the
860-file corpus". A plain `find` over `corpus/` for `.v`/`.sv`/`.svh`/`.vh`
returns exactly **860**, matching every earlier round's number for this same
directory (`docs/features/lucisv-server/README.md`'s QA log, 2026-08-19: "860
files"). `corpus/` itself is listed in the repo's own `.gitignore`, but the
LSP root was pointed *at* `corpus/`, so that rule is moot; however `corpus/`
contains **19 nested `.gitignore` files** from the vendored upstream repos
themselves (`corpus/ibex/.gitignore`, `corpus/opentitan/.gitignore`, etc.),
and the workspace walk has honored `.gitignore` unconditionally since
`lucisv-core-lift` landed the same day as this round. So 820 vs. 860 is
plausibly real — some vendored generated/build files are legitimately
excluded now that they weren't when the 860 number was first measured — but
I could not independently confirm 820 exactly: LSP exposes no
"how many files did you index" answer, and `workspace/symbol` is capped at
256. **Not filed as a defect** — the explanation is plausible and the actual
measured behavior (references answers, timings) was correct throughout —
but flagging the inconsistency between the README's own two numbers (820 in
Work log vs. 860 in Assumptions, for what reads as the same measurement) so
whoever owns the prose can pick one and true it up.
#### A process discrepancy worth the lead's attention (not a code defect)
The Work log states plainly: "Did not touch ... `TODO.md` or the umbrella
plan." But `git diff HEAD -- TODO.md` currently shows an uncommitted,
20-line addition — the M7–M14 checklist items — that is **not** part of
`HEAD` (`6036a62`, which only touched
`docs/features/refactor/README.md` per `git show --stat`). I did not revert
it (TODO.md is explicitly out of QA's scope per the round brief, and I
cannot tell from the working tree alone whether this is unfinished, not-yet-
committed lead work from the same triage session, or something the dev
agent added despite its own claim). Flagging so the lead can reconcile the
Work log's claim against what is actually sitting in the working tree before
commit.
#### Summary
| Claim | Verdict |
|---|---|
| Gates (fmt/clippy/test/smoke) | **Pass**, 1329 confirmed (1330 after my one added test) |
| `collect_occurrences` factoring is behavior-identical | **Pass** — diff-reviewed and 48/48 rename tests green |
| `find_references`: bind, instance arrays, glob import, ambiguous refusal, end labels, rename/references consistency | **Pass**, all as documented |
| `nav::leaves_this_file` gate, ambiguous degrade, sibling isolation, comment/keyword null, unsaved-overlay behavior (both shapes), staleness window | **Pass**, all as documented |
| Ports cross-file referenceable from both the declaration and a connection | **Pass**, confirmed on the real binary |
| `documentHighlight` fallthrough order (pairs first, symbol second, null third) | **Pass**, confirmed on the real binary |
| Folding: 2-line block, CRLF, unmatched-opener-amid-matched-pairs (LIFO correctness) | **Pass** |
| Independent e2e round trip (references × 2 + folding) | **Pass** |
| Perf: prim_lfsr corpus measurement | **Pass**, reconfirmed independently (~211 ms request, matches dev's 218 ms) |
| Perf: common-name worst case (new measurement) | **Pass** — ~300 ms request, no blowup |
| Corpus file count in the README (820 vs. 860) | **Informational** — plausible, not independently confirmable, prose-only inconsistency |
| TODO.md untouched (Work log claim) | **Contradicted by the working tree** — flagged for the lead, not fixed |
No corruption, no crash, no silent wrong answer found anywhere. One
permanent test added (small, unambiguous, per CLAUDE.md). No probe files
left in the tree; `nav.rs` and `folding.rs` diffs verified to match the
dev's original shape plus exactly my one addition.
**Verdict: ship**, with the two informational items (corpus count prose,
TODO.md discrepancy) left for the lead to reconcile — neither is a
correctness or safety issue in the shipped feature.
## Review
**2026-08-28 — lead, references-latency round.** Reviewed after QA's
clean SHIP; gates re-run independently (fmt clean, clippy silent, 2407
workspace tests green). Measure-first discipline held: the probes were
written and their before-numbers recorded ahead of any fix, and they
convicted the overlay loop (H1) while acquitting `references` of the
owner-reported asymmetry — which the didOpen numbers (H3) explain
instead, correctly filed as a Handshake request rather than fixed
cross-scope. The prefilter comment in `indexed_references` points at
the soundness argument, QA traced that argument to the code
(single-key filing, no name normalization anywhere between lexer and
lookup), and the unit-vs-member equivalence test QA added is the
sharpest same-spelling case the design admits. The empty-span check
deliberately left unhoisted — so a spanless ambiguous use still aborts
— is the kind of detail that separates a fast loop from a subtly
different one; noted with approval. Accepted; the scope-widening
rescan follow-up (210 ms of re-parsing open buffers) is the next
round.
**2026-08-27 — lead, indexed-navigation performance round (external dev:
codex).** Reviewed the full diff line-by-line and ran all three gates
independently (fmt clean, clippy silent, 1155 server tests + workspace
suite green). The design keeps the one-project-model rule: reference
facts live in `FileFacts` (the existing persistence and incremental
unit), postings are merged in `WorkspaceIndex`, and `FACTS_FORMAT` 1→2
plus the cache header's format handshake discards every v1 store whole —
verified in `index_cache.rs:324`. `macro_definitions` filters
`DefineKind::Define`, byte-identical semantics with the
`DefineTable::all` it replaces. Ambiguity is preserved everywhere it
mattered: ambiguous postings are marked, an ambiguous live overlay use
aborts to the in-file answer mid-collection, and the rename refusal
contract survives. The equivalence test pins the indexed answer to the
old `vlog_refactor::find_references` walk, which stays as rename's
engine and the oracle. Lead re-ran the ignored release probe:
0.062 ms/request over 820 files vs 21.7 ms for the old walk (~350×),
consistent with the work log's numbers. No QA-agent pass this round;
the lead review substituted, and the incremental-fingerprint,
unsaved-buffer and ambiguity tests cover the paths a QA attack would
have targeted. Accepted.
**2026-08-24 — lead.** Reviewed after QA's ship verdict (clean first
pass); gates run independently (1330 tests, 0 failures, clippy silent).
The factoring is the right move — `collect_occurrences` peeled out of
rename with the edit-conversion left behind, QA line-verified it
behavior-identical — and `leaves_this_file` asking the index instead of
re-deriving exportedness is exactly the no-second-resolution rule the
umbrella plan demands. Folding as the fourth consumer of `pairs::analyze`
cost one file. QA's added regression test for the ambiguous-degrade path
is accepted with thanks; its corpus-count discrepancy note (820 vs 860)
is the gitignore-aware walk, as suspected, and its TODO.md flag was the
lead's own uncommitted M7–M14 queue. Rename↔references span consistency
was verified — the property that makes this milestone honest. Accepted;
M7 checked off in the umbrella plan and TODO.md §8.