`tb.dut.g_sw[0].buf_q` written in a file that does not declare `tb` now resolves like an instance path: the binder marks a dotted path's head (Target::PathHead), resolve/root.rs answers a plain lexical miss with a hierarchical external candidate, head_site roots the spine there, and fold_path walks it — every hop a module/interface surface. find_references, LSP references and rename see every segment; $root.tb works; a local `tb` shadows. FACTS_FORMAT 22. Rooted only when the root is provable (owner's ruling: conservative): not when the head has an import candidate (so `import uvm_pkg::*` with uvm_pkg outside the project stays warned — opentitan's DV force paths behave as before), not from inside a class, not beside a macro that stands where a declaration could (item, statement, port list), not when the root name is also a package or ambiguous. The LSP rename set adds the files of the path's root and middle hops (sources.rs, WorkspaceIndex::path_units_to). An unresolved path is warned once. QA (Opus) x2: F1-F4 and R1 silent-wrong-rename shapes fixed with tests; QA's attack cases 1-6 each warned or correctly renamed; lucisv check hw byte-identical to master. Completion after `tb.` deferred (TODO §65.8). tools/gates.sh: PASS, 15 steps, 5 180 tests, corpus 814/820. docs/features/top-rooted-paths. Co-Authored-By: Claude Opus 5.5 <[email protected]>
top-rooted-paths
TODO §65.4 (from §65.1 QA F1). Wave 0.62.0 (§65.7), serial after lane A.
Goal
A hierarchical path whose head is a top-level module declared in another
file — tb.dut.u_x.sig, the shape every opentitan DV force, $deposit
and uvm_hdl_* path takes (IEEE 1800 §23.6: a top-level module name is the
root of a hierarchical name) — resolved nothing: tb was a Target::Lexical
use that missed in the writing file, resolve::head_site stopped the spine
there, no segment after it was a reference, and a rename of dut's
declarations left the path behind (since §65.1 with a warning). The goal is
that such a path resolves through the workspace exactly as an instance path
does, so find_references and LSP references list its segments and rename
rewrites them, while a root the workspace does not declare stays unchanged
and is warned about.
Design
- The head is its own target.
bind/expr.rs: the bare identifier that heads a dotted path (ExprKind::Memberwhose base is anIdent) is bound asTarget::PathHeadinstead ofTarget::Lexical. Only the head of a dotted path: a bare identifier anywhere else is unchanged, so a value-position miss is still never swept through the unit table (the reasonlexical's doc gives). Thewith/bindfunnel inbind/mod.rs::use_membertreatsPathHeadexactly asLexical. resolve/root.rs(new) holds the root rules. The governing rule (lead, after QA): a path is rooted only when this file shows the head can be nothing but a top-level module or interface; in doubt it is not, and the path stays unresolved and warned about.roots_at_top(scopes, from): false when any scope from the use up to the file is a class (a member, inherited or macro-declared, is never a provable path into the hierarchy; a class in a package may not reference it at all) or holds an unexpanded macro invocation where a declaration could stand (Scope::macro_items, set byBinder::mark_macro_declarationsfor an item, a statement or block item in anybegin/end,fork, task or function body, and a port-list entry or an unreadable port element; it may declare the name). A macro inside an expression or used as a data type cannot declare a name and does not block.path_head: the lexical answer; on a plainNotFoundthatroots_at_topallows, the candidateExternalCandidate { paths: [head], surface: Hierarchical }. An import candidate (import p::*in scope, which by the LRM could supply the name) is left exactly aslexicalgave it, whether or not the workspace can answer it; so is anInheritedCandidate.unit_root: the siteMemberSite::Unit { path: head, surface: Hierarchical }.$root.tb.…:top_site/top_modulelooktbup at file scope only (an in-file module or interface), else the workspace unit.$rootskips the lexical walk, so a localtbdoes not capture$root.tb.
resolve.rs::head_site: on a plainNotFoundthatroots_at_topallows (the same rule as the head's own reference) the resolution walk answersroot::unit_root(head), so the head reference and the segments after it are rooted in one unit; anything else roots nothing. The workspace'sfold_paththen walkstb→dut's type → … exactly as for an instance path. A system name or a macro ($unit,`TOP) roots nothing.- The completion walk is unchanged.
member_site(whatSemantics::member_siteand the completion popup call) and the resolution walk sharespine_site, parameterised byHeadMiss:member_ofpassesTopModule,member_sitepassesNothing. A popup after an unknown head keeps answeringNone(so the ordinary tiers run), which the server's completion tests pin; offeringtb.'s members is a server-side change (Handshake H2).$root.tb.is rooted in both walks. - Only a module or an interface is a root, and a package is never a
hop.
workspace/external.rs: a bare path equal to the name on the hierarchical surface (only a path head produces one) answers throughroot_units— all instantiable, else nothing. Andfold_path, on the hierarchical surface, checks every unit it stands in (design_unit): the first must be declared and only as modules/interfaces; a later one may not be a module and something else at once (the member table is keyed by name and would merge the two). A later unit that is only a package would need a declaration typed with a package's name, which is not code; the separate "never a package" clause was dropped as unreachable (QA M7). So with a module and a package both namedtbthe head and every segment answer nothing, andpk.xwith only a packagepkresolves to nothing (QA F1). - The rename's file set (LSP):
WorkspaceIndex::path_units_to(def)(new,workspace/path_units.rs) lists every unit an indexed hierarchical use ofdefwalks through — the root and each hop's type — read off the facts the index holds.lucisv_server/src/state/sources.rs:: want_declarationadds those units' declaring files, so a three-hoptb.dut.u_core.sigresolves inside the rename's set as in the whole (QA F3; lead-granted). A unit outside the index scope adds nothing, and the path stays warned about. - An accurate refusal (
vlog_refactor/src/rename/mod.rs): a rename asked at a path segment the workspace could not walk is refused with "xis a segment of a hierarchical path lucisv could not resolve to one declaration …", not "declared outside the files lucisv indexes". FACTS_FORMAT21 → 22 (facts.rs, reason written there): no new field, but new records — a 0.61.0 store would answer as though no DV file'sforce tb.dut.…named anything.- The §65.1 path warning (
vlog_refactor/src/rename/paths.rs): a segment of a top-rooted path (head is$root, or the head's reference is a root candidate) whose overlay answer isStillUnresolvedcounts as unresolved, so the warning still fires for a root the workspace does not declare, or declares several times. AnAmbiguousanswer is not flagged: when it can name the renamed declarationcollect_occurrencesalready refuses the rename. - Said once (Handshake H1, lead-granted):
warnings.rs'sunresolved_candidate_warningsskips a candidate thatpaths::names_top_rooted_misssays the path scan names, so such a line carries only the §65.1 path warning. The file is lexed for that check only when an unanswered candidate is on the hierarchical surface.
What resolves now
tb.dut.g_sw[0].buf_qin a file that does not declaretb, with exactly onemodule tb(orinterface tb) in the set:tb→ the module,dut→ the instance,g_sw→ the block,buf_q→ the variable. Every segment is a reference:find_referenceslists it,renameof any of the four declarations (or from the segment itself) rewrites it, verified as usual.$root.tb.dut.…, the same, and$root.tb.xagainst an in-filetb.- Not rooted, by the rule above, and left warned exactly as before §65.4: a head an import could supply, a head inside any class, a head in (or under) a scope holding an item-level macro invocation, a head named both a module and a package, and a package alone.
Limits
- Several
module tbin the set (opentitan: 70 files underhw/):tbisAmbiguous,tb.dutnames 70 instances, andmember_unit_inrefuses an ambiguous hop, so nothing after the head resolves; the rename leaves the path and warns. Choosing thetbwhose branch has the next member was considered and rejected: the whole-treegen_sw_assignscase is ambiguous betweenkeymgrandkeymgr_dpeanyway, and anAmbiguousanswer that can name the renamed declaration makescollect_occurrencesrefuse the whole rename — so branching would turn today's warnings into refusals for every common member name. - A renamed top module's
tbheads are references to it. With several same-named tops a rename of one is refused as ambiguous (pinned:renaming_one_of_two_same_named_tops_is_refused); before, the heads wereNotFoundand only the declaration was renamed. - Any wildcard import in scope stops rooting — including the
import uvm_pkg::*;nearly every opentitan DV interface starts with. By the LRM such an import could supply the head, anduvm_pkgis not in the tree for the index to rule it out, so the path is doubt. Measured: on opentitanhw(and inhw/ip/keymgr_dpe) the reference postings are exactly master's — no DV force path roots. Rooting when every supplying import is indexed and shown not to hold the head is possible future work; it would not change opentitan whileuvm_pkgis outside the tree. - Any macro where a declaration could stand blocks rooting from its
scope down (lead's R1 ruling): a
`uvm_infostatement in the block beside aforceblocks it too, since the binder cannot tell a logging macro from a declaring one. A macro statement in an unnamedbeginwhose statements bind in the enclosing scope blocks that whole scope. - Completion after
tb.answers nothing (H2, deferred by the lead). undeclared-identifierno longer sees an unknown path head asNotFound(it is a root candidate now). Measured on opentitanhw: 7 findings before and after, identical.
Assumptions
- A bare identifier followed by
.whose lexical lookup misses plainly — no import could supply it, no class or item-level macro on the scope chain — is a top-level module name (§23.6); a typo there is an unresolved candidate, notNotFound. - Only the head of a dotted path is a root;
tb[0].x(an indexed head) is not modelled as one. - The surface tag on the head candidate is the only signal that a bare path must be instantiable; nothing else produces a bare hierarchical path.
Handshakes
- Consumes:
WorkspaceIndex::member_unit_in/fold_path(unchanged),hierarchy::member(unchanged),Scope::analysis().external. - Promises (changed):
Resolution::ExternalCandidatewithsurface: Hierarchicaland a bare path is now produced for a path head;follow_oneanswers it with modules and interfaces only.Semantics:: member_siteis unchanged for every head except$root. - H1 (granted by the lead 2026-10-19, done):
warnings.rsunresolved_candidate_warningsskips a segmentpaths.rsnames (paths::names_top_rooted_miss,pub(super)), so an unresolved top-rooted path is said once, in the §65.1 wording. - F3 (granted by the lead, done):
lucisv_server/src/state/sources.rswant_declarationadds the files ofWorkspaceIndex::path_units_to(def). Promised to the server:path_units_tois a pure read of the index's facts (no file is read); its cost is one pass over the reference records of each file holding a use ofdef. - Outside the listed files, flagged:
vlog_refactor/src/rename/mod.rsgainedhierarchical/unresolved_pathso the refusal at an unresolved segment is the accurate one the lead's F3 ruling asks for (two call sites, the message only; no rename decision changes). - H2 (deferred by lead → TODO;
lucisv_server/src/completion/member.rsuntouched): to offertb.'s members, call a root-aware member site and answerNonewhen the index holds no unit for the root (the server'san_unresolvable_head_answers_nothing_at_allmust keep passing).
Status / TODO
- root lookup in
head_site, the head recorded as a module use - QA's repro renames the path instead of warning
- the §65.1 warning stays for an undeclared (or ambiguous) root
find_referencesand LSP references list the path segments- the local-shadows-top case
$root.(cheap: done)- opentitan index/scan cost before and after;
FACTS_FORMATbump reasoned - H1: an unresolved top-rooted path is said once (lead-granted)
- rework after QA: F1 (no package root or hop), F2 (an import wins), F3 (LSP rename set holds the path's units; accurate refusal), F4 (no root in a class or beside an item-level macro)
- H2: completion after
tb.— deferred by lead → TODO
Work log
2026-10-19 (dev, Opus). Worktree fast-forwarded ec492cd → 51b975b.
- Implemented as designed above.
resolve.rs559 → 586 production lines (the walk splitspine_site/HeadMiss); the root rules are the newresolve/root.rs(29). - Deviation: the planned single walk would have changed completion after an unknown head (two server tests), so completion keeps its walk (H2).
- Deviation: rooting a head on an import miss as well as on
NotFound— opentitan's DV interfaces import packages, soNotFound-only would leave the target shape unresolved. - QA's repro
a_path_rooted_at_another_files_top_module_is_never_silently_left_behindflipped to assert the rename (granted). Other §65.1 tests that used a declaredtbas the vehicle for an unresolved root now droptb.svfrom their set (so the root is genuinely undeclared) and gained the declared counterpart asserting the rename:qa_generate_label.rs(three rechecks),qa_warning_scope.rs(two),rename_generate_label.rs(two, wording),generate_blocks.rs/member_access.rs(an unknown head's tail is now a candidate, not absent), serverrename_generate_label.rs(shown wording). - Invariant 4:
vlog_refactor/src/check/untouched. - Tests:
vlog_semantic/tests/top_rooted_paths.rs(13),vlog_refactor/tests/top_rooted_paths.rs(8), one declared-root counterpart inqa_generate_label.rs,vlog_refactor/tests/ opentitan_top_rooted.rs(3, ignored),lucisv_server/src/server/tests/ references_top_rooted.rs(5). Counts before → after:vlog_semantic401 → 414 (4 ignored),vlog_refactor727 → 736 (3 → 6 ignored),lucisv_server1 865 → 1 870 (40 ignored),lucisv_mcp383 → 383;vlog_linter673 → 673. Gates: fmt, clippy-D warnings, the four suites green. Onelucisv_serverrun lost twolarge::linear-time tests to host load (load average 14–16, another lane's suites); the re-run was green.
Opentitan (eval clone ~/.cache/lucisv-eval/ot, read-only; release;
engine API, nothing written — vlog_refactor/tests/opentitan_top_rooted.rs,
ignored by default):
before (51b975b) |
after | |
|---|---|---|
rename gen_sw_assigns, set hw/ip/keymgr_dpe (23 files, the LSP folder scope) |
1 site in 1 file; warnings: uvm_info macro arg :523, path :514,515,517 |
4 sites in 2 files (label + keymgr_dpe_if.sv:514,515,517); warning: uvm_info :523 only |
same, set hw (3 979 files, 70 module tb) |
1 site; 4 warnings (2 macro args, 2 path lines keymgr_if.sv:468,469,471, keymgr_dpe_if.sv:514,515,517) |
1 site; 4 warnings, the same 4 (6 before H1: the 2 candidate lines for the same sites) |
rename time, hw |
2.16 s | 2.23 s |
facts, hw (encoded) |
54 297 047 B | 54 465 816 B (+0.31 %) |
index postings reference_sites / keys |
528 532 / 60 559 | 528 719 / 60 573 |
WorkspaceIndex::build, hw, best of 3 |
1.65 s | 1.69 s |
lucisv check hw wall, two runs each |
1.050 / 1.051 s (re-run 1.059 / 1.063) | 1.064 / 1.065 s |
lucisv check hw findings |
1 158 | 1 158, byte-identical output |
check --select undeclared-identifier hw |
7 | 7, identical |
The host was shared with another lane's suites (load average 14–16), so the sub-2 % time deltas are within noise.
2026-10-19 (dev, Opus) — H1. Lead granted H1, deferred H2.
paths::names_top_rooted_miss (pub(super), wraps is_segment +
top_rooted_miss) is asked by warnings.rs::unresolved_candidate_warnings
for each unanswered hierarchical candidate; a hit is skipped. The tests that
tolerated the duplicate now assert exactly one line again
(qa_generate_label.rs recheck, rename_generate_label.rs back to
warnings.len() == 1, top_rooted_paths.rs two, server
an_unresolved_path_in_an_open_buffer_is_shown_as_a_rename_warning back to
probe.sv:2: with no "more"), plus a new
an_unresolved_top_rooted_path_is_named_by_exactly_one_warning (QA's repro
undeclared, and with three module tb), and the opentitan whole-tree probe
asserts the force lines are said once. Opentitan rename gen_sw_assigns
over hw: 6 → 4 warnings (2 macro arguments, 2 path lines), 1 site,
2.16 s; IP folder unchanged (4 sites in 2 files, 1 warning). Counts:
vlog_refactor 737 (6 ignored), lucisv_server 1 870 (40), lucisv_mcp
383 (4) — its a_rename_names_each_same_named_file_by_its_root_relative_path_once
passes with the two path lines and no candidate lines. fmt and clippy clean.
2026-10-19 (dev, Opus) — rework after QA. Governing rule (lead): root only when the engine can show the head is a top module or interface.
- F1 (
workspace/external.rs):fold_pathchecks every unit on the hierarchical surface (design_unit): first unit declared and all modules/interfaces; later units never a package nor mixed. Tests: semantica_package_never_lends_a_top_rooted_path_its_members; refactorqa_f1_a_package_sharing_the_roots_name_lends_the_path_nothing(QA's B12: renaming the package'sdut, the module's instancedut, orxleavestb.dut.xand names it),qa_f1_a_package_is_never_a_root(A3/A4). - F2 (
resolve/root.rs,resolve.rs::head_site): an import candidate is never rooted, and the "bare name last" fallback is gone. Tests: semantican_import_in_scope_wins_and_roots_nothing(replacesan_import_in_scope_is_tried_before_the_top_module); refactorqa_f2_an_imported_head_is_never_rooted_at_a_same_named_module(A1). - F3 (
workspace/path_units.rsnew,lucisv_server/src/state/sources.rs,vlog_refactor/src/rename/mod.rsmessage): server testsrename_top_rooted_scope.rs(5, folder scope): three-hop rename from the declaration and from the segment, the generate-blockbuf_q, LSP equals engine over the scope, and a root outside the scope (warned; segment rename refused with "hierarchical path", not "declared outside"). With thesources.rsrung disabled four of the five fail. - F4 (
Scope::macro_items,roots_at_top): semantica_head_inside_a_class_or_beside_a_macro_item_roots_nothing(A11, D2, A12, and a macro one scope out); refactorqa_f4_a_head_this_crate_cannot_see_is_never_rooted. - Mutations:
design_unitandroots_at_topboth forced true → both F1 refactor tests and the F4 test fail;head_siterooting an import candidate again → the F2 test fails. - Changed tests:
rename_generate_label.rsgenblk1 refusal accepts the new message; the opentitan probe's IP-folder test is nowthe_ip_folder_leaves_the_imported_head_and_says_so. - Counts:
vlog_semantic416 (4 ignored),vlog_refactor741 (6),lucisv_server1 875 (40),lucisv_mcp383 (4),vlog_linter673 (0); fmt and clippy-D warningsclean; every suite through the guard, exit 0. - Opentitan:
lucisv check hwstdout and stderr byte-identical to master's binary (1 158 lines);--select undeclared-identifieridentical (7).rename gen_sw_assigns: IP folder 1 site, 2 warnings (uvm_info:523, path :514,515,517 —keymgr_dpe_if.svimportsuvm_pkg::*); wholehw1 site, 4 warnings, 2.13 s — both exactly master's. Index overhw:reference_sites528 532 / keys 60 559, equal to master; facts 54 333 266 B (+36 KB, the head candidates).
2026-10-19 (dev, Opus) — rework 2 (R1, M7).
- R1:
Binder::mark_macro_declarations(scope)(bind/mod.rs) is now called for an item-level macro (bind/item.rs), a macro statement (bind/stmt.rs,StmtKind::MacroStmt, on the scope the statement binds in) and a header port list holding a`-spelled port or an error element (bind/item.rs::port_list_may_hide_declarations, on the module's scope). Tests: semantica_macro_where_a_declaration_could_stand_roots_nothing(E1, E2, E6, E3 twice) anda_macro_that_cannot_declare_the_head_still_roots(data-type macro, sibling generate block E7, a macro inside an expression); refactorqa_r1_a_macro_where_a_declaration_could_stand_blocks_rooting(E1, E2, E6 left and named; E3 left) andqa_r1_a_macro_off_the_scope_chain_or_as_a_type_still_renames(E7, E8 shape). With both new flag sites disabled the refactor R1 test fails. - M7: the later-hop "never a package" clause in
design_unitdropped as unreachable (argued in its doc comment); the mixed module+package rule still refuses QA's B12, pinned by the F1 tests. - QA's cases1–6 re-run against this build (QA's harness
scratchpad/qa654/attack, outputs inscratchpad/p654/cases{1..6}.out). Every rename either rewrites the correct sites or leaves the path and warns:- A1, A3, A4, A7, A8, A10, A11, A12: left and warned. A2: the package variable renamed with its use (correct). A5, A6, A9: the head is a local (clocking block, interface port, virtual interface handle), the path is another declaration, nothing to warn (correct).
- B1, B7, B8, B10: renamed correctly (local
tbelsewhere warned in B1). B2, B3:$rootpaths renamed; the local-tbline warned; twotbrefused. B4: five colliding renames refused. B5: the instance-array path warned, the unpacked array and the instance array name renamed. B6 (bind) and B9 (forward local) warned. B11: warned. B12: both renames leavetb.dut.xand warn. - C1: renamed from the declaration, the segment and the label; refs list all three sites.
- D1: the unshadowed module's path renamed, the shadowed one warned. D2,
D3 (struct field), D6 (typo head): warned; D3's
accrenamed. D4, D5: renamed correctly. - E1, E2, E3, E4, E5, E6: left and warned. E7 (sibling block) and E9
(modport macro): renamed, correctly. E8 (data-type macro): the head is
the local
st, warned as an unresolved candidate. - F3 (
cases6): eachsigrename edits exactly its own references.
- Counts:
vlog_semantic418 (4 ignored),vlog_refactor743 (6),lucisv_server1 875 (40),lucisv_mcp383 (4),vlog_linter673 (0); fmt and clippy-D warningsclean; every suite through the guard, exit 0. - Opentitan
lucisv check hw: stdout and stderr byte-identical to master's binary (1 158 lines);--select undeclared-identifieridentical (7).
QA log
2026-10-19 — QA agent (Opus).
Verdict: conditional pass. F1 needs a fix before release, and the lead
should rule on F2–F4. Everything else held: the
verifier, the shadow and $root rules, the cache bump, opentitan byte
identity, and every guard mutated.
Gates (worktree as handed over, 51b975b + dev diff; every suite through
tools/guard.sh, guard exit 0 each, logs kept):
cargo fmt --all --checkclean, andclippy --workspace --all-targets -D warningsclean.- Suites:
vlog_semantic414 passed (4 ignored),vlog_refactor737 (6),lucisv_server1 870 (40),lucisv_mcp383 (4),vlog_linter673 (0). All 0 failed, and every count matches the work log. No host stall.
Tests read. The new semantic, refactor and server tests assert what their
names say: exact file:line sets, the exact texts after the edit, and
warning counts. Flipped tests:
qa_generate_label.rsandqa_warning_scope.rsnow droptb.sv, so the root is really undeclared, and each gained a declared counterpart. That is sound.- The server rename test covers only the block label
g_sw, which is one hop below the root's child. That is exactly the case F3 does not hit.
Mutations. Each was applied in a scratch copy of the workspace
(scratchpad/qa654/ws), never in this tree, and each ran the semantic,
refactor and server suites:
- M1: remove the module/interface-only rule in
root_units. Caught by 1 semantic test (only_a_module_or_an_interface_is_a_root); 0 refactor or server failures. - M2: a local of the head's name no longer shadows, in both
path_headandhead_site. Caught by 70 semantic and 37 refactor failures. - M3:
$root.tbignores an in-filetb, intop_siteandtop_module. Caught by 1 semantic test (dollar_root_reaches_a_top_module_this_file_declares). - M4:
$root.tbgoes through the lexical walk, so a localtbcaptures it. Caught by 2 semantic tests (dollar_root_names_the_top_module_and_skips_the_lexical_walkand the previous one). - All four are caught. M1 and M3 are each pinned by a single unit test, and nothing at the rename level pins them.
Verifier (invariant 4; check/ untouched). 8 masked-corruption attacks
went into a scratch-only check/qa_top_rooted.rs over dut_a / tb /
probe (tb.dut.buf_q ×2 and $root.tb.dut.buf_q). All 8 behaved: three
honest edit sets verify, and every corrupt one is refused:
- a leaf rename missing each one of the 3 path segments, or missing the declaration;
- a top-module rename missing each one of the 3 heads, or also renaming a
local
logic tb; - an instance rename missing each segment.
Opentitan (~/.cache/lucisv-eval/ot, read-only, git status clean before
and after):
lucisv check --no-cache hw. Master51b975b, built in a scratchgit worktreethat has since been removed, and this branch both print 1 158 lines. stdout and stderr are byte-identical.--select undeclared-identifier. Identical, 7 findings.find_referencesat 48 seeded random positions. Half of them follow a., overhw/ip/{keymgr_dpe,aes,uart,i2c}. Before and after are byte-identical.- Targeted top-rooted positions. These were
pwrmgr_if.sv:191tb.dut.u_slow_fsm…, andotp_ctrl_if.sv:169/287andtb.sv:248undertop_earlgrey/ip_autogen/{pwrmgr,otp_ctrl}. Every difference is a segment of a top-rooted path that now has references where it had none. For example,gen_partitionswent from no symbol to 12 references (10 force and release lines,tb.svand the RTL label), andu_slow_fsmwent from none to 4. - No other names changed.
FACTS_FORMAT 22. The server ran over one fixture first with master's
binary (format 21), then with this branch. The new server analysed every
file afresh, with no cached: lines, and answered with the new references.
A second run of the new server read its own cache. The unit tests
index_cache.rs:846 and qa_m6.rs:367 already reject every older format.
Code.
- No new
unwrap,expectorpanic. The index arithmetic inpaths.rspath_headandmatching_openis guarded. - Production lines:
resolve.rs586, which is under 600 but at the mark, so the next arm goes in a module.resolve/root.rsis 29,paths.rs158,warnings.rs555,external.rs224. warnings.rs::unresolved_candidate_warningsis now about 79 lines, including its doc comment. That is just under the 80-line investigate mark (Info).
Findings
-
F1 (High): silent wrong rename and silent miss when a module and a package share the root's name. Location:
vlog_semantic/src/workspace/external.rs:337-342(follow_one, the multi-segment branch).- What
root_unitsguards: only the bare head pathtb. - What it misses: the next segment's path
tb::dutfoldstband asksmember_chainon the hierarchical surface, which answers from the package. - Repro:
module tb; dut_a dut (); endmodule,package tb; logic dut; endpackage, andother.sv:initial force tb.dut.x = 0;.- Renaming the package's
duttod2rewrites the path totb.d2.x, which is wrong because the path names the module's instance. No warning. - Renaming the module's instance
duttou_dutleaves the path, also with no warning, because it resolved to a different declaration. - Before §65.4 neither edit touched the path, and the path was warned about.
- Renaming the package's
- The same root cause makes
pk.x, with a packagepkand no module (illegal code), resolve into the package, and renaming the package member rewrites it (A3/A4, Low on their own). - This contradicts the Design bullet "Only a module or an interface is a root".
- Suggested direction, the dev's to choose: apply the instantiable check to the first hop of a hierarchical candidate rooted at a top. Then add a rename-level test, because M1 is caught only by the semantic suite.
- What
-
F2 (Medium, a documented limit, but a silent wrong rename): an imported package variable used as a head, next to a same-named module. Location:
vlog_semantic/src/resolve.rs:408(head_siteroots onExternalCandidateas well as onNotFound).- Repro:
package p; typedef struct packed {logic field;} s_t; s_t cfg; endpackage,module cfg; logic field; endmodule, anduser.sv:import p::*; assign o = cfg.field;. - The head
cfgresolves top::cfg, the package variable, but the tailfieldresolves to the module'sfield. - Renaming the module's
fieldtofld2rewritescfg.fieldtocfg.fld2with no warning. Before, the tail had no reference. - The head and its tail disagree about the root, which is detectable. The
tail could carry the head's import paths first (
p::cfg::field, thencfg::field), or rooting could be refused when the head's own answer is not a unit.
- Repro:
-
F3 (Medium, loud): LSP rename misses the files of the path's middle hops. Location:
lucisv_server/src/state/sources.rs:235-285(fan_out_of/want_declaration; outside this lane's files, so this is a Handshake request).- The rename set holds the declaration, the reference postings and the
instantiation sites of the container. It does not hold the root's file
(
tb.sv) or a middle hop's file. Inside the rename, the root is then undeclared. - Repro, fixture
ip/rtl/{core,dut_a}.sv,ip/dv/{tb,probe}.sv, whereprobe.svhasforce tb.dut.u_core.sig = 1'b0;, under the default folder scope:- LSP references on
core.sv'ssiglistprobe.sv:2. - LSP rename of
sigeditscore.svonly and warns "probe.sv:2: a hierarchical path throughsigwas not resolved…". - Rename from the segment in
probe.svis refused with "sigis declared outside the files lucisv indexes", which is misleading.
- LSP references on
- The same happens for
buf_qinsideg_sw: references listprobe.sv:2,3, and rename edits the declaration only. top_sig(one hop) andg_sw(the label) rename fine.- The Goal's own shape
tb.dut.u_x.sigis the failing one, and most opentitan force paths are deeper than one hop. The engine API (and solucisv-mcp) renames them correctly over the whole set. - Not silent, because it is warned, but references and rename disagree over LSP.
- The rename set holds the declaration, the reference postings and the
instantiation sites of the container. It does not hold the root's file
(
-
F4 (Low–Medium, by the §23.6 assumption): a head the binder cannot see now roots silently. Location:
vlog_semantic/src/resolve/root.rs:24(path_head) withresolve.rs:408.- Before, these were the §65.1 path warning. Now each is renamed silently
through a same-named module:
- a class without
extendswhosecfgcomes from a macro (A11:`DECLARE_CFGthencfg.en); - a module whose struct
stcomes from`DECL_STRUCT(st)(A12); - a class in a package writing
tb.dut.x(D2). That is illegal (a package may not reference the hierarchy), but it is renamed anyway.
- a class without
- A cheap narrowing: do not root inside a class scope. Opentitan's DV classes all live in packages, where no head can legally be a top module.
- Before, these were the §65.1 path warning. Now each is renamed silently
through a same-named module:
-
F5 (Low, documented).
undeclared-identifierno longer reports an unknown path head (tbb.dut.x), which is now an unresolved candidate. The rename still warns, and the opentitan count is unchanged (7).
Held (no finding).
- Locals shadow. A local
tbnet (same file or another) shadows and is warned. A forward-declared local instancetbshadows. - Labels and other heads. A named block
blkbeatsmodule blk. A clocking blockcb.data, a modport / interface port head and avirtual bus_if vifhead all stay local. A genvar or parameter head, andf().x, are warned. - Classes. An extending class leaves the head alone and warns.
bindand$root. Abindhead is warned (the BindScope funnel).$root.tbwith a localtbreaches the top, and$unit::is unaffected.- Renaming the root and its instance. Renaming
tbrewrites every head and$root.tb, and skips localtbs. Twomodule tbis refused. A colliding rename of a leaf, the instance or the top is refused (5 cases).tb.dut.x = yrenamedx→ycorrectly. - Arrays. An instance array
u[2].xis not descended and is warned.mem[3]and the instance array name itself rename. A struct field throughacc[1].rlis warned. - Interfaces and upward names. An interface top works, and so does an
upward module-name reference (
par.sigfrom a child). - LSP references. Correct with the declaring file open or closed. Under
workspacewith twotb, they answer nothing and rename is refused. - H1. The dedupe predicate is equivalent to the path scan's, and the path scan's text prefilter trims newlines, so a multi-line path is not lost.
Fixes made by QA: none. Scratch harnesses: scratchpad/qa654/attack
(case files cases1–4.txt), refs_{new,base}, lspfx*, probe2.py.
2026-10-19 — QA agent (Opus), re-check after "rework after QA".
Verdict: pass for F1–F4 as reworked. One new Medium finding needs the lead's ruling (R1: a macro that is not item-level can declare the head), and there are two Info notes. No QA fixes were made.
Gates. Every suite ran through the guard with exit 0.
cargo fmt --all --checkandclippy --workspace --all-targets -D warningsare clean.- Suites:
vlog_semantic416 (4 ignored),vlog_refactor741 (6),lucisv_server1 875 (40),lucisv_mcp383 (4),vlog_linter673 (0). All 0 failed, and every count matches the work log.
The old attacks, re-run against the new build (cases1–4, plus LSP
lspfx, lspfx2).
- F1 is fixed. B12 (a module
tbbeside a packagetb): renaming the package'sdutor the module's instancedutnow leavestb.dut.xand warns about it, both ways. A3 and A4 (pk.xthrough a package) now warn, and the segment refuses. - F2 is fixed. A1: the imported
cfgkeeps its head. Renaming the module'sfieldleavescfg.fieldand warns, and the segment has no reference. - F4 is fixed. A11 (a class with a macro member), A12 (a macro item in a module) and D2 (a package class) are all warned again, as before §65.4.
- F3 is fixed. The three-hop
tb.dut.u_core.sigrenames over LSP from the declaration and from the segment: 2 edits in 2 files, equal to the references. So does the generate-blockbuf_q(3 edits in 2 files). Underworkspacescope with twotb, the segment refusal now says "segment of a hierarchical path…". - Every other round-1 case is byte-identical to round 1. That covers
B1–B11, D1, D3–D6,
$root, the shadows, the collisions and the arrays.
New attacks.
- F3's wider set (
lspfx4).- The fixture puts an unrelated
sigin every hop file:tb.sv(a localsig, plusdut.siganddut.u_core.sig), anddut_a.sv(its ownsig, plusmodule helperwith asig). - Renaming
core's,dut_a's ortb'ssigover LSP edits exactly the references, and the engine over the whole set gives the same edits. helperis never touched, and neither is the unrelatedsigin any hop file.
- The fixture puts an unrelated
- A macro beside a head that is not item-level (
cases5.txt). These are the R1 cases:- E1:
initial begin `DECL_LOCAL(st) st.a = 1; endbesidemodule st; logic a;. Renamingst.a'satobrewritesst.atost.bsilently. - E2 and E6: the same inside a task body and a function body.
- E3:
module user (`MY_PORTS, output logic o); … bus.databesidemodule bus. The rename rewrites it silently.
- E1:
- Macro shapes that hold or are warned.
- Held: a macro in a non-ANSI port region (E4), a macro at file scope (E5), and a macro used as a data type (E8).
- Rooted, and correctly so: a macro in a sibling generate block (E7) is not in the head's lexical chain.
- A macro inside a modport list (E9) still roots. A modport declares no variables, so this is no finding.
Mutations (scratch copy, re-synced):
- M5:
roots_at_topwithout its class check. Caught by 1 semantic test andqa_f4_…. - M6:
roots_at_topwithout its macro check. Caught by the same two tests. - M7:
design_unit's later-hop "never a package" clause removed. Not caught by any of the three suites (Info). A later hop's unit is an instance's or a variable's type, and a module and package sharing a name is already refused by the mixed check. So the clause looks unreachable short of an instance of a package (malformed code). Either pin it with such a test or drop it.
Opentitan (read-only, git status clean):
lucisv check --no-cache hw. Against master51b975b(scratch worktree, removed afterwards), stdout and stderr are byte-identical, 1 158 lines each.--select undeclared-identifieris identical.find_referencesspot checks. The 48 seeded positions are identical to master. The round-1 top-rooted positions (pwrmgr_if.sv:191,otp_ctrl_if.sv:169/287) now answer exactly as master, because those interfaces importuvm_pkg::*and the owner's conservative ruling applies.- Info: on opentitan's DV interfaces the feature is therefore dormant; every one imports a package.
Code.
- No new
unwrap,expectorpanic. - Production lines:
resolve.rs587 (at the mark),resolve/root.rs38,external.rs240,workspace/path_units.rs50,state/sources.rs176.
Findings
- R1 (Medium, silent wrong rename; the lead to rule): a macro that is not
item-level can declare the head.
- Location:
vlog_semantic/src/resolve/root.rs:40(roots_at_top) andbind/item.rs(onlyItemKind::MacroItemsetsmacro_items). - What escapes it:
- a macro statement in a
begin/end, task or function body, where a block-item declaration is legal (E1, E2, E6); - a macro in an ANSI port list (E3).
- a macro statement in a
- These root the head at a same-named module and rename through it silently. Before §65.4 they were warned about.
- Narrowing would follow the same rule as F4: a macro statement in any enclosing procedural scope, and a macro in the port list, also count as doubt.
- The coordinator's brief says statement macros were left out by design. E1–E3 show that they can declare the head, so the trade-off is the lead's call. It needs a module sharing the head's name, which is rare in RTL.
- Location:
Review
2026-10-19 — lead. Accepted after two reworks. QA (Opus) found four
silent-wrong-rename shapes (F1 a package sharing the root's name; F2 an
imported head beside a same-named module; F4 heads the binder cannot see)
plus the LSP rename set missing the middle hops (F3); its re-check found R1
(a statement-level or port-list macro declaring the head). All fixed with
tests built from QA's repros; QA's cases1–6 re-run against the final build
are each warned or correctly renamed. Owner's ruling: stay conservative —
a head with an import candidate (e.g. import uvm_pkg::* with uvm_pkg not
in the project) is doubt and not rooted, so opentitan's DV force paths stay
warned exactly as before; the feature applies where the root is provable.
lucisv check hw byte-identical to master. Granted handshakes: rename/ warnings.rs (H1, said once), lucisv_server/src/state/sources.rs (F3),
the message in rename/mod.rs. H2 (completion after tb.) deferred as
TODO §65.8.