diff --git a/README.md b/README.md index ca7e647..2ecb371 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,12 @@ trailing `/` (matches directories only), and `!` negation. **Not** supported: git's "already-tracked files are never ignored" rule. See `docs/features/parallel-files/README.md` for the exact subset. +Directory walks enter each directory once by identity, so symlink cycles +terminate. Inputs resolving to one canonical file path are processed once. +Unreadable directories or `.gitignore` files and dangling source links found +during a walk warn on stderr and are skipped without changing the exit code; +a missing explicitly named input is still an error. + ## Configuration Settings live in a `lucisv.toml` (or `.lucisv.toml`) file, ruff-style. For each diff --git a/TODO.md b/TODO.md index 33a577f..7365aea 100644 --- a/TODO.md +++ b/TODO.md @@ -4896,11 +4896,158 @@ hierarchical surface. Nothing else changes what it sees. hierarchically from a DV bench, timing before/after, and the count of newly resolved references over `hw/ip/aes`. -- [ ] 49.1 surface bit in facts, FACTS_FORMAT bump, index member walk -- [ ] 49.2 `MemberOf` behind an instance reads the hierarchical surface; +- [x] 49.1 surface bit in facts, FACTS_FORMAT bump (18 → 19), index member + walk — `workspace/hierarchy.rs`, a second `hier_members` table +- [x] 49.2 `MemberOf` behind an instance reads the hierarchical surface; rename edits the tail; the warning retired for resolved tails -- [ ] docs: feature README; topo §2.9-23 struck (lead); record.rs's - export doc rewritten -- [ ] Gates (guarded); census delta explained; opentitan timing -- [ ] QA: the shapes above over the wire; the connection-list completion +- [x] docs: feature README (`docs/features/hierarchical-tail/README.md`); + topo §2.9-23 struck (lead — strike text in the README); record.rs's + export doc rewritten (the ruling moved to `hierarchy::surface_of`) +- [x] Gates (guarded): 3 839 tests / 0 failed / 44 ignored (baseline 3 829, + +10 new); corpus 814/820, the same six; `format --stdout` of all 860 + corpus files byte-identical to `lucisv-0.44.0`, 0 differing; clippy and + fmt clean; release server smoke OK. Census: single-file corpus census + unmoved (860 / 27 486 / 103 875 / 1 197 / 0), index gains 5 239 + hierarchical-only members beside an unchanged 12 939, and 335 corpus + references resolve that could not before. opentitan (read-only, + requests never applied): `lc_ctrl`'s `fsm_state_q` rename now names + `dv/tb.sv` as well as `rtl/lc_ctrl_fsm.sv` (10 → 22 ms; prepareRename + unmoved); over `hw/ip/aes` the newly resolved count is **0** (every + `aes` hierarchical path goes through a generate block or a `bind`) and + rename is 41 → 55 ms for the same answer; over all of `hw/` 514 + references newly resolve; store +10.7 % on `aes`, +6.2 % on `lc_ctrl` +- [x] QA: the shapes above over the wire; the connection-list completion unchanged; rename verifier refusals unchanged; opentitan before/after + +## 55. Filed 2026-09-05 — `lucisv_server/src/state.rs` over the size threshold + +The §49 dev measured `crates/lucisv_server/src/state.rs` at 957 production +lines outside tests, over the 800 "consider splitting" mark and past the +§28 decomposition note in CLAUDE.md (which is stale for it). A pure-move +decomposition round (Fable refactor-dev, per the refactor policy): the +scope/widen logic, the document store, and the source selectors +(`module_sources`, `rename_sources`) are three sentences. Not planned; the +owner decides where it goes in loop 2. + +- [ ] `state.rs` decomposition (pure move, byte-identical output, test + count unchanged); CLAUDE.md's measurement line refreshed + +## 50. `.*` expansion (planned 2026-09-05) — the first §8 refactoring + +One lane after 0.45.0, §36's protocol. Feature README: +`docs/features/expand-wildcard/README.md`. Ships in 0.46.0 with §51. + +A wildcard connection `sub u_x (.clk(clk), .*);` binds every remaining +port to the same-named signal in scope (IEEE 1800 §23.3.2.4). Expanding it +writes those bindings out — the refactoring people reach for before a +port list diverges, and the one the ports engine already refuses to edit +around (`add`/`remove` warn and leave `.*` sites alone; `propagate` +declines a wildcard site). + +- **Engine** (`vlog_refactor::ports`, new `expand.rs` beside + `propagate.rs` — the closest sibling: it already computes "the ports the + instantiation does not name" from the instantiated module's declaration): + `expand_wildcard(files, file, offset) -> Result`. + At the cursor's instantiation: refuse unless the connection list holds a + `.*`; take the instantiated module's port list (through `Scope`, the + fan-out reader `propagate` uses); for every port not explicitly + connected, emit `.name(name)` when a signal `name` is declared in the + instantiating scope (the wildcard's own rule: same name, in scope, any + kind — net, var, port, parameter is *not* a signal); a port with no + same-named signal in scope is what the wildcard would have left + unconnected → emit `.name()` and a warning naming it (the compiler + would have errored; saying so is the point of the expansion). Replace the + `.*` token with the generated connections in the port's declaration + order, one per line when the list is already multi-line, inline + otherwise — then let the formatter's verified splice do the layout + (the ports engine's lexical splice + "the file still parses" rule, + README §"How an edit is made"). The `.*` element's comments (before/after + slots) go on the first generated connection. +- **Refusals** (the verifier's whole-edit rule): the instantiated module + unknown or declared twice; a parse diagnostic in either file; a port + list carrying compiler directives (`ListDirective` — the same refusal + `instantiation_plan` makes); an instance with more than one `.*` (illegal); + a `.*` inside a `bind` directive (out of scope, say so). +- **Server:** a code action `lucisv: expand .* (N connections)` offered at + a `.*` under the cursor, through the lazy offer path (§37.1: the offer + reads the buffer + the declaration, `resolve` computes the edit); a + command `lucisv.expandWildcard [uri, position]` for clients without + code actions; the VS Code extension needs nothing new (commands are + discovered). Title count from the plan. +- Tests: engine — a three-port module with one explicit and `.*`; all + ports present in scope; one missing (`.name()` + warning); a port whose + same-named signal is a *parameter* (not bound — pin per the LRM); + nested/generate instantiation; multi-line vs inline lists; comments on + the `.*`; the five refusals; idempotency of the result (formatting the + edited file changes nothing further); the formatter's byte contract on + three corpus files edited in a scratch copy. Server — offer + resolve + over the wire; the command; opentitan read-only: count the `.*` sites + under `hw/ip` and expand ten of them into scratch copies, each result + formatting cleanly and parsing with the same instance count. + +- [ ] 50.1 `expand_wildcard` engine + refusals +- [ ] 50.2 code action (lazy) + command +- [ ] docs: feature README; README/site rows (lead applies); §8 line + annotated +- [ ] Gates (guarded); byte-identity vs 0.45.0 +- [ ] QA: the LRM rule attacked (kinds, scopes, generate, parameters); + refusals; ten opentitan sites in scratch copies + +## 51. Non-ANSI → ANSI port conversion (planned 2026-09-05) — the second §8 refactoring + +One lane after §50 merges, §36's protocol. Feature README: +`docs/features/ansi-conversion/README.md`. Ships in 0.46.0. + +A Verilog-2001 header `module m (a, b, c);` with body declarations +`input a; output [7:0] b; inout c;` (and optionally `reg b;` beside the +`output`) becomes `module m (input a, output reg [7:0] b, inout c);` with +the body declarations removed. The ports engine already edits headers of +both shapes (`ports/add.rs::header_edits`: the ANSI list, the non-ANSI +list plus the body declaration) and its lexical splice + "the file still +parses" verifier is the safety net; this is the whole-header version. + +- **Engine** (`vlog_refactor::ports`, new `ansi.rs`): + `convert_to_ansi(files, file, offset) -> Result` on + a module whose header is `PortList::NonAnsi`. For each header name in + header order: find its body `PortDecl` (direction, net type or `reg`/ + `logic`, signing, packed dims — from the port declaration and, when a + separate `reg`/`wire`/`logic` declaration of the same name exists, its + type merged per IEEE 1800 §23.2.2.2: `output [7:0] b; reg [7:0] b;` → + `output reg [7:0] b`); emit the ANSI port; delete the body declarations + it absorbed (whole items, with their trailing comments moved onto the + ANSI port's slot — comments are never dropped). Leading comments of a + body declaration go before the ANSI port on its own line if the list is + multi-line, else are the reason to refuse (say so). +- **Refusals:** a header name with no body declaration (an implicit port — + illegal); a body declaration for a name not in the header; a port + declared twice; a non-ANSI port whose header entry is an expression or + concatenation (`.a({x,y})`, `{x,y}` — §23.2.2.1 port expressions: refuse + with the reason); a `PortDecl` with an unpacked dimension differing from + its variable declaration; any compiler directive in the header or in an + absorbed declaration; a body declaration inside a generate or + conditional region; an `interface`/`program` (out of scope in this + round, say so); the module declared twice in the workspace (the port + engine's own rule); a parse diagnostic in the file. +- **Server:** code action `lucisv: convert ports to ANSI (N ports)` offered + with the cursor anywhere in a non-ANSI module's header, lazy per §37.1; + command `lucisv.convertToAnsi [uri, position]`. +- Tests: engine — the LRM examples of §23.2.2.2 (each merge rule), a + header with 20 ports and mixed declarations, comments on every absorbed + declaration (all kept, positions pinned), `reg` and `logic` and `wire` + variants, signed, packed dims, a `parameter` between the declarations + (untouched), every refusal, idempotency (the result formats unchanged; + re-running the action refuses because the header is ANSI); the corpus: + count non-ANSI modules (`PortList::NonAnsi`) and convert every one in a + scratch copy — each result parses, formats, and has the same port names + in the same order (a census assertion, not a byte one). Server — offer + + resolve over the wire; the command; opentitan read-only: the count of + non-ANSI modules under `hw/vendor` and ten conversions into scratch + copies. + +- [ ] 51.1 `convert_to_ansi` engine + refusals +- [ ] 51.2 code action (lazy) + command +- [ ] docs: feature README; README/site rows (lead applies); §8 line + annotated +- [ ] Gates (guarded); byte-identity vs 0.45.0; the corpus conversion census +- [ ] QA: every §23.2.2.2 merge rule attacked; comments; refusals; the + corpus census re-derived; opentitan scratch conversions diff --git a/crates/lucisv_server/src/completion/member.rs b/crates/lucisv_server/src/completion/member.rs index 58b359e..f28b556 100644 --- a/crates/lucisv_server/src/completion/member.rs +++ b/crates/lucisv_server/src/completion/member.rs @@ -14,7 +14,7 @@ use std::collections::HashSet; use lsp_types::CompletionResponse; use vlog_parser::token::{Token, TokenKind}; -use vlog_semantic::{MemberSite, Semantics, SymbolKind, WorkspaceIndex}; +use vlog_semantic::{MemberSite, Semantics, Surface, SymbolKind, WorkspaceIndex}; use super::site::balanced; use super::tiers::innermost_scope; @@ -168,6 +168,14 @@ fn members_at( site: &MemberSite, ) -> Vec { let mut members = Members::new(); + // A cross-file site says which surface its own tail resolution reads, and + // the list follows it: behind `u_x.` in an *expression* that is the + // module's hierarchical surface — its nets, variables and instances as + // well as its ports and parameters — which is exactly what the in-file + // `MemberSite::Scope` half above offers for an instance this file + // declares. A connection list's `.` never arrives here; it is + // `connection_members` below, and it is the connection surface. + let mut surface = Surface::Connection; let base = match site { MemberSite::Scope(scope) => { let (scopes, base) = semantics.member_scopes(*scope); @@ -181,10 +189,13 @@ fn members_at( // overlay's own inheritance chase does. base.map(|path| last_segment(&path).to_string()) } - MemberSite::Unit(unit) => Some(unit.clone()), + MemberSite::Unit { path, surface: reads } => { + surface = *reads; + Some(path.clone()) + } }; if let Some(unit) = base { - for (name, def) in index.members_of_chain(&unit) { + for (name, def) in index.members_of_chain_in(&unit, surface) { members.push(name, def.kind, indexed_detail(def.kind, def.type_name.as_deref())); } } @@ -983,6 +994,53 @@ endmodule assert_eq!(clk.detail.as_deref(), Some("port"), "table-only across files"); } + /// **§49's completion decision, and its limit.** Behind `u_sub.` in an + /// *expression* the list is the module's **hierarchical** surface — its + /// nets, its variables and its instances as well as its ports and its + /// parameters — because that is what a hierarchical path may name and + /// exactly what the tail resolution will find, so every item offered is + /// an item hover and go-to-definition answer. Behind the `.` of a + /// **connection list** it is the connection surface and nothing more: + /// `.internal(w)` is not a legal connection, and an item the resolution + /// could not find is a wrong answer rather than a generous one. + #[test] + fn an_instance_head_lists_the_hierarchical_surface_and_a_connection_list_does_not() { + const SUB: &str = "module sub (input logic clk);\n wire internal;\n int counter;\n leaf u_leaf ();\nendmodule\n"; + let hierarchical = { + let tree = Tree::new("hiersurface_expr"); + tree.write("sub.sv", SUB); + tree.write("leaf.sv", "module leaf;\nendmodule\n"); + let top = "module top;\n sub u_sub ();\n initial y = u_sub.;\nendmodule\n"; + let (_tree, ws, uri, position) = opened(tree, top, "= u_sub."); + let mut found = labels(&items(completions(&ws, &uri, position, true))) + .iter() + .map(|l| l.to_string()) + .collect::>(); + found.sort(); + found + }; + assert_eq!( + hierarchical, + vec!["clk", "counter", "internal", "u_leaf"], + "the port and the three hierarchical-only members" + ); + + let connection = { + let tree = Tree::new("hiersurface_conn"); + tree.write("sub.sv", SUB); + tree.write("leaf.sv", "module leaf;\nendmodule\n"); + let top = "module top;\n sub u_sub (\n .\n );\nendmodule\n"; + let (_tree, ws, uri, position) = opened(tree, top, " ."); + let mut found = labels(&items(completions(&ws, &uri, position, true))) + .iter() + .map(|l| l.to_string()) + .collect::>(); + found.sort(); + found + }; + assert_eq!(connection, vec!["clk"], "the connection list is the port list, unchanged"); + } + #[test] fn an_interface_instance_lists_its_ports_too() { let tree = Tree::new("ifaceconn"); diff --git a/crates/lucisv_server/src/rename.rs b/crates/lucisv_server/src/rename.rs index a8a8235..c6fee29 100644 --- a/crates/lucisv_server/src/rename.rs +++ b/crates/lucisv_server/src/rename.rs @@ -795,11 +795,16 @@ mod tests { /// workspace was never consulted), so the file should not even be pulled /// in — and if it were, the rename must still succeed, since no capture is /// possible against a symbol nothing outside that file can see. + /// + /// The symbol is a **function's** local, not a module's net: since + /// 2026-09-05 a net is a declaration on the module's hierarchical surface + /// and joins the fan-out by that rung (the test below), which would answer + /// this one for the wrong reason. A name inside a subprogram body is on + /// neither surface, which is what this attack needs. #[test] fn a_local_only_symbol_sharing_the_new_names_spelling_is_not_a_bogus_refusal() { const PKG: &str = "package cfg_pkg;\n parameter int DEPTH = 4;\nendpackage\n"; - const LOCAL_ONLY: &str = - "module unrelated;\n wire taken_local;\n assign taken_local = 1'b0;\nendmodule\n"; + const LOCAL_ONLY: &str = "module unrelated;\n function automatic int f();\n int taken_local = 0;\n return taken_local;\n endfunction\nendmodule\n"; let tree = Tree::new("fanout_local_only"); let files = [("pkg.sv", PKG), ("local.sv", LOCAL_ONLY)]; let (ws, _) = tree_with(&tree, &files, &["pkg.sv"]); @@ -816,6 +821,32 @@ mod tests { assert!(edit.edits_for(&tree.path.join("local.sv")).is_empty()); } + /// The rung the hierarchical surface added: a module's internal **net** + /// spelled like the new name *is* a declaration the fan-out has to hold, + /// because `assign w = u_unrelated.taken_net;` in a fourth file resolves + /// to it now. So the file is pulled in — and the rename still succeeds + /// and still writes nothing there, because a package name and a net + /// inside a module capture nothing of each other. + #[test] + fn a_module_net_sharing_the_new_names_spelling_joins_the_fan_out_and_refuses_nothing() { + const PKG: &str = "package cfg_pkg;\n parameter int DEPTH = 4;\nendpackage\n"; + const NET_ONLY: &str = + "module unrelated;\n wire taken_net;\n assign taken_net = 1'b0;\nendmodule\n"; + let tree = Tree::new("fanout_hierarchical_net"); + let files = [("pkg.sv", PKG), ("net.sv", NET_ONLY)]; + let (ws, _) = tree_with(&tree, &files, &["pkg.sv"]); + let path = tree.path.join("pkg.sv"); + let at = at(PKG, "cfg_pkg;"); + + let fan = fan_out(&ws, &path, at, "taken_net"); + assert!( + fan.contains(&tree.path.join("net.sv")), + "a net is a hierarchical declaration of its name: {fan:?}" + ); + let edit = same_answer(&ws, &path, at, "taken_net").expect("renames, no capture possible"); + assert!(edit.edits_for(&tree.path.join("net.sv")).is_empty()); + } + /// Attack on the old-name exemption: a shadowing/"unmasking" hunt. Two /// packages, `p_pkg` and `q_pkg`, both export a member spelled the same /// (`shared_name`); a third file imports both, `p_pkg` first, so diff --git a/crates/lucisv_server/src/state.rs b/crates/lucisv_server/src/state.rs index e1690c8..ad7c60b 100644 --- a/crates/lucisv_server/src/state.rs +++ b/crates/lucisv_server/src/state.rs @@ -1521,6 +1521,10 @@ impl Workspace { /// `follow_paths` only ever looks a reference's *own* name up, so a /// set holding every declarer of `N` resolves every reference spelling /// `N` exactly as the whole workspace does; + /// * **every file declaring `N` on a module's hierarchical surface** + /// ([`WorkspaceIndex::hierarchical_declarations`]) — an internal net + /// is not a workspace symbol, and a hierarchical tail in another file + /// resolves to one; /// * **every file with a use the index resolved to one of them** /// ([`WorkspaceIndex::references_to`]) — every file a rename can edit, /// and every file whose meaning the verifier could see move; @@ -1604,6 +1608,19 @@ impl Workspace { containers.extend(symbol.container); self.want_declaration(symbol.def, wanted); } + // And every declaration of it on a module's **hierarchical** surface, + // which `workspace_symbols` deliberately does not list: an internal + // net is not a workspace symbol, but `assign w = u_x.sig;` in another + // file resolves to one and a rename must edit both ends. Without this + // rung the fan-out would hold the file that *names* the net and not + // the file that declares it (`docs/features/hierarchical-tail`). + for (unit, def) in self.index.hierarchical_declarations(name) { + if self.index.references_are_ambiguous(def) { + return false; + } + containers.insert(unit); + self.want_declaration(def, wanted); + } self.want_sites(name, wanted); self.want_macro_text(name, wanted); for unit in containers { diff --git a/crates/lucisv_server/tests/e2e.rs b/crates/lucisv_server/tests/e2e.rs index e3cbd94..d0ce638 100644 --- a/crates/lucisv_server/tests/e2e.rs +++ b/crates/lucisv_server/tests/e2e.rs @@ -6405,7 +6405,10 @@ endclass /// An instance head: `u.clk_i` where `u` instantiates a module declared in /// another file. The instance's declared type is the module, so the port is -/// hovered exactly as a class property is. +/// hovered exactly as a class property is — and, since the hierarchical +/// surface (2026-09-05), so is `u.internal`: a hierarchical path may name a +/// module's internal net, and hover follows the same resolution the rename +/// does. #[test] fn an_instance_heads_port_is_hovered_across_files() { let dir = temp_dir("instancehead"); @@ -6455,14 +6458,11 @@ fn an_instance_heads_port_is_hovered_across_files() { assert!(port.contains("sub.sv:1"), "the port's own file and line: got {port}"); assert!(port.contains("clk_i"), "got {port}"); - // A module exports its ports and parameters and nothing else, so an - // internal net of another file answers nothing rather than something — - // the round-2 ruling in the feature README. - assert!( - response(3)["result"].is_null(), - "an internal signal is not exported across files: {:#?}", - response(3) - ); + // An internal net reached through an instance head is the hierarchical + // surface, and it answers with the net's own declaration in its own file. + let net = response(3)["result"]["contents"]["value"].as_str().expect("hover markdown"); + assert!(net.contains("sub.sv:2"), "the net's own file and line: got {net}"); + assert!(net.contains("wire internal"), "got {net}"); let _ = std::fs::remove_dir_all(&dir); } diff --git a/crates/vlog_refactor/src/rename/warnings.rs b/crates/vlog_refactor/src/rename/warnings.rs index ee2c123..e0a74ba 100644 --- a/crates/vlog_refactor/src/rename/warnings.rs +++ b/crates/vlog_refactor/src/rename/warnings.rs @@ -324,7 +324,7 @@ impl<'a> Scope<'a> { /// not about every unresolved identifier in the file. fn unresolved_unit(resolution: &Resolution) -> Option { match resolution { - Resolution::ExternalCandidate { paths } => { + Resolution::ExternalCandidate { paths, .. } => { let first = paths.first()?; Some(first.rsplit_once("::")?.0.to_string()) } diff --git a/crates/vlog_refactor/tests/rename.rs b/crates/vlog_refactor/tests/rename.rs index 0998d81..cc2f7b0 100644 --- a/crates/vlog_refactor/tests/rename.rs +++ b/crates/vlog_refactor/tests/rename.rs @@ -853,6 +853,186 @@ fn a_hierarchical_tail_that_resolves_is_renamed_with_its_declaration() { ); } +// ---------------------------------------------------------------------- +// the hierarchical surface, across files (TODO.md §49) +// ---------------------------------------------------------------------- + +/// The cross-file twin of the test above, which is the whole of §49: the +/// module and the instance that names into it are in **different** files, and +/// the edit has to land in both. Before 2026-09-05 a module exported its +/// ports and parameters only, so `u_sub.sig` could not be finished across a +/// file boundary — `sub.sv` was edited alone and `top.sv` got the §2.9-20 +/// warning instead of an edit. +#[test] +fn a_cross_file_hierarchical_tail_is_renamed_with_its_declaration() { + const SUB: &str = "module sub;\n wire sig;\n assign sig = 1'b0;\nendmodule\n"; + const TOP: &str = + "module top;\n sub u_sub ();\n wire w;\n assign w = u_sub.sig;\nendmodule\n"; + let files = workspace(&[("sub.sv", SUB), ("top.sv", TOP)]); + + for (from, text, name) in [("sub.sv", SUB, "wire"), ("top.sv", TOP, "u_sub.")] { + let edit = rename(&files, &path(from), at(text, name, "sig"), "signal") + .unwrap_or_else(|e| panic!("renames from {from}: {e}")); + assert_eq!( + apply(SUB, &edit, &path("sub.sv")), + "module sub;\n wire signal;\n assign signal = 1'b0;\nendmodule\n", + "the declaration and its own file's uses, from {from}" + ); + assert_eq!( + apply(TOP, &edit, &path("top.sv")), + "module top;\n sub u_sub ();\n wire w;\n assign w = u_sub.signal;\nendmodule\n", + "and the tail in the other file, from {from}" + ); + assert!( + !edit.warnings.iter().any(|w| w.contains("could not be resolved")), + "the §2.9-20 warning is retired for a tail that resolved, from {from}: {:?}", + edit.warnings + ); + } +} + +/// `u_a.u_b.sig`: two hops, three files. The middle hop is an **instance**, +/// which is on the hierarchical surface for exactly this reason — without it +/// `u_b` has no declared type and the walk stops one segment short of `sig`. +#[test] +fn a_nested_cross_file_hierarchical_tail_is_renamed_through_both_hops() { + const LEAF: &str = "module leaf;\n wire sig;\nendmodule\n"; + const MID: &str = "module mid;\n leaf u_b ();\nendmodule\n"; + const TOP: &str = + "module top;\n mid u_a ();\n wire w;\n assign w = u_a.u_b.sig;\nendmodule\n"; + let files = workspace(&[("leaf.sv", LEAF), ("mid.sv", MID), ("top.sv", TOP)]); + + let edit = + rename(&files, &path("leaf.sv"), at(LEAF, "wire", "sig"), "signal").expect("renames"); + assert_eq!(apply(LEAF, &edit, &path("leaf.sv")), "module leaf;\n wire signal;\nendmodule\n"); + assert_eq!( + apply(TOP, &edit, &path("top.sv")), + "module top;\n mid u_a ();\n wire w;\n assign w = u_a.u_b.signal;\nendmodule\n", + "the two-hop tail is edited" + ); + assert_eq!(apply(MID, &edit, &path("mid.sv")), MID, "and the file in between is untouched"); +} + +/// A tail naming a **port**, which is on the connection surface and therefore +/// found by *both* reads. One declaration, one answer, one edit — the check +/// that the hierarchical read consulting the connection table first is not +/// producing a duplicate. +#[test] +fn a_tail_naming_a_port_is_one_answer_and_one_edit() { + const SUB: &str = "module sub (input wire clk_i);\n wire w;\n assign w = clk_i;\nendmodule\n"; + const TOP: &str = + "module top;\n wire c;\n sub u_sub (.clk_i(c));\n wire w;\n assign w = u_sub.clk_i;\nendmodule\n"; + let files = workspace(&[("sub.sv", SUB), ("top.sv", TOP)]); + + let edit = rename(&files, &path("sub.sv"), at(SUB, "input wire", "clk_i"), "clock_i") + .expect("renames"); + assert_eq!( + apply(SUB, &edit, &path("sub.sv")), + "module sub (input wire clock_i);\n wire w;\n assign w = clock_i;\nendmodule\n" + ); + assert_eq!( + apply(TOP, &edit, &path("top.sv")), + "module top;\n wire c;\n sub u_sub (.clock_i(c));\n wire w;\n assign w = u_sub.clock_i;\nendmodule\n", + "the connection and the hierarchical tail, each once" + ); + let tail = at(TOP, "u_sub.", "clk_i"); + assert_eq!( + edit.edits_for(&path("top.sv")).iter().filter(|e| e.range.start == tail).count(), + 1, + "the tail is edited once, not once per surface: {:?}", + edit.edits_for(&path("top.sv")) + ); +} + +/// The same for a **parameter**, the other half of the connection surface. +#[test] +fn a_tail_naming_a_parameter_is_renamed_across_files() { + const SUB: &str = "module sub #(parameter int W = 8) ();\nendmodule\n"; + const TOP: &str = "module top;\n sub u_sub ();\n localparam int N = u_sub.W;\nendmodule\n"; + let files = workspace(&[("sub.sv", SUB), ("top.sv", TOP)]); + + let edit = + rename(&files, &path("sub.sv"), at(SUB, "parameter int", "W"), "WIDTH").expect("renames"); + assert_eq!( + apply(SUB, &edit, &path("sub.sv")), + "module sub #(parameter int WIDTH = 8) ();\nendmodule\n" + ); + assert_eq!( + apply(TOP, &edit, &path("top.sv")), + "module top;\n sub u_sub ();\n localparam int N = u_sub.WIDTH;\nendmodule\n" + ); +} + +/// The honest refusal, pinned. A net declared inside a **generate block** is +/// not a member of the module: its scope is the block's, and the member table +/// records a unit's own scope only. `u_x.gen_b.sig` therefore does not +/// resolve, the tail is left as written, and the rename says so rather than +/// editing half a design. Widening this means teaching the index about +/// generate scopes and their loop indices (`u_x.gen[0].sig`), which §49 +/// deliberately did not do. +#[test] +fn a_generate_block_scoped_net_named_through_an_instance_is_refused_honestly() { + const SUB: &str = concat!( + "module sub;\n", + " if (1) begin : gen_b\n", + " wire sig;\n", + " end\n", + "endmodule\n" + ); + const TOP: &str = + "module top;\n sub u_x ();\n wire w;\n assign w = u_x.gen_b.sig;\nendmodule\n"; + let files = workspace(&[("sub.sv", SUB), ("top.sv", TOP)]); + + let edit = rename(&files, &path("sub.sv"), at(SUB, "wire", "sig"), "signal").expect("renames"); + assert!(apply(SUB, &edit, &path("sub.sv")).contains("wire signal;"), "the declaration moves"); + assert_eq!( + apply(TOP, &edit, &path("top.sv")), + TOP, + "a generate-scoped name is not on either surface, so the tail is left alone" + ); +} + +/// An **interface** instance's tail already resolved before §49 — an +/// interface's signals are its connection surface (2026-09-01) — and it must +/// still resolve exactly the same way, through the connection table. +#[test] +fn an_interface_instance_tail_is_unchanged_by_the_hierarchical_surface() { + const IF: &str = "interface bus_if;\n logic data;\nendinterface\n"; + const TOP: &str = + "module top;\n bus_if u_bus ();\n wire w;\n assign w = u_bus.data;\nendmodule\n"; + let files = workspace(&[("bus_if.sv", IF), ("top.sv", TOP)]); + + let edit = + rename(&files, &path("bus_if.sv"), at(IF, "logic", "data"), "payload").expect("renames"); + assert_eq!( + apply(IF, &edit, &path("bus_if.sv")), + "interface bus_if;\n logic payload;\nendinterface\n" + ); + assert_eq!( + apply(TOP, &edit, &path("top.sv")), + "module top;\n bus_if u_bus ();\n wire w;\n assign w = u_bus.payload;\nendmodule\n" + ); +} + +/// The verifier's refusal is not weakened by the new surface: two files each +/// declaring `module sub`, and a tail naming into one of them. Which `sub` +/// the instance means is not something the workspace can say, so the rename +/// refuses from either end rather than editing one of the two. +#[test] +fn an_ambiguous_module_behind_a_hierarchical_tail_is_still_refused() { + const ONE: &str = "module sub;\n wire sig;\nendmodule\n"; + const TWO: &str = "module sub;\n wire sig;\nendmodule\n"; + const TOP: &str = "module top;\n sub u_x ();\n wire w;\n assign w = u_x.sig;\nendmodule\n"; + let files = workspace(&[("one.sv", ONE), ("two.sv", TWO), ("top.sv", TOP)]); + + let message = rename(&files, &path("one.sv"), at(ONE, "wire", "sig"), "signal") + .expect_err("an ambiguous tail must be refused"); + assert!(message.contains("more than one"), "{message}"); + let message = rename(&files, &path("top.sv"), at(TOP, "u_x.", "sig"), "signal") + .expect_err("and from the tail itself"); + assert!(message.contains("more than one"), "{message}"); +} + #[test] fn a_hierarchical_tail_that_cannot_resolve_is_left_alone_and_named_as_such() { // The module behind the instance is nowhere in the workspace, so the tail diff --git a/crates/vlog_semantic/src/facts.rs b/crates/vlog_semantic/src/facts.rs index 2306d2d..f744e32 100644 --- a/crates/vlog_semantic/src/facts.rs +++ b/crates/vlog_semantic/src/facts.rs @@ -19,7 +19,7 @@ use std::path::PathBuf; use vlog_parser::defines::{Define, DefineKind, DefineTable}; use vlog_parser::span::TextRange; -use crate::model::SymbolKind; +use crate::model::{Surface, SymbolKind}; use crate::workspace::{ Decl, DeclLines, DeclPositions, DeclSite, FileFacts, InstanceOccurrence, Reexport, ReferenceFact, SiteFact, Utf16Pos, Utf16Range, @@ -133,7 +133,19 @@ use crate::workspace::{ /// though no package in the workspace re-exported anything — for exactly the /// files it had cached, which is the half-right answer this bump exists to /// prevent. See `docs/features/package-reexports/README.md`. -pub const FACTS_FORMAT: u32 = 18; +/// +/// 18 → 19 (2026-09-05, hierarchical-tail): a **surface** letter on every +/// declaration and on every external reference — `c` for the connection +/// surface, `h` for the hierarchical one. It is two new fields, so an older +/// record would be read field-shifted; and the census grows with it, since a +/// module now exports its nets, its variables and its instances on the +/// hierarchical surface where it exported nothing at all before. A store +/// written by a 0.44.0 build would answer definition, find-references and the +/// rename of an internal net named through an instance (`assign w = +/// u_x.sig;`) as though the tail resolved to nothing — for exactly the files +/// it had cached, which is the half-right answer every one of these bumps +/// exists to prevent. See `docs/features/hierarchical-tail/README.md`. +pub const FACTS_FORMAT: u32 = 19; impl FileFacts { /// These facts as one line's worth of fields, tab-separated. @@ -379,6 +391,19 @@ impl Writer { // bump that goes with it // (`docs/features/class-member-access/README.md`, round 2). self.text(decl.type_name.as_deref().unwrap_or("")); + // The surface the owner exports this declaration on. One letter, on + // every declaration rather than only on the `M` group, so the two + // groups keep the one shared `decl` shape they have always had. + self.surface(decl.surface); + } + + /// One [`Surface`] as the letter a reader takes it back by. + fn surface(&mut self, surface: Surface) { + self.field(); + self.out.push(match surface { + Surface::Connection => 'c', + Surface::Hierarchical => 'h', + }); } /// One [`Utf16Range`]: four numbers, in the order a reader takes them. @@ -436,7 +461,7 @@ impl Writer { self.range(*definition); self.range(*occurrence); } - ReferenceFact::External { name, base, paths, occurrence } => { + ReferenceFact::External { name, base, paths, surface, occurrence } => { self.field(); self.out.push('e'); self.text(name); @@ -448,6 +473,10 @@ impl Writer { for path in paths { self.text(path); } + // Which surface those paths are walked in — the one field + // that makes a cross-file hierarchical tail resolve from a + // restored record exactly as it does from a fresh parse. + self.surface(*surface); self.range(*occurrence); } } @@ -525,6 +554,7 @@ impl<'a> Reader<'a> { let detail_line = self.num()?; let type_name = self.text()?; let type_name = (!type_name.is_empty()).then_some(type_name); + let surface = self.surface()?; // Client positions are not one of a declaration's shared fields: a // caller reading the `U` group takes them from `positions()` next, and // a member has none at all (`vlog_semantic::DeclPositions`). @@ -533,7 +563,17 @@ impl<'a> Reader<'a> { detail: (detail_line != 0).then_some(detail_line), positions: None, }; - Some(Decl { name, name_span, decl_span, kind, detail_span, lines, type_name }) + Some(Decl { name, name_span, decl_span, kind, detail_span, lines, type_name, surface }) + } + + /// The mirror of the encoder's one-letter surface: anything else is a + /// record this format did not write. + fn surface(&mut self) -> Option { + match self.next()? { + "c" => Some(Surface::Connection), + "h" => Some(Surface::Hierarchical), + _ => None, + } } fn utf16(&mut self) -> Option { @@ -596,6 +636,7 @@ impl<'a> Reader<'a> { name, base: (!base.is_empty()).then_some(base), paths, + surface: self.surface()?, occurrence: self.range()?, }) } diff --git a/crates/vlog_semantic/src/lib.rs b/crates/vlog_semantic/src/lib.rs index c36bb83..f41caae 100644 --- a/crates/vlog_semantic/src/lib.rs +++ b/crates/vlog_semantic/src/lib.rs @@ -28,7 +28,7 @@ mod workspace; pub use facts::{record_path, FACTS_FORMAT}; pub use model::{ DocumentSymbol, Duplicate, Import, MemberSite, Reference, ReferenceId, Resolution, Scope, - ScopeId, ScopeKind, Symbol, SymbolId, SymbolKind, + ScopeId, ScopeKind, Surface, Symbol, SymbolId, SymbolKind, }; pub use workspace::{ index_order, resolve_external, DeclLines, DeclPositions, DeclSite, Def, Definition, diff --git a/crates/vlog_semantic/src/model.rs b/crates/vlog_semantic/src/model.rs index 5aed66e..3df2635 100644 --- a/crates/vlog_semantic/src/model.rs +++ b/crates/vlog_semantic/src/model.rs @@ -186,6 +186,39 @@ pub struct Duplicate { pub scope: ScopeId, } +/// Which of a unit's two member surfaces a lookup reads. +/// +/// A **package**, a **class** and a `struct` typedef have one surface and this +/// is noise for them. A **module** has two, and they are not the same set +/// (IEEE 1800 §23.3 vs §23.6): +/// +/// * its **connection** surface is what a connection list may name — its +/// ports and its parameters (plus the properties and sequences a bound-in +/// checker instantiates). `.sig(w)` in an instantiation, and the completion +/// list behind that `.`, read exactly this and nothing more: an internal net +/// is not connectable, and offering one would be an item the resolution +/// could not find. +/// * its **hierarchical** surface is everything a hierarchical path may name +/// from anywhere in the design — the connection surface *plus* its nets, its +/// variables and its instances (the last so `u_a.u_b.sig` has a hop to +/// take). Only the tail walk behind an instance head reads it. +/// +/// The hierarchical surface **contains** the connection one, so a tail naming +/// a port has one answer and not two: a member record is tagged with the +/// narrowest surface it joins, the connection query reads only the records +/// tagged [`Surface::Connection`], and the hierarchical query reads those +/// first and the [`Surface::Hierarchical`] ones after. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub enum Surface { + /// Ports and parameters: what a connection list may name, and what every + /// package, class and struct exports. The default for everything that is + /// not a hierarchical tail. + Connection, + /// The whole of what a hierarchical path may name: the connection surface + /// plus a module's nets, variables and instances. + Hierarchical, +} + /// What a [`Reference`] turned out to name. #[derive(Debug, Clone, PartialEq, Eq)] pub enum Resolution { @@ -199,7 +232,14 @@ pub enum Resolution { /// those units — a path containing `::` is a package path, a bare name is a /// module, package or class name — in the order they are tried, the use's /// own name last. The workspace index (TODO.md §6) is what finishes these. - ExternalCandidate { paths: Vec }, + /// + /// `surface` is which of the named unit's two member surfaces the lookup + /// reads ([`Surface`]). It is [`Surface::Connection`] for every candidate + /// but one: the tail of `u_x.sig` whose head resolved to an **instance**, + /// which is a hierarchical path and reads the module's hierarchical + /// surface. Carried here rather than worked out again at lookup time + /// because only the file that wrote the path knows what its head was. + ExternalCandidate { paths: Vec, surface: Surface }, /// A use inside a class that nothing lexical binds, where the class's /// `extends` could: `base` is the base-class path as written /// (`uvm_component`, `pkg::base`), and `paths` are the import paths the @@ -242,11 +282,16 @@ pub enum MemberSite { Scope(ScopeId), /// A type this file does not declare, as the unit name plus any member /// names already selected from it — `pkt_t`, `pkt_t::hdr` — in exactly the - /// spelling [`crate::WorkspaceIndex`]'s member lookup walks. The tail - /// resolution appends `::` to it and hands the result to - /// `follow_one`; the *list* is - /// [`WorkspaceIndex::members_of_chain`](crate::WorkspaceIndex::members_of_chain). - Unit(String), + /// spelling [`crate::WorkspaceIndex`]'s member lookup walks, with the + /// [`Surface`] the walk reads. The tail resolution appends `::` to + /// the path and hands the pair to `follow_one`; the *list* is + /// [`WorkspaceIndex::members_of_chain_in`](crate::WorkspaceIndex::members_of_chain_in). + /// + /// The surface is [`Surface::Hierarchical`] exactly when the head of the + /// spine was an **instance**, and it stays that for every further hop: + /// `u_a.u_b.` is one hierarchical path, and each hop is an instance inside + /// the module before it. + Unit { path: String, surface: Surface }, } /// A *use* of a name: an expression identifier, a type name, an instantiated diff --git a/crates/vlog_semantic/src/resolve.rs b/crates/vlog_semantic/src/resolve.rs index 26f8ade..eeb059d 100644 --- a/crates/vlog_semantic/src/resolve.rs +++ b/crates/vlog_semantic/src/resolve.rs @@ -5,7 +5,7 @@ //! requires at module scope and what an editor needs mid-edit. use crate::bind::{Pending, Target}; -use crate::model::{MemberSite, Resolution, Scope, ScopeId, Symbol, SymbolId, SymbolKind}; +use crate::model::{MemberSite, Resolution, Scope, ScopeId, Surface, Symbol, SymbolId, SymbolKind}; /// Resolve one pending use against the finished scope tree. /// @@ -34,7 +34,10 @@ pub(crate) fn resolve(scopes: &[Scope], symbols: &[Symbol], p: &Pending) -> Opti None => Resolution::NotFound, }, // The port list lives in whatever file declares the module. - None => Resolution::ExternalCandidate { paths: vec![module.clone()] }, + None => Resolution::ExternalCandidate { + paths: vec![module.clone()], + surface: Surface::Connection, + }, }, Target::InScope => return in_scope(scopes, p.scope, &p.name), Target::TypeMember { unit } => return type_member(scopes, symbols, p.scope, unit, &p.name), @@ -95,7 +98,10 @@ fn in_bind_target( ) -> Option { match owning_scope(scopes, symbols, target, is_instantiable) { Some(scope) => scopes.get(scope.0 as usize)?.lookup_local(name).map(Resolution::Resolved), - None => Some(Resolution::ExternalCandidate { paths: vec![target.to_string()] }), + None => Some(Resolution::ExternalCandidate { + paths: vec![target.to_string()], + surface: Surface::Connection, + }), } } @@ -135,6 +141,7 @@ fn type_member( TypeHere::NotAUnit => None, TypeHere::Absent => Some(Resolution::ExternalCandidate { paths: vec![format!("{}::{name}", last_segment(unit))], + surface: Surface::Connection, }), } } @@ -185,6 +192,7 @@ fn member_of( }), Err(Some(base)) => Some(Resolution::ExternalCandidate { paths: vec![format!("{}::{name}", last_segment(&base))], + surface: Surface::Connection, }), // A class this file declares whole, with no such member: nothing // to say that `NotFound` would not overstate. @@ -193,8 +201,8 @@ fn member_of( // A type this file does not declare: the workspace's member table is // the only layer that can say. The last `::` segment names the unit, // the spelling `follow_one` turns back into `member(unit, name)`. - MemberSite::Unit(path) => { - Some(Resolution::ExternalCandidate { paths: vec![format!("{path}::{name}")] }) + MemberSite::Unit { path, surface } => { + Some(Resolution::ExternalCandidate { paths: vec![format!("{path}::{name}")], surface }) } } } @@ -231,12 +239,17 @@ pub(crate) fn member_site( Ok(id) => link_type(scopes, symbols, id)?, // The chain leaves this file at a base class: everything from // here on is one composed path for the workspace to walk. - Err(Some(base)) => MemberSite::Unit(format!("{}::{mid}", last_segment(&base))), + Err(Some(base)) => MemberSite::Unit { + path: format!("{}::{mid}", last_segment(&base)), + surface: Surface::Connection, + }, Err(None) => return None, }, // Already outside this file — each further name is one more // segment of the path `follow_one` walks member by member. - MemberSite::Unit(path) => MemberSite::Unit(format!("{path}::{mid}")), + MemberSite::Unit { path, surface } => { + MemberSite::Unit { path: format!("{path}::{mid}"), surface } + } }; } Some(here) @@ -258,7 +271,10 @@ fn head_site( let (chain, base) = extends_chain(scopes, symbols, class); match chain.get(1) { Some(&base_scope) => Some(MemberSite::Scope(base_scope)), - None => Some(MemberSite::Unit(last_segment(&base?).to_string())), + None => Some(MemberSite::Unit { + path: last_segment(&base?).to_string(), + surface: Surface::Connection, + }), } } _ => { @@ -294,7 +310,9 @@ pub(crate) fn unit_site( let id = scopes.get(scope.0 as usize)?.lookup_local(segment)?; MemberSite::Scope(container_scope(symbols, id)?) } - MemberSite::Unit(unit) => MemberSite::Unit(format!("{unit}::{segment}")), + MemberSite::Unit { path, surface } => { + MemberSite::Unit { path: format!("{path}::{segment}"), surface } + } }; } Some(here) @@ -322,7 +340,7 @@ fn unit_scope(scopes: &[Scope], symbols: &[Symbol], from: ScopeId, unit: &str) - } current = scope.parent; } - MemberSite::Unit(unit.to_string()) + MemberSite::Unit { path: unit.to_string(), surface: Surface::Connection } } /// Where the members of one declaration live: its **declared type**'s scope @@ -347,7 +365,26 @@ fn link_type(scopes: &[Scope], symbols: &[Symbol], id: SymbolId) -> Option None, - TypeHere::Absent => Some(MemberSite::Unit(last_segment(type_name).to_string())), + TypeHere::Absent => Some(MemberSite::Unit { + path: last_segment(type_name).to_string(), + surface: head_surface(symbol.kind), + }), + } +} + +/// Which member surface a link of a spine opens: the **hierarchical** one when +/// the link is an instance, the connection one for everything else. +/// +/// `u_x.sig` is a hierarchical path (IEEE 1800 §23.6) and `sig` may be any of +/// `sub`'s own declarations; `handle.field` is a member access on a type, and +/// `pkt_t` has one surface anyway. The distinction only ever matters for a +/// module — the one unit whose two surfaces differ — and it is settled here, +/// in the file that can see what the head is, because the path handed to the +/// workspace is only a spelling. +fn head_surface(kind: SymbolKind) -> Surface { + match kind { + SymbolKind::Instance => Surface::Hierarchical, + _ => Surface::Connection, } } @@ -678,9 +715,10 @@ fn unit_member( } // Nothing here declares the unit, or a `typedef class c;` promises it // lives elsewhere: the member is the workspace's to find. - MemberSite::Unit(_) => { - Resolution::ExternalCandidate { paths: vec![format!("{unit}::{name}")] } - } + MemberSite::Unit { .. } => Resolution::ExternalCandidate { + paths: vec![format!("{unit}::{name}")], + surface: Surface::Connection, + }, } } @@ -724,7 +762,7 @@ fn super_member(scopes: &[Scope], from: ScopeId) -> Resolution { /// because the use was not a type — is `NotFound`. fn miss(scopes: &[Scope], from: ScopeId, external: Vec, unit_lookup: bool) -> Resolution { if unit_lookup { - return Resolution::ExternalCandidate { paths: external }; + return Resolution::ExternalCandidate { paths: external, surface: Surface::Connection }; } if let Some(base) = nearest_extends(scopes, from) { return Resolution::InheritedCandidate { base, paths: external }; @@ -732,7 +770,7 @@ fn miss(scopes: &[Scope], from: ScopeId, external: Vec, unit_lookup: boo if external.is_empty() { Resolution::NotFound } else { - Resolution::ExternalCandidate { paths: external } + Resolution::ExternalCandidate { paths: external, surface: Surface::Connection } } } @@ -789,7 +827,10 @@ fn named_at_file_scope( ) -> Resolution { match file_symbol(scopes, symbols, name, wanted) { Some(id) => Resolution::Resolved(id), - None => Resolution::ExternalCandidate { paths: vec![name.to_string()] }, + None => Resolution::ExternalCandidate { + paths: vec![name.to_string()], + surface: Surface::Connection, + }, } } diff --git a/crates/vlog_semantic/src/workspace/external.rs b/crates/vlog_semantic/src/workspace/external.rs index c2bbcf8..a4d23d3 100644 --- a/crates/vlog_semantic/src/workspace/external.rs +++ b/crates/vlog_semantic/src/workspace/external.rs @@ -7,10 +7,10 @@ use std::collections::{HashMap, HashSet}; -use crate::model::{ReferenceId, Resolution, Symbol, SymbolKind}; +use crate::model::{ReferenceId, Resolution, Surface, Symbol, SymbolKind}; use crate::Semantics; -use super::{reexport, Def, WorkspaceIndex}; +use super::{hierarchy, reexport, Def, WorkspaceIndex}; /// What the workspace layer made of one external-candidate reference. #[derive(Debug, Clone, PartialEq, Eq)] @@ -79,9 +79,11 @@ pub fn resolve_external(sem: &Semantics, index: &WorkspaceIndex) -> ExternalReso let mut targets = HashMap::new(); for (i, reference) in sem.references().iter().enumerate() { let target = match &reference.resolution { - Resolution::ExternalCandidate { paths } => follow_paths(index, &reference.name, paths), + Resolution::ExternalCandidate { paths, surface } => { + follow_paths(index, &reference.name, paths, *surface) + } Resolution::InheritedCandidate { base, paths } => { - match resolve_fact(index, &reference.name, Some(base), paths) { + match resolve_fact(index, &reference.name, Some(base), paths, Surface::Connection) { ExternalTarget::StillUnresolved => continue, answered => answered, } @@ -106,10 +108,14 @@ pub(super) fn resolve_fact( name: &str, base: Option<&str>, paths: &[String], + surface: Surface, ) -> ExternalTarget { - match follow_paths(index, name, paths) { + match follow_paths(index, name, paths, surface) { ExternalTarget::StillUnresolved => match base { - Some(base) => target(member_chain(index, last_segment(base), name)), + // A base class is a class, and a class has one surface. + Some(base) => { + target(member_chain(index, last_segment(base), name, Surface::Connection)) + } None => ExternalTarget::StillUnresolved, }, answered => answered, @@ -133,11 +139,18 @@ pub(super) fn resolve_fact( /// of comparisons and no file is read. The walk is bounded by the visited set /// as well as by the workspace: `class a extends b; class b extends a;` /// terminates, and so does a chain that meets itself further up. -pub(super) fn member_chain<'i>(index: &'i WorkspaceIndex, unit: &str, name: &str) -> &'i [Def] { - let found = own_chain(index, unit, name); +pub(super) fn member_chain<'i>( + index: &'i WorkspaceIndex, + unit: &str, + name: &str, + surface: Surface, +) -> &'i [Def] { + let found = own_chain(index, unit, name, surface); if !found.is_empty() { return found; } + // A re-export is a package's business and a package has one surface, so + // this hop is the connection one whatever the tail was. reexport::member(index, unit, name) } @@ -149,13 +162,18 @@ pub(super) fn member_chain<'i>(index: &'i WorkspaceIndex, unit: &str, name: &str /// recurse into the very walk that called it. So the layering is exactly two /// deep — a re-export hop reaches a package's own members and its bases, and /// the re-export walk itself is what chases a chain of re-exports. -pub(super) fn own_chain<'i>(index: &'i WorkspaceIndex, unit: &str, name: &str) -> &'i [Def] { - let found = index.member(unit, name); +pub(super) fn own_chain<'i>( + index: &'i WorkspaceIndex, + unit: &str, + name: &str, + surface: Surface, +) -> &'i [Def] { + let found = hierarchy::member(index, unit, name, surface); if !found.is_empty() { return found; } for hop in base_chain(index, unit) { - let found = index.member(hop, name); + let found = hierarchy::member(index, hop, name, surface); if !found.is_empty() { return found; } @@ -169,13 +187,17 @@ pub(super) fn own_chain<'i>(index: &'i WorkspaceIndex, unit: &str, name: &str) - /// /// [`WorkspaceIndex::members_of_chain`]'s inner half, shared with the /// re-export walk for the same reason [`own_chain`] is. -pub(super) fn own_members<'i>(index: &'i WorkspaceIndex, unit: &str) -> Vec<(&'i str, &'i Def)> { +pub(super) fn own_members<'i>( + index: &'i WorkspaceIndex, + unit: &str, + surface: Surface, +) -> Vec<(&'i str, &'i Def)> { let mut hops: Vec<&str> = vec![unit]; hops.extend(base_chain(index, unit)); let mut out: Vec<(&'i str, &'i Def)> = Vec::new(); let mut seen: HashSet<&str> = HashSet::new(); for hop in hops { - for (name, defs) in index.members_of(hop) { + for (name, defs) in hierarchy::members_of(index, hop, surface) { if let Some(def) = defs.first() { if seen.insert(name) { out.push((name, def)); @@ -224,11 +246,11 @@ pub(super) fn base_chain<'i>(index: &'i WorkspaceIndex, unit: &str) -> Vec<&'i s /// /// The same fold [`follow_one`] runs before its own lookup — shared, so a /// list and a lookup of the same path cannot land in different units. -pub(super) fn fold_path(index: &WorkspaceIndex, path: &str) -> Option { +pub(super) fn fold_path(index: &WorkspaceIndex, path: &str, surface: Surface) -> Option { let mut segments = path.split("::"); let mut unit = segments.next()?.to_string(); for segment in segments { - unit = index.member_unit(&unit, segment)?; + unit = index.member_unit_in(&unit, segment, surface)?; } Some(unit) } @@ -261,9 +283,14 @@ pub(super) fn last_segment(path: &str) -> &str { /// Try the recorded paths in the order `analyze` wrote them — which is the /// order the imports are written in — and take the first that has an answer. -fn follow_paths(index: &WorkspaceIndex, name: &str, paths: &[String]) -> ExternalTarget { +fn follow_paths( + index: &WorkspaceIndex, + name: &str, + paths: &[String], + surface: Surface, +) -> ExternalTarget { for path in paths { - match target(follow_one(index, name, path)) { + match target(follow_one(index, name, path, surface)) { ExternalTarget::StillUnresolved => continue, answered => return answered, } @@ -288,22 +315,31 @@ fn follow_paths(index: &WorkspaceIndex, name: &str, paths: &[String]) -> Externa /// `handle.member` and `this.member` reach a base class in a third file, and /// what keeps the overlay and the index's own reference postings (which run /// through this same function) from disagreeing about what a use names. -fn follow_one<'i>(index: &'i WorkspaceIndex, name: &str, path: &str) -> &'i [Def] { +fn follow_one<'i>( + index: &'i WorkspaceIndex, + name: &str, + path: &str, + surface: Surface, +) -> &'i [Def] { let mut segments: Vec<&str> = path.split("::").collect(); if segments.is_empty() { return &[]; } if segments.len() < 2 { - return if path == name { index.units(name) } else { member_chain(index, path, name) }; + return if path == name { + index.units(name) + } else { + member_chain(index, path, name, surface) + }; } // The last segment is the use's own name, which `name` already carries // (and which a `p::*` import spells as a wildcard); the ones before it are // the hops. segments.pop(); - let Some(unit) = fold_path(index, &segments.join("::")) else { + let Some(unit) = fold_path(index, &segments.join("::"), surface) else { return &[]; }; - member_chain(index, &unit, name) + member_chain(index, &unit, name, surface) } impl ExternalResolutions { diff --git a/crates/vlog_semantic/src/workspace/hierarchy.rs b/crates/vlog_semantic/src/workspace/hierarchy.rs new file mode 100644 index 0000000..9608ebe --- /dev/null +++ b/crates/vlog_semantic/src/workspace/hierarchy.rs @@ -0,0 +1,145 @@ +//! A unit's two member surfaces: which surface each declaration joins +//! ([`surface_of`]), and the index reads that take a [`Surface`] rather than +//! assuming one. +//! +//! Every unit but a module has one surface, and for those this module is a +//! formality — the same set answers a `pkg::x` and a `handle.field`. A module +//! has two, because SystemVerilog gives it two different ways of being reached +//! from outside: a **connection list** may name its ports and parameters +//! (§23.3), and a **hierarchical path** may name anything it declares (§23.6). +//! Merging them would make `.internal_net(w)` a legal connection; keeping only +//! the first is what made `assign w = u_x.sig;` unresolvable across files +//! (`docs/topo.md` §2.9-23). +//! +//! So the index stores both, tagged, and every read says which one it wants. +//! The connection surface is the whole of what was there before this module +//! existed; the hierarchical surface is that set **plus** a module's nets, +//! variables and instances, which is why a record is tagged with the narrowest +//! surface it joins and a hierarchical read consults the connection table +//! first. A port has one record, is found by both reads, and is one answer. + +use std::collections::HashSet; + +use crate::model::{Surface, SymbolKind}; + +use super::{Def, WorkspaceIndex}; + +/// Which surface `member` joins in `unit`, or `None` when `unit` does not +/// export it at all. +/// +/// A **package** or **class** exports everything declared at its top level (a +/// package's classes included — that is what lets `import uvm_pkg::*` answer +/// `uvm_object`), and it has no second surface: nothing reaches into a package +/// by a hierarchical path. +/// +/// A **module** is the unit with two. Its connection surface is what a +/// connection list may name — ports and parameters — plus the properties and +/// sequences a bound-in checker instantiates (`top.u_dut.p_req`, and an +/// `` `include``d assertion file's bare-name instantiation). Its hierarchical +/// surface adds its **nets**, its **variables** and its **instances**: those +/// are what `u_x.sig` and `u_a.u_b.sig` name, they are not connectable, and +/// before 2026-09-05 they were not exported at all — which is what made a +/// cross-file rename of an internal net edit one file and warn about the +/// other. The instances are in it for the hop as much as for themselves: +/// `u_a.u_b.sig` needs `u_b`'s declared type to know where `sig` lives. +/// +/// An **interface** is the 2026-09-01 exception and is unchanged: its signals +/// *are* its connection surface, because `virtual bus_if vif; vif.data` is how +/// every DV testbench reaches `data` and `vif` is a variable, not an instance. +/// It gains its instances hierarchically for the same hop reason, and nothing +/// else moves. +/// +/// A `typedef struct`/`union` exports its fields, and a field that is itself +/// an inline aggregate exports its own — which is what a generated register +/// package is: `reg2hw_t` → `ctrl` → `q`. A covergroup's surface is its +/// labelled coverpoints and crosses plus the `sample` method its header +/// declares. Neither has a hierarchical surface: a struct is a type, and a +/// path reaches a covergroup's coverpoints the same single way from anywhere. +pub(super) fn surface_of(unit: SymbolKind, member: SymbolKind) -> Option { + match unit { + SymbolKind::Package | SymbolKind::Class => matches!( + member, + SymbolKind::Param + | SymbolKind::LocalParam + | SymbolKind::Typedef + | SymbolKind::EnumVariant + | SymbolKind::Function + | SymbolKind::Task + | SymbolKind::Net + | SymbolKind::Var + | SymbolKind::Class + | SymbolKind::Constraint + | SymbolKind::Covergroup + | SymbolKind::Property + | SymbolKind::Sequence + ) + .then_some(Surface::Connection), + SymbolKind::Module => match member { + SymbolKind::Port + | SymbolKind::Param + | SymbolKind::LocalParam + | SymbolKind::Property + | SymbolKind::Sequence => Some(Surface::Connection), + SymbolKind::Net | SymbolKind::Var | SymbolKind::Instance => Some(Surface::Hierarchical), + _ => None, + }, + SymbolKind::Typedef | SymbolKind::StructMember => { + (member == SymbolKind::StructMember).then_some(Surface::Connection) + } + SymbolKind::Covergroup => { + matches!(member, SymbolKind::Coverpoint | SymbolKind::Cross | SymbolKind::Function) + .then_some(Surface::Connection) + } + SymbolKind::Interface => match member { + SymbolKind::Net + | SymbolKind::Var + | SymbolKind::Port + | SymbolKind::Param + | SymbolKind::LocalParam + | SymbolKind::Typedef + | SymbolKind::Function + | SymbolKind::Task + | SymbolKind::Modport + | SymbolKind::Clocking => Some(Surface::Connection), + SymbolKind::Instance => Some(Surface::Hierarchical), + _ => None, + }, + _ => None, + } +} + +/// `member` of `unit` in one surface: the connection records, and — for +/// [`Surface::Hierarchical`] — the hierarchical-only ones after them. +/// +/// Connection first, so a name in both surfaces has exactly one answer and it +/// is the same declaration either read finds. Two map reads at worst, and one +/// for every lookup that is not a hierarchical tail. +pub(super) fn member<'i>( + index: &'i WorkspaceIndex, + unit: &str, + member: &str, + surface: Surface, +) -> &'i [Def] { + let found = index.member(unit, member); + match surface { + Surface::Connection => found, + Surface::Hierarchical if !found.is_empty() => found, + Surface::Hierarchical => index.hierarchical_member(unit, member), + } +} + +/// Every member of `unit` in one surface, connection records first, each name +/// once — the listing half of [`member`] and the same first-hit-wins rule, so +/// a completion list offers what a lookup in the same surface would find. +pub(super) fn members_of<'i>( + index: &'i WorkspaceIndex, + unit: &str, + surface: Surface, +) -> Vec<(&'i str, &'i [Def])> { + let mut out: Vec<(&'i str, &'i [Def])> = index.members_of(unit).collect(); + if surface == Surface::Hierarchical { + let held: HashSet<&str> = out.iter().map(|(name, _)| *name).collect(); + out.extend(index.hierarchical_members_of(unit).filter(|(name, _)| !held.contains(name))); + } + out +} diff --git a/crates/vlog_semantic/src/workspace/index.rs b/crates/vlog_semantic/src/workspace/index.rs index fa563bc..81e3a94 100644 --- a/crates/vlog_semantic/src/workspace/index.rs +++ b/crates/vlog_semantic/src/workspace/index.rs @@ -11,9 +11,10 @@ use std::path::{Path, PathBuf}; use vlog_parser::defines::{Define, DefineTable}; -use crate::model::SymbolKind; +use crate::model::{Surface, SymbolKind}; use super::external::{fold_path, last_segment, member_chain, own_members}; +use super::hierarchy; use super::record::{FileFacts, ReferenceFact}; use super::{ reexport, Def, DefinitionKey, FileId, IndexCounts, InheritanceEdge, InstantiationEdge, @@ -69,15 +70,30 @@ impl WorkspaceIndex { self.units.get(name).map_or(&[], Vec::as_slice) } - /// Every declaration of `member` exported by `unit`. This is what makes - /// `p::x` and `import p::*` reach into another file, and what makes a - /// `.port` connection reach into the instantiated module. + /// Every declaration of `member` `unit` exports on its **connection** + /// surface. This is what makes `p::x` and `import p::*` reach into + /// another file, and what makes a `.port` connection reach into the + /// instantiated module. + /// + /// The connection surface is the whole surface of a package, a class and + /// a struct; for a module it is its ports and parameters, and what a + /// hierarchical path may name besides is + /// [`WorkspaceIndex::member_in`]'s business ([`Surface`]). pub fn member(&self, unit: &str, member: &str) -> &[Def] { self.members.get(unit).and_then(|m| m.get(member)).map_or(&[], Vec::as_slice) } - /// Every exported member of `unit`, sorted by name — the completion list - /// behind `p::` and behind an instantiation's connection list. + /// [`WorkspaceIndex::member`] in a named surface: the same answer for + /// [`Surface::Connection`], and for [`Surface::Hierarchical`] the + /// connection records first and a module's nets, variables and instances + /// after them. + pub fn member_in(&self, unit: &str, member: &str, surface: Surface) -> &[Def] { + hierarchy::member(self, unit, member, surface) + } + + /// Every member `unit` exports on its connection surface, sorted by name + /// — the completion list behind `p::` and behind an instantiation's + /// connection list. pub fn members_of(&self, unit: &str) -> impl Iterator { self.members .get(unit) @@ -85,6 +101,44 @@ impl WorkspaceIndex { .flat_map(|m| m.iter().map(|(name, defs)| (name.as_str(), defs.as_slice()))) } + /// Every member of `unit` a hierarchical path may name and a connection + /// list may not, sorted by name — the second half of a hierarchical + /// listing, never a listing on its own. + pub(super) fn hierarchical_members_of( + &self, + unit: &str, + ) -> impl Iterator { + self.hier_members + .get(unit) + .into_iter() + .flat_map(|m| m.iter().map(|(name, defs)| (name.as_str(), defs.as_slice()))) + } + + /// [`WorkspaceIndex::member`] on the hierarchical-only half alone. + pub(super) fn hierarchical_member(&self, unit: &str, member: &str) -> &[Def] { + self.hier_members.get(unit).and_then(|m| m.get(member)).map_or(&[], Vec::as_slice) + } + + /// Every unit that declares `name` on its **hierarchical** surface, with + /// the declaration — the census `workspace_symbols` deliberately does not + /// hold. + /// + /// A module's internal net is not a workspace symbol: `workspace/symbol` + /// answers what a user can name from outside, and a design with 20 000 + /// modules has hundreds of thousands of internal signals. But a rename's + /// fan-out has to find the *declaring file* of a name a hierarchical tail + /// resolves to, and that is exactly this question — asked once per + /// rename, over a map, reading nothing. See + /// `docs/features/hierarchical-tail/README.md`. + pub fn hierarchical_declarations<'a>( + &'a self, + name: &'a str, + ) -> impl Iterator + 'a { + self.hier_members.iter().flat_map(move |(unit, members)| { + members.get(name).into_iter().flatten().map(move |def| (unit.as_str(), def)) + }) + } + /// Every member `path::` can name, **inherited ones included**, sorted by /// name with one declaration each — the completion list behind `pkg::`, /// `handle.` and `vif.` when the type is another file's. @@ -104,13 +158,22 @@ impl WorkspaceIndex { /// own declaration of a name it also re-exports, are what is listed *and* /// what a lookup would find. Map reads only: no file is opened. pub fn members_of_chain(&self, path: &str) -> Vec<(&str, &Def)> { - let Some(unit) = fold_path(self, path) else { + self.members_of_chain_in(path, Surface::Connection) + } + + /// [`WorkspaceIndex::members_of_chain`] in a named surface — the list + /// behind `u_x.` in an expression, where the module's nets, variables and + /// instances are what the user is reaching for and what the tail + /// resolution will find. A connection list's `.` is the other surface and + /// its own function (`completion::connection_members`). + pub fn members_of_chain_in(&self, path: &str, surface: Surface) -> Vec<(&str, &Def)> { + let Some(unit) = fold_path(self, path, surface) else { return Vec::new(); }; let mut out: Vec<(&str, &Def)> = Vec::new(); let mut seen: HashSet<&str> = HashSet::new(); for (name, def) in - own_members(self, &unit).into_iter().chain(reexport::members(self, &unit)) + own_members(self, &unit, surface).into_iter().chain(reexport::members(self, &unit)) { if seen.insert(name) { out.push((name, def)); @@ -140,7 +203,14 @@ impl WorkspaceIndex { /// class declared inside a package declares no file-scope unit at all — /// the dominant UVM shape — and is unaffected. pub fn member_unit(&self, unit: &str, member: &str) -> Option { - let [def] = member_chain(self, unit, member) else { + self.member_unit_in(unit, member, Surface::Connection) + } + + /// [`WorkspaceIndex::member_unit`] in a named surface: the hop + /// `u_a.u_b.sig` takes, where `u_b` is an instance inside `a` and only + /// the hierarchical surface holds it. + pub fn member_unit_in(&self, unit: &str, member: &str, surface: Surface) -> Option { + let [def] = member_chain(self, unit, member, surface) else { return None; }; let next = last_segment(def.type_name.as_deref()?); @@ -415,6 +485,12 @@ impl WorkspaceIndex { .filter(|d| d.kind == SymbolKind::Class) .count(), members: self.members.values().flat_map(|m| m.values()).map(Vec::len).sum(), + hierarchical_members: self + .hier_members + .values() + .flat_map(|m| m.values()) + .map(Vec::len) + .sum(), defines: self.facts.iter().map(|f| f.defines.entries().len()).sum(), instantiations: self.instantiations.values().map(Vec::len).sum(), inheritances: self.subclasses.values().map(Vec::len).sum(), diff --git a/crates/vlog_semantic/src/workspace/mod.rs b/crates/vlog_semantic/src/workspace/mod.rs index 4374521..04bf5f6 100644 --- a/crates/vlog_semantic/src/workspace/mod.rs +++ b/crates/vlog_semantic/src/workspace/mod.rs @@ -18,11 +18,14 @@ //! `index` answers questions of a built index, `update` changes one after it //! is built, `record` reads off what one file contributes ([`FileFacts`]), //! `external` is the overlay — [`resolve_external`] — and the member and -//! inheritance walks it shares with `index`, and `reexport` is the one edge -//! neither of those two could hold: what `export b_pkg::x;` makes reachable -//! through the package that writes it. +//! inheritance walks it shares with `index`, `reexport` is the one edge +//! neither of those two could hold — what `export b_pkg::x;` makes reachable +//! through the package that writes it — and `hierarchy` is which of a unit's +//! two member surfaces holds what, and the reads that take a +//! [`crate::Surface`] instead of assuming one. mod external; +mod hierarchy; mod index; mod record; mod reexport; @@ -291,8 +294,18 @@ pub struct WorkspaceIndex { facts: Vec, /// File-scope name → every declaration of it, in disambiguation order. units: BTreeMap>, - /// Unit name → member name → every declaration of it. + /// Unit name → member name → every declaration of it, on the + /// **connection** surface: what a connection list, a `pkg::x` and a + /// `handle.field` may name. This is the whole member table as it was + /// before 2026-09-05, and every query that does not name a surface reads + /// exactly this. members: BTreeMap>>, + /// The same shape for the members a **hierarchical path** may name and a + /// connection list may not — a module's (or an interface's) nets, + /// variables and instances. Kept apart rather than tagged in place so + /// that every existing read stays the read it was, and a hierarchical + /// read is `members` first and this second (`hierarchy`). + hier_members: BTreeMap>>, /// Instantiated module name → every site, in file order then walk order. instantiations: BTreeMap>, /// Base class name → every class extending it, in file order then walk @@ -336,9 +349,14 @@ pub struct IndexCounts { /// Class declarations reachable in the index — file-scope units plus /// classes registered as members of a package or an enclosing class. pub classes: usize, - /// Package, class and module member declarations, duplicates counted - /// separately. + /// Package, class and module member declarations on the **connection** + /// surface, duplicates counted separately. pub members: usize, + /// Member declarations only a hierarchical path can name — a module's or + /// an interface's nets, variables and instances — duplicates counted + /// separately. Disjoint from `members`, so the whole member census is the + /// two added. + pub hierarchical_members: usize, /// `` `define``/`` `undef`` directives recorded across all files. pub defines: usize, /// Instantiation sites recorded — one per written statement, inside a diff --git a/crates/vlog_semantic/src/workspace/record.rs b/crates/vlog_semantic/src/workspace/record.rs index 1291dd2..a5764b9 100644 --- a/crates/vlog_semantic/src/workspace/record.rs +++ b/crates/vlog_semantic/src/workspace/record.rs @@ -1,10 +1,11 @@ //! What one file contributes to an index, read off its parse: the //! [`FileFacts`] record and the per-file shapes inside it ([`Decl`], //! [`SiteFact`], [`ReferenceFact`]), the read-off itself -//! ([`facts_from_analysis`]), and the two rulings it applies — which -//! file-scope kinds are units, and what each kind of unit exports. A record -//! is the unit of persistence (`facts.rs` encodes exactly this) and of -//! incremental update, which is why it is a module of its own. +//! ([`facts_from_analysis`]), and the ruling it applies about which +//! file-scope kinds are units. What each kind of unit *exports*, and on which +//! surface, moved to [`hierarchy::surface_of`] when a module gained a second +//! one. A record is the unit of persistence (`facts.rs` encodes exactly this) +//! and of incremental update, which is why it is a module of its own. use std::collections::HashSet; use std::path::{Path, PathBuf}; @@ -15,12 +16,12 @@ use vlog_parser::span::TextRange; use vlog_parser::token::Token; use vlog_parser::{parse_source_tolerant, parse_tolerant, tokenize, LineIndex}; -use crate::model::{Resolution, Symbol, SymbolKind}; +use crate::model::{Resolution, Surface, Symbol, SymbolKind}; use crate::{analyze, classes, instantiations, Semantics}; use super::{ - reexport, DeclLines, DeclPositions, DeclSite, Def, FileId, InstanceOccurrence, Reexport, - Utf16Range, + hierarchy, reexport, DeclLines, DeclPositions, DeclSite, Def, FileId, InstanceOccurrence, + Reexport, Utf16Range, }; /// One declaration as a single file contributes it, before that file has a @@ -35,12 +36,19 @@ pub(crate) struct Decl { pub(crate) detail_span: Option, pub(crate) lines: DeclLines, pub(crate) type_name: Option, + /// Which of its owner's member surfaces this declaration joins — the + /// narrowest one, so a connection-surface record is found by a + /// hierarchical read too ([`hierarchy::surface_of`]). Always + /// [`Surface::Connection`] for a unit, which has no owner and is reached + /// by name. + pub(crate) surface: Surface, } impl Decl { - /// A member's declaration: lines only, no client positions — see - /// [`DeclPositions`] for why the cheap half is the only half a member gets. - fn member(symbol: &Symbol, lines: &LineIndex) -> Decl { + /// A member's declaration, on the surface its owner exports it: lines + /// only, no client positions — see [`DeclPositions`] for why the cheap + /// half is the only half a member gets. + fn member(symbol: &Symbol, lines: &LineIndex, surface: Surface) -> Decl { Decl { name: symbol.name.clone(), name_span: symbol.name_span, @@ -49,13 +57,14 @@ impl Decl { detail_span: symbol.detail_span, lines: DeclLines::of(lines, symbol.name_span, symbol.detail_span), type_name: symbol.type_name.clone(), + surface, } } /// A file-scope declaration: the same, plus the two ranges a client is /// pointed at, converted here so no one converts them later. fn unit(symbol: &Symbol, src: &str, lines: &LineIndex) -> Decl { - let mut decl = Decl::member(symbol, lines); + let mut decl = Decl::member(symbol, lines, Surface::Connection); decl.lines.positions = Some(DeclPositions { name: Utf16Range::of(src, lines, symbol.name_span), decl: Utf16Range::of(src, lines, symbol.decl_span), @@ -102,7 +111,8 @@ pub struct FileFacts { pub(crate) defines: DefineTable, /// File-scope declarations, in declaration order. pub(crate) units: Vec, - /// Members, each under the name of the unit that exports it, in the order + /// Members, each under the name of the unit that exports it and tagged + /// with the surface it is exported on ([`Decl::surface`]), in the order /// the scope tree yields them. pub(crate) members: Vec<(String, Decl)>, /// Instantiation sites, each under the name of the module instantiated, in @@ -155,7 +165,17 @@ pub(crate) enum ReferenceFact { /// chases it. Without it a `this.x` whose class is another file's had no /// posting at all, so a cross-file find-references from the property's /// own declaration did not list it (round 1's residue). - External { name: String, base: Option, paths: Vec, occurrence: TextRange }, + External { + name: String, + base: Option, + paths: Vec, + /// Which member surface the recorded paths are walked in — carried + /// straight from [`Resolution::ExternalCandidate`], because the file + /// that wrote the path is the only layer that knows whether its head + /// was an instance. + surface: Surface, + occurrence: TextRange, + }, } impl ReferenceFact { @@ -299,11 +319,29 @@ fn facts_from_analysis( facts.units.push(Decl::unit(unit, src, lines)); collect_members(sem, &unit.name, unit, lines, &mut facts.members); } + // The **connection** surface only. A `Local` posting exists so that a + // declaration another file can point at carries its own file's uses + // without that file being re-read, and every consumer of the postings + // that matters here — the rename, which re-analyses the declaring file + // anyway — already has them. Posting a module's every internal net use + // would multiply the reference table by the size of an RTL body for an + // answer nothing reads; the hierarchical surface is what a *cross-file* + // tail resolves through, and that half is an `External` fact below. + // See `docs/features/hierarchical-tail/README.md`, "what did not widen". + // Which kind lands on which surface is `hierarchy::surface_of`, the one + // rule this filter and the member tables both read (§49's QA asked for + // the pointer). let exported: HashSet<(u32, u32)> = facts .units .iter() .map(|decl| (decl.name_span.start, decl.name_span.end)) - .chain(facts.members.iter().map(|(_, decl)| (decl.name_span.start, decl.name_span.end))) + .chain( + facts + .members + .iter() + .filter(|(_, decl)| decl.surface == Surface::Connection) + .map(|(_, decl)| (decl.name_span.start, decl.name_span.end)), + ) .collect(); for reference in sem.references() { let fact = match &reference.resolution { @@ -313,21 +351,25 @@ fn facts_from_analysis( .contains(&(definition.start, definition.end)) .then_some(ReferenceFact::Local { definition, occurrence: reference.name_span }) }), - Resolution::ExternalCandidate { paths } if !paths.is_empty() => { + Resolution::ExternalCandidate { paths, surface } if !paths.is_empty() => { Some(ReferenceFact::External { name: reference.name.clone(), base: None, paths: paths.clone(), + surface: *surface, occurrence: reference.name_span, }) } // An inherited candidate is recorded even with **no** paths: the // base alone is a handle on the declaration, and the merge chases // it through the same member tables the overlay does. + // An inherited miss is a class's business, and a class has one + // surface. Resolution::InheritedCandidate { base, paths } => Some(ReferenceFact::External { name: reference.name.clone(), base: Some(base.clone()), paths: paths.clone(), + surface: Surface::Connection, occurrence: reference.name_span, }), _ => None, @@ -417,10 +459,13 @@ fn collect_members( let Some(member) = sem.symbol(id) else { continue; }; - if !is_exported(unit.kind, member.kind) || member.name_span.is_empty() { + let Some(surface) = hierarchy::surface_of(unit.kind, member.kind) else { + continue; + }; + if member.name_span.is_empty() { continue; } - let mut decl = Decl::member(member, lines); + let mut decl = Decl::member(member, lines, surface); let nested = nested_key(key, member); if let Some(nested) = &nested { decl.type_name = Some(nested.clone()); @@ -487,80 +532,3 @@ fn is_unit(kind: SymbolKind) -> bool { matches!(kind, SymbolKind::Package | SymbolKind::Typedef | SymbolKind::Class) || kind.is_instantiable() } - -/// What `unit::member` / `.member` may reach. -/// -/// A package or class exports everything declared at its top level (a -/// package's classes included — that is what lets `import uvm_pkg::*` answer -/// `uvm_object`). A **module** exports only what a connection list can name — -/// its ports and its parameters — so an internal net is never reachable from -/// another file. -/// -/// An **interface** is the exception the 2026-09-01 round exists for: its -/// signals *are* its surface. `virtual bus_if vif; vif.data` is how every DV -/// testbench in the world reaches `data`, and `data` is an ordinary net or -/// variable declared inside the interface, not a port of it. So an interface -/// exports its nets, variables, ports, parameters, typedefs, methods, modports -/// and clocking blocks. The module ruling is untouched: a module handle is an -/// *instance*, whose internals no other file's connection list may name. -fn is_exported(unit: SymbolKind, member: SymbolKind) -> bool { - match unit { - SymbolKind::Package | SymbolKind::Class => matches!( - member, - SymbolKind::Param - | SymbolKind::LocalParam - | SymbolKind::Typedef - | SymbolKind::EnumVariant - | SymbolKind::Function - | SymbolKind::Task - | SymbolKind::Net - | SymbolKind::Var - | SymbolKind::Class - | SymbolKind::Constraint - | SymbolKind::Covergroup - | SymbolKind::Property - | SymbolKind::Sequence - ), - // A module exports its ports and parameters — and, since - // `sva-bodies`, the properties and sequences declared in its body: a - // bound-in checker module names them as `top.u_dut.p_req`, and an - // `` `include``d assertion file instantiates them by bare name. - SymbolKind::Module => matches!( - member, - SymbolKind::Port - | SymbolKind::Param - | SymbolKind::LocalParam - | SymbolKind::Property - | SymbolKind::Sequence - ), - // A `typedef struct`/`union` exports its fields, and a field that is - // itself an inline aggregate exports its own — which is what a - // generated register package is: `reg2hw_t` → `ctrl` → `q`. Nothing - // else lives in a struct body, so this arm is exhaustive by - // construction rather than by policy. - SymbolKind::Typedef | SymbolKind::StructMember => { - matches!(member, SymbolKind::StructMember) - } - // A covergroup's surface is its labelled coverpoints and crosses — - // `cg.cp` is how a cross in another covergroup, or a `get_coverage` - // call in another file, names one — plus the `sample` method the - // header declares. - SymbolKind::Covergroup => { - matches!(member, SymbolKind::Coverpoint | SymbolKind::Cross | SymbolKind::Function) - } - SymbolKind::Interface => matches!( - member, - SymbolKind::Net - | SymbolKind::Var - | SymbolKind::Port - | SymbolKind::Param - | SymbolKind::LocalParam - | SymbolKind::Typedef - | SymbolKind::Function - | SymbolKind::Task - | SymbolKind::Modport - | SymbolKind::Clocking - ), - _ => false, - } -} diff --git a/crates/vlog_semantic/src/workspace/reexport.rs b/crates/vlog_semantic/src/workspace/reexport.rs index 79a5cd4..3b0c7fd 100644 --- a/crates/vlog_semantic/src/workspace/reexport.rs +++ b/crates/vlog_semantic/src/workspace/reexport.rs @@ -14,6 +14,8 @@ use std::collections::{HashSet, VecDeque}; use vlog_parser::ast::{ExportDecl, Item, ItemKind, SourceFile}; +use crate::model::Surface; + use super::external::{own_chain, own_members}; use super::{Def, WorkspaceIndex}; @@ -127,7 +129,8 @@ pub(super) fn member<'i>(index: &'i WorkspaceIndex, unit: &str, name: &str) -> & if !seen.insert(hop) { continue; } - let found = own_chain(index, hop, name); + // A package's surface is a package's surface: one, and connection. + let found = own_chain(index, hop, name, Surface::Connection); if !found.is_empty() { return found; } @@ -164,11 +167,15 @@ pub(super) fn members<'i>(index: &'i WorkspaceIndex, unit: &str) -> Vec<(&'i str } match only { None => { - out.extend(own_members(index, package)); + out.extend(own_members(index, package, Surface::Connection)); queue.extend(hops(index, package)); } Some(name) => { - out.extend(own_chain(index, package, name).first().map(|def| (name, def))); + out.extend( + own_chain(index, package, name, Surface::Connection) + .first() + .map(|def| (name, def)), + ); queue.extend( index .reexports(package) diff --git a/crates/vlog_semantic/src/workspace/update.rs b/crates/vlog_semantic/src/workspace/update.rs index f8c2b51..839cadf 100644 --- a/crates/vlog_semantic/src/workspace/update.rs +++ b/crates/vlog_semantic/src/workspace/update.rs @@ -9,6 +9,8 @@ use std::path::{Path, PathBuf}; use vlog_parser::defines::DefineKind; +use crate::model::Surface; + use super::external::{resolve_fact, ExternalTarget}; use super::record::{facts_of, FileFacts, ReferenceFact}; use super::{ @@ -251,6 +253,7 @@ impl WorkspaceIndex { None => { self.units.clear(); self.members.clear(); + self.hier_members.clear(); self.instantiations.clear(); self.subclasses.clear(); self.reexports.clear(); @@ -262,6 +265,7 @@ impl WorkspaceIndex { } for name in &affected.containers { self.members.remove(name); + self.hier_members.remove(name); } for name in &affected.modules { self.instantiations.remove(name); @@ -289,7 +293,14 @@ impl WorkspaceIndex { if affected.is_some_and(|a| !a.containers.contains(unit)) { continue; } - self.members + // The record's own tag picks the table; the two are keyed + // alike, are cleared together above, and a caller that names + // no surface reads the connection one. + let table = match decl.surface { + Surface::Connection => &mut self.members, + Surface::Hierarchical => &mut self.hier_members, + }; + table .entry(unit.clone()) .or_default() .entry(decl.name.clone()) @@ -365,8 +376,8 @@ impl WorkspaceIndex { }; sites.entry(key).or_default().push(site); } - ReferenceFact::External { name, base, paths, .. } => { - match resolve_fact(self, name, base.as_deref(), paths) { + ReferenceFact::External { name, base, paths, surface, .. } => { + match resolve_fact(self, name, base.as_deref(), paths, *surface) { ExternalTarget::Resolved(def) => { sites.entry(DefinitionKey::of(&def)).or_default().push(site); } diff --git a/crates/vlog_semantic/tests/classes.rs b/crates/vlog_semantic/tests/classes.rs index 29884e5..ad62ac8 100644 --- a/crates/vlog_semantic/tests/classes.rs +++ b/crates/vlog_semantic/tests/classes.rs @@ -6,7 +6,7 @@ use std::path::PathBuf; use vlog_parser::parse_source; use vlog_semantic::{ analyze, resolve_external, Definition, ExternalTarget, Resolution, ScopeKind, Semantics, - SymbolId, SymbolKind, WorkspaceIndex, + Surface, SymbolId, SymbolKind, WorkspaceIndex, }; fn sem(src: &str) -> Semantics { @@ -309,7 +309,7 @@ endclass "; let s = sem(src); match resolution_at(&s, nth(src, "uvm_object", 0)) { - Resolution::ExternalCandidate { paths } => { + Resolution::ExternalCandidate { paths, .. } => { // The wildcard import and the bare unit name, in that order. assert_eq!(paths, vec!["uvm_pkg::*".to_string(), "uvm_object".to_string()]); } @@ -393,11 +393,17 @@ endclass let s = sem(src); assert_eq!( resolution_at(&s, nth(src, "other_pkg", 0)), - Resolution::ExternalCandidate { paths: vec!["other_pkg".to_string()] } + Resolution::ExternalCandidate { + paths: vec!["other_pkg".to_string()], + surface: Surface::Connection, + } ); assert_eq!( resolution_at(&s, nth(src, "other_base", 0)), - Resolution::ExternalCandidate { paths: vec!["other_base".to_string()] } + Resolution::ExternalCandidate { + paths: vec!["other_base".to_string()], + surface: Surface::Connection, + } ); assert_eq!( resolution_at(&s, nth(src, "member_miss", 0)), @@ -482,7 +488,7 @@ endfunction let s = sem(src); // The class is not in this file: the head is an external candidate... match resolution_at(&s, nth(src, "elsewhere", 0)) { - Resolution::ExternalCandidate { paths } => { + Resolution::ExternalCandidate { paths, .. } => { assert_eq!(paths, vec!["elsewhere".to_string()]) } other => panic!("expected an external candidate, got {other:?}"), @@ -562,7 +568,10 @@ endmodule let s = sem(src); assert_eq!( resolution_at(&s, nth(src, "later::K", 0) + 7), - Resolution::ExternalCandidate { paths: vec!["later::K".to_string()] } + Resolution::ExternalCandidate { + paths: vec!["later::K".to_string()], + surface: Surface::Connection, + } ); } diff --git a/crates/vlog_semantic/tests/interfaces.rs b/crates/vlog_semantic/tests/interfaces.rs index f53aa4c..f1108c4 100644 --- a/crates/vlog_semantic/tests/interfaces.rs +++ b/crates/vlog_semantic/tests/interfaces.rs @@ -6,8 +6,8 @@ use std::path::{Path, PathBuf}; use vlog_parser::parse_source; use vlog_semantic::{ - analyze, resolve_external, Def, ExternalTarget, FileFacts, Resolution, Semantics, Symbol, - SymbolKind, WorkspaceIndex, + analyze, resolve_external, Def, ExternalTarget, FileFacts, Resolution, Semantics, Surface, + Symbol, SymbolKind, WorkspaceIndex, }; // ---------------------------------------------------------------------- @@ -112,7 +112,10 @@ fn an_interface_instantiation_resolves_in_file_and_across_files() { let use_at = at(sources[1].1, "bus_if u_bus"); assert_eq!( resolution(&sem(sources[1].1), use_at), - Some(Resolution::ExternalCandidate { paths: vec!["bus_if".to_string()] }) + Some(Resolution::ExternalCandidate { + paths: vec!["bus_if".to_string()], + surface: Surface::Connection, + }) ); let def = overlay_def(&ws, sources[1].1, use_at).expect("the unit table answers"); assert_eq!(def.kind, SymbolKind::Interface); @@ -251,7 +254,10 @@ fn the_modport_half_of_a_port_type_resolves_across_files() { let tail = after(src, "bus_if."); assert_eq!( resolution(&sem(src), tail), - Some(Resolution::ExternalCandidate { paths: vec!["bus_if::mp".to_string()] }) + Some(Resolution::ExternalCandidate { + paths: vec!["bus_if::mp".to_string()], + surface: Surface::Connection, + }) ); let def = overlay_def(&ws, src, tail).expect("the member table answers"); assert_eq!(def.kind, SymbolKind::Modport); @@ -350,7 +356,10 @@ fn a_clocking_signal_is_reached_through_the_block_in_file_and_across_files() { let tail = after(env, "vif.cb."); assert_eq!( resolution(&sem(env), tail), - Some(Resolution::ExternalCandidate { paths: vec!["bus_if::cb::data".to_string()] }) + Some(Resolution::ExternalCandidate { + paths: vec!["bus_if::cb::data".to_string()], + surface: Surface::Connection, + }) ); let def = overlay_def(&ws, env, tail).expect("the member chain answers"); assert_eq!(slice(&ws, &sources, &def), "data"); diff --git a/crates/vlog_semantic/tests/member_access.rs b/crates/vlog_semantic/tests/member_access.rs index 0cedfd7..6003f20 100644 --- a/crates/vlog_semantic/tests/member_access.rs +++ b/crates/vlog_semantic/tests/member_access.rs @@ -6,7 +6,7 @@ use std::path::PathBuf; use vlog_parser::parse_source; use vlog_semantic::{ - analyze, resolve_external, Def, ExternalTarget, Resolution, Semantics, SymbolKind, + analyze, resolve_external, Def, ExternalTarget, Resolution, Semantics, Surface, SymbolKind, WorkspaceIndex, }; @@ -284,11 +284,17 @@ endmodule let s = sem(src); assert_eq!( resolution_at(&s, tail(src, "h.user_id", 0)), - Resolution::ExternalCandidate { paths: vec!["c1::user_id".to_string()] } + Resolution::ExternalCandidate { + paths: vec!["c1::user_id".to_string()], + surface: Surface::Connection, + } ); assert_eq!( resolution_at(&s, tail(src, "q.other", 0)), - Resolution::ExternalCandidate { paths: vec!["c2::other".to_string()] } + Resolution::ExternalCandidate { + paths: vec!["c2::other".to_string()], + surface: Surface::Connection, + } ); } @@ -525,7 +531,10 @@ fn a_qualified_type_from_a_package_elsewhere_still_reaches_the_workspace() { let s = sem(src); assert_eq!( resolution_at(&s, tail(src, "h.user_id", 0)), - Resolution::ExternalCandidate { paths: vec!["c1::user_id".to_string()] } + Resolution::ExternalCandidate { + paths: vec!["c1::user_id".to_string()], + surface: Surface::Connection, + } ); } @@ -795,7 +804,10 @@ fn a_chain_resolves_link_by_link_in_one_file() { fn a_chain_resolves_across_three_files() { assert_eq!( resolution_at(&sem(DRIVER), tail(DRIVER, "item.hdr.addr", 0)), - Resolution::ExternalCandidate { paths: vec!["item_t::hdr::addr".to_string()] }, + Resolution::ExternalCandidate { + paths: vec!["item_t::hdr::addr".to_string()], + surface: Surface::Connection, + }, "the single-file layer composes the path and stops" ); for order in [ @@ -929,8 +941,11 @@ endmodule } /// Across files, an instance head reaches what the index holds for the module -/// — its **ports and parameters**, which is what a module exports (see the -/// feature README's round-2 ruling on internal signals). +/// on its **hierarchical** surface: its ports and parameters, and — since +/// 2026-09-05 — its internal nets and variables too, because `u.internal` is +/// a hierarchical path and IEEE 1800 §23.6 says a hierarchical path may name +/// any of them (`docs/features/hierarchical-tail/README.md`). A `.internal(w)` +/// *connection* is still refused: that reads the connection surface. #[test] fn an_instance_head_reaches_a_module_in_another_file() { const SUB: &str = @@ -938,16 +953,27 @@ fn an_instance_head_reaches_a_module_in_another_file() { const TOP: &str = "module m;\n sub u ();\n initial begin\n y = u.clk_i;\n y = u.W;\n y = u.internal;\n end\nendmodule\n"; assert_eq!( resolution_at(&sem(TOP), tail(TOP, "u.clk_i", 0)), - Resolution::ExternalCandidate { paths: vec!["sub::clk_i".to_string()] } + // An instance head is a hierarchical path, and its tail reads the + // module's hierarchical surface — which holds the connection surface + // whole, so a *port* named through one has exactly one answer. + Resolution::ExternalCandidate { + paths: vec!["sub::clk_i".to_string()], + surface: Surface::Hierarchical, + } ); let ws = index(&[("sub.sv", SUB), ("top.sv", TOP)]); let port = overlay_def(&ws, TOP, tail(TOP, "u.clk_i", 0)).expect("the port"); assert_eq!(port.kind, SymbolKind::Port); let param = overlay_def(&ws, TOP, tail(TOP, "u.W", 0)).expect("the parameter"); assert_eq!(param.kind, SymbolKind::Param); - // An internal net is not exported to any other file — the same rule a - // `.secret(w)` connection has always followed. - assert!(overlay_def(&ws, TOP, tail(TOP, "u.internal", 0)).is_none()); + // An internal net is reached hierarchically and nowhere else: the tail + // resolves to `sub`'s own declaration of it... + let net = overlay_def(&ws, TOP, tail(TOP, "u.internal", 0)).expect("the internal net"); + assert_eq!(net.kind, SymbolKind::Net); + // ...while the connection surface — what a `.internal(w)` connection and a + // connection list's completion read — still does not hold it. + assert!(ws.member("sub", "internal").is_empty()); + assert_eq!(ws.member("sub", "clk_i").len(), 1, "a port is on both surfaces, once"); } /// The spines a chain is **not** walked from, each still resolving whatever @@ -1035,7 +1061,10 @@ fn a_hierarchical_path_crosses_a_file_boundary() { const TB: &str = "module dut;\n core u_core ();\nendmodule\n\nmodule tb;\n dut dut_i ();\nendmodule\n\nmodule probe;\n initial y = tb.dut_i.u_core.sig;\nendmodule\n"; assert_eq!( resolution_at(&sem(TB), tail(TB, "tb.dut_i.u_core.sig", 0)), - Resolution::ExternalCandidate { paths: vec!["core::sig".to_string()] } + Resolution::ExternalCandidate { + paths: vec!["core::sig".to_string()], + surface: Surface::Hierarchical, + } ); let ws = index(&[("core.sv", CORE), ("tb.sv", TB)]); let def = overlay_def(&ws, TB, tail(TB, "tb.dut_i.u_core.sig", 0)).expect("the leaf signal"); diff --git a/crates/vlog_semantic/tests/member_site.rs b/crates/vlog_semantic/tests/member_site.rs index 275c543..0a56b32 100644 --- a/crates/vlog_semantic/tests/member_site.rs +++ b/crates/vlog_semantic/tests/member_site.rs @@ -14,8 +14,8 @@ use std::path::PathBuf; use vlog_parser::parse_source; use vlog_semantic::{ - analyze, resolve_external, MemberSite, Resolution, Scope, ScopeId, Semantics, SymbolKind, - WorkspaceIndex, + analyze, resolve_external, MemberSite, Resolution, Scope, ScopeId, Semantics, Surface, + SymbolKind, WorkspaceIndex, }; // ---------------------------------------------------------------------- @@ -202,7 +202,7 @@ endmodule &[("p.hdr", "p", &[], "pkt_t"), ("p.hdr.addr", "p", &["hdr"], "pkt_t::hdr")]; for (needle, head, mids, expected_site) in cases { let at = tail(src, needle); - let Resolution::ExternalCandidate { paths } = resolution_at(&s, at) else { + let Resolution::ExternalCandidate { paths, .. } = resolution_at(&s, at) else { panic!("{needle} must be the workspace's business"); }; let member = needle.rsplit('.').next().expect("a tail"); @@ -211,7 +211,10 @@ endmodule let mids: Vec = mids.iter().map(|m| (*m).to_string()).collect(); assert_eq!( s.member_site(scope_at(&s, at), head, &mids), - Some(MemberSite::Unit((*expected_site).to_string())), + Some(MemberSite::Unit { + path: (*expected_site).to_string(), + surface: Surface::Connection, + }), "{needle}: the site is the path the resolution walks, minus the tail", ); } @@ -390,7 +393,7 @@ fn super_with_a_base_in_another_file_names_that_base_as_the_unit() { let at = tail(src, "super.x"); assert_eq!( s.member_site(scope_at(&s, at), "super", &[]), - Some(MemberSite::Unit("elsewhere_c".to_string())), + Some(MemberSite::Unit { path: "elsewhere_c".to_string(), surface: Surface::Connection }), ); } @@ -497,10 +500,10 @@ fn a_package_no_file_here_declares_is_the_workspaces_unit() { let at = tail(src, "other_pkg::x"); assert_eq!( s.unit_site(scope_at(&s, at), "other_pkg"), - Some(MemberSite::Unit("other_pkg".to_string())), + Some(MemberSite::Unit { path: "other_pkg".to_string(), surface: Surface::Connection }), ); // Which is exactly the unit the resolution's own path names. - let Resolution::ExternalCandidate { paths } = resolution_at(&s, at) else { + let Resolution::ExternalCandidate { paths, .. } = resolution_at(&s, at) else { panic!("the workspace's business"); }; assert_eq!(paths, vec!["other_pkg::x".to_string()]); diff --git a/crates/vlog_semantic/tests/reexports.rs b/crates/vlog_semantic/tests/reexports.rs index 05e00fa..f133ab2 100644 --- a/crates/vlog_semantic/tests/reexports.rs +++ b/crates/vlog_semantic/tests/reexports.rs @@ -8,8 +8,8 @@ use std::path::PathBuf; use vlog_parser::parse_source_tolerant; use vlog_semantic::{ - analyze, resolve_external, Def, Definition, FileFacts, Resolution, Semantics, SymbolKind, - WorkspaceIndex, + analyze, resolve_external, Def, Definition, FileFacts, Resolution, Semantics, Surface, + SymbolKind, WorkspaceIndex, }; fn semantics(src: &str) -> Semantics { @@ -67,12 +67,18 @@ fn an_export_records_both_halves_on_exactly_their_own_bytes() { } assert_eq!( only_reference(&sem, "x").resolution, - Resolution::ExternalCandidate { paths: vec!["b_pkg::x".to_string()] }, + Resolution::ExternalCandidate { + paths: vec!["b_pkg::x".to_string()], + surface: Surface::Connection, + }, "the item is a member of the package it is taken from" ); assert_eq!( only_reference(&sem, "b_pkg").resolution, - Resolution::ExternalCandidate { paths: vec!["b_pkg".to_string()] }, + Resolution::ExternalCandidate { + paths: vec!["b_pkg".to_string()], + surface: Surface::Connection, + }, "the package half is the package itself" ); } @@ -125,7 +131,7 @@ fn a_reexported_name_is_not_visible_bare_inside_the_exporting_package() { sem.references() .iter() .filter(|r| r.name == "x") - .any(|r| matches!(&r.resolution, Resolution::ExternalCandidate { paths } + .any(|r| matches!(&r.resolution, Resolution::ExternalCandidate { paths, .. } if paths.contains(&"b_pkg::*".to_string()))), "an `import` beside the `export` is what brings the name in" ); diff --git a/crates/vlog_semantic/tests/semantics.rs b/crates/vlog_semantic/tests/semantics.rs index 1dc0c97..b0fcafd 100644 --- a/crates/vlog_semantic/tests/semantics.rs +++ b/crates/vlog_semantic/tests/semantics.rs @@ -1,7 +1,7 @@ //! What `analyze` binds, what it resolves, and what it refuses to guess. use vlog_parser::{parse_source, parse_source_tolerant}; -use vlog_semantic::{analyze, Resolution, Semantics, SymbolId, SymbolKind}; +use vlog_semantic::{analyze, Resolution, Semantics, Surface, SymbolId, SymbolKind}; fn sem(src: &str) -> Semantics { let file = parse_source(src).expect("fixture must parse"); @@ -310,25 +310,37 @@ endmodule let some = s.reference_at(nth(src, "SOMETHING", 0)).expect("the use"); assert_eq!( some.resolution, - Resolution::ExternalCandidate { paths: vec!["other_pkg::*".into()] } + Resolution::ExternalCandidate { + paths: vec!["other_pkg::*".into()], + surface: Surface::Connection, + } ); let thing = s.reference_at(nth(src, "named_pkg::THING", 0) + 11).expect("the imported name"); assert_eq!( thing.resolution, - Resolution::ExternalCandidate { paths: vec!["named_pkg::THING".into()] } + Resolution::ExternalCandidate { + paths: vec!["named_pkg::THING".into()], + surface: Surface::Connection, + } ); let scoped = s.reference_at(nth(src, "elsewhere_pkg::VALUE", 0) + 15).expect("the tail"); assert_eq!( scoped.resolution, - Resolution::ExternalCandidate { paths: vec!["elsewhere_pkg::VALUE".into()] } + Resolution::ExternalCandidate { + paths: vec!["elsewhere_pkg::VALUE".into()], + surface: Surface::Connection, + } ); // An instantiation of a module this file does not declare, and its ports. let module = s.reference_at(nth(src, "missing_mod", 0)).expect("the module name"); assert_eq!( module.resolution, - Resolution::ExternalCandidate { paths: vec!["missing_mod".into()] } + Resolution::ExternalCandidate { + paths: vec!["missing_mod".into()], + surface: Surface::Connection, + } ); let port = s.reference_at(nth(src, ".p(w)", 0) + 1).expect("the port name"); assert!(port.is_external_candidate()); @@ -798,7 +810,10 @@ endmodule assert_eq!(item.name, "t"); assert_eq!( item.resolution, - Resolution::ExternalCandidate { paths: vec!["pkg::t".into()] }, + Resolution::ExternalCandidate { + paths: vec!["pkg::t".into()], + surface: Surface::Connection, + }, "the same candidate `pkg::t x;` would record" ); } diff --git a/crates/vlog_semantic/tests/workspace.rs b/crates/vlog_semantic/tests/workspace.rs index cfcfd46..e8f5d6d 100644 --- a/crates/vlog_semantic/tests/workspace.rs +++ b/crates/vlog_semantic/tests/workspace.rs @@ -6,7 +6,7 @@ use vlog_parser::defines::{collect_defines, DefineTable}; use vlog_parser::{parse_source_tolerant, parse_tolerant, tokenize}; use vlog_semantic::{ analyze, resolve_external, Def, Definition, ExternalTarget, FileFacts, FileId, Resolution, - Semantics, SymbolKind, Utf16Pos, WorkspaceIndex, + Semantics, Surface, SymbolKind, Utf16Pos, WorkspaceIndex, }; /// Build an index from `(path, source)` literals, as a server would from disk. @@ -529,7 +529,10 @@ fn an_unqualified_type_miss_carries_its_own_name_to_the_unit_table() { assert_eq!( resolution(&sem, sources[1].1, "bus_if bus"), - Resolution::ExternalCandidate { paths: vec!["bus_if".to_string()] } + Resolution::ExternalCandidate { + paths: vec!["bus_if".to_string()], + surface: Surface::Connection, + } ); let defs = external_defs(&sem, &ws, sources[1].1, "bus_if bus"); assert_eq!(defs.len(), 1, "{defs:?}"); @@ -600,7 +603,10 @@ fn a_direction_less_first_ansi_port_binds_its_interface_type_cross_file() { let sem = semantics(src); assert_eq!( resolution(&sem, src, needle), - Resolution::ExternalCandidate { paths: vec!["bus_if".to_string()] }, + Resolution::ExternalCandidate { + paths: vec!["bus_if".to_string()], + surface: Surface::Connection, + }, "{needle}" ); let defs = external_defs(&sem, &ws, src, needle); @@ -771,7 +777,10 @@ fn an_import_that_can_supply_the_name_still_wins_over_a_same_named_unit() { assert_eq!( resolution(&sem, sources[2].1, "state_t s"), - Resolution::ExternalCandidate { paths: vec!["tdp::*".to_string(), "state_t".to_string()] } + Resolution::ExternalCandidate { + paths: vec!["tdp::*".to_string(), "state_t".to_string()], + surface: Surface::Connection, + } ); let defs = external_defs(&sem, &ws, sources[2].1, "state_t s"); assert_eq!(defs.len(), 1, "{defs:?}"); @@ -896,7 +905,7 @@ fn the_corpus_index_finishes_most_external_references() { let counts = ws.counts(); println!( "workspace index: {} files in {:.2}s — {} modules, {} packages, {} file-scope typedefs, \ - {} classes, {} exported members, {} define directives", + {} classes, {} exported members (+{} hierarchical-only), {} define directives", counts.files, build.as_secs_f64(), counts.modules, @@ -904,6 +913,7 @@ fn the_corpus_index_finishes_most_external_references() { counts.typedefs, counts.classes, counts.members, + counts.hierarchical_members, counts.defines, ); @@ -1004,7 +1014,7 @@ impl Tally { ExternalTarget::StillUnresolved => { self.unresolved += 1; let paths = match &reference.resolution { - Resolution::ExternalCandidate { paths } => paths.join(" | "), + Resolution::ExternalCandidate { paths, .. } => paths.join(" | "), _ => String::new(), }; let entry = self.misses.entry(paths).or_insert((0, reference.name.clone())); @@ -1064,6 +1074,72 @@ impl Tally { } } +/// **The §49 census delta, measured rather than asserted.** Over the whole +/// corpus, how many references the hierarchical surface is the *only* reason +/// the workspace can answer: a candidate carrying [`Surface::Hierarchical`] +/// that lands on a record the *hierarchical-only* table holds. Membership of +/// that table is the exact test — a hierarchical candidate landing on a port, +/// a parameter or an **interface's** signal is not part of the delta, because +/// those are on the connection surface and resolved before §49 too, through +/// the connection table the hierarchical read consults first. +/// +/// The number is printed, not pinned to a constant: the corpus moves, and a +/// hard number here would be a test that fails for the wrong reason. What is +/// pinned is the direction — the hierarchical surface must actually be +/// answering something, and every answer it gives must be one of the three +/// kinds that live on it. +#[test] +fn the_hierarchical_surface_is_what_answers_a_measurable_slice_of_the_corpus() { + let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../corpus"); + if !root.is_dir() { + eprintln!("corpus/ not checked out — skipping"); + return; + } + let mut paths = Vec::new(); + collect(&root, &mut paths); + paths.sort(); + let sources: Vec<(PathBuf, String)> = paths + .iter() + .filter_map(|p| std::fs::read_to_string(p).ok().map(|s| (p.clone(), s))) + .collect(); + let ws = WorkspaceIndex::build(sources.iter().map(|(p, s)| (p.clone(), s.as_str()))); + + let (mut candidates, mut answered, mut only_hierarchical) = (0usize, 0usize, 0usize); + for (_, src) in &sources { + let (tree, _) = parse_source_tolerant(src); + let sem = analyze(&tree, src); + let overlay = resolve_external(&sem, &ws); + for (i, reference) in sem.references().iter().enumerate() { + if !matches!( + reference.resolution, + Resolution::ExternalCandidate { surface: Surface::Hierarchical, .. } + ) { + continue; + } + candidates += 1; + let Some(ExternalTarget::Resolved(def)) = + overlay.get(vlog_semantic::ReferenceId(i as u32)) + else { + continue; + }; + answered += 1; + let hierarchical_only = ws + .hierarchical_declarations(&reference.name) + .any(|(_, d)| d.file == def.file && d.name_span == def.name_span); + only_hierarchical += usize::from(hierarchical_only); + } + } + println!( + "hierarchical tails: {candidates} candidates, {answered} answered, \ + {only_hierarchical} of them only because of the hierarchical surface" + ); + assert!(candidates > 0, "the corpus does write hierarchical paths"); + assert!( + only_hierarchical > 0, + "the hierarchical surface answers references the connection surface could not" + ); +} + fn collect(dir: &std::path::Path, out: &mut Vec) { let Ok(entries) = std::fs::read_dir(dir) else { return; @@ -1936,8 +2012,8 @@ fn a_format_3_record_with_two_declarations_is_rejected_not_misread() { /// this format wrote back into what `FACTS_FORMAT` 3 wrote for the same file — /// remove, from every one of `units` unit-decls and `members` member-decls, the /// client positions added in format 5, the `decl_span` added in format 5, the -/// declared type name added in format 7, and the two trailing (`name_line`, -/// `detail_line`) fields added in format 4. +/// surface letter added in format 19, the declared type name added in format 7, +/// and the two trailing (`name_line`, `detail_line`) fields added in format 4. /// Assumes `D0` (no `` `define``s), which every fixture here satisfies, so the /// `U` tag's field index is fixed and decl positions can be computed directly /// rather than parsed. @@ -1946,8 +2022,8 @@ fn strip_every_decls_line_fields(encoded: &str, units: usize, members: usize) -> let units_at = fields.iter().position(|f| *f == "U").expect("a U tag"); assert_eq!(fields[units_at + 1], units.to_string(), "premise: unit count"); // A member's decl = name, kind, name_span×2, decl_span×2, detail_span×2, - // line×2, type_name — 11 fields. A unit's is that plus its two client - // ranges, four numbers each — 19. + // line×2, type_name, surface — 12 fields. A unit's is that plus its two + // client ranges, four numbers each — 20. let members_at = units_at + 2 + units * UNIT_DECL_FIELDS; assert_eq!(fields[members_at], "M", "premise: members tag follows the units"); assert_eq!(fields[members_at + 1], members.to_string(), "premise: member count"); @@ -1968,6 +2044,7 @@ fn strip_every_decls_line_fields(encoded: &str, units: usize, members: usize) -> if is_unit { fields.drain(start + MEMBER_DECL_FIELDS..start + UNIT_DECL_FIELDS); } + fields.drain(start + 11..start + 12); fields.drain(start + 10..start + 11); fields.drain(start + 8..start + 10); fields.drain(start + 4..start + 6); @@ -1976,7 +2053,7 @@ fn strip_every_decls_line_fields(encoded: &str, units: usize, members: usize) -> } /// Fields one member declaration occupies in a record this format writes. -const MEMBER_DECL_FIELDS: usize = 11; +const MEMBER_DECL_FIELDS: usize = 12; /// The same for a unit, which also carries its two client ranges. const UNIT_DECL_FIELDS: usize = MEMBER_DECL_FIELDS + 8; diff --git a/docs/coverage_gaps.md b/docs/coverage_gaps.md index 99932f5..19ae9d2 100644 --- a/docs/coverage_gaps.md +++ b/docs/coverage_gaps.md @@ -1,23 +1,23 @@ # Verilog/SystemVerilog coverage gaps — ranked (2026-09-01) -**Reading this report today (2026-09-04).** The survey below is a historical +**Reading this report today (2026-09-05).** The survey below is a historical v0.21.0 measurement with later amendments, not a fresh list of current failures. -For the current implementation and outstanding contracts, use -[repository-analysis.md](repository-analysis.md) and [topo.md](topo.md). -Since the original survey, interface/modport and struct-member semantics, -statement/class fences, header/list recovery, rule documentation, and three -lint expansion waves have landed. The old probes were not re-run as part of -the documentation audit; their historical counts are retained. +Use [repository-analysis.md](repository-analysis.md) and [topo.md](topo.md) for +current implementation status. Original probe counts remain historical. -Current follow-ups to the latest addendum: v0.40.0 recovers bare item-level -`begin` blocks as `ItemKind::GenBlock` **in tolerant mode**, so lint rules see -their contents; strict formatting still refuses them. It also improves recovery -for unclosed overrides that would consume the following instance. The -post-v0.41.0 `parser-skips` commit accepts rival conditional unit headers as -verbatim units and preserves net delays before or after the type. Its QA is -accepted; release v0.42.0 is pending. Comments immediately before a net-delay -`#` still cause a formatter verification refusal. External waiver files remain -planned, not implemented. +Through v0.44.0, external waivers, rival conditional headers, net-delay +positions and comment slots, inline aggregate overrides, statement/class +fences, header recovery, and the three lint-expansion waves have shipped. +The prior audit's atomic-write, project lint-selection and directory-cycle +findings are also fixed. Bare item-level `begin` blocks are recovered for +lint/editor consumers; strict formatting still refuses them. + +At committed `9ef1058`, type-name spans replace `vlog_semantic/src/scan.rs`, +and package re-exports resolve through shared member edges (facts codec 18). +Both are accepted for the next release. The active hierarchical-tail work +proposes codec 19; QA is pending, and handshake 23 remains open. DPI-export +name binding is a separate remaining gap (handshake 31), and generate-block +hierarchy and cross-file macro expansion remain outside these fixes. What lucisv 0.21.0 does not yet handle, ranked by severity, from two independent sweeps crossed against each other: diff --git a/docs/features/comment-slots/README.md b/docs/features/comment-slots/README.md index 6f249c4..cf2ef37 100644 --- a/docs/features/comment-slots/README.md +++ b/docs/features/comment-slots/README.md @@ -124,6 +124,10 @@ where marked; no existing field changed meaning. edited (`a_hierarchical_tail_that_resolves_is_renamed_with_its_declaration` is the pin). Not this round's to fix — the warning is exactly the heads-up §2.9-20 asked for — but it is a real gap worth a row of its own. + **Closed 2026-09-05 by TODO §49 / `docs/features/hierarchical-tail`:** a + module's hierarchical surface makes the cross-file tail resolve, so the + edit lands in both files and the warning is retired for a tail that + resolved. 3. **`docs/topo.md` rows 20, 21 and 22 are closed** and want striking by the lead (this round does not edit `topo.md`). diff --git a/docs/features/hierarchical-tail/README.md b/docs/features/hierarchical-tail/README.md new file mode 100644 index 0000000..cc42924 --- /dev/null +++ b/docs/features/hierarchical-tail/README.md @@ -0,0 +1,532 @@ +# hierarchical-tail + +TODO.md §49 — the cross-file instance-member tail in rename. `docs/topo.md` +§2.9 row 23. Ships in 0.45.0. + +## Goal + +With `module sub` in `sub.sv` and `assign w = u_x.sig;` in `top.sv`, renaming +`sub`'s internal `wire sig` used to edit `sub.sv` alone and warn about the +tail in `top.sv` — a rename that hands back a design which no longer +elaborates, with an apology. The same shape in one file resolved and was +edited. The cause was the export rule in `workspace/record.rs::is_exported`: +a module exported its ports and its parameters and nothing else, so the +cross-file member walk could not see `sig` through `u_x`. + +The lead's ruling, implemented here: a module gains a **second, distinct +member surface**. Its *connection* surface stays what it was — ports and +parameters, what a connection list may name (IEEE 1800 §23.3). Its +*hierarchical* surface is that set **plus** its nets, its variables and its +instances, which is what a hierarchical path may name from anywhere in the +design (§23.6). The index records both, tagged; only the tail walk behind an +**instance** head reads the hierarchical one. Rename's reference set then +includes the cross-file tail, the edit lands in both files, and the §2.9-20 +"the rename says so" warning is no longer raised for a tail that resolved (it +stays, unchanged, for one that did not). + +## Assumptions + +- **A hierarchical path is what an instance head opens, and nothing else + is.** `resolve.rs::head_surface` returns `Surface::Hierarchical` for exactly + `SymbolKind::Instance` and `Surface::Connection` for every other link of a + spine. A class handle, a struct field, a virtual interface and a package + path are all the connection surface, and for those units the distinction is + noise anyway — a package, a class, a struct and a covergroup have one + surface each. +- **The hierarchical surface contains the connection one.** A record is + tagged with the *narrowest* surface it joins, and a hierarchical read + consults the connection table first. So a tail naming a port has exactly one + answer, from one record, and it is the same declaration a connection-list + lookup finds. This is asserted, not assumed: + `a_tail_naming_a_port_is_one_answer_and_one_edit`. +- **A unit's members are the symbols of its own scope.** `collect_members` + walks `unit.child_scope` and no deeper (except into a nested class, struct + or covergroup, whose members are keyed under their own name). A net declared + inside a **generate block** therefore joins neither surface: its scope is + the block's. `u_x.gen_b.sig` does not resolve, and the rename leaves the + tail alone and says so — the honest refusal, pinned by + `a_generate_block_scoped_net_named_through_an_instance_is_refused_honestly`. + Widening that means teaching the index about generate scopes and their loop + indices (`u_x.gen[0].sig`), which §49 deliberately did not do. +- **An interface is unchanged.** Its signals *are* its connection surface + (the 2026-09-01 ruling: `virtual bus_if vif; vif.data` is how every DV + testbench reaches `data`, and `vif` is a variable, not an instance). It + gains only its **instances** on the hierarchical surface, for the same hop + reason a module does. +- **Two instances of a name in one module cannot happen**, so the + hierarchical table's `Vec` per name holds duplicates only across files + — the same ambiguity rule, and the same refusal, the connection table has + always had. + +## Handshakes + +### What this consumes + +- `vlog_semantic::Semantics` — `member_site` / `unit_site` return the site a + tail is walked from, and a `Symbol`'s `kind` is what says whether a link is + an instance. +- `vlog_parser` — unchanged; nothing in the parser moved. + +### What this promises + +**`vlog_semantic` (the surface encoding).** + +- `pub enum Surface { Connection, Hierarchical }` in `model.rs`, re-exported + from the crate root. +- `Resolution::ExternalCandidate { paths, surface }` — a new field. Every + construction site outside a hierarchical tail passes `Surface::Connection`; + `resolve.rs::head_surface` is the one place that can return the other. +- `MemberSite::Unit { path, surface }` — was `MemberSite::Unit(String)`. The + surface is `Hierarchical` exactly when the head of the spine was an + instance, and it stays that for every further hop: `u_a.u_b.` is one + hierarchical path. +- `WorkspaceIndex` gains `member_in(unit, member, surface)`, + `members_of_chain_in(path, surface)`, `member_unit_in(unit, member, + surface)` and `hierarchical_declarations(name)`. **Every existing method + reads the connection surface and answers exactly what it answered before**: + `member`, `members_of`, `members_of_chain`, `member_unit`, + `workspace_symbols`. +- `IndexCounts` gains `hierarchical_members`, disjoint from `members`, so the + whole member census is the two added. +- `FACTS_FORMAT` 18 → 19. Two new fields — a one-letter surface on every + declaration and on every `External` reference fact — so an older record + would be read field-shifted, and `index_cache` drops a store by format as it + already does. + +**`lucisv_server`.** `Workspace::rename_sources`' fan-out gains one rung: +every file declaring the name on a module's hierarchical surface. `state.rs` +is the only server file whose *behaviour* changed; +`completion/member.rs` follows the site's own surface (below). + +**`vlog_refactor`.** No behaviour of its own changed. `rename/warnings.rs` +took a mechanical `..` in one pattern for the new `ExternalCandidate` field; +the §2.9-20 warning retires itself, because it is raised only when the overlay +answers `StillUnresolved` and a resolved tail no longer does. + +### The completion decision, said plainly + +Behind `u_x.` **in an expression**, completion lists the module's +**hierarchical** surface — its nets, its variables and its instances as well +as its ports and its parameters. That is what the user is reaching for, it is +exactly what the tail resolution will find, and it is what the *in-file* half +of the same function has always offered for an instance this file declares +(`MemberSite::Scope` pushes every symbol of the module's scope). Making the +two halves disagree would have been the odd choice. + +Behind the `.` of a **connection list** it is the connection surface and +nothing more. `.internal_net(w)` is not a legal connection, so an item there +would be one the resolution could not answer — a wrong answer rather than a +generous one. That path is `connection_members`, which reads +`WorkspaceIndex::members_of` (the connection table) and filters to `Port` or +`Param`; it never reaches `members_at`. Both halves are pinned in one test: +`an_instance_head_lists_the_hierarchical_surface_and_a_connection_list_does_not`. + +The `propagate-ports` engine reads `member`/`members_of` and is untouched. + +### What did not widen + +- **Reference postings.** `facts_from_analysis` records a `Local` posting only + for a use whose declaration is on the **connection** surface. Posting a + module's every internal-net use would multiply the reference table by the + size of an RTL body for an answer nothing reads: the only consumer is a + rename, which re-analyses the declaring file anyway. The *cross-file* half — + the tail in the other file — is an `External` fact, and that is what makes + the rename work. +- **`workspace/symbol`.** An internal net is still not a workspace symbol: the + request answers what a user can name from outside, and a design with 20 000 + modules has hundreds of thousands of internal signals. + `hierarchical_declarations` is the separate, map-only question the rename + fan-out asks instead. +- **`verify.rs`.** Untouched. No normalization was added or broadened, so no + masked-corruption attack tests are owed. + +## Status / TODO + +- [x] 49.1 surface bit in facts, `FACTS_FORMAT` 18 → 19, index member walk +- [x] 49.2 `MemberOf` behind an instance reads the hierarchical surface; + rename edits the tail; the warning retired for resolved tails +- [x] `workspace/hierarchy.rs` — `surface_of` (the old `is_exported`, + re-ruled) plus the two surface-taking reads; `record.rs`'s export doc + comment rewritten to say the ruling moved +- [x] Completion decision made, said here, and pinned both ways +- [x] Tests: the cross-file twin of the rename pin; nested `u_a.u_b.sig`; a + tail naming a port (one answer, one edit); a parameter; the + generate-block refusal; the interface tail unchanged; the ambiguous + `sub` still refused; the connection list unchanged; the census delta +- [x] Gates (guarded); census delta explained; opentitan before/after +- [ ] QA + +## Work log + +### 2026-09-05 — dev (agent 2, resuming) + +**The state I found.** The first dev agent on this lane was cut off by a +network failure mid-round, leaving uncommitted work in the tree: 20 modified +files plus a new `crates/vlog_semantic/src/workspace/hierarchy.rs`, and no +feature README at all. `cargo check --workspace --all-targets` passed; the +agent's last words were "now the test compile errors across the workspace", +and that is exactly where it stood — the *library* half of §49 was complete +and coherent, the test suite was not green, and no new tests had been written. + +What the first agent had already built, and which I kept unchanged: the +`Surface` enum and its two carriers (`Resolution::ExternalCandidate`, +`MemberSite::Unit`), `head_surface` in `resolve.rs`, `hierarchy.rs` with +`surface_of` and the two surface-taking reads, the second `hier_members` table +in `WorkspaceIndex` with its update/clear paths, the `FACTS_FORMAT` 18 → 19 +encoding, `hierarchical_declarations` and the fan-out rung in the server's +`state.rs`, and the completion follow-the-site change in +`completion/member.rs`. It is a good design and I did not redo any of it. + +**What I finished.** + +1. Made the workspace suite green. Four failures, each a real consequence of + the change rather than a bug: + - `lucisv_server` `a_local_only_symbol_sharing_the_new_names_spelling_is_not_a_bogus_refusal` + — its fixture was a module's `wire`, which is now a hierarchical + declaration and joins the fan-out by the new rung, so the test would have + passed for the wrong reason ever after. The fixture is now a **function's + local**, which is on neither surface, and the rung-6 attack it exists for + is intact. The behaviour it used to pin got its own test beside it, + `a_module_net_sharing_the_new_names_spelling_joins_the_fan_out_and_refuses_nothing`: + the file *is* pulled in, and the rename still succeeds and still writes + nothing there. + - `vlog_semantic` `a_format_3_record_with_two_declarations_is_rejected_not_misread` + — the record stripper counts a decl's fields. `MEMBER_DECL_FIELDS` + 11 → 12, `UNIT_DECL_FIELDS` 19 → 20, and one more `drain` for the surface + letter. + - `vlog_semantic` `an_instance_head_reaches_a_module_in_another_file` — its + `u.internal` assertion was the old ruling. It now asserts the net + resolves, *and* that the connection table still does not hold it, *and* + that a port has one record on it. + - `lucisv_server` e2e `an_instance_heads_port_is_hovered_across_files` — + hover of `u.internal` across files now answers with the net's own + declaration. The test asserts the file and line it names. +2. Wrote the plan's tests (all passed first time against the first agent's + library code, which is the strongest evidence I have that it was finished): + the cross-file twin driven from **both** ends, nested `u_a.u_b.sig` over + three files, the port, the parameter, the generate-block refusal, the + interface tail, the ambiguous-`sub` refusal from both ends, and the + two-way completion pin. +3. Added the census-delta measurement as a corpus test rather than a prose + claim, and put the hierarchical count into the index census line. +4. Wrote this README, which the first agent had not started. + +**Deviations and files touched outside the plan's expected set.** The plan +named `crates/vlog_semantic/{facts.rs,workspace/*}`, +`crates/vlog_refactor/src/rename/*`, +`crates/lucisv_server/src/{completion/*,state.rs}`, tests, this README and +`TODO.md`. Beyond those I touched: + +- `crates/lucisv_server/src/rename.rs` — **tests only** (the `#[cfg(test)]` + block): the fixture swap and the new sibling test above. No production line + in that file changed. +- `crates/lucisv_server/tests/e2e.rs` — the hover assertion above. +- `crates/vlog_semantic/src/{lib.rs,model.rs,resolve.rs}` — the first agent's + work, and unavoidable: `Surface` has to live in the model and be exported, + and `resolve.rs` is where a spine's head is visible. + +**One size flag for the lead.** `crates/lucisv_server/src/state.rs` is **957 +production lines outside its test module** — already well over the 800 +threshold before this lane, and CLAUDE.md's post-§28 measurement (which names +only `perf.rs` and `lexer.rs` as over 600) is stale for it. This lane added +**13** production lines there: the fan-out's new rung, seven lines inside +`fan_out_of` plus its doc bullet. The rule says a dev adding to a file near +600 puts the code in a new module; I did not, because the rung reads +`self.index`, `want_declaration` and the caller's `containers` set and a +module holding seven lines of it would be worse than the disease. The file +wants a split of its own, which is a decomposition round, not a paragraph in +this one. Every other file this lane touched is inside the rule: +`workspace/hierarchy.rs` 80 production lines, `workspace/index.rs` 283, +`workspace/record.rs` 315 (it *lost* the 60-line `is_exported`), +`model.rs` 161, `resolve.rs` 520, `facts.rs` 526. Every function added or +changed is under 50 lines. + +**The gates.** `cargo fmt -p vlog_semantic -p lucisv_server -p vlog_refactor` +(never `--all`) and `cargo clippy --all-targets` clean; `cargo test +--workspace` **3 839 passed / 0 failed / 44 ignored** (baseline 3 829, +10: +seven new rename tests, one new server fan-out test, one new completion test, +one new census test); `tools/corpus_check.sh` **814/820**, the same six +pre-existing parse errors (`compare_helper.sv`, `riscv_core_setting.tpl.sv`, +`latch_map.v`, `riscv_instr_cover_group.sv`, `romload/testbench.v`, +`smtbmc/mulcmp.v`); `format --stdout` over all **860** corpus files +**byte-identical** to `~/.cache/lucisv-baselines/lucisv-0.44.0`, 0 differing; +`cargo build --release -p lucisv_server` + `node editors/vscode/smoke.js` OK. +Everything through `tools/guard.sh`; no guard kill, no limit raised. + +**The census delta.** The single-file corpus census does not move at all — +860 files, 27 486 symbols, 103 875 references, 1 197 unresolved, 0 unplaced, +identical to the number the brief carried. It cannot move: §49 adds a tag to +a resolution, not a resolution. What moves is the *workspace* census: + +| | before | after | +|---|---|---| +| exported members (connection surface) | 12 939 | 12 939 | +| hierarchical-only members | — | **5 239** | +| corpus references only the hierarchical surface answers | 0 | **335** | + +The connection count is unchanged **by construction**: `surface_of`'s +`Surface::Connection` arms are the old `is_exported`'s `true` arms, name for +name, with the hierarchical kinds added as new arms. The 5 239 new records are +the corpus's modules' and interfaces' nets, variables and instances. Over the +whole corpus 707 references carry a hierarchical candidate and 668 of them +resolve; **335** of those land in the hierarchical-only table, which is the +slice that could not resolve before. +`the_hierarchical_surface_is_what_answers_a_measurable_slice_of_the_corpus` +prints the three numbers on every run and pins the direction, not the +constants. + +A note on how that 335 is counted, because the obvious way is wrong. "The +declaration's kind is `Net`, `Var` or `Instance`" over-counts by 216 on this +corpus: an **interface's** signals are `Net`/`Var` and are on the *connection* +surface, so they resolved before §49 as well. The exact test is membership of +the hierarchical-only table itself +(`WorkspaceIndex::hierarchical_declarations`), which is what the test does. + +### opentitan (read-only, scratch index store) + +Everything below is a `textDocument/rename` **request** whose returned edit +was inspected and never applied. +`git -C ~/repo/opentitan status --porcelain` reported the same three +pre-existing files (`hw/ip/aes/dv/tb/tb.sv`, +`hw/top_darjeeling/ip/ast/rtl/ast.sv`, `hw/top_earlgrey/ip/ast/rtl/ast.sv`) +before and after every run. Baseline binary: `lucisv-server` built +`--release` from the `v0.44.0` tag in a scratch `git worktree` under the +scratchpad, removed afterwards. Guard on every command; **no guard kill**. + +**The headline — a DV bench reaching an IP module's internal variable.** +`hw/ip/lc_ctrl/dv/tb.sv:229` writes +`assign #1ps lc_ctrl_if.lc_ctrl_fsm_state = dut.u_lc_ctrl_fsm.fsm_state_q;`, +and `fsm_state_q` is declared at `hw/ip/lc_ctrl/rtl/lc_ctrl_fsm.sv:173`. +Renaming it (root `hw/ip/lc_ctrl`, cursor on the declaration): + +| | 0.44.0 | this branch | +|---|---|---| +| files in the returned edit | `rtl/lc_ctrl_fsm.sv` (8 edits) | `rtl/lc_ctrl_fsm.sv` (8) **+ `dv/tb.sv` (1)** | +| `rename`, three tries | 10 / 9 / 10 ms | 22 / 23 / 22 ms | +| `prepareRename`, three tries | 1 / 0 / 1 ms | 0 / 0 / 1 ms | + +That is the whole feature in one row: 0.44.0 edited the RTL and left the +bench spelling the old name, and now the bench moves with it. It is also the +whole cost: the tail's file is in the rename's fan-out now, so it is read, +parsed and verified — 10 ms → 22 ms on this cursor. `prepareRename` does not +move, because it does not fan out. + +**`hw/ip/aes`, the tree the brief named.** Rename of +`hw/ip/aes/rtl/aes_core.sv:87`'s `logic key_touch_forces_reseed`, root +`hw/ip/aes`: **the same answer before and after** — `rtl/aes_core.sv`, 3 +edits — at 40 / 41 / 41 ms before and 53 / 55 / 57 ms after; `prepareRename` +≈ 1 ms in both. And the count of newly resolved `MemberOf` references over +`hw/ip/aes` is **0**, before and after. That is not a disappointment to hide, +it is the shape of the IP: `aes`'s 5 hierarchical candidates all reach through +a **generate block** (`u_aes_core.u_aes_control.gen_fsm[i]. … `, +`u_aes_core.gen_ghash.u_aes_ghash. … ` in `rtl/aes.sv`) or sit inside a +`bind aes …` in `dv/sva/aes_bind.sv`, where the head is resolved in the bind +target's scope in another file and is therefore not an instance symbol this +file can see. Neither is on either surface, and §49 said so in advance. + +Over **all of `hw/`** (3 979 files) the picture is the one the corpus +predicts: 91 930 connection members + **71 849** hierarchical-only ones; +1 611 references carry a hierarchical candidate, 1 290 resolve, and **514** +of those are answers only the hierarchical surface can give — `lc_ctrl`, +`otbn`, `keymgr`, `dma` and `entropy_src` benches reaching into their DUTs. + +**Store size** (the scratch `initializationOptions.storagePath`, the whole +index cache for that root): + +| root | 0.44.0 | this branch | delta | +|---|---|---|---| +| `hw/ip/aes` (124 files) | 1 459 576 B | 1 615 179 B | +155 603 B, **+10.7 %** | +| `hw/ip/lc_ctrl` | 765 347 B | 813 065 B | +47 718 B, **+6.2 %** | + +Two things are in that delta and they are not the same size: the one-letter +surface field on every declaration and every external reference fact (small, +and paid whether or not a module has internals), and the hierarchical member +records themselves (the bulk). + +## QA log + +### 2026-09-05 — QA + +**Diffs read in full**: `resolve.rs`, `model.rs`, `workspace/{hierarchy.rs (new), +external.rs, index.rs, mod.rs, record.rs, reexport.rs, update.rs}`, `facts.rs`, +`lib.rs`, `rename/warnings.rs`, `completion/member.rs`, `state.rs`, `rename.rs`, +`e2e.rs`, all touched test files. Traced `head_surface` end to end — a link +opens `Surface::Hierarchical` exactly when the *head symbol's own kind* is +`SymbolKind::Instance` (`resolve.rs::link_type`/`head_surface`), never off a +type name's spelling; a same-file spine stays on `MemberSite::Scope` +untouched by any surface at all, exactly as before this feature. The `Local` +reference-posting filter to `Surface::Connection` only in `record.rs` is by +design and doesn't widen anything: an internal net's own-file uses are found +by re-analysing its declaring file directly (which rename always does for +the file it edits), not through the posting table that filter narrows. + +**Gates (guarded, `tools/guard.sh` throughout).** `cargo fmt --check` clean; +`cargo clippy --all-targets` clean; `cargo test --workspace`: **3 839 passed +/ 0 failed / 44 ignored** — matches the dev's claim exactly (re-verified +twice: once with the QA attack tests added, once after removing them, same +count both times save for the attacks themselves). `tools/corpus_check.sh`: +**814/820**, the same six pre-existing parse errors. `format --stdout` over +all 860 corpus files vs `~/.cache/lucisv-baselines/lucisv-0.44.0`: **0 +differing**. Release build (`lucisv`, `lucisv_server`) + VS Code smoke +(`node editors/vscode/smoke.js target/release/lucisv-server`): OK. Census: +`the_corpus_index_finishes_most_external_references` prints 860 files, +103 875 references, 12 939 connection members + **5 239** hierarchical-only — +matches the README's table exactly. + +**Rename matrix, driven through the public engine API (`vlog_refactor`) and +confirmed by the dev's own tests plus attacks I added and then removed +(temporary `qa_49_*` tests, run green, then deleted — the tree is back to +exactly the dev's diff):** + +- Cross-file twin from both ends, nested `u_a.u_b.sig` over three files, a + port (one answer, one edit — checked the tail's edit range fires once, not + once per surface), a parameter, the generate-block-scoped net refused + honestly with no edit, an interface instance tail unchanged, the ambiguous + two-`sub` case refused from both ends: all the dev's own tests, read and + re-run green. +- **New attack — rename onto a name already in the module, via the + hierarchical tail, from both ends**: refused (`"would change what..."`). + The live cross-file tail does not bypass the ordinary same-module capture + check. +- **New attack — rename a hierarchically-reached net onto a sibling port's + name**: refused. A capture across the connection/hierarchical surface + boundary is caught exactly like one within a surface. +- **New attack — a non-instance head whose *type name* happens to spell a + module name** (`sub h;` with no parens, a data declaration, not an + instantiation): `head_surface` correctly reads the head symbol's own kind + (`Var`, not `Instance`), so `h.internal` reads the connection surface and + refuses the net. No crash. +- **New attack — a hierarchical path inside a `bind` connection expression, + through an instance declared *inside the bind target's module* in another + file** (the shape behind the aes `bind` zero-count in the README): no + crash, and the tail never resolves through the wrong scope — the head is + looked up (if at all) in the writing scope, never the target's, exactly as + the README predicts. Pinned with a temporary test, then removed. +- **New attack — `didChange` promotes an internal net to a port**: before, + hierarchical-only (1 record); after, on the connection table (1 record, + not 2 — the hierarchical read still finds exactly one), and the cross-file + tail still resolves exactly once, now to the port. **New attack — + `didChange` removes the net entirely**: the hierarchical table drops the + record and the cross-file tail goes back to unresolved. Both via + `WorkspaceIndex::update_file` at the library level (no server session + needed) — the incremental-update code path (`update.rs`) is exercised + identically for hierarchical and connection tables, which is by + construction from the diff (same `absorb`/`update_file` code, dispatched + on `decl.surface`) and confirmed by these two round-trips. +- **New attack — a hierarchical declaration's own reference postings + include the cross-file tail** (`WorkspaceIndex::references_to` on a net's + `Def`, gotten via `hierarchical_declarations`): confirmed — this is the + exact mechanism `state.rs::want_declaration` stands on to pull the tail's + file into a rename's fan-out. + +**Completion.** The dev's own two-way pin +(`an_instance_head_lists_the_hierarchical_surface_and_a_connection_list_does_not`) +read and re-run. **New attacks, run green then removed**: `u_a.u_b.` +(nested) lists `u_b`'s module's own hierarchical surface, not `u_a`'s and +not empty; an instance of an **unknown** module in *expression* position +(not just the connection-list shape the dev's own +`a_module_the_workspace_does_not_declare_answers_nothing` already covered) +answers empty, no panic. + +**Opentitan (read-only; every`textDocument/rename` a request, inspected, +never applied).** Built `v0.44.0`'s `lucisv-server` in a scratch worktree +(`git worktree add`, removed after). `git -C ~/repo/opentitan status +--porcelain` showed only the three pre-existing files +(`hw/ip/aes/dv/tb/tb.sv`, `hw/top_darjeeling/.../ast.sv`, +`hw/top_earlgrey/.../ast.sv`) before and after every run — reproduced +independently, not assumed from the dev's log. + +- `lc_ctrl_fsm.sv:173`'s `fsm_state_q`, renamed from the declaration: 0.44.0 + → `rtl/lc_ctrl_fsm.sv` alone, 8 edits, 9–10 ms rename / 0–1 ms + prepareRename. This branch → **+ `dv/tb.sv`, 1 edit**, same 8 in the rtl + file, 22–24 ms rename / 0–1 ms prepareRename. Matches the README exactly. + Dumped every edit's range and the *exact source text at that range* on + both files: **every one reads `"fsm_state_q"`**, character-for-character, + new file included (`dv/tb.sv:229`, columns 63–74). +- `aes_core.sv:87`'s `key_touch_forces_reseed`: **identical answer** before + and after — `rtl/aes_core.sv`, 3 edits — 38–41 ms → 55–56 ms. Matches. +- Sampled the newly-resolved references over `hw/` with an independent + read-only tool (not the dev's — built fresh against the library API): + **1611 hierarchical candidates, 1290 answered, 514 hierarchical-only** — + matches the README's table exactly. Printed 20 of the 514 with the + occurrence line, the resolved declaration's file:line, and the + declaration's own source text. All 20 are genuine DV-bench-into-DUT + reaches (`dut.reg2hw...`, `dut.u_x.state_q`, `dut.lfsr_en`, …), every + declaration's source text actually spells the referenced name at the + claimed location, and every one is a plausible member of the instance's + module — no false positive found in the sample. + +**Findings.** None at HIGH or MEDIUM severity. Two LOW observations, neither +blocking: + +- LOW — `crates/lucisv_server/src/state.rs` is already flagged by the dev + (957 production lines) and separately filed by the lead as TODO §55; no + new action from this QA pass beyond confirming the number. +- LOW — the `Local`-reference-posting filter to the connection surface + (`record.rs::facts_from_analysis`) is a quiet, easy-to-miss line to + re-derive from first principles (it looks at first glance like it could + under-post same-file hierarchical uses). Traced it through + `merge_references`/`want_declaration` and confirmed by the incremental + `didChange` attacks above that nothing is actually lost — worth a comment + pointer from `record.rs` to `hierarchy.rs::surface_of` for the next reader, + but not a functional gap. + +**Verdict: PASS.** Rename correctness, the completion split, the verifier's +refusals, the two-table index mechanics, the census delta and the opentitan +before/after all hold under attack, including several shapes beyond the +dev's own plan (own-scope and cross-surface capture through a hierarchical +tail, a non-instance head sharing a module's name, a bind-through-target +scope, and both `didChange` directions). Every temporary QA test was +removed after running green; the tree's diff against master is byte-for-byte +the dev's original plus this log entry and the TODO.md checkbox below. + +## Docs to apply at merge (lead) + +**`docs/topo.md` §2.9 row 23** — strike, with: + +> ~~A **cross-file instance-member tail does not resolve for rename** …~~ — +> **delivered 2026-09-05 by hierarchical-tail (TODO §49):** a module now has +> two member surfaces. Its *connection* surface is unchanged — ports and +> parameters, what a connection list may name and what `member` / +> `members_of` / `members_of_chain` / the `propagate-ports` engine / +> connection-list completion read. Its *hierarchical* surface is that set plus +> its nets, variables and instances (§23.6), recorded in a second index table +> and tagged on the fact (`FACTS_FORMAT` 18 → 19), and read **only** by the +> tail walk behind an instance head (`Resolution::ExternalCandidate` carrying +> `Surface::Hierarchical`, set by `resolve.rs::head_surface`). `assign w = +> u_x.sig;` in `top.sv` now resolves to `sub.sv`'s `wire sig`, the rename +> edits both files, and the §2.9-20 warning is retired for a tail that +> resolved. A generate-block-scoped net (`u_x.gen[0].sig`) is on neither +> surface and is still refused honestly — the one gap this row leaves behind. + +**`docs/features/comment-slots/README.md`, "Findings" item 2** — the gap it +flagged is closed. **Already applied by this lane** (the one line the brief +allowed); nothing for the lead to do, it is recorded here so the merge sees +it: + +> **Closed 2026-09-05 by TODO §49 / `docs/features/hierarchical-tail`:** a +> module's hierarchical surface makes the cross-file tail resolve, so the edit +> lands in both files and the warning is retired for it. + +**`README.md`** — no change needed; it does not describe the member tables at +this depth. + +## Review + +**2026-09-05 — lead.** Accepted; ships in 0.45.0 with §47 and §48. The +first dev was cut off by the outage with the library half complete and +sound; the second kept all of it and finished the tests, the README and +the gates — the right call. The ruling is implemented as ruled: two +disjoint tables, the hierarchical one read by exactly one walk, and the +connection surface byte-identical for every existing reader (the census's +12 939 connection members unchanged by construction). QA's matrix is the +proof that matters for a rename: refusals on capture across the surface +boundary, on an ambiguous module, on a generate-scoped net; the lc_ctrl +edit inspected range by range; 20 of the 514 newly resolved opentitan +references sampled and all genuine. The completion decision (hierarchical +members behind `u_x.` in an expression, ports only in a connection list) +is what a user typing a hierarchical path wants. The rename cost of one +more file's read is the feature. QA's two LOWs: `state.rs` is filed as +§55; the `Local`-posting doc pointer is added at review. + +*(reserved for the lead — do not write here)* diff --git a/docs/repository-analysis.md b/docs/repository-analysis.md index ced7725..c7b86d2 100644 --- a/docs/repository-analysis.md +++ b/docs/repository-analysis.md @@ -1,195 +1,150 @@ # Repository analysis -Audited 2026-09-04 against HEAD `d5abf81`. The manifest still declares -**v0.41.0**; HEAD includes the accepted parser-skips work intended for -v0.42.0. This is a source and documentation audit, not a new performance or -full language-conformance measurement. +Refreshed **2026-09-05**. Latest release: **v0.44.0** (`66f3898`). This +review uses committed snapshot **`9ef1058`**, which also includes accepted +type-name-spans and package-reexports work intended for v0.45.0. The active +hierarchical-tail changes are described separately; their QA is still open. -## Assessment +## Assessment and current status -lucisv is a complete developer-tool stack, with eight Rust crates (six -libraries and two binaries), a VS Code extension, Neovim/Vim configuration, -release/corpus scripts, and an Astro/Starlight documentation site. Its strongest -architectural choices are shared language engines, runtime formatter checks, -conservative semantic resolution, and a single owner for mutable LSP state. +lucisv remains an eight-crate toolchain: six reusable Rust libraries, CLI and +LSP binaries, editor integration, corpus/release tools, and a static docs site. +The architecture still separates syntax, formatting, semantics, linting, +refactoring, and project inputs. The three issues raised by the September 4 +audit have been fixed; they should no longer be treated as open priorities. -The most consequential remaining issues found in this audit are coordination -between atomic writers and disagreement between project-file and editor lint -selection. The test suite passes, but neither result establishes those contracts: -the atomic tests exercise sequential replacement, and editor rule-selection -tests exercise client settings. Documentation had also fallen behind the -recent implementation rounds. +| Change | Status at this refresh | Implementation and contract | +|---|---|---| +| External waiver files | Released in v0.42.0 | `ExternalWaivers`, `WaiverUse`, and `lint_with`; CLI, project config and editor paths add together; inline/external suppression is a union; unused external waivers are reported only after a complete CLI run | +| Rival conditional headers and net-delay position | Released in v0.42.0 | Split units stay verbatim; delays print before or after the type according to their original position | +| Atomic-write coordination | Released in v0.43.0 | Exclusive per-operation temp files, permissions applied before bytes, CLI dedup by canonical path; separate processes remain last-writer-wins | +| Project/editor lint agreement | Released in v0.43.0 | Non-empty editor select/ignore lists override project lists independently; rejected project entries log once with file and line; valid entries continue to apply | +| Cycle-aware walks and net-delay comment slots | Released in v0.43.0 | Directory identity prevents cycles; comments around a delay's `#` are preserved | +| Walk warnings, editor rule-name warnings, aggregate overrides and delay-list comments | Released in v0.44.0 | Recoverable walk problems warn and continue; editor name typos log once; aggregate override expressions and delay-list comment slots are handled | +| didOpen cost | Released in v0.44.0 | `undriven-net` asks the workspace mention oracle after local guards; findings and synchronous request ordering stay unchanged | +| Type-name spans | Committed, accepted for v0.45.0 | `DataType::name_span()` / `segments()` and disable-target spans replace semantic name scanning; `scan.rs` is deleted | +| Package re-exports | Committed, accepted for v0.45.0 | Export name halves are references; the shared member walk follows cycle-guarded re-export edges; persisted facts gain `RX`, codec **18** | +| Hierarchical tails | **Working tree, QA pending** | Proposed codec **19**, tagged member/reference surfaces, instance-tail resolution and completion, and cross-file rename updates | + +The current source of truth for feature acceptance is each feature's QA/review +log and [TODO.md](../TODO.md). The [topology](topo.md) records the interfaces +that future changes must preserve. A missing documented edge is not proof that +two edits have disjoint ownership. ## Repository map | Location | Responsibility and starting point | |---|---| -| `crates/vlog_parser` | Lexer and trivia, strict/tolerant recursive descent, AST and source coordinates; start at `src/lib.rs`, then `parser/` and `ast/` | -| `crates/vlog_formatter` | AST → document IR → printer, alignment, fences, ranges, token equivalence and convergence; start at `src/format/mod.rs` and `src/verify.rs` | -| `crates/vlog_semantic` | File binding/resolution and workspace facts; start at `src/lib.rs`, `bind/`, `workspace/`, and `facts.rs` | -| `crates/vlog_linter` | 73-rule registry, lazy analysis, options, severity, inline waivers and fixes; start at `src/lib.rs`, `context.rs`, and `registry.rs` | -| `crates/vlog_refactor` | Rename/references, port edits and instance plans; shared `src/scope.rs`, whole-edit checks in `check.rs` | -| `crates/lucisv_core` | Config, filelists, walking, format cache and atomic replacement; no language-engine dependency | -| `crates/lucisv` | CLI argument handling, discovery, worker pool, reports and writes; `src/main.rs`, `args.rs`, `lint.rs` | -| `crates/lucisv_server` | Synchronous LSP transport, workspace state, overlays, scans and capability handlers; `src/main.rs`, `server/`, `state.rs` | -| `editors/` | VS Code client/grammar/settings/hierarchy UI, plus configuration examples for other editors | -| `tools/`, `scripts/`, `.gitea/workflows/` | Resource guard, corpus evaluation, artifact audits and release automation | -| `docs/features/` | Feature-specific contracts, implementation history, QA and review; 135 READMEs at audit time | +| `crates/vlog_parser` | Lexer/trivia, strict and tolerant recursive descent, AST/spans; `src/lib.rs`, `parser/`, `ast/` | +| `crates/vlog_formatter` | AST → document IR → printer, alignment, fences/ranges, equivalence and convergence; `format/mod.rs`, `verify.rs` | +| `crates/vlog_semantic` | File binding/resolution, workspace facts and member lookup; `bind/`, `resolve.rs`, `workspace/`, `facts.rs`; committed `workspace/reexport.rs`, active `workspace/hierarchy.rs` | +| `crates/vlog_linter` | 73-rule registry, lazy semantics, options, severities, inline/external waivers and fixes; `lib.rs`, `context.rs`, `registry.rs`, `waiver_file.rs` | +| `crates/vlog_refactor` | Rename/references, port edits, instance plans; shared `scope.rs`, whole-edit verification in `check.rs` | +| `crates/lucisv_core` | Config, filelists, cycle-aware walks and warning channel, format cache, atomic replacement; no language-engine dependency | +| `crates/lucisv` | Argument handling, input discovery/dedup, worker pool, reports and source writes | +| `crates/lucisv_server` | Ordered LSP loop and workspace overlays; `server/`, `state.rs`, capability handlers; project lint validation/logging in `lint/project.rs` | +| `editors/` | VS Code client/grammar/settings/hierarchy UI and configuration for other editors | +| `tools/`, `scripts/`, `.gitea/workflows/` | Resource guard, corpus evaluation, artifact checks and releases | +| `docs/features/` | Implementation contracts, dated measurements, QA and acceptance records | | `docs/site/` | User-facing static documentation and tracked generated output | -[topo.md](topo.md) gives dependency directions, recent cross-crate contracts, -shared interfaces, and numbered open handshakes. The manifests are authoritative -for crate edges; an absent documented edge alone does not prove two edits safe -to perform concurrently. +The crate dependency graph is unchanged. Parser and core have no dependencies; +formatter and semantics each depend on parser; linter and refactor depend on +parser and semantics. The linter depends on the formatter only in tests. +The CLI composes core/parser/formatter/linter; the server composes all six +libraries. External Rust dependencies stay in the CLI worker pool and server +LSP/JSON stack. -## Runtime behavior and limits +## Runtime contracts worth preserving -**Formatting.** `format_source` strictly parses input, renders a document tree, -re-lexes both versions and compares normalized tokens (including comments), -then parses/formats the output again and checks convergence. A failed check -returns an error instead of a candidate string. The CLI leaves the affected -source file alone. This protects lexical fidelity and stable layout; it does -not elaborate SystemVerilog or prove hardware equivalence. Fenced text still -has to parse. Ranges select items; fences can additionally protect statements -and class members. +**Formatting:** strict parse, layout, normalized token comparison (including +comments), then a second parse/format and convergence check. Failure returns +an error, not a candidate output. These are lexical/layout checks, not design +elaboration or proof of hardware equivalence. Fenced text must still parse; +ranges select items, while fences also protect statement and class scopes. -**Linting.** `ParsedSource` shares a tokenization and tolerant parse, and -`LintContext` computes semantics lazily. Rules consume text, tokens, AST, and -optional project facts; malformed AST elements remain opaque. Inline waivers -filter findings, and severity is stamped centrally. The CLI/server filter -fixes through the formatter's fence API: `apply_fixes` alone does not provide -that protection. `always-comb` offers an unsafe fix; editor actions offer only -safe fixes. +**Linting:** one prepared tokenization/tolerant parse feeds rules and lazy +semantics. Malformed AST elements remain opaque. Front ends call `lint_with` +when applying external waivers and filter automatic edits through the formatter's +fence API; `apply_fixes` alone does not protect fenced bytes. Editor actions +continue to offer only safe fixes. The mention oracle is a pure predicate; +asking it after cheap local guards avoids repeated workspace scans. -**Refactoring and editor state.** Refactors use resolved source spans and check -the whole edit; source selectors must remain supersets of every file an engine -could edit or refuse over. The LSP loop owns workspace mutation, open documents -overlay disk facts, and stepped scans publish related index/include/completion -state together. Facts persist under `FACTS_FORMAT = 17`. Lazy port code actions -compute their edits on selection for capable clients. Recorded UTF-16 positions -avoid reads for closed-file file-scope definitions; members and open buffers -still use text-based locations. +**Editor and refactors:** one loop owns workspace mutation; buffers overlay +disk facts and scans publish related index/include/completion state together. +Lazy port actions defer edits until selection. File-scope definition positions +can come from the index; members and open buffers use text-based positions. +Refactor source selectors must include every file an engine might edit or +refuse over, even when completion or navigation can answer from fewer files. -**Intentional scope.** Neither parser mode performs cross-file macro expansion -or compiler elaboration. Missing definitions outside an index scope can mean -missing hints or conservative lint silence. Rootless indexing never climbs; -with depth 0 it reads siblings flat, while positive depth walks descendants. -The published 814/820 frozen-corpus result is historical feature QA evidence, -not a new corpus sweep performed by this audit. Performance reports under -`docs/performance*.md` and `docs/perf/` likewise remain dated measurements. +**New committed semantic contracts:** a type-name segment is derived from AST +span data and verified against the source by `Binder::exact_or_empty`. The +source parameter to analysis remains necessary even though `scan.rs` is gone. +A package re-export records reference edges without adding a local import. +`export *::*` expands the package's imports into re-export facts; member lookup +follows those edges with cycle guards. Cache codec 18 prevents older stores +from silently omitting this information. -## Findings and follow-up priorities +## Active work and remaining limits -### 1. Coordinate writes to a shared target +TODO §49 owns hierarchical-tail resolution. At this refresh, its working tree +adds `Surface::{Connection, Hierarchical}`, a second member table, surface tags +on persisted declarations/references, and codec 19. Connection completion and +port propagation retain the existing ports/parameters view; paths behind an +instance can additionally reach internal nets, variables and nested instances. +Member completion and rename fan-out are part of the same contract. The feature +README reports development checks; independent QA is still pending, so topology +handshake 23 remains open. No working-tree API is treated as released here. -Evidence: [atomic.rs](../crates/lucisv_core/src/atomic.rs) canonicalizes the -target, then derives a temp name from the target filename and process ID. -`fs::write` opens that predictable path without exclusive creation. -[CLI dedup](../crates/lucisv/src/main.rs) folds lexical path components but -intentionally leaves symlinks unresolved. Two rayon jobs reaching one target -through different spellings can therefore share a temporary file. +Remaining constraints include generate-block-scoped hierarchical paths, +cross-file macro expansion, and compiler elaboration. Package re-export support +does not bind a DPI-export function name; that residue is now separated into +topology handshake 31. Shared path normalization (1) and structured formatter +error output (11) also remain open. Inline aggregate override arguments are +supported, but instance templates still omit a type default written across +multiple lines. These are narrower limits than the old audit's unresolved +entries 2, 16 and 17 suggested. -A disposable probe compiled the actual `atomic.rs` and used two barrier-started -threads per round to write different 1 MiB buffers to one target. Across -**100 rounds / 200 calls, 100 writes failed**. The final file in every round -was a complete one-writer buffer; **no mixed final bytes were observed**. This -reproduces the helper's collision, not an end-to-end formatter corruption. -The probe used only `/tmp` files and ran under the resource guard. +## Historical audit findings and evidence -Recommended follow-up: exclusive, unique per-operation temp files; coordinate -or deduplicate writes by target identity; add a concurrent alias regression. -The existing temp-and-rename helper is useful for sequential replacement, but -its tests do not justify a same-target concurrency guarantee. Tracked as -[topology handshake 26](topo.md). +The **2026-09-04** audit reproduced a temp-file collision at the old revision: +100 errors in 200 concurrent helper calls, with no mixed final bytes observed. +That is historical evidence, not a current failure. The +[atomic-write-coordination QA](features/atomic-write-coordination/README.md) +records the committed regression test and successful 2/4/8-thread checks. +[Lint-config-contract](features/lint-config-contract/README.md) records CLI/LSP +selection parity and once-only logging checks. +[Walk-cycles](features/walk-cycles/README.md) and +[small-items-4](features/small-items-4/README.md) record cycle handling, recoverable +warnings and the closed delay-comment gaps. -**Fixed by TODO §41 (0.43.0, 2026-09-05):** the probe now runs as -`atomic::tests::two_threads_writing_one_target_never_collide` and reports -0 write errors in 200 calls (QA re-ran it at 4 and 8 threads: 0 in 400 and -0 in 800); the symlink alias closes as `cli::a_symlink_and_its_target_are_one_file`. -Two processes writing one target remain last-writer-wins, stated in -`atomic.rs`. See `docs/features/atomic-write-coordination/README.md`. +[Performance take 3](performance_take3.md) measures v0.43.0 and predates the +v0.44.0 fix. The later [didOpen-cost report](features/didopen-cost/README.md) +records 1,742 ms → 117 ms on the large pinmux file at workspace scope, with +unchanged diagnostics. These are feature measurements on one machine, not +fresh measurements by this documentation refresh. The 814/820 frozen-corpus +result likewise remains attributed to feature QA; no corpus or OpenTitan sweep +is part of this refresh. -### 2. Define a consistent project lint configuration contract +## Validation of this refresh -Evidence: [server linting](../crates/lucisv_server/src/lint.rs) selects rules in -`enabled_rules` from `ClientSettings` only. Its `configured` function discovers -`lucisv.toml` but reads `lint_options` and line length, not `lint_select` or -`lint_ignore`. In contrast, [CLI linting](../crates/lucisv/src/lint.rs) consumes -project selection. The server also discards invalid project option entries -with `let _ = options.set_raw(...)`; only invalid *editor* option settings -receive the corresponding per-entry log. - -**Fixed by TODO §42 (0.43.0, 2026-09-05):** `enabled_rules` now takes the -project's selection beside the editor's and picks the editor's list when it -is non-empty, the project's otherwise, key by key — the CLI's `pick` applied -to the editor. Rejected project entries are logged once per (configuration -file, entry) as `:: `, the wording `lucisv check` fails -with, and the buffer is still linted with the entry dropped. Pinned by -`lint::project`'s four-way table test and by three wire-level tests in -`crates/lucisv_server/tests/e2e.rs`, one of which asserts the CLI's and the -server's rule lists equal for three configurations. See -`docs/features/lint-config-contract/README.md`. - -### 3. Keep traversal and semantic gaps explicit - -The shared [directory walker](../crates/lucisv_core/src/walk.rs) recursively -follows `Path::is_dir()` with no visited-directory set. Symlink cycles remain -an existing open issue (topology handshake 8); eventual filesystem refusal is -not an explicit traversal budget or cycle policy. Prioritize a deliberate -cycle policy before broadening traversal. - -Other concrete open contracts include missing type spans (handshake 2), -package re-export resolution (16), inline aggregate type arguments (17), and -cross-file rename of an internal module net (23). The parser-skips regression -suite also retains a refusal for comments immediately before a net-delay `#` -(27). These limitations should remain visible when widening grammar or index -coverage; formatter verification must continue to reject unsupported output. - -**Fixed by TODO §43 (0.43.0, 2026-09-05):** the walker enters each directory -once by identity (`(dev, ino)` on unix, the canonical path elsewhere); a -symlink cycle terminates and a doubly reachable file is reported once. The -"no traversal budget" ruling was the lead's: identity is the policy. The -net-delay comment refusal (handshake 27) is closed by `NetDelay`'s comment -slots. Still open from this finding: handshakes 2, 16, 17, 23, and the new 30 -(an unreadable directory aborts the walk). See -`docs/features/walk-cycles/README.md`. - -## Documentation changes from this audit - -- Expanded the README's architecture to cover all eight crates and documented - the runtime checks, actual indexing behavior, documentation entry points, - and guarded verification commands. -- Updated topology facts to codec 17, corrected moved module paths, recorded - recent recovery/lint/fence/atomic/LSP contracts, and closed the stale `program` - linked-editing request using the existing module-shaped AST path. -- Updated site configuration, formatter/linter guides, CLI, language tools, - architecture and API navigation for current behavior. The API index now - explicitly defers to rustdoc for exhaustive signatures and fields. -- Removed the stale `0.9.0` product version from site structured metadata; - release versions remain owned by the workspace/release files. - -The parser-skips changes were already present when the audit started and were -committed by another workflow during the audit. Their QA log now records PASS; -the topology reflects that final state. This audit made no Rust implementation -changes and did not modify their feature log or backlog checkboxes. - -## Validation +Checks ran against an isolated archive of committed `9ef1058`, with a separate +build directory and the repository resource guard. This avoids the live agents' +target directory and does not certify their uncommitted changes. - `cargo fmt --all -- --check`: passed. -- `cargo clippy --workspace --all-targets -- -D warnings`: passed. -- `tools/guard.sh -- cargo test --workspace`: **3,745 passed, 0 failed, - 44 ignored**, summed across 48 test/doc-test harnesses. Counts include the - post-v0.41.0 parser-skip cases and one passing doctest; ignored measurement - tests were not enabled. -- Documentation build: `ASTRO_TELEMETRY_DISABLED=1 npm run build` in - `docs/site` passed; 13 pages, Pagefind index and sitemaps generated. -- Generated-site verification: 817 local links, assets and anchors checked, - zero failures; relative links in the repository documentation checked. - `git diff --check` passed. -- Atomic-write probe: collision reproduced as described above, no repository - source files written. +- `cargo clippy --offline --workspace --all-targets -- -D warnings`: passed. +- `cargo test --offline --workspace`: **3,829 passed, 0 failed, 44 ignored**, + across 49 harnesses, under `tools/guard.sh`. The archive did not include the + ignored/untracked corpus checkout, and ignored measurement tests were not run. +- `ASTRO_TELEMETRY_DISABLED=1 npm run build` in `docs/site`: passed; + 13 pages, Pagefind search and sitemaps rebuilt. +- Generated-site validation: **820** local links, assets and anchors checked, + zero errors. Relative links in the root analysis/topology/coverage docs also + passed. `git diff --check` passed for these documentation changes. -The first test attempt was stopped because sandboxed `ps` prevented the guard -from measuring memory; the successful rerun used an approved environment where -monitoring worked. No corpus sweep, OpenTitan sweep, ignored benchmark run, -release packaging, or external publishing was performed by this audit. +The previous audit's 3,745 passing tests describe its September 4 snapshot; +they are not reused as the test result for this revision. This refresh changes +documentation only and leaves feature QA logs and backlog checkboxes to their +owners. No corpus/OpenTitan sweep, new benchmark, release packaging or +publishing was performed. diff --git a/docs/site/dist/guides/linter/index.html b/docs/site/dist/guides/linter/index.html index 148e0e3..b392ea3 100644 --- a/docs/site/dist/guides/linter/index.html +++ b/docs/site/dist/guides/linter/index.html @@ -116,4 +116,4 @@ to the lucisv log whether the file was named by the editor setting or by are reported under unused-waiver at their line of the waiver file, by lucisv check only and only after the whole run.

