# topo.md — the dependency topology of lucisv **Purpose.** This document is the map an agent reads before touching anything: which modules depend on which, which features consume which, and where the two graphs meet. It exists to make parallel multi-agent development safe — every edge below is an interface somebody can break, and every *absent* edge is a place two agents can work at the same time without talking. Sources of truth this document is derived from (and defers to on conflict): each crate's `Cargo.toml`, each feature's `docs/features//README.md` (the **Handshakes** section in particular), `README.md` and `CLAUDE.md`. Drafted 2026-08-27 from the workspace at v0.10.2 (93 feature READMEs); updated 2026-08-28 for hover-declarations, change-debounce, port-detail-spans and interactive-latency (97 feature READMEs); updated 2026-08-29 from v0.14.0 for hover-line-index, scan-interleave, incremental scope widening, the request-fan-out performance wave and verbose-timing (100 feature READMEs); updated 2026-08-30 from v0.17.0 for inline-instantiation, the two-level module-instantiation split (106 feature READMEs — the testbench wave's five arrived in between, their edges already tabled below; +§2.9-19); updated 2026-08-30 again for fuzzy-completion (107 feature READMEs); updated 2026-09-01 for null-items (108 feature READMEs). **Edge notation, used in all three sections:** | notation | meaning | |---|---| | `A ──▶ B` | **A depends solely on B.** A consumes B's published interface; B was not changed for A and does not know A exists. Breaking B's interface breaks A; breaking A costs B nothing. | | `A ◀──▶ B` | **Handshake.** A negotiated, two-sided contract: B changed something *for* A (or both sides pin one wire shape / file format / naming convention), and the contract is written down in one or both READMEs. Either side moving unilaterally breaks the other. | | `A ─▶ B` | **Not a dependency** — a one-way note whose `kind` column says what it is: `sequencing` (corpus files handed from one bucket to the next), `standing promise` (A imposes a rule on B and its successors), `open request`, or `depends (consumed by)` — the last reads **B depends on A**. | | *(absent)* | The two are independent. Independent pairs are **not listed** — their absence is the claim. | A handshake that was **requested but not yet delivered** is an *open handshake*; those are collected in §2.9 because they are exactly the coordination points parallel agents must not both grab. --- ## 1. Module dependency graph "Module" here means: the eight workspace crates, the two editor trees, and the script layer (`tools/`, `scripts/`, CI). Intra-crate structure that matters for parallel work is in §1.3. ### 1.1 Crate-level graph ```mermaid graph TD subgraph foundations [foundation crates — depend on nothing] P[vlog_parser] C[lucisv_core] end F[vlog_formatter] --> P S[vlog_semantic] --> P L[vlog_linter] --> P L --> S R[vlog_refactor] --> P R --> S CLI[lucisv (CLI)] --> C CLI --> P CLI --> F CLI --> L SRV[lucisv_server] --> C SRV --> P SRV --> S SRV --> R SRV --> F SRV --> L L -.dev-dep (fix harness).-> F VSC[editors/vscode] -.spawn contract.-> SRV VSC -.KEYWORDS grammar lock.-> P NVIM[editors/nvim (docs)] -.spawn contract.-> SRV TOOLS[tools/ release scripts] -.builds/packages.-> CLI TOOLS -.builds/packages.-> SRV TOOLS -.builds/packages.-> VSC CI[Gitea Actions] --> TOOLS CORPUS[scripts/ + tools/corpus_*] -.exit codes, msg prefixes.-> CLI ``` *(The diagram shows direction only; §1.2 is authoritative on `depends` vs `handshake` for each edge.)* External dependencies (all exactly pinned in the workspace `Cargo.toml`): `rayon` (CLI only, sanctioned by TODO §3), `lsp-server` + `lsp-types` + `serde`/`serde_json` (server only, sanctioned by TODO §6). Those are the only **direct** external dependencies; everything the workspace itself writes is std (they pull in ~20 transitive crates — see `Cargo.lock` — which is what an audit counts, not what an agent can call). `lsp-types` carries `features = ["proposed"]` for LSP 3.18 `inlineCompletion` (inline-templates). ### 1.2 Crate edges, documented Every edge is directional; "consumes" lists the load-bearing surface, i.e. what a change on the pointed-to side must not silently break. | edge | kind | contract | |---|---|---| | `vlog_formatter ──▶ vlog_parser` | depends | `parse(tokens, source)` / `parse_source`, the whole AST, `tokenize` (re-used by `verify.rs` to re-lex both sides of the safety net), trivia attachment (`Meta::{leading,trailing,before_sep,attrs}` — comments are never dropped), `RawText.col` (the dedent column for verbatim re-indent), spans. The formatter is the AST's primary consumer: **every new `ItemKind`/`StmtKind`/`ExprKind` variant costs an arm in `format.rs`** (its matches are exhaustive). | | `vlog_semantic ──▶ vlog_parser` | depends | The AST read-only, `parse_source_tolerant`/`parse_tolerant` (never fails; `Error` nodes are opaque leaves), the **name-span contract** `src[name_span] == name` on every declaring node, `token::is_keyword`, `defines::collect_defines`/`DefineTable`, `TextRange`. `bind.rs`'s `ItemKind`/`ExprKind`/`DimKind` matches are exhaustive — new variants cost an arm here too. | | `vlog_linter ──▶ vlog_parser` | depends | `ParsedSource::parse` = `tokenize` + `parse_tolerant` (one-parse bundle), `LineIndex`, `TextRange`, AST shapes walked by `visit.rs` (which ends in `_ => {}`, so new variants usually cost nothing here), token facts for text rules (a macro use is one `Ident` token; a directive is one `Directive` token). | | `vlog_linter ──▶ vlog_semantic` | depends | `analyze`, `Semantics::{symbols, references, references_of}` for the three semantic rules (`unused-signal`, `undriven-net`, `multiply-driven`). Lazy: a run with no semantic rule enabled never calls `analyze`. Justified in `vlog_linter/Cargo.toml`; adds no external code (`vlog_semantic` is `vlog_parser` + std). | | `vlog_linter ──▶ vlog_formatter` **(dev-only)** | depends (tests) | The `.lint` fix harness asserts a lint fix never produces text `format_source` refuses. **The library dependency list is still `vlog_parser` + `vlog_semantic` + std** — `cargo tree -p vlog_linter -e normal` is the pinned check. Do not promote this to a normal dep; the fence filter deliberately lives in the front ends instead (see shared-fence-filter, §2.4). | | `vlog_refactor ──▶ vlog_parser` | depends | `tokenize`, `parse_source_tolerant` + diagnostics, `LineIndex`, `TextRange`, the port/instantiation/module AST shapes, `token::is_keyword` (new-name validity), `defines` via the index. Every edit span originates in a parsed node — no textual search-and-replace. | | `vlog_refactor ──▶ vlog_semantic` | depends | `Semantics` queries (`symbol_at`, `references_of`, `reference_id_at`, …), `Resolution` variants (three of them are refusal rules), `WorkspaceIndex` + `resolve_external` + `ExternalTarget`, and the exactness promise on `name_span` (re-checked before each edit is emitted). One historical exception: refactor-rename added `Target::Declaration` + end-label uses *into* `vlog_semantic` (lead-authorized, additive — see §2.6). | | `lucisv ──▶ lucisv_core` | depends | `config::{FileConfig, Discovery}` (lucisv.toml discovery — `config::parse` is reached through `Discovery`, not called directly), `walk::{collect_files, EXTENSIONS}` (the `.gitignore`/`--exclude` walk), `filelist::read` (`-f`), `cache` (the format cache). (`walk::is_excluded` is `pub` but currently has no consumer outside the crate.) | | `lucisv ──▶ vlog_formatter` | depends | `format_source` / `format_range` / `LineRanges` / `Config` / `FormatError`, and `fence::{protected_regions, is_protected}` (the `--fix` fence filter — the linter crate deliberately has no fence notion). | | `lucisv ──▶ vlog_linter` | depends | The public linter API for `lucisv check` — `lint` + `LintContext`/`ParsedSource`, `apply_fixes`, `select_rules` (the CLI does not call `run` itself). Relies on: rule names stable, linting never panics/writes, findings sorted by `(span.start, span.end, rule)`. | | `lucisv ──▶ vlog_parser` | depends | `LineIndex` / `TextRange` for lint report coordinates, plus `PARSE_STACK_SIZE` for both the named `lucisv` thread and rayon workers. (The CLI otherwise reaches the parser through the formatter and linter.) | | `lucisv ──▶ rayon` | depends | The worker pool. Pinned exactly; pool must keep `stack_size(vlog_parser::PARSE_STACK_SIZE)` (currently 16 MiB; recursion-limit handshake) or the parser's depth guarantee regresses to a stack overflow. | | `lucisv_server ──▶ lucisv_core` | depends | Same config discovery and walk as the CLI (that sameness is the point — format-on-save must agree with `lucisv --check`), `filelist::read` (index scope rung 1, `+incdir+` for the include graph), `cache::content_hash` (re-used by the persistent index cache — one FNV-1a, not two). | | `lucisv_server ──▶ vlog_parser` | depends | `tokenize`, `parse_source_tolerant`/`parse_tolerant`, `ParseDiagnostic`, `LineIndex`, `TextRange`, tokens + trivia, `defines`, `KEYWORDS` (completion keyword tier; also the source the VS Code grammar is generated from), and `PARSE_STACK_SIZE` for the named `lucisv-main` thread. | | `lucisv_server ──▶ vlog_semantic` | depends | `analyze`/`Semantics` (every navigation answer), `WorkspaceIndex` (build/incremental update, units/members/defines, `instantiations_of`/`subclasses_of` edge tables, `FileFacts` codec for the persistent cache), `resolve_external` overlay, `index_order`/`IndexBuilder` (watched builds). | | `lucisv_server ◀──▶ vlog_semantic` | handshake | Two negotiated additions, both 2026-08-28 and both additive: **`Symbol::detail_span` / `Def::detail_span`** (where a non-ANSI port's body declaration completes the header that names it — the server's hover card and `nav::definition` both read it, and they show/jump to it in the same order), and **`Semantics::symbols_named`** (name → declarations, built in `analyze`, in declaration order — the server replaced two scan-every-symbol loops with it and the *first-match tie-break must stay declaration order* or hover's choice between two live declarations of one name changes). `docs/features/port-detail-spans/README.md`. | | `lucisv_server ◀──▶ vlog_semantic` | handshake | Three later additive performance surfaces: **`DeclLines` / `Def::lines`** record declaration and detail lines at index time (`FACTS_FORMAT` 3 → 4); **`WorkspaceIndex::absorb`** folds a scan batch with one merge rather than one merge per file; and **`WorkspaceIndex::files_spelling`** finds external uses by spelling, resolved or not, for rename's dangling-use refusal. The first feeds hover-line-index, the second scan-interleave, and the third refactor-rename's six-rung fan-out. Changing the facts codec, reference-fact census or merge semantics breaks those consumers. | | `lucisv_server ──▶ vlog_refactor` | depends | `prepare_rename`/`rename`, `find_references`, the port refactorings, `instantiation_plan`/`render_with`/`module_definition` (the inline instantiation ghost, signature help, inlay hints — the completion popup stopped consuming them 2026-08-30, names-only tier). Promise consumed: never a partial edit — `Ok` verified whole, `Err` is a sentence. | | `lucisv_server ◀──▶ vlog_refactor` | handshake | Request-scope selectors added for the performance wave: `prepare_rename_here` must produce the same answer/refusal text as whole-scope `prepare_rename`; `rename_name_at` must name the target that the rename engine acts on; `port_action_modules` and `enclosing_module` must name every module the corresponding port action/command can edit. The server uses those names only to choose an index-derived superset of files; the engine remains the authority. | | `lucisv_server ──▶ vlog_formatter` | depends | `format_source`, `format_range`/`LineRanges` (range, ranges, on-type formatting), `Config`, `fence::protected_regions` (quick-fix filter). | | `lucisv_server ──▶ vlog_linter` | depends | `run`, `lint` + `LintContext::from_parse` (lints from the `Document`'s own parse — one-parse), `default_rules`, `apply_fixes`, `rule_by_name`. Same three promises the CLI relies on. | | `lucisv_server ──▶ lsp-server / lsp-types` | depends | The transport (synchronous, no async runtime) and the protocol data model. Both pinned exactly. cancel-request additionally relies on `lsp-server 0.10.0`'s stdio transport being a **rendezvous channel** (its own forwarder queue exists because of it) — a version bump must re-read that crate's `stdio.rs`. | | `editors/vscode ◀──▶ lucisv_server` | handshake | The **spawn contract**: binary named `lucisv-server`, no env, LSP over stdio, `initialize` works with no roots (single-file mode). The extension passes exactly `[]` by default or `['--verbose']` when `lucisv.verbose` is true; the server accepts only that spelling (repeats are idempotent) and refuses any other argument with exit 2. Changing that setting restarts the server because it is a process argument, not an LSP setting. Wire shapes pinned on both sides: the custom `lucisv/scopePairs` result, the other `lucisv.*` settings section (push and pull), `initializationOptions.storagePath`, the markdown fence tag `systemverilog` (server emits it, extension's grammar registers it), the `bin/` layouts of the platform `.vsix` packages. `smoke.js` still drives the default no-argument contract headlessly; `tests/e2e.rs` pins both spawns and `tests/grammar.rs` pins the grammar. | | `editors/vscode ◀──▶ vlog_parser` | handshake | The TextMate grammar's keyword alternation is **hand-maintained and test-locked to `vlog_parser::KEYWORDS`**: `crates/lucisv_server/tests/grammar.rs` fails, naming the missing/extra words, when they diverge (there is no generator script). Adding a keyword to `token.rs`'s `keywords!` macro is therefore also a hand edit to `editors/vscode/syntaxes/systemverilog.tmLanguage.json`. | | `editors/nvim ──▶ lucisv_server` | depends | Documentation-only module: config snippets consuming the same spawn contract and settings shape. No code. | | `tools/ ◀──▶ crates + editors/vscode` | handshake | `release.sh` parses `lucisv --version` (field 2), runs `smoke.js` against the built server, stages `dist/lucisv[-server]--` names, packages seven `.vsix` files and asserts their `bin/` layouts. `audit_artifacts.sh` and `prune_release_assets.sh` key on those exact names. The version number lives in exactly four files (two `Cargo` files, two `package*.json`) and nowhere in Rust source. | | `CI (Gitea Actions) ──▶ tools/` | depends | `release.yml` is (almost) all `tools/` one-liners — `release.sh --cross`, `audit_artifacts.sh`, `prune_release_assets.sh`, `release_notes.sh`, `publish_release.sh` — so every release step runs by hand too; its only inline logic is the tag-vs-`lucisv --version` check. `ci.yml` is plain `cargo fmt`/`clippy`/`test` plus `scripts/corpus_gate.sh` (which reaches `tools/corpus_fetch.sh` on a cache miss). Tag `vX.Y.Z` must equal the workspace version; release notes come from `CHANGELOG.md`'s `## — ` headings via `release_notes.sh`. | | `scripts/score.sh + tools/corpus_check.sh ──▶ lucisv` | depends | The frozen 0/1/2 exit-code contract, plus a **textual** dependency on the message prefixes `parse error:` / `lex error:` / `verification failed:` (a standing fragile coupling — rewording those means telling corpus-check; see §2.9). | **Deliberately absent crate edges** (independence you can rely on): - `lucisv` (CLI) does **not** depend on `vlog_semantic` or `vlog_refactor` — the CLI formats and lints; semantic lints reach it only *through* `vlog_linter`, and refactoring is server-only today. - `vlog_refactor` does **not** depend on `vlog_formatter` — refactored output is edited source, not reformatted source (refactor README, by design). - Among `vlog_formatter`, `vlog_semantic`, `vlog_refactor`, `vlog_linter` there are exactly two build-time inter-crate edges — `vlog_linter → vlog_semantic` and `vlog_refactor → vlog_semantic` — plus `vlog_linter → vlog_formatter` as a **dev-dependency only**. All four depend on `vlog_parser`. `vlog_formatter` is the isolated one: nothing in this group depends on it at build time and it depends on none of them. Formatter work and semantic work are parallel-safe except where both touch `vlog_parser::ast`. - `lucisv_core` depends on nothing and nothing in it knows about Verilog — it is "which files, with what settings". - `vlog_parser` depends on nothing. It is also the **highest-contention module in the workspace**: six crates depend on it, five consume the AST (the CLI takes only `LineIndex`/`TextRange`), and two of those match it exhaustively — `vlog_formatter/src/format.rs` and `vlog_semantic/src/bind.rs` — with `vlog_parser`'s own `tests/spans.rs` as a third exhaustive walker. `vlog_linter`, `vlog_refactor` and `lucisv_server` walk it with catch-all arms. See §3.3. ### 1.3 Intra-crate structure (what matters for parallel work) **`vlog_parser`** — `lexer.rs` → `token.rs` (tokens + trivia attachment); `parser.rs` (recursive descent, strict + tolerant entry points over one grammar, depth/chain budgets from recursion-limit) → `ast.rs`; `span.rs` (`TextRange`), `line_index.rs` (offset↔line:col), `defines.rs` (the `` `define`` table, reads the token stream, expands nothing). `tests/spans.rs` is an exhaustive AST walker: **every new node needs an arm there** and must keep the span-nesting invariant. `PARSE_STACK_SIZE` is part of the public parser contract: every production thread that can reach parse or analysis must use it; the CLI main thread, rayon pool and server main thread do so, while the server queue and `lsp-server` I/O threads are proven not to parse. **`vlog_formatter`** — the pipeline is `format.rs` (per-node rules) → `doc.rs` (the Wadler IR) → `printer.rs` (width-aware printing); `verify.rs` (the runtime safety net: token equivalence + convergence — CLAUDE.md invariant #4 territory, see §3.3); `fence.rs` (format-off regions + `protected_regions`, consumed by both front ends); `range.rs` (`--lines`); `align.rs` (alignment inference). `format_source` = parse → format → verify; an error means emit nothing. **`vlog_semantic`** — `bind.rs` (AST → scopes/symbols/references) → `model.rs`; `resolve.rs` (the lexical walk; misses become `ExternalCandidate`/`InheritedCandidate` carrying candidate paths); `scan.rs` (residual text-scanning for the one span the parser doesn't carry — `DataType`; shrinks to zero when open handshake §2.9-2 lands); `workspace.rs` (`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 4); `instantiations.rs`, `classes.rs` (the shared walks, lifted from the server so the index census and the request handlers cannot drift). **`lucisv_core`** — `config.rs` (`lucisv.toml` parsing + `Discovery`, the upward search with its per-instance cache), `walk.rs` (`collect_files`, `EXTENSIONS`, `.gitignore`/`--exclude` filtering), `filelist.rs` (the `.f` reader: files, `+incdir+`, defines, warnings), `cache.rs` (the format cache + `content_hash` — the one FNV-1a the server's index cache also reuses). Knows nothing of Verilog; depends on nothing; owns two open handshakes (§2.9-1, §2.9-8). **`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`, `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). **`vlog_refactor`** — `rename.rs` (the `Scope` cache + occurrence walk — also the engine of `references.rs::find_references`; publishes the cheap `prepare_rename_here`/`rename_name_at` selectors whose parity with the full engine is test-pinned), `ports.rs` (add/remove/propagate plus `port_action_modules`/`enclosing_module`, the names the server uses to bound the input set), `instantiate.rs` (plans + rendering; the one layout both plain and snippet spellings go through), `check.rs` (whole-edit verification: re-tokenize + re-resolve, refuse everything on any drift). **`lucisv` (CLI)** — `main.rs` (args → walk → per-file worker pool; `process_file` is the cache-aware unit of work; panic hook installed once at startup — **keep it that way**, cli-polish → parallel-files handshake), `args.rs`, `diff.rs`, `lint.rs` (the `check` subcommand; owns the CLI-side fence filter). **`lucisv_server`** — layered, 40 files (`includes.rs` is the one file that spans two layers — the include graph *and* the `documentLink` handler; `perf.rs` is `#[cfg(test)]`-only and is not a layer — see `docs/perf/README.md`): | layer | files | role | |---|---|---| | entry | `main.rs` | the no-argument / `--verbose`-only argument contract, capabilities advertisement, `InitializeParams` reading, wiring | | loop | `server.rs` | the message loop + queue/burst (cancel-request), dispatch, `Pending` map for server-initiated requests, stepped startup scans with mid-scan request drains, held-request ordering for rescans, reindex/widen orchestration, progress/log senders, optional `timing:` instrumentation | | state | `state.rs` | `Workspace` (roots, scope ladder, index, include graph, candidates, index cache, open `Document`s with overlay, bounded closed-file `FileView` cache), `Scan` (whole or additive widen), fan-out source selectors (`module_sources`, `rename_sources`, `include_sources`), and `Document` (text, tokens, tree, semantics, diagnostics, `large` flag) | | substrate | `convert.rs`, `uri.rs`, `locate.rs`, `pairs.rs`, `includes.rs`, `candidates.rs`, `index_cache.rs`, `watch.rs`, `settings.rs`, `templates.rs`, `sync.rs` | position math, URI↔path, location building, the begin/end scope matcher, the include graph, completion word/module tables and their scan-batch forms, the persistent index store, watcher registration, `lucisv.*` settings parsing, snippet registry, incremental text sync | | handlers | one file per capability: `format.rs`, `diagnostics.rs`, `lint.rs`, `hover.rs`, `expand.rs`, `nav.rs`, `type_def.rs`, `type_hierarchy.rs`, `hierarchy.rs`, `symbols.rs`, `tokens.rs`, `completion.rs`, `signature.rs`, `inlay.rs`, `inline.rs`, `lens.rs`, `code_action.rs`, `rename.rs`, `ports.rs`, `folding.rs`, `selection.rs`, `linked.rs`, `on_type.rs`, `includes.rs` (links), `file_ops.rs`, `large.rs` | each is a mostly-pure function over `Document`/`Workspace`; protocol only, no language analysis of its own (anything that looks like analysis in here is a bug or a Handshake request — lucisv-server README) | **`editors/vscode`** — `extension.js` (spawn + rainbow decorations + storage path; ~everything else is `vscode-languageclient` driven off advertised capabilities), `package.json` (languages, grammar, snippets, settings, colour ids), `syntaxes/` (hand-maintained grammar, test-locked to `KEYWORDS`), `snippets/` (static, server-independent), `restart.js` (the one serialized start/restart chain, so a `lucisv.verbose` toggle cannot be lost to an in-flight start — shipped, and the only module `extension.js` requires), `smoke.js` (headless handshake check) and `restart_test.js` (headless check of that chain, against a scripted fake client), `README.md` (the Marketplace Details page, owned by editor-marketplace-page). --- ## 2. Feature dependency graph 100 features. They 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. ```mermaid graph LR subgraph FMT [formatter foundations] direction TB safety[safety-net] --- cmts[comment rounds] --- fences[format-fences] --- rangef[range-formatting] end subgraph GRAM [parser grammar / corpus] direction TB corpus[corpus-check] --- pspans[spans / name-spans] --- macro[macro-items] --- classes --- rest[...12 more buckets] end subgraph CLIL [CLI lane] direction TB polish[cli-polish] --- cfg[config-discovery] --- par[parallel-files] --- cache[format-cache] end subgraph LINT [linter lane] direction TB lcore[linter-core] --- lr2[lint-rules-2] --- slint[semantic-lints] end subgraph SEM [semantics & index] direction TB vsem[vlog-semantic] --- widx[workspace-index] --- incr[incremental-index] --- persist[index-persistence] end subgraph REF [refactor lane] direction TB flist[filelist M1] --- ren[refactor-rename M2] --- prt[refactor-ports M3] --- inst[refactor-instantiate M4] end subgraph LSP [LSP server lane] direction TB srv[lucisv-server] --- caps[~30 capability features] end subgraph PKG [packaging & release] direction TB epack[editor-packaging] --- pvsix[editor-platform-vsix] --- cirel[ci-release] end GRAM --> FMT corpus -. measures .-> GRAM LINT --> FMT SEM --> GRAM SEM --> CLIL REF --> SEM LSP --> SEM LSP --> REF LSP --> FMT LSP --> LINT LSP --> CLIL CLIL --> FMT PKG --> LSP PKG --> CLIL PKG --> GRAM ``` ### 2.1 Formatter foundations | edge | kind | contract | |---|---|---| | `case-tables ──▶ safety-net` | depends | The case harness consumes `format_source`'s post-safety-net `Err` — cases that used to produce wrong output now report `format failed:`. | | `formatter-bug-fixes ◀──▶ safety-net` | handshake | safety-net *filed* the request (comments need positions to re-indent); formatter-bug-fixes *delivered* it: `Comment { line, col }`, `Token::trailing: Option`, `RawText { text, col }`. | | `formatter-bug-fixes ──▶ case-tables` | depends | Fixes the five bugs case-tables found and parked; each `#SKIP` case became a live regression case. | | `format-fences ──▶ spans` | depends | The first consumer of byte spans: a fenced region is a source slice by span. Also added `Doc::Verbatim` (leaf; emitted only right after a line break). | | `comments-round ◀──▶ format-fences` | handshake | fences requested a span on `Meta.trailing`; comments-round delivered `Option`. Same-line fences remain deliberately inert (matcher unchanged) — documented on both sides. | | `comments-round-2 ──▶ comments-round` | depends | Closes the bracket-position comment shapes round 1 parked; same machinery, four new `Vec` slots. | | `corpus-bugs ──▶ corpus-check` | depends | Fixes exactly the four root causes A–D the corpus check catalogued; measured back to 0 verification errors. | | `range-formatting ──▶ format-fences` | depends | A range is "an inverted fence": reuses `Doc::Verbatim`, `fence::collect`/`region_at`, and two helpers widened to `pub(crate)` (`line_start`, `with_trailing_comments`) — the only fence.rs change. | | `range-formatting ──▶ spans` | depends | The planner selects items by span/line. | | `alignment ──▶ spans` (+ name-spans) | depends | Anchor columns are derived from `name_span` byte offsets + the source text; deliberately **no** token-level representation of spacing. `doc.rs`/`printer.rs`/`verify.rs` untouched. | | `alignment ──▶ format-fences` | depends | `fence::region_at` (via `Fmt::is_fenced`) keeps fenced items out of alignment groups. | | `shared-fence-filter ◀──▶ linter-core / server-lint` | handshake | Closes server-lint Handshake 3: `fence::protected_regions` + `is_protected` become the **one** answer to "what may an automatic fix not touch"; CLI `--fix` and server quick fixes both call it; `vlog_linter` itself deliberately stays fence-blind. | | `recursion-limit ◀──▶ parallel-files` | handshake | recursion-limit requires every parsing thread to use `vlog_parser::PARSE_STACK_SIZE` (currently 16 MiB); parallel-files points the rayon pool at the constant, and the later stack audit put the CLI/server main work on named threads using the same value. Tests fail if a spawn site drifts. | | `recursion-limit ◀──▶ error-recovery` | handshake | Recovery must not reset `depth`/`links` while unwinding; error-recovery proves it with white-box + mutation tests. | | `one-parse ◀──▶ linter-core / server-lint` | handshake | Both filed the "one parse, two tools" request; one-parse delivered `LintContext::from_parse` + `ParsedSource`, `Document` gained its `tree` field, and both front ends lint from one parse. Behavior byte-identical was the gate. | Standing discipline for every feature in this lane (and any feature touching the formatter): **`verify.rs` widening is guilty until proven innocent** (CLAUDE.md #4). The only widening ever shipped is macro-items' backtick-`Ident` arm in `normalize` — the normalization that produced lucisv's one real corruption (2026-08-19, shipped without attack tests). Its repair, `trim_lines_outside_strings`, is a *narrowing*, and it shipped with the rejection tests the widening lacked. Every other round states "`verify.rs` untouched" and adds *rejection/attack tests anyway*. Treat that as the template. ### 2.2 Parser grammar / corpus lane `corpus-check` is the measuring instrument for the whole lane: it defines the buckets, and each grammar feature empties one and *advances* files into the next — a sequencing chain, not a code dependency. The lane's members: the sixteen bucket features (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) plus the parser-infrastructure features (spans, name-spans, error-recovery, lexer-cleanup, define-table, and recursion-limit, whose edges sit in §2.1). Code edges: | edge | kind | contract | |---|---|---| | every grammar feature `──▶ corpus-check` | depends | The bucket scores and first-blocker histograms are how each round chose its target and measured its result. | | `classes ◀──▶ vlog_parser::parse` | handshake | `parse(tokens)` became `parse(tokens, source)` — verbatim capture needs source in strict mode; every caller updated in the same change. | | `assertions ──▶ classes` | depends | Reuses `verbatim_since`/`skip_balanced` (the constraint/covergroup capture) unchanged; adds `StmtKind::Verbatim`. | | `directive-split ──▶ assertions / classes` | depends | Fifth producer of `ItemKind::Verbatim`; reuses the capture and `Fmt::raw_text` unchanged. | | `item-misc ──▶ macro-items` | depends | Extends `at_macro_item` (spaced argument lists, `` `error``/`` `warning``); same verbatim contract, `RawText.col` still load-bearing. | | `classes ─▶ macro-items` | refined in place | classes added the one-line `#(`-lookahead refinement to `at_macro_item` (the `` `uvm_component_new`` + parameterized-declaration idiom) — documented in classes' Handshakes, safety property unchanged. | | `dynamic-types ─▶ ast::Dim` consumers | non-additive change | `Dim` became `{ kind: DimKind, span }` — the lane's **only** vector-element/shape change in history; every consumer was found by grep and updated (`Fmt::dim`, `bind_dims`, the spans walker). The precedent §3.3's "prefer additive fields" rule exists to avoid repeating. | | `mop-up-2 ──▶ macro-items / dv-statements` | depends | Delivers the macro-followed-by-symbol fix dv-statements filed against macro-items, plus `new obj` (the expressions request from dv-statements) and base-only numbers. | | `directives-in-instances ──▶ directives-in-lists` | depends | Reuses `ListDirective` and `take_list_directives` verbatim; same additive-fields shape chosen for the same blast-radius reason. | | `dpi-export ─▶ dv-statements` | sequencing | Handed `csr_utils_pkg.sv` on (its next blocker was a `foreach`, a dv-statements shape). Typical of many one-way "your bucket now" notes across this lane. | | `interfaces ─▶ expressions-2` | sequencing | Two files advanced to `->` implication and drive strengths; expressions-2 emptied that bucket. | | `classes ◀──▶ class-semantics` | handshake | classes shipped with the honest gap "no name inside a class body is indexed"; class-semantics closed it (see §2.5). | | `classes ─▶ format-fences` | open request | `fence::scan_nested` has no `Class` arm, so a fence inside a class body is inert **for the formatter** (the `protected_regions` line-scan backstop still protects `--fix`). Filed, not fixed — §2.9. | | `ansi-first-port ◀──▶ type-definition` | handshake | type-definition filed the "first port with no direction doesn't parse" request; ansi-first-port delivered it (parser + one `bind_data_type` arm + one `type_span` tweak), and type-definition's tests flipped. | | `out-of-class-constraints ──▶ classes` | depends | Reuses the verbatim constraint capture and `parse_method_name` unchanged; one line in `parse_constraint`, no new AST variant, so none of the exhaustive-arm blast radius applies (2026-08-29 testbench wave, Lane A). | | `directive-in-statements ──▶ directive-split / directives-in-lists / assertions` | depends | The mirror-image recovery: a directive OPENING inside a statement/expression, captured verbatim through `construct_end` (Semi / endfunction+label / Unknown → refuse) and `terminated_in_arm`; `take_list_directives` additionally stops harvesting an outer region's `` `else `` as a list element. No new AST variant (2026-08-29 testbench wave, serial round). | | `directive-in-statements ◀──▶ formatter-bug-fixes` | handshake | formatter-bug-fixes round 2 filed the `take_before_open` pending-comment drain; directive-in-statements delivered it as `Parser::take_gap` (comments kept only when `span.start >= last_end()`, `CallComments::dangling` included — the specified fix alone was insufficient). The refusal pin flipped to a formats case on the merged tree, closing the last bucket-2 file (`keymgr_scoreboard.sv`). | | `null-items ──▶ corpus-check / safety-net` | depends | `ItemKind::Empty` (2026-09-01): a lone `;` where an item belongs — IEEE 1800-2017 A.1.4's null item — accepted in every item scope by one branch at the top of `parse_item_kind`. The variant's exhaustive-arm cost was paid in exactly the three places §3.3 predicts (`format.rs`, `bind.rs`, `tests/spans.rs`); every other walker is catch-all and a leaf needs nothing. Formatter layout is decided from `src` spans in `item_seq` (glued to the previous sibling's line when no newline separates them and the `;` carries no docs of its own; else its own line), so the AST carries no layout flag. `verify.rs` untouched, seven attack pairs added; corpus byte-identical at 813/820, measured against the pre-change binary. Ships with the `empty-item` lint (slang's `-Wempty-member`) and its safe fix — see §2.4. | | `formatter-bug-fixes (round 2) ──▶ safety-net` | depends | Three comment-shape bugs fixed in `format.rs` (`then_is_block` trailing-line-comment cuddle guard, `Fmt::header_parens`, `default_has_colon`); `verify.rs` untouched, four masked-corruption rejection pairs added per the standing template, plus three more for the directive capture at merge (2026-08-29 testbench wave, Lane B + lead). | | `lexer-cleanup ──▶ error-recovery / lint-rules-2` (QA logs) | depends | Fixes three lexer gaps: `@(* )` (TODO §1) plus the BOM and non-ASCII-honesty findings those two QA rounds filed; adds `ParsedSource::lex_error()` so `lucisv check` stops silently passing unlexable files. | | `error-recovery ─▶ lucisv-server / linter-core` | depends (downstream) | `parse_source_tolerant` is the entry point the whole LSP and the linter stand on; the strict/tolerant split (shared grammar, no second parser) is the contract. | | `name-spans ◀──▶ vlog-semantic` | handshake | vlog-semantic filed request 1 (spans on ~15 declaring nodes); name-spans delivered it, shrinking `scan.rs` to the `DataType` case (still open — §2.9). | | `spans ─▶ everything positional` | depends | Byte ranges + `LineIndex` are the prerequisite named by TODO §6 for the LSP effort and by fences/range formatting. | Also uniform in this lane: each new AST variant lists its exhaustive-match blast radius (formatter arm, `bind.rs` arm, `spans.rs` arm) — that checklist **is** the interface cost of touching `ast.rs`, and §3.3 restates it as a rule. `vlog_linter`'s `visit.rs` is catch-all **for compilation only**: a new variant that *contains items or statements* still needs an arm there, or no AST lint rule ever descends into it (dv-statements added two such arms; classes' missing one was a filed coverage gap, closed by lint-rules-2). ### 2.3 CLI lane A clean promise chain — each feature consumed the previous one's written promise: | edge | kind | contract | |---|---|---| | `config-discovery ──▶ cli-polish` | depends | Consumed `Options.stdin_filename` exactly as promised (discovery anchor only) and `Options.exclude` as the CLI layer config patterns append to. | | `parallel-files ◀──▶ cli-polish` | handshake | cli-polish flagged its hook-swapping `catch_panic` as single-thread-only; parallel-files replaced it with one startup hook + thread-local flag. **Anyone editing `catch_panic` must keep it that way.** | | `parallel-files ──▶ config-discovery` | depends | Consumed the promise that config resolution happens up front in `gather`, producing the exact `Vec<(PathBuf, Config)>` work list a `par_iter` wants. | | `format-cache ──▶ parallel-files` | depends | Consumed the promise that `process_file` is the per-file unit of work and `Outcome` the place a `Cached` bucket goes. | | `format-cache ──▶ config-discovery` | depends | Consumed the cache-key promise: key includes resolved per-file settings (values, not config-file identity). | | `format-cache ─▶ every output-changing feature` | standing promise | **Any change to formatter output must bump the workspace version** or warm caches keep stale verdicts. Same discipline as ruff/black. | | `cli-filelist ──▶ filelist` | depends | Reuses `lucisv_core::filelist::read` unchanged (M1 explicitly parked the `-f` flag for this round); drops `incdirs`/`defines` as meaningless to a non-preprocessing formatter. | | `cli-polish / linter-core ─▶ corpus-check, CI users` | standing promise | The 0/1/2 exit-code contract is frozen; new modes map onto it, never extend it. | | `lucisv-core-lift ◀──▶ lucisv-server` | handshake | Delivered the server's two filed requests (config discovery + ignore-aware walk) by lifting `config.rs`/`walk.rs` into `lucisv_core` unchanged; CLI behavior byte-identical. | ### 2.4 Linter lane | edge | kind | contract | |---|---|---| | `linter-core ──▶ error-recovery` | depends | Lints the tolerant tree so unparseable files are still linted for what is visible. | | `linter-core ──▶ format-fences` | depends | CLI `--fix` reads `fence` (already `pub`) to stay out of fenced regions — one answer to "what is fenced", not two (later formalized by shared-fence-filter). | | `lint-harness ──▶ linter-core` | depends | Consumes only the public API; the `.lint` case format + "marker naming a dead rule fails the suite" is the enforcement of rule-name stability on the test side. | | `lint-harness ──▶ safety-net` (via dev-dep) | depends | Every fix's output must be something `format_source` accepts. | | `lint-rules-2 ◀──▶ classes` | handshake | Closes the classes handshake: `visit.rs` now walks class bodies, so the four AST rules see class members. | | `semantic-lints ──▶ vlog-semantic` | depends | The three symbol-table rules; new (justified) crate dep `vlog_linter → vlog_semantic`; lazy analysis; the lead's pre-authorization to modify `vlog_semantic` went **unused** (recorded so it is not read as taken). | | `semantic-lints ──▶ one-parse` | depends | Reaches the server and CLI through the existing one-parse path (`LintContext::semantics()` / `with_semantics`). | | `server-lint ──▶ linter-core` | depends | Protocol wiring only; relies on the three written promises (stable names, no panics/writes, sorted findings). | | `null-items ──▶ linter-core / shared-fence-filter` | depends | The `empty-item` rule (2026-09-01) walks `ItemKind::Empty` through `visit::walk_items`; its safe fix deletes the `;`, the horizontal whitespace before it, and the line only when nothing but whitespace and other null items stood on it — a final guard refuses any range holding a byte other than `;`/whitespace, so a same-line comment structurally cannot be swallowed (invariant 3). Rule name is stable API from this release on. | | `server-lint ◀──▶ shared-fence-filter, one-parse` | handshake | Both of server-lint's filed requests were delivered by those rounds (fence-safe quick fixes; lint-from-Document). | ### 2.5 Semantics & index lane | edge | kind | contract | |---|---|---| | `vlog-semantic ──▶ error-recovery, spans` | depends | Tolerant trees as input; span conventions throughout. | | `workspace-index ──▶ vlog-semantic` | depends | Finishes `ExternalCandidate`s against what every file declares; the `paths` spelling contract is the coupling — if `bind.rs`/`resolve.rs` change a path's spelling, `workspace.rs::follow_one` changes with it. | | `workspace-index ──▶ define-table` | depends | Each file's `` `define`` table is an index column (`find_define`). | | `class-semantics ◀──▶ classes` | handshake | Delivers the filed gap; adds `SymbolKind::Class`, `ScopeKind::Class`, `InheritedCandidate` — with the two named compile-fix arms in `lucisv_server` (`tokens.rs`, `symbols.rs`). | | `class-semantics ──▶ name-spans` | depends | Built on the delivered span fields; keeps `src[name_span] == name` corpus-asserted. | | `overlay-promotion ◀──▶ type-definition` | handshake | Delivers type-definition's request 1: a **type-position** miss carries the bare name as its last candidate path (both miss spellings), so the overlay answers interfaces and package-less classes; type-definition then deleted its `indexed_type` fallback. Value-position misses unchanged — that asymmetry is the contract. | | `type-hierarchy ──▶ overlay-promotion` | depends | The whole cross-file half is overlay-promotion being consumed at the `extends` offset. | | `incremental-index ◀──▶ code-lens, hierarchy, type-hierarchy` | handshake | Delivers the jointly-filed edge tables: `instantiations_of` / `subclasses_of` recorded at build time; `callers_of_each` and `subtypes` became lookups (92 ms→0.26 ms, 82 ms→0.71 ms). Census policy carried over by construction: the walks (`instantiations.rs`, `classes.rs`) were **lifted into `vlog_semantic`**, not copied. | | `incremental-index ──▶ indexing-ux` | depends | Amends the event story: a one-file update reports no events (one parse is not a scan); invariant: `update_file` yields byte-for-byte the index a full rebuild would (`fingerprint` is the witness; `update_one_checked` the test form). | | `index-scope ◀──▶ indexing-ux` | handshake | Closes indexing-ux's QA finding by making `IndexBuilder` order-insensitive (sort/dedup in `finish`); `index_order` survives for the progress denominator. | | `index-scope ──▶ filelist` | depends | Rung 1 (a filelist defines the scope exactly) is untouched; rungs 2/3 of the scope ladder were re-written (folder-scoped, open-file-first) — the ladder itself is the contract, documented in both READMEs. | | `index-persistence ──▶ incremental-index` | depends | `update_one` writes its record through via `WorkspaceIndex::facts_for` (no double parse). | | `index-persistence ──▶ format-cache` (lucisv_core) | depends | Reuses `lucisv_core::cache::content_hash` — one FNV-1a shared with the format cache, not a second copy. Also one additive `vlog_parser` touch: `DefineTable::from_entries` + `PartialEq`/`Eq` derives, so a record restores a table without re-reading a file. | | `index-persistence ◀──▶ indexing-ux` | handshake | `IndexEvent::Cached` — a new variant, so every consumer is forced to say what it does with an unparsed file; the end message names the cached count. | | `port-detail-spans ◀──▶ index-persistence` | handshake | A declaration record grew two numbers (the detail span, written unconditionally as `0 0` for the `None` every ordinary declaration has), so **`FACTS_FORMAT` went 2 → 3** and every store written by an earlier build is discarded whole rather than read field-shifted. The bump *is* the contract: `index_cache.rs`'s header line carries the number, and the reader's `done()` check is a backstop, not a version scheme. | | `vscode-hierarchy-sidebar ◀──▶ index-persistence / hover-line-index / incremental-index` | handshake | **`FACTS_FORMAT` 4 → 5**, one bump for three additions: `Def::decl_span`; `InstantiationEdge::instances` (a `Vec` — the statement edge stays one-per-statement, so call hierarchy and code-lens counts are unchanged and the census is still the one `instantiations::sites` walk); and client positions — `DeclLines::positions: Option` on **file-scope declarations only**, plus `Utf16Range` on every instance occurrence. Members deliberately carry none: they outnumber units by two orders of magnitude, and the `U`/`M` groups are separate, so a member costs no field at all. `FileFacts::from_analysis` grew a `src: &str` parameter (a position cannot be read off a line table). Measured store cost of the positions: +1.69 % on the 820-file corpus, +1.86 % on opentitan. | | `vscode-hierarchy-sidebar ──▶ vlog_parser` | depends | `LineIndex::utf16_position` — byte offset to (0-based line, UTF-16 column), moved down beside the line table so the semantic index and `lucisv_server::convert::Positions` cannot answer differently. `Positions::position` is now a wrapper over it; the cross-crate equality is test-pinned. | | `vscode-hierarchy-sidebar ◀──▶ workspace-index` | handshake | `WorkspaceIndex::units_of(kind)` — file-scope declarations of one kind, in name order, walking the unit table alone. The cheap half of `workspace_symbols("")` for a caller that never wants members; 15 ms per snapshot on opentitan. | | `hover-line-index ──▶ port-detail-spans / index-persistence` | depends + handshake | `DeclLines { name, detail }` rides each indexed `Decl`, so ordinary and split-port hover headings do not reread a file just to compute a line. The record grew again and **`FACTS_FORMAT` went 3 → 4**; the server's bounded `FileView` cache supplies the text/`LineIndex` only when a snippet or a non-indexed position still needs it. Its four invalidation points are `set_document`, `close_document`, `update_one`, and a whole rebuild. | | `scan-interleave ◀──▶ workspace-index` | handshake | A scan is a stepped `Scan` value; staged `FileFacts` land through `WorkspaceIndex::absorb`, one whole-index merge per queue drain rather than per file. `Candidates::absorb` and `IncludeGraph::absorb` publish their tables in the same drain, so “the workspace as far as scanned” cannot mean three different prefixes. | | `scan-interleave ──▶ hover-line-index` | depends | Delivers hover-line-index's measured startup-wait request: a startup scan above 64 files drains queued messages between files. A rescan deliberately still holds requests; what an answer sees never depends on elapsed wall time. | | `index-scope ──▶ scan-interleave` | depends | A scope widen is the second `Scan` shape (`begin_widen`) and shares `scan_step`/`finish_scan`; it folds only newly reached folders plus open-buffer analyses, never masquerades as a whole scan, and never interleaves. Folder scope now ships at depth 2; rootless sessions do not climb an unnamed tree. | | `index-scope ──▶ one-parse / completion-core` | depends | Whole scans and widens reuse each open `Document`'s existing `FileFacts` and completion words rather than reparse its text. `IndexEvent::Analyzed` keeps this distinct from a persistent-cache hit. | | `class-member-access ◀──▶ workspace-index / index-persistence / vlog-semantic` | handshake | **`FACTS_FORMAT` 5 → 6** (2026-09-01): the field layout is unchanged but the reference census grew — `head.member` tails (`Target::MemberOf`, resolved head → `Symbol::type_name` → class scope → member, in-file `extends` chase) and names inside out-of-class method bodies (a stand-in `Class` scope carrying the class path as `extends`) are references now, so older stores must be discarded whole. `WorkspaceIndex::base_of` is a subclass → base map rebuilt in `merge` from the existing inheritance census (no new facts field); the cross-file chase lives in `follow_one` so hover, references and rename cannot disagree about what a tail names. `Symbol::type_name` is the declared type as written, deliberately absent on unpacked declarators (`c1 q[$]`) so `q.size()` never resolves against `c1`. `resolve` returns `Option`: a tail with nothing to say records no reference (not `NotFound`), keeping `a_hierarchical_name_resolves_only_its_head` and the unresolved count byte-stable. | | `class-member-access (round 2) ◀──▶ workspace-index / index-persistence / refactor-rename` | handshake | **`FACTS_FORMAT` 6 → 7** (2026-09-01): `Def::type_name` / `Decl::type_name` (the same capture rule as `Symbol::type_name`, now in `fingerprint`) and `ReferenceFact::External.base` (so `this.x`/`super.x` inherited uses post cross-file). Chains `a.b.c`: `Target::MemberOf { head, mids }` carries *spellings*, so the outer tail never depends on the inner's result — in-file `member_of` hops declared type → declared type; a chain leaving the file is ONE composed path `Unit::mid::tail` that `follow_one` walks via `member_type`, refusing a hop through a type name the workspace declares twice with different kinds. Instance heads: an instance symbol's `type_name` is its module; **modules export ports and parameters only** (lead ruling on measurement: nets/vars export cost +24 % store AND made `.port(w)` connections resolve to internal nets) — so `u.port` resolves cross-file, `u.internal` in-file only. Typedef-alias chase in `type_here`, file-scope typedefs cross-file. **Rename truth flipped**: `u_sub.sig` is sub's `wire sig` and is edited (`a_hierarchical_tail_that_resolves_is_renamed_with_its_declaration`); an unresolvable tail is left alone but no longer warned about — §2.9-20. | | `define-table ◀──▶ macro-expansion` | handshake | What began as free-to-change became contract at M14: params stored **as written**, `NAME()` = `Some(vec![])` — `expand.rs` counts arguments against them and declines on mismatch. | ### 2.6 Refactor lane (the M-plan) `refactor` is the umbrella plan; M1–M4 are its milestones plus two follow-ups. | edge | kind | contract | |---|---|---| | `filelist (M1) ──▶ refactor` | depends | The scope story: a `.f` filelist is the project file; parser in `lucisv_core` (so the CLI later reuses it — it did, cli-filelist), scope ladder in the server. | | `refactor-rename (M2) ──▶ vlog-semantic / workspace-index` | depends | Every edit from a resolved span; whole-edit verification; refusals from `Resolution` variants. | | `refactor-rename ◀──▶ vlog_semantic` | handshake | The one authorized cross-module change of M2: `Target::Declaration` + `use_end_label` (end labels must rename or the output doesn't compile). Strictly additive; logged in vlog-semantic's work log. | | `refactor-ports (M3) ──▶ refactor-rename` | depends | Reuses M2's `check`/`Scope`; the two preprocessor scans were factored to return *sites* so M3 words its own warnings without inheriting M2's text (M2's wording pinned by its 48 tests). | | `refactor-ports ◀──▶ incremental-index / lucisv_server` | handshake | `port_action_modules` and `enclosing_module` name the engine's possible module targets; `Workspace::module_sources` expands them through module declarations, `instantiations_of`, reference postings and open buffers. Code actions and all three commands use the same builder, and parity tests assert the narrowed result equals the old whole-scope result. The instantiation census in `vlog_semantic::instantiations` and `ports::collect_instantiations` must grow together. | | `refactor-instantiate (M4) ──▶ workspace-index, editor-scopes` | depends | Plans from the index's real definitions; the item-position gate is built on `pairs::analyze`'s published output only. | | `apply-edit ──▶ refactor-ports` | depends | The port commands now *push* `workspace/applyEdit` (the protocol's actual mechanism) instead of answering the edit as a result no client applies. `ports::execute`'s signature and behavior unchanged — the only `ports.rs` edit was correcting a now-false doc comment, so this is consumption, not a handshake. | | `references-nav ──▶ refactor-rename` | depends | `find_references` is `Scope::collect_occurrences` lifted out of `collect_edits` — the references list and a rename's touch-set **cannot disagree**, by construction (deliberately not moved to `vlog_semantic`; the walk needs refactor-crate concerns). | | `refactor-rename ◀──▶ workspace-index / lucisv_server` | handshake | `prepareRename` answers from the open `Document` plus index through `prepare_rename_here`; `rename` asks `rename_name_at` for the engine's target and feeds only `Workspace::rename_sources`'s six-rung superset. The rungs cover declarations/members, resolved postings, instantiation edges, macro definitions, every open buffer, and `files_spelling` for unresolved new-name uses; if a rung cannot bound a case it falls back to all sources. Refusal sentences and whole-scope parity are pinned. Open residue: macro-invocation-argument warnings need §2.9-18. | | `file-operations ◀──▶ include-nav / lucisv_server` | handshake | `IncludeGraph::includers` exposes the files that can contain a resolving include; `Workspace::include_sources` overlays open buffers and reads only that set for `willRenameFiles`, instead of the workspace. It is sound only while the graph's held-edge census and `resolve` agree. | ### 2.7 LSP server lane `lucisv-server` is the trunk; everything below extends it. Edges to engine-lane features are listed above; this table is the server-internal web. | edge | kind | contract | |---|---|---| | `editor-scopes ─▶ (many)` | depends (consumed by) | `pairs.rs` — one stack matcher, eight consumers today: documentHighlight, missing-closer diagnostics, `lucisv/scopePairs` rainbow, folding (references-nav), the item-position gates (completion-core / refactor-instantiate), on-type-formatting's keyword tables, inline-templates' unmatched-`begin` check, expand-selection (`selection.rs`). The `RULES` table + guard list is the shared truth; a keyword change means re-checking it. | | `editor-scopes ◀──▶ editors/vscode` | handshake | The `lucisv/scopePairs` wire shape (pinned as literal JSON in a test) and the `lucisv.rainbow*` colour ids that must match between `package.json` and `extension.js`. | | `completion-core ──▶ define-table, vlog-semantic, workspace-index, refactor-instantiate` | depends | Five tiers over existing facts; the parser widening (`KEYWORDS` export) is its one engine touch. Deliberate duplication recorded: `visible_symbols` vs `ports::visible_in` share an idea, not code. Since the performance wave, tier 0 reads module names from `Candidates::modules` (built once with the index); equality with `vlog_refactor::module_names` is test-pinned. Since 2026-08-30 tier 0 is names-only — no file read, no plan — and the guarded header-slice planning (`module_header`/`plan_for`) serves only `inline.rs`'s exact-match ghost (see the inline-instantiation handshake). | | `fuzzy-completion ◀──▶ completion-core` | handshake | The matching rule (2026-08-30, owner policy = VS Code's own): below `FUZZY_MIN = 3` typed characters every tier matches by prefix, byte-for-byte the old behavior; from 3 up the scope, index-name and word tiers match by case-insensitive **subsequence**, ranked prefix-first then score (`Score`/`rank_cmp`), served top-K under the same `LIMIT`. `Candidates` carries parallel 32-bit char-mask tables (`unit_masks`/`word_masks`, written in exactly two places — `take_index_tables`, `remask_words` — so table and mask cannot desync) and `Query`/`units_fuzzy`/`words_fuzzy`. **Wire contract:** every response below the floor is `isIncomplete: true` — a complete 2-char answer would be client-filtered and the 3rd keystroke (the one that turns fuzzy on) would never reach the server; above the floor incompleteness follows truncation, sound because appending characters only shrinks a subsequence hit set. Module (substring), keyword, template and macro tiers unchanged; `inline.rs`'s `has_module` ghost probe stays exact and case-sensitive — fuzzy must never leak into it. | | `completion-templates ──▶ completion-core, editor-scopes` | depends | Tier 3; `templates.rs` is data + one renderer; tier digits moved (only e2e's word-tier assertion cared). Also consumes `vlog_refactor::Layout` (M4's `{ base, step }`), reused rather than re-declared, so a skeleton and a template indent by one type. | | `completion-templates ◀──▶ editor-snippets` | handshake | Nine overlapping statement/block snippets were **removed** from `editors/vscode/snippets/*.json` when the server started offering them as tier 3; both READMEs' prefix tables are the shared truth. A template added server-side must check the static set, and vice versa. | | `inlay-hints ──▶ refactor-instantiate` | depends | Reads exactly the `module_definition` + `instantiation_plan` facts M4 published (the `PlanPort`/`PlanParam` name lists signature help reads); every plan refusal is swallowed silently — a hint has no place for a sentence. | | `inline-templates ──▶ completion-templates, editor-scopes` | depends | Same skeletons as ghost text (LSP 3.18 `inlineCompletion`, `lsp-types` `proposed` feature); relative-indent contract — the client finishes the whitespace; round 2 dropped its `layout_at` consumption (re-privatized). | | `inline-instantiation ◀──▶ completion-core` | handshake | The two-level split (2026-08-30, owner ruling): tier 0's items are module **names**, not skeletons — the M4 "popup inserts the whole instantiation" pin is superseded, `completion::item`/`documentation` deleted. Three surfaces made `pub(crate)` for `inline.rs`: `at_instantiation_site` (tier 0's position gate, lifted so ghost and popup answer "may an instantiation go here" identically), `plan_for` and `snippet_hole` (one planner, one tabstop spelling). `Candidates::has_module` — case-**sensitive** `O(log n)` binary search over the module table — is the ghost's per-keystroke probe; it pins the table's `str` order (inherited from `workspace_symbols`'s sort) with its own test, so a case-folded sort upstream breaks loudly. | | `inline-instantiation ──▶ refactor-instantiate` | depends | `instantiation_plan` → `render_with` consumed unchanged for exactly one module per space-armed exact-name match, read through the `FileView` cache. Round 2 (2026-08-30): the file is chosen by `completion::nearest_definition` — most shared leading path components with the asking buffer, then shallowest candidate, then lexicographic — never refusing on multiplicity; `vlog_refactor::module_definition` is no longer on this path (unchanged for its own callers, which want its ambiguity refusal). A plan with an escaped identifier is *declined* (ghost text has no plain-text spelling to fall back to); `InstantiationPlan::render`'s plain spelling now has no server consumer at all. Signature help and inlay hints unchanged. | | `inline-instantiation ──▶ inline-templates` | depends | `inline_completions` probes the space-armed Ident shape (`name_then_space`: exactly one space before the cursor, the `Ident` ending just before it — owner ruling, round 2) ahead of the trigger table's token-ends-at-cursor route, which is byte-for-byte unchanged; an `Ident` ending exactly at the cursor now offers nothing at all. Wire shape, empty range at the cursor and the relative-`\t` indentation contract inherited unchanged. `lucisv.inlineInstantiation` (unset = on) is its own setting, independent of `lucisv.inlineTemplates`, same non-scope-change shape. | | `hover/define ──▶ define-table`; `macro-expansion ──▶ define-table + hover` | depends | See the §2.5 handshake; `expand.rs` is deliberately workspace-blind (two strings + a `Define`). | | `include-nav ──▶ filelist` | depends | First consumer of `incdirs`; the include graph (build/resolve/reachable, one `scan` shared by links, definition and the graph) plus hover's reachability overlay — `find_define`'s contract explicitly unchanged. | | `file-operations ──▶ include-nav, file-watching` | depends | `resolve_as_if` added so willRename asks the *one* resolution engine about a future filesystem; reuses `watch::watched` + `SOURCE_GLOB` as the one scope predicate. | | `file-watching ──▶ filelist / lucisv-core-lift` | depends | `SOURCE_GLOB` pinned to `walk::EXTENSIONS` by test; watches the filelist itself; re-registers on filelist change. | | `folders-and-config ──▶ editor-settings` | depends | Adds the pull door (`workspace/configuration`) wrapped back into the push shape so there is exactly one settings parser; `Pending` generalizes apply-edit's `applying` map. | | `editor-settings ◀──▶ lucisv-core-lift` | handshake | The four-rung precedence ladder (lucisv.toml > `lucisv.*` settings > tab size > defaults), per key — the reason the ladder can exist is the lifted `Discovery`. `will-save-wait-until` reuses the ladder minus rung 3. | | `incremental-sync ◀──▶ pull-diagnostics` | handshake | One `didChange` = one `set_document` = one generation bump, however many ranges — pinned by test; the generation **is** the pull model's `resultId`. `semantic-tokens-delta` promises the inverse: token requests never bump it. **Amended 2026-08-28 by change-debounce**: one *flush* is one `set_document`, one bump and one publish per dirty buffer — however many ranges *and* however many notifications it coalesced. | | `change-debounce ◀──▶ incremental-sync, pull-diagnostics` | handshake | The amendment above. A `didChange` composes its ranges against the *pending* text when there is one (`sync::apply_changes` unchanged) and defers only the analysis; the flush happens at the next request, the next non-`didChange` notification, or a 150 ms quiet period on the `cancel-request` queue (`recv_timeout` — no thread, no timer object). Observable: intermediate diagnostics states are no longer published, pinned in `tests/e2e.rs`. | | `port-detail-spans ──▶ hover-declarations` | depends | The second fenced section, and the comment attached to each, are built on hover-declarations' snippet machinery and its `spells_exactly` guard, both unchanged. `nav::definition` returns the detail location first so a jump and the card cannot disagree. | | `hover-declarations ◀──▶ vlog_semantic` | handshake | `Semantics::symbols_named` (§1.2) replaced `hover::live_symbol`'s and `nav::indexed_references`' scan-every-symbol loops. Behavior-identical **because the lookup preserves declaration order** — the tie-break between two live declarations of one name is pinned on both sides. | | `hover-line-index ──▶ hover-declarations / port-detail-spans` | depends | `Def::lines` supplies indexed hover headings (including split-port detail lines); `Workspace::file_view` supplies the guarded snippet and the few non-indexed line lookups. `locate::location` shares that view, so a references list reads a closed file once rather than once per site. | | `cancel-request ──▶ lsp-server pin` | depends | See §1.2; queue/burst exists because the pinned transport is a rendezvous channel. | | `scan-interleave ──▶ cancel-request / work-done-progress` | depends | The same queue is polled between startup-scan files. `publish_scan` lands the index, completion and include batches before dispatch; `must_wait` holds requests queued behind any rescan-triggering message and preserves their order/cancels. Progress still counts the whole scan even when requests are answered before the bar comes down. | | `verbose-timing ◀──▶ editor-packaging / scan-interleave / change-debounce` | handshake | `lucisv.verbose` is an extension-owned spawn setting: false means no arguments and no timing traffic; true means `lucisv-server --verbose`, and changing it restarts the client process. The server writes `MessageType::LOG` lines prefixed `timing:` for request/notification handlers, scan and widen lifecycles, dirty-buffer flushes, one-file reindexes, and requests held behind rescans. The request line precedes its response; notification lines follow their work. Instrumentation is silent by construction when off (one branch, no clock read or formatting), and it observes rather than changes scan/queue ordering. | | `work-done-progress ──▶ indexing-ux` | depends (then) | w-d-p put up the bar; indexing-ux made it count (`IndexEvent` stream); index-persistence added `Cached`. | | `large-file-mode ◀──▶ semantic-tokens-delta` | handshake | The windowed lexing serves `semanticTokens/range`; on a large buffer `full`/`full/delta` must answer an ERROR (`ServerCancelled`/`ContentModified`) or the client stops asking the range provider — two sides pinning one wire behavior. `Document::large` is structurally a full `Document` (all fields valid, empty) so no handler changes — the obligation lands on **future** handlers that read `doc.text` (dispatch-table test enforces). | | `lsp-318-extras ──▶ range-formatting` | depends | `rangesFormatting` is a thin adapter over the same n-range `LineRanges` engine `--lines` uses; hand-rolled params because `lsp-types` 0.97 lacks 3.18. | | `on-type-formatting ──▶ range-formatting, editor-scopes` | depends | `;` goes through `format::range_formatting` unchanged; `\n` answers indent only, computed from `pairs.rs`'s own keyword tables (three items widened to `pub(crate)`) — one reader's answer for "what opens a scope". | | `interactive-latency ──▶ change-debounce, editor-scopes, selection-range, on-type-formatting, completion-core, inline-templates` | depends | Round 2 of the perf work (`docs/perf/README.md`). It measures the flush change-debounce coalesces and the round trip it defers, and it replaces one token *sweep* with one token *binary search* in `selection.rs`, `on_type.rs`, `completion.rs` and `inline.rs`. No answer moved — each swap is pinned against the sweep it replaced at every byte — so none of those five features' contracts changed; what they now share is `state.rs`'s two search primitives and the ordering property of `tokenize`'s output they rest on. | | `interactive-latency ◀──▶ lucisv-server` | handshake | Two free functions, `first_token_reaching` and `first_token_from`, are published from `state.rs` beside `Document::token_at`; that is where the monotonicity argument every caller depends on is written down, and `state::tests::the_token_stream_rises_and_never_overlaps` is the test that fails first if `vlog_parser` ever breaks it. `tests/e2e.rs`'s `Live::finish` now returns its publish count (existing callers ignore it), and `perf::generated_module` has a copy in `tests/e2e.rs` — a binary crate's modules are unreachable from an integration test — which must stay the same shape as the original. | | `references-nav ──▶ workspace-index / hover-line-index` | depends | Cross-file references resolve an indexed target first and consume declaration postings directly; same-file local references stay on `Semantics`. Locations use the shared `FileView`. `documentHighlight` now also follows the document's external overlay for names declared elsewhere, fixing the old “references works, highlight is empty” split without widening highlights beyond the current file. | | `selection-range / linked-editing ──▶ spans, name-spans` | depends | Pure arrangements of existing ranges; linked-editing's table documents exactly which constructs carry both spans (and which verbatim ones can't — `program`, property/sequence, covergroup). | | `type-definition ──▶ nav / overlay-promotion / ansi-first-port` | depends + 2 delivered handshakes | Now literally `nav::definition` at the type name's offset; both of its filed requests landed (§2.2, §2.5). | | `hierarchy ◀──▶ inlay-hints` | handshake (shared walk) | The instantiation walk was lifted out of `inlay.rs` into a shared module (now `vlog_semantic::instantiations`) rather than copied — the two answers cannot drift; inlay's 34 tests are the regression net. | | `vscode-hierarchy-sidebar ◀──▶ editors/vscode` | handshake | Two custom wire members, both **gated on `initializationOptions.hierarchyView`** so no other LSP client sees them: the request `lucisv/moduleHierarchy` → a flat `schemaVersion: 2` snapshot (`files` table; locations as `{ file, range, selectionRange }` with each range `[startLine, startCharacter, endLine, endCharacter]`; **no** per-row id and **no** per-instance `definitions` — the client composes both in `hierarchyModel.js::validateSnapshot`), and the notification `lucisv/moduleHierarchyChanged { revision }`. `revision` rises on every completed index install; the notification rides beside the code-lens refresh point so all mutation paths are covered once. An older binary answers `-32601`, which the view renders as a compatibility message. | | `vscode-hierarchy-sidebar ◀──▶ code-lens / hierarchy` | handshake | Both read the *same* statement-level `InstantiationEdge`; only the sidebar flattens `edge.instances`, so `sub u1 (), u2 ();` is still one call site and one lens count and two sidebar rows. No second census exists. | | `vscode-hierarchy-sidebar ──▶ scan-interleave / cancel-request` | depends | `complete` is `Server::index_is_complete()` = `!scanning && !must_wait()`. It is false exactly during the startup scan: a request owed a rescan is *held* by `must_wait`, and `rescan_wanted` is only ever set while `scanning` is true, so no snapshot is ever answered `complete` off an index a queued message is about to rebuild. | | `code-lens ◀──▶ hierarchy` | handshake | code-lens split `incoming` into the batch primitive `callers_of_each` so lens and hierarchy share one census; `incoming` is a one-element call into it and its behavior (empty-name guard included) is pinned unchanged. Lens and hierarchy views can never disagree; refresh rides `reindex()` after the bar comes down. | | `server-lint / pull-diagnostics / editor-scopes ──▶ diagnostics.rs` | depends | One `diagnostics::all` composition: parse errors + missing-closer warnings + lint warnings, one publish (or one pull) per change; `send_diagnostics` is the single push gate so a pulling client is never served both models. | ### 2.8 Packaging & release lane | edge | kind | contract | |---|---|---| | `editor-packaging ◀──▶ lucisv-server` | handshake | The spawn contract (§1.2), including verbose-timing's `[]` / `['--verbose']` argument pair and restart-on-setting-change rule, plus the fence-tag contract: every markdown code block the server emits opens ```` ```systemverilog ```` — three call sites pin the string; the grammar registers the id. | | `editor-packaging ◀──▶ vlog_parser` | handshake | The grammar↔`KEYWORDS` test lock (§1.2). | | `editor-snippets ──▶ editor-packaging` | depends | Static `contributes.snippets` keyed to the two language ids the manifest declares; consumes nothing from the server *at runtime* (works with the server missing — deliberate). Its **content** is negotiated against the server's template tier — see the `completion-templates ◀──▶ editor-snippets` handshake in §2.7. | | `editor-platform-vsix ──▶ editor-packaging, release-prep` | depends | Changes *which path* is spawned, never how; consumes `release.sh`'s artifact naming; promises the three `bin/` layout shapes to `extension.js` (asserted with `unzip -Z1` per package). | | `editor-platform-vsix ◀──▶ editor-marketplace-page` | handshake | The marketplace rewrite must keep the seven-package install table and the two bundled-binary layout sentences (re-applied additively during the concurrent rounds). | | `ci-release ──▶ release-prep / editor-platform-vsix` | depends | Workflow = one-liners over `tools/`; consumes the exact seven `.vsix` names (`prune_release_assets.sh` checks each), the `CHANGELOG.md` heading convention, tag == workspace version. | | `release-prep ──▶ editor-packaging` | depends | `release.sh` runs `smoke.js` as its gate; closed the missing-`LICENSE` item editor-packaging filed. Version lives in exactly four files — a promise to everyone. | | `editor-marketplace-page ──▶ lucisv-server` (docs) | depends | The Details page mirrors the shipped capability table in the server's README; drifts if that table does. | ### 2.9 Open handshakes (filed, not yet delivered — claim before working) These are the known coordination points. An agent picking one up should update the filing README(s) and this file. | # | request | filed by | owner it waits on | |---|---|---|---| | 1 | `lucisv_core::path::normalize` — one `.`/`..` folding instead of three private copies (`filelist::Reader::normalize`, `config::Discovery::absolute`, `includes::normalize`, the last now `pub`) | include-nav; restated by file-operations | lucisv_core | | 2 | A span for `DataType` (and `ExprKind::Cast::ty` tails) — the last thing keeping `vlog_semantic/src/scan.rs` alive | vlog-semantic (item 2); restated by class-semantics | vlog_parser | | 3 | `fence::scan_nested` has no `ItemKind::Class` arm — formatter fences are inert inside class bodies (the `--fix` backstop still holds; asymmetry errs hands-off) | classes | vlog_formatter (fence.rs) | | 4 | A `lint` key in `lucisv.toml` (`[lint.]` config; selected-rules list) with CLI>config precedence | linter-core; restated by lint-rules-2, semantic-lints, server-lint | config-discovery / lucisv_core | | 5 | `lucisv check --rules-doc` printing `rules_markdown()` | lint-rules-2 | crates/lucisv | | 6 | Workspace-wide "does any file mention this name" query — the precondition for the semantic lints defaulting on (cross-file hierarchical use is their one false-positive mode) | semantic-lints | vlog_semantic (index) | | 7 | `SymbolKind::Interface` (interfaces currently indexed as `Module`; modport/clocking names unbound) | interfaces | vlog_semantic (+ mechanical arms in server `symbols.rs`/`hover.rs`) | | 8 | Symlink-cycle detection in the shared walk (both front ends exposed; wants its own round — it changes CLI behavior) | lucisv-core-lift | lucisv_core | | ~~9~~ | ~~Chasing `InheritedCandidate` through the member tables (in-file and cross-file) + hover for `extends`~~ — **delivered 2026-09-01 by class-member-access**: `resolve::member_in_chain` walks the in-file `extends` chain, `WorkspaceIndex::base_of` + `member_chain` walk it across files (inside `follow_one`, so hover and cross-file references agree), both cycle-guarded; `this.x`/`super.x` misses ride the same loop. `extends` hover/definition on the base name was already answered by overlay-promotion's type-position promotion. Residue filed in TODO §15 round 2: a `base` field on `ReferenceFact` so `this.x` misses get index postings too | class-semantics | ~~vlog_semantic~~ done | | ~~10~~ | ~~`Fmt::raw_text`'s string-crossing path emits a `Doc::Text` carrying newlines~~ — **delivered 2026-08-26 (`53f2269`)**: both `raw_text` and the parameterized-type `#( … )` now emit `Doc::Inline`, whose printer arm resumes measuring from the text's own last line. directive-split's README (QA round 3 note) still documents it as open and should be struck there too | directive-split QA | ~~vlog_formatter~~ done | | 11 | Corpus scripts match `parse error:` / `lex error:` / `verification failed:` textually; a structured `--output-format json` for format mode would remove it | corpus-check | crates/lucisv | | 12 | `vlog_refactor::rename::Scope::build` re-derives sort-and-dedup by hand; could call `index_order` | indexing-ux | vlog_refactor | | 13 | Anonymous-aggregate members (`enum {A,B} x;`) not declared as symbols — hover/definition gap | types-decls | vlog_semantic | | 14 | A `program` node with `name_span`/`end_label_span` (today it lands in `Error`/verbatim), which would let linked-editing serve it with one arm | linked-editing | vlog_parser | | 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) | bind | 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) | 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 | refactor-instantiate (gap 1; its gap 2 was delivered by ansi-first-port) | vlog_parser | | 18 | A macro-invocation census in `FileFacts`: per-file macro names plus identifier-shaped words in their arguments. Rename's index-bounded fan-out currently preserves every edit/refusal but can lose informational macro-argument warnings in files that have no other relationship to the renamed name; the same table would serve the port refactorings' identical scan. This changes the record shape and therefore requires a `FACTS_FORMAT` bump. | refactor-rename (performance-wave residue, accepted and filed) | vlog_semantic | | 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). | inline-instantiation (lead) | lucisv_server | | 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. | class-member-access round 2 (lead) | vlog_refactor (`rename.rs`) | --- ## 3. Combined graph — features mapped onto modules ### 3.1 Feature → primary-home matrix Where a feature's code chiefly lives (its README remains the authority on exact file scope). Cross-module touches are recorded per-feature in §2 and in each feature README's Handshakes; this matrix names only the primary home. Grammar-lane features (*italicized*) routinely add exhaustive-match arms in other crates — see §3.3's `ast.rs` row — though not always a formatter arm: directive-split and ansi-first-port shipped with `vlog_formatter/src` untouched, reusing existing arms. | module | features whose home it is | |---|---| | `vlog_parser` | spans, name-spans, recursion-limit, error-recovery, define-table, lexer-cleanup, 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* (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 | | `vlog_semantic` | vlog-semantic (`bind`/`resolve`/`model`), workspace-index (`workspace.rs`), class-semantics, overlay-promotion, port-detail-spans (`Symbol`/`Def::detail_span` and `Semantics::symbols_named`), hover-line-index (`DeclLines`, facts codec + `FACTS_FORMAT` 4), scan-interleave (`WorkspaceIndex::absorb`), 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`; 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`), 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) | | `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), and one or two modules per capability feature: editor-scopes→`pairs.rs`, filelist→scope ladder in `state.rs`, include-nav→`includes.rs`, completion-core→`completion.rs`/`candidates.rs`, completion-templates→`templates.rs`, inline-templates→`inline.rs`, inline-instantiation→`inline.rs`+`completion.rs`+`candidates.rs` (+`settings.rs` key), fuzzy-completion→`candidates.rs`+`completion.rs`, macro-expansion→`expand.rs`, hierarchy→`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.rs`, 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.rs`, semantic-tokens-delta→`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`, 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→`server.rs`+`state.rs`+`candidates.rs`+`includes.rs`, change-debounce→`server.rs`, verbose-timing→`main.rs`+`server.rs`+`tests/e2e.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.rs`/`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), 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`) | ### 3.2 The combined picture ```mermaid graph TD subgraph parser [vlog_parser] gram[grammar-lane features] --- pinfra[spans / name-spans / recursion-limit / error-recovery / define-table] end subgraph fmt [vlog_formatter] net[safety-net verify.rs] --- fmtf[fences / range / alignment / comment rounds] end subgraph sem [vlog_semantic] core[vlog-semantic] --- idx[workspace-index + incremental / persistence / scope / ux] end subgraph lint [vlog_linter] lc[linter-core + rules + harness + semantic-lints] end subgraph refac [vlog_refactor] ms[M2 rename / M3 ports / M4 instantiate / references] end subgraph corelib [lucisv_core] cw[config + walk + filelist + cache] end subgraph cli [lucisv CLI] clif[cli lane features] end subgraph srv [lucisv_server] caps[capability features (~30)] end subgraph ed [editors/vscode + tools/CI] pkg[packaging lane] end gram --> fmt fmt --> parser sem --> parser lint --> parser lint --> sem refac --> parser refac --> sem srv --> parser cli --> parser cli --> corelib cli --> fmt cli --> lint srv --> corelib srv --> sem srv --> refac srv --> fmt srv --> lint pkg --> srv pkg --> cli ``` Reading it feature-side: a grammar feature is by default a **parser+formatter pair** (new AST + its layout, plus minimal arms in `bind.rs`/`spans.rs`) — though one that reuses an existing arm ships with the formatter untouched (directive-split, ansi-first-port); an index feature is a **vlog_semantic + lucisv_server pair** (the data structure and the events/settings around it); a capability feature is usually **server-only plus one manifest line** (one handler module + `main.rs` capability + often a `settings.rs` field, which then owes an `editors/vscode/package.json` `contributes.configuration` entry — the choke point whose mismatches are silent); a packaging feature is **editors/tools-only, save for the two pins it owns in Rust** (editor-packaging's `tests/grammar.rs`, release-prep's `--version` shape). Those shapes are the default that makes the lanes parallel-safe — not an invariant; say in your scope which arms you actually owe. ### 3.3 Choke points — files where features meet These are the highest-contention interfaces. When two agents' scopes both name one of these, they are not parallel — serialize or split the file's ownership explicitly. | choke point | owner (feature) | consumers | the rule | |---|---|---|---| | `vlog_parser/src/ast.rs` | the grammar lane collectively | formatter, semantic, linter, refactor, server, `tests/spans.rs` | A new variant costs, at minimum: a `format.rs` arm, a `bind.rs` arm, a `spans.rs` arm. `visit.rs` is catch-all for compilation only — a variant containing items/statements still needs an arm there or AST lint rules never see inside it. Prefer **additive fields / parallel vectors** over changing vector element types — that is why `ListDirective` sits beside the lists instead of inside them (two rounds chose it independently for blast-radius reasons). | | `vlog_formatter/src/verify.rs` | safety-net | every formatter feature; the CLI's exit-2 promise | CLAUDE.md invariant #4. Never widen a normalization without masked-corruption attack tests; the standing pattern is "untouched + rejection tests anyway". The single widening in history is macro-items' backtick-`Ident` arm in `normalize` — which produced lucisv's one real corruption; its repair, `trim_lines_outside_strings`, is a *narrowing*, and the pattern to copy: the widening shipped without attack tests, the fix shipped with them. `line_starts_inside_string` is the one definition of "which line breaks are data" — both `format.rs` and `verify.rs` must read it. | | `vlog_formatter/src/fence.rs` | format-fences | range-formatting, shared-fence-filter, CLI `--fix` (`lucisv/src/lint.rs`), server quick fixes (`lucisv_server/src/lint.rs`) | `protected_regions`/`is_protected` are the **only** supported way to ask "may an automatic edit touch these bytes". One answer, **two** front ends — and `vlog_linter` is deliberately not one of them (it stays fence-blind; the filter lives in each front end). Open gap: no `Class` arm in `scan_nested` (§2.9-3). | | `lucisv_server/src/pairs.rs` | editor-scopes | documentHighlight, missing-closer diagnostics, scopePairs rainbow, folding, completion gates, on-type indent, inline-templates, expand-selection (`selection.rs`) | The `RULES` table + no-closer guard list is shared truth. Any keyword added to/removed from `token.rs` requires re-checking it (a word that stops being a keyword silently stops being matched). | | `lucisv_server/src/server.rs` | 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 and always reads its own directory flat) 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.rs` (+ `facts.rs`) | workspace-index; extended by incremental-index, index-persistence, index-scope, hover-line-index, scan-interleave, refactor-rename performance | server state, hierarchy/lens/type-hierarchy, refactor, completion | Determinism (same inputs → same index, any order), the `paths` spelling coupling with `resolve.rs`, `FACTS_FORMAT` bumped on any codec change (currently 4), 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. | | `vlog_refactor/src/rename.rs` | 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. | | `tools/release.sh` artifact names | release-prep / editor-platform-vsix | ci-release (`prune_release_assets.sh`), `audit_artifacts.sh`, extension `bin/` layouts | Renaming a `.vsix` is a two-file change (`release.sh` + `prune_release_assets.sh`'s suffix list); renaming a per-triple binary is a two-file change (`release.sh` + `audit_artifacts.sh`, which skips `.vsix` and hard-fails on an unknown binary name). Get the wrong pair and the release fails by name. | | The frozen CLI contract | cli-polish | corpus scripts, CI users, every new CLI mode | Exit codes 0/1/2 forever; stdout stays machine-readable (JSON mode prints exactly one array; warnings to stderr). | ### 3.4 Working rules distilled for parallel agents 1. **Pick lanes, not files.** The eight lanes in §2 are the intended parallelism. Two features in one lane usually share a choke point (§3.3); check before spawning both. 2. **A grammar feature is a pair by default** (parser + formatter arms + minimal `bind.rs`/`spans.rs` arms) — unless it reuses an existing arm, as the verbatim producers and ansi-first-port did. Say which arms you owe in the feature scope up front; the compile-fix arms in other crates are legitimate and should be listed in Handshakes, per the established pattern. 3. **`cargo fmt` per package** (`-p a -p b`), never `--all`, while another agent is live — this rule already saved two concurrent rounds (directives-in-lists, dynamic-types). 4. **Cross-module wants are filed, not done.** Write the request in your README's Handshakes, add it to §2.9 here, and stop — the lead routes it. Delivered requests get struck through in the filing README with a pointer (the ~~strikethrough~~ + "Delivered by X" convention is established). 5. **Wire shapes and names are pinned by tests, so change them by test**: scopePairs JSON, the systemverilog fence tag, the seven `.vsix` names, the grammar/KEYWORDS lock, rule names, exit codes, message prefixes (§2.9-11 until structured output lands). 6. **Anything touching formatter output**: attack tests for any verify-adjacent machinery, and a version bump or the format cache serves stale verdicts (§2.3). --- *Maintenance: this file is derived documentation. When a feature round adds, delivers, or supersedes a handshake, update the relevant table (§2.9 especially) in the same round, the way TODO.md checkboxes are kept current.*