TODO §65.2 closed by ruling: LSP references are scope-relative by design; tests pin both scopes
Root cause (lane A): not the fan-out. The default index scope (`folder`, depth 2) opened from hw/ip/aes/dv/tb/tb.sv indexes hw/ip/aes only, so the three *_pd_main.sv tops are never walked; with index.scope "workspace" the LSP answers 14/12, equal to the whole-set engine. Ruled out: the 1 MiB cap, autogen/ignore rules, the multi-line instantiation. The owner kept the design; the index.scope setting now says a rename of a module instantiated outside the scope leaves those sites unchanged. Tests: server/tests/references_scope.rs (3: the LSP equals the engine over the same file set in both scopes, a module rename reaches the top under `workspace`), tests/opentitan_references.rs (2, ignored: 14/12 workspace, 11/9 default). lucisv_server 1 865 passed, 0 failed; node 8/8. docs/features/references-fanout-pd-main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
ec492cdd86
commit
51b975bf68
6 files changed
+602
-8
No files matched your search
@@ -0,0 +1,140 @@
|
||||
# references-fanout-pd-main
|
||||
|
||||
## Goal
|
||||
|
||||
TODO §65.2 (topo §2.9-36, MCP-6): on opentitan, `textDocument/references` at
|
||||
the `aes` instantiation in `hw/ip/aes/dv/tb/tb.sv` and at its `.clk_i`
|
||||
connection answered 11 and 9 locations, while the whole-set engine
|
||||
(`vlog_refactor::find_references` over every file, as `lucisv-mcp`'s
|
||||
`references` runs it) answered 14 and 12 — the same plus the three generated
|
||||
tops `hw/top_{earlgrey,darjeeling,englishbreakfast}/rtl/autogen/*_pd_main.sv`.
|
||||
Find the cause, fix it at the cause, and pin the answer.
|
||||
|
||||
## Root cause
|
||||
|
||||
**It is the index scope, not the fan-out.** The language server runs on the
|
||||
shipped default `lucisv.index.scope: "folder"` with `scopeDepth: 2`
|
||||
(`settings.rs` `DEFAULT_SCOPE_DEPTH`, ladder in `state/scope.rs`). Opening
|
||||
`hw/ip/aes/dv/tb/tb.sv` raises its folder two levels to **`hw/ip/aes`**, and
|
||||
that is the whole index: the three `*_pd_main.sv` tops are never walked, so
|
||||
no index table (units, instantiations, reference postings, words) knows them.
|
||||
`lucisv-mcp` hands the engine every file under the root, which is the
|
||||
`"workspace"` rung's set. The two answers are over different file sets; over
|
||||
the same set they are identical.
|
||||
|
||||
This is the documented behaviour of `docs/features/index-scope` ("cross-file
|
||||
answers are scope-relative … `find_references` and a workspace rename all
|
||||
answer within the active scope"; migration line `"lucisv.index.scope":
|
||||
"workspace"`), chosen 2026-08-27/28 for scan cost.
|
||||
|
||||
Evidence (release `lucisv-server` built at ec492cd, LSP client driving it over
|
||||
stdio, root `ot/hw`, `tb.sv` opened, positions `45:3` `aes` and `50:6`
|
||||
`clk_i`, after the scan's progress end plus 5 s):
|
||||
|
||||
| scope | `aes` | `.clk_i` | files listed |
|
||||
|---|---|---|---|
|
||||
| default (`folder`, depth 2) | 11 | 9 | all under `hw/ip/aes/` |
|
||||
| `index.scope: "workspace"` | **14** | **12** | the 11/9 + `darjeeling_pd_main.sv:1521/1538`, `earlgrey_pd_main.sv:2069/2086`, `englishbreakfast_pd_main.sv:933/950` |
|
||||
|
||||
The workspace-scope answer is exactly MCP-6's 14/12 list. Ruled out, as the
|
||||
lead's pre-investigation suggested: the 1 MiB size cap (the tops are
|
||||
62–141 kB and are indexed under the workspace scope), `.gitignore`/the walk
|
||||
(`autogen` is walked under the workspace scope), and the multi-line
|
||||
`aes #( … ) u_aes (` shape (indexed and answered under the workspace scope).
|
||||
`state/sources.rs` (`module_sources`, `rename_sources_traced`, `fan_out_of`)
|
||||
and `nav.rs`'s indexed-references path are correct: within the scope they
|
||||
equal the engine over `Workspace::sources()`.
|
||||
|
||||
**Rename has the same scope relation and no gap of its own.** Probe over the
|
||||
same checkout: a rename of `aes` from `tb.sv:45` edits 14 sites in 9 files
|
||||
under the workspace scope (the three tops included) and 11 sites in 6 files
|
||||
under the folder scope. The latter is the sharper consequence: under the
|
||||
default scope a module rename from the testbench would leave the three tops
|
||||
instantiating a module that no longer exists. That is the index-scope
|
||||
README's stated trade-off, but it is a correctness hazard for a write, not
|
||||
only an incomplete read — flagged for the lead below.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- "The whole-set engine" means `vlog_refactor::find_references` over every
|
||||
file the client's root holds, as `lucisv-mcp` runs it; the server's answer
|
||||
is compared to it over the same file set.
|
||||
- The folder scope's documented behaviour stands until the lead rules
|
||||
(Handshakes); nothing in this lane changes which files are indexed.
|
||||
|
||||
## Handshakes
|
||||
|
||||
- **Ruling request → lead (the fix is outside this lane's files).** The
|
||||
cause is the shipped default scope, which lives in
|
||||
`crates/lucisv_server/src/settings.rs` (`IndexScope::default`,
|
||||
`DEFAULT_SCOPE_DEPTH`) and `state/scope.rs`, and is a product decision
|
||||
recorded in `docs/features/index-scope`. Not edited. Options:
|
||||
1. **Keep the design; close §65.2 as scope-relative by design.** The tests
|
||||
below pin both halves. Optionally document it where users meet it (the
|
||||
VS Code setting's description, the README's LSP section).
|
||||
2. **Widen only for writes.** A cross-file rename (and port refactorings)
|
||||
on a unit whose instantiations may exist outside the folder scope runs
|
||||
against the workspace walk, or refuses with "outside the index scope —
|
||||
set `lucisv.index.scope: workspace`". Closes the hazard above without
|
||||
changing read latency. Touches `state/sources.rs` (`fan_out_of` /
|
||||
`rename_sources_traced`) and the rename handler.
|
||||
3. **Change the default to `"workspace"` when the client has roots.**
|
||||
Restores pre-2026-08-27 behaviour; costs the full scan the index-scope
|
||||
round removed (opentitan: ~4 000 files; the persistent cache and the
|
||||
interleaved scan now bound it). `settings.rs`, the index-scope README,
|
||||
release notes.
|
||||
- Consumed, unchanged: `Workspace::sources()`, `WorkspaceIndex::files()`,
|
||||
`vlog_refactor::find_references`. No handshake changed.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] Reproduce at the LSP level (11/9 default scope; 14/12 workspace scope)
|
||||
- [x] Root cause named: the folder index scope (`hw/ip/aes`), not the fan-out
|
||||
- [x] Rename's fan-out checked: same scope relation, no separate gap
|
||||
- [x] Fixture regression tests (`server/tests/references_scope.rs`, 3 tests)
|
||||
- [x] Ignored opentitan test (`tests/opentitan_references.rs`, 2 tests)
|
||||
- [ ] Fix — pending the lead's ruling (Handshakes); no code fix was needed in
|
||||
`sources.rs`/`nav.rs`
|
||||
- [ ] QA
|
||||
|
||||
## Work log
|
||||
|
||||
- **2026-10-19 (dev).** Fast-forwarded the lane worktree from 75d2d37 to the
|
||||
wave's base ec492cd (TODO-only commit). Built release `lucisv-server` and
|
||||
drove it with a scratch stdio LSP client: default scope 11/9, all locations
|
||||
under `hw/ip/aes/`; `index.scope: "workspace"` 14/12, exactly MCP-6's list.
|
||||
So the gap is the scope, and the fan-out code is correct — nothing in
|
||||
`sources.rs` or `nav.rs` changed. Rename probe: 9 files/14 edits (workspace)
|
||||
vs 6 files/11 edits (folder) for `aes`; the `.clk_i` rename under the
|
||||
workspace scope refuses over an unrelated implicit `.clk_i` binding in
|
||||
`hw/ip/keymgr_dpe/dv/tb.sv` (the existing safety refusal), under the folder
|
||||
scope it edits 16 sites in 6 files.
|
||||
Tests: `server/tests/references_scope.rs` — opentitan's shape in miniature
|
||||
(`ip/blk/rtl/blk.sv`, `ip/blk/dv/tb/tb.sv`, `top/rtl/autogen/top_pd_main.sv`
|
||||
with a multi-line `blk #( … ) u_blk (`): (1) whole workspace: LSP ==
|
||||
engine over every file, for the module name and `clk_i`, each from its
|
||||
declaration and from a use, and the top is listed; (2) folder scope: the top
|
||||
is not in the index, LSP == engine over `Workspace::sources()` at the same
|
||||
four positions, the top absent; opening the top widens the scope and the
|
||||
answer becomes the whole set's; (3) whole workspace: a module rename from
|
||||
the testbench edits the top. `tests/opentitan_references.rs` (ignored, skips
|
||||
without the checkout): pins 14/12 with the three tops under the workspace
|
||||
scope, and 11/9 all-in-`hw/ip/aes` under the default. Ran both ignored tests
|
||||
against `~/.cache/lucisv-eval/ot`: pass (17.8 s, debug); with
|
||||
`LUCISV_OPENTITAN=/nonexistent` both skip and pass.
|
||||
|
||||
## QA log
|
||||
|
||||
## Review
|
||||
|
||||
**2026-10-19 — lead (owner's ruling).** The owner chose **keep as
|
||||
designed**: cross-file answers stay relative to the index scope, and §65.2
|
||||
is closed as scope-relative by design rather than as a defect. The lane's
|
||||
tests are merged as the pin of both halves (the workspace scope equals the
|
||||
whole-set engine, the folder scope equals the engine over the scope, the
|
||||
opentitan 14/12 vs 11/9). The rename consequence is now said in the
|
||||
`lucisv.index.scope` setting's description (a rename of a module
|
||||
instantiated outside the scope leaves those instantiations unchanged). No
|
||||
production code changed, so no QA lane was run; the lead reviewed the
|
||||
tests.
|
||||
|
||||
Reference in new issue
Block a user