See the complete rule reference.

- \ No newline at end of file + \ No newline at end of file diff --git a/docs/site/dist/pagefind/fragment/en_13d9741.pf_fragment b/docs/site/dist/pagefind/fragment/en_13d9741.pf_fragment deleted file mode 100644 index 5e6dca7..0000000 Binary files a/docs/site/dist/pagefind/fragment/en_13d9741.pf_fragment and /dev/null differ diff --git a/docs/site/dist/pagefind/fragment/en_1681e2c.pf_fragment b/docs/site/dist/pagefind/fragment/en_1681e2c.pf_fragment deleted file mode 100644 index 346aeac..0000000 Binary files a/docs/site/dist/pagefind/fragment/en_1681e2c.pf_fragment and /dev/null differ diff --git a/docs/site/dist/pagefind/fragment/en_1d77e98.pf_fragment b/docs/site/dist/pagefind/fragment/en_1d77e98.pf_fragment deleted file mode 100644 index 889367a..0000000 Binary files a/docs/site/dist/pagefind/fragment/en_1d77e98.pf_fragment and /dev/null differ diff --git a/docs/site/dist/pagefind/fragment/en_209bfcf.pf_fragment b/docs/site/dist/pagefind/fragment/en_209bfcf.pf_fragment deleted file mode 100644 index 8786643..0000000 Binary files a/docs/site/dist/pagefind/fragment/en_209bfcf.pf_fragment and /dev/null differ diff --git a/docs/site/dist/pagefind/fragment/en_3f32cd5.pf_fragment b/docs/site/dist/pagefind/fragment/en_3f32cd5.pf_fragment new file mode 100644 index 0000000..f2e20fb Binary files /dev/null and b/docs/site/dist/pagefind/fragment/en_3f32cd5.pf_fragment differ diff --git a/docs/site/dist/pagefind/fragment/en_57d1313.pf_fragment b/docs/site/dist/pagefind/fragment/en_57d1313.pf_fragment new file mode 100644 index 0000000..ba4b940 Binary files /dev/null and b/docs/site/dist/pagefind/fragment/en_57d1313.pf_fragment differ diff --git a/docs/site/dist/pagefind/fragment/en_6122ede.pf_fragment b/docs/site/dist/pagefind/fragment/en_6122ede.pf_fragment new file mode 100644 index 0000000..e7b0d6b Binary files /dev/null and b/docs/site/dist/pagefind/fragment/en_6122ede.pf_fragment differ diff --git a/docs/site/dist/pagefind/fragment/en_ad63758.pf_fragment b/docs/site/dist/pagefind/fragment/en_ad63758.pf_fragment new file mode 100644 index 0000000..e95e568 Binary files /dev/null and b/docs/site/dist/pagefind/fragment/en_ad63758.pf_fragment differ diff --git a/docs/site/dist/pagefind/fragment/en_d952f62.pf_fragment b/docs/site/dist/pagefind/fragment/en_d952f62.pf_fragment deleted file mode 100644 index 56fe150..0000000 Binary files a/docs/site/dist/pagefind/fragment/en_d952f62.pf_fragment and /dev/null differ diff --git a/docs/site/dist/pagefind/fragment/en_e3a0d5d.pf_fragment b/docs/site/dist/pagefind/fragment/en_e3a0d5d.pf_fragment new file mode 100644 index 0000000..6f9e280 Binary files /dev/null and b/docs/site/dist/pagefind/fragment/en_e3a0d5d.pf_fragment differ diff --git a/docs/site/dist/pagefind/index/en_179e478.pf_index b/docs/site/dist/pagefind/index/en_179e478.pf_index deleted file mode 100644 index 2ff02dd..0000000 Binary files a/docs/site/dist/pagefind/index/en_179e478.pf_index and /dev/null differ diff --git a/docs/site/dist/pagefind/index/en_49be357.pf_index b/docs/site/dist/pagefind/index/en_49be357.pf_index deleted file mode 100644 index f4c3dda..0000000 Binary files a/docs/site/dist/pagefind/index/en_49be357.pf_index and /dev/null differ diff --git a/docs/site/dist/pagefind/index/en_bde889a.pf_index b/docs/site/dist/pagefind/index/en_bde889a.pf_index new file mode 100644 index 0000000..5c63b16 Binary files /dev/null and b/docs/site/dist/pagefind/index/en_bde889a.pf_index differ diff --git a/docs/site/dist/pagefind/index/en_ee67eb2.pf_index b/docs/site/dist/pagefind/index/en_ee67eb2.pf_index new file mode 100644 index 0000000..2ca63fb Binary files /dev/null and b/docs/site/dist/pagefind/index/en_ee67eb2.pf_index differ diff --git a/docs/site/dist/pagefind/pagefind-entry.json b/docs/site/dist/pagefind/pagefind-entry.json index f7f86d4..bb21927 100644 --- a/docs/site/dist/pagefind/pagefind-entry.json +++ b/docs/site/dist/pagefind/pagefind-entry.json @@ -1 +1 @@ -{"version":"1.5.2","languages":{"en":{"hash":"en_e88e94fa5c","wasm":"en","page_count":12}},"include_characters":["_","‿","⁀","⁔","︳","︴","﹍","﹎","﹏","_"]} \ No newline at end of file +{"version":"1.5.2","languages":{"en":{"hash":"en_8310bcd6c3","wasm":"en","page_count":12}},"include_characters":["_","‿","⁀","⁔","︳","︴","﹍","﹎","﹏","_"]} \ No newline at end of file diff --git a/docs/site/dist/pagefind/pagefind.en_8310bcd6c3.pf_meta b/docs/site/dist/pagefind/pagefind.en_8310bcd6c3.pf_meta new file mode 100644 index 0000000..8860dab Binary files /dev/null and b/docs/site/dist/pagefind/pagefind.en_8310bcd6c3.pf_meta differ diff --git a/docs/site/dist/pagefind/pagefind.en_e88e94fa5c.pf_meta b/docs/site/dist/pagefind/pagefind.en_e88e94fa5c.pf_meta deleted file mode 100644 index 45c3109..0000000 Binary files a/docs/site/dist/pagefind/pagefind.en_e88e94fa5c.pf_meta and /dev/null differ diff --git a/docs/site/dist/reference/architecture/index.html b/docs/site/dist/reference/architecture/index.html index f3c04c1..6cd06fa 100644 --- a/docs/site/dist/reference/architecture/index.html +++ b/docs/site/dist/reference/architecture/index.html @@ -70,7 +70,7 @@ })();

Architecture

lucisv follows the same separation of concerns that makes ruff fast and maintainable: syntax and source fidelity at the bottom, reusable analysis and transformations in the middle, and thin product surfaces at the top.

+

Architecture

lucisv follows the same separation of concerns that makes ruff fast and maintainable: syntax and source fidelity at the bottom, reusable analysis and transformations in the middle, and thin product surfaces at the top.

@@ -142,7 +142,7 @@ Only a verified string is returned. Ranges splice whole items; format fences also protect statement scopes, and verification covers the complete output.
  • Lint: ParsedSource bundles one tokenization and tolerant parse; LintContext supplies source facts and lazy semantics. The registry selects -73 rules with severities and validated options. Inline waivers filter findings, +73 rules with severities and validated options. Inline and external waivers filter findings, and the front ends protect fenced bytes before applying fixes.
  • Refactor: parsed spans and resolved references produce an edit plan; the engine checks the whole candidate edit before returning it. Server source @@ -150,7 +150,7 @@ selectors bound the input set but must include every file the engine might edit or refuse over. No formatter dependency is involved.
  • Editor: one ordered synchronous loop owns Workspace; open documents overlay disk facts. Scans publish index/include/completion batches together. -Closed-file facts persist under codec 17; a bounded file-view cache serves +Committed closed-file facts persist under codec 18, including package re-exports; a bounded file-view cache serves queries that still need source text. Lazy port actions defer the edit until selection; recorded file-scope definition positions avoid a closed-file read.
  • @@ -164,6 +164,19 @@ server’s synchronous LSP/JSON stack.

    verification, persisted semantic facts, server state/ordering, and matching server/editor setting names. Source modules are split by grammar domain under parser/, ast/, format/, bind/, workspace/, ports/, and server/.

    + +

    v0.42–0.44 added external waiver files, exclusive atomic temp files with +canonical CLI deduplication, shared project/editor lint configuration, +cycle-aware directory walks with recoverable warnings, and inline aggregate +overrides. The v0.44.0 undriven-net fix asks the workspace mention census only +after local guards, reducing editor open/flush latency without changing the +rule’s findings or the synchronous request-ordering contract.

    +

    Two accepted changes are committed after v0.44.0: type names now carry exact +AST spans (scan.rs is retired), and package re-exports are references and +cycle-guarded member edges in codec 18. Re-exporting a name does not import it +into the exporting package’s local scope. DPI-export names remain unbound. +The separate hierarchical-tail work proposes codec 19 and a module member +surface for instance paths; it is still under QA and is not a released API.

    • Source fidelity: comments and blank-line intent survive the parser.
    • diff --git a/docs/site/dist/reference/cli/index.html b/docs/site/dist/reference/cli/index.html index f1d4d6d..acd52e6 100644 --- a/docs/site/dist/reference/cli/index.html +++ b/docs/site/dist/reference/cli/index.html @@ -247,6 +247,12 @@

      Filelist paths bypass --exclude and .gitignore, just like direct command-line files. Duplicates are processed once. Unknown options, unset variables, and missing listed files warn without changing the exit code; an unreadable filelist is an error.

      Directory walks read .gitignore in each directory. Deeper rules override shallower rules; the last matching line wins. Supported syntax includes comments, blank lines, * within a component, anchored /, directory-only trailing /, and ! negation. **, ?, character classes, escapes, global excludes, and tracked-file exceptions are not implemented.

      +

      A directory is visited once by identity, so symlink cycles terminate. CLI +inputs resolving to the same canonical path are processed once. An unreadable +directory or .gitignore, or a dangling source-file link encountered while +walking, produces warning: <path>: <message> on stderr and the walk continues; +these warnings do not change the exit code. A missing explicitly named input +remains an error.

    diff --git a/docs/site/dist/reference/rules/index.html b/docs/site/dist/reference/rules/index.html index 0535ae5..fc05b4d 100644 --- a/docs/site/dist/reference/rules/index.html +++ b/docs/site/dist/reference/rules/index.html @@ -74,7 +74,7 @@

    Every rule is in one of three severity classes. error is code that would very likely fail to compile, elaborate or synthesize; warning is code that compiles and very likely does not mean what it says; style is code that is correct and reads badly. The class is the word in the CLI diagnostic line (FILE:LINE:COL: warning: …), the severity field of --output-format json, and the colour of the editor’s squiggle — and it is accepted wherever a rule name is, so --ignore style and --select error both work.

    Every error-class rule is held to one discipline: it goes silent whenever the run cannot answer — a file that did not fully parse, a module the project does not hold or holds twice, a name a macro produces, a fragment written to be `included. A wrong accusation in that class is worse than a hundred missed ones.

    This page is hand-written prose. The generated truth is lucisv check --rules-doc, which prints every rule with its class, default, fix and rationale straight from the registry — and every option a rule takes, with its kind and default.

    -

    A configurable rule is configured in a [lint.<rule-name>] table of a lucisv.toml, or from an editor in the lucisv.lint.options object; the option names are Verible’s wherever it has the same option. An unknown rule or option name, a value of the wrong kind, an out-of-range integer or a pattern that does not compile fails a CLI run naming the file and the line. Invalid editor option settings are logged and dropped; invalid project-file option entries are currently dropped silently by server linting.

    +

    A configurable rule is configured in a [lint.<rule-name>] table of a lucisv.toml, or from an editor in the lucisv.lint.options object; the option names are Verible’s wherever it has the same option. An unknown rule or option name, a value of the wrong kind, an out-of-range integer or a pattern that does not compile fails a CLI run naming the file and the line. Rejected project entries are logged once with file and line and dropped by server linting; invalid editor options and unknown editor select/ignore names are also logged. Valid entries continue to apply.

    [lint.line-length]
    length = 120
    [lint.typedef-structs-unions]
    allow_anonymous_nested = true

    A rule marked on (project) runs by default only where lucisv can see the other files of your project — lucisv check <dir>, or the language server. Over a single file or a stdin buffer it is off and must be --selected, because its one false-positive mode is a use in another file. Turn any rule off with --ignore, with ignore under [lint] in lucisv.toml, or with lucisv.lint.ignore in your editor.

    diff --git a/docs/site/dist/reference/rust-api/index.html b/docs/site/dist/reference/rust-api/index.html index 34eaf79..525bd9a 100644 --- a/docs/site/dist/reference/rust-api/index.html +++ b/docs/site/dist/reference/rust-api/index.html @@ -72,7 +72,9 @@ StarlightThemeProvider.updatePickers();

    Rust API index

    Public functions indexed

    This is a navigational API index, not source documentation. It summarizes the main public callable surface of the six reusable library crates in the workspace; command-line and language-server binaries are documented in their dedicated references.

    -

    The workspace baseline is v0.41.0. For the complete signatures and fields, +

    The latest release is v0.44.0. This index includes the accepted type-name-span +and package-re-export additions committed at 9ef1058 for the next release; +it excludes the in-progress hierarchical-tail API and codec 19. For the complete signatures and fields, run cargo doc --workspace --no-deps; this hand-maintained index is not an exhaustive replacement for rustdoc. The parser’s strict and tolerant entry points share one grammar; tolerant errors do not imply formatter acceptance. @@ -189,7 +191,7 @@ The CLI and server configure their worker threads accordingly.

    - + @@ -311,7 +313,11 @@ The CLI and server configure their worker threads accordingly.

    - + + + + + @@ -397,6 +403,14 @@ The CLI and server configure their worker threads accordingly.

    + + + + + + + + @@ -481,8 +495,8 @@ The CLI and server configure their worker threads accordingly.

    DataTypeis_implicit, params, inlineis_implicit, params, inline, name_span, segments
    VirtualKw
    lintRun enabled rules against a prepared contextRun enabled rules against a prepared context with inline waivers
    lint_withApply inline and external waivers and return external usage alongside findings
    all_rules as_str, vocabulary / value, as_written
    ExternalWaiversread, parse, absorb, is_empty, unused
    WaiverUsemerge (aggregate usage across a complete run before reporting unused waivers)
    editor settings functions vscode_lint_settings, rule_setting, severity_setting
    -

    FACTS_FORMAT is 17. Cached facts include normal and macro identifier -censuses; Def::lines.positions can carry DeclPositions with UTF-16 ranges +

    FACTS_FORMAT is 18 in the committed snapshot. Cached facts include +normal/macro identifier censuses and package re-export edges (the RX group); Def::lines.positions can carry DeclPositions with UTF-16 ranges for file-scope declarations. Any persisted shape or fact-census change needs a codec-version decision so stale caches cannot silently omit answers.

    @@ -608,7 +622,7 @@ a codec-version decision so stale caches cannot silently omit answers.

    walk::collect_files -Walk inputs with ignores and exclusions +Walk inputs with ignores, exclusions and directory-cycle detection; accepts a FnMut(Warning) sink for recoverable failures walk::is_excluded @@ -627,7 +641,7 @@ a codec-version decision so stale caches cannot silently omit answers.

    atomic::write_atomic -Replace file contents through a sibling temp file and rename; callers must coordinate concurrent writes to one target +Replace contents using an exclusively created per-operation temp file; concurrent replacements publish one whole buffer, last writer wins content_hash diff --git a/docs/site/dist/start/configuration/index.html b/docs/site/dist/start/configuration/index.html index a89dc02..c41065f 100644 --- a/docs/site/dist/start/configuration/index.html +++ b/docs/site/dist/start/configuration/index.html @@ -292,11 +292,15 @@ setting is non-empty and the project’s [lint] select o is decided the same way and independently. The severity switches and per-rule toggles are editor-only — a lucisv.toml has no such keys — and apply over whichever selection stands. Editor rule options overlay project -rule options key by key. An entry that cannot be used is dropped and logged -once per configuration file and entry, in the same <file>:<line>: <message> wording lucisv check fails with: an invalid editor option, an -invalid [lint.<rule>] entry, an unknown rule name in [lint] select/ignore, or an unreadable waiver file. lucisv check treats each -of these as a configuration error and exits 2; the server keeps linting with -the entry dropped.

    +rule options key by key. An invalid project option, unknown project rule name, +or bad waiver entry is dropped and logged once with the same +<file>:<line>: <message> wording the CLI reports. The CLI treats those +project errors as exit 2; the server keeps linting with the valid entries. +Editor-only settings are validated separately: bad options are logged, and an +unknown select/ignore name is logged once as +lucisv.lint.select: unknown rule: <name> (or ignore). Changing that list +re-arms logging for newly introduced mistakes. An empty editor selection is +the fallback sentinel, so it does not clear a non-empty project selection.

    Successful “already formatted” verdicts are cached under .lucisv_cache/. Entries are keyed by file, content hash, line length, indentation, and lucisv version. Files that would change or fail are never cached. Use --no-cache to disable reads and writes or --cache-dir to relocate the store.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/docs/site/src/content/docs/reference/architecture.md b/docs/site/src/content/docs/reference/architecture.md index 74c783e..04f289b 100644 --- a/docs/site/src/content/docs/reference/architecture.md +++ b/docs/site/src/content/docs/reference/architecture.md @@ -39,7 +39,7 @@ lucisv follows the same separation of concerns that makes ruff fast and maintain also protect statement scopes, and verification covers the complete output. - **Lint:** `ParsedSource` bundles one tokenization and tolerant parse; `LintContext` supplies source facts and lazy semantics. The registry selects - 73 rules with severities and validated options. Inline waivers filter findings, + 73 rules with severities and validated options. Inline and external waivers filter findings, and the front ends protect fenced bytes before applying fixes. - **Refactor:** parsed spans and resolved references produce an edit plan; the engine checks the whole candidate edit before returning it. Server source @@ -47,7 +47,7 @@ lucisv follows the same separation of concerns that makes ruff fast and maintain edit or refuse over. No formatter dependency is involved. - **Editor:** one ordered synchronous loop owns `Workspace`; open documents overlay disk facts. Scans publish index/include/completion batches together. - Closed-file facts persist under codec 17; a bounded file-view cache serves + Committed closed-file facts persist under codec 18, including package re-exports; a bounded file-view cache serves queries that still need source text. Lazy port actions defer the edit until selection; recorded file-scope definition positions avoid a closed-file read. @@ -63,6 +63,22 @@ verification, persisted semantic facts, server state/ordering, and matching server/editor setting names. Source modules are split by grammar domain under `parser/`, `ast/`, `format/`, `bind/`, `workspace/`, `ports/`, and `server/`. +## Recent changes and release boundary + +v0.42–0.44 added external waiver files, exclusive atomic temp files with +canonical CLI deduplication, shared project/editor lint configuration, +cycle-aware directory walks with recoverable warnings, and inline aggregate +overrides. The v0.44.0 `undriven-net` fix asks the workspace mention census only +after local guards, reducing editor open/flush latency without changing the +rule's findings or the synchronous request-ordering contract. + +Two accepted changes are committed after v0.44.0: type names now carry exact +AST spans (`scan.rs` is retired), and package re-exports are references and +cycle-guarded member edges in codec 18. Re-exporting a name does not import it +into the exporting package's local scope. DPI-export names remain unbound. +The separate hierarchical-tail work proposes codec 19 and a module member +surface for instance paths; it is still under QA and is not a released API. + ## Design invariants - **Source fidelity:** comments and blank-line intent survive the parser. diff --git a/docs/site/src/content/docs/reference/cli.md b/docs/site/src/content/docs/reference/cli.md index 9765f92..4914434 100644 --- a/docs/site/src/content/docs/reference/cli.md +++ b/docs/site/src/content/docs/reference/cli.md @@ -60,6 +60,13 @@ Filelist paths bypass `--exclude` and `.gitignore`, just like direct command-lin Directory walks read `.gitignore` in each directory. Deeper rules override shallower rules; the last matching line wins. Supported syntax includes comments, blank lines, `*` within a component, anchored `/`, directory-only trailing `/`, and `!` negation. `**`, `?`, character classes, escapes, global excludes, and tracked-file exceptions are not implemented. +A directory is visited once by identity, so symlink cycles terminate. CLI +inputs resolving to the same canonical path are processed once. An unreadable +directory or `.gitignore`, or a dangling source-file link encountered while +walking, produces `warning: : ` on stderr and the walk continues; +these warnings do not change the exit code. A missing explicitly named input +remains an error. + ## Exit codes | Code | Meaning | diff --git a/docs/site/src/content/docs/reference/rules.md b/docs/site/src/content/docs/reference/rules.md index 3eacc02..d11a2d8 100644 --- a/docs/site/src/content/docs/reference/rules.md +++ b/docs/site/src/content/docs/reference/rules.md @@ -11,7 +11,7 @@ Every `error`-class rule is held to one discipline: it goes **silent whenever th This page is hand-written prose. The generated truth is `lucisv check --rules-doc`, which prints every rule with its class, default, fix and rationale straight from the registry — **and every option a rule takes, with its kind and default**. -A configurable rule is configured in a `[lint.]` table of a `lucisv.toml`, or from an editor in the `lucisv.lint.options` object; the option names are Verible's wherever it has the same option. An unknown rule or option name, a value of the wrong kind, an out-of-range integer or a pattern that does not compile fails a CLI run naming the file and the line. Invalid editor option settings are logged and dropped; invalid project-file option entries are currently dropped silently by server linting. +A configurable rule is configured in a `[lint.]` table of a `lucisv.toml`, or from an editor in the `lucisv.lint.options` object; the option names are Verible's wherever it has the same option. An unknown rule or option name, a value of the wrong kind, an out-of-range integer or a pattern that does not compile fails a CLI run naming the file and the line. Rejected project entries are logged once with file and line and dropped by server linting; invalid editor options and unknown editor select/ignore names are also logged. Valid entries continue to apply. ```toml [lint.line-length] diff --git a/docs/site/src/content/docs/reference/rust-api.md b/docs/site/src/content/docs/reference/rust-api.md index de50769..937a2aa 100644 --- a/docs/site/src/content/docs/reference/rust-api.md +++ b/docs/site/src/content/docs/reference/rust-api.md @@ -7,7 +7,9 @@ description: Navigational index of the main public APIs in lucisv’s reusable R This is a navigational API index, not source documentation. It summarizes the main public callable surface of the six reusable library crates in the workspace; command-line and language-server binaries are documented in their dedicated references. -The workspace baseline is v0.41.0. For the complete signatures and fields, +The latest release is v0.44.0. This index includes the accepted type-name-span +and package-re-export additions committed at `9ef1058` for the next release; +it excludes the in-progress hierarchical-tail API and codec 19. For the complete signatures and fields, run `cargo doc --workspace --no-deps`; this hand-maintained index is not an exhaustive replacement for rustdoc. The parser's strict and tolerant entry points share one grammar; tolerant errors do not imply formatter acceptance. @@ -50,7 +52,7 @@ The CLI and server configure their worker threads accordingly. | `Module` | `end_kw` | | `ClassDecl` | `is_interface_class` | | `BindDirective` | `target_path`, `head` | -| `DataType` | `is_implicit`, `params`, `inline` | +| `DataType` | `is_implicit`, `params`, `inline`, `name_span`, `segments` | | `VirtualKw` | `text` | | `CallComments` | `is_empty` | | `WithComments` | `is_empty` | @@ -93,7 +95,8 @@ The CLI and server configure their worker threads accordingly. | Function | Purpose | |---|---| | `run` | Parse and lint source in one call | -| `lint` | Run enabled rules against a prepared context | +| `lint` | Run enabled rules against a prepared context with inline waivers | +| `lint_with` | Apply inline and external waivers and return external usage alongside findings | | `all_rules` | Return the complete rule registry | | `default_rules` | Return rules enabled for a single-file run | | `workspace_rules` | Return defaults plus project-aware semantic rules | @@ -117,6 +120,8 @@ The CLI and server configure their worker threads accordingly. | `Severity` | `as_str`, `from_name`, `describes`; classes `Error`, `Warning`, `Style` | | `RuleOptions` | `new`, `is_empty`, `set_raw`, `set`, `overlay`, `is_set`, `bool`, `int`, `str`, `list` | | `OptionKind` / `OptionDefault` | `as_str`, `vocabulary` / `value`, `as_written` | +| `ExternalWaivers` | `read`, `parse`, `absorb`, `is_empty`, `unused` | +| `WaiverUse` | `merge` (aggregate usage across a complete run before reporting unused waivers) | | editor settings functions | `vscode_lint_settings`, `rule_setting`, `severity_setting` | ## `vlog_semantic` @@ -145,8 +150,8 @@ The CLI and server configure their worker threads accordingly. | `index_order` | Sort workspace inputs into their deterministic index order | | `words::harvest` / `harvest_text` / `harvest_raw` | Build the shared identifier census from tokens or source text | -`FACTS_FORMAT` is **17**. Cached facts include normal and macro identifier -censuses; `Def::lines.positions` can carry `DeclPositions` with UTF-16 ranges +`FACTS_FORMAT` is **18** in the committed snapshot. Cached facts include +normal/macro identifier censuses and package re-export edges (the `RX` group); `Def::lines.positions` can carry `DeclPositions` with UTF-16 ranges for file-scope declarations. Any persisted shape or fact-census change needs a codec-version decision so stale caches cannot silently omit answers. @@ -190,14 +195,14 @@ a codec-version decision so stale caches cannot silently omit answers. | `config::parse` | Parse strict lucisv configuration text | | `Discovery` | `new`, `for_input`, `for_file`, `for_dir` | | `filelist::read` | Resolve a nested EDA filelist | -| `walk::collect_files` | Walk inputs with ignores and exclusions | +| `walk::collect_files` | Walk inputs with ignores, exclusions and directory-cycle detection; accepts a `FnMut(Warning)` sink for recoverable failures | | `walk::is_excluded` | Test a path against exclusion patterns | ### Atomic writes and cache | Function or type | Public methods | |---|---| -| `atomic::write_atomic` | Replace file contents through a sibling temp file and rename; callers must coordinate concurrent writes to one target | +| `atomic::write_atomic` | Replace contents using an exclusively created per-operation temp file; concurrent replacements publish one whole buffer, last writer wins | | `content_hash` | Compute the cache’s FNV-1a content fingerprint | | `Cache` | `load`, `disabled`, `is_clean`, `record`, `store` | diff --git a/docs/site/src/content/docs/start/configuration.md b/docs/site/src/content/docs/start/configuration.md index 90cdc68..d876b2b 100644 --- a/docs/site/src/content/docs/start/configuration.md +++ b/docs/site/src/content/docs/start/configuration.md @@ -96,13 +96,15 @@ setting is non-empty and the project's `[lint] select` otherwise; `ignore` is decided the same way and independently. The severity switches and per-rule toggles are editor-only — a `lucisv.toml` has no such keys — and apply over whichever selection stands. Editor rule options overlay project -rule options key by key. An entry that cannot be used is dropped and logged -once per configuration file and entry, in the same `:: -` wording `lucisv check` fails with: an invalid editor option, an -invalid `[lint.]` entry, an unknown rule name in `[lint] -select`/`ignore`, or an unreadable waiver file. `lucisv check` treats each -of these as a configuration error and exits 2; the server keeps linting with -the entry dropped. +rule options key by key. An invalid project option, unknown project rule name, +or bad waiver entry is dropped and logged once with the same +`:: ` wording the CLI reports. The CLI treats those +project errors as exit 2; the server keeps linting with the valid entries. +Editor-only settings are validated separately: bad options are logged, and an +unknown select/ignore name is logged once as +`lucisv.lint.select: unknown rule: ` (or `ignore`). Changing that list +re-arms logging for newly introduced mistakes. An empty editor selection is +the fallback sentinel, so it does not clear a non-empty project selection. ## Cache diff --git a/docs/topo.md b/docs/topo.md index 07916d8..dbe4fa9 100644 --- a/docs/topo.md +++ b/docs/topo.md @@ -24,13 +24,20 @@ null-items (108 feature READMEs); updated 2026-09-02 through v0.33.0 for the testbench grammar/semantics wave, comment slots, bind semantics, SVA bodies, and the four decomposition rounds (125 feature READMEs). -**Code audit: 2026-09-04, HEAD `d5abf81`, after the v0.41.0 release (`97aa2fe`).** The crate -edges below were checked against all eight manifests. Current facts codec: -**17**. Recent feature contracts are summarized in §1.4. HEAD -also contains **parser-skips** (TODO §38): implementation committed and QA -accepted, intended for v0.42.0; it is not part of the v0.41.0 release. External -waiver files (TODO §39) remain planned. See [repository-analysis.md](repository-analysis.md) -for findings, validation, and the distinction between measured and historical results. +**Code audit refreshed 2026-09-05.** Latest release: **v0.44.0** +(`66f3898`). Committed snapshot: **`9ef1058`**, including type-name-spans +(TODO §47) and package-reexports (§48), both accepted for v0.45.0. The +committed facts codec is **18**; the active **hierarchical-tail** work (§49) +uses **19** in the working tree and is awaiting QA. Public contracts below +describe committed code unless explicitly marked in progress. Do not treat +the working-tree codec or an unchecked QA item as a released guarantee. + +The original audit's atomic-write, lint-config and walk-cycle findings are +closed in v0.43.0. External waivers shipped in v0.42.0; walk warnings, +inline aggregate overrides and the didOpen cost fix shipped in v0.44.0. +See [repository-analysis.md](repository-analysis.md) for current priorities +and dated verification evidence. Feature QA logs and TODO checkboxes remain +the authority for work being completed by other agents. **Edge notation, used in all three sections:** @@ -200,11 +207,12 @@ an error means emit nothing. `ExternalCandidate`/`InheritedCandidate` carrying candidate paths); `workspace/` (`mod` = the tables, `index` = queries and `build`, `update` = incremental update and `fingerprint`, `record` = the `FileFacts` read-off, -`external` = the overlay; `WorkspaceIndex`: units, members, defines, instantiation and +`external` = the overlay, `reexport` = cycle-guarded package member traversal; +active §49 adds `hierarchy` and a second member table; `WorkspaceIndex`: units, members, defines, instantiation and inheritance edge tables, incremental `update_file`/`remove_file`, reference postings, `files_spelling`, batch `absorb`, declaration `DeclLines`, `fingerprint`); `facts.rs` (`FileFacts` codec for the persistent cache; -`FACTS_FORMAT` is 17); +`FACTS_FORMAT` is 18 in committed code (19 in the active §49 work)); `instantiations.rs`, `classes.rs` (the shared walks, lifted from the server so the index census and the request handlers cannot drift). @@ -217,13 +225,17 @@ reader: files, `+incdir+`, defines, warnings), `cache.rs` (the format cache + nothing of Verilog; depends on nothing. Config stores `LintOption` entries raw with source/line information; front ends validate them through `vlog_linter::RuleOptions`, so core still has no linter dependency. Open -contracts include path normalization, walk cycles, and same-target write -coordination (§2.9-1, §2.9-8, §2.9-26). +contract: path normalization (§2.9-1). Walk cycles and same-target temp +collisions are resolved (§2.9-8, §2.9-26). `collect_files` now takes a +`&mut dyn FnMut(Warning)` sink; CLI and server own presentation of recoverable +walk failures (§2.9-30). Atomic replacement uses exclusive per-operation temps; +CLI canonical-path dedup prevents symlink aliases reaching two workers. **`vlog_linter`** — `registry.rs` (`Rule` trait, `all_rules`/`default_rules`/ `select_rules`), `rules/` (one file per rule; names are **stable API** — they appear in users' waivers), `context.rs` (`LintContext<'a>`, `ParsedSource`, -lazy `semantics()`), `visit.rs` (the item/statement walk), `waiver.rs`, +lazy `semantics()`), `visit.rs` (the item/statement walk), `waiver.rs` (inline +waivers), `waiver_file.rs` (`ExternalWaivers`, usage tracking, unused reports), `violation.rs` (+ `Fix`, `Applicability`), `signals.rs` (the shared signal table for the three semantic rules), `naming.rs`, `rule_docs.rs` (`rules_markdown()` — docs generated from the registry). There are 73 rules; @@ -294,10 +306,17 @@ output after content changes, and keep historical measurements dated. | linter-expansion-1 | `Severity`, `Violation::severity`, `rules_named`, `MentionOracle::module_interface`, `Semantics::duplicates` ↔ CLI reports, server diagnostics/settings, generated VS Code toggles | Delivered; duplicate facts are in-memory only | | linter-expansion-2 | core `FileConfig::lint_options`/`LintOption` → linter `RuleOptions`; registry specs ↔ CLI validation, server option overlay and editor settings | Delivered; core records raw values and does not depend on the linter | | linter-expansion-3 | shared scoped-item/expression/preprocessor walkers ↔ 73-rule registry, rule docs and generated editor toggles | Delivered; rule names and option keys are user-facing contracts | -| small-items-3 | parser `ItemKind::GenBlock` → every recursive item walker; `recover_list` lookahead; core `atomic::write_atomic` → CLI format/fix and format cache | Delivered in v0.40.0; atomic replacement does not yet coordinate same-target writers (§2.9-26) | +| small-items-3 | parser `ItemKind::GenBlock` → every recursive item walker; `recover_list` lookahead; core `atomic::write_atomic` → CLI format/fix and format cache | Delivered in v0.40.0; per-operation temp ownership and canonical CLI dedup followed in v0.43.0 (§2.9-26) | | lazy-code-action | refactor `sites_phrase` ↔ server `ports.rs`; `ClientAbilities::code_action_resolve` ↔ dispatch and `{uri, position, title}` action data; indexed `DeclPositions` → `locate::definition_location` | Delivered in v0.41.0; clients without resolve support retain eager port actions, lint fixes remain eager | -| parser-skips | parser `module.rs`/`split.rs` rival-header detection; `DataDecl::delay: Option` → formatter `format/decl.rs` and semantic `bind/decl.rs` | **Committed after v0.41.0; QA accepted, release pending**; preserves the written delay position; no verifier normalization change | -| external waiver files | proposed linter waiver parser ↔ core config, CLI args, server settings/diagnostics and VS Code manifest | **Planned (TODO §39)**; no callable API, CLI flag, or config setting yet | +| parser-skips | parser `module.rs`/`split.rs` rival-header detection; `DataDecl::delay: Option` → formatter `format/decl.rs` and semantic `bind/decl.rs` | **Released in v0.42.0**; preserves the written delay position; no verifier normalization change | +| waiver-files | linter `ExternalWaivers`/`WaiverUse`/`lint_with` ↔ core `[lint] waivers`, CLI `--waiver-file`, server `lucisv.lint.waivers`, quick fixes and VS Code manifest | Released in v0.42.0; inline/external union, unused external reports are CLI-only | +| atomic-write-coordination | core exclusive temp creation and permissions → CLI canonical-path dedup and every in-place writer | Released in v0.43.0; independent processes remain last-writer-wins | +| lint-config-contract | server `lint/project.rs` parses project selection/options/waivers; `ProjectLint` → lint selection, `ConfigProblems`/`ProblemLog` → diagnostics logging | Released in v0.43.0; editor lists override project lists when non-empty, separately for select and ignore | +| walk-cycles / small-items-4 | core directory identity set and warning sink ↔ CLI/server walk callers; parser delay-comment fields and `ExprKind::Type` → formatter and instance planning | Released in v0.43–0.44; warning paths continue without changing CLI status, direct missing inputs remain errors | +| didopen-cost | `undriven-net` local guards → existing `MentionOracle` predicate; diagnostics equality → server publish/request ordering | Released in v0.44.0; no new async work or index API | +| type-name-spans | parser `DataType::name_span`/`segments`, disable-target span → binder `exact_or_empty` and census | Committed after v0.44.0; `scan.rs` deleted; source text remains the exact-span oracle | +| package-reexports | binder export references → `FileFacts` RX group, codec 18 ↔ workspace `reexport.rs` and shared member queries | Committed after v0.44.0; package exports add no local import; DPI-export names remain unbound | +| hierarchical-tail | proposed `Surface` tags on declarations/references, codec 19 ↔ `workspace/hierarchy.rs`, member-tail resolution, completion and rename source selection | **In progress, QA pending (TODO §49)**; connection surface stays unchanged, instance tails read the new hierarchical surface | The lazy action resolves against current workspace state and rejects a stale or inapplicable action. Indexed definition locations bypass closed-file reads @@ -309,7 +328,7 @@ outside the configured index scope, rather than a hint-generation failure. ## 2. Feature dependency graph -125 features. They cluster into eight lanes; edges inside a lane are listed in +Feature contracts cluster into eight lanes; edges inside a lane are listed in that lane's table, cross-lane edges are repeated where they matter. The mermaid graph shows the lanes and the load-bearing cross-lane edges only. @@ -627,22 +646,22 @@ update the filing README(s) and this file. | ~~13~~ | ~~Anonymous-aggregate members (`enum {A,B} x;`) not declared as symbols — hover/definition gap~~ — **delivered 2026-09-01 by struct-members**: anonymous enum variants land in the enclosing scope via the shared `bind_enum_body`; an anonymous `struct {…} s;` declarator and every inline nested struct field carry their own `Struct` child scope, and `member_scope` accepts any symbol whose child scope is a `Struct` scope. Residue filed in the struct-members README: cross-file anonymous struct *variables*, `typeDefinition` inside an anonymous aggregate written as a data declaration | types-decls | ~~vlog_semantic~~ done | | ~~14~~ | ~~A `program` node with `name_span`/`end_label_span` for linked editing~~ — **delivered by vendor-formal-grammar (0.30.0)**: `parser/item.rs` routes `program` to `parse_module("endprogram")`; the resulting `ItemKind::Module` carries both spans and `linked.rs::module_pairs` consumes them. Confirmed in the 2026-09-04 source audit. | linked-editing | ~~vlog_parser~~ done | | ~~15~~ | ~~Bind semantics: whether a `bind`'s target scope and connections should resolve through the workspace index (today only the instantiated module name is recorded)~~ — **delivered 2026-09-02 by bind-semantics**: `BindDirective::target` is `Vec`; a lone target binds as `Target::Module`, an instance path records nothing (a guess would be a wrong answer); each connection's port half is `Target::Port(inst.module)` and its expression half `Target::BindScope` — the target's own scope first (`resolve::in_bind_target`, `None` on a miss because generate blocks open scopes of their own), the workspace's one-segment member path when the target lives elsewhere, the writing scope last. `FACTS_FORMAT` 14 → 15 | bind | ~~vlog_semantic~~ done | -| ~~16~~ | ~~DPI/package re-export halves as real references (`export pkg::item` doesn't resolve; `*::*` has `"*"` as its package name, which nothing expects)~~ — **closed 2026-09-05 by package-reexports (TODO §48):** both halves of `export pkg::item` are references (`bind_export_path`, no scope import); the index records each package's re-exports (`FACTS_FORMAT` 18, the `RX` group, `*::*` expanded to the package's own imports at record time); the member walk follows them transitively with a visited set, so definition, hover, completion, references and rename read the one edge. A DPI export's `name` is still unbound (dpi-export request (b)). | dpi-export | vlog_semantic | +| ~~16~~ | ~~DPI/package re-export halves as real references (`export pkg::item` doesn't resolve; `*::*` has `"*"` as its package name, which nothing expects)~~ — **closed 2026-09-05 by package-reexports (TODO §48):** both halves of `export pkg::item` are references (`bind_export_path`, no scope import); the index records each package's re-exports (`FACTS_FORMAT` 18, the `RX` group, `*::*` expanded to the package's own imports at record time); the member walk follows them transitively with a visited set, so definition, hover, completion, references and rename read the one edge. Package half closed; the DPI-export `name` remains unbound, tracked separately as §2.9-31. | dpi-export | vlog_semantic | | ~~17~~ | ~~Inline aggregate as a parameter-override *argument* (`m #(.T(struct packed { logic a; })) u ();`) is rejected in expression position; M4's `instantiation_plan` drops such a `parameter type` default rather than emit unparseable text~~ — **delivered 2026-09-05 by small-items-4 (TODO §45.3):** `parse_expr_or_type` routes a `struct`/`union`/`enum` head to the type grammar; the value is an `ExprKind::Type` printed by the type printer. `instantiation_plan` emits a one-line `parameter type` aggregate default; a multi-line one is still dropped by the "written across several lines" rule, not the grammar. | refactor-instantiate (gap 1; its gap 2 was delivered by ansi-first-port) | vlog_parser | | ~~18~~ | ~~A macro-invocation census in `FileFacts`~~ — **delivered 2026-09-02**: the engine half by sva-bodies (`macro_use_warnings` pinned for a file in the source set) and the server half by macro-word-census (TODO §29.2): `FileFacts::macro_words` (`words::harvest_raw`, tag `MW`, `FACTS_FORMAT` 16 → 17, +3.1 % corpus / +1.7 % opentitan store), `WorkspaceIndex::files_naming_in_macros`, and a warning appended by `lucisv_server::rename` for every such file **outside** the set `rename_sources` built — no rung, nothing read (58 files in 186 µs on opentitan for `clk`). | refactor-rename; sva-bodies; macro-word-census | ~~vlog_semantic~~ done | | ~~19~~ | ~~An execute-command spelling of the instantiation skeleton (plain-text `render` through the same `plan_for`), for clients without `textDocument/inlineCompletion` — since the 2026-08-30 names-only popup, such a client (Neovim's built-in LSP, today) has no path to the full skeleton at all. Filed at lead review after correcting the dev's assumption that a `lucisv/instantiate` command already existed (it never did).~~ — **delivered 2026-09-02 by bind-semantics**: `lucisv.instantiate [uri, position, module]` (`lucisv_server/src/instantiate.rs`, advertised by `main.rs::commands()`, routed through `ports::execute`) — `plan_for` → plain `render` under `completion::layout_at` → `workspace/applyEdit`; `at_instantiation_site` validates the position; escaped names go in as plain text. Pinned at the plan level: the command's plan renders to the ghost's text. `editors/nvim/README.md` documents it | inline-instantiation (lead) | ~~lucisv_server~~ done | | ~~20~~ | ~~Rename loses its heads-up for an **unresolvable member/hierarchical tail** spelling the renamed name (`unknown_mod u_x (); … u_x.sig` when `unknown_mod` is indexed nowhere): before class-member-access the tail had no reference and `rename.rs::stray_reason` warned "a hierarchical or member tail, which lucisv does not resolve"; since round 2 it carries an `ExternalCandidate` the workspace cannot answer, which the engine neither edits (correct) nor mentions. Wanted: a warning for candidate references that spell the old name and stayed unresolved through the overlay — one message per file. Pinned as a premise by `a_hierarchical_tail_that_cannot_resolve_is_left_alone_and_named_as_such`. Same class as item 18.~~ — **delivered 2026-09-02 by comment-slots**: `Scope::unresolved_candidate_warnings` — a reference that stayed `ExternalTarget::StillUnresolved` through the overlay (or an `InheritedCandidate` that missed) is reported one line per (file, unit), run over every file that spells the name. The premise pin is inverted. Surfaced item 23 in the process | class-member-access round 2 (lead) | ~~vlog_refactor (`rename.rs`)~~ done | | ~~21~~ | ~~`Parser::parse_scoped_name` joins a `pkg::name` chain into one `String`, erasing the segment boundary, so an escaped segment (`\my-pkg ::\state-t` as a type, an instantiated module or a `bind` target) is reprinted without its terminating space and **refused by the safety net** — an error, never a corruption. Wanted: the AST keeps the segments (as `parse_method_name` already does for `FunctionDecl::scope`). Pinned by `escaped_identifiers.cases`'s one `#SKIP` and `verification::an_escaped_name_in_a_scoped_type_is_rejected_rather_than_corrupted`, both of which must keep failing-to-format until delivered~~ — **delivered 2026-09-02 by comment-slots**: `Parser::push_scope_segment` is the one join for every `::` chain and writes the escaped segment's terminator; `parse_method_name` keeps real segments (`ScopeSeg`, one comment slot per `::`). The `#SKIP` is a live case and the verification pin is inverted, with a new pair asserting the tightened spelling is still refused | escaped-identifiers | ~~vlog_parser~~ done | | ~~22~~ | ~~**Comment slots in shared expression/name machinery** drop the comment and the safety net refuses the file: `q[/*c*/ i]` (index expressions), `x inside {[/*c*/ 0:3]}` and `n /*c*/ inside {` (`inside` / `parse_value_range`), `pkg/*c*/ ::cls::name` (`parse_method_name` chains), `foreach (q[/*c*/ i])` (`parse_foreach_target`), `static /*c*/ constraint` / `pure /*c*/ static function` (`take_member_prefix`). Found by constraint-bodies' exhaustive gap fuzzer (358 gaps; these 40 fail identically on v0.26.0 in the same constructs outside a constraint). Inside a constraint they are regressions relative to the verbatim era — but no opentitan file hits one (sweep unchanged). Wanted: a parser-wide round giving each slot a `Meta`/comments field, then re-running the fuzzer to zero.~~ — **delivered 2026-09-02 by comment-slots**: ~70 named comment fields across `ExprKind`/`Stmt`/declarations/headers/labels (`SegmentComments`, `BinaryComments`, `CastComments`, `LabelComments`, `Stmt::before_semi` + `StmtKind::takes_semi()`), three duplicated grammars folded into `parse_postfix_segment` / `parse_value_range`, and four gap fuzzers at zero — covergroup 329, fragment 153, constraint 395 (committed at last), RTL 352 (new). Corpus (860 files) and opentitan (3 975 files) byte-identical to v0.30.0. Deliberately left: `if`/`case` in-paren comments still recovered print-side by `header_parens` (only `after_kw` got a slot) — a real slot there would change existing layout A fifth fuzzer bar 2026-09-05 (small-items-4, TODO §45.4): the **delay list** — `#(1:2:3)` on nets and continuous assignments, `#(rise, fall)` on gates — gained `MinTypMaxComments`, `ast::DelayValue`, `ContAssign::{after_hash, after_delay}`, `GateInstantiation::{before_hash, after_hash, before_semi}`, `GateInstance::before_args`; `EXPECTED_RTL_GAPS` 374 → 419 at zero. | constraint-bodies (dev + QA) | ~~vlog_parser~~ done | -| 23 | A **cross-file instance-member tail does not resolve for rename**: with `module sub` in `sub.sv` and `assign w = u_x.sig;` in `top.sv`, renaming `sub`'s `wire sig` edits `sub.sv` only — the same shape in one file resolves and is edited (`a_hierarchical_tail_that_resolves_is_renamed_with_its_declaration`). Since comment-slots the rename *says so* (item 20's warning); the edit itself is the gap. Modules export ports and parameters only (the class-member-access round 2 ruling), so an internal net is exactly what the cross-file hop refuses — the fix is either an export rule for nets named through an instance or a rename-time in-file fallback resolution of the tail. | comment-slots (dev, surfaced by the §2.9-20 control test) | vlog_semantic / vlog_refactor | +| ~~23~~ | ~~A **cross-file instance-member tail does not resolve for rename**: with `module sub` in `sub.sv` and `assign w = u_x.sig;` in `top.sv`, renaming `sub`'s `wire sig` edits `sub.sv` only — the same shape in one file resolves and is edited (`a_hierarchical_tail_that_resolves_is_renamed_with_its_declaration`). Since comment-slots the rename *says so* (item 20's warning); the edit itself is the gap. Modules export ports and parameters only (the class-member-access round 2 ruling), so an internal net is exactly what the cross-file hop refuses — the fix is either an export rule for nets named through an instance or a rename-time in-file fallback resolution of the tail. **Active owner: hierarchical-tail (TODO §49), working-tree implementation present; QA pending.** Keep this request open until acceptance.~~ — **delivered 2026-09-05 by hierarchical-tail (TODO §49):** a module has two member surfaces — the *connection* surface (ports, parameters; unchanged for every existing reader) and the *hierarchical* surface (plus nets, variables, instances; a second index table, `FACTS_FORMAT` 19) read only by the tail walk behind an instance head (`Surface::Hierarchical` from `resolve.rs::head_surface`). `assign w = u_x.sig;` resolves cross-file, the rename edits both files, the §2.9-20 warning is retired for a resolved tail. A generate-block-scoped net (`u_x.gen[0].sig`) is on neither surface and is still refused honestly. 514 references newly resolve over opentitan `hw/`. | comment-slots (dev, surfaced by the §2.9-20 control test) | vlog_semantic / vlog_refactor | | ~~24~~ | ~~A **half-typed `#(` parameter override whose value can read as a call** (`sub #(.W(` ⏎ `u0 (.a(x))`) — the greedy expression grammar swallows the next instance's name before any error fires, so the whole instantiation still degrades to an item-level `Error` node instead of getting header recovery's benefit. Found by §32's QA; the fix is a lookahead in the override grammar (an identifier followed by `(` on a later line is the next instance, not a call).~~ — **delivered 2026-09-04 by small-items-3 (TODO §36)** | header-recovery (QA) | vlog_parser | | ~~25~~ | ~~The parser **refuses** a module-scope `begin … end` and a bare `begin` inside a `generate` region (an `ItemKind::Error`) rather than recovering them as an unnamed generate block, so `module-begin-block` and `v2001-generate-begin` (TODO §35) fire on an error leaf and the rest of the unit is lost to recovery. Wanted: tolerant-mode recovery that keeps the block's items.~~ — **delivered 2026-09-04 by small-items-3 (TODO §36)** | linter-expansion-3 (dev) | vlog_parser | - | ~~26~~ | ~~**Same-target atomic writers share a temp path.** `atomic::temp_path` uses canonical target + process ID; parallel workers following distinct symlink spellings can reach that same name, while CLI dedup is lexical. A bounded direct helper probe (100 rounds, two threads, 1 MiB each) returned 100 write errors in 200 calls; no mixed final bytes observed in that probe. Use exclusive per-operation temp creation and coordinate/deduplicate target writes. See repository-analysis.md for limits.~~ — **closed by §41 (0.43.0):** unique `O_EXCL` temps (`.{name}.{pid}.{n}.lucisv-tmp`), dedup on `fs::canonicalize`; two *processes* remain last-writer-wins by design, stated in `atomic.rs` | repository audit, 2026-09-04 | lucisv_core / lucisv | -| ~~27~~ | ~~**Net-delay comment slot**: parser-skips records a pre-existing refusal for a comment immediately before `#` in a net declaration. The regression cases mark it `#SKIP`; preserve the verifier's rejection until a parser/formatter comment slot handles it.~~ — **delivered 2026-09-05 by walk-cycles (TODO §43.2):** `NetDelay::{before_hash, after_hash}` own the gaps around `#`; the `#SKIP` is retired; the RTL gap fuzzer covers it. The gaps inside `#(1:2:3)` remain §2.9-22's. | parser-skips (dev + QA) | vlog_parser / vlog_formatter | +| ~~27~~ | ~~**Net-delay comment slot**: parser-skips records a pre-existing refusal for a comment immediately before `#` in a net declaration. The regression cases mark it `#SKIP`; preserve the verifier's rejection until a parser/formatter comment slot handles it.~~ — **delivered 2026-09-05 by walk-cycles (TODO §43.2):** `NetDelay::{before_hash, after_hash}` own the gaps around `#`; the `#SKIP` is retired; the RTL gap fuzzer covers it. The gaps inside delay lists subsequently closed in small-items-4 (§45.4; see §2.9-22). | parser-skips (dev + QA) | vlog_parser / vlog_formatter | | ~~28~~ | ~~**Project lint selection is not consumed by the server.** `enabled_rules` reads `ClientSettings`; `configured` reads project rule options and line length only. `[lint] select/ignore` currently controls CLI runs, while the editor needs `lucisv.lint.select/ignore`. Decide and test a common precedence contract before claiming project-wide parity.~~ — **closed by §42 (0.43.0):** `enabled_rules` picks the editor's list when set, else the project's, key by key (the CLI's `pick`); rejected project entries logged once with file:line | repository audit, 2026-09-04 | lucisv_server | | ~~29~~ | ~~An unknown rule name in the **editor's** `lucisv.lint.select`/`ignore` is still dropped silently, while §42 logs the same mistake in a project file (and `lucisv.lint.options` logs its bad entries). Wants the same once-only log through `notification.rs`.~~ — **delivered 2026-09-05 by small-items-4 (TODO §45.1):** `settings::rules` records every dropped name in `ClientSettings::lint_name_warnings` as `lucisv.lint.: unknown rule: `; `apply_settings` logs what the previous settings value did not already say — once per (setting, name), re-armed by a changed list. | lint-config-contract (QA) | lucisv_server | | ~~30~~ | ~~**An unreadable directory aborts the whole walk.** `Walk::dir` propagates `read_dir`'s error with `?`, so one permission-denied directory anywhere under the start — reachable now that a symlink to an outside directory is followed once (§2.9-8's ruling) — drops every file already found and fails the run. Found by walk-cycles' QA on a link to `/`. Wanted: skip the directory and say so through a warning channel the walk does not have today (the filelist-missing-file precedent), which is also where a dangling source link's warning belongs.~~ — **delivered 2026-09-05 by small-items-4 (TODO §45.2):** `walk::collect_files` takes a `&mut dyn FnMut(Warning)` sink; an unreadable directory, an unreadable `.gitignore` and a dangling source link are warned about (`warning: : ` on the CLI's stderr before the report, exit code unchanged; logged once per scan by the server through `report_scope`) and the walk continues. | walk-cycles (QA) | lucisv_core / lucisv / lucisv_server | +| 31 | **DPI-export name binding remains open.** Package re-export resolution closed §2.9-16, but the name in a DPI export is still not a semantic reference. Keep this separate from the delivered package-member traversal. | dpi-export request (b); package-reexports | vlog_semantic | --- @@ -663,12 +682,12 @@ untouched, reusing existing arms. |---|---| | `vlog_parser` | spans, name-spans, recursion-limit, error-recovery, define-table, lexer-cleanup, decomposition-parser, and the grammar lane: *macro-items*, *classes*, *bind*, *dynamic-types*, *types-decls*, *item-misc*, *directives-in-lists*, *directives-in-instances*, *dpi-export*, *assertions*, *interfaces*, *expressions-2*, *dv-statements*, *mop-up-2*, *directive-split*, *ansi-first-port*, *null-items*, *constraint-bodies*, *covergroup-bodies*, *fragment-mode*, *vendor-formal-grammar*, *comment-slots*, *bind-semantics*, *sva-bodies* (most also add formatter arms — parser+formatter pairs by default; directive-split and ansi-first-port reused existing arms and left `vlog_formatter/src` untouched) | | `vlog_formatter` | safety-net (`verify.rs`), case-tables, formatter-bug-fixes, corpus-bugs, comments-round, comments-round-2, alignment (`align.rs`), format-fences (`fence.rs`), range-formatting (`range.rs`), shared-fence-filter, decomposition-formatter, and the layout halves of constraint-bodies, covergroup-bodies, comment-slots, bind-semantics and sva-bodies (`format/`) | -| `vlog_semantic` | vlog-semantic (`bind/`, `resolve.rs`, `model.rs`), workspace-index (`workspace/`), decomposition-semantic, class-semantics, interface-semantics, class-member-access, struct-members, overlay-promotion, port-detail-spans (`Symbol`/`Def::detail_span` and `Semantics::symbols_named`), hover-line-index (`DeclLines`, facts codec), vscode-hierarchy-sidebar's declaration/instance positions, scan-interleave (`WorkspaceIndex::absorb`), semantic-lints-on's word census, bind-semantics and sva-bodies, refactor-rename's performance amendment (`files_spelling`), plus the index halves of indexing-ux (`index_order`/`IndexBuilder`), index-scope (order-insensitive `finish`, facts-from-analysis), incremental-index (`update_file`, edge/reference tables, `instantiations.rs`, `classes.rs`), index-persistence (`facts.rs`; current `FACTS_FORMAT` 17; plus a small `vlog_parser::defines` touch — `DefineTable::from_entries`, `Eq` derives) | +| `vlog_semantic` | vlog-semantic (`bind/`, `resolve.rs`, `model.rs`), workspace-index (`workspace/`), decomposition-semantic, class-semantics, interface-semantics, class-member-access, struct-members, overlay-promotion, port-detail-spans (`Symbol`/`Def::detail_span` and `Semantics::symbols_named`), hover-line-index (`DeclLines`, facts codec), vscode-hierarchy-sidebar's declaration/instance positions, scan-interleave (`WorkspaceIndex::absorb`), semantic-lints-on's word census, bind-semantics and sva-bodies, refactor-rename's performance amendment (`files_spelling`), plus the index halves of indexing-ux (`index_order`/`IndexBuilder`), index-scope (order-insensitive `finish`, facts-from-analysis), incremental-index (`update_file`, edge/reference tables, `instantiations.rs`, `classes.rs`), index-persistence (`facts.rs`; committed `FACTS_FORMAT` 18; active §49 uses 19; plus a small `vlog_parser::defines` touch — `DefineTable::from_entries`, `Eq` derives) | | `vlog_linter` | linter-core, lint-harness, lint-rules-2, semantic-lints (`signals.rs`), semantic-lints-on (workspace oracle), one-parse (`context.rs`) | | `vlog_refactor` | refactor (plan), refactor-rename (including `prepare_rename_here` / `rename_name_at` selector half), refactor-ports (including module-target selectors), refactor-instantiate, references-nav (whole-scope equivalence oracle), and the refactor half of decomposition-semantic | | `lucisv_core` | lucisv-core-lift (`config.rs`, `walk.rs`), filelist (`filelist.rs`), format-cache (`cache.rs`) | | `lucisv` (CLI) | cli-polish, config-discovery (wiring), parallel-files, cli-filelist, linter-core (CLI half in `lint.rs`), one-parse (`lint.rs` parses once via `ParsedSource`), format-cache (wiring), release-prep (`--version` contract) | -| `lucisv_server` | lucisv-server (trunk), decomposition-server (`server/`, `completion/`), and one or two modules per capability feature: editor-scopes→`pairs.rs`, filelist→scope ladder in `state.rs`, include-nav→`includes.rs`, completion-core/fuzzy-completion/member-completion→`completion/`+`candidates.rs`, completion-templates→`templates.rs`, inline-templates→`inline.rs`, inline-instantiation→`inline.rs`+`completion/`+`candidates.rs` (+`settings.rs` key), bind-semantics→`instantiate.rs`, macro-expansion→`expand.rs`, hierarchy→`hierarchy.rs`, vscode-hierarchy-sidebar→`design_hierarchy.rs`, type-hierarchy→`type_hierarchy.rs`, type-definition→`type_def.rs`, code-lens→`lens.rs`, inlay-hints→`inlay.rs`, server-lint→`lint.rs`+`code_action.rs`, one-parse→`lint.rs`+`state.rs` (`Document.tree`), refactor wiring/performance fan-outs→`rename.rs`/`ports.rs`+`state.rs`, apply-edit+folders-and-config+cancel-request+work-done-progress→`server/`, editor-settings+indexing-ux+index-scope+index-persistence→`settings.rs`+`state.rs`(+`index_cache.rs`), incremental-sync→`sync.rs`, file-watching→`watch.rs`, file-operations→`file_ops.rs` (+`include_sources` in `state.rs`), pull-diagnostics→`diagnostics.rs`+`server/`, semantic-tokens-delta→`tokens.rs`+`server/semantic_tokens.rs`, on-type-formatting→`on_type.rs`, will-save-wait-until→`format.rs` (+`settings.rs`/`main.rs`), selection-range→`selection.rs`, linked-editing→`linked.rs`, references-nav (server half)→`folding.rs`+`nav.rs`, large-file-mode→`large.rs`+`server/large_file.rs`, lsp-318-extras→`format.rs` (+`main.rs` capability), hover-declarations→`hover.rs`(+`nav.rs`), port-detail-spans (server half)→`hover.rs`+`nav.rs`, hover-line-index→`hover.rs`+`locate.rs`+`state.rs`, scan-interleave/change-debounce/verbose-timing→`server/`+`state.rs`, perf measurements→`src/perf.rs` (`docs/perf/README.md`, not a feature README), interactive-latency→`state.rs` (the two token searches) + `selection.rs`/`on_type.rs`/`completion/`/`inline.rs` (their callers) + `src/perf.rs`/`tests/e2e.rs` (its measurements), editor-packaging (grammar test)→`tests/grammar.rs` | +| `lucisv_server` | lucisv-server (trunk), decomposition-server (`server/`, `completion/`), and one or two modules per capability feature: editor-scopes→`pairs.rs`, filelist→scope ladder in `state.rs`, include-nav→`includes.rs`, completion-core/fuzzy-completion/member-completion→`completion/`+`candidates.rs`, completion-templates→`templates.rs`, inline-templates→`inline.rs`, inline-instantiation→`inline.rs`+`completion/`+`candidates.rs` (+`settings.rs` key), bind-semantics→`instantiate.rs`, macro-expansion→`expand.rs`, hierarchy→`hierarchy.rs`, vscode-hierarchy-sidebar→`design_hierarchy.rs`, type-hierarchy→`type_hierarchy.rs`, type-definition→`type_def.rs`, code-lens→`lens.rs`, inlay-hints→`inlay.rs`, server-lint→`lint.rs`+`lint/project.rs`+`code_action.rs`, one-parse→`lint.rs`+`state.rs` (`Document.tree`), refactor wiring/performance fan-outs→`rename.rs`/`ports.rs`+`state.rs`, apply-edit+folders-and-config+cancel-request+work-done-progress→`server/`, editor-settings+indexing-ux+index-scope+index-persistence→`settings.rs`+`state.rs`(+`index_cache.rs`), incremental-sync→`sync.rs`, file-watching→`watch.rs`, file-operations→`file_ops.rs` (+`include_sources` in `state.rs`), pull-diagnostics→`diagnostics.rs`+`server/`, semantic-tokens-delta→`tokens.rs`+`server/semantic_tokens.rs`, on-type-formatting→`on_type.rs`, will-save-wait-until→`format.rs` (+`settings.rs`/`main.rs`), selection-range→`selection.rs`, linked-editing→`linked.rs`, references-nav (server half)→`folding.rs`+`nav.rs`, large-file-mode→`large.rs`+`server/large_file.rs`, lsp-318-extras→`format.rs` (+`main.rs` capability), hover-declarations→`hover.rs`(+`nav.rs`), port-detail-spans (server half)→`hover.rs`+`nav.rs`, hover-line-index→`hover.rs`+`locate.rs`+`state.rs`, scan-interleave/change-debounce/verbose-timing→`server/`+`state.rs`, perf measurements→`src/perf.rs` (`docs/perf/README.md`, not a feature README), interactive-latency→`state.rs` (the two token searches) + `selection.rs`/`on_type.rs`/`completion/`/`inline.rs` (their callers) + `src/perf.rs`/`tests/e2e.rs` (its measurements), editor-packaging (grammar test)→`tests/grammar.rs` | | `editors/vscode` | editor-packaging, editor-snippets, editor-settings (manifest half), editor-scopes (rainbow half), vscode-hierarchy-sidebar (`hierarchyView.js`/`hierarchyModel.js`), editor-platform-vsix, editor-marketplace-page, index-persistence (`storagePath` line), verbose-timing (`lucisv.verbose`, spawn args and restart in `extension.js`) | | `tools/` + CI | corpus-check, release-prep, ci-release, editor-platform-vsix (staging), range-formatting (`lucisv-changed.sh`) | @@ -754,7 +773,7 @@ ownership explicitly. | `lucisv_server/src/server/` | lucisv-server; amended by cancel-request, change-debounce, scan-interleave, index-scope, verbose-timing | every request/notification and every rebuild trigger | One ordered loop owns all mutable server state. A startup scan may publish a prefix and answer queued work between files; a request queued behind a rescan trigger is held until that rescan lands, and its cancel travels with it. Never make the distinction time-based: machine load must not change which index a request sees. Verbose timing may observe each wrapper/lifecycle but must be entirely silent when off and must not move protocol ordering. The queue thread only forwards protocol messages and must never parse. | | `lucisv_server/src/state.rs` | lucisv-server; amended by filelist, index-scope, scan-interleave, indexing-ux, incremental-index, index-persistence, hover-line-index, large-file-mode, one-parse (`Document.tree`), editor-settings + folders-and-config (`set_client_settings`/`change_roots`), include-nav (the include graph), completion-core (candidates), file-watching, interactive-latency (`first_token_reaching`/`first_token_from`), refactor performance fan-outs | every handler | `Workspace` is immutable through request handlers except the interior-mutable four-entry/8 MiB `FileView` cache. The scope ladder (filelist > `index.scope: "workspace"` > folder-scope at shipped depth 2; a rootless session never climbs; it reads flat at depth 0 and walks descendants at positive depth (including the default 2)) and open-buffer overlay are contracts. `Scan` has whole/widen shapes but one step/finish path; index/candidate/include prefixes publish together. `module_sources`, `rename_sources`, and `include_sources` must remain supersets of what their engines can edit/refuse over; `rename_sources` falls back to `sources()` when an ambiguous posting prevents a proven bound. `update_one` and a completed scan must equal a fresh build (`fingerprint`). Handlers reading `doc.text` instead of tokens/tree must check `doc.large`. | | `lucisv_server/src/settings.rs` | editor-settings | folders-and-config, indexing-ux, index-scope, index-persistence, inline-templates, will-save-wait-until, filelist, large-file-mode | One parser for both doors (push and pull, via `from_section` re-wrapping). Every key drops garbage independently; defaults that are not "silence" (1 MiB cap, log on, persist on, 4 MiB large-file threshold) are hand-written in `Default`. `set_client_settings` returns whether a reindex is owed — new keys must decide that question explicitly. | -| `vlog_semantic/src/workspace/` (+ `facts.rs`) | workspace-index; extended by incremental-index, index-persistence, index-scope, hover-line-index, scan-interleave, member semantics, semantic-lints-on, bind-semantics, SVA bodies and refactor-rename performance | server state, hierarchy/lens/type-hierarchy, refactor, completion, semantic lints | Determinism (same inputs → same index, any order), the `paths` spelling coupling with `resolve.rs`, `FACTS_FORMAT` bumped on any codec change (currently 17), edge/posting tables built by the same lifted walks the engines use. `DeclLines` must round-trip and participate in `fingerprint`; `absorb` must equal one build over the resulting record set; `files_spelling` must continue to include unresolved non-empty external/inherited paths or rename loses its dangling-use refusal; `FileFacts::words` is the shared project mention/completion census. | +| `vlog_semantic/src/workspace/` (+ `facts.rs`) | workspace-index; extended by incremental-index, index-persistence, index-scope, hover-line-index, scan-interleave, member semantics, semantic-lints-on, bind-semantics, SVA bodies and refactor-rename performance | server state, hierarchy/lens/type-hierarchy, refactor, completion, semantic lints | Determinism (same inputs → same index, any order), the `paths` spelling coupling with `resolve.rs`, `FACTS_FORMAT` bumped on any codec change (committed 18; active §49 uses 19), edge/posting tables built by the same lifted walks the engines use. `DeclLines` must round-trip and participate in `fingerprint`; `absorb` must equal one build over the resulting record set; `files_spelling` must continue to include unresolved non-empty external/inherited paths or rename loses its dangling-use refusal; `FileFacts::words` is the shared project mention/completion census. | | `vlog_refactor/src/rename/` | refactor-rename; shared by references-nav and the performance wave | server rename/prepareRename/references and port refactor verification | `Scope` remains the whole-scope authority and `collect_occurrences` the one rename/references walk. The fast `prepare_rename_here` answer/refusal and `rename_name_at` target are parity contracts, not alternate semantics. Any new refusal must be expressible on the fast path or force a deferral; any new occurrence shape must be reflected in the server fan-out or trigger its all-sources fallback. | | `vlog_parser/src/token.rs` keyword table | completion-core (`KEYWORDS` export) | lexer, pairs.rs, editor grammar (test-locked), completion | Adding a keyword = lexer change + `pairs.rs` re-check + a hand edit to the grammar (`tests/grammar.rs` names the missing word) + potentially `verify.rs`-adjacent behavior. dv-statements added `randcase`/`let` to `is_keyword` and recorded it as shared with the adjacent lexer-cleanup round — the precedent for treating this file as coordinated even between back-to-back rounds. | | `editors/vscode/package.json` | editor-packaging | editor-settings, editor-scopes (colour ids), editor-snippets, index-persistence, verbose-timing, platform-vsix, marketplace-page | Settings/colour/snippet ids referenced from `extension.js` or the server must move in lockstep; mismatches are *silent* (VS Code ignores unknown ids). `lucisv.verbose` is special: it changes a spawn argument and therefore restarts the server instead of flowing through the ordinary settings push. Version number is one of the four version files. |