Compare commits

...
2 Commits
Author SHA1 Message Date
Guoliang ChenandClaude Mythos 5.2 3823b85667 Release 0.66.1: sticky scroll pins the module instance
ci / checks (push) Successful in 57s
ci / corpus (push) Successful in 14s
ci / linux (push) Successful in 4m56s
release / build-and-publish (push) Successful in 5m17s
A multi-line module instantiation now answers folding ranges, so VS Code's
sticky scroll pins it (TODO §72, docs/features/instance-folding): one range
from the module-type line, and one more per instance from the line its name
is on when that is a later line, so both `aes_control_fsm #(` and
`) u_aes_control_fsm (` stay pinned inside the connection list. The closing
`);` line stays visible.

- folding/instances.rs: what is an instantiation comes from
  vlog_semantic::instantiations::sites; where it closes is re-read from the
  tokens, and a statement whose tokens are not exactly that shape folds
  nothing.
- folding.rs: in_answer_order is a stable sort by start line over scopes,
  branches, instances; every earlier fold is unchanged and first on a shared
  start line (0.66.0 against this tree on 4 933 files: identical once the
  instance folds are removed).
- OpenTitan hw: 18 200 multi-line instantiations, none without its fold.
- Not folded: two-dimensional instance arrays; an instance whose head an
  `ifdef splits.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
2026-11-19 23:22:18 -08:00
Guoliang ChenandClaude Mythos 5.2 10cb6e020f Release 0.66.0: the overnight queue, complete
ci / checks (push) Successful in 57s
ci / corpus (push) Successful in 15s
ci / linux (push) Successful in 4m52s
release / build-and-publish (push) Successful in 5m18s
Closes TODO §71: eight owner-ordered features shipped as 0.65.2–0.65.11.
No engine change since 0.65.11.

- docs/topo.md refreshed through 0.65.11: contracts, server-lane edges,
  packaging rows, open handshakes 44–66, new modules, choke points; stale
  FACTS_FORMAT and state.rs references corrected.
- CLAUDE.md: file sizes re-measured.
- Feature READMEs: five stale facts corrected.
- large.rs: the two linear-time tests re-measure up to three times before
  failing (0.65.11's Linux CI run read 24.9x against a 24x limit under load).

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
2026-11-19 21:01:14 -08:00
21 changed files with 1772 additions and 108 deletions

No files matched your search

+71
View File
@@ -4,6 +4,77 @@ All notable changes to lucisv are recorded here. Versions follow
[semantic versioning](https://semver.org/); until 1.0 the CLI's exit codes [semantic versioning](https://semver.org/); until 1.0 the CLI's exit codes
(see `README.md`) are the only frozen contract. (see `README.md`) are the only frozen contract.
## 0.66.1 — 2026-11-19
### Sticky scroll pins the module instance
- **A module instantiation folds, so its header lines stay pinned** (TODO
§72, `docs/features/instance-folding`). `textDocument/foldingRange` answers
one range per multi-line instantiation from its module-type line, and one
more per instance from the line its name is on when that is a later line,
so both `aes_control_fsm #(` and `) u_aes_control_fsm (` are pinned while
the reader is in the connection list. The closing `);` line stays visible.
What is an instantiation comes from `vlog_semantic::instantiations::sites`;
where it closes is re-read from the tokens, and a statement whose tokens
are not exactly that shape folds nothing.
- Every fold answered before is unchanged and first on a shared start line
(0.66.0 against this tree on 4 933 files: 75 256 ranges identical once the
instance folds are removed). OpenTitan `hw`: 18 200 multi-line
instantiations, none without its fold. Worst file about 2 ms per request
(1.1 ms before).
- Not folded: two-dimensional instance arrays; an instance whose head an
`` `ifdef `` splits.
## 0.66.0 — 2026-11-19
### The overnight queue, complete
0.66.0 closes TODO §71: eight owner-ordered features, each shipped as its own
0.65.x release with a dev round, a QA round and the full gates. Nothing in
the engine changed between 0.65.11 and this release; it adds the topology
and size re-measurement (`docs/topo.md`, `CLAUDE.md`) and is the version to
install. Each line names the release that carries the detail below.
- **Editing and saving no longer re-index the workspace** (0.65.6/0.65.7).
A saved or changed file updates its own records and the files that depend
on it; only a change that can reach everything (a config, a filelist)
rescans.
- **Actions on the open file do not wait for the workspace** (0.65.11).
Hover, go-to-definition, highlights, the outline and folding for names the
file declares answer in milliseconds during a scan or a rescan, and
completion lists what the file can reach first.
- **Highlighting does not wait for the index** (0.65.10). Colours come from
the buffer at once, as a best guess for cross-file names, and are
corrected by one refresh when the index settles.
- **`` `ifdef `` / `` `else `` / `` `endif `` branches fold** and take part
in sticky scroll (0.65.4).
- **Formatter styles** (0.65.5): `auto` follows the file's own style, or
choose `lucisv`, `ansi`, `google`, `lowrisc`, `microsoft` or `nxp`; the presets are one readable
table in `vlog_formatter/src/style.rs`.
- **The module view marks where you are** (0.65.2): the current file's
module and its parents, in shades of orange.
- **Find References next to a name** (0.65.8): a caret just past a name's
last letter now finds it — the cause of "no references" that worked on a
second try — and edits arriving during a rescan are applied in order.
- **Comments are comments** (0.65.3): no bracket or code colouring inside
them, and `TODO`, `FIXME`, `FIX_ME`, `TBD` and your own words
(`lucisv.commentKeywords.custom`) are highlighted.
Also since 0.65.0: releases are gated by `tools/gates.sh`, which
compile-checks Windows and Linux (0.65.1, 0.65.7); CI runs the suite on
Linux as well as macOS, and `lucisv-mcp` no longer serves stale contents
after a same-instant rewrite (0.65.9).
One test change in this release: 0.65.11's Linux CI run failed on a
wall-clock test of the large-file path (24.9x measured against a 24x limit
on a loaded runner; nothing in that path had changed). The test now
re-measures up to three times before failing — a real quadratic regression
measures ~64x every time.
**Not yet seen in a running editor by a human** — every feature above was
verified through the server's protocol and the extension's tests, on
OpenTitan's `hw` tree. Open follow-ups are listed in TODO §71.
## 0.65.11 — 2026-11-19 ## 0.65.11 — 2026-11-19
### Actions on the open file no longer wait for the workspace ### Actions on the open file no longer wait for the workspace
+10
View File
@@ -89,6 +89,16 @@ Re-measured 2026-10-14 after TODO §55 (pure move, `docs/features/decomposition-
files over 600 workspace-wide: `lucisv_server/src/perf.rs` 907 (reasoned), files over 600 workspace-wide: `lucisv_server/src/perf.rs` 907 (reasoned),
`vlog_parser/src/lexer.rs` 771, `vlog_formatter/src/format/stmt.rs` 604. `vlog_parser/src/lexer.rs` 771, `vlog_formatter/src/format/stmt.rs` 604.
Re-measured 2026-11-19 at 0.66.0, after the overnight queue (TODO §71; non-blank,
non-comment lines before `mod tests`): two files over 600 — `perf.rs` 907
(reasoned) and `lexer.rs` 771 — then `vlog_semantic/src/resolve.rs` 587 and
`vlog_parser/src/parser/item.rs` 582, both at the mark: the next addition to
either goes in a new module. The queue's new modules are all small
(`server/ahead.rs`, `same_file.rs`, `completion/related.rs`, `server/viewport.rs`,
`server/caret.rs`, `state/watched.rs`, `folding/directives.rs`, formatter
`style.rs` / `auto.rs`); `server/dispatch.rs` is 503 and `server/index.rs`
is where four of the eight features met.
## Rust standards ## Rust standards
- `cargo fmt` clean, `cargo clippy --all-targets` clean (no `#[allow]` - `cargo fmt` clean, `cargo clippy --all-targets` clean (no `#[allow]`
Generated
+9 -9
View File
@@ -97,7 +97,7 @@ dependencies = [
[[package]] [[package]]
name = "lucisv" name = "lucisv"
version = "0.65.11" version = "0.66.1"
dependencies = [ dependencies = [
"lucisv_core", "lucisv_core",
"rayon", "rayon",
@@ -108,11 +108,11 @@ dependencies = [
[[package]] [[package]]
name = "lucisv_core" name = "lucisv_core"
version = "0.65.11" version = "0.66.1"
[[package]] [[package]]
name = "lucisv_mcp" name = "lucisv_mcp"
version = "0.65.11" version = "0.66.1"
dependencies = [ dependencies = [
"lucisv_core", "lucisv_core",
"serde", "serde",
@@ -126,7 +126,7 @@ dependencies = [
[[package]] [[package]]
name = "lucisv_server" name = "lucisv_server"
version = "0.65.11" version = "0.66.1"
dependencies = [ dependencies = [
"lsp-server", "lsp-server",
"lsp-types", "lsp-types",
@@ -262,14 +262,14 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]] [[package]]
name = "vlog_formatter" name = "vlog_formatter"
version = "0.65.11" version = "0.66.1"
dependencies = [ dependencies = [
"vlog_parser", "vlog_parser",
] ]
[[package]] [[package]]
name = "vlog_linter" name = "vlog_linter"
version = "0.65.11" version = "0.66.1"
dependencies = [ dependencies = [
"lucisv_core", "lucisv_core",
"vlog_formatter", "vlog_formatter",
@@ -279,11 +279,11 @@ dependencies = [
[[package]] [[package]]
name = "vlog_parser" name = "vlog_parser"
version = "0.65.11" version = "0.66.1"
[[package]] [[package]]
name = "vlog_refactor" name = "vlog_refactor"
version = "0.65.11" version = "0.66.1"
dependencies = [ dependencies = [
"vlog_formatter", "vlog_formatter",
"vlog_parser", "vlog_parser",
@@ -292,7 +292,7 @@ dependencies = [
[[package]] [[package]]
name = "vlog_semantic" name = "vlog_semantic"
version = "0.65.11" version = "0.66.1"
dependencies = [ dependencies = [
"vlog_parser", "vlog_parser",
] ]
+1 -1
View File
@@ -13,7 +13,7 @@ members = [
] ]
[workspace.package] [workspace.package]
version = "0.65.11" version = "0.66.1"
authors = ["Guoliang Chen"] authors = ["Guoliang Chen"]
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
+27 -1
View File
@@ -7350,7 +7350,7 @@ subsection, plan and `docs/features/<name>/README.md` when its turn comes.
`signal[]` gets highlighted today), **but do highlight `TODO`, `signal[]` gets highlighted today), **but do highlight `TODO`,
`FIXME`, `FIX_ME`, `TBD`**, plus a user setting for custom words that `FIXME`, `FIX_ME`, `TBD`**, plus a user setting for custom words that
are highlighted only in comments. are highlighted only in comments.
- [ ] **71.9 Release `0.66.0`** once 71.1–71.8 have each shipped. - [x] **71.9 Release `0.66.0`** once 71.1–71.8 have each shipped.
### 71 — wave 1 (lead, 2026-11-19): 71.6 runs beside §70 ### 71 — wave 1 (lead, 2026-11-19): 71.6 runs beside §70
@@ -7498,3 +7498,29 @@ indexing, collide with each other and with §70's test files, and wait for
between a settled session and a fresh server on OpenTitan). between a settled session and a fresh server on OpenTitan).
- [ ] The 40 000-file rescan after a delete takes either 12.3 s or - [ ] The 40 000-file rescan after a delete takes either 12.3 s or
14.5–15.5 s, on 0.65.10 and on this tree alike; cause not found. 14.5–15.5 s, on 0.65.10 and on this tree alike; cause not found.
## 72. Sticky scroll pins the module instance (planned 2026-11-19, owner's order)
Owner: "only the module definition is floating. I want to extend this a
little so that the module instance would be floating as well." Folds come
only from keyword pairs and `` `ifdef `` branches, so nothing delimited by
`( )` pins. Surveyed on OpenTitan `hw` (4 047 files): 162 instances of 50+
lines, none pinned; 132 of them write `#(` on the type line, so the instance
name sits on a later `) u_name (` line. Example:
`hw/ip/aes/rtl/aes_control_fsm_n.sv:382-594`. One lane (dev, then QA),
feature README `docs/features/instance-folding/README.md`.
- [x] `crates/lucisv_server/src/folding/instances.rs` (new): one fold per
multi-line module instantiation from its module-type line, and one more
per instance from the line its name is on when that is a different
line, so both `aes_control_fsm #(` and `) u_aes_control_fsm (` pin
while the reader is in the connection list. The closing line stays
visible, as for every scope fold.
- [x] `crates/lucisv_server/src/folding.rs`: the third source merged through
`in_answer_order`; every fold the server answered before is still
there, unchanged and first on a shared start line.
- [x] Tests in the same change, and `folding/opentitan_sweep.rs` extended:
instances counted independently, existing folds proven unchanged.
- [x] `editors/vscode/README.md`: the sticky-scroll row names the instance.
- [x] Seen in a running VS Code (owner, 2026-11-19, on the local 0.66.1
build). Shipped as 0.66.1.
+55 -19
View File
@@ -6,12 +6,16 @@
//! This module is the fourth consumer of the first and the second of the //! This module is the fourth consumer of the first and the second of the
//! second. See `docs/features/references-nav/README.md`. The third source, //! second. See `docs/features/references-nav/README.md`. The third source,
//! the branches of `` `ifdef `` regions, is [`directives`] //! the branches of `` `ifdef `` regions, is [`directives`]
//! (`docs/features/ifdef-folding/README.md`). //! (`docs/features/ifdef-folding/README.md`); the fourth, module
//! instantiations, is [`instances`] (`docs/features/instance-folding/README.md`).
mod directives; mod directives;
#[cfg(test)] #[cfg(test)]
mod ifdef_tests; mod ifdef_tests;
#[cfg(test)] #[cfg(test)]
mod instance_tests;
mod instances;
#[cfg(test)]
mod opentitan_sweep; mod opentitan_sweep;
use std::collections::HashSet; use std::collections::HashSet;
@@ -24,8 +28,8 @@ use crate::pairs::analyze;
use crate::state::Document; use crate::state::Document;
/// Every foldable region in a buffer: one per matched scope pair, one per /// Every foldable region in a buffer: one per matched scope pair, one per
/// branch of a closed `` `ifdef `` region, plus every block comment that spans /// branch of a closed `` `ifdef `` region, one or more per multi-line module
/// more than one line. /// instantiation, plus every block comment that spans more than one line.
/// ///
/// A keyword whose counterpart never arrived is **not** foldable — `analyze` /// A keyword whose counterpart never arrived is **not** foldable — `analyze`
/// leaves it out of `pairs`, and folding to the end of the file because an /// leaves it out of `pairs`, and folding to the end of the file because an
@@ -35,7 +39,8 @@ use crate::state::Document;
pub fn folding_ranges(doc: &Document) -> Vec<FoldingRange> { pub fn folding_ranges(doc: &Document) -> Vec<FoldingRange> {
let scopes = scope_and_comment_folds(doc); let scopes = scope_and_comment_folds(doc);
let branches = branch_folds(doc, &scopes); let branches = branch_folds(doc, &scopes);
in_answer_order(scopes, branches) let instances = instance_folds(doc, &scopes, &branches);
in_answer_order([scopes, branches, instances])
} }
/// The scope-pair and block-comment folds, exactly as they were before /// The scope-pair and block-comment folds, exactly as they were before
@@ -80,26 +85,57 @@ fn branch_folds(doc: &Document, existing: &[FoldingRange]) -> Vec<FoldingRange>
out out
} }
/// One fold per multi-line module instantiation, from its module-type line,
/// and one per instance whose name is on a later line, sorted by start line.
/// The closing line stays visible, as for a scope. An instance fold whose two
/// lines are exactly an existing fold's is left out, as a branch fold is; of
/// two instance folds on one start line only the longer is kept, since VS
/// Code would show only one of them anyway.
fn instance_folds(
doc: &Document,
scopes: &[FoldingRange],
branches: &[FoldingRange],
) -> Vec<FoldingRange> {
let mut out = Vec::new();
for (start, through) in
instances::instance_spans(&doc.tree.items, &doc.tokens, |offset| line(doc, offset))
{
let taken = |folds| has_lines(folds, start, through);
if !taken(scopes) && !taken(branches) {
push(&mut out, start, through, FoldingRangeKind::Region);
}
}
out.sort_by_key(|range| (range.start_line, std::cmp::Reverse(range.end_line)));
out.dedup_by_key(|range| range.start_line);
out
}
/// Whether `folds`, sorted by start line, has one on exactly these two lines.
fn has_lines(folds: &[FoldingRange], start: u32, end: u32) -> bool {
let from = folds.partition_point(|range| range.start_line < start);
let mut same_start = folds[from..].iter().take_while(|range| range.start_line == start);
same_start.any(|range| range.end_line == end)
}
/// The one place the answer's order is defined: by start line; on a shared /// The one place the answer's order is defined: by start line; on a shared
/// start line, every scope or comment fold (in their own `(start, end)` /// start line, by source in the order given — every scope or comment fold (in
/// order) before any branch fold. /// their own `(start, end)` order), then every branch fold, then every
/// instance fold.
/// ///
/// The order is load-bearing. VS Code keeps only the *first* range it /// The order is load-bearing. VS Code keeps only the *first* range it
/// receives for a start line (`sanitizeRanges`), so whatever comes first is /// receives for a start line (`sanitizeRanges`), so whatever comes first is
/// the fold the user gets and the line sticky scroll pins. Putting existing /// the fold the user gets and the line sticky scroll pins. Putting the older
/// folds first means a branch fold never costs the user a fold they had /// sources first means a newer fold never costs the user a fold they had
/// before — on `module m; `ifdef A` the `module` fold survives and the branch /// before — on `module m; `ifdef A` the `module` fold survives and the branch
/// yields. See `docs/features/ifdef-folding/README.md`. /// yields; on `begin sub u (` the `begin` survives and the instance yields.
fn in_answer_order(existing: Vec<FoldingRange>, branches: Vec<FoldingRange>) -> Vec<FoldingRange> { /// See `docs/features/ifdef-folding/README.md` and
let mut out = Vec::with_capacity(existing.len() + branches.len()); /// `docs/features/instance-folding/README.md`.
let mut branches = branches.into_iter().peekable(); ///
for range in existing { /// A stable sort by start line over the sources laid end to end is exactly
while let Some(branch) = branches.next_if(|b| b.start_line < range.start_line) { /// that: equal start lines keep the order they were laid down in.
out.push(branch); fn in_answer_order<const N: usize>(sources: [Vec<FoldingRange>; N]) -> Vec<FoldingRange> {
} let mut out: Vec<FoldingRange> = sources.into_iter().flatten().collect();
out.push(range); out.sort_by_key(|range| range.start_line);
}
out.extend(branches);
out out
} }
@@ -0,0 +1,613 @@
//! Module-instantiation folds, through the whole [`folding_ranges`] answer so
//! every test also sees how they sit beside the scope, comment and branch
//! folds — and, on every text, that the answer without them is exactly the
//! answer the server gave before they existed.
use lsp_types::{FoldingRange, FoldingRangeKind};
use vlog_semantic::WorkspaceIndex;
use super::{branch_folds, folding_ranges, instance_folds, scope_and_comment_folds};
use crate::state::Document;
fn doc_of(text: &str) -> Document {
Document::new(None, text.to_string(), &WorkspaceIndex::default())
}
/// The answer before instance folds existed: the two-way merge
/// `in_answer_order` was, verbatim, kept here as the oracle the generalised
/// one is checked against.
fn previous_answer(doc: &Document) -> Vec<FoldingRange> {
let existing = scope_and_comment_folds(doc);
let branches = branch_folds(doc, &existing);
let mut out = Vec::with_capacity(existing.len() + branches.len());
let mut branches = branches.into_iter().peekable();
for range in existing {
while let Some(branch) = branches.next_if(|b| b.start_line < range.start_line) {
out.push(branch);
}
out.push(range);
}
out.extend(branches);
out
}
/// Every fold as `(start line, end line)`, after checking the promises every
/// answer keeps: sorted by start line, `start < end`, region kind for every
/// instance fold, and — with the instance folds taken out — byte-identical to
/// [`previous_answer`], in the same order.
fn folds(text: &str) -> Vec<(u32, u32)> {
let doc = doc_of(text);
let ranges = folding_ranges(&doc);
assert!(ranges.windows(2).all(|w| w[0].start_line <= w[1].start_line), "{ranges:?}");
assert!(ranges.iter().all(|r| r.start_line < r.end_line), "{ranges:?}");
let scopes = scope_and_comment_folds(&doc);
let branches = branch_folds(&doc, &scopes);
let instances = instance_folds(&doc, &scopes, &branches);
assert!(instances.iter().all(|r| r.kind == Some(FoldingRangeKind::Region)));
let rest: Vec<FoldingRange> =
ranges.iter().filter(|r| !instances.contains(r)).cloned().collect();
assert_eq!(rest, previous_answer(&doc), "the old answer must survive unchanged");
assert_eq!(ranges.len(), rest.len() + instances.len(), "{ranges:?}");
ranges.iter().map(|r| (r.start_line, r.end_line)).collect()
}
/// The instance folds alone, as `(start, end)`.
fn instance_lines(text: &str) -> Vec<(u32, u32)> {
folds(text);
let doc = doc_of(text);
let scopes = scope_and_comment_folds(&doc);
let branches = branch_folds(&doc, &scopes);
instance_folds(&doc, &scopes, &branches).iter().map(|r| (r.start_line, r.end_line)).collect()
}
#[test]
fn a_parameterised_instance_pins_its_type_line_and_its_name_line() {
// The owner's shape (`aes_control_fsm_n.sv`): the statement folds from the
// type line, the connection list from the `) u_name (` line, and the `);`
// stays visible under both.
let text = concat!(
"module top;\n", // 0
" aes_control_fsm #(\n", // 1
" .AESGCMEnable ( AESGCMEnable ),\n", // 2
" .SecMasking ( SecMasking )\n", // 3
" ) u_aes_control_fsm (\n", // 4
" .clk_i ( clk_i ),\n", // 5
" .rst_ni ( rst_ni )\n", // 6
" );\n", // 7
"endmodule\n", // 8
);
assert_eq!(folds(text), vec![(0, 7), (1, 6), (4, 6)]);
}
#[test]
fn an_instance_without_parameters_folds_once() {
let text = concat!(
"module top;\n", // 0
" sub u_sub (\n", // 1
" .a(a),\n", // 2
" .b(b)\n", // 3
" );\n", // 4
"endmodule\n", // 5
);
assert_eq!(folds(text), vec![(0, 4), (1, 3)]);
}
#[test]
fn a_one_line_instance_folds_nothing() {
let text = concat!(
"module top;\n",
" sub u (.a(a));\n",
" sub #(.W(8)) v (.a(a), .b(b));\n",
"endmodule\n",
);
assert_eq!(folds(text), vec![(0, 2)], "the module only");
}
#[test]
fn the_closer_on_its_own_line_after_the_list_stays_visible() {
// `)` and `;` on different lines: the statement stops before the `;`
// line, the instance before the `)` line.
let text = concat!(
"module top;\n", // 0
" sub u (\n", // 1
" .a(a)\n", // 2
" )\n", // 3
" ;\n", // 4
"endmodule\n", // 5
);
assert_eq!(folds(text), vec![(0, 4), (1, 3)]);
}
#[test]
fn every_later_instance_of_a_statement_gets_its_own_fold() {
let text = concat!(
"module top;\n", // 0
" sub a (\n", // 1
" .x(x)\n", // 2
" ), b (\n", // 3
" .x(y)\n", // 4
" ),\n", // 5
" c (\n", // 6
" .x(z)\n", // 7
" );\n", // 8
"endmodule\n", // 9
);
// `a` is on the statement's own line, so it adds nothing; `b` and `c` do.
assert_eq!(folds(text), vec![(0, 8), (1, 7), (3, 4), (6, 7)]);
}
#[test]
fn two_instances_named_on_one_line_add_one_fold() {
let text = concat!(
"module top;\n", // 0
" sub #(\n", // 1
" .W(8)\n", // 2
" ) a (.x(x)), b (\n", // 3
" .x(y)\n", // 4
" );\n", // 5
"endmodule\n", // 6
);
// `a` closes on its own line, so it has nothing to hide and starts no
// fold; `b`, named on that same line, does.
assert_eq!(folds(text), vec![(0, 5), (1, 4), (3, 4)]);
}
#[test]
fn an_instance_array_folds_from_its_name_line() {
let text = concat!(
"module top;\n", // 0
" sub #(\n", // 1
" .W(8)\n", // 2
" ) u_x [3:0] (\n", // 3
" .a(a)\n", // 4
" );\n", // 5
" sub u_y [N-1:0] (\n", // 6
" .a(a)\n", // 7
" );\n", // 8
"endmodule\n", // 9
);
assert_eq!(folds(text), vec![(0, 8), (1, 4), (3, 4), (6, 7)]);
}
#[test]
fn a_two_dimensional_instance_array_is_not_an_instantiation_to_the_tree() {
// `u [1:0][2] (` does not parse as an `Instantiation` (the tree has no
// site for it), so it folds nothing rather than something guessed from
// tokens. Pinned so a parser change that starts reading it shows up here.
let text = "module top;\n sub u [1:0][2] (\n .a(a)\n );\nendmodule\n";
assert!(instance_lines(text).is_empty());
}
#[test]
fn instances_in_generate_blocks_fold_and_the_blocks_keep_theirs() {
let text = concat!(
"module top;\n", // 0
" if (A) begin : g_a\n", // 1
" sub #(\n", // 2
" .W(8)\n", // 3
" ) u_sub (\n", // 4
" .a(a)\n", // 5
" );\n", // 6
" end\n", // 7
" for (genvar i = 0; i < 2; i++) begin : g_f\n", // 8
" sub u_f (\n", // 9
" .a(a[i])\n", // 10
" );\n", // 11
" end\n", // 12
"endmodule\n", // 13
);
assert_eq!(folds(text), vec![(0, 12), (1, 6), (2, 5), (4, 5), (8, 11), (9, 10)]);
}
#[test]
fn instances_in_a_generate_region_a_case_and_an_else_are_reached() {
let text = concat!(
"module top;\n", // 0
" generate\n", // 1
" case (K)\n", // 2
" 0: begin : g0\n", // 3
" sub u0 (\n", // 4
" .a(a)\n", // 5
" );\n", // 6
" end\n", // 7
" endcase\n", // 8
" if (A) begin\n", // 9
" end else begin\n", // 10
" sub u1 (\n", // 11
" .a(a)\n", // 12
" );\n", // 13
" end\n", // 14
" endgenerate\n", // 15
"endmodule\n", // 16
);
assert_eq!(instance_lines(text), vec![(4, 5), (11, 12)]);
}
#[test]
fn instances_in_interfaces_and_programs_are_reached() {
let text = concat!(
"interface bus_if;\n", // 0
" sub u (\n", // 1
" .a(a)\n", // 2
" );\n", // 3
"endinterface\n", // 4
"program p;\n", // 5
" sub v (\n", // 6
" .a(a)\n", // 7
" );\n", // 8
"endprogram\n", // 9
);
assert_eq!(instance_lines(text), vec![(1, 2), (6, 7)]);
}
#[test]
fn an_instance_sharing_a_line_with_a_begin_yields_to_it() {
// VS Code keeps the first range per start line: the `begin` fold was
// there first and stays first; the instance fold rides behind it.
let text = concat!(
"module top;\n", // 0
" if (A) begin : g sub u (\n", // 1
" .a(a)\n", // 2
" );\n", // 3
" end\n", // 4
"endmodule\n", // 5
);
assert_eq!(folds(text), vec![(0, 4), (1, 3), (1, 2)]);
}
#[test]
fn an_instance_with_exactly_a_begins_lines_is_left_out() {
let text = concat!(
"module top;\n", // 0
" if (A) begin : g sub u (\n", // 1
" .a(a)\n", // 2
" ); end\n", // 3
"endmodule\n", // 4
);
assert_eq!(folds(text), vec![(0, 3), (1, 2)], "the begin's own fold, once");
assert!(instance_lines(text).is_empty());
}
#[test]
fn an_instance_sharing_a_line_with_an_ifdef_branch_comes_after_it() {
let text = concat!(
"module top;\n", // 0
" sub u ( `ifdef X\n", // 1
" .a(a)\n", // 2
" `else\n", // 3
" .a(b)\n", // 4
" `endif\n", // 5
" );\n", // 6
"endmodule\n", // 7
);
assert_eq!(folds(text), vec![(0, 6), (1, 2), (1, 5), (3, 4)]);
}
#[test]
fn an_ifdef_inside_the_connection_list_keeps_its_branch_folds() {
let text = concat!(
"module top;\n", // 0
" sub u (\n", // 1
" .a(a),\n", // 2
"`ifdef X\n", // 3
" .b(b)\n", // 4
"`else\n", // 5
" .b(c)\n", // 6
"`endif\n", // 7
" );\n", // 8
"endmodule\n", // 9
);
assert_eq!(folds(text), vec![(0, 8), (1, 7), (3, 4), (5, 6)]);
}
#[test]
fn an_ifdef_around_a_whole_instance_nests_its_fold() {
let text = concat!(
"module top;\n", // 0
"`ifdef X\n", // 1
" sub u (\n", // 2
" .a(a)\n", // 3
" );\n", // 4
"`endif\n", // 5
"endmodule\n", // 6
);
assert_eq!(folds(text), vec![(0, 5), (1, 4), (2, 3)]);
}
#[test]
fn ordered_connections_fold_like_named_ones() {
let text = concat!(
"module top;\n", // 0
" sub #(8, 16)\n", // 1
" u (\n", // 2
" a,\n", // 3
" ,\n", // 4
" b\n", // 5
" );\n", // 6
"endmodule\n", // 7
);
assert_eq!(folds(text), vec![(0, 6), (1, 5), (2, 5)]);
}
#[test]
fn a_wildcard_or_empty_list_folds_only_what_spans_lines() {
let text = concat!(
"module top;\n", // 0
" sub #(\n", // 1
" .W(8)\n", // 2
" ) u (.*);\n", // 3
" sub #(\n", // 4
" .W(8)\n", // 5
" ) v ();\n", // 6
" sub w (\n", // 7
" .*\n", // 8
" );\n", // 9
"endmodule\n", // 10
);
assert_eq!(instance_lines(text), vec![(1, 2), (4, 5), (7, 8)]);
}
#[test]
fn comments_between_the_pieces_do_not_move_a_line() {
let text = concat!(
"module top;\n", // 0
" sub /* c */ #( // why\n", // 1
" .W(8)\n", // 2
" ) /* name */ u_sub\n", // 3
" /* before list */ (\n", // 4
" .a(a), // a\n", // 5
" /* two\n", // 6
" lines */\n", // 7
" .b(b)\n", // 8
" ) /* end */ ;\n", // 9
"endmodule\n", // 10
);
assert_eq!(folds(text), vec![(0, 9), (1, 8), (3, 8), (6, 7)]);
}
#[test]
fn crlf_line_ends_give_the_same_lines() {
let text = concat!(
"module top;\r\n",
" sub #(\r\n",
" .W(8)\r\n",
" ) u_sub (\r\n",
" .a(a)\r\n",
" );\r\n",
"endmodule\r\n",
);
assert_eq!(folds(text), vec![(0, 5), (1, 4), (3, 4)]);
}
#[test]
fn an_instance_cut_off_by_the_end_of_the_file_folds_nothing() {
let text = concat!("module top;\n", " sub #(\n", " .W(8)\n", " ) u (\n", " .a(a),\n");
assert!(instance_lines(text).is_empty(), "{:?}", folds(text));
let text = concat!("module top;\n", " sub #(\n", " .W(8)\n");
assert!(instance_lines(text).is_empty(), "{:?}", folds(text));
}
#[test]
fn an_instance_missing_its_closer_or_its_semicolon_folds_nothing() {
let no_paren = concat!(
"module top;\n",
" sub u (\n",
" .a(b)\n",
" ;\n",
" wire w;\n",
"endmodule\n",
);
let no_semi = concat!(
"module top;\n",
" sub u (\n",
" .a(b)\n",
" )\n",
" wire w;\n",
"endmodule\n"
);
let half_typed = concat!("module top;\n", " sub u (.a(\n", "\n", " wire w;\n", "endmodule\n");
let no_param_close = concat!(
"module top;\n",
" sub #(\n",
" .W(8)\n",
" u (\n",
" .a(b)\n",
" );\n",
"endmodule\n",
);
for text in [no_paren, no_semi, half_typed, no_param_close] {
assert!(instance_lines(text).is_empty(), "{text:?}: {:?}", folds(text));
}
}
#[test]
fn calls_macros_declarations_and_gates_are_not_instances() {
let text = concat!(
"module top;\n", // 0
" initial begin\n", // 1
" foo(\n", // 2
" a,\n", // 3
" b\n", // 4
" );\n", // 5
" end\n", // 6
" `MY_MACRO(\n", // 7
" a,\n", // 8
" b)\n", // 9
" logic [3:0] x = f(\n", // 10
" a,\n", // 11
" b);\n", // 12
" and g1 (\n", // 13
" q,\n", // 14
" a\n", // 15
" );\n", // 16
" assign y = g(\n", // 17
" a);\n", // 18
"endmodule\n", // 19
);
assert!(instance_lines(text).is_empty(), "{:?}", folds(text));
}
#[test]
fn a_bind_folds_like_the_instantiation_it_carries() {
let text = concat!(
"bind top sub u_b (\n", // 0
" .a(a)\n", // 1
");\n", // 2
);
assert_eq!(folds(text), vec![(0, 1)]);
}
#[test]
fn a_large_file_still_folds_nothing() {
let text = "module top;\n sub u (\n .a(a)\n );\nendmodule\n".to_string();
assert!(folding_ranges(&Document::large(None, text)).is_empty());
}
// ----------------------------------------------------------------------
// QA (2026-11-19): adversarial inputs and the README's untested assumptions
// ----------------------------------------------------------------------
/// A text with most shapes at once: generate block, `#(` list with a string
/// and a comment holding `)` and `;`, `` `ifdef `` inside a connection list,
/// an instance array, a second instance, a block comment ending on the type
/// line, a nested call in a connection, `)` and `;` on separate lines, and a
/// macro use ending on the type line.
const RICH: &str = concat!(
"module top;\n", // 0
" if (A) begin : g\n", // 1
" sub #(\n", // 2
" .W(8), // ) ;\n", // 3
" .S(\")(;\")\n", // 4
" ) u_a (\n", // 5
" .a(a[1:0]),\n", // 6
"`ifdef X\n", // 7
" .b({b, c})\n", // 8
"`else\n", // 9
" .b(d)\n", // 10
"`endif\n", // 11
" ), u_b [3:0] (\n", // 12
" .a(a)\n", // 13
" );\n", // 14
" end\n", // 15
" /* x\n", // 16
" */ sub v (\n", // 17
" .a(f(\n", // 18
" 1))\n", // 19
" )\n", // 20
" ;\n", // 21
" `M(x) sub w (.*\n", // 22
" );\n", // 23
"endmodule\n", // 24
);
/// Every fold ends inside the text, and every instance fold of `text` is one
/// the whole of [`RICH`] has: damage never invents a fold.
fn assert_only_whole_text_folds(text: &str, whole: &[(u32, u32)]) {
let lines = text.split('\n').count() as u32;
assert!(folds(text).iter().all(|&(_, end)| end < lines), "{text:?}");
for fold in instance_lines(text) {
assert!(whole.contains(&fold), "{fold:?} not in {whole:?}: {text:?}");
}
}
#[test]
fn every_cut_and_every_blanked_token_folds_only_what_the_whole_text_does() {
let whole = instance_lines(RICH);
assert_eq!(whole, vec![(2, 13), (5, 11), (12, 13), (17, 20)]);
// Mid-typing: the text cut off at every character.
for cut in (0..=RICH.len()).filter(|&cut| RICH.is_char_boundary(cut)) {
assert_only_whole_text_folds(&RICH[..cut], &whole);
}
// One token blanked to spaces, so every line keeps its number.
for token in &doc_of(RICH).tokens {
let (start, end) = (token.span.start as usize, token.span.end as usize);
let mut text = RICH.to_string();
text.replace_range(start..end, &" ".repeat(end - start));
assert_only_whole_text_folds(&text, &whole);
}
}
#[test]
fn a_macro_in_type_position_and_an_attribute_do_not_move_the_fold() {
let text = concat!(
"module top;\n", // 0
" `MY_MOD u (\n", // 1
" .a(a)\n", // 2
" );\n", // 3
" (* keep = \"true\" *) sub #(\n", // 4
" .W(8)\n", // 5
" ) v (\n", // 6
" .a(a)\n", // 7
" );\n", // 8
"endmodule\n", // 9
);
assert_eq!(instance_lines(text), vec![(1, 2), (4, 7), (6, 7)]);
}
#[test]
fn brackets_and_semicolons_in_strings_and_comments_are_not_closers() {
let text = concat!(
"module top;\n", // 0
" sub #(\n", // 1
" .S(\")(;\")\n", // 2
" ) u ( // ) ;\n", // 3
" /* ( */ .a(a)\n", // 4
" );\n", // 5
"endmodule\n", // 6
);
assert_eq!(instance_lines(text), vec![(1, 4), (3, 4)]);
}
#[test]
fn a_udp_instance_folds_and_a_wrapped_bind_starts_on_its_type_line() {
// README: UDP instances fold (indistinguishable from a module without
// resolving the name); a wrapped `bind` pins the bound module's type line.
let text = concat!(
"module top;\n", // 0
" my_udp u (\n", // 1
" q,\n", // 2
" a, b);\n", // 3
"endmodule\n", // 4
"bind top\n", // 5
" sub u_b (\n", // 6
" .a(a)\n", // 7
" );\n", // 8
);
assert_eq!(instance_lines(text), vec![(1, 2), (6, 7)]);
}
#[test]
fn class_and_procedural_lookalikes_are_not_instances() {
let text = concat!(
"package p;\n",
" class c;\n",
" foo #(int) x = new(\n",
" 1,\n",
" 2);\n",
" covergroup cg (int a);\n",
" endgroup\n",
" cg cg_i = new(\n",
" 1);\n",
" function void f();\n",
" void'(h(\n",
" 3));\n",
" endfunction\n",
" endclass\n",
"endpackage\n",
"module top;\n",
" typedef logic [3:0] nib_t;\n",
" nib_t x = f(\n",
" 1);\n",
" a_label: assert property (\n",
" @(posedge clk) a |-> b\n",
" ) else $error(\n",
" \"x\");\n",
" initial begin\n",
" my_task (\n",
" a,\n",
" b);\n",
" end\n",
"endmodule\n",
);
assert!(instance_lines(text).is_empty(), "{:?}", folds(text));
}
@@ -0,0 +1,138 @@
//! Folding for module instantiations, so sticky scroll pins the instance a
//! reader is wiring up: one range per multi-line instantiation statement, from
//! its module-type line, and one more per instance whose name sits on a later
//! line (`) u_name (` under a `#(` parameter list).
//!
//! **What** is an instantiation comes from the parse tree, through the walk
//! the call hierarchy and the inlay hints already share
//! ([`vlog_semantic::instantiations::sites`]): generate blocks, interfaces and
//! programs included, gate primitives excluded. **Where** its lines are comes
//! from the token stream, because the tolerant parser keeps an instantiation
//! whose `)` or `;` is missing — mid-typing — and its spans then end wherever
//! it gave up. So every bracket and the `;` are re-read from the tokens, and a
//! statement whose shape is not exactly what the tree says folds nothing.
//! See `docs/features/instance-folding/README.md`.
use vlog_parser::ast::{Instance, Instantiation, Item};
use vlog_parser::token::{Token, TokenKind};
use vlog_semantic::instantiations::sites;
use crate::state::first_token_from;
/// `(first line, last line)` of every instantiation fold in `items`, in
/// 0-based lines, given the line a byte offset falls on.
///
/// Per statement: one span from the module-type line through the line before
/// the `;`, then one per instance from its name's line through the line before
/// its connection list's `)` — left out when it has nothing to hide or when
/// the name is on a line this statement already starts a span on. A statement
/// span with nothing between its two lines comes back too (`last <= first`);
/// the caller drops it.
pub(super) fn instance_spans(
items: &[Item],
tokens: &[Token],
line_of: impl Fn(u32) -> u32,
) -> Vec<(u32, u32)> {
let mut out = Vec::new();
for site in sites(items) {
let Some(shape) = shape(site.inst, tokens) else { continue };
let first = line_of(site.inst.module_span.start);
out.push((first, line_of(shape.semi).saturating_sub(1)));
// The lines this statement already starts a non-empty span on.
let mut starts = vec![first];
for (instance, close) in site.inst.instances.iter().zip(shape.closes) {
let at = line_of(instance.name_span.start);
let last = line_of(close).saturating_sub(1);
if last > at && !starts.contains(&at) {
starts.push(at);
out.push((at, last));
}
}
}
out
}
/// Where an instantiation's closers are, as byte offsets of their first byte.
struct Shape {
/// The `)` closing each instance's connection list, in instance order.
closes: Vec<u32>,
/// The `;` ending the statement.
semi: u32,
}
/// The closers of `inst`, read off the tokens, or `None` unless the tokens
/// spell exactly `type [#( … )] name [dims] ( … ) {, name [dims] ( … )} ;`
/// with every bracket matched where the tree says it is.
fn shape(inst: &Instantiation, tokens: &[Token]) -> Option<Shape> {
let mut at = first_token_from(tokens, inst.module_span.end);
if inst.params.is_some() {
let first_name = inst.instances.first()?.name_span.start;
at = params_end(tokens, at, first_name)?;
}
let mut closes = Vec::with_capacity(inst.instances.len());
for (i, instance) in inst.instances.iter().enumerate() {
if i > 0 {
at = expect(tokens, at, ",")?;
}
let close = instance_close(instance, tokens, at)?;
closes.push(tokens.get(close)?.span.start);
at = close + 1;
}
let semi = tokens.get(at).filter(|t| t.is_sym(";"))?;
Some(Shape { closes, semi: semi.span.start })
}
/// The index just past a `#( … )` parameter list that starts at `at` and
/// closes before the first instance's name at byte `limit`.
fn params_end(tokens: &[Token], at: usize, limit: u32) -> Option<usize> {
let open = expect(tokens, at, "#")?;
tokens.get(open).filter(|t| t.is_sym("("))?;
Some(matching(tokens, open, limit, ("(", ")"))? + 1)
}
/// The index of the `)` closing `instance`'s connection list, when its name
/// token is at `at` and that `)` is the one the tree's span ends on.
fn instance_close(instance: &Instance, tokens: &[Token], at: usize) -> Option<usize> {
let name = tokens.get(at)?;
if name.span.start != instance.name_span.start {
return None;
}
let mut open = at + 1;
let limit = instance.span.end;
while tokens.get(open).is_some_and(|t| t.is_sym("[")) {
open = matching(tokens, open, limit, ("[", "]"))? + 1;
}
tokens.get(open).filter(|t| t.is_sym("("))?;
let close = matching(tokens, open, limit, ("(", ")"))?;
(tokens.get(close)?.span.end == instance.span.end).then_some(close)
}
/// The index after the token at `at`, when that token is the symbol `sym`.
fn expect(tokens: &[Token], at: usize, sym: &str) -> Option<usize> {
tokens.get(at).filter(|t| t.is_sym(sym)).map(|_| at + 1)
}
/// The index of the `close` matching the `open` at `at`, counting only that
/// pair, among the tokens that start before byte `limit` — the end of the
/// construct the tree says the brackets belong to, so a broken statement
/// costs its own length and never a scan to the end of the file. `None` when
/// the brackets are not closed by then: an unclosed list never folds.
fn matching(tokens: &[Token], at: usize, limit: u32, pair: (&str, &str)) -> Option<usize> {
let (open, close) = pair;
let mut depth = 0usize;
let within = tokens.iter().enumerate().skip(at).take_while(|(_, t)| t.span.start < limit);
for (i, token) in within {
if token.kind != TokenKind::Symbol {
continue;
}
if token.text == open {
depth += 1;
} else if token.text == close {
depth = depth.checked_sub(1)?;
if depth == 0 {
return Some(i);
}
}
}
None
}
@@ -1,6 +1,7 @@
//! The real-world proof for `` `ifdef `` folding: every `.sv`/`.svh`/`.v` //! The real-world proof for `` `ifdef `` and instantiation folding: every
//! file under an OpenTitan `hw` tree, through [`folding_ranges`], with the //! `.sv`/`.svh`/`.v` file under an OpenTitan `hw` tree, through
//! ranges checked against the file and the directives counted independently. //! [`folding_ranges`], with the ranges checked against the file and the
//! directives and instantiations counted independently.
//! //!
//! `#[ignore]`: it parses four thousand files. Run with //! `#[ignore]`: it parses four thousand files. Run with
//! `LUCISV_OPENTITAN_HW=/path/to/opentitan/hw tools/guard.sh -- cargo test //! `LUCISV_OPENTITAN_HW=/path/to/opentitan/hw tools/guard.sh -- cargo test
@@ -16,7 +17,9 @@ use vlog_semantic::WorkspaceIndex;
use lsp_types::FoldingRange; use lsp_types::FoldingRange;
use super::{branch_folds, directives, folding_ranges, line, scope_and_comment_folds}; use super::{
branch_folds, directives, folding_ranges, instance_folds, line, scope_and_comment_folds,
};
use crate::state::Document; use crate::state::Document;
/// The tree: `LUCISV_OPENTITAN_HW`, else the full-tree cache. /// The tree: `LUCISV_OPENTITAN_HW`, else the full-tree cache.
@@ -98,6 +101,8 @@ struct Tally {
shared_start: usize, shared_start: usize,
folding: Duration, folding: Duration,
branches: Duration, branches: Duration,
/// The instantiation half, counted by [`check_instances`].
instances: InstanceTally,
} }
#[test] #[test]
@@ -111,24 +116,29 @@ fn every_opentitan_file_folds_its_ifdef_branches_validly() {
sources(&root, &mut files); sources(&root, &mut files);
files.sort(); files.sort();
let mut tally = Tally::default(); let mut tally = Tally::default();
let mut slowest: Vec<(Duration, Duration, PathBuf)> = Vec::new(); let mut slowest: Vec<(Duration, Duration, Duration, PathBuf)> = Vec::new();
for path in &files { for path in &files {
let Ok(text) = std::fs::read_to_string(path) else { continue }; let Ok(text) = std::fs::read_to_string(path) else { continue };
let (folding, branches) = sweep_one(path, text, &mut tally); let (folding, branches, instances) = sweep_one(path, text, &mut tally);
slowest.push((folding, branches, path.clone())); slowest.push((folding, branches, instances, path.clone()));
} }
slowest.sort_by_key(|entry| std::cmp::Reverse(entry.0)); slowest.sort_by_key(|entry| std::cmp::Reverse(entry.0));
eprintln!("opentitan_sweep: {tally:#?}"); eprintln!("opentitan_sweep: {tally:#?}");
for (folding, branches, path) in slowest.iter().take(5) { for (folding, branches, instances, path) in slowest.iter().take(5) {
eprintln!(" {folding:?} (branches {branches:?}) {}", path.display()); eprintln!(
" {folding:?} (branches {branches:?}, instances {instances:?}) {}",
path.display()
);
} }
assert!(tally.files > 0); assert!(tally.files > 0);
assert_eq!(tally.spans, tally.nexts_matched + tally.closes_matched, "{tally:#?}"); assert_eq!(tally.spans, tally.nexts_matched + tally.closes_matched, "{tally:#?}");
assert_instances_complete(&tally.instances);
} }
/// Fold one file, check its ranges, and add it to `tally`. Returns the time /// Fold one file, check its ranges, and add it to `tally`. Returns the time
/// the whole answer took and the time the branch pass alone took. /// the whole answer took and the times the branch and instance passes alone
fn sweep_one(path: &Path, text: String, tally: &mut Tally) -> (Duration, Duration) { /// took.
fn sweep_one(path: &Path, text: String, tally: &mut Tally) -> (Duration, Duration, Duration) {
tally.files += 1; tally.files += 1;
let by_text = text_count(&text); let by_text = text_count(&text);
tally.text_lines += by_text; tally.text_lines += by_text;
@@ -153,6 +163,7 @@ fn sweep_one(path: &Path, text: String, tally: &mut Tally) -> (Duration, Duratio
assert!(range.end_line < lines, "{}: {range:?} past line {lines}", path.display()); assert!(range.end_line < lines, "{}: {range:?} past line {lines}", path.display());
} }
check_existing_unchanged(&doc, &ranges, path, tally); check_existing_unchanged(&doc, &ranges, path, tally);
let instances = check_instances(&doc, &ranges, path, &mut tally.instances);
let before = tally.tokens; let before = tally.tokens;
let directive_lines = check_directives(&doc, path, tally); let directive_lines = check_directives(&doc, path, tally);
if tally.tokens - before != by_text { if tally.tokens - before != by_text {
@@ -169,7 +180,7 @@ fn sweep_one(path: &Path, text: String, tally: &mut Tally) -> (Duration, Duratio
path.display() path.display()
); );
} }
(folding, branches) (folding, branches, instances)
} }
/// Count the directive tokens into `tally` and return the lines they start on. /// Count the directive tokens into `tally` and return the lines they start on.
@@ -217,9 +228,14 @@ fn check_existing_unchanged(
) { ) {
let existing = scope_and_comment_folds(doc); let existing = scope_and_comment_folds(doc);
let branches = branch_folds(doc, &existing); let branches = branch_folds(doc, &existing);
let rest: Vec<&FoldingRange> = ranges.iter().filter(|r| !branches.contains(r)).collect(); let instances = instance_folds(doc, &existing, &branches);
let rest: Vec<FoldingRange> =
ranges.iter().filter(|r| !instances.contains(r)).cloned().collect();
assert_eq!(rest, previous_answer(existing.clone(), branches.clone()), "{}", path.display());
let rest: Vec<&FoldingRange> = rest.iter().filter(|r| !branches.contains(r)).collect();
assert_eq!(rest, existing.iter().collect::<Vec<_>>(), "{}", path.display()); assert_eq!(rest, existing.iter().collect::<Vec<_>>(), "{}", path.display());
assert_eq!(ranges.len(), existing.len() + branches.len(), "{}", path.display()); let all = existing.len() + branches.len() + instances.len();
assert_eq!(ranges.len(), all, "{}", path.display());
let spans = directives::branch_spans(&doc.tokens, |t| line(doc, t.span.start)); let spans = directives::branch_spans(&doc.tokens, |t| line(doc, t.span.start));
let kept = spans.iter().filter(|(s, e)| e > s).count(); let kept = spans.iter().filter(|(s, e)| e > s).count();
tally.same_lines_as_existing += kept - branches.len(); tally.same_lines_as_existing += kept - branches.len();
@@ -230,3 +246,303 @@ fn check_existing_unchanged(
} }
} }
} }
/// The answer before instance folds existed: the two-way merge
/// `in_answer_order` was until then, kept verbatim as the oracle.
fn previous_answer(existing: Vec<FoldingRange>, branches: Vec<FoldingRange>) -> Vec<FoldingRange> {
let mut out = Vec::with_capacity(existing.len() + branches.len());
let mut branches = branches.into_iter().peekable();
for range in existing {
while let Some(branch) = branches.next_if(|b| b.start_line < range.start_line) {
out.push(branch);
}
out.push(range);
}
out.extend(branches);
out
}
// ----------------------------------------------------------------------
// Instantiations, counted on the token stream by a rule of their own
// ----------------------------------------------------------------------
/// The instantiation half of the sweep.
#[derive(Default, Debug)]
struct InstanceTally {
/// Statements the token rule finds, and those of them spanning lines.
statements: usize,
multi_line: usize,
/// Instances in those statements whose name is on a later line than the
/// type and whose connection list spans lines — each owed a fold.
later_names: usize,
/// Expected folds present in the answer, statement and instance alike.
present: usize,
/// Expected folds left out because an older fold has the same two lines.
same_lines_as_existing: usize,
/// Expected folds missing from the answer: the tree disagrees with the
/// token rule. Each is printed.
missing: usize,
/// Instance folds in the answer that the token rule did not expect.
unexpected: usize,
/// Instance folds sharing a start line with an older fold (they yield).
shared_start: usize,
/// Statements whose head an `` `ifdef `` splits (`) u (` / `` `else `` /
/// `type u (`): owed no fold, since which arm's head is real is not
/// known. Any fold the answer has for one is counted `unexpected`.
split_heads: usize,
/// Statements of 50+ lines, the owner's survey count.
long: usize,
/// Time spent in the instance pass alone.
time: Duration,
}
/// One instantiation statement as the token rule reads it: 0-based lines of
/// the type name and the `;`, and of each instance's name and `)`.
struct Counted {
type_line: u32,
semi_line: u32,
instances: Vec<(u32, u32)>,
/// The type follows an `` `else ``/`` `elsif `` whose previous arm ended
/// on an open `(`: this is the second spelling of a split head.
split_head: bool,
}
impl Counted {
/// The folds this statement is owed, statement first: what the feature
/// promises, re-derived here from the lines alone.
fn expected(&self) -> Vec<(u32, u32)> {
let mut out = vec![(self.type_line, self.semi_line.saturating_sub(1))];
let mut starts = vec![self.type_line];
for &(name, close) in &self.instances {
let through = close.saturating_sub(1);
if through > name && !starts.contains(&name) {
starts.push(name);
out.push((name, through));
}
}
out.retain(|(start, end)| end > start);
out
}
}
/// Count `doc`'s instantiations by the token rule and check the answer
/// against them. Returns the time the instance pass alone took.
fn check_instances(
doc: &Document,
ranges: &[FoldingRange],
path: &Path,
t: &mut InstanceTally,
) -> Duration {
let existing = scope_and_comment_folds(doc);
let branches = branch_folds(doc, &existing);
let started = Instant::now();
let produced = instance_folds(doc, &existing, &branches);
let time = started.elapsed();
t.time += time;
if path.ends_with("hw/ip/aes/rtl/aes_control_fsm_n.sv") {
check_owner_example(ranges);
}
let older: Vec<(u32, u32)> =
existing.iter().chain(&branches).map(|r| (r.start_line, r.end_line)).collect();
let mut owed = Vec::new();
for counted in counted_statements(doc) {
t.statements += 1;
if counted.split_head {
t.split_heads += 1;
eprintln!(" split head at line {}: {}", counted.type_line + 1, path.display());
continue;
}
if counted.semi_line > counted.type_line {
t.multi_line += 1;
}
t.long += usize::from(counted.semi_line >= counted.type_line + 49);
let expected = counted.expected();
t.later_names += expected.len().saturating_sub(1);
owed.extend(expected);
}
for &(start, end) in &owed {
if older.contains(&(start, end)) {
t.same_lines_as_existing += 1;
} else if ranges.iter().any(|r| (r.start_line, r.end_line) == (start, end)) {
t.present += 1;
} else {
t.missing += 1;
eprintln!(" instance fold {}..{} missing: {}", start + 1, end + 1, path.display());
}
}
for range in &produced {
let lines = (range.start_line, range.end_line);
if !owed.contains(&lines) {
t.unexpected += 1;
eprintln!(" unexpected instance fold {lines:?}: {}", path.display());
}
if older.iter().any(|&(start, _)| start == range.start_line) {
t.shared_start += 1;
eprintln!(" instance fold shares line {}: {}", range.start_line + 1, path.display());
}
}
time
}
/// Every statement the token rule calls an instantiation:
/// `type [#( … )] name [ […] … ] ( … ) {, name [ […] … ] ( … )} ;`, where the
/// type is a plain identifier not written after a keyword that would make it
/// something else (a function's return type, a `virtual` interface).
fn counted_statements(doc: &Document) -> Vec<Counted> {
let mut out = Vec::new();
let mut i = 0;
while i < doc.tokens.len() {
match statement_at(doc, i) {
Some((counted, next)) => {
out.push(counted);
i = next;
}
None => i += 1,
}
}
out
}
/// The statement starting at token `i`, and the index after its `;`.
fn statement_at(doc: &Document, i: usize) -> Option<(Counted, usize)> {
let tokens = &doc.tokens;
if !is_plain_name(tokens.get(i)?) || !may_start_after(tokens, i) {
return None;
}
let mut j = i + 1;
if is(tokens, j, "#") {
if !is(tokens, j + 1, "(") {
return None;
}
j = closer(tokens, j + 1)? + 1;
}
let mut instances = Vec::new();
loop {
if !is_plain_name(tokens.get(j)?) {
return None;
}
let name_line = line(doc, tokens[j].span.start);
j += 1;
while is(tokens, j, "[") {
j = closer(tokens, j)? + 1;
}
if !is(tokens, j, "(") {
return None;
}
let close = closer(tokens, j)?;
instances.push((name_line, line(doc, tokens[close].span.start)));
j = close + 1;
if is(tokens, j, ",") {
j += 1;
} else if is(tokens, j, ";") {
break;
} else {
return None;
}
}
let counted = Counted {
type_line: line(doc, tokens[i].span.start),
semi_line: line(doc, tokens[j].span.start),
instances,
split_head: splits_a_head(tokens, i),
};
Some((counted, j + 1))
}
/// Whether the type at `i` follows an `` `else `` or `` `elsif `` that itself
/// follows an open `(` — the previous arm wrote its own head.
fn splits_a_head(tokens: &[Token], i: usize) -> bool {
let Some(directive) = i.checked_sub(1).map(|p| &tokens[p]) else { return false };
let next_arm = directive.kind == TokenKind::Directive
&& (directive.text.starts_with("`else") || directive.text.starts_with("`elsif"));
next_arm && i >= 2 && is(tokens, i - 2, "(")
}
/// An identifier that is not a macro use.
fn is_plain_name(token: &Token) -> bool {
token.kind == TokenKind::Ident && !token.text.starts_with('`')
}
/// Whether an instantiation's type name may follow the token before it: not a
/// keyword (other than one ending a block or a declaration), not a `.`, `::`,
/// `#` or `'`, and not the `:` of a block's end label (`end : name`), which
/// would make the label look like a type.
fn may_start_after(tokens: &[Token], i: usize) -> bool {
let Some(previous) = i.checked_sub(1).map(|p| &tokens[p]) else { return true };
match (previous.kind, previous.text.as_str()) {
(TokenKind::Keyword, word) => matches!(
word,
"begin"
| "end"
| "else"
| "generate"
| "endgenerate"
| "endcase"
| "endfunction"
| "endtask"
| "endclocking"
| "endproperty"
| "endsequence"
| "endgroup"
),
(TokenKind::Symbol, ":") => i < 2 || tokens[i - 2].kind != TokenKind::Keyword,
(TokenKind::Symbol, text) => !matches!(text, "." | "::" | "#" | "'"),
_ => true,
}
}
/// Whether token `at` is the symbol `text`.
fn is(tokens: &[Token], at: usize, text: &str) -> bool {
tokens.get(at).is_some_and(|t| t.kind == TokenKind::Symbol && t.text == text)
}
/// The index of the bracket closing the one at `at`, every bracket kind
/// matched on one stack; `None` on a mismatch or the end of the file.
fn closer(tokens: &[Token], at: usize) -> Option<usize> {
let mut stack: Vec<&str> = Vec::new();
for (i, token) in tokens.iter().enumerate().skip(at) {
if token.kind != TokenKind::Symbol {
continue;
}
match token.text.as_str() {
"(" => stack.push(")"),
"[" => stack.push("]"),
"{" | "'{" => stack.push("}"),
text @ (")" | "]" | "}") => {
if stack.pop()? != text {
return None;
}
if stack.is_empty() {
return Some(i);
}
}
_ => {}
}
}
None
}
/// The owner's example, `aes_control_fsm_n.sv:382-486` (1-based): the
/// statement folds from `aes_control_fsm #(` and the connection list from
/// `) u_aes_control_fsm (`, both through the line before `);`.
fn check_owner_example(ranges: &[FoldingRange]) {
let around: Vec<(u32, u32)> = ranges
.iter()
.filter(|r| (370..490).contains(&r.start_line))
.map(|r| (r.start_line + 1, r.end_line + 1))
.collect();
eprintln!(
"opentitan_sweep: aes_control_fsm_n.sv folds from lines 371-490 (1-based): {around:?}"
);
assert!(around.contains(&(382, 485)), "{around:?}");
assert!(around.contains(&(385, 485)), "{around:?}");
}
/// Print the instance counts and the owner's example, and require that the
/// tree and the token rule agree everywhere.
fn assert_instances_complete(t: &InstanceTally) {
eprintln!("opentitan_sweep instances: {t:#?}");
assert!(t.multi_line > 0, "{t:#?}");
assert_eq!(t.missing, 0, "{t:#?}");
assert_eq!(t.unexpected, 0, "{t:#?}");
}
+49 -28
View File
@@ -832,14 +832,15 @@ mod tests {
for doc in &docs { for doc in &docs {
assert!(!window(doc, range(0, 1)).tokens.is_empty()); assert!(!window(doc, range(0, 1)).tokens.is_empty());
} }
let costs = fastest_of_five(&docs, |doc| { assert_grows_linearly(&sizes, "colouring tokens on one line", || {
let clock = Instant::now(); fastest_of_five(&docs, |doc| {
let data = crate::tokens::semantic_tokens_in_window(doc, range(0, 1)); let clock = Instant::now();
let elapsed = clock.elapsed(); let data = crate::tokens::semantic_tokens_in_window(doc, range(0, 1));
assert!(!data.is_empty(), "the window really did colour something"); let elapsed = clock.elapsed();
elapsed assert!(!data.is_empty(), "the window really did colour something");
elapsed
})
}); });
assert_grows_linearly(&sizes, &costs, "colouring tokens on one line");
} }
/// **QA finding 1 (2026-08-27), fixed and now a gate**, on the *other* /// **QA finding 1 (2026-08-27), fixed and now a gate**, on the *other*
@@ -879,17 +880,18 @@ mod tests {
(doc, hits) (doc, hits)
}) })
.collect(); .collect();
let costs = fastest_of_five(&docs, |(doc, hits)| { assert_grows_linearly(&sizes, "locating hits on one line", || {
let positions = doc.positions(); fastest_of_five(&docs, |(doc, hits)| {
let clock = Instant::now(); let positions = doc.positions();
// Exactly what `Server::large_scan` does with them. let clock = Instant::now();
let mut walker = positions.walker(); // Exactly what `Server::large_scan` does with them.
for hit in hits { let mut walker = positions.walker();
std::hint::black_box(walker.range(*hit)); for hit in hits {
} std::hint::black_box(walker.range(*hit));
clock.elapsed() }
clock.elapsed()
})
}); });
assert_grows_linearly(&sizes, &costs, "locating hits on one line");
} }
/// How much faster than its input a linear-time test's cost may grow /// How much faster than its input a linear-time test's cost may grow
@@ -913,21 +915,40 @@ mod tests {
fastest fastest
} }
/// How many times a measurement over [`GROWTH_SLACK`] is taken again
/// before the test fails. Load from the tests running beside this one
/// can stretch one whole measurement (the Linux runner read 24.9x of the
/// 24x limit once, with 1.35x between two neighbouring sizes); a
/// quadratic conversion measures ~64x every time, so asking again
/// loosens nothing the test can see.
const ATTEMPTS: usize = 3;
/// Fails unless the cost at the largest size is within [`GROWTH_SLACK`] /// Fails unless the cost at the largest size is within [`GROWTH_SLACK`]
/// of linear growth from the smallest. /// of linear growth from the smallest, in one of [`ATTEMPTS`] measurements.
#[track_caller] #[track_caller]
fn assert_grows_linearly(sizes: &[u32], costs: &[Duration], what: &str) { fn assert_grows_linearly(
for (size, cost) in sizes.iter().zip(costs) { sizes: &[u32],
eprintln!("{what}: {size} → {cost:?}"); what: &str,
} mut measure: impl FnMut() -> Vec<Duration>,
) {
let (first, last) = (sizes[0], sizes[sizes.len() - 1]); let (first, last) = (sizes[0], sizes[sizes.len() - 1]);
let input = f64::from(last) / f64::from(first); let input = f64::from(last) / f64::from(first);
let growth = let mut seen = Vec::new();
costs[costs.len() - 1].as_secs_f64() / costs[0].as_secs_f64().max(f64::MIN_POSITIVE); for _ in 0..ATTEMPTS {
assert!( let costs = measure();
growth <= GROWTH_SLACK * input, for (size, cost) in sizes.iter().zip(&costs) {
"{what}: {input}x the input cost {growth:.1}x the time ({costs:?}) — \ eprintln!("{what}: {size} → {cost:?}");
more than {GROWTH_SLACK}x linear, the quadratic conversion is back" }
let growth = costs[costs.len() - 1].as_secs_f64()
/ costs[0].as_secs_f64().max(f64::MIN_POSITIVE);
if growth <= GROWTH_SLACK * input {
return;
}
seen.push((growth, costs));
}
panic!(
"{what}: {input}x the input cost more than {GROWTH_SLACK}x linear in each of \
{ATTEMPTS} measurements ({seen:?}) — the quadratic conversion is back"
); );
} }
} }
+4 -1
View File
@@ -396,7 +396,10 @@ auto is the idempotency above.
- [x] Fix round (QA F1–F8): auto measure counts indentation; server remembers - [x] Fix round (QA F1–F8): auto measure counts indentation; server remembers
the preset per document; labelled-`end` `else` for google/lowrisc; presets the preset per document; labelled-`end` `else` for google/lowrisc; presets
as one table; doc corrections as one table; doc corrections
- [ ] Lane 71.1: `lint.rs` line-length width from the style (Handshake request above) - [x] Lane 71.1: `lint.rs` line-length width from the style (Handshake request above)
— delivered by localized-reindex (lane 71.1, round 3) and released in
0.65.6: `crates/lucisv_server/src/lint.rs` falls back to the chosen style's
width (`file.format_style.or(client.style)` → `style::preset`), else 100
## Work log ## Work log
@@ -200,6 +200,10 @@ expansion state survives every relight.
- `rowLevels(rows, nodes, list, path)` → `Map<rowId, level>` for lit rows only. - `rowLevels(rows, nodes, list, path)` → `Map<rowId, level>` for lit rows only.
- `levelChanges(before, after)` → `[id, level | null][]`. - `levelChanges(before, after)` → `[id, level | null][]`.
- `LIT_COLORS`, `litLevel`, `cssVariableFor` — the level ↔ colour contract. - `LIT_COLORS`, `litLevel`, `cssVariableFor` — the level ↔ colour contract.
- `BAR_COLOR` (`lucisv.hierarchyCurrentBar`, the lit row's left bar) and
`nodeDistance(node, path)` (a node's distance, `undefined` when unlit) are
exported too; `hierarchyView.js` reads neither (`BAR_COLOR` is read by
`hierarchyCurrent_test.js` and `hierarchyPalette_test.js`).
### `hierarchyView.js` → `media/hierarchy.js` (the wire inside the extension) ### `hierarchyView.js` → `media/hierarchy.js` (the wire inside the extension)
+2 -1
View File
@@ -120,7 +120,8 @@ line 7 shows module → `if (a) begin` → `if (b) begin`.
prefix) is private in `vlog_parser/src/parser/directive.rs:15-28`; it is four prefix) is private in `vlog_parser/src/parser/directive.rs:15-28`; it is four
lines and is repeated in `folding/directives.rs` rather than widened into lines and is repeated in `folding/directives.rs` rather than widened into
the parser's public surface. (A third copy, by first whitespace word, lives the parser's public surface. (A third copy, by first whitespace word, lives
in `on_type/auto_end.rs:258`.) If a public `Token::directive_word` is ever in `on_type/auto_end.rs:258-261`, `conditional`; the first-word split is
line 259.) If a public `Token::directive_word` is ever
added, all three should use it — a request, not a blocker. added, all three should use it — a request, not a blocker.
- **Promises** `folding::folding_ranges` (the only caller is - **Promises** `folding::folding_ranges` (the only caller is
`server/dispatch.rs`, unchanged): sorted by start line (tie-break in `server/dispatch.rs`, unchanged): sorted by start line (tie-break in
+315
View File
@@ -0,0 +1,315 @@
# instance-folding
## Goal
Owner: "only the module definition is floating. I want to extend this a little
so that the module instance would be floating as well." VS Code's sticky scroll
follows the server's `textDocument/foldingRange` answer (the extension sets
`editor.stickyScroll.defaultModel: foldingProviderModel`, TODO §67) and pins
the start line of every fold around the top of the viewport. Folds came from
keyword pairs, block comments and `` `ifdef `` branches only, so a 200-line
instance pinned nothing. This feature adds a fourth fold source,
`crates/lucisv_server/src/folding/instances.rs`: one fold per multi-line
instantiation statement from its module-type line, and one more per instance
whose name sits on a later line (`) u_name (` under a `#(` list), so inside a
connection list both `aes_control_fsm #(` and `) u_aes_control_fsm (` are
pinned. Server-side only (TODO §72).
## Assumptions
- **Fold shape.** Statement: from the line of the module-type name through the
line before the `;` — the `);` stays visible, the rule every scope fold
follows. Instance: from the line of its name through the line before its
connection list's `)`. An instance fold is added only when its name is on a
line this statement has not already started a non-empty fold on and when it
hides at least one line, so `sub u (` (name on the type line) folds once and
`) a (.x(x)), b (` gives `b` its own fold. Inside the `#( … )` list only the
statement fold encloses the reader, so only the type line is pinned there.
`aes_control_fsm_n.sv` (1-based): type `aes_control_fsm #(` 382,
`) u_aes_control_fsm (` 385, `);` 486 → folds `382–485` and `385–485`
(0-based `(381, 484)`, `(384, 484)`). The brief said 382–594; the statement
ends at 486 in the checked-out tree (594 is a later `prim_buf #(`).
- **What is an instantiation: the parse tree.** Found through
`vlog_semantic::instantiations::sites`, the walk the call hierarchy, the
inlay hints and the workspace index already share — no new visitor. It
descends into modules, interfaces, programs (all `ItemKind::Module`),
packages, `generate` regions, generate `if`/`else if`/`else`/`for`/`case`
blocks, with or without `generate`.
- **Not instances (tested):** task/function calls (statements, not items),
macro calls (one `Ident` token with its arguments), declarations with an
initialiser (`logic x = f(…)`), continuous assignments, gate primitives
(`and g (…)` is `ItemKind::GateInstantiation`, which the shared walk
excludes on purpose — it names no module).
- **UDP instances fold.** `my_udp u (q, a, b);` is syntactically a module
instantiation; nothing short of resolving the name tells them apart, and
folding a multi-line UDP instance is harmless and arguably right.
- **`bind` folds** (the shared walk includes the instantiation a `bind`
carries). Its statement fold starts on the line of the bound module's type
name, which is the `bind` line unless the bind is wrapped. Tested.
- **Two-dimensional instance arrays** (`u [1:0][2] (`) are not an
`Instantiation` in the tolerant tree (no site), so they fold nothing.
Pinned by a test; a parser change that reads them will flip it. Not a
request — none in OpenTitan.
- **Where its lines are: the token stream.** The tolerant parser keeps an
instantiation whose `)` or `;` is missing (`close_list` and
`expect_after_recovery` accept the gap), and its spans then end wherever it
gave up — on a nested `.a(b)`'s `)`, for instance. So `instances.rs`
re-reads the statement from the tokens: from the token after the type name,
`#` `(` … matched `)` when the tree has a parameter list, then per instance
the name token at exactly `name_span.start`, any `[ … ]` dimensions, `(` …
matched `)` whose end is exactly `Instance::span.end`, `,` between
instances, and `;` right after the last. Anything else and the whole
statement folds nothing. Bracket matching only looks at tokens that start
before the construct's end as the tree has it (the first instance name for
`#( … )`, `Instance::span.end` for a connection list), so a broken statement
costs its own length and can never match a bracket past it — no fold to the
end of the file, no `end < start` (`push` drops `end <= start` anyway).
Comments are trivia and attributes `(* *)` are one token, so neither moves
a line; a macro use carries its arguments in its own token.
- **`` `ifdef `` inside a statement.** Directives are tokens. Inside a
connection or parameter list they are skipped by the bracket matcher, so
branch folds nest inside the instance fold (tested). An `` `ifdef `` that
splits the head (`) dut (` / `` `else `` / `chip dut (` — OpenTitan
`top_*/dv/tb/tb.sv`) does not have the shape and folds nothing: which arm's
head is real is not knowable here.
- **No existing fold is lost or changed** (the lead's rule from
ifdef-folding, applied again):
- an instance fold with exactly the two lines of a scope, comment or branch
fold is not added — that fold keeps its kind (tested: `begin sub u (` …
`); end`);
- **order on a shared start line: scope/comment folds, then branch folds,
then instance folds.** Branch folds were in the answer before this
feature, so they are "existing" too and the instance fold yields to them
as well. VS Code keeps only the first range per start line, so on
`begin : g sub u (` the `begin` keeps its fold and its pin, and on
`sub u ( `ifdef X` the branch keeps its fold (both tested). The instance
fold is still sent, behind them;
- two instance folds on one start line (only possible across two
statements written on one line) keep only the longer, since VS Code would
keep only one anyway.
- **`in_answer_order` is still the one place the order is defined**,
generalised from a two-way merge to a stable sort by start line over the
sources laid end to end (`[scopes, branches, instances]`). For two sources
that is exactly the old merge (equal starts keep the order they were laid
down in; each source is already sorted). Proven, not asserted: the old
two-way merge is kept verbatim as the oracle in `instance_tests.rs`
(`previous_answer`, checked on every test text) and in the OpenTitan sweep
(every file).
- **Kind `region`**, like scope and branch folds (*Fold All Regions* folds
them; `imports` would auto-collapse).
- **Large-file fast path: unchanged.** A `Document::large` has no tokens and
the empty file's tree, so the walk finds no site and the answer stays `[]`
(tested; also `server/tests/large_file.rs`).
## Handshakes
- **Consumes** (read-only, no change): `vlog_semantic::instantiations::sites`
(the shared instantiation census; `Site::inst`), `vlog_parser::ast::
{Instantiation, Instance}` (`module_span`, `params.is_some()`,
`instances[].name_span`, `instances[].span`), `vlog_parser::token::Token`
(`is_sym`, `kind`, `span`), `crate::state::first_token_from`,
`Document::{tree, tokens, line_index}`. No parser change.
- **Promises** `folding::folding_ranges` (only caller `server/dispatch.rs`,
unchanged): sorted by start line; on a tie scope/comment folds (old
`(start, end)` order), then branch folds, then instance folds; every range
`start < end` and inside the file; instance folds kind `region`; with the
instance folds removed the answer is exactly the 0.66.0 answer, same order
and kinds (asserted per test and per OpenTitan file).
- **No requests.** (Noted, not requested: 2-D instance arrays are not an
`Instantiation` in the tolerant tree.)
## Status / TODO
- [x] Find how instantiations are reached (shared `sites` walk) and where the
tree's spans can lie (tolerant recovery of `)`/`;`).
- [x] `folding/instances.rs`: statement + per-instance spans, token-verified.
- [x] `folding.rs`: `instance_folds` (drop same-lines, one per start),
`in_answer_order` generalised to N sources.
- [x] Unit tests `folding/instance_tests.rs` (25), with the old-answer oracle
on every text.
- [x] OpenTitan sweep extended: independent token-rule count, every owed fold
present, no unexpected fold, old answer unchanged per file, aes example.
- [x] Timing before/after.
- [x] `editors/vscode/README.md` sticky-scroll row.
- [ ] Seen in a running VS Code (owner): scroll into `aes_control_fsm_n.sv`'s
connection list and see both header lines pinned; scroll into the
parameter list and see only the type line.
## Work log
### 2026-11-19 — dev
- Reused `vlog_semantic::instantiations::sites` for *what* (it already
covers generate blocks, interfaces, programs, `bind`, and excludes gates);
tokens for *where*, because the tolerant tree keeps a half-typed
instantiation with spans ending at whatever it last consumed. `shape()`
re-reads the whole statement; any disagreement with the tree → no fold.
- `folding.rs`: `instance_folds` (same-lines check by binary search on the
already-sorted scope and branch folds — a `HashSet` first, swapped after
timing), `in_answer_order<const N>` = stable sort by start line over the
concatenated sources.
- Tests (`folding/instance_tests.rs`, 25): owner's shape exact; no `#(`;
one-liners; `)` and `;` on separate lines; multi-instance; two names on one
line; instance arrays (and the 2-D non-site); generate `if`/`for` with
`begin`, `generate` region + `case` + `else`; interface and program; shared
start with a `begin` (yields) and identical lines (dropped); shared start
with an `` `ifdef `` branch (yields); `` `ifdef `` inside the list and
around the instance; ordered connections; `.*`/`()`; comments everywhere
incl. a multi-line one in the list; CRLF; cut off at EOF; missing `)`,
missing `;`, half-typed `.a(`, missing `)` of `#(`; calls/macros/
declarations/gates/assigns; `bind`; large file. Every test text also goes
through the invariant checks (sorted, `start < end`, region kind,
answer minus instance folds == the old two-way merge verbatim).
- First sweep run found the *token rule* (the sweep's independent count) too
loose, not the code: `end : label` followed by `task_call();` and
`endfunction`/`endtask` before an instantiation. Fixed the rule; then 2
remaining "missing" were the split heads in `top_*/dv/tb/tb.sv`, now
classified (`split_heads`) and owed nothing.
- **OpenTitan sweep** (`LUCISV_OPENTITAN_HW=/Users/lucio/repo/opentitan/hw
tools/guard.sh -- cargo test --release -p lucisv_server opentitan_sweep --
--ignored --nocapture`, 4 047 files, passed): token rule finds 18 724
instantiation statements, 18 200 multi-line, 164 of 50+ lines, 2 split
heads; 16 277 later-name instance folds owed; **34 450 owed folds, all
present, 0 missing, 0 unexpected** (every instance fold the answer has is
one the rule owed), 0 identical to an older fold, 0 sharing a start line
with an older fold. Old answer unchanged on every file (the verbatim
two-way merge as oracle), branch counts unchanged (1 852 directive tokens,
1 072 spans, 1 066 ranges). `aes_control_fsm_n.sv` lines 371–490 now answer
exactly `[(382, 485), (385, 485)]` (1-based), asserted.
- **Timing** (`folding_ranges`, release, same machine, load ~3): before (base
tree, same sweep) whole tree 35.1 ms, slowest `top_earlgrey/.../
pinmux_reg_top.sv` 1.07 ms; after, two runs: whole tree 45.1–46.3 ms,
slowest the same file 1.95–1.97 ms, of which the instance pass is
0.62–0.66 ms (the whole tree's instance pass: 7.1–7.3 ms). The rest of the
growth is the bigger answer (≈ +8.5 folds per file on average) and its sort.
- Test counts: `lucisv_server` lib 1 999 passed + 47 ignored before → 2 024 +
47 after (+25); e2e 106, grammar 3, ifdef_folding 1 unchanged.
- Not touched: `vlog_parser`, `vlog_semantic`, dispatch, `large.rs`,
versions, changelogs, `docs/topo.md`.
## QA log
### 2026-11-19 — QA (Opus 5.5)
**Verdict: PASS.** No defect found; two info-level notes below.
**Gates, run by QA** (all through `tools/guard.sh`, no kill):
- `cargo fmt --all -- --check` clean; `cargo clippy --all-targets -- -D warnings`
exit 0 (only the pre-existing `workspace.package.authors` manifest warning).
- `cargo test -p lucisv_server`: lib 2 024 passed + 47 ignored as delivered
(2 029 after QA's 5 tests), e2e 106, grammar 3, ifdef_folding 1,
opentitan_references 0 + 2 ignored; all green.
- OpenTitan sweep (release, `--ignored`): passed, 4 047 files; instances
18 724 statements, 18 200 multi-line, 16 277 later names, 34 450 present,
0 missing, 0 unexpected, 0 shared start, 2 split heads, 164 long.
`aes_control_fsm_n.sv` → `[(382, 485), (385, 485)]` (1-based); checked by
hand against the file (type 382, `) u_aes_control_fsm (` 385, `);` 486).
**Old answer unchanged, independently of the dev's oracle.** Two temporary
`git worktree`s in the scratchpad (HEAD = 0.66.0, and HEAD + this diff), each
with a throwaway `#[ignore]` dumper (never in the real tree; worktrees removed
after), release builds in separate target dirs. Dumped the full ordered answer
for 4 933 files (OpenTitan `hw` 4 069 incl. `.vh`, `~/.cache/lucisv-corpus`
860, repo fixtures). New answer with the instance folds removed is
**byte-identical, same order and kinds, to the 0.66.0 answer** on every file
(75 256 old ranges). Across the new answer (111 226 ranges, 35 970 instance
folds in 1 308 files): 0 unsorted, 0 `start >= end`, 0 past the last line,
0 instance folds sharing a start line with an older fold or with another
instance fold, every instance fold `region`.
**Is the sweep's count independent?** Mostly. It shares no code with
`instances.rs` (own bracket matcher over all bracket kinds, own token walk,
no `sites`), but it does share the lucisv lexer, `line()`, and it restates the
fold-shape rule (`Counted::expected`) — so a lexer bug, or a wrong shape rule
in the spec, would cancel out; and it was loosened/tightened after the first
run to match. Cross-checked with QA's own counter
(scratchpad `count_inst.py`: own comment/string/attribute stripper, own lexer,
statements split on depth-0 `;` and block keywords, not lucisv's tokens):
OpenTitan 18 679 statements, 18 173 multi-line, 164 long, 34 417 owed folds;
**every fold it owes is in the answer**; the answer has 29 folds it does not
own, every one inspected and a limitation of QA's script (hierarchical / macro
/ `: inst` `bind` targets, `` `ifdef `` lines in `top_*/dv/tb/tb.sv`), each
fold correct against the source. Answer total on the 4 069 files 34 446 vs the
sweep's 34 450: the sweep follows the one symlinked file
(`hw/ip/tlul/rtl/tlul_adapter_shim.sv`), `find -type f` does not.
**Attacks** (probe files dumped through the new build, each answer read
against the source; no wrong fold, no panic anywhere):
- Cut at every character and every token blanked to spaces of a text with
most shapes (generate, `#(` with string/comment holding `)`/`;`, `` `ifdef ``
in the list, array, second instance, `*/ sub v (`, nested call, `)`/`;` split,
`` `M(x) sub w ( ``): every fold inside the file, start < end, old answer
unchanged, and no instance fold the whole text does not have. Also every
single character blanked (scratch only): 0 violations. Kept as a test.
- Folds right: `` `MY_MOD u ( ``, `` `MY_MOD #( ``, macro with multi-line args
inside `#(`, `(* attr *) sub #(`, `endgenerate sub y (`, `begin end sub k (`,
`*/ sub v (`, `) ;; ;`, CRLF + tabs + UTF-8 in comments, nested generate
with array + second instance, interface/program, `bind` plain and wrapped,
UDP, `sub u8 ( … )\n ;`, `.a((b)\n ));`, `my_class #(.T(int)) obj (` in a
module (syntactically an instantiation — right).
- Fold nothing (right or harmless): `` `ifdef `` between `)` and the name and
around `#( … )`; `foo #(int) x = new(`, `cg cg_i = new(`, `void'(h(`,
multi-line task/function calls, typedef'd declaration with initialiser,
labelled `assert property ( … ) else $error(`; `)),` and `)) u (` and
`.W((8)` unbalanced; a statement after `garbage ( ( ( ;` and after a
statement missing its `;` (recovery swallows them — under-fold only).
- Same-line probes: on `generate if (A) begin : g sub u (` … `); end` the
instance fold equals the `begin`'s and is dropped (as designed).
**Timing** (release, same machine, two runs each, sweep's own clock):
0.66.0 whole tree 33.4 / 34.8 ms, slowest `pinmux_reg_top.sv` 1.05–1.10 ms;
this tree 45.3 / 46.3 ms, slowest the same file 1.86–2.04 ms (instance pass
0.60–0.70 ms). Dev's 35.1 → ~46 ms and 1.07 → 1.96 ms hold. Per-edit worst
case is that file (`pinmux_reg_top.sv`, the three tops), ~2 ms per request.
**Standards.** No `unwrap`/`expect()`/`panic!` in library code (`expect` in
`instances.rs` is a local helper's name; `panic!` only in `mod tests`), no
`#[allow]`, doc comments present. Production lines (non-blank, non-comment,
before `mod tests`): `folding.rs` ~86 (66 at 0.66.0), `instances.rs` 89.
Longest new production function `instance_spans` 23 lines. README has every
required section and matches the code. `in_answer_order`: inputs are sorted
by start (scopes by `(start, end)`, branches by start, stable), so the stable
sort equals the old merge — confirmed by the cross-build diff above.
**Findings** (none blocking):
1. *Info — README claim / dead branch.* `folding.rs:108-109`
(`sort_by_key` + `dedup_by_key` on start line) and the Assumptions line
"two instance folds on one start line (only possible across two statements
written on one line) keep only the longer": not reachable. A non-empty fold
of one statement ends at least one line before its `)`/`;`, so the next
statement's type line is always after every non-empty fold start of the
previous one; within a statement `starts` already prevents it. The sweep
and the cross-build dump agree (0 cases in 35 970). Harmless; the dev may
reword the README or keep the code as a guard.
2. *Info — pre-existing, not this feature.* Code on the same line after
`` `ifdef X `` or `` `endif `` (`` `ifdef X sub w ( `` …, `` `endif sub z ( ``)
is not an instantiation in the tree, so it gets no instance fold (the
branch fold is unchanged). Repro: probe `module top;\n`endif sub z (\n .a(a)\n );\nendmodule`.
**Assumptions vs tests.** Previously untested README assumptions now tested by
QA: UDP instances fold, a wrapped `bind` starts on its type line, attributes
`(* *)` and a macro in type position do not move a line, brackets/`;` in
strings and comments. All others were already covered by the dev's tests.
**Fixed / added directly:** five tests appended to
`folding/instance_tests.rs` (QA section): every cut / every blanked token of a
rich text; macro type + attribute; strings/comments with closers; UDP and
wrapped `bind`; class/procedural lookalikes. No production code touched.
**Not verified:** behaviour in a running VS Code (owner's checkbox); the
request path through `server/dispatch.rs` was not exercised beyond the
existing e2e suite (QA called `folding_ranges` directly).
## Review
- **2026-11-19 (lead).** Accepted. Read `folding/instances.rs` and the
`folding.rs` diff: the tree says what is an instantiation, the tokens say
where it closes, and a statement whose tokens are not exactly the tree's
shape folds nothing — the right side to fail on. `in_answer_order` is still
the one place order is defined. QA's independent 0.66.0-vs-tree dump (4 933
files, 75 256 ranges identical once instance folds are removed) is the proof
that no earlier fold moved. `tools/gates.sh` on the tree: PASS, every step
(`target/gates/20261119-230338`). QA note 1 (the same-start-line dedup can
never fire) stays as a guard. Edge recorded in `docs/topo.md`. Open: seen in
a running VS Code (owner); 2-D instance arrays need the parser to read them
as instantiations first.
@@ -93,11 +93,13 @@ the assertion where it *can* run.
- [x] The two linear-time tests bound growth, not wall-clock; shown to trip - [x] The two linear-time tests bound growth, not wall-clock; shown to trip
on the quadratic conversion on macOS and on the Linux runner. on the quadratic conversion on macOS and on the Linux runner.
- [x] Cleaning round (see work log). - [x] Cleaning round (see work log).
- [ ] Linux suite green as root (twice) and as `--user`. Observed: root - [x] Linux suite green as root (twice) and as `--user`. Observed: root
once green; `--user` once with one failure, the new flake once green; `--user` once with one failure, the new flake
`scan_trace::the_stages_add_up_to_the_scan_they_describe` (open, see `scan_trace::the_stages_add_up_to_the_scan_they_describe` (open, see
the work log); the second root run and the flake's diagnosis were cut the work log); the second root run and the flake's diagnosis were cut
off when ssh to luhpe stopped working. off when ssh to luhpe stopped working. Done in Round 2: 10 of 10 green
as root and 10 of 10 as `--user` (dev), 6 of 6 each (QA) — work log
and QA log.
- [x] `tools/gates.sh` green on macOS (see the work log for each run). - [x] `tools/gates.sh` green on macOS (see the work log for each run).
- [x] Fix round: `scan_trace` lower bound on the best of three sessions; - [x] Fix round: `scan_trace` lower bound on the best of three sessions;
linear-time tests best of five; `tools/linux_check.sh` hardened. linear-time tests best of five; `tools/linux_check.sh` hardened.
+4 -2
View File
@@ -223,10 +223,12 @@ from-scratch build.
filelist is among them). `watch.rs` was touched for this only. filelist is among them). `watch.rs` was touched for this only.
- **Changed:** `IncludeGraph::update_file` removed; `update_held(path, text)` - **Changed:** `IncludeGraph::update_file` removed; `update_held(path, text)`
(this file's edges, nothing relearned), `add_known(path)` and (this file's edges, nothing relearned), `add_known(path)` and
`refresh_naming(path)` added (`includers_of`, added in the first cut, is `refresh_naming(path)` added, and `refresh_naming_all(&[PathBuf])` (round
3: one walk for a batch of paths) (`includers_of`, added in the first cut, is
gone). The graph holds every file's include lines; its test fingerprint gone). The graph holds every file's include lines; its test fingerprint
renders them. renders them.
- **New:** `Workspace::refresh_includes_naming(path)`; `watch::names_a_config`. - **New:** `Workspace::refresh_includes_naming(&[PathBuf])` (round 3 batched
it; it was `(path)` before); `watch::names_a_config`.
- **Changed:** `WorkspaceIndex::fingerprint` renders each ambiguity's count. - **Changed:** `WorkspaceIndex::fingerprint` renders each ambiguity's count.
- **Changed:** `Candidates::update_file`/`update_words` are `#[cfg(test)]`; - **Changed:** `Candidates::update_file`/`update_words` are `#[cfg(test)]`;
`set_file_words` and `refresh_names` are the production halves. `set_file_words` and `refresh_names` are the production halves.
+108 -25
View File
@@ -22,7 +22,11 @@ their edges already tabled below; +§2.9-19); updated 2026-08-30 again
for fuzzy-completion (107 feature READMEs); updated 2026-09-01 for for fuzzy-completion (107 feature READMEs); updated 2026-09-01 for
null-items (108 feature READMEs); updated 2026-09-02 through v0.33.0 for the null-items (108 feature READMEs); updated 2026-09-02 through v0.33.0 for the
testbench grammar/semantics wave, comment slots, bind semantics, SVA bodies, testbench grammar/semantics wave, comment slots, bind semantics, SVA bodies,
and the four decomposition rounds (125 feature READMEs). and the four decomposition rounds (125 feature READMEs); updated 2026-11-19
through v0.65.11 for release gating, hierarchy-current-path,
comment-highlighting, ifdef-folding, format-styles, localized-reindex,
scan-ordering, linux-test-portability (Round 2, the MCP stamp fix),
viewport-highlight and fast-actions; open handshakes 44–66 from TODO §70/§71.
**Code audit refreshed 2026-09-07.** Latest release: **v0.49.0** **Code audit refreshed 2026-09-07.** Latest release: **v0.49.0**
(`4c2dae3`); committed snapshot: **`df4e714`**, clean at review start. (`4c2dae3`); committed snapshot: **`df4e714`**, clean at review start.
@@ -159,7 +163,7 @@ what a change on the pointed-to side must not silently break.
| `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/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. | | `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]-<version>-<triple>` 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. | | `tools/ ◀──▶ crates + editors/vscode` | handshake | `release.sh` parses `lucisv --version` (field 2), runs `smoke.js` against the built server, stages `dist/lucisv[-server]-<version>-<triple>` 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 — `gates.sh` first (the release is gated since 0.65.1), then `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 `## <version> — <date>` headings via `release_notes.sh`. | | `CI (Gitea Actions) ──▶ tools/` | depends | `release.yml` is (almost) all `tools/` one-liners — `gates.sh` first (the release is gated since 0.65.1: fmt, clippy, one `suite:<crate>` step per workspace member, docs, corpus — fetched first so it is not skipped —, node, cross; a red gate stops before anything is built), then `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) on the macOS runner, and since 0.65.9 a `linux` job (`runs-on: linux-x64`, the luhpe runner, as root, 4 CPU / 8 GB, rustup per job, cold build) running `cargo clippy --all-targets -- -D warnings` and `cargo test --workspace`; `tools/linux_check.sh [--user] [--dry-run]` runs a command against the working tree in the same job image without a push (§2.8). `ci.yml` runs on the branch push and the release does not wait for it: a tag publishes only after `gates.sh` is green on macOS, so releases are gated on macOS alone (§2.9-57). Both jobs run `cargo test --workspace` bare, not through `tools/guard.sh` (§2.9-65). Tag `vX.Y.Z` must equal the workspace version; release notes come from `CHANGELOG.md`'s `## <version> — <date>` 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). | | `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 production edges** (also check shared file ownership): **Deliberately absent production edges** (also check shared file ownership):
@@ -215,7 +219,12 @@ server queue and `lsp-server` I/O threads are proven not to parse.
`verify.rs` (the runtime safety net: token equivalence + convergence — `verify.rs` (the runtime safety net: token equivalence + convergence —
CLAUDE.md invariant #4 territory, see §3.3); `fence.rs` (format-off regions + CLAUDE.md invariant #4 territory, see §3.3); `fence.rs` (format-off regions +
`protected_regions`, consumed by both front ends); `range.rs` (`--lines`); `protected_regions`, consumed by both front ends); `range.rs` (`--lines`);
`align.rs` (alignment inference). `format_source` = parse → format → verify; `align.rs` (alignment inference; `align::plan` takes an `Alignment` mode,
`Infer` = the old rule); `selection/` (`format_selection`, §66.2);
`style.rs` (`Style`, the `PRESETS` table of six rows, `preset`, `names`;
every switch moves whitespace only, so `verify.rs` knows nothing of styles);
`auto.rs` (`format_auto`, `resolve_style`: format with each preset, keep the
fewest changed lines). `format_source` = parse → format → verify;
an error means emit nothing. an error means emit nothing.
**`vlog_semantic`** — `bind/` (AST → scopes/symbols/references; since **`vlog_semantic`** — `bind/` (AST → scopes/symbols/references; since
@@ -226,21 +235,27 @@ an error means emit nothing.
`workspace/` (`mod` = the tables, `index` = queries and `build`, `update` = `workspace/` (`mod` = the tables, `index` = queries and `build`, `update` =
incremental update and `fingerprint`, `record` = the `FileFacts` read-off, incremental update and `fingerprint`, `record` = the `FileFacts` read-off,
`external` = the overlay, `reexport` = cycle-guarded package member traversal; `external` = the overlay, `reexport` = cycle-guarded package member traversal;
`hierarchy` = tagged connection/hierarchical member tables; `WorkspaceIndex`: units, members, defines, instantiation and `hierarchy` = tagged connection/hierarchical member tables; `path_units`
(§65.4); `dependents` = the readers table, which files' resolution read which
merged-table key; `references` = postings built whole or re-done for a few
files; `replace` = one record replaced, only the keys it reaches re-merged —
the last three localized-reindex's; `WorkspaceIndex`: units, members, defines, instantiation and
inheritance edge tables, incremental `update_file`/`remove_file`, inheritance edge tables, incremental `update_file`/`remove_file`,
reference postings, `files_spelling`, batch `absorb`, declaration `DeclLines`, reference postings, `files_spelling`, batch `absorb`, declaration `DeclLines`,
`fingerprint`); `facts.rs` (`FileFacts` codec for the persistent cache; `fingerprint`); `facts.rs` (`FileFacts` codec for the persistent cache;
`FACTS_FORMAT` is **20**); `FACTS_FORMAT` is **22**, since §65.4);
`instantiations.rs`, `classes.rs` (the shared walks, lifted from the server `instantiations.rs`, `classes.rs` (the shared walks, lifted from the server
so the index census and the request handlers cannot drift); `imports.rs` so the index census and the request handlers cannot drift); `imports.rs`
(`import_usage`, `import_scopes`, `unused_imports`, `Exports`, `PackageExports`) (`import_usage`, `import_scopes`, `unused_imports`, `Exports`, `PackageExports`)
is the shared usage judgement consumed by organize-imports and the linter. is the shared usage judgement consumed by organize-imports and the linter.
**`lucisv_core`** — `config.rs` (`lucisv.toml` parsing + `Discovery`, the **`lucisv_core`** — `config.rs` (`lucisv.toml` parsing + `Discovery`, the
upward search with its per-instance cache), `walk.rs` (`collect_files`, upward search with its per-instance cache; `FileConfig::format_style`,
`STYLE_NAMES`, `parse_style`, and `NAMES`, now `pub`), `walk.rs` (`collect_files`,
`EXTENSIONS`, `.gitignore`/`--exclude` filtering), `filelist.rs` (the `.f` `EXTENSIONS`, `.gitignore`/`--exclude` filtering), `filelist.rs` (the `.f`
reader: files, `+incdir+`, defines, warnings), `cache.rs` (the format cache + reader: files, `+incdir+`, defines, warnings), `cache.rs` (the format cache +
`content_hash` — the one FNV-1a the server's index cache also reuses), `content_hash` — the one FNV-1a the server's index cache also reuses; an
`Entry` carries its `style`, a seven-field store line),
`atomic.rs` (shared replacement for CLI source writes and the format cache). Knows `atomic.rs` (shared replacement for CLI source writes and the format cache). Knows
nothing of Verilog; depends on nothing. Config stores `LintOption` entries nothing of Verilog; depends on nothing. Config stores `LintOption` entries
raw with source/line information; front ends validate them through raw with source/line information; front ends validate them through
@@ -295,10 +310,10 @@ spans two layers — the include graph *and* the `documentLink` handler;
| layer | files | role | | layer | files | role |
|---|---|---| |---|---|---|
| entry | `main.rs` | the no-argument / `--verbose`-only argument contract, capabilities advertisement, `InitializeParams` reading, wiring | | entry | `main.rs` | the no-argument / `--verbose`-only argument contract, capabilities advertisement, `InitializeParams` reading, wiring |
| loop | `server/` (since 2026-09-02: `mod` = the loop; `dispatch`, `client`, `index`, `notification`, `progress`, `diagnostics`, `batch`, `formatting`, `large_file`, `semantic_tokens`; tests in `server/tests/`) | 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 | | loop | `server/` (since 2026-09-02: `mod` = the loop; `dispatch`, `client`, `index`, `notification`, `progress`, `diagnostics`, `batch`, `formatting`, `large_file`, `semantic_tokens`, `startup`; `ahead` = answering a request from its buffer ahead of whatever holds the rest — the one precondition (`answer_from_the_buffer`), `REACH`, every place a request is offered (fast-actions, 0.65.11); `viewport` = which colouring requests may go ahead, the range-guess record and the refresh (viewport-highlight; tests in `server/viewport/`); `probe` = `#[cfg(test)]` burst scripting and `went_ahead`; tests in `server/tests/`) | 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 and for notifications (`must_hold`), the early-answer exemption, 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) | | state | `state/` (a directory since TODO §55: `mod`, `document`, `buffers`, `views`, `scope`, `scan`, `rescan`, `discover`, `sources`, `port_grace`; localized-reindex added `incremental` — `OneFile`, `update_one_file` — and `watched` — `Watched`) | `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 | | substrate | `convert.rs`, `uri.rs`, `locate.rs`, `pairs.rs`, `includes.rs`, `candidates.rs`, `index_cache.rs`, `watch.rs`, `settings.rs`, `templates.rs`, `sync.rs`, `caret.rs`, `auto_style.rs`, `same_file.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, the byte a name-under-the-cursor request is about (`symbol_offset`), the per-document `auto` preset memory, whether a request's whole answer is its buffer's (`same_file::METHODS`, `answered_by_the_buffer`; tests in `same_file/`) |
| handlers | one file per capability: `format.rs`, `diagnostics.rs`, `lint.rs` (with `fences.rs`: the formatter's text-only fence answer memoized once per `Document` — perf5-p1; the shared-fence-filter contract is unamended; and `lint_snapshot.rs` + `lint_trace.rs` — perf5r-lint-snapshot, 2026-09-08: one `lint_with` pass per document revision shared by the diagnostics publish and quick-fix discovery, keyed by value on every input of that call — rule names, merged options, line width, tab width, oracle presence, external waiver *contents* — held in a `Slot` on the `Document` and cleared by `Document::refresh_overlay`, which every index mutation ends in; a `timing: codeaction … key=value` line under `--verbose`, parsed by `tools/perf/phases_r1.py`), `rename_trace.rs` (perf5-p2: `Rung`/`Wanted`/`SelectionTrace` — the path set the rename fan-out ladder fills, remembering which rung asked for each file; `Workspace::rename_sources_traced` is the ladder with that sink), `hover.rs`, `expand.rs`, `nav.rs`, `type_def.rs`, `type_hierarchy.rs`, `hierarchy.rs`, `design_hierarchy.rs`, `symbols.rs`, `tokens.rs`, `completion/` (`mod`, `member`, `module`, `tiers`, `word`, `site`; test harness in `harness`), `signature.rs`, `inlay.rs`, `inline.rs`, `lens.rs`, `code_action.rs`, `rename.rs`, `ports.rs`, `imports.rs`, `extract.rs`, `inline_module.rs`, `folding.rs`, `selection.rs`, `linked.rs`, `on_type.rs`, `includes.rs` (links), `file_ops.rs`, `instantiate.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) | | handlers | one file per capability: `format.rs`, `diagnostics.rs`, `lint.rs` (with `fences.rs`: the formatter's text-only fence answer memoized once per `Document` — perf5-p1; the shared-fence-filter contract is unamended; and `lint_snapshot.rs` + `lint_trace.rs` — perf5r-lint-snapshot, 2026-09-08: one `lint_with` pass per document revision shared by the diagnostics publish and quick-fix discovery, keyed by value on every input of that call — rule names, merged options, line width, tab width, oracle presence, external waiver *contents* — held in a `Slot` on the `Document` and cleared by `Document::refresh_overlay`, which every index mutation ends in; a `timing: codeaction … key=value` line under `--verbose`, parsed by `tools/perf/phases_r1.py`), `rename_trace.rs` (perf5-p2: `Rung`/`Wanted`/`SelectionTrace` — the path set the rename fan-out ladder fills, remembering which rung asked for each file; `Workspace::rename_sources_traced` is the ladder with that sink), `hover.rs`, `expand.rs`, `nav.rs`, `type_def.rs`, `type_hierarchy.rs`, `hierarchy.rs`, `design_hierarchy.rs`, `symbols.rs`, `tokens.rs` (+ `tokens/`: `instantiation.rs`, window tests, ignored sweep), `completion/` (`mod`, `member`, `module`, `tiers`, `word`, `site`, `buffer`, `connection`; `related` = the related tier, sortText `4`, outside `LIMIT` with its own `RELATED_LIMIT`; `wire` = the `itemDefaults` payload rewrite — both fast-actions; test harness in `harness`), `signature.rs`, `inlay.rs`, `inline.rs`, `lens.rs`, `code_action.rs`, `rename.rs`, `ports.rs`, `imports.rs`, `extract.rs`, `inline_module.rs`, `folding.rs` (+ `folding/directives.rs`), `selection.rs`, `linked.rs`, `on_type.rs`, `includes.rs` (links), `file_ops.rs`, `instantiate.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 **`editors/vscode`** — `extension.js` (spawn + rainbow decorations + storage
path; ~everything else is `vscode-languageclient` driven off advertised path; ~everything else is `vscode-languageclient` driven off advertised
@@ -308,12 +323,21 @@ colour ids), `syntaxes/` (hand-maintained grammar, test-locked to
serialized start/restart chain, so a `lucisv.verbose` toggle cannot be lost to serialized start/restart chain, so a `lucisv.verbose` toggle cannot be lost to
an in-flight start — shipped, shared by the extension restart paths), an in-flight start — shipped, shared by the extension restart paths),
`hierarchyView.js`/`hierarchyModel.js`/`hierarchySections.js` (the indexed `hierarchyView.js`/`hierarchyModel.js`/`hierarchySections.js` (the indexed
instance hierarchy sidebar and client-only DUT sections), `extract.js` instance hierarchy sidebar and client-only DUT sections), `hierarchyCurrent.js`
(the current-path highlight; `media/hierarchy.{js,css}` set `data-lit`),
`commentScan.js`/`commentKeywords.js` (the grammar-mirroring comment scan
and its decorations), `referencesView.js`/`referencesModel.js`, `typing.js`,
`mcp.js`, `extract.js`
(the module-name input and extract command), (the module-name input and extract command),
`smoke.js` (headless handshake check) and `restart_test.js` (headless check of `smoke.js` (headless handshake check) and `restart_test.js` (headless check of
that chain, against a scripted fake client), `README.md` (the Marketplace that chain, against a scripted fake client), `README.md` (the Marketplace
Details page, owned by editor-marketplace-page). Details page, owned by editor-marketplace-page).
**`tools/`** — besides the release and corpus scripts (§1.2), `gates.sh`
(every gate as a guarded step; the release runs it first) and
`linux_check.sh` (a command against the working tree in the Linux job image,
over ssh, no push).
--- ---
**`docs/site`** — Astro/Starlight content in `src/content/docs/`, sidebar and **`docs/site`** — Astro/Starlight content in `src/content/docs/`, sidebar and
@@ -343,13 +367,23 @@ output after content changes, and keep historical measurements dated.
| walk-cycles / small-items-4 | core directory identity set and warning sink ↔ CLI/server walk callers; parser delay-comment fields and `ExprKind::Type` → formatter and instance planning | Released in v0.43–0.44; warning paths continue without changing CLI status, direct missing inputs remain errors | | walk-cycles / small-items-4 | core directory identity set and warning sink ↔ CLI/server walk callers; parser delay-comment fields and `ExprKind::Type` → formatter and instance planning | Released in v0.43–0.44; warning paths continue without changing CLI status, direct missing inputs remain errors |
| didopen-cost | `undriven-net` local guards → existing `MentionOracle` predicate; diagnostics equality → server publish/request ordering | Released in v0.44.0; no new async work or index API | | didopen-cost | `undriven-net` local guards → existing `MentionOracle` predicate; diagnostics equality → server publish/request ordering | Released in v0.44.0; no new async work or index API |
| type-name-spans | parser `DataType::name_span`/`segments`, disable-target span → binder `exact_or_empty` and census | Released in v0.45.0; `scan.rs` deleted; source text remains the exact-span oracle | | type-name-spans | parser `DataType::name_span`/`segments`, disable-target span → binder `exact_or_empty` and census | Released in v0.45.0; `scan.rs` deleted; source text remains the exact-span oracle |
| package-reexports | binder export references → `FileFacts` RX group (introduced at codec 18, now 19) ↔ workspace `reexport.rs` and shared member queries | Released in v0.45.0; package exports add no local import; DPI-export names remain unbound | | package-reexports | binder export references → `FileFacts` RX group (introduced at codec 18; the codec is 22 now) ↔ workspace `reexport.rs` and shared member queries | Released in v0.45.0; package exports add no local import; DPI-export names remain unbound |
| hierarchical-tail | `Surface` tags on declarations/references, codec 19 ↔ `workspace/hierarchy.rs`, member-tail resolution, completion and rename source selection | Released in v0.45.0; §2.9-23 closed; connection surface stays unchanged, instance tails read the hierarchical surface | | hierarchical-tail | `Surface` tags on declarations/references, codec 19 ↔ `workspace/hierarchy.rs`, member-tail resolution, completion and rename source selection | Released in v0.45.0; §2.9-23 closed; connection surface stays unchanged, instance tails read the hierarchical surface |
| expand-wildcard / convert-to-ansi | `ports/{expand,ansi,merge}.rs` ↔ whole-edit verifier; server `ports.rs`, commands and action titles ↔ extension manifest; refactor → formatter test-only edge | Released in v0.46.0; explicit unmatched-port warnings and conservative merge/refusal rules | | expand-wildcard / convert-to-ansi | `ports/{expand,ansi,merge}.rs` ↔ whole-edit verifier; server `ports.rs`, commands and action titles ↔ extension manifest; refactor → formatter test-only edge | Released in v0.46.0; explicit unmatched-port warnings and conservative merge/refusal rules |
| organize-imports | semantic `imports.rs` → linter `unused-import` and refactor `imports.rs`; server `imports.rs` ↔ `source.organizeImports` / `lucisv.organizeImports` | Released in v0.47.0; 74 rules, new rule default off; package re-exports count as usage | | organize-imports | semantic `imports.rs` → linter `unused-import` and refactor `imports.rs`; server `imports.rs` ↔ `source.organizeImports` / `lucisv.organizeImports` | Released in v0.47.0; 74 rules, new rule default off; package re-exports count as usage |
| extract / inline module | refactor `extract/`, `inline/`, `check/ledger.rs`, `RefactorEdit::created` ↔ server `extract.rs`, `inline_module.rs`, source selectors and client resource capabilities; extension `extract.js` ↔ name prompt | Extract v0.47.0, inline v0.49.0; file copies/moves preserve protected pieces; open §2.9-32/33 | | extract / inline module | refactor `extract/`, `inline/`, `check/ledger.rs`, `RefactorEdit::created` ↔ server `extract.rs`, `inline_module.rs`, source selectors and client resource capabilities; extension `extract.js` ↔ name prompt | Extract v0.47.0, inline v0.49.0; file copies/moves preserve protected pieces; open §2.9-32/33 |
| dut-hierarchy | extension `hierarchySections.js` ↔ model/view, manifest commands, `lucisv.hierarchy.duts`, workspace state; consumes unchanged `lucisv/moduleHierarchy` snapshot | Delivered in v0.48.0, package corrected in v0.48.2; configured DUTs are locked, saved and configured names union | | dut-hierarchy | extension `hierarchySections.js` ↔ model/view, manifest commands, `lucisv.hierarchy.duts`, workspace state; consumes unchanged `lucisv/moduleHierarchy` snapshot | Delivered in v0.48.0, package corrected in v0.48.2; configured DUTs are locked, saved and configured names union |
| coverage-gaps-l | new `randsequence` AST/parser/formatter modules and six grammar additions → all AST walkers and grammar keyword lock; `Config::uvm_utils_indent` ↔ core `[format]`, CLI config merge, server setting and extension manifest | Released in v0.49.0; default-off output option; cache-key omission open in §2.9-34 | | coverage-gaps-l | new `randsequence` AST/parser/formatter modules and six grammar additions → all AST walkers and grammar keyword lock; `Config::uvm_utils_indent` ↔ core `[format]`, CLI config merge, server setting and extension manifest | Released in v0.49.0; default-off output option; cache-key omission open in §2.9-34 |
| release-gates | `.gitea/workflows/release.yml` runs `tools/gates.sh` before `release.sh --cross`; `gates.sh` step list/limits ↔ `docs/features/release-gates`, `tools/RELEASING.md`; `cross` step ↔ the rustup toolchain `release.sh --cross` builds with | Released in v0.65.1 (gate) and v0.65.7 (`cross`); release still gated on macOS only (§2.9-57) |
| hierarchy-current-path | extension `hierarchyCurrent.js` ↔ `hierarchyView.js` ↔ `media/hierarchy.{js,css}` (`lit` row field + `{type:'lit'}` message); `hierarchySections.headerId` now exported; manifest colours `lucisv.hierarchyCurrent`/`Parent1–3`/`Ancestor`/`CurrentBar` + `lucisv.hierarchy.highlightCurrent`; consumes the unchanged schema-2 snapshot | Released in v0.65.2; extension-only, no server change; not yet seen in a running editor |
| comment-highlighting | extension `commentScan.js` mirrors the grammar's `comments`/`strings` rules (locked by `commentScan_test.js`) ↔ `commentKeywords.js` decorations ↔ manifest `lucisv.commentKeywords.{builtIn,custom,caseSensitive}` + colour `lucisv.commentKeyword`; `.vscodeignore`/`RELEASING.md` runtime-module list | Released in v0.65.3; grammar and server unchanged; bracket colour in comments is VS Code's (explained, not changed) |
| ifdef-folding | server `folding/directives.rs::branch_spans` (reads lexer `Directive` tokens) → `folding.rs` (`scope_and_comment_folds` / `branch_folds` / `in_answer_order`) ↔ sticky scroll via the extension's `foldingProviderModel` (§67) | Released in v0.65.4; existing folds byte-identical and first on a shared start line; large buffers still fold nothing |
| format-styles | formatter `style.rs` (`Style`, `PRESETS`, `preset`, `names`), `auto.rs` (`format_auto`, `resolve_style`), `align::plan(mode)`, `Config::{style, auto_style, styled, named, style_name}` ↔ core `STYLE_NAMES`/`parse_style`/`FileConfig::format_style`, cache `Entry::style` (seven-field line) ↔ CLI `--style`, MCP `format`/`diagnostics`, server `settings.rs` `lucisv.format.style`, `auto_style.rs`, `lint.rs` line-length ↔ manifest enum | Released in v0.65.5 (server lint width v0.65.6); default `lucisv` byte-identical; `verify.rs` untouched; open §2.9-44/47 |
| localized-reindex | semantic `workspace/{dependents,references,replace}.rs` (readers table, in memory, in `fingerprint`), `update_file`/`update_facts -> bool`, `symbols_named`, `FileFacts::{declares_the_same, declared_names}` ↔ server `state/incremental.rs` (`OneFile`), `state/watched.rs` (`Watched`), `watch::{scope_files, names_a_config}`, `IncludeGraph::{update_held, add_known, refresh_naming}`, `Candidates::{set_file_words, refresh_names}`, `server/index.rs` `BURST_DIVISOR` | Released in v0.65.6, published as v0.65.7 (Windows fix); no `FACTS_FORMAT` change; open §2.9-48/49/51 |
| scan-ordering | server `server/mod.rs` `must_hold`/`behind`/`hold`, `server/batch.rs::changes_state`, `opened_mid_scan` set in `notification.rs`'s `didOpen` arm and read in `index.rs::answer_what_is_waiting`; `caret.rs::symbol_offset` → `dispatch.rs` `Server::symbol_offset` (nine requests); extension `referencesView.js` opens rows at the name's start | Released in v0.65.8; amended in v0.65.11 (fast-actions: `owes_a_state_change` — the answer to a settings pull is ordered like a notification); open §2.9-50/52/53 |
| linux-test-portability (Round 2) | `lucisv_mcp` `project/files.rs` `Stamp` (`identity: Option<Identity>`, `read_mono`, `RACY` 3 s over mtime and ctime, `Change::Suspect`) ↔ every index-based MCP tool; `ci.yml` `linux` job ↔ `tools/linux_check.sh` (same image, no push) | Released in v0.65.9; test code plus the one MCP product fix; open §2.9-54–57 |
| viewport-highlight | server `server/viewport.rs` (`colours_may_go_ahead`, `coloured_ahead`, `index_unsettled`, `refresh_tokens_if_stale`, `Viewport::defers_widen`) and, since 0.65.11, `server/ahead.rs` (`answer_from_the_buffer`, `set_aside`, `open_then_widen`, `answer_ahead_mid_widen`) ↔ `must_hold`/`behind`/`held`/`dirty` (scan-ordering) ↔ `dispatch.rs::answer_flushed` ↔ `index.rs::reindex_widened`; `tokens::semantic_tokens_in_range` + `large::line_window` + `tokens/instantiation.rs::overrides_within`; `ClientAbilities::semantic_tokens_refresh` (`main.rs`) | Released in v0.65.10; non-colour answers unchanged (978 compared); the early-answer machinery moved to `ahead.rs` in v0.65.11 (pure move); open §2.9-58–60 |
| fast-actions | server `server/ahead.rs` (`answer_from_the_buffer` — the one precondition —, `REACH`/`Reach`, `Server::can_reach`, `nothing_unapplied_for`, `settings_awaited`, `answer_ahead_of`, `answer_held_ahead`) ↔ `same_file.rs` (`METHODS`, `answered_by_the_buffer`; its README table pinned to the dispatch by `same_file/tests.rs`) ↔ `server/mod.rs` (`must_hold`, `owes_a_state_change`, `settings_announced`) ↔ `server/diagnostics.rs::flush_buffer` ↔ `server/large_file.rs::reclassify_large_buffers` ↔ `viewport.rs` (`index_unsettled` also while anything is held); `completion/related.rs` (sortText `4`, `RELATED_LIMIT`, tiers renumbered `4→5`…`7→8`, `tests/e2e.rs` digits) and `completion/wire.rs` ↔ `ClientAbilities::completion_item_defaults` (`main.rs`); `includes::include_at`, `type_def::type_name`, `candidates::macro_of` now `pub(crate)` | Released in v0.65.11 (TODO §71.2) after an escalation round; no `vlog_semantic` change; scan-ordering's response exemption amended; `completionItem/resolve` measured, not built; open §2.9-61–64; not seen in a running VS Code |
The lazy action resolves against current workspace state and rejects a stale The lazy action resolves against current workspace state and rejects a stale
or inapplicable action. Indexed definition locations bypass closed-file reads or inapplicable action. Indexed definition locations bypass closed-file reads
@@ -649,6 +683,19 @@ engine-lane features are listed above; this table is the server-internal web.
| `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. | | `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. | | `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. | | `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. |
| `localized-reindex ◀──▶ incremental-index / workspace-index / include-nav / file-watching / completion-core` | handshake | (2026-11-19, TODO §71.1, 0.65.6) A save costs the file plus the readers of what moved. `vlog_semantic`: `update_file`/`update_facts` return whether the index moved; `workspace/dependents.rs` records, through a thread-local `note`, which files' resolution read which merged-table key; `replace.rs` re-merges only the keys either record names and `references.rs` re-does postings only for those keys' readers. In memory, no codec change, rendered in `fingerprint` so every equality test holds it to a rebuild. Server: `update_one_file -> OneFile { NotHeld, Unchanged, Changed }` — `Unchanged` sends no `codeLens/refresh` or `moduleHierarchyChanged` but still republishes every open buffer; `Workspace::watched -> Watched { Held, Outside, Unknown }` — `Outside` re-resolves the include lines naming it (`refresh_includes_naming(&[PathBuf])`) and starts no rescan, another spelling of a held file is one-file; a `lucisv.toml` event is now a whole rescan; a burst naming more than half the index (`BURST_DIVISOR`) keeps the one rescan. The amended fast-path table lives in the feature README; the invariant (any edit sequence answers as a fresh server) is its differential suite. Cost: the readers table on every whole merge, CLI and MCP included. |
| `localized-reindex ◀──▶ format-styles` (`lint.rs`) | handshake | `line-length`'s width is `file.line_length.or(client.line_length)`, else the style's width (`file.format_style.or(client.style)` → `vlog_formatter::style::preset`), else 100 — the ladder `format::indent_width` and `lucisv check` walk; `auto` names no preset. Pinned rung by rung against the CLI's ladder. |
| `scan-ordering ◀──▶ scan-interleave / cancel-request / change-debounce` | handshake | (2026-11-19, TODO §71.7, 0.65.8) **No notification overtakes an older notification.** `Server::must_hold(message)` replaces `must_wait() && Request` in `process_batch`: a request waits on `must_wait` (unchanged); a state-changing notification (`batch::changes_state`: any but `$/cancelRequest`) waits while an older one is unapplied — in `held`, or counted by `Server::behind` (the unapplied notifications in the tail of the burst whose message started the scan now draining); a cancel waits whenever anything is held; a response is never held — **amended in 0.65.11 (fast-actions)**: the client's answer to a `workspace/configuration` pull is applied by the same `apply_settings` a push is, so it is ordered like a notification (`Server::owes_a_state_change` = `changes_state` or an unapplied settings answer replaces `changes_state` in what `behind` counts and in both state-change clauses of `must_hold`); every other response stays exempt, and staging still takes the answer out of `held` first (`take_the_answer_out_of_held`). A held request is answered against whatever is applied when it is replayed (not "no notification overtakes a request"). A `didOpen` changes scan order where it is *applied* (`head_owed` + `opened_mid_scan` in `notification.rs`, read once per batch by `answer_what_is_waiting`; `batch::opened_in` deleted), so a held batch is handed back at most once per file opened. Any new caller of `process_batch` inherits the rule; anything applying a client message around it breaks it. |
| `scan-ordering ──▶ hover / nav / references-nav / refactor-rename / hierarchy / type-hierarchy` (caret) | depends | `caret::symbol_offset(text, caret)` steps one byte left when the caret is just past a name (identifier, keyword, system task, macro, number, escaped identifier) and not at the start of another; `Server::symbol_offset` (`dispatch.rs`) applies it for hover, definition, typeDefinition, references, documentHighlight, prepareRename, rename and the two hierarchy prepares. Linked editing, signature help, completion/inline completion, on-type, selection range and code actions keep `Server::offset` on purpose; a new "name under the cursor" request should use `symbol_offset`. The feature README tables every position-taking request. Extension half: `referencesView.js` opens a row at the name's start. MCP answers by name and is unaffected. |
| `viewport-highlight ◀──▶ scan-ordering / semantic-tokens-delta / large-file-mode` | handshake | (2026-11-19, TODO §71.3, 0.65.10) The first exemption from held-request order: before `process_batch` holds a `semanticTokens/{range,full,full/delta}` request, it is answered through `answer_flushed` (dispatch minus `flush_dirty`) when its buffer's text is current. **Since 0.65.11 the decision is fast-actions' `Server::answer_from_the_buffer` in `server/ahead.rs`** (moved there from `viewport.rs` as a pure move, with `set_aside` and `open_then_widen`), so clauses (a)/(b) are shared with every early answer: the buffer open, `behind == 0`, and nothing older in `held` or in the burst `ahead` of it that `REACH`/`Server::can_reach` cannot clear (a watcher event still does not hold a colour; a settings push now does — before, a notification naming no buffer passed for harmless, QA's S1). What stays the colours' own (`viewport.rs`): `colours_may_go_ahead` (without `refreshSupport` only `range` goes), a dirty buffer waits instead of being analyzed, they go during staging, never ahead of a notification about to be applied (`answer_ahead_of` takes `same_file` requests only), and `coloured_ahead` marks a range taken off an unsettled index. Reads that one `Document`, its overlay as of the last publish, `has_large_documents`/`Document::large`/`token_server_cancel`, and the remembered tokens — never the index, another buffer, a flush or a publish. Every whole answer goes through `remember_tokens`, so a `previousResultId` always names data the client holds. Responses leave out of arrival order for these three methods and fast-actions' `same_file::METHODS` only. |
| `viewport-highlight ──▶ index-scope / scan-interleave` (widen and refresh) | depends | A `didOpen` that widens is applied through `open_then_widen`: `Viewport::defers_widen` records the widen, the burst's colouring requests are answered, then `reindex_widened` runs and `answer_ahead_mid_widen` (`server/ahead.rs`, 0.65.11; `answer_colours_mid_widen` before) drains between files (what can go ahead answered — colours and, since 0.65.11, `same_file` requests — everything else to `held`). `refresh_tokens_if_stale`, called by `run` once `held` is empty, sends at most one `workspace/semanticTokens/refresh` per `hierarchy_revision`, only if a buffer answered while `index_unsettled` (scan running/owed, `Viewport::widening`, or — since 0.65.11 — anything held) would colour differently (`early`) or was painted by a range (`guessed`). `semantic_tokens_in_range` classifies the range's lines (`large::line_window`, `overrides_within`) and still equals the full answer filtered. |
| `ifdef-folding ──▶ references-nav (folding) / editor-scopes / large-file-mode` | depends | (2026-11-19, TODO §71.4, 0.65.4) `folding/directives.rs::branch_spans` reads the lexer's `TokenKind::Directive` tokens (so comments, strings and `` `define `` bodies never fold) and yields one `region` fold per `` `ifdef ``/`` `ifndef ``/`` `elsif ``/`` `else `` branch; `folding_ranges` = `scope_and_comment_folds` (the old answer, verbatim) + `branch_folds` (dropping any `(start, end)` an existing fold has), merged by `in_answer_order` (start line, existing first on a tie). Sticky scroll pins the branch line through the extension's `foldingProviderModel` (§67). A large buffer has no tokens and still answers `[]`. The directive-word rule is a private copy (also in `parser/directive.rs` and `on_type/auto_end.rs`). |
| `instance-folding ──▶ ifdef-folding / references-nav (folding) / call-hierarchy (`instantiations::sites`) / large-file-mode` | depends | (2026-11-19, TODO §72) `folding/instances.rs::instance_spans` takes *what* is an instantiation from `vlog_semantic::instantiations::sites` (the walk the call hierarchy, inlay hints and index share; gate primitives excluded) and *where* its closers are from the token stream, folding nothing unless the tokens spell exactly the shape the tree says. One `region` fold from the module-type line to the line before `;`, one more per instance from its name line to the line before its `)`. `folding_ranges` = scopes/comments + branches + instances through `in_answer_order` (now a stable sort by start line over the sources in that order), so on a shared start line an instance fold yields to both older sources and the pre-§72 answer is an unchanged subsequence. A large buffer still answers `[]`. Not folded: 2-D instance arrays (the parser does not read them as instantiations), an instance whose head an `` `ifdef `` splits. |
| `comment-highlighting ◀──▶ editor-packaging` (grammar) | handshake | (2026-11-19, TODO §71.8, 0.65.3) Extension only: `commentScan.js` re-implements the grammar's `comments` and `strings` rules to find comment bodies; `commentScan_test.js` fails on any change to those two rules, on a reordering that moves them off the top, or on another top-level rule that could match `/` or `"` — a grammar edit updates `commentScan.js` in the same change (the `tests/grammar.rs` keyword lock is separate and untouched). `commentKeywords.js` paints visible lines ±50, honours `editor.maxTokenizationLineLength`. Server side: nothing — the three `lucisv.commentKeywords.*` keys arrive in `didChangeConfiguration` and `settings.rs` ignores them; semantic tokens were measured to colour nothing inside a comment. |
| `format-styles ◀──▶ editor-settings / format-cache / selection-formatting / on-type-formatting` | handshake | (2026-11-19, TODO §71.5, 0.65.5) One name list, three pins: `PRESETS` (`vlog_formatter/src/style.rs`) + `auto` = `lucisv_core::config::STYLE_NAMES` (`args::tests::the_core_style_names_are_the_formatter_presets`) = the manifest's `lucisv.format.style` enum and descriptions (`settings::tests::the_style_drop_down_is_the_style_names`). Ladder: explicit `indent`/`line-length` over the style's numbers; `lucisv.toml` over the editor. Server: `auto_style.rs::AutoStyles` remembers per document the preset `format_auto` chose; whole-document formats set it, range/ranges/on-type/selection reuse it (`concrete`); forgotten on open/close/rename/delete, a whole-buffer replacement, a named-style format, any settings change and a `lucisv.toml` event — three call lines in `notification.rs` (`notice`, `changed`, `forget_all`). The cache entry carries the style, so changing it invalidates verdicts. |
| `hierarchy-current-path ──▶ vscode-hierarchy-sidebar / dut-hierarchy` | depends | (2026-11-19, TODO §71.6, 0.65.2) Extension only, no server request: `hierarchyCurrent.js` (`matchingFiles`, `currentPath` — BFS up `hierarchySections.parentIndex`, nearer distance wins — `rowLevels`, `levelChanges`, `LIT_COLORS`/`litLevel`/`cssVariableFor`) reads the schema-2 snapshot's `definition.file`. `hierarchyView.js` follows `onDidChangeActiveTextEditor` and posts `{type:'lit', changes}`; a rendered row carries `lit: 0..4` only when lit, so an unlit pane's rows are byte-identical to before. `media/hierarchy.{js,css}` set `data-lit`. Matching compares the model's URIs, so a case-differing folder or a UNC path (server `uri.rs` writes `file:////srv/…`) never lights. |
| `fast-actions ◀──▶ scan-ordering / viewport-highlight / large-file-mode / cancel-request` | handshake | (2026-11-19, TODO §71.2, 0.65.11) **A request whose whole answer is its buffer's is answered from it at once, even while a scan holds everything else, and its answer is the settled answer.** The precondition is stated once, on `Server::answer_from_the_buffer` (`server/ahead.rs`), the one function that decides: for the buffer the request names (a) it is open; (b) every older client message that can change what the handler reads is applied — `nothing_unapplied_for` reads `held` and the burst `ahead` through `Server::can_reach`, and requires `behind == 0`; (c) its analysis is current — a dirty buffer is analyzed for its own request alone (`Server::flush_buffer`, `server/diagnostics.rs`), a colouring request on a dirty buffer waits; (d) no settings are awaited (`settings_awaited` = `staging` or `Server::settings_announced`, the pull an empty `didChangeConfiguration` caused); (e) the answer is the buffer's alone — `same_file::answered_by_the_buffer` (`same_file.rs`, twelve `METHODS`; completion, inlay hints, code lenses, links and every workspace-wide request always wait) or `viewport.rs`'s rule for colours. Where a request is offered: `process_batch` → `answered_ahead`, `set_aside`, `answer_ahead_of` (behind the next notification of its own burst, `same_file` requests only), `open_then_widen`, `answer_ahead_mid_widen`, `answer_held_ahead` (when the startup's settings land) — the same function at each. **`ahead::REACH`** is one row per notification `handle_notification` handles (`Reach::{Nothing, Named, Any}`); a method without a row reaches `Any`, so **a new notification arm needs a `REACH` row — the default is wait** — and `every_notification_the_server_handles_says_which_buffers_it_can_reach` fails until it has one; a handler that starts changing a buffer it does not name must move its row to `Any`; a new `Pending` kind must be classified in `can_reach` (exhaustive `match`). **With viewport-highlight:** the early-answer path moved from `viewport.rs` to `ahead.rs` and the colours share it (row above). **With scan-ordering (amended):** the client's answer to a settings pull is ordered like a notification (`owes_a_state_change`); every other response stays exempt. **With large-file-mode:** `reclassify_large_buffers` (`server/large_file.rs`, called from `apply_settings`) re-analyzes every clean open buffer a new `largeFile.threshold` classifies differently and re-requests colours — a new threshold no longer waits for each buffer's next edit (large-file-mode's prose saying so is stale, its test renamed). Responses for the early kinds go out ahead of older held requests (allowed by the spec); a burst's cancel is honoured where it goes ahead. Proof: `server/tests/fast_actions_differential.rs` (early == settled), `fast_actions_bursts.rs` (the burst differential; its oracle's weakness is §2.9-62). |
| `fast-actions (related tier, payload) ◀──▶ completion-core / fuzzy-completion / member-completion` | handshake | (2026-11-19, TODO §71.2, 0.65.11) `completion/related.rs`: a tier between the file's own (`1`–`3`) and the workspace's, sortText `4` (`TIER_RELATED`); index `4→5`, templates `5→6`, keywords `6→7`, project words `7→8` (`tests/e2e.rs`'s digits moved). Its sources: the members of every package the scope chain at the cursor imports (`WorkspaceIndex::members_of`; a wildcard all, an explicit import the one it names), the members the enclosing class inherits (`members_of_chain`), and after a backtick the `` `define``s of the headers the buffer's `` `include``s reach (`includes::reachable_from` → `WorkspaceIndex::defines`); prefix and fuzzy rules as the other tiers. **No item is taken away:** a related item does not count against `LIMIT` (`Items::related`) and a name it claims is skipped by later tiers without being counted, so every label of the 0.65.10 answer is still offered with the same edit and format; what changes for a claimed name is its icon and detail (the declaration the file is related to). Own cap `RELATED_LIMIT` (256), past which the answer is `isIncomplete`. `completion/wire.rs`: for a client listing `editRange` and `insertTextFormat` in `completionList.itemDefaults` (`ClientAbilities::completion_item_defaults`, read in `main.rs` by `completion::item_defaults_support`), `with_item_defaults` rewrites the serialized list — lossless, an item keeps its own edit or format when it differs; done on JSON because `lsp-types` 0.97 has neither field. Completion is never answered early (every path reads the index). `completionItem/resolve` is measured, not built. |
### 2.8 Packaging & release lane ### 2.8 Packaging & release lane
@@ -666,6 +713,9 @@ engine-lane features are listed above; this table is the server-internal web.
| `release-prep / editor-platform-vsix ──▶ lucisv-mcp` (mcp-packaging) | depends | `release.sh` builds `-p lucisv_mcp` for every triple and stages it as the THIRD `bin/` entry (fifteen in the `all` package); `expect_vsix_bins` and `audit_artifacts.sh` pin the name; the seven `.vsix` names are unchanged. `mcp_smoke.js` is the gate beside `smoke.js`. | | `release-prep / editor-platform-vsix ──▶ lucisv-mcp` (mcp-packaging) | depends | `release.sh` builds `-p lucisv_mcp` for every triple and stages it as the THIRD `bin/` entry (fifteen in the `all` package); `expect_vsix_bins` and `audit_artifacts.sh` pin the name; the seven `.vsix` names are unchanged. `mcp_smoke.js` is the gate beside `smoke.js`. |
| `lucisv-mcp ──▶ lucisv-server` (index cache, M6) | depends (read-only) | MCP reads the server's `index-cache` store read-only when `--index-cache DIR` names it (header `CACHE_FORMAT`/`FACTS_FORMAT`/version must match, else ignored) and writes its own `index-cache-mcp` beside it; it never writes the server's file. A codec change on the server side costs MCP its warm start, never its correctness. | | `lucisv-mcp ──▶ lucisv-server` (index cache, M6) | depends (read-only) | MCP reads the server's `index-cache` store read-only when `--index-cache DIR` names it (header `CACHE_FORMAT`/`FACTS_FORMAT`/version must match, else ignored) and writes its own `index-cache-mcp` beside it; it never writes the server's file. A codec change on the server side costs MCP its warm start, never its correctness. |
| `editor-packaging ◀──▶ lucisv-mcp` (mcp-read-only, M8) | handshake | The read-only mode (2026-09-29, PLAN §11): setting `lucisv.mcp.mode` (`"full"` default / `"read-only"`) appends `--read-only` to the spawn args and labels the definition `lucisv read-only (<folder>)`; copy-config keys it `lucisv-ro`. The binary then lists exactly `hierarchy, find, outline, read, check` (≤ 1 800 model-visible bytes, instructions ≤ 300), answers the four edit names with `-32602` `unknown tool: NAME (the server runs --read-only)`, and writes nothing inside a root (`tests/read_only.rs`); full mode is byte-identical to 0.58.0. `mcp_smoke.js --read-only` is the second MCP gate in `release.sh`, host and embedded. | | `editor-packaging ◀──▶ lucisv-mcp` (mcp-read-only, M8) | handshake | The read-only mode (2026-09-29, PLAN §11): setting `lucisv.mcp.mode` (`"full"` default / `"read-only"`) appends `--read-only` to the spawn args and labels the definition `lucisv read-only (<folder>)`; copy-config keys it `lucisv-ro`. The binary then lists exactly `hierarchy, find, outline, read, check` (≤ 1 800 model-visible bytes, instructions ≤ 300), answers the four edit names with `-32602` `unknown tool: NAME (the server runs --read-only)`, and writes nothing inside a root (`tests/read_only.rs`); full mode is byte-identical to 0.58.0. `mcp_smoke.js --read-only` is the second MCP gate in `release.sh`, host and embedded. |
| `release-gates ──▶ release-prep` (`cross` step) | depends | (0.65.7) `cargo check --target x86_64-pc-windows-gnu --target x86_64-unknown-linux-musl -p lucisv -p lucisv_server -p lucisv_mcp`, with the rustup toolchain `release.sh --cross` uses (`~/.rustup/toolchains/stable-aarch64-apple-darwin`). Binaries only, not `--all-targets`, so test-only platform code is not checked (§2.9-56). **Skipped with a note, not failed, when that toolchain is absent** — a gate run on a machine without it does not prove the cross build (§2.9-66). |
| `ci.yml linux job ◀──▶ tools/linux_check.sh` | handshake | (0.65.9, TODO §70) `ci.yml`'s `linux` job (`runs-on: linux-x64`, the luhpe runner, as root, 4 CPU / 8 GB, rustup per job, cold build) runs `cargo clippy --all-targets -- -D warnings` and `cargo test --workspace`. `tools/linux_check.sh [--user] [--dry-run]` runs a command against the working tree in the same job image without a push (tracked + unignored untracked files, one run at a time). The suite is root-safe: permission tests probe whether modes bind and say `skipped:` when not; growth tests bound ratios, not wall clock. Linux is tested on push, but releases are gated on macOS only (§2.9-57). |
| `lucisv-mcp ──▶ filesystem` (`project/files.rs` stamp) | depends | (0.65.9) A held file is current when size, mtime and `identity` (ctime + inode, `Option` — `None` on Windows) match its `Stamp`; any trusted timestamp within `RACY` (3 s) of `read_at`, or a wall clock that stepped back since the read (`read_mono`), makes it `Change::Suspect` and it is re-read and re-hashed (git's racily-clean rule, now over ctime too). Known blind spots, in `docs/features/mcp-transport`: on Windows a same-size rewrite restoring an mtime > 3 s old; writes through a memory map not yet reflected in timestamps; future mtimes re-read on every call (§2.9-54). The server's index cache and the `index-cache-mcp` store contract are unchanged. |
### 2.9 Open handshakes (filed, not yet delivered — claim before working) ### 2.9 Open handshakes (filed, not yet delivered — claim before working)
@@ -717,6 +767,29 @@ update the filing README(s) and this file.
| 41 | **MCP-13 → `vlog_linter`:** a forced deletion of a non-ANSI body port leaves a header port with no direction and no lint reports it | mcp-structural-edits | vlog_linter | | 41 | **MCP-13 → `vlog_linter`:** a forced deletion of a non-ANSI body port leaves a header port with no direction and no lint reports it | mcp-structural-edits | vlog_linter |
| 42 | **Parser leniency → `vlog_parser`:** a trailing `,` in a named connection list, an empty concatenation element `{d,, d}`, and `type(x)'(y)` in a connection parse without a diagnostic (the rename verifier's position rule covers the rename; every other splice contract is exposed) | refactor-rename (M3.5) | vlog_parser | | 42 | **Parser leniency → `vlog_parser`:** a trailing `,` in a named connection list, an empty concatenation element `{d,, d}`, and `type(x)'(y)` in a connection parse without a diagnostic (the rename verifier's position rule covers the rename; every other splice contract is exposed) | refactor-rename (M3.5) | vlog_parser |
| ~~43~~ | ~~**MCP-14 → `vlog_refactor`/`vlog_semantic`:** rename of a generate block label leaves hierarchical paths through it unrewritten and `find_references` does not report them — vlog_refactor/vlog_semantic; the MCP layer refuses the rename; the LSP still allows it~~ — **closed 2026-09-30 by generate-label-rename (TODO §65.1, 0.60.0):** the gap was resolution, not the rename — `vlog_semantic` now declares a `for` block's label in the enclosing scope (the genvar stays in the header), treats `generate … endgenerate` as no scope, gives a named block a member scope, walks an index in a path as the name it indexes, and puts blocks on a module's hierarchical surface with their members under the synthesized key `module.label` (`FACTS_FORMAT` 21; `Semantics::member_key`, which `lucisv_server/src/nav.rs` now asks with). Every segment — bare, indexed, nested, cross-file — and the closing label are ordinary references, so `find_references`, `rename` (LSP, CLI engine, MCP) and the verifier's unchanged resolution print all see them; no verifier normalization was added, eight attacks pin that (`check/qa_block_paths.rs`). `lucisv-mcp`'s `block` refusal is lifted. Also answers row 40's second half (`gen_l[0].z` is found). | mcp-lean-catalogue | vlog_refactor, vlog_semantic | | ~~43~~ | ~~**MCP-14 → `vlog_refactor`/`vlog_semantic`:** rename of a generate block label leaves hierarchical paths through it unrewritten and `find_references` does not report them — vlog_refactor/vlog_semantic; the MCP layer refuses the rename; the LSP still allows it~~ — **closed 2026-09-30 by generate-label-rename (TODO §65.1, 0.60.0):** the gap was resolution, not the rename — `vlog_semantic` now declares a `for` block's label in the enclosing scope (the genvar stays in the header), treats `generate … endgenerate` as no scope, gives a named block a member scope, walks an index in a path as the name it indexes, and puts blocks on a module's hierarchical surface with their members under the synthesized key `module.label` (`FACTS_FORMAT` 21; `Semantics::member_key`, which `lucisv_server/src/nav.rs` now asks with). Every segment — bare, indexed, nested, cross-file — and the closing label are ordinary references, so `find_references`, `rename` (LSP, CLI engine, MCP) and the verifier's unchanged resolution print all see them; no verifier normalization was added, eight attacks pin that (`check/qa_block_paths.rs`). `lucisv-mcp`'s `block` refusal is lifted. Also answers row 40's second half (`gen_l[0].z` is found). | mcp-lean-catalogue | vlog_refactor, vlog_semantic |
| 44 | **A comment between a generate `end` and `else`** (also a trailing `// c` after a labelled generate `end` before `else`) is a verification error, so the file is left unformatted — the safety net works, the formatter should not need it. Present in 0.65.4 (TODO §71 wave 4) | format-styles (QA) | vlog_parser / vlog_formatter |
| 45 | **`` `ifdef `` between `end` and `else` is a parse error** (TODO §71 wave 4) | format-styles (QA) | vlog_parser |
| 46 | **An attribute on an ANSI port** (`(* keep *) input a`) is a parse error (TODO §71 wave 4) | format-styles (QA) | vlog_parser |
| 47 | **Multi-instance declarations under one-per-line styles** (`p1 u8 (...), u9 (...)`) get the hanging layout instead of the style's (TODO §71 wave 4; CHANGELOG 0.65.5 known limit) | format-styles (QA) | vlog_formatter |
| 48 | **Directory-only watcher events.** VS Code coalesces deletes under a removed folder into one folder event and the client's `**/*.{v,vh,sv,svh}` filter drops it, so the server receives nothing; a folder moved in is dropped likewise. Wanted: a second registration (`**/*`, `Create \| Delete`) and a handler expanding a folder to the held files and include lines under it — changes every client's registration and traffic, the owner's call (TODO §71 waves 5–6) | localized-reindex (QA P1); scan-ordering | owner decision, then lucisv_server (`main.rs`/`watch.rs`) |
| 49 | **A buffer the scope would not take stays indexed after `didClose`** (excluded or unlisted, taken in by a scan or the one-file path), and **closing an unsaved in-scope buffer a rescan indexed leaves its text in the index** (QA-7a). One root: a close does not touch the index. A one-file remove costs ~225 ms on OpenTitan (fixed and reverted in scan-ordering); wanted: a cheap removal, e.g. a tombstone the next scan or publish folds in (TODO §71 waves 5–6) | localized-reindex (QA P2); scan-ordering (QA-1, QA-7a) | vlog_semantic (index removal) / lucisv_server (`state/`) |
| 50 | **An unheld buffer opened while a scan runs is never taken in** by that scan or afterwards; opened before the scan it is held — the same final state answers differently by timing (TODO §71 wave 6) | scan-ordering (QA-2) | lucisv_server (`state/scan.rs`, `server/index.rs`) |
| 51 | **Symlinked files are held under one spelling or both** depending on what was open at scan time (`discover.rs`'s `Aliased`); incremental and rebuild answers disagree in all six `filelink.py` variants. Rule to adopt: one file, one spelling, whatever is open — in the walk, the overlay and the one-file path together (TODO §71 waves 5–6) | localized-reindex (QA P3); scan-ordering | lucisv_server (`state/discover.rs`, `state/incremental.rs`) |
| 52 | **A request held during a scan is answered against the newest text**, so a position-based request can resolve a different symbol when an edit moved the text under it; rename edits carry no document version for the client to reject (TODO §71 wave 6) | scan-ordering (QA) | lucisv_server (`server/`, `rename.rs`) |
| 53 | **Renaming a port of a module defined twice** gives an edit or a refusal at random across fresh servers (`top_englishbreakfast/ip/ast/rtl/adc.sv:81`, `qa717/drv/dup.py`); not diagnosed (TODO §71 wave 6) | scan-ordering (QA-7c) | vlog_refactor / lucisv_server (`module_select.rs`) — undiagnosed |
| 54 | **`lucisv-mcp` re-reads a file with a future mtime on every call**, forever (67 ms against 7 ms per `find` on 4 000 files) — the racy rule never settles (TODO §70) | linux-test-portability (Round 2) | lucisv_mcp (`project/files.rs`) |
| 55 | `crates/lucisv/tests/cli.rs:2149` (`a_stdin_buffer_reads_the_rule_options_too`) asserts only an empty stdout, no exit code (TODO §70) | linux-test-portability (Round 2) | crates/lucisv (tests) |
| 56 | `crates/lucisv_mcp/tests/qa_m3.rs` uses `std::os::unix` with no `cfg`, so `cargo check --all-targets` for Windows fails (tests only; the `cross` gate checks binaries only) (TODO §70) | linux-test-portability (Round 2) | lucisv_mcp (tests) |
| 57 | **Releases are gated on macOS alone**: Linux runs the suite in `ci.yml` but the release does not wait for it, and Windows is compile-checked (`cross`), never executed (TODO §70) | linux-test-portability (Round 2) | tools/ + CI (lead) |
| 58 | **The discovery walk at the start of every scan drains nothing** (25–80 ms on OpenTitan): what is left of the first-colour wait in workspace scope (62–86 ms late open) and the rescan hold (70–159 ms). Wanted: a resumable walk in `state/discover.rs` (it holds `&mut Workspace` throughout `begin_scan`), with its own identical-result proof (TODO §71 wave 7) | viewport-highlight (Handshake request 2) | lucisv_server (`state/discover.rs`) |
| 59 | **A `range` answered during a rescan always counts as a guess** (`Viewport::guessed`) and costs one refresh at settle even when nothing changed (TODO §71 wave 7) | viewport-highlight (QA) | lucisv_server (`server/viewport.rs`) |
| 60 | **An edit in one file that changes how another open file colours sends no refresh** (a package type renamed) — as before this lane (TODO §71 wave 7) | viewport-highlight | lucisv_server (`server/viewport.rs`) |
| 61 | **Inside the startup settings wait, the client's answer to the pull is applied ahead of an older settings push held with it** (`server/startup.rs`, `take_the_answer_out_of_held`); predates fast-actions; needs a client whose push and answer disagree in one burst (TODO §71 wave 8; fast-actions QA F1) | fast-actions (QA) | lucisv_server (`server/startup.rs`) |
| 62 | **`tests/fast_actions_bursts.rs`'s oracle accepts an answer the reference gives after any later message of the round**: 2–9 % of injected stale answers pass when a later message restores the state; every mutation is still caught and the directed tests lack the weakness (TODO §71 wave 8; fast-actions QA F4) | fast-actions (QA) | lucisv_server (tests) |
| 63 | **Whether a large open buffer is in the index depends on when it was opened, saved or scanned** — a fast-path buffer contributes nothing when open at scan or save time but keeps its disk record when opened after the scan; 77–98 answers differ between a settled session and a fresh server on OpenTitan. Predates fast-actions; wanted: always keep, or always drop, the disk record of a fast-path buffer at open, save, flip and scan alike (TODO §71 wave 8; fast-actions QA S2, Handshake request 8) | fast-actions (QA) | lucisv_server (`state/`, the index lane) |
| 64 | **The 40 000-file rescan after a delete takes either 12.3 s or 14.5–15.5 s**, on 0.65.10 and 0.65.11 alike; cause not found (TODO §71 wave 8) | fast-actions | undiagnosed (lucisv_server scan) |
| 65 | **`ci.yml` runs `cargo test --workspace` bare in both jobs**, not through `tools/guard.sh` as CLAUDE.md's runaway guard asks of every `cargo test`; predates 0.65.9 for the macOS job, the Linux runner is resource-capped. Recorded, not judged (topo refresh 2026-11-19) | topo refresh (draft discrepancy 10) | CI (lead) |
| 66 | **The `cross` gate step reports `SKIPPED (no toolchain)` rather than failing** when `~/.rustup/toolchains/stable-aarch64-apple-darwin` is absent, so a green `gates.sh` on another machine does not prove the cross build (topo refresh 2026-11-19) | topo refresh (draft discrepancy 11) | tools/ (`gates.sh`, lead) |
--- ---
@@ -736,15 +809,16 @@ untouched, reusing existing arms.
| module | features whose home it is | | module | features whose home it is |
|---|---| |---|---|
| `vlog_parser` | spans, name-spans, recursion-limit, error-recovery, define-table, lexer-cleanup, decomposition-parser, and the grammar lane: *macro-items*, *classes*, *bind*, *dynamic-types*, *types-decls*, *item-misc*, *directives-in-lists*, *directives-in-instances*, *dpi-export*, *assertions*, *interfaces*, *expressions-2*, *dv-statements*, *mop-up-2*, *directive-split*, *ansi-first-port*, *null-items*, *constraint-bodies*, *covergroup-bodies*, *fragment-mode*, *vendor-formal-grammar*, *comment-slots*, *bind-semantics*, *sva-bodies* (most also add formatter arms — parser+formatter pairs by default; directive-split and ansi-first-port reused existing arms and left `vlog_formatter/src` untouched) | | `vlog_parser` | spans, name-spans, recursion-limit, error-recovery, define-table, lexer-cleanup, decomposition-parser, and the grammar lane: *macro-items*, *classes*, *bind*, *dynamic-types*, *types-decls*, *item-misc*, *directives-in-lists*, *directives-in-instances*, *dpi-export*, *assertions*, *interfaces*, *expressions-2*, *dv-statements*, *mop-up-2*, *directive-split*, *ansi-first-port*, *null-items*, *constraint-bodies*, *covergroup-bodies*, *fragment-mode*, *vendor-formal-grammar*, *comment-slots*, *bind-semantics*, *sva-bodies* (most also add formatter arms — parser+formatter pairs by default; directive-split and ansi-first-port reused existing arms and left `vlog_formatter/src` untouched) |
| `vlog_formatter` | safety-net (`verify.rs`), case-tables, formatter-bug-fixes, corpus-bugs, comments-round, comments-round-2, alignment (`align.rs`), format-fences (`fence.rs`), range-formatting (`range.rs`), shared-fence-filter, decomposition-formatter, and the layout halves of constraint-bodies, covergroup-bodies, comment-slots, bind-semantics and sva-bodies (`format/`) | | `vlog_formatter` | safety-net (`verify.rs`), case-tables, formatter-bug-fixes, corpus-bugs, comments-round, comments-round-2, alignment (`align.rs`), format-fences (`fence.rs`), range-formatting (`range.rs`), shared-fence-filter, decomposition-formatter, and the layout halves of constraint-bodies, covergroup-bodies, comment-slots, bind-semantics and sva-bodies (`format/`), format-styles (`style.rs`, `auto.rs`, `align.rs` mode) |
| `vlog_semantic` | vlog-semantic (`bind/`, `resolve.rs`, `model.rs`), workspace-index (`workspace/`), decomposition-semantic, class-semantics, interface-semantics, class-member-access, struct-members, overlay-promotion, port-detail-spans (`Symbol`/`Def::detail_span` and `Semantics::symbols_named`), hover-line-index (`DeclLines`, facts codec), vscode-hierarchy-sidebar's declaration/instance positions, scan-interleave (`WorkspaceIndex::absorb`), semantic-lints-on's word census, bind-semantics and sva-bodies, refactor-rename's performance amendment (`files_spelling`), plus the index halves of indexing-ux (`index_order`/`IndexBuilder`), index-scope (order-insensitive `finish`, facts-from-analysis), incremental-index (`update_file`, edge/reference tables, `instantiations.rs`, `classes.rs`), index-persistence (`facts.rs`; `FACTS_FORMAT` 19; plus a small `vlog_parser::defines` touch — `DefineTable::from_entries`, `Eq` derives) | | `vlog_semantic` | vlog-semantic (`bind/`, `resolve.rs`, `model.rs`), workspace-index (`workspace/`), decomposition-semantic, class-semantics, interface-semantics, class-member-access, struct-members, overlay-promotion, port-detail-spans (`Symbol`/`Def::detail_span` and `Semantics::symbols_named`), hover-line-index (`DeclLines`, facts codec), vscode-hierarchy-sidebar's declaration/instance positions, scan-interleave (`WorkspaceIndex::absorb`), semantic-lints-on's word census, bind-semantics and sva-bodies, refactor-rename's performance amendment (`files_spelling`), plus the index halves of indexing-ux (`index_order`/`IndexBuilder`), index-scope (order-insensitive `finish`, facts-from-analysis), incremental-index (`update_file`, edge/reference tables, `instantiations.rs`, `classes.rs`), index-persistence (`facts.rs`; `FACTS_FORMAT` 22; plus a small `vlog_parser::defines` touch — `DefineTable::from_entries`, `Eq` derives), localized-reindex (`workspace/{dependents,references,replace}.rs`) |
| `vlog_linter` | linter-core, lint-harness, lint-rules-2, semantic-lints (`signals.rs`), semantic-lints-on (workspace oracle), one-parse (`context.rs`) | | `vlog_linter` | linter-core, lint-harness, lint-rules-2, semantic-lints (`signals.rs`), semantic-lints-on (workspace oracle), one-parse (`context.rs`) |
| `vlog_refactor` | refactor (plan), refactor-rename (including `prepare_rename_here` / `rename_name_at` selector half), refactor-ports (including module-target selectors), refactor-instantiate, references-nav (whole-scope equivalence oracle), and the refactor half of decomposition-semantic; expand-wildcard and convert-to-ansi (`ports/`), organize-imports (`imports.rs`), extract-inline-module (`extract/`, `inline/`, `check/ledger.rs`) | | `vlog_refactor` | refactor (plan), refactor-rename (including `prepare_rename_here` / `rename_name_at` selector half), refactor-ports (including module-target selectors), refactor-instantiate, references-nav (whole-scope equivalence oracle), and the refactor half of decomposition-semantic; expand-wildcard and convert-to-ansi (`ports/`), organize-imports (`imports.rs`), extract-inline-module (`extract/`, `inline/`, `check/ledger.rs`) |
| `lucisv_core` | lucisv-core-lift (`config.rs`, `walk.rs`), filelist (`filelist.rs`), format-cache (`cache.rs`) | | `lucisv_core` | lucisv-core-lift (`config.rs`, `walk.rs`), filelist (`filelist.rs`), format-cache (`cache.rs`), format-styles (`STYLE_NAMES`, cache `style` field) |
| `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` (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), format-styles (`--style`) |
| `lucisv_server` | lucisv-server (trunk), decomposition-server (`server/`, `completion/`), and one or two modules per capability feature: editor-scopes→`pairs.rs`, filelist→scope ladder in `state.rs`, include-nav→`includes.rs`, completion-core/fuzzy-completion/member-completion→`completion/`+`candidates.rs`, completion-templates→`templates.rs`, inline-templates→`inline.rs`, inline-instantiation→`inline.rs`+`completion/`+`candidates.rs` (+`settings.rs` key), bind-semantics→`instantiate.rs`, macro-expansion→`expand.rs`, hierarchy→`hierarchy.rs`, vscode-hierarchy-sidebar→`design_hierarchy.rs`, type-hierarchy→`type_hierarchy.rs`, type-definition→`type_def.rs`, code-lens→`lens.rs`, inlay-hints→`inlay.rs`, server-lint→`lint.rs`+`lint/project.rs`+`code_action.rs`, one-parse→`lint.rs`+`state.rs` (`Document.tree`), refactor wiring/performance fan-outs→`rename.rs`/`ports.rs`+`state.rs`, apply-edit+folders-and-config+cancel-request+work-done-progress→`server/`, editor-settings+indexing-ux+index-scope+index-persistence→`settings.rs`+`state.rs`(+`index_cache.rs`), incremental-sync→`sync.rs`, file-watching→`watch.rs`, file-operations→`file_ops.rs` (+`include_sources` in `state.rs`), pull-diagnostics→`diagnostics.rs`+`server/`, semantic-tokens-delta→`tokens.rs`+`server/semantic_tokens.rs`, on-type-formatting→`on_type.rs`, will-save-wait-until→`format.rs` (+`settings.rs`/`main.rs`), selection-range→`selection.rs`, linked-editing→`linked.rs`, references-nav (server half)→`folding.rs`+`nav.rs`, large-file-mode→`large.rs`+`server/large_file.rs`, lsp-318-extras→`format.rs` (+`main.rs` capability), hover-declarations→`hover.rs`(+`nav.rs`), port-detail-spans (server half)→`hover.rs`+`nav.rs`, hover-line-index→`hover.rs`+`locate.rs`+`state.rs`, scan-interleave/change-debounce/verbose-timing→`server/`+`state.rs`, perf5-p1→`fences.rs` (+ the `_at` helpers in `ports.rs`/`imports.rs`/`extract.rs`/`inline_module.rs`), perf5-p2→`rename_trace.rs`+`module_select.rs`, perf5-p4→`scan_trace.rs`+`scan_order.rs`+`server/startup.rs`+`state/scan.rs`, perf5r-first-answer→`state/discover.rs` (+ counters and the compaction skip in `index_cache.rs`), perf measurements→`src/perf.rs` (`docs/perf/README.md`, not a feature README), interactive-latency→`state.rs` (the two token searches) + `selection.rs`/`on_type.rs`/`completion/`/`inline.rs` (their callers) + `src/perf.rs`/`tests/e2e.rs` (its measurements), editor-packaging (grammar test)→`tests/grammar.rs` | | `lucisv_mcp` | the MCP block (`docs/features/mcp-*`), linux-test-portability Round 2 (`project/files.rs` stamp), format-styles (`format`/`diagnostics` take the style) |
| `editors/vscode` | editor-packaging, editor-snippets, editor-settings (manifest half), editor-scopes (rainbow half), vscode-hierarchy-sidebar (`hierarchyView.js`/`hierarchyModel.js`), dut-hierarchy (`hierarchySections.js`), extract-inline-module (`extract.js`), editor-platform-vsix, editor-marketplace-page, index-persistence (`storagePath` line), verbose-timing (`lucisv.verbose`, spawn args and restart in `extension.js`) | | `lucisv_server` | lucisv-server (trunk), decomposition-server (`server/`, `completion/`), and one or two modules per capability feature: editor-scopes→`pairs.rs`, filelist→scope ladder in `state.rs`, include-nav→`includes.rs`, completion-core/fuzzy-completion/member-completion→`completion/`+`candidates.rs`, completion-templates→`templates.rs`, inline-templates→`inline.rs`, inline-instantiation→`inline.rs`+`completion/`+`candidates.rs` (+`settings.rs` key), bind-semantics→`instantiate.rs`, macro-expansion→`expand.rs`, hierarchy→`hierarchy.rs`, vscode-hierarchy-sidebar→`design_hierarchy.rs`, type-hierarchy→`type_hierarchy.rs`, type-definition→`type_def.rs`, code-lens→`lens.rs`, inlay-hints→`inlay.rs`, server-lint→`lint.rs`+`lint/project.rs`+`code_action.rs`, one-parse→`lint.rs`+`state.rs` (`Document.tree`), refactor wiring/performance fan-outs→`rename.rs`/`ports.rs`+`state.rs`, apply-edit+folders-and-config+cancel-request+work-done-progress→`server/`, editor-settings+indexing-ux+index-scope+index-persistence→`settings.rs`+`state.rs`(+`index_cache.rs`), incremental-sync→`sync.rs`, file-watching→`watch.rs`, file-operations→`file_ops.rs` (+`include_sources` in `state.rs`), pull-diagnostics→`diagnostics.rs`+`server/`, semantic-tokens-delta→`tokens.rs`+`server/semantic_tokens.rs`, on-type-formatting→`on_type.rs`, will-save-wait-until→`format.rs` (+`settings.rs`/`main.rs`), selection-range→`selection.rs`, linked-editing→`linked.rs`, references-nav (server half)→`folding.rs`+`nav.rs`, large-file-mode→`large.rs`+`server/large_file.rs`, lsp-318-extras→`format.rs` (+`main.rs` capability), hover-declarations→`hover.rs`(+`nav.rs`), port-detail-spans (server half)→`hover.rs`+`nav.rs`, hover-line-index→`hover.rs`+`locate.rs`+`state.rs`, scan-interleave/change-debounce/verbose-timing→`server/`+`state.rs`, perf5-p1→`fences.rs` (+ the `_at` helpers in `ports.rs`/`imports.rs`/`extract.rs`/`inline_module.rs`), perf5-p2→`rename_trace.rs`+`module_select.rs`, perf5-p4→`scan_trace.rs`+`scan_order.rs`+`server/startup.rs`+`state/scan.rs`, perf5r-first-answer→`state/discover.rs` (+ counters and the compaction skip in `index_cache.rs`), perf measurements→`src/perf.rs` (`docs/perf/README.md`, not a feature README), interactive-latency→`state.rs` (the two token searches) + `selection.rs`/`on_type.rs`/`completion/`/`inline.rs` (their callers) + `src/perf.rs`/`tests/e2e.rs` (its measurements), editor-packaging (grammar test)→`tests/grammar.rs`, localized-reindex→`state/incremental.rs`+`state/watched.rs`+`watch.rs`+`includes.rs`+`candidates.rs`+`server/index.rs`, scan-ordering→`server/mod.rs`+`server/batch.rs`+`caret.rs`+`server/dispatch.rs`, viewport-highlight→`server/viewport.rs`+`tokens/`+`large.rs`+`server/index.rs`, ifdef-folding→`folding/directives.rs`, format-styles (server half)→`auto_style.rs`+`server/formatting.rs`+`settings.rs`+`lint.rs`, fast-actions→`server/ahead.rs`+`same_file.rs`+`completion/related.rs`+`completion/wire.rs` (+ `flush_buffer` in `server/diagnostics.rs`, `reclassify_large_buffers` in `server/large_file.rs`, `owes_a_state_change`/`settings_announced` in `server/mod.rs`) |
| `tools/` + CI | corpus-check, release-prep, ci-release, editor-platform-vsix (staging), range-formatting (`lucisv-changed.sh`) | | `editors/vscode` | editor-packaging, editor-snippets, editor-settings (manifest half), editor-scopes (rainbow half), vscode-hierarchy-sidebar (`hierarchyView.js`/`hierarchyModel.js`), dut-hierarchy (`hierarchySections.js`), extract-inline-module (`extract.js`), editor-platform-vsix, editor-marketplace-page, index-persistence (`storagePath` line), verbose-timing (`lucisv.verbose`, spawn args and restart in `extension.js`), hierarchy-current-path (`hierarchyCurrent.js`, `media/hierarchy.*`), comment-highlighting (`commentScan.js`, `commentKeywords.js`), format-styles (`lucisv.format.style`), scan-ordering (`referencesView.js`) |
| `tools/` + CI | corpus-check, release-prep, ci-release, editor-platform-vsix (staging), range-formatting (`lucisv-changed.sh`), release-gates (`gates.sh`, `release.yml`), linux-test-portability (`linux_check.sh`, `ci.yml` `linux` job) |
### 3.2 The combined picture ### 3.2 The combined picture
@@ -828,18 +902,27 @@ ownership explicitly.
| `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/` and `verify.rs` must read it. | | `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/` 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). Class and statement scopes are supported by statement-fences (§2.9-3 delivered); `range::plan` must merge these protected spans with unselected runs. Port and case-label lists remain outside independent fence scopes. | | `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). Class and statement scopes are supported by statement-fences (§2.9-3 delivered); `range::plan` must merge these protected spans with unselected runs. Port and case-label lists remain outside independent fence scopes. |
| `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/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/` | 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/server/` | lucisv-server; amended by cancel-request, change-debounce, scan-interleave, index-scope, verbose-timing, scan-ordering, viewport-highlight, fast-actions | 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. No notification overtakes an older notification (`must_hold`; the answer to a settings pull counts as one, `owes_a_state_change`). The only requests answered out of arrival order are those `Server::answer_from_the_buffer` (`server/ahead.rs`) lets go: a text-current colouring request, or a `same_file` request whose answer is its buffer's. |
| `lucisv_server/src/state.rs` | lucisv-server; amended by filelist, index-scope, scan-interleave, indexing-ux, incremental-index, index-persistence, hover-line-index, large-file-mode, one-parse (`Document.tree`), editor-settings + folders-and-config (`set_client_settings`/`change_roots`), include-nav (the include graph), completion-core (candidates), file-watching, interactive-latency (`first_token_reaching`/`first_token_from`), refactor performance fan-outs | every handler | `Workspace` is immutable through request handlers except the interior-mutable four-entry/8 MiB `FileView` cache. The scope ladder (filelist > `index.scope: "workspace"` > folder-scope at shipped depth 2; a rootless session never climbs; it reads flat at depth 0 and walks descendants at positive depth (including the default 2)) and open-buffer overlay are contracts. `Scan` has whole/widen shapes but one step/finish path; index/candidate/include prefixes publish together. `module_sources`, `rename_sources`, and `include_sources` must remain supersets of what their engines can edit/refuse over; `rename_sources` falls back to `sources()` when an ambiguous posting prevents a proven bound. `update_one` and a completed scan must equal a fresh build (`fingerprint`). Handlers reading `doc.text` instead of tokens/tree must check `doc.large`. **(2026-09-12)** `Document::new`'s derivations are individually traced (`lint_trace::Rebuild`), so a stage added to or removed from that constructor wants a `Rebuild` variant beside it. | | `lucisv_server/src/server/mod.rs` (`process_batch`, `must_wait`, `must_hold`, `behind`, `hold`) | scan-interleave; amended by scan-ordering, viewport-highlight, fast-actions (`owes_a_state_change`, `settings_announced`) | every client message; the early-answer path (`server/ahead.rs`) reads `held`/`behind`/`dirty`/`staging`/`pending` | Every client message goes through `process_batch`; nothing applies one around it. `must_hold` is the one ordering rule and `behind` its count; a new exemption is taken where requests are held, reads only what the exempted handler proves it needs, and states why that is valid between two scan files. |
| `lucisv_server/src/server/index.rs` (`reindex_*`, `answer_what_is_waiting`, `BURST_DIVISOR`) | scan-interleave / index-scope; amended by localized-reindex, scan-ordering, viewport-highlight, format-styles (no lines) | saves, watcher events, widens, startup | localized-reindex owns the one-file/outside/burst decisions; scan-ordering owns hand-back (`opened_mid_scan`, once per file opened); viewport owns the widen deferral (`defers_widen`) and fast-actions the drain (`answer_ahead_mid_widen` in `server/ahead.rs`, `answer_colours_mid_widen` until 0.65.11). Two of those in one wave are not parallel. |
| `lucisv_server/src/server/notification.rs` | lucisv-server; amended by localized-reindex, scan-ordering (`didOpen` arm), format-styles (three `auto_styles` calls), viewport-highlight (reads), fast-actions (`settings_announced`, `reclassify_large_buffers` from `apply_settings`) | every notification; `ahead::REACH` (one row per arm, test-pinned) | A notification arm is where state changes are *applied*, so scan-order effects (`head_owed`, `opened_mid_scan`) and per-document memories (`auto_styles`) are set here, never read off a batch. A new arm needs a `REACH` row in `server/ahead.rs` or the precondition test fails; until it has one it reaches `Any` (early answers wait behind it). A lane needing a line here asks the owning lane (format-styles' three lines were granted). |
| `lucisv_server/src/server/dispatch.rs` (`symbol_offset`, `answer_flushed`) | lucisv-server; amended by scan-ordering, viewport-highlight, fast-actions | every request handler | A name-under-the-cursor request resolves through `symbol_offset`; a request with its own boundary rule keeps `offset` and says so in scan-ordering's table. `answer_flushed` is dispatch minus `flush_dirty` and must stay a pure split. A new request arm needs a row in fast-actions' README table (`same_file/tests.rs` reads the arms and fails otherwise) and stays out of `same_file::METHODS` unless its handler reads only the buffer. |
| `lucisv_server/src/server/ahead.rs` (`answer_from_the_buffer`, `REACH`, `can_reach`) + `same_file.rs` | fast-actions (viewport-highlight's colour exemption moved here) | `process_batch`, `set_aside`, `answer_ahead_of`, `open_then_widen`, `answer_ahead_mid_widen`, `answer_held_ahead`; `viewport.rs` (`colours_may_go_ahead`, `coloured_ahead`); every `same_file` handler (hover, nav, symbols, folding, selection, linked editing, highlights, references, prepareRename, signature help) | The precondition is stated once, on `answer_from_the_buffer`, and nowhere else; a new place that offers a request early calls it, never a copy. `REACH` lists what is **proved** harmless — a notification without a row waits, a handler that starts touching a buffer it does not name moves its row to `Any`, a new `Pending` kind is classified in `can_reach`. `same_file::answered_by_the_buffer` must change with any handler arm that starts reading the index or the overlay; `fast_actions_differential.rs` (early == settled) is the alarm. |
| `lucisv_server/src/state/` (`state.rs` until TODO §55) | lucisv-server; amended by filelist, index-scope, scan-interleave, indexing-ux, incremental-index, index-persistence, hover-line-index, large-file-mode, one-parse (`Document.tree`), editor-settings + folders-and-config (`set_client_settings`/`change_roots`), include-nav (the include graph), completion-core (candidates), file-watching, interactive-latency (`first_token_reaching`/`first_token_from`), refactor performance fan-outs | every handler | `Workspace` is immutable through request handlers except the interior-mutable four-entry/8 MiB `FileView` cache. The scope ladder (filelist > `index.scope: "workspace"` > folder-scope at shipped depth 2; a rootless session never climbs; it reads flat at depth 0 and walks descendants at positive depth (including the default 2)) and open-buffer overlay are contracts. `Scan` has whole/widen shapes but one step/finish path; index/candidate/include prefixes publish together. `module_sources`, `rename_sources`, and `include_sources` must remain supersets of what their engines can edit/refuse over; `rename_sources` falls back to `sources()` when an ambiguous posting prevents a proven bound. `update_one` and a completed scan must equal a fresh build (`fingerprint`). Handlers reading `doc.text` instead of tokens/tree must check `doc.large`. **(2026-09-12)** `Document::new`'s derivations are individually traced (`lint_trace::Rebuild`), so a stage added to or removed from that constructor wants a `Rebuild` variant beside it. |
| `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. | | `lucisv_server/src/settings.rs` | editor-settings | folders-and-config, indexing-ux, index-scope, index-persistence, inline-templates, will-save-wait-until, filelist, large-file-mode | One parser for both doors (push and pull, via `from_section` re-wrapping). Every key drops garbage independently; defaults that are not "silence" (1 MiB cap, log on, persist on, 4 MiB large-file threshold) are hand-written in `Default`. `set_client_settings` returns whether a reindex is owed — new keys must decide that question explicitly. |
| `vlog_semantic/src/workspace/` (+ `facts.rs`) | workspace-index; extended by incremental-index, index-persistence, index-scope, hover-line-index, scan-interleave, member semantics, semantic-lints-on, bind-semantics, SVA bodies and refactor-rename performance | server state, hierarchy/lens/type-hierarchy, refactor, completion, semantic lints | Determinism (same inputs → same index, any order), the `paths` spelling coupling with `resolve.rs`, `FACTS_FORMAT` bumped on any codec change (current 19), edge/posting tables built by the same lifted walks the engines use. `DeclLines` must round-trip and participate in `fingerprint`; `absorb` must equal one build over the resulting record set; `files_spelling` must continue to include unresolved non-empty external/inherited paths or rename loses its dangling-use refusal; `FileFacts::words` is the shared project mention/completion census. | | `vlog_semantic/src/workspace/` (+ `facts.rs`) | workspace-index; extended by incremental-index, index-persistence, index-scope, hover-line-index, scan-interleave, member semantics, semantic-lints-on, bind-semantics, SVA bodies and refactor-rename performance | server state, hierarchy/lens/type-hierarchy, refactor, completion, semantic lints | Determinism (same inputs → same index, any order), the `paths` spelling coupling with `resolve.rs`, `FACTS_FORMAT` bumped on any codec change (current 22), edge/posting tables built by the same lifted walks the engines use. `DeclLines` must round-trip and participate in `fingerprint`; `absorb` must equal one build over the resulting record set; `files_spelling` must continue to include unresolved non-empty external/inherited paths or rename loses its dangling-use refusal; `FileFacts::words` is the shared project mention/completion census. |
| `vlog_refactor/src/rename/` | refactor-rename; shared by references-nav and the performance wave | server rename/prepareRename/references and port refactor verification | `Scope` remains the whole-scope authority and `collect_occurrences` the one rename/references walk. The fast `prepare_rename_here` answer/refusal and `rename_name_at` target are parity contracts, not alternate semantics. Any new refusal must be expressible on the fast path or force a deferral; any new occurrence shape must be reflected in the server fan-out or trigger its all-sources fallback. | | `vlog_refactor/src/rename/` | refactor-rename; shared by references-nav and the performance wave | server rename/prepareRename/references and port refactor verification | `Scope` remains the whole-scope authority and `collect_occurrences` the one rename/references walk. The fast `prepare_rename_here` answer/refusal and `rename_name_at` target are parity contracts, not alternate semantics. Any new refusal must be expressible on the fast path or force a deferral; any new occurrence shape must be reflected in the server fan-out or trigger its all-sources fallback. |
| `vlog_parser/src/token.rs` keyword table | completion-core (`KEYWORDS` export) | lexer, pairs.rs, editor grammar (test-locked), completion | Adding a keyword = lexer change + `pairs.rs` re-check + a hand edit to the grammar (`tests/grammar.rs` names the missing word) + potentially `verify.rs`-adjacent behavior. dv-statements added `randcase`/`let` to `is_keyword` and recorded it as shared with the adjacent lexer-cleanup round — the precedent for treating this file as coordinated even between back-to-back rounds. | | `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. | | `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. | | `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). | | 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). |
| `editors/vscode/syntaxes/systemverilog.tmLanguage.json` | editor-packaging | `tests/grammar.rs` (keyword lock), `commentScan.js` (comment/string rules, `commentScan_test.js`) | Two locks: a keyword edit is checked against `KEYWORDS`; a `comments`/`strings` edit, a reorder of top-level rules, or a new top-level rule matching `/` or `"` must update `commentScan.js` in the same change. |
| style name list (`style.rs` `PRESETS` + `auto`) | format-styles | core `STYLE_NAMES`/`parse_style`, cache `Entry::style`, CLI `--style`, MCP, server `settings.rs`/`auto_style.rs`/`lint.rs`, manifest enum | A preset added or renamed moves all of these; two tests pin the chain (`args.rs`, `settings.rs`). Only the default may never move a byte (corpus + OpenTitan proof). Extends the existing `Config` → core → CLI/server → cache boundary noted under §3.3. |
The 2026-09-07 size measurement in `CLAUDE.md` puts `state.rs` at 958 The 2026-09-07 size measurement in `CLAUDE.md` put `state.rs` at 958
production lines; its decomposition is deferred to Loop 3 (TODO §55). production lines; TODO §55 decomposed it into `state/` (2026-10-14, pure
move; `state/mod.rs` 63 lines), and localized-reindex added
`state/incremental.rs` and `state/watched.rs`.
Additional shared boundaries are `vlog_refactor/src/check/ledger.rs` (every Additional shared boundaries are `vlog_refactor/src/check/ledger.rs` (every
move/copy planner), `vlog_semantic/src/imports.rs` (linter and refactor usage move/copy planner), `vlog_semantic/src/imports.rs` (linter and refactor usage
agreement), and `Config` → core config → CLI/server settings → format cache agreement), and `Config` → core config → CLI/server settings → format cache
+16
View File
@@ -5,6 +5,22 @@ for you. The extension and its bundled language server share one version
number; the full engineering notes live in the number; the full engineering notes live in the
[project changelog](https://git.luci.ooo/lucio/lucisv/src/branch/master/CHANGELOG.md). [project changelog](https://git.luci.ooo/lucio/lucisv/src/branch/master/CHANGELOG.md).
## 0.66.1 — 2026-11-19
- **Sticky scroll pins the module instance you are inside.** The instance's
type line stays at the top of the editor, and so does its `) u_name (` line
once you are in the connection list. Instances fold too; the closing `);`
stays visible.
## 0.66.0 — 2026-11-19
- **Rolls up 0.65.2–0.65.11:** saving no longer re-indexes the workspace;
hover, definition, outline and colours for the open file do not wait for
indexing; `` `ifdef `` branches fold; formatter styles (`auto`, `ansi`,
`google`, `lowrisc`, `microsoft`, `nxp`); the module view marks the current file and
its parents; Find References works with the caret just past a name;
`TODO`/`FIXME`/`TBD` and your own keywords are highlighted in comments.
## 0.65.11 — 2026-11-19 ## 0.65.11 — 2026-11-19
- **Hover, go-to-definition, the outline and folding answer immediately for - **Hover, go-to-definition, the outline and folding answer immediately for
+9 -2
View File
@@ -30,7 +30,7 @@ Install **lucisv — Verilog/SystemVerilog** from the VS Code Extensions view,
then open a Verilog or SystemVerilog file. There is no separate server or CLI then open a Verilog or SystemVerilog file. There is no separate server or CLI
setup. setup.
The current release is **0.65.11**. Its platform packages include The current release is **0.66.0**. Its platform packages include
`lucisv-server`, the `lucisv` command-line tool and `lucisv-mcp` (see `lucisv-server`, the `lucisv` command-line tool and `lucisv-mcp` (see
[Agents (MCP)](#agents-mcp)): [Agents (MCP)](#agents-mcp)):
@@ -154,7 +154,7 @@ enabling both paths formats twice.
| Document and workspace symbols | Hierarchical outline plus indexed symbol search across the design | | Document and workspace symbols | Hierarchical outline plus indexed symbol search across the design |
| Include links | Resolvable `` `include`` paths become clickable using local and filelist `+incdir+` search rules | | Include links | Resolvable `` `include`` paths become clickable using local and filelist `+incdir+` search rules |
| Folding | Modules, classes, blocks, regions, and multiline comments fold on syntax-aware boundaries; every branch of an `` `ifdef``/`` `ifndef`` region folds on its own, from its directive to the line before the next `` `elsif``/`` `else``/`` `endif``, which stays visible | | Folding | Modules, classes, blocks, regions, and multiline comments fold on syntax-aware boundaries; every branch of an `` `ifdef``/`` `ifndef`` region folds on its own, from its directive to the line before the next `` `elsif``/`` `else``/`` `endif``, which stays visible |
| Sticky scroll | The first line of every block you are inside — the module, the `always`, the `case`, the case item, the `if`, the `` `ifdef``/`` `else`` branch — stays pinned at the top of the editor, up to ten lines deep | | Sticky scroll | The first line of every block you are inside — the module, the `always`, the `case`, the case item, the `if`, the `` `ifdef``/`` `else`` branch, the module instance (its type line, and its `) u_name (` line once you are in its connections) — stays pinned at the top of the editor, up to ten lines deep |
| Inlay hints | Adds port and parameter names to ordered instantiations without guessing at ambiguous sites | | Inlay hints | Adds port and parameter names to ordered instantiations without guessing at ambiguous sites |
| Code lenses | Shows the workspace-wide instantiation count above every module/interface; click to jump to a site | | Code lenses | Shows the workspace-wide instantiation count above every module/interface; click to jump to a site |
| Call hierarchy | Incoming calls answer “who instantiates this?”; outgoing calls answer “what does this instantiate?” | | Call hierarchy | Incoming calls answer “who instantiates this?”; outgoing calls answer “what does this instantiate?” |
@@ -440,6 +440,13 @@ default):
} }
``` ```
## Release 0.66.0 highlights
Version 0.66.0 completes a round of eight editor features: no workspace
re-index on save, same-file actions and colours that do not wait for
indexing, `` `ifdef `` folding, formatter styles, a module view that marks
where you are, a Find References fix and comment keywords.
## Release 0.65.11 highlights ## Release 0.65.11 highlights
Version 0.65.11 answers hover, go-to-definition, the outline and folding for Version 0.65.11 answers hover, go-to-definition, the outline and folding for
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "lucisv", "name": "lucisv",
"version": "0.65.11", "version": "0.66.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "lucisv", "name": "lucisv",
"version": "0.65.11", "version": "0.66.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"vscode-languageclient": "9.0.1" "vscode-languageclient": "9.0.1"
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "lucisv", "name": "lucisv",
"displayName": "lucisv — Verilog/SystemVerilog", "displayName": "lucisv — Verilog/SystemVerilog",
"description": "Fast Verilog/SystemVerilog formatting, linting, navigation, refactoring, semantic highlighting and RTL design intelligence.", "description": "Fast Verilog/SystemVerilog formatting, linting, navigation, refactoring, semantic highlighting and RTL design intelligence.",
"version": "0.65.11", "version": "0.66.1",
"publisher": "guoliangchen", "publisher": "guoliangchen",
"author": "Guoliang Chen", "author": "Guoliang Chen",
"license": "MIT", "license": "MIT",