# workspace-index ## Goal `vlog_semantic::analyze` is deliberately single-file: a name only another file can supply comes back as `Resolution::ExternalCandidate` carrying the import paths that could finish it — 19.6 % of every use on cleanly-parsed corpus files (`docs/features/vlog-semantic/README.md`). This feature is the second layer that finishes them. `WorkspaceIndex::build` scans every file in the workspace once and records what each one *declares* — modules, packages, file-scope typedefs, each package's and module's exported members, and each file's `` `define`` table. `resolve_external` walks one file's external candidates against that index and answers them in an **overlay** keyed by reference id. That is what turns `import prim_pkg::*` and `prim_fifo_sync u_fifo (...)` into a jump into the file that declares them — TODO.md §6's "cross-file resolution through header imports", the last piece `textDocument/definition` needs before `lucisv_server` can be written. ## API as built ```rust // The index impl WorkspaceIndex { fn build<'a>(files: impl IntoIterator) -> WorkspaceIndex; fn files(&self) -> &[PathBuf]; // indexed by FileId fn path(&self, FileId) -> Option<&Path>; fn units(&self, name: &str) -> &[Def]; // module | package | file-scope typedef fn member(&self, unit: &str, member: &str) -> &[Def]; fn members_of(&self, unit: &str) -> impl Iterator; fn defines(&self, FileId) -> Option<&DefineTable>; fn find_define(&self, name: &str) -> Vec<(FileId, &Define)>; fn workspace_symbols(&self, query: &str) -> Vec>; fn counts(&self) -> IndexCounts; } struct Def { file: FileId, name_span: TextRange, kind: SymbolKind } struct WorkspaceSymbol<'a> { name: &'a str, container: Option<&'a str>, def: &'a Def } struct IndexCounts { files, modules, packages, typedefs, members, defines } // The overlay fn resolve_external(&Semantics, &WorkspaceIndex) -> ExternalResolutions; enum ExternalTarget { Resolved(Def), Ambiguous(Vec), StillUnresolved } impl ExternalTarget { fn defs(&self) -> &[Def]; fn best(&self) -> Option<&Def>; } // StillUnresolved deliberately does not distinguish "package absent from the // workspace" from "package found but member absent" (QA find, lead-ruled): // both answer an LSP definition request the same way (no target), and the // in-file analog of the second case is already Resolution::NotFound before // the overlay is consulted. If a diagnostic ever wants the distinction, add // a variant then — not speculatively now. impl ExternalResolutions { fn get(&self, ReferenceId) -> Option<&ExternalTarget>; fn iter(&self) -> impl Iterator; // reference order fn counts(&self) -> (usize, usize); // (answered, total) fn definition_of(&self, &Semantics, offset: u32) -> Option>; } enum Definition<'a> { Local(&'a Symbol), External(&'a [Def]) } ``` Additive changes to `vlog_semantic`'s existing API (nothing removed, nothing renamed): `ReferenceId(pub u32)`, `Semantics::reference(ReferenceId)` and `Semantics::reference_id_at(offset)` — the overlay needs a stable key for a reference, and index-into-`references()` is the one that already exists implicitly. ### The two layers, and why they are two `analyze` gives a file's `Semantics`; `resolve_external` gives an `ExternalResolutions` **beside** it. `Semantics` is never mutated. - A file's own analysis is true regardless of what the rest of the workspace is doing. Folding workspace answers into it would make every `Semantics` stale the moment any *other* file is edited. - The two layers are invalidated by different events — editing this buffer invalidates the `Semantics`, editing any other file invalidates the index — so a server recomputes whichever one changed and recomposes cheaply. - Composition is one function: `ExternalResolutions::definition_of` asks the in-file layer first (a local declaration always wins over a workspace one), then the overlay, then falls back to "the cursor is on a declaration". `Semantics::definition_of` still works alone, for a server with no workspace open. The overlay holds an entry **only** for references the in-file layer left as `ExternalCandidate`; a locally-resolved reference is absent from it entirely, which is also how a caller tells "resolved locally" from "not an external candidate at all" without re-reading the `Resolution`. ## Resolution rules An external candidate carries `paths` — every import in the lexical chain that could supply the name, in the order they are written, or the single unit name for an instantiation. The paths are tried **in that order** and the first path with any hit wins: 1. `p::*` and `p::x` both mean *the name this use spells, inside unit `p`* — looked up in the index's member table for `p`. (For `p::x` the tail always equals the use's own name, both for a `p::x` expression and for an `import p::x` that only offers itself for the name `x`; the use's name is what is looked up, so the two spellings need no separate handling.) 2. A bare path is the **unit itself** when the use spells the unit's name — an instantiated module, the `p` head of `p::x`, the package of an import. 3. A bare path whose name differs from the use's is a **member of that unit**: the `.port` (or `.PARAM` override) of a connection to a module declared in another file. Two paths that could both supply the name do not make an ambiguity: the first one written wins, which is exactly the rule the single-file layer already applies to two in-file wildcard imports ("imports are consulted in the order written"). Ambiguity means something else — see below. ### What is indexed - **Units** (`units(name)`): every file-scope `module`, `package` and `typedef`. File-scope typedefs are indexed for `workspace_symbols` and for a future include-aware lookup; nothing resolves to them today, because a use of a type declared in another file with no import path is `NotFound`, not an external candidate, and so never reaches this layer. - **Package members**: everything declared at a package's top level — params, typedefs, enum variants, functions, tasks, nets and vars. This is what makes `import p::*` and `p::x` reach *into* the package's file. - **Module members**: ports and parameters only. That is exactly what a connection list or a `#(.W(8))` override can name; an internal net of another module stays unreachable, which is correct and is a test. - **`` `define`` tables**: `defines::collect_defines` per file, keyed by `FileId`, read off the same token stream the parse used. A declaration whose `name_span` is empty (the single-file layer's "I could not locate this name in the source") is **not** indexed: an editor must never be sent to a zero-width range. ### Duplicates and ambiguity Real workspaces collide: the corpus declares the same module name in several files (vendored copies, `_reg_top` variants, an `.sv` and a `.v` of the same block). Every declaration is kept. - `units(name)` / `member(unit, name)` return **all** of them, in **disambiguation order: by file path (byte-wise `PathBuf` sort), then by position within the file**. `FileId`s are assigned in that same sorted order, so `FileId` order *is* path order, and the order does not depend on the order the caller happened to hand the files over (asserted by a test). - One hit → `ExternalTarget::Resolved`. Several → `ExternalTarget::Ambiguous` holding all of them in that order. `best()` takes the first; `Definition::External` hands the whole slice to the caller, because LSP's `textDocument/definition` accepts several locations and showing all of them is more honest than silently picking one. - No kind filtering: a name declared as a module in one file and a package in another is ambiguous over both. Distinguishing them would need the reference to say which it wanted, which the recorded paths do not carry. - A path handed to `build` twice is one file; the first copy wins. ### `` `define`` lookup has a home, not a policy `find_define(name)` returns **every** definition in the workspace, in file order. Which one a given use actually sees depends on the `` `include`` graph and on `` `ifdef``, neither of which this index models (and neither of which the define table models either — `docs/features/define-table/README.md`). Hover can show "defined as 8 in `defs.svh:12`, as 16 in `other.svh:3`"; picking one silently would be a guess. `defines(file)` is the exact per-file table when the caller does know which file it means. ## Assumptions - The caller does the I/O, the file discovery and the encoding decisions, and hands over `(PathBuf, &str)`. `build` does the tokenizing and parsing itself (with the tolerant parser) so that every file contributes the declarations that *did* parse — 42 % of corpus files still hit a parse error, and a workspace index that skipped them would be useless on real RTL. - Sources outlive the `build` call only; the index copies out the names and spans it needs and keeps no borrow. Slicing a `Def.name_span` is the caller's job, against the same text it passed in — the index does not retain file contents (860 corpus files are ~30 MB; keeping them would double the memory a server already spends on open buffers). - A file that does not *lex* (an unterminated string or block comment) still gets a `FileId` and an empty define table, and contributes no declarations. The lexer is all-or-nothing, so there is nothing to salvage. - The corner where a module's name equals one of its own port names (`module foo (input foo);`, and a connection `.foo(x)` on it) resolves the bare path to the module rather than the port, by rule 2 above. Nothing in the corpus does this. - `build` is O(files) and single-threaded. Measured at 860 files below; a workspace an order of magnitude larger would want the same rayon treatment `lucisv` already applies to formatting, which is a change of caller, not of this API. ## Non-goals - **No incrementality.** `build` is a pure function of its inputs; a changed workspace means calling it again. TODO.md §6 defers salsa-style incrementality explicitly, and per-file recompute is fine at Verilog sizes. - **No `` `include`` following.** The index does not build the include graph, so it cannot say which define or which typedef a given file actually sees. - **No elaboration**: no parameter binding, no instance hierarchy, no cross-file type checking. - **No filesystem walking, no config discovery.** The caller decides what the workspace is. - **The index does not rewrite `Semantics`.** By design, see the two layers above. ## Handshakes **Consumed from `vlog_parser`:** - `tokenize`, `parse_tolerant`, `parse_source_tolerant` — the tolerant path, never failing. - `defines::collect_defines(&[Token]) -> DefineTable`, `Define`, `DefineTable::all/latest/entries`. - `span::TextRange`. The concurrent parser change adding `name_span` to AST nodes (the handshake `docs/features/vlog-semantic/README.md` filed) landed mid-run. This module was written against the AST as it stood and does **not** adopt the new fields: it consumes only `Symbol.name_span` from `vlog_semantic`, whose meaning is unchanged by where the span comes from. Nothing here needs revisiting when `scan.rs` is deleted. **Consumed from `vlog_semantic` (this crate):** - `analyze`, `Semantics::{scope, symbol, references, reference, file_scope, symbol_at, reference_id_at}`, `Symbol.{name, kind, name_span, child_scope}`, `Scope.symbols`, `Resolution::ExternalCandidate { paths }`. - The `paths` contract in particular: "every import in the chain that could supply the name, in scope order" for a lexical use, `"p::x"` for a package member, the bare unit name for an instantiation or a `.port`. The three rules above are exactly a reading of that contract; if `bind.rs`/`resolve.rs` ever change the spelling of a path, `follow_one` in `workspace.rs` changes with it. **Promised to consumers (`lucisv_server`):** - `WorkspaceIndex::build` never panics and never fails, on any input, including files that do not lex. - The index is deterministic: same `(path, source)` set → same `FileId`s, same order in every returned slice, regardless of iteration order. - `Def.name_span` is a non-empty byte range in `Def.file` that slices back to exactly the name that was looked up (asserted over the whole corpus). - `resolve_external` does not mutate `Semantics` and holds no borrow of the index in its result. ## Corpus acceptance `cargo test -p vlog_semantic --test workspace -- --nocapture`, over the 860 `.v`/`.sv`/`.svh` files in `corpus/` (Ibex, OpenTitan, PULP common_cells, picorv32), 2026-08-19: ``` workspace index: 860 files in 0.68s — 521 modules, 63 packages, 38 file-scope typedefs, 8044 exported members, 502 define directives ``` Build time is a debug build, single-threaded, sources already in memory (reading them costs the caller another ~0.1 s). Well inside the ~2 s budget; re-running the whole build on every workspace change is affordable, which is why there is no incrementality. **The headline.** For each file: analyze it, resolve its external candidates against the index, and count what happened. | population | references | external candidates | workspace answers | one target | ambiguous | still unresolved | external rate after | |---|---:|---:|---:|---:|---:|---:|---:| | every file | 73 708 | 14 325 (19.4 %) | **81.4 %** | 75.4 % | 6.0 % | 18.6 % | 3.6 % | | files that parse cleanly | 46 408 | 9 101 (19.6 %) | **87.0 %** | 78.9 % | 8.1 % | 13.0 % | **2.6 %** | Read against `docs/features/vlog-semantic/README.md`'s baseline: on cleanly parsed files the single-file layer resolved 79.5 % of uses and left 19.6 % as external candidates. The workspace layer answers 87 % of those, so the unresolved-external rate over *all* references falls **19.6 % → 2.6 %**, and ~96 % of every identifier in the corpus now has somewhere to jump to. "Ambiguous" counts as answered: it is a list of real locations, which is what LSP's definition request takes. **Where the ambiguity comes from** — all of it real, none of it a defect. The top shapes are OpenTitan's technology libraries: `prim_buf`, `prim_flop`, `prim_xor2` and their ports/params are declared once in `ibex/vendor/lowrisc_ip/ip/prim_generic/rtl/` and again in `.../prim_xilinx/rtl/`. Which one a build uses is a build-system choice this index has no access to, so both are offered. 98 distinct ambiguous shapes in the whole corpus. **The honest gaps** (top unresolved paths, clean-file population): | path | uses | what it is | |---|---:|---| | `picorv32` | 429 | *is* in the corpus, but its `module` header contains a `` `ifdef`` inside the port list, so the declaration is swallowed by an error node and never indexes. Moves when the parser moves, not when this feature does. | | `sail_ibexspec` | 168 | a formal-verification model not vendored into the corpus | | `picorv32_axi` | 141 | same `` `ifdef``-in-header problem as `picorv32` | | `SB_SPRAM256KA` | 44 | an iCE40 vendor primitive — no source anywhere | | `PLLE2_ADV` | 32 | a Xilinx vendor primitive — likewise | Over all files the list also shows `uvm_pkg::*` (220) and `uart_reg_pkg::*` (214) — a verification library and a generated register package, neither checked into the corpus. Every one of these is a workspace that genuinely does not contain the definition; none is a lookup this layer got wrong. **Properties the test asserts** (not the percentages): no panic anywhere; `build` twice over the same sources gives byte-identical file ids, counts and symbol fingerprint; every single answer's `name_span` slices back to exactly the name the reference spells, in the file the answer names; build under 5 s; and more than half of all external candidates answered on clean files. ## Status / TODO - [x] `crates/vlog_semantic/src/workspace.rs`: `WorkspaceIndex::build` over `(PathBuf, &str)` pairs, tolerant parse inside - [x] Units indexed: modules, packages, file-scope typedefs — duplicates kept, path-sorted disambiguation order - [x] Members indexed: package exports (params, typedefs, enum variants, functions, tasks, nets, vars) and module ports/params - [x] Per-file `` `define`` tables + workspace-wide `find_define` - [x] `resolve_external` → `ExternalResolutions` overlay keyed by `ReferenceId`, `Semantics` untouched - [x] Composed `definition_of`, `workspace_symbols`, `members_of` - [x] Unit tests: cross-file instantiation, cross-file port, wildcard and explicit import, package member, enum variant, duplicate → `Ambiguous`, broken file, empty workspace, rebuild after edit, path-order independence, define lookup - [x] Corpus acceptance: build time, counts, resolution rate, determinism, every answer's span slices back to the name - [x] TODO.md §6 workspace-index checkbox - [ ] Deferred (non-goals above): `` `include`` graph, incrementality, elaboration ## Work log **2026-08-19 — dev agent.** Built `workspace.rs` and `tests/workspace.rs`. Key decisions, all argued above: - **Overlay, not mutation.** The task named this; the argument that made it obviously right is invalidation: the two layers go stale on different events. - **Members are indexed for modules too**, not only packages. The single-file layer emits an external candidate for every `.port` of every instantiation of an out-of-file module, and on this corpus those are a large share of all external candidates — indexing ports and params costs one `matches!` arm and converts them. Restricted to ports and params so an internal net of another module never becomes reachable. - **First path wins; ambiguity is per-path.** Consistent with the single-file rule for two competing in-file imports. Ambiguity is reserved for the thing it really means — the same name declared in more than one file. - **`FileId` follows sorted paths**, assigned after sorting inside `build`, so determinism does not depend on the caller and "disambiguation order" is simply ascending `FileId`. - **Empty `name_span`s are dropped** rather than indexed: the single-file layer documents an empty span as "the name is not literally spelled here", and an editor sent to a zero-width range is worse than no answer. - **`find_define` returns all definitions.** No include graph exists, so any single answer would be a guess; the table is a home for the lookup, not a policy. Two additive items in the existing crate API (`ReferenceId`, `Semantics::reference`/`reference_id_at`) — an overlay needs a key, and `reference_at` returned only a `&Reference`, which cannot be used as one. Checks at the end: `cargo test -p vlog_semantic` 46 tests green (6 scan unit + 19 behavior + 1 vlog-semantic corpus + 20 new), `cargo clippy -p vlog_semantic --all-targets` silent, `cargo fmt -p vlog_semantic -- --check` clean, `cargo test --workspace` green (19 test binaries, 0 failures). Mid-run the parser agent's `name_span` change landed and briefly broke `vlog_parser`/`bind.rs` compilation. Per the task brief this module did not adopt the new AST fields; it depends only on `vlog_semantic`'s own `Symbol.name_span`, so it needed no change once their work compiled again. ## QA log **2026-08-19 — QA agent.** Verified every claim in the review request. No BLOCKING findings (no silent corruption, no wrong definition target, no nondeterminism). Two minor, non-blocking findings below. **Gates (`-p vlog_semantic`).** - `cargo test -p vlog_semantic`: **46/46 green** — 6 `scan` unit + 1 corpus + 19 `semantics` + 20 `workspace`, matching the claim exactly. - `cargo clippy -p vlog_semantic --all-targets`: silent. - `cargo fmt -p vlog_semantic -- --check`: clean. - `cargo test --workspace`: green, 19 test binaries (16 with tests + 3 doc-test binaries at 0 tests each), 0 failures. Ran clean on the first try; no vlog_parser churn observed during this pass. - `git diff -- crates/vlog_semantic/src/lib.rs crates/vlog_semantic/src/model.rs`: confirmed additive-only — `mod workspace;`, the `workspace::*` re-export block, `ReferenceId` (new struct in `model.rs`), and `Semantics::{reference, reference_id_at}` are all new; nothing renamed or removed. (`bind.rs` also has unrelated non-additive edits adapting to the concurrent parser's `name_span`/`ImportPath` change — outside this feature's scope, not evaluated here, and not part of the workspace-index diff.) **Corpus numbers — reproduced exactly, 3 runs:** ``` workspace index: 860 files in 0.70s / 0.70s / 0.69s — 521 modules, 63 packages, 38 file-scope typedefs, 8044 exported members, 502 define directives ``` Every count byte-identical across all 3 runs; times within the claimed 0.68–0.71 s band. Full headline table (every file / clean files) reproduced exactly: 73708/14325(19.4%)/81.4%(75.4%+6.0%)/18.6%/3.6% and 46408/9101(19.6%)/87.0%(78.9%+8.1%)/13.0%/2.6% — matches the README table and work-log figures to the decimal. Spot-checked the ambiguity claim independently: `corpus/ibex/vendor/lowrisc_ip/ip/prim_generic/rtl/` and `.../prim_xilinx/rtl/` do contain the same file basenames (`prim_and2.sv`, `prim_buf.sv`, `prim_clock_buf.sv`, `prim_flop.sv`, `prim_pkg.sv`, ...) — the OpenTitan ambiguity claim is real corpus structure, not asserted blind. **Attack probes (18 scratch tests, `crates/vlog_semantic/tests/qa_probe.rs`, written, run, and deleted — no trace left in the tree):** - Same module name in 3 files, **4 permuted input orderings**: all kept (`units("dup").len() == 3`), ascending `FileId`, `FileId` order == path order (`a_first.sv` < `b_second.sv` < `c_third.sv`) regardless of caller order, and the resulting `Vec` byte-identical across all 4 orderings. - Garbage-only file (`@@@ !!! not verilog`): 1 file id, 0 declarations, no panic. Unlexable file (unterminated string): still gets a file id and an empty define table, no panic. - Same path handed twice with **different content** (not just identical content, which is all the existing suite covers): one file in the index either way; content of the **first entry in the caller's input order** wins (verified both orderings — first-wins is consistent with `build`'s `sort_by` being a stable sort over equal keys, then `dedup_by` keeping the first of each run). Matches the documented "first copy wins" rule. Not silent corruption — deterministic and exactly what the README promises. - Package member name shadowing a module name workspace-wide: `units()` and `member()` are confirmed separate namespaces — `units("shadow")` sees only the module, `member("p", "shadow")` sees only the package member, no cross-contamination. - Empty-string source: 1 file id, zero of everything, no panic. Zero-member package (`package p; endpackage`): unit indexed as `Package`, `members_of` empty, `member("p", anything)` empty — no panic on an empty child scope. - `import p::absent_member` where `p` is declared in another file but has no such member: **2** external candidates come out of this one import statement — the path head `p` itself (resolves fine to the package, since `p` really is in the workspace) and the tail `absent_member` (`ExternalTarget::StillUnresolved`, confirmed via `overlay.get`). Compared against the in-file equivalent (`p` declared in the *same* file, `p::absent_member` used): `resolve.rs`'s `Target::PackageMember` arm returns `Resolution::NotFound` directly when the package is known locally and lacks the member — it never becomes an `ExternalCandidate` at all (`overlay.counts()` is `(0, 0)` for that reference). So the two layers are *behaviorally* consistent (both end in "no target" for a real absence) but *representationally* different: in-file collapses to `NotFound` before the overlay ever sees it, cross-file surfaces as `StillUnresolved` because `ExternalTarget` has no `NotFound` variant to distinguish "no such member" from "no such package in the workspace either." This asymmetry is not documented anywhere in the README's Resolution rules section. **Minor, non-blocking** — the observable behavior (no definition offered) is correct either way, but a future consumer inspecting `ExternalTarget` variants alone cannot tell "package exists, member doesn't" from "package doesn't exist in the workspace at all." Worth a one-line mention in Resolution rules or Assumptions if the lead wants it; not fixed here per the write-scope restriction on this pass (QA log only). - `find_define("K")` defined in 3 files with 3 different values: all 3 returned, in file-path order (`a.svh` < `m.svh` < `z.svh`), not value order and not any other ranking — confirms "no resolution order is implied" as documented. **Overlay correctness (3-file scratch workspace: A instantiates B, imports `p::*`, uses `p::K` and absent `q::Z`):** - Instantiation of `b` in A resolves via `definition_of` to `Definition::External` pointing at B.sv, `name_span` slices to exactly `"b"`. - `K` resolves to `Definition::External` pointing at P.sv, slices to `"K"`. - `q::Z` (q not declared anywhere): `definition_of` returns `None`, and the underlying overlay entry is confirmed `ExternalTarget::StillUnresolved` (not just "None for some other reason"). - A local symbol (`localparam int SHARED` inside the module) shadowing an imported package member of the same name: `definition_of` returns `Definition::Local` pointing at the in-file declaration — two-layer precedence (local always wins over the overlay) confirmed. - `reference_id_at(offset)` round-trips: any offset inside a reference's name span maps to the same `ReferenceId`, and `sem.reference(id)` gives back the right reference. **`workspace_symbols` probes:** - True substring match (not prefix-only): `"FIFO"` matches `my_fifo_thing` (match in the middle of the name). - Case-insensitive both directions: `"FIFO"` and `"fIfO"` both match `my_fifo_thing`. - Empty query: matches both units and members (confirmed a package unit and one of its members both appear). - A query matching a unit and a member of the same spelled name (`"shadow"` module vs. `p::shadow` param, same fixture as the namespace probe): both appear, exactly 2 hits, one with `container: None` and one with `container: Some("p")` — no cross-contamination in `workspace_symbols` either. - `"zzz"` (no match): empty result, no panic. **Determinism stress:** corpus index counts identical across 3 independent full 860-file builds (see corpus numbers above); a 3-file local workspace built 5× in a row gives byte-identical `IndexCounts` every time; the corpus test's own internal build-twice-and-fingerprint-`workspace_symbols("")` assertion also passed. No nondeterminism found anywhere probed. **CLAUDE.md compliance:** - No `unwrap()`/`expect()`/`panic!` anywhere in `workspace.rs` (grepped, zero hits) — library code paths return `Option`/empty slices instead, as required. - README has all required sections (Goal, Assumptions, Handshakes, Status/TODO, Work log, QA log, Review) present and populated. - TODO.md §6 "Workspace index for cross-file navigation" checkbox: checked, and the summary line under it (87% of external candidates, 19.6%→2.6%, 0.7s/860 files) matches the reproduced corpus numbers exactly — honest. - The stale out-of-scope line noted in `docs/features/vlog-semantic/README.md` (line 223, "Requested of `vlog_parser` — not done here — out of scope for this...") was located but **left untouched** per instructions — lead's call, not this feature's file. - One doc-comment gap found: `IndexCounts` in `workspace.rs` (around line 238) has doc comments on `files`, `typedefs`, `members`, `defines` but **not** on `pub modules: usize` or `pub packages: usize` — the only two undocumented public fields found in the whole module. **Minor, non-blocking**, self-explanatory field names, not fixed here per the write-scope restriction (docs/features/workspace-index/README.md QA log only, no source edits this pass). **Verdict: PASS on all 6 claims.** No blocking findings. Two minor, non-blocking documentation gaps noted above for the lead/dev to close: (1) `IndexCounts::modules`/`IndexCounts::packages` missing doc comments, (2) the cross-file-vs-in-file `NotFound`/`StillUnresolved` asymmetry for "package known, member absent" is real, consistent in effect, but undocumented. ## Review **2026-08-19 — lead. Verdict: accepted; commits jointly with name-spans (round 10). The owner's cross-file requirement — `import pkg::*;` at the top of a file resolving anywhere in the workspace — is now met.** Points reviewed and accepted: 1. **The two-layer overlay design** is the architectural decision of the round: `Semantics` stays a pure single-file fact, the overlay is keyed by `ReferenceId`, and the two invalidate on different events (this buffer vs. any other file). That's the shape an editor actually needs, and it kept the whole feature additive — QA confirmed nothing in the existing API was renamed or moved. 2. **FileIds assigned after path sort** makes determinism a property of the data, not the caller — QA's permuted-input and same-path-different-content probes are exactly the attacks that design defeats. 3. **Ambiguity kept, not resolved**: OpenTitan's prim_generic vs prim_xilinx duplicates are real, and handing all locations to the LSP (which supports several) is more honest than inventing a ranking. Same reasoning accepted for `find_define` being unranked without an `` `include`` graph. 4. **87% of external candidates answered** (19.6% → 2.6% on clean files), with the residue traced to named causes — the `ifdef-in-port-list parse gap (roadmap item 6) and genuinely absent sources. The acceptance metric was measured against the number the vlog-semantic review set, which is how these baselines are supposed to work. Lead fixes on acceptance: the two missing `IndexCounts` doc comments, and QA's notable finding — `StillUnresolved` not distinguishing package-absent from member-absent — is now documented as a deliberate ruling in the API sketch above (both mean "no target" to an LSP; add a variant when a diagnostic needs it, not speculatively). With this, TODO §6's foundations are all delivered: spans, tolerant parsing, define table, single-file semantics, workspace index. What remains is the server itself and editor packaging.