generate-label-rename README: "What changed" covers reworks 1-5 and the review fixes; the stale "engine and verifier unchanged in code" claim is replaced (what a rename rewrites is unchanged; the verifier gained no normalization, only path-qualified file names). Status lists reworks 2-5, P1/P2, §65.6 and the review; work log entries for M-2 and M-3, including that QA's P1/P2 were fixed in the tree with no log entry. refactor-rename README: dated correction. topo row 40: second half answered by row 43. CHANGELOG: the two scoping bullets merged into one that matches rework 5 plus the H-1/H-2 fix. qa_warning_scope.rs P1/P2 test comments and the rename module doc updated (comments only; that suite: 24 passed). Co-Authored-By: Claude Opus 5.5 <[email protected]>
159 KiB
refactor-rename
Milestone M2 of docs/features/refactor/README.md.
Goal
Give lucisv the refactoring every Verilog user misses: rename a symbol and have
every reference to it change, across files, or have the request refused with
a sentence explaining why. The engine lives in a new crate,
crates/vlog_refactor, so the CLI and every editor get identical behavior;
lucisv_server only maps the protocol (textDocument/prepareRename,
textDocument/rename → WorkspaceEdit). Every edit comes from a span the
semantic layer resolved — there is no textual search-and-replace anywhere in
this feature — and the whole edit is verified in memory before it is returned:
re-tokenize every touched file and re-resolve it, and refuse the entire
rename if anything but the renamed name moved. That is the formatter's
never-corrupt contract, applied to refactoring, without touching
vlog_formatter or verify.rs.
API as built
// crates/vlog_refactor/src/lib.rs
pub struct TextEdit { pub range: TextRange, pub new_text: String }
pub struct RefactorEdit { pub edits: Vec<(PathBuf, Vec<TextEdit>)>, pub warnings: Vec<String> }
pub struct RenameTarget { pub range: TextRange, pub name: String }
pub fn prepare_rename(files: &[(PathBuf, String)], file: &Path, offset: u32)
-> Result<RenameTarget, String>;
pub fn rename(files: &[(PathBuf, String)], file: &Path, offset: u32, new_name: &str)
-> Result<RefactorEdit, String>;
// Added 2026-08-28 (the performance wave). Same question, no file set.
pub fn prepare_rename_here(semantics: &Semantics, external: &ExternalResolutions,
index: &WorkspaceIndex, offset: u32)
-> Result<RenameTarget, String>;
pub fn rename_name_at(semantics: &Semantics, offset: u32) -> Option<String>;
files is the boring option: the in-scope files as (path, text) pairs —
exactly what WorkspaceIndex::build already takes, and exactly what
lucisv_server's scope resolution (M1's filelist ⊃ walk ⊃ siblings ladder, open
buffers overlaying disk) already produces. No trait, no borrow of server
state, no I/O inside the crate.
Err(String) is a user-facing sentence: the server returns it verbatim as
the LSP request error, which is what VS Code puts in the rename box.
Deviations from the milestone sketch, and why:
offset: u32, notusize. Everything below the protocol —TextRange,Semantics::symbol_at,Def.name_span— counts bytes inu32. Ausizeparameter would be cast at both ends of every call.prepare_renamereturns aRenameTarget, not a bare range: the editor wants the placeholder too, and it is the identifier's own text.prepare_rename_heretakes an analysis rather than a file set (added 2026-08-28). The server already holds every argument it needs for the open buffer, so this asks nothing of the filesystem;prepare_renamestays as the whole-workspace oracle the parity tests measure it against. See "The file set a rename reads" below.rename_name_atdecides nothing. It answers only "which identifier is under this cursor", which is what the server needs to ask the index for the fan-out. Every refusal stays withrename, which is the call that has the files; a second opinion here could only disagree with it.
What can be renamed
Every kind vlog_semantic resolves, because the engine never looks at
SymbolKind at all — it renames "the symbol the cursor resolves to", whatever
that is: nets and variables (wire/reg/logic/int), module ports (ANSI
and non-ANSI, where the redeclaration is a reference to the header port),
parameters and localparams, genvars, typedefs, enum variants, struct members,
functions, tasks, task/function arguments, block labels, module names,
instance names, packages, classes and class members.
Renaming from a reference works exactly like renaming from the declaration: the cursor is resolved to a declaration first (in this file, or through the workspace overlay into another file), and everything after that is the same code path.
End labels move with their declaration. endmodule : m,
endinterface/endpackage/endfunction/endtask/endclass : name, and
end : label / join : label on a named block or generate block are all
edited, because vlog_semantic records each of them as a use of the
declaration it closes (round 2 of this milestone; see Handshakes). No text
matching is involved: the label is bound to its own construct by the binder,
so a label can never attach to a same-named declaration somewhere else. Two
cases still record nothing and are warned about instead — a label that does
not spell the declared name (already illegal SystemVerilog) and a label whose
declaration was a redeclaration that bound no symbol of its own.
Cross-file comes from the same overlay textDocument/definition uses: every
in-scope file is analyzed, its external candidates are resolved against the
WorkspaceIndex, and a reference whose answer is this declaration
(same FileId, same name_span) is an edit. That covers module names in
instantiations, package members at import p::* / import p::x / p::x
sites, .port(...) connection names, and #(.PARAM(...)) overrides.
The refusal list — exact
rename returns Err and produces no edits at all when:
-
new_nameis empty, does not lex, lexes to more than one token, lexes to something that is not an identifier, or is a keyword. -
new_nameis the name it already has. -
The file the request names is not one of the in-scope files.
-
The cursor is on no identifier the semantic layer recorded (whitespace, punctuation, a keyword, a
`definedirective, a system task). -
The identifier is a reference the layer left
NotFound. -
The identifier is a reference the layer left
InheritedCandidate— a name that could only come through a class'sextends, which nothing resolves. -
The identifier is an external candidate the workspace index cannot answer (
StillUnresolved): the declaration is outside the indexed files, so the rename would be half a rename. -
The identifier is an external candidate the index answers ambiguously (
ExternalTarget::Ambiguous) — the name is declared in more than one file and picking one would be a coin flip. -
The declaration is a file-scope unit (module, package, class, file-scope typedef) whose name the index holds more than once — the same ambiguity, caught when the rename starts from the declaration and so never reaches rule 8.
-
Some other in-scope reference to the name resolves ambiguously onto this declaration — a use lucisv would have to edit but cannot attribute.
-
The declaration's
name_spanis empty (the layer could not find the name literally in the source), or an edit span does not slice back to the name. -
Collision / capture. After applying the edits in memory and re-analyzing every watched file — every file the edits touch, plus every file whose text spells the old or the new name — any reference or declaration resolves differently than it did before (modulo the rename itself), or the reference/declaration sets differ in size. This is the check that refuses
x→ywhen ayalready exists in a scope the rename reaches, in both directions: the renamed uses being captured by an existingy, and an existing use ofybeing captured by the renamed declaration — including in a third file the rename never edits, whose existingyreference the rename would make ambiguous. -
Token verification. A touched file no longer lexes, or its token stream is not identical to the original's except that the edited identifier tokens spell the new name — same count, same kinds, same texts, same attached comments, same spans after shifting.
-
Implicit connections lucisv cannot read (added 2026-09-23, see "Implicit connections"): a
.*or.namethat binds — or could bind — the renamed name through a module lucisv cannot read or finds declared twice, a connection list split by compiler directives or holding text a tolerant parse could not read, a hierarchicalbindtarget, a.*that would start binding the new name, and a package variable an import might hand to a.*. -
Binding verification (2026-09-23): what any
.nameor.*in a watched file binds — port half and net half — differs before and after.
Rules 12, 13 and 15 are checked over the whole edit; any one fails the entire
rename, never part of it (RefactorEdit is all-or-nothing, hard invariant 1's
shape for refactorings).
prepare_rename applies rules 3–7 (and 9), which is exactly what an editor
needs to decide whether to open the rename box at all: everything else needs a
new name to judge.
The file set a rename reads (2026-08-28)
Until this round both entry points were handed Workspace::sources() — every
in-scope file, read from disk — and built a whole WorkspaceIndex over it
before answering anything. On OpenTitan (3 976 files) that cost 1.7–3.0 s
for prepareRename and 3.2–8.7 s for rename, on a single-threaded
server where everything the editor sent next waited behind it. prepareRename
is what the rename key sends before the box opens, so those seconds were a
frozen editor on a keypress that had committed to nothing.
Two different fixes, because they are two different questions.
prepareRename: the buffer already holds the answer
The question is "is this a renameable symbol, and what are its range and
placeholder". prepare_rename_here answers it from the open buffer's own
Semantics, the ExternalResolutions overlay the server keeps beside it, and
the index — no file is read and nothing is parsed. Measured: 238 ms →
200 ns on the synthetic 504-file workspace, 1.604 s → 135 ns on
OpenTitan.
Refusal-by-refusal parity
Every refusal prepare_rename can produce, and what the cheap path does with
it. Deferring a refusal to rename is allowed — LSP explicitly permits an
optimistic prepareRename — and losing one is not: a deferred refusal is
still delivered, in the same words, by the rename that follows.
| # | Refusal (its own sentence) | Where it comes from | Cheap path |
|---|---|---|---|
| 3 | "… is not one of the files lucisv indexes …" | the request's file absent from files |
unreachable either way. sources() contains every open buffer with a path, and this handler is only reached for one; a fast-path (large) buffer is refused by server.rs before it gets here. |
| — | "the file could not be analyzed." | Scope::analysis of an in-range index |
dead code in both: the index came from index_of, so the lookup cannot miss. |
| 4 | "there is no symbol to rename at this position." | no reference and no symbol at the offset | reproduced — reference_id_at / symbol_at on the buffer. |
| 5 | "… is not resolved to any declaration …" | Resolution::NotFound |
reproduced — single-file resolution, in the buffer. |
| 6 | "… could only come from the base class B …" |
Resolution::InheritedCandidate |
reproduced — same. |
| 7 | "… is declared outside the files lucisv indexes …" | ExternalTarget::StillUnresolved / absent |
reproduced — the overlay is resolve_external against this same index, which is the call Scope::declaration_across_files makes. |
| 8 | "… is declared in more than one indexed file …" (from a cross-file use) | ExternalTarget::Ambiguous |
reproduced — same overlay. |
| 9 | "… is declared in more than one indexed file …" (from the declaration) | declaration.scope == file_scope && index.units(name).len() > 1 |
reproduced — the buffer knows the scope, the index knows the count. |
| 11a | "lucisv cannot find where x is spelled in its declaration …", declaration in this buffer |
empty name_span |
reproduced. |
| 11b | the same sentence, declaration in another file | that file's fresh name_span |
deferred. The index only ever records a non-empty span, so this can only fire on a file whose analysis disagrees with the index — which means reading it. |
| — | "x's declaring file is not in scope." |
index_of on the declaring path |
deferred (and unreachable in practice: sources() is a superset of the index's files). |
| — | "the declaring file could not be analyzed." / "lucisv cannot locate the declaration of x." |
the declaring file's own analysis | deferred, same reason. |
| 1, 2, 10, 12, 13 | new-name validity, same name, ambiguous use onto this declaration, capture, token drift | — | not prepare_rename's at all; they always were rename's. |
Pinned by rename::tests::the_buffer_answers_a_prepare_exactly_as_the_workspace_does
and its five siblings, which ask both entry points the same question at every
byte of hostile buffers — packages and qualified names, a name declared
twice, nothing resolving, generate blocks and macros, a file that does not
parse — and fail on any reworded refusal, any different answer, and any
refusal the cheap path invents. Deferrals are counted, never asserted away.
The one divergence, stated exactly. Rule 9's count comes from the index,
and the index is rebuilt on save, not on keystroke (state.rs), so an unsaved
edit that adds or removes a file-scope declaration of the name is not in it.
prepare_rename counts the same declarations over the current texts. Both
directions are possible in principle; both are the ordinary index-staleness
window every other index-backed answer in this server lives in, and the
sentence itself says "indexed file". rename re-derives the count from the
current texts and is the authority.
rename: the symbol's fan-out, and why it is enough
Workspace::rename_sources (state.rs) builds the file set from what the index
already holds. Its rungs, for the request's file, every open buffer, and each
spelling N in {old_name, new_name}:
- every file declaring
N—WorkspaceIndex::workspace_symbols(N)filtered to the exact name, which covers units and members (ports, parameters, package and class members); - every file the index recorded a use of one of those declarations in —
references_to(def), for every such declaration, not only the target's; - every file instantiating
N—instantiations_of(N); - every file whose
`definetable namesNor spells it in a macro body — a walk over theDefineTables the index already holds (no file is read), asking the samevlog_refactor::contains_wordthatScope::define_sitesdecides with, so the fan-out and the warning cannot disagree about which files carry one; - the units that export
Nas a member, and every file declaring, referring to or instantiating one of them — how a third file's.N(...)connection oru::Nis reached.
and, for the new name only, a sixth:
- every file that spells the new name in a use this workspace had to look
outside that file to answer — including the uses it could not answer at
all —
WorkspaceIndex::files_spelling(N), a walk over the per-file records (no file is read, nothing is parsed). Rungs 1–5 are all keyed by a declaration, and a use that resolved to nothing has no declaration to be keyed by; this is the rung that finds it. Why only the new name needs it is argued under "The dangling-use case" below.
Rung 6 is the only one whose cost grows with the workspace rather than with
the symbol, so it is measured on its own: 852 µs on OpenTitan's 3 976 files
in the worst case — a name nothing spells, where the walk cannot
short-circuit — and 402 µs for clk_i, which 681 files spell. Building the
whole file set is 4.75 ms, most of it the other five rungs'
workspace_symbols scan and `define walk. Against a rename that costs
105 ms and used to cost 3.5 s, a sub-millisecond linear scan is the boring
implementation and stays one; a name-keyed side map is the fallback if a
workspace ever makes it visible, and nothing measured here comes close.
The sufficiency argument
Lemma (name-locality of resolution). A reference spelling N is resolved
by vlog_semantic::follow_paths, which tries the reference's recorded paths in
order and, for each, calls follow_one — and follow_one returns either
index.units(N) or index.member(u, N) for some unit name u. Both are
keyed by N, and both are contributed only by files that declare the name
N (as a unit, or as a member of some unit). Rung 1 puts every one of those
files in the set. Therefore, for every path list and every unit name,
follow_one(subset, N, ·) == follow_one(whole, N, ·), so
follow_paths(subset, N, ·) == follow_paths(whole, N, ·): every reference
spelling N resolves in the subset exactly as it resolves in the whole
workspace. ∎
Three consequences, which are the three things that could have gone wrong:
- No missed edit.
Scope::collect_occurrencesemits a span in file i only when i is the declaring file, or when a reference in i spelling the old name resolves to the target declaration. The declaring file is rung 1. A file with such a reference resolves the same way in the whole workspace (Lemma), so the index recorded a posting for it — rung 2. Hence every file the whole-workspace rename would edit is in the set. This is the invariant-1 claim, and it is asserted directly, not only through an equality, byevery_file_the_workspace_rename_edits_is_in_the_fan_out. - No extra edit. The converse of the same Lemma: a file in the subset
cannot resolve a reference onto the target that the whole workspace
resolves elsewhere. Without rung 1 this was a live corruption route — drop
the file declaring
p::xand ap::x/q::xreference would fall through toq::xand be renamed — which is why rung 1 isworkspace_symbolsand notunits. - The verifier keeps its reach.
check::watched_fileswatches every file spelling the old or the new name. In the subset it can only watch what it was given, so the new name gets rungs 1–6 of its own — which is what keeps refusal 12 (capture) alive:the_fan_out_still_refuses_a_rename_that_would_capture_a_name_elsewherebuilds exactly the third file whose existing reference the rename would make ambiguous, and the subset holds it because it is in the new name's postings.
The dangling-use case, and why the sixth rung is the new name's alone
The Lemma settles what a name resolves to. It does not by itself settle
which files hold a use of that name, and rungs 1–5 answer that question only
through declarations: a file is in the set because it declares the name,
because a posting keys it to a declaration of the name, because it
instantiates the name, because a macro table mentions it, or because it names
the unit that exports it. A use that resolved to nothing is keyed by
nothing. merge_references drops a StillUnresolved result rather than
posting it, which is correct for references_to — there is no declaration to
post it against — and is exactly the hole.
That hole is real and it costs a refusal, not a warning. Take
import taken_pkg::* in a file with no other tie to the rename: today it
resolves to nothing, and check::print records Anchor::Unresolved. Rename a
package to taken_pkg and the same use resolves — Anchor::External — which
is a changed meaning in a file the rename never edits, and refusal 12 exists
to refuse exactly that. QA found this on 2026-08-28 and reproduced it; the
lead ruled it not shippable, and rung 6 is the fix.
The old name has no analogous case, and this is why. A rename only ever removes declarations of the old name — it renames them away — and never adds one. So for a use spelling the old name:
- if it resolves, its declaration is one of the declarations of the old
name, so the file is in
references_toof that declaration — and rung 2 walks every declaration of the name, not only the target's. Already in the set. - if it resolves to nothing, it still resolves to nothing afterwards.
follow_onelooks the name up inunits(old)andmember(u, old); the rename only takes entries out of those, and a lookup cannot start succeeding because a candidate was taken away.Anchor::Unresolvedbefore,Anchor::Unresolvedafter — nothing for the verifier to see, so nothing lost by not reading the file. - if it resolves ambiguously, the escape hatch below fires and the whole scope is handed over anyway.
Pinned from both ends: a_dangling_import_of_the_new_name_is_refused_by_both_paths
(the new name's case, now parity rather than a disclosed gap) and
a_dangling_use_of_the_old_name_needs_no_rung_of_its_own (the old name's,
which asserts both that the new-name rung fires when the dangling spelling is
the destination and that nothing is pulled in when it is merely a bystander).
The escape hatch
Refusal 10 — some other reference resolves ambiguously onto this
declaration — is the one the postings cannot locate: an ambiguous use is
recorded against the declarations it could name (references_are_ambiguous)
and not against the file that writes it. Rather than lose that refusal,
rename_sources hands back the whole sources() the moment the index says
any declaration of either spelling is ambiguously referenced. Correct and
slow beats fast and silent. Pinned by
an_ambiguously_referenced_declaration_falls_back_to_the_whole_scope.
How often it fires, measured. On OpenTitan the aes and clk_rst_if
cursors narrow to 7 and 114 files of 3 976; a cursor on a .clk_i port
connection falls back to all 3 976 — some declaration named clk_i somewhere
in the checkout is ambiguously referenced, and the hatch is deliberately
asked about every declaration of the name rather than about the target
alone. The answer is still right there (edits identical, all 652 warnings
identical); it is simply not faster. The obvious narrowing — ask only about
the declaration the cursor resolves to, which is the only one refusal 10
tests — is left for a later round on purpose: it needs the target Def
identified server-side, which reintroduces the buffer-staleness question the
rest of this design keeps on one side of a line. Filed, not guessed at.
The staleness premise, stated exactly
The index is the server's authority on which files declare a name and which files use it. A file changed on disk with nothing telling this server — no save, no watcher event, no rescan — or a file a startup scan has not reached yet, is a file a rename does not read. Open buffers are the one exemption: every open buffer is in the set whatever the index holds, and the engine re-analyzes it from its current text, so unsaved edits are seen in full.
This is the same rule definition, hover, references, the code lens and the
call hierarchy already live by, and the file watcher is what keeps it true. It
is what the port refactorings adopted on 2026-08-28, one round earlier. What
it costs a rename specifically: a reference living only in a file whose disk
copy moved unseen is a reference the rename does not rewrite and cannot
refuse over — check::verify re-analyzes the subset, so a file outside it
is not compared before and after. Before this round rename was, with
prepareRename and the port actions, one of the few answers in this server
that could see further than the index; it no longer is.
The residue — what the subset cannot see
Written out rather than argued away. Each of these is a file whose only mention of a name is something the index records no declaration, posting, instantiation edge, macro definition or external-reference fact for. After the 2026-08-28 rework there is exactly one, and it costs a warning — no edit and no refusal:
-
One warning flavour, and it is the loudest item on this page — measured, not hypothetical.
Scope::warningsproduces three sentences. Two are read off a file's`definetable ("xis also a macro defined at …" and "xappears in the body of macroM…") and both survive: the index holds every file's table, and rung 4 walks it (the_fan_out_keeps_the_define_warnings_of_files_it_would_not_otherwise_read). The third comes from a macro invocation whose arguments spell the name, and that one needs the file's token stream. A file outside the fan-out no longer produces it.On the real OpenTitan checkout, at two cursors, with no edit lost at either:
aes -> aes_core_top edits identical (7 files, 7 edits) warnings 7 -> 0, every one of them a macro-invocation sentence: `aes` in the arguments of `CONNECT_TL_DEVICE_IF` at tb__xbar_connect.sv:30 and :47 (twice), `DRIVE_CHIP_TL_DEVICE_IF` at :97, :140, :161, `uvm_error` at keymgr_dpe_scoreboard.sv:644 clk_rst_if -> clk_rst_thing edits identical (114 files, 275 edits) warnings 64 -> 61, the three lost being `uvm_fatal` invocationsThose macro invocations really do still spell the old name after the rename, and saying so is the whole point of the warning.
tb__xbar_connect.svmentionsaesonly inside macro-invocation tokens, and the index models those in no table at all: a macro invocation is one opaque token, contributing no declaration, no reference, no instantiation edge and no define entry, so nothing short of reading and lexing the file can find it.This is a lead decision, and it is stated here rather than buried. The narrowing costs no edit and no refusal — the same runs assert the edit sets byte-identical — but it costs the user a real piece of news. Recovering it as things stand means running the warning pass over
sources()while the edits and the verification run over the fan-out: at least the 200–241 ms workspace read plus atokenizeof every file spelling the name, which is most of the win this round is for. The right answer is a macro-invocation census inFileFacts, which would make this rung an index lookup like the other five; that is avlog_semanticchange, and it is filed as a request below rather than guessed at here. -
No lost refusal. The first draft of this round had one — a file whose only mention of the new name was a use that resolved to nothing — and it is closed, by rung 6. See "The dangling-use case" above for the argument and the two tests. It is recorded here rather than deleted because the shape is worth remembering: every rung keyed by a declaration is blind to a use that has none, and a rename's whole job is to change which declarations exist.
-
Nothing else. A file whose occurrences of either name are strays — a comment, a string, a local declaration inside a module, a hierarchical tail — resolves identically before and after the edit, so the whole-workspace verifier had nothing to say about it either.
The alternative considered and not taken: hand the engine the whole file list
but a prebuilt index, which narrows nothing and would still cost the
sources() read (200–241 ms on OpenTitan) plus an index clone. It is recorded
here so the choice is visible rather than implied.
The verification story
Two independent checks, both run in memory on the edited text, before anything is returned.
1. Token-stream identity. Every touched file is re-tokenized. The new
stream must have the same length as the old one, and token i must have the
same kind, the same attached comments (leading list and trailing, by text),
the same blank_before, the span it gets by shifting the original's, and the
same text — except for tokens whose span is exactly an edit, which must be
Ident tokens spelling the new name. A rename that merged two tokens, split
one, ate a comment, changed a number's spelling or wandered into a string or a
directive cannot survive this. It is the analog of the formatter's verify
pass, and it lives in this crate rather than borrowing verify.rs — hard
invariant 4 says the formatter's safety net does not widen, and nothing here
touches it.
2. Resolution identity. For every watched file, before and after, the
engine builds a print of every declaration (name_span, name, kind) and
every reference (name_span, name, what it resolves to), where "what it
resolves to" is a workspace-wide anchor: Local(span) for an in-file
resolution, External(path, span) for one the overlay answered, None for
anything unresolved. The before print has its spans and anchors shifted
through the edit map, and the names of the edited occurrences replaced with
the new name. The two prints must be equal. So: every edited occurrence
still resolves to the renamed declaration, the renamed declaration still has
exactly the same reference set, and no other name in those files changed
meaning. The post-edit side re-builds the workspace index over the edited
texts, so a cross-file capture is caught the same way an in-file one is.
The watch list. Watched = every file that receives an edit, plus every
file whose text spells the old name or the new name as a whole word. That is
sound: an edit only adds and removes declarations of those two names, and a
lookup of any other name cannot see them, so a file mentioning neither
cannot change meaning. The whole-word text search is a deliberate
superset of "has a token spelling the name" — a token always spells its name
literally — so it errs by watching a file whose only mention is in a comment,
which costs one analysis and never causes a refusal (its print is identical
either way; there is a test). This is what closes QA's third-file case:
top.sv instantiating a pre-existing child never spells sub, receives no
edit, and would previously have been accepted while its instantiation
silently became ambiguous.
Why the whole print and not just the names involved: only lookups of the old and the new name can change, so a narrower check would be sound — but it would need its own argument for why, and the wide one costs a few hundred microseconds on a Verilog file and needs no argument at all. Simplicity first.
Preprocessor honesty
lucisv does not preprocess (TODO.md §7). What that means here, exactly as implemented:
`definebodies and macro names are never edited. A`defineis oneDirectivetoken, so the semantic layer records no reference inside it and no edit can be produced there in the first place. When the workspace'sDefineTables show the name as a macro name (`define a/`undef a) or inside a macro body, a warning names the file and line.- Macro invocations are never edited, and their arguments are warned
about.
`BUMP(a)lexes as a single opaqueIdenttoken, name and argument list together, soainside it is invisible to the semantic layer — there is nothing to resolve and nothing to edit. The engine scans every in-scope file's macro-invocation tokens for the name as a whole word and warns per occurrence: "aappears in the arguments of the macro invocation`BUMPat m.sv:4 …". This scan covers files the rename never edits, since a macro call in an untouched file still expands to the old name. - A reference the workspace could not finish is left alone and warned
about too. Added 2026-09-02 (
docs/features/comment-slots/README.md,docs/topo.md§2.9-20). The stray-token scan below cannot see these: it skips any span the semantic layer recorded a reference for, and a hierarchical tail likeu_x.sigdoes carry one — anExternalCandidate { paths: ["unknown_mod::sig"] }the overlay leavesExternalTarget::StillUnresolvedbecause nothing in the indexed workspace answers it. Before this the tail had no reference at all and the stray scan warned about it; gaining a reference is what silenced it.Scope::unresolved_candidate_warningsasks theResolutionfirst (anInheritedCandidatethat missed stores nothing in the overlay, soExternalResolutions::getanswersNonefor it and for a plain local miss alike), then checks forStillUnresolved, and emits one line per (file, unit): "sigat top.sv line(s) 4 could not be resolved — nothing in the indexed workspace answersunknown_mod::sig, so lucisv records no reference there and it was left unchanged." Like the macro-invocation scan it runs over every file that spells the name, not only the edited ones, and it costs nothing extra becausecollect_occurrenceshas already analysed each of them. `ifdefarms are ordinary tokens to lucisv, so a resolved reference inside one is renamed — in every arm. That is the honest behavior: the tokens are there, they bound to the declaration, and editing only one arm would break the build for the other. No warning; there is nothing left unaccounted for.- Occurrences the layer records nothing for are left alone and warned
about, grouped by why — the warning names the actual construct rather
than guessing at a template:
a hierarchical or member tail, which lucisv does not resolve—u_inst.sig,a.b.c, anddefparam u1.Ppaths. This is the honest limitation: resolving a tail needs instance elaboration, which is a non-goal ofvlog_semantic. Adefparamnaming a renamed parameter is therefore left pointing at the old name, and said so.an end label lucisv could not attach to its declaration— a mismatched label, or one whose declaration was a redeclaration.a label lucisv records no declaration for, andan occurrence lucisv cannot attribute to any declarationfor the rest.
Implicit connections (2026-09-23)
The defect this closes (TODO-MCP M3.5, M3 QA finding 1, reproduced with
vlog_refactor::rename directly). .name and .* (IEEE 1800 §23.3.2.3–4)
bind a port to the same-named declaration where the instance is written.
The semantic layer records a reference for the port half of .name and
nothing at all for its net half or for .* — so renaming a port d → din
of leaf left leaf u_leaf (.*) binding nothing and turned .d into .din
against a parent with no net din, and renaming the parent's net cut both
bindings. Every one verified clean: the token check saw one identifier change,
and the resolution print saw no reference move, because none was ever
recorded. A silent CLAUDE.md invariant-1 corruption in a shipped engine; the
LSP's rename shared it.
What a rename does now (rename/connections.rs):
| Renamed | Written at an instance | Becomes |
|---|---|---|
port p → q of M |
M u (.p) |
M u (.q(p)) — one edit, p → q(p) |
port p → q of M |
M u (.*) and a net, variable, port or instance named p visible |
M u (.*, .q(p)) |
port p → q of M |
M u (.*), nothing named p or q visible |
unchanged — the wildcard bound nothing and still binds nothing |
net/var/port/instance n → m |
C u (.n) where n is the renamed one |
C u (.n(m)) |
net/var/port/instance n → m |
C u (.*), C declares port n |
C u (.*, .n(m)) |
| either | .* beside an explicit .p(...) / .n(...) |
nothing added — the explicit one wins, and the rename's own edit handles it |
Every such rewrite is listed in RefactorEdit.warnings — "u_leaf at
top.sv:2 bound d through .*; added .din(d)." and "u_leaf at top2.sv:2
connected d by the shorthand .d; wrote .din(d) so it still binds the
same net." — so both the LSP and the MCP show it. A port of a module that is
itself instantiated gets both directions at once: renaming mid's port d
adds .din(d) to top's mid u_mid (.*) and .d(din) to mid's own
leaf u_leaf (.*).
Where an implicit connection binds (rename/sites.rs): an ordinary
instance, at the nearest declaration of the name walking outward from the
scope the instance is written in (generate blocks included); a bind whose
target is one plain module name, at that module's own top-level
declaration (WorkspaceIndex::member_in(.., Surface::Hierarchical), the
table the semantic layer resolves a bind connection's bare name through).
Which instances are walked: for a port, every instance of its module in the
in-scope files that spell the module's name; for a net, every instance in its
own file from whose position the name resolves to it, plus every bind into
its module when it is declared at the module's top level; for a package
variable, every instance in a file that names the package — refused, not
rewritten (lucisv does not follow an import into a .*).
Layout. An insertion only — nothing the source wrote is replaced, so no
comment can move. A .* addition goes after the last connection element,
before the ), in the list's own style: , .q(p) on the same line for an
inline list; its own line at the last element's indentation for a list
written one per line; when the last element carries a // comment, the comma
goes before the comment and the connection on the next line (a , after //
is inside the comment). The newline is the list's own, so a CRLF file stays
CRLF. An escaped identifier gets the blank that terminates it. Nothing adds a
trailing comma.
Refused, never guessed — each sentence names the instance and its line:
- a
.*whose module lucisv cannot read ("u_xat top.sv:4 connects with.*toghost, which lucisv cannot read, so it cannot tell whetherdis bound implicitly; the rename was abandoned."), or finds declared in more than one indexed file, or whose port list carries compiler directives; - a connection list split by compiler directives (when it holds
.*), or holding text a tolerant parse could not read that spells either name or a*; - a
bindwhose target is a hierarchical path, or a lone instance name that may be an instance of the renamed module: resolved upward from the bind's own scope first (the enclosing module's instances of that name), else through every indexed instance of that name; refused when one of them is the renamed module's or none is indexed, skipped when all are other modules' (rework, QA finding 2); - a
.*whose module declares a port spelled like the new name, not connected explicitly — the rename would make the wildcard start binding it; - a package variable a
.*or.namemight reach through an import.
How the verifier accounts for it (check/implicit.rs; check/ had to
learn the shape, because the whole point is that its reference print could
not see it). Two additions, both inside the existing verify:
- A file whose edits insert is held to the splice contract plus a shape
rule. The token-identity check allows no insertion at all, so such a file
is checked by the port refactorings' piece comparison (
ledger::Split,pieces_match: every piece in place, no comment or attribute dropped or duplicated) plus: every replacement is exactly one identifier token spelling the old name, replaced by the new name; every insertion lexes to(X),,,.X(Y)or, .X(Y)withX,Ythe old or the new name and no comment, at a place a connection list takes it (rework, QA finding 1):(X)only right after a shorthand connection's name,,only right after the last element of a named list holding.*,, .X(Y)between that element — past blanks and comments — and the list's), and a bare.X(Y)only there behind such a,; the places are read off the before-tree with the samesiteswalk the engine plans with. Anything else: "the rename would write…outside a connection list in ; no edits were made." And the file gains no parse diagnostic. The resolution print excludes the inserted ranges (their names are the next check's to account for). - The binding print. For every watched file that could write an
implicit connection of either name (a cheap text prefilter,
sites::may_connect_implicitly, which is a superset — a.that starts a list element followed by*or one of the names — and every file the edits insert into), every instance's bindings are printed before and after:(instance, what the port half names, what the net half names), for every named connection whose port or bare-name net spells one of the two names, and every port spelling one of them that a.*reaches. The net half of.name/.*is looked up the way the language looks it up (above); a.*into a module that cannot be read prints a probe of what each of the two names finds there. Before-side spans are shifted through the edit map. The two prints must be equal. Why only the two names: a rename adds and removes declarations of those two names alone, so no other lookup and no other port can move — the watched-file argument applied one level down.
The attack pairs (check::implicit::tests, CLAUDE.md invariant 4 — the
binding print is a new strictness, not a forgiveness, but the insertions it
admits are a widening of what a rename may write, so they ship with attacks):
the QA finding itself (.d → .din, .* untouched) and the wildcard alone;
a shorthand written out with the wrong net ((din) — spells only the two
names, so only the binding print sees it); a wildcard connection to a third
name and to the swapped halves (.d(din)); insertions that are not connection
text (a comment, ; wire din;, a doubled connection, an unclosed one); a
connection added beside an explicit one of the same port; an insertion into
the wrong instance; a net rename that leaves .* alone, and one with swapped
halves; a .* that starts binding the new name; a net rename behind an
unreadable .*. Sabotage-checked: with the binding print disabled, seven of
the eleven fail (the rest are caught by the shape rule or the piece ledger
as well).
What it costs. A rename with no implicit connection of the name anywhere
parses nothing extra: the engine and the verifier both parse only files that
pass the prefilter (the rename parses each input file once and each edited file once more still holds verbatim). A file that does pass costs the engine
one parse and the verifier one per side.
Assumptions
- The caller hands over the same file set the workspace index was built from, with open buffers already overlaying disk. The crate does no I/O and does not walk anything.
- A file whose text does not contain the old name as a substring cannot
contain a reference to it, so it is never analyzed. Sound because the
semantic layer promises
src[reference.name_span] == reference.name— a reference always spells its name literally. This prefilter is what keeps a rename over an 860-file workspace to a handful of analyses. - Duplicate paths in
filesare deduplicated exactly asWorkspaceIndex::builddoes it (sort by path, first copy wins), so the engine's file indices and the index'sFileIds describe the same texts. - A rename is a rare, user-initiated request, so re-analyzing candidate files twice (once before the edit, once after) is affordable. No caching, no incrementality. Amended 2026-08-28: a prepareRename is not rare — it is what the rename key sends before the box opens — and "the candidate files" is now the symbol's fan-out through the index rather than the whole scope. See "The file set a rename reads".
- The index is the server's authority on where a name is declared and used (2026-08-28). The fan-out is read from it, so a rename sees the workspace as far as the index describes it: a file changed on disk with nothing telling this server, or one a startup scan has not reached, is a file the rename does not read. Open buffers are exempt — every one of them is in the set whatever the index holds. The exact premise, what it costs and what it does not, is written out under "The staleness premise, stated exactly".
- Refactored output is edited source, not reformatted source (umbrella Handshakes): the edits are minimal, and the user runs the formatter separately.
- Implicit connections (2026-09-23).
.*and.namebind a port to a net, a variable, a port or an instance of the same name (sites::binds_implicitly:ports/expand.rs's reading plus the instance, because an interface port binds to an interface instance and writing a module instance's connection out is exactly as wrong as the implicit one); the nearest declaration of the name shadows, so a parameter or a type of that name is a binding to nothing. The lookup is lexical and local — the nearest declaration walking outward from the instance — so a name a.*could reach only through a package import is not seen: a rename of a package variable is refused wherever a file naming the package writes a candidate implicit connection, and a rename that would make an import-reached name newly visible to a.*is caught only when the local lookup moves. Abindinto a module the fan-out does not hold is outside the rename exactly as any other use in such a file is (the staleness premise); abindwhose target is a hierarchical path is refused whenever it writes a candidate implicit connection of the name, since lucisv cannot name its scope. The compilation unit ($unit) is treated as one file.
Handshakes
Consumed from vlog_parser (no change required):
tokenize,parse_source_tolerant,LineIndex,TextRange.token::{Token, TokenKind, is_keyword}— the new-name validity check and the token-stream verification.defines::{DefineTable, DefineKind}via the index — the macro warnings.
Consumed from vlog_semantic (no change required, nothing patched):
analyze,Semantics::{symbol, symbol_at, reference_at, reference_id_at, references, references_of, file_scope, scope}.Resolution::{Resolved, ExternalCandidate, InheritedCandidate, NotFound}— the last three are three of the refusal rules.WorkspaceIndex::{build, files, path, units, defines},resolve_external,ExternalTarget::{Resolved, Ambiguous, StillUnresolved},Def.- The promise that
Symbol.name_span/Reference.name_spanare exact byte ranges that slice back to the name — every edit span is one of these, and the engine re-checks the slice before emitting it.
Consumed from vlog_semantic, added 2026-08-28 (no change required):
WorkspaceIndex::{workspace_symbols, references_to, references_are_ambiguous, instantiations_of, defines} — the posting, edge and macro tables — are what make
the rename's file set a lookup instead of a workspace read. The sufficiency
argument leans on one published property of theirs, and it is worth naming so
it moves under supervision: references_to's postings are built by
merge_references, which resolves each recorded reference with the same
follow_paths resolve_external uses. If those two ever stop being the one
function, the postings stop being a superset of the files a rename must edit.
The same goes for workspace_symbols covering both the units and the
members tables: rung 1 of the fan-out is that coverage.
Changed in vlog_semantic (lead-authorized 2026-08-28 after QA, strictly
additive — the second such change this feature has made, the first being M2's
Target::Declaration):
WorkspaceIndex::files_spelling(name) -> impl Iterator<Item = FileId>— every file holding an external reference fact spellingname, resolved or not. New query, no new state, no format change: it reads theFileFacts::referencesrecords the index already keeps, andFACTS_FORMATis untouched. Logged indocs/features/vlog-semantic/README.md's work log, as M2's change was.- Why it had to live there. The records are
pub(crate), and the question — "which files hold a use spelledNthat this index had to look outside that file to answer" — is a question about the index's own tables. The alternative was for the server to re-derive it by reading and analyzing files, which is the workspace read this whole round removes. - The contract it carries:
references_tois keyed by the declaration a use landed on, so a use that landed on nothing is in no posting.files_spellingis the same records asked by spelling instead, which is what makes it answer for the unresolved ones. Iffacts_from_analysisever stops recording an unresolved external candidate — today it records everyExternalCandidate/InheritedCandidatewith a non-empty path list — rung 6 stops closing the dangling-use case and this section must be re-read.
Promised to lucisv_server (and to any future CLI):
renamenever panics and never returns a partial edit:Okmeans every edit in it verified together,Errmeans nothing at all is to be applied.prepare_rename_hererefuses in the same sentencesprepare_renamedoes, or defers torename; it never invents a refusalprepare_renamewould not have made. The parity table above is the contract, and the byte-by-byte parity tests are the enforcement.rename_name_atnames the identifierprepare_rename'sRenameTargetwould name, at every offset whereprepare_renameanswers at all (the_name_a_fan_out_is_built_from_is_the_name_the_engine_acts_on).
Requested of vlog_semantic (filed 2026-08-28, not taken): a
macro-invocation census in FileFacts — per file, the macro invocations
it writes and the identifier-shaped words in their arguments. It is the one
piece of the rename's warning set the index cannot answer, and its absence is
the measured residue above: on OpenTitan, renaming aes loses seven
"aes appears in the arguments of the macro invocation …" warnings because
the files holding them contribute nothing else about aes. The census would
be one more Vec on a record FACTS_FORMAT already versions, read off the
token stream the parse already produced, and it would turn
Scope::macro_use_warnings from a workspace lex into a lookup — for the port
refactorings' identical scan as much as for this one.
RefactorEdit.editsis sorted by path; each file's edits are sorted by start offset, non-overlapping and non-empty.warningsare informational only — anOkresult with warnings is still safe to apply.
Changed in vlog_semantic (lead-authorized 2026-08-24 after QA round 1;
strictly additive, and the only cross-module change this milestone makes):
bind::TargetgainsDeclaration(SymbolId)— "this exact declaration, no lookup".resolve.rsanswers it withResolution::Resolved(id).Binder::use_end_labelrecords an end label as a use of the declaration it closes, called from the module/interface, package, class, function, task, generate-block and statement-block/fork-join arms.- Nothing was renamed, removed or re-spanned;
vlog_parserneeded no change at all, becauseend_label/end_label_spanwere already on every one of those AST nodes. Logged indocs/features/vlog-semantic/README.md's work log, and its "end labels record nothing" simplification is struck there.
The reason this could not stay inside vlog_refactor: a rename that leaves
endmodule : old_name behind produces non-compiling SystemVerilog, and
the only alternative — matching the label textually — would have broken this
feature's one structural rule, that every edit comes from a resolved
reference.
Requested 2026-09-23 (implicit connections), not blocking — each has a workaround in this crate:
-
vlog_refactor::ports(ports/list.rs,ports/find.rs).append_to_list,after_same_line_comments,line_indent,walk_instantiationsanddeclared_portsarepub(super)to the port refactorings; the rename needed the same five, and M3.5 did not own the files. Workaround:rename/layout.rsandrename/sites.rsrestate them (with two differences the rename needed: a CRLF-aware line break, and thebinddirective handed to the visitor rather than a bool). Request: lift them topub(crate)and let the rename call them, so there is one list layout rule. -
vlog_semantic. Recording an implicit connection's net half as a reference (.name→ a use of the net;.*→ one use per port the module declares, when it can be read) would letcollect_occurrences, find-all- references and the resolution print see these bindings directly, and would retire most ofrename/sites.rs. Workaround: the AST walk here, which both the engine and the verifier read. -
Delivered 2026-09-23 inside M3.5 (lead ruling): see the work log's fan-out entry. The original request, kept as filed: The rename's fan-out holds every file declaring either name, so a modulelucisv_server(state/mod.rs::rename_sources_traced) — the one that matters for the LSP.Ca.*instantiates is in it exactly whenCdeclares a port spelled like one of them — which is the case that needs a rewrite. When it does not,C's file is not handed over, and the engine, which cannot tell "not in this subset" from "not in the workspace", reportsCas a module it cannot read and refuses. Safe, and the whole-scope callers (the MCP, the CLI, the tests) never see it; but an LSP rename of a net in a module whose instances use.*into modules that do not declare the name is refused where it could succeed. Request: a seventh rung — for every file in the set that writes.*, add the declaring file of each module instantiated there (WorkspaceIndex::unitsof the instantiation edges the index already records). No engine change is needed for it. -
vlog_parser(filed 2026-09-23, QA M3.5 finding 3 and round one's{d,, d}). The tolerant parser accepts a trailing,in a named connection list (other u_o (.*,)) and an empty concatenation element ({d,, d}) without a diagnostic, so the verifiers' "no new parse diagnostic" rule cannot see either. The rename's position check refuses both on its own (a lone comma is not a place a connection list takes); the request is that the parser report them, so every refactoring's splice contract gets the same net for free. Not this lane's to fix.
Requested of nobody else. Hierarchical tails and defparam paths remain
unresolved by design (vlog_semantic non-goal: "resolving a tail needs
instance elaboration"), so they stay warned-not-edited; making them edits is
a much larger change than an end label and is not part of M2.
Status / TODO
- New crate
crates/vlog_refactor(workspace member; depends onvlog_parser+vlog_semanticonly — no formatter, no LSP types) TextEdit/RefactorEdit/RenameTargetmodel- Target location: from a declaration, from an in-file reference, from a cross-file reference through the overlay
- Cross-file edit collection through
resolve_external - New-name validity (single identifier token, not a keyword)
- Refusals: unresolved, inherited, still-unresolved, ambiguous (both directions), empty name span, same name, unknown file
- Collision safety by re-analysis (resolution print equality) over every watched file, edited or not (QA round 1, HIGH #1)
- Token-stream verification per touched file
`definewarnings, macro-invocation-argument warnings (QA round 1, HIGH #2), and unaccounted-occurrence warnings grouped by reason- End labels renamed with their declaration, through a lead-authorized
vlog_semanticchange (QA round 1, priority finding) lucisv_server:rename.rs,prepareRename+rename, capabilities- Tests: 64 in
vlog_refactor(14 unit incl. 8 masked-corruption attacks, 48 behavior, 2 corpus), 3 new invlog_semantic, 8 inlucisv_server(7 inrename.rs, 1 capability), 1 e2e session prepareRenameanswered from the open buffer and the index rather than fromsources()(2026-08-28):prepare_rename_herein the engine, the refusal-by-refusal parity table above, and six byte-by-byte parity suites againstprepare_renameas the oraclerenamecomputed over the symbol's fan-out rather than the whole scope (2026-08-28):Workspace::rename_sourcesin the server,rename_name_atin the engine, the sufficiency argument above, the ambiguity escape hatch, and equivalence tests over hostile workspaces- The dangling-use rung (2026-08-28, QA-driven rework):
WorkspaceIndex::files_spellingand rung 6 of the fan-out, applied to the new name, which closes the one refusal the first draft lost. The old name's exemption is argued under "The dangling-use case" and pinned by its own test - Implicit connections (2026-09-23, TODO-MCP M3.5):
.nameand.*rewritten explicitly in both directions (port and net), every rewrite warned about, the unreadable cases refused, and the verifier taught the shape (insertions under the splice contract + a shape rule; the binding print) with eleven attack pairs - Deferred: rename in comments and strings (rope's
docs=True) — the umbrella lists it as an option, off by default, "until asked for" - Deferred: renaming a module together with its file
(
workspace/willRenameFiles) — umbrella backlog - Deferred (honest limitation, documented in Preprocessor honesty):
hierarchical tails (
u_inst.sig) anddefparampaths stay warned-not-edited; resolving them needs instance elaboration, avlog_semanticnon-goal
Corpus acceptance
cargo test -p vlog_refactor --test corpus -- --nocapture, over the 860
.v/.sv/.svh files in corpus/ (Ibex, OpenTitan, PULP common_cells,
picorv32), 2026-08-24:
corpus rename over 860 files: Ok((6, 18)) in 0.38s (release; 1.7s debug)
Renaming prim_fifo_sync — a module OpenTitan instantiates all over — edits
6 files, 18 occurrences: the declaration, the instantiations, and the
.port/#(.PARAM) names that reach into it. Every edit slices back to
prim_fifo_sync in the file it names (asserted), and the whole thing takes
0.38 s in release over the full corpus, index rebuild and verification pass
included. The substring prefilter is what buys that: 860 files are indexed
twice, but only the handful that spell the name are analyzed.
The second test asks prepare_rename at 300 offsets spread over a real file —
whitespace, punctuation, mid-token, mid-comment, mid-directive — and requires
an answer at every one and a panic at none.
The tests assert the properties, not the numbers: no panic, every edit covers the name, more than one file touched, under 30 s, and a refusal (which is a correct answer — the corpus really does declare some names twice) reads as a sentence.
Work log
2026-08-24 — dev agent. Built the crate and the server wiring.
Key decisions, all argued above:
(PathBuf, String)slice as the file view, not a trait. The server already materializes exactly this list forWorkspaceIndex::build; a trait would have one implementor and would have to answer "what is the file set?" as well as "what is this file's text?", which the caller knows better.- Everything canonicalizes to a declaration before any edit is computed. Renaming from a reference is not a second code path; it is one extra overlay lookup at the front.
- Verification is two checks, not one. The token check catches lexical damage (an edit landing inside a string, a comment lost, two tokens merged); the resolution check catches semantic damage (capture, shadowing, a cross-file use silently rebinding). Neither implies the other: a capture leaves the token stream perfect, and a botched span leaves resolution plausible.
- The whole-file resolution print, rather than only the references spelling the old or the new name. The narrow check is sound, but the wide one is obviously sound, and a Verilog file's reference list is a few thousand entries at most.
- The substring prefilter is the one performance concession, and it rests
on a promise the semantic layer's corpus test already asserts (every
name_spanslices back to its name). - Unaccounted occurrences are warned about, not edited.
endmodule : mis the motivating case. Editing it would mean textual replacement, which this feature does not do anywhere; warning is the honest half-measure until the parser/semantic layer records the label. (Superseded 2026-08-24 by the rework entry below: end labels are references now and are edited.) - Server errors use LSP's
RequestFailed(-32803), which is what the protocol reserves for "the request was well-formed and the server declined"; VS Code shows the message in the rename box.prepareRenameuses the same code, which is how the editor is stopped from offering a rename that would later fail. Workspace::rebuild_indexand the newWorkspace::sourcesshare one helper (collect_sources), so a rename sees byte-for-byte the file set the index was built from, including the open-buffer overlay, without keeping a second copy of the workspace in memory.
Two things worth flagging for review:
endmodule : mlabels are warned about, not renamed. This is the one place a user could be surprised. The alternative needs a reference fromvlog_semanticfor the end label ("endmodule : mand other end labels record nothing",docs/features/vlog-semantic/README.md), which is a handshake for a later round rather than a textual patch here. (The lead authorized exactly that handshake; see the rework entry below.)- A
#[allow(clippy::mutable_key_type)]oncrates/lucisv_server/src/rename.rs, with the reason in a comment:WorkspaceEdit.changesis keyed bylsp_types::Uri, whose interior mutability is its own parse cache and takes no part inHash/Eq. The map's shape is the protocol's, not ours.
Checks at the end: cargo fmt --all -- --check clean,
cargo clippy --all-targets silent (zero warnings, workspace-wide),
cargo test --workspace green — 55 in vlog_refactor, 212 in lucisv_server's
unit suite, 12 e2e sessions, nothing else moved. No unwrap/expect/panic!
and no unsafe in any library path of either crate (test modules only).
2026-08-24 (later) — dev agent, rework after QA round 1 and the lead's three rulings. All three items closed; nothing else in the design moved.
1. End labels are renamed, not warned (priority finding). Taking the
lead's authorization, the change went into vlog_semantic and not into
vlog_parser: every node that can carry a label — Module (module and
interface), ItemKind::Package, ClassDecl, FunctionDecl, TaskDecl,
GenBlock, StmtKind::Block, StmtKind::ForkJoin — already carried
end_label and end_label_span, so there was nothing to add to the AST and
the spans suite never moved. bind.rs gains one target variant,
Target::Declaration(SymbolId), and one 20-line helper, use_end_label;
resolve.rs answers the variant with Resolution::Resolved(id).
The decision that matters is binding, not lookup: the label is recorded
as a use of the symbol the binder just created for that construct, so
end : inner inside a module cannot attach to a different inner declared
elsewhere, and no text matching is involved anywhere. Two cases deliberately
record nothing rather than guess — a label that does not spell the declared
name (endmodule : wrong, already illegal), and a label whose declaration was
a redeclaration that bound no symbol of its own (wire m; then begin : m).
Both then fall through to the warning path, which now names them precisely.
endclocking is untouched: a clocking block is opaque to vlog_semantic and
declares no symbol. Three tests added in vlog_semantic, five in
vlog_refactor — including the two masked-corruption attacks the lead asked
for: an end label belonging to a different construct of the same name must
not be edited, and // endmodule : m / "endmodule : m" in a comment and a
string must not be edited.
2. Third-file collision (HIGH #1). check::verify no longer iterates the
edited files; it iterates the watched files —
check.rs::watched_files — which is the edited set plus every in-scope file
whose text spells the old or the new name as a whole word. The soundness
argument is one sentence and is now in the Verification story: an edit only
adds and removes declarations of those two names, so a file mentioning
neither cannot change meaning. Whole-word text search rather than a token
scan, deliberately: it is a superset (a token always spells its name
literally), it needs no parse to decide, and over-inclusion costs one analysis
and never a refusal. QA's exact 3-file reproduction is now
a_collision_with_a_third_file_that_never_spells_the_old_name_is_refused,
and its mirror —
a_third_file_that_merely_mentions_the_new_name_in_a_comment_is_not_a_collision
— pins the no-false-refusal half. Corpus rename is unchanged at 0.35 s.
3. Macro-invocation arguments (HIGH #2). The README's promise was true of
`define bodies and false of macro calls, because a call is one opaque
token and unaccounted_warning compared whole token texts. New
Scope::macro_use_warnings scans macro-invocation tokens (Token::is_macro)
for the name as a whole word inside the argument list, in every in-scope
file that spells it — not only edited ones, since a call in an untouched file
still expands to the old name. They are warnings, never edits: opaque is
opaque. The Preprocessor honesty section was rewritten to describe exactly
this, and to state the hierarchical-tail/defparam limitation as the
limitation it is rather than burying it.
Bonus defect, fixed. The fixed `endmodule : X` warning template is
gone. unaccounted_warnings now groups strays by reason, read off the
token stream's neighbours (stray_reason): a . before the name means a
hierarchical or member tail; a : preceded by an end* keyword means an end
label that could not be attached; the rest say so plainly. One warning per
reason per file, naming the lines.
Checks after the rework: cargo fmt --all -- --check clean,
cargo clippy --all-targets zero warnings workspace-wide,
cargo test --workspace green at 1085 tests (was 1072).
2026-08-28 — dev agent (performance wave, Lane A). The rename family stops
reading the workspace. performance.md's two worst rows were
textDocument/rename (3.6–8.7 s) and textDocument/prepareRename
(2.5–3.0 s), both of them ws.sources() followed by a whole WorkspaceIndex
build; the measurer's own push-back — that prepareRename is what the rename
key sends before the box opens, not a rare user gesture — is the framing
this round took.
Everything argued under "The file set a rename reads" above. The decisions worth repeating here:
prepare_rename_heretakes an analysis, not a file set. The server already holds the buffer'sSemantics, itsExternalResolutionsoverlay and the index, and the overlay isresolve_externalagainst that same index — which is the exact callScope::declaration_across_filesmakes. So every refusal that depends on which declaration a use names is reproduced rather than approximated, and only the four that need the declaring file's own text are deferred.prepare_renamestays, as the oracle the parity tests measure against; the refusal sentences were factored into five functions so the two paths cannot word one situation two ways.- The fan-out's first rung is
workspace_symbols, notunits. This is the rung the whole equality argument turns on and the one that was easy to get wrong:follow_pathslooks a reference's own name up, inunits(N)ormember(u, N), and both tables are contributed only by files that declare the nameN. Drop the file declaringp::xfrom the set and a reference with paths[p::, q::]falls through toq::xand is renamed — an over-edit, corruption in the direction nobody looks. With rung 1 in place the Lemma makes the subset's resolution of every reference spelling either name identical to the workspace's, which is what buys "no missed edit" and "no extra edit" at once. - The new name gets the whole fan-out too, or refusal 12 (capture) dies: the file whose existing reference a rename would make ambiguous is in the new name's postings and in nothing of the old name's.
- The ambiguity escape hatch. An ambiguous use is recorded against the
declarations it could name, never against the file that writes it, so
refusal 10 cannot be reached from a subset.
rename_sourceshands backsources()when the index reports one. Slow and correct beats fast and silent. willRenameFilesgot the same treatment through the include graph — written up indocs/features/file-operations/README.md, including the four-lineIncludeGraph::includersaccessor, which is the one file this round touched outside its stated scope and is flagged there for the lead.
Measured, --release, and the equality checked as well as the clock:
| before | after | |
|---|---|---|
OpenTitan (3 976 files), prepareRename on the aes instantiation |
1.663 s | 139 ns |
OpenTitan, rename of aes (7 files edited) |
3.467 s | 105.5 ms (7-file fan-out) |
synthetic 504 files, prepareRename on a module name |
251 ms | 212 ns |
synthetic 504 files, rename (4 files edited) |
486 ms | 370 µs |
(All four re-taken after the 2026-08-28 rework below, so the table describes the shipped code. The earlier round measured 1.604 s → 135 ns, 3.284 s → 103.6 ms, 238 ms → 200 ns and 465 ms → 294 µs on the same corpus: the sixth rung is inside the noise, which is what the separate rung measurement above says directly.)
The OpenTitan numbers were taken with throwaway probes against the local
checkout and deleted — no test may depend on it. The reproducible probe is
perf::a_rename_before_and_after. The throwaway also swept every 7th byte
of tb.sv comparing prepare_rename_here against prepare_rename: 564
offsets, all identical, zero deferrals — the parity table's contract holding
over real code, not only over the six synthetic buffers in the suite.
What the OpenTitan sweep found, and it is not nothing. At the aes cursor
the two edit sets are byte-identical (7 files) and the warnings are 7 → 0:
tb__xbar_connect.sv and keymgr_dpe_scoreboard.sv spell aes only inside
macro-invocation tokens, which the index does not model in any table. Written
up in full under "The residue", with the cost of recovering it and a filed
request for the FileFacts macro-invocation census that would make it a
lookup. It is a lost warning, never a lost edit or a lost refusal, and it is
the lead's call at review — the honesty gate the brief asked for.
Deliberately not done: check::watched_files still sweeps the file list it is
given with contains_word, which is now the fan-out rather than the
workspace; no attempt was made to narrow it further, because it is O(files in
the set) over text already in memory.
Gates: cargo fmt --all -- --check clean, cargo clippy --all-targets clean
workspace-wide, cargo test --workspace green, node editors/vscode/smoke.js
OK against the release binary.
2026-08-28 — dev agent (QA-driven rework: the lost refusal is closed). The
lead ruled the round's "one lost refusal" residue not shippable — a silently
weaker refusal is not a residue we ship — and directed the fix. QA had found
it, reproduced it and pinned it as
known_residue_a_dangling_import_of_the_new_name_is_a_lost_refusal; that test
is now a_dangling_import_of_the_new_name_is_refused_by_both_paths and
asserts parity through same_answer instead of pinning the divergence.
The diagnosis, which is what makes the fix a rung rather than a patch: rungs
1–5 are every one of them keyed by a declaration. A file is in the set
because it declares the name, because a posting keys it to a declaration of
it, because it instantiates it, because a macro table mentions it, or because
it names the unit exporting it. A use that resolved to nothing has no
declaration to be keyed by — merge_references drops a StillUnresolved
result rather than posting it, correctly, since there is nothing to post it
against — and a rename's whole job is to change which declarations exist. So
import taken_pkg::* of a package nobody declares yet was invisible to the
fan-out and became meaningful the moment the rename landed, which is exactly
what capture rule 12 refuses over.
What changed:
WorkspaceIndex::files_spelling(name)— one additive, lead-authorizedvlog_semanticquery: every file holding an external reference fact spelling the name, resolved or not. No new state, no new field,FACTS_FORMATuntouched; it reads theFileFacts::referencesrecords the index already keeps, which is the only reason the answer is available at all without reading files. Logged indocs/features/vlog-semantic/README.md's work log as M2'sTarget::Declarationwas, and the recording rule it rests on is written into both Handshakes sections so it moves under supervision.- Rung 6 of
Workspace::rename_sources,want_spellers, applied to the new name only. The old name provably needs nothing: a rename only ever removes declarations of it, a resolving use of it is already in rung 2 (which walks every declaration of the name, not only the target's), and a non-resolving one cannot start resolving because a candidate was taken away. That argument is written out under "The dangling-use case" and pinned from the other side bya_dangling_use_of_the_old_name_needs_no_rung_of_its_own, which checks both that the new-name rung fires when the dangling spelling is the destination and that nothing is pulled in when it is a bystander. - The Lemma is unchanged — it was always about what a name resolves to, and it was always sound. What it never claimed, and what the sufficiency argument now says out loud, is which files hold a use. Rung 6 is that second question's answer.
The rung's cost, measured (the lead asked for the number, and for a
name-keyed side map as the fallback if it were large — it is not). On
OpenTitan's 3 976 files: 852 µs for a name nothing spells, which is the
worst case because any() cannot short-circuit, and 402 µs for clk_i,
which 681 files spell. The whole file-set build is 4.75 ms, most of it the
other rungs. rename itself went 103.6 ms → 105.5 ms, i.e. unchanged against
a 3.5 s baseline. On the synthetic 504-file corpus the rung is 49.8 µs of a
128.7 µs set build; both are printed by perf::a_rename_before_and_after,
which grew two lines for them.
Re-verified after the rework, against the real OpenTitan checkout: all four
cursors still byte-identical (aes 7 files, clk_rst_if 114 files, .clk_i
4 files), the capture refusal on aes → prim_fifo_sync still verbatim, the
warning counts unmoved. The refusal parity table is unaffected — it is
prepareRename's, and neither entry point's refusal set changed; what changed
is which files rename reads before producing rule 12's.
The macro-invocation warning residue stands as documented — the lead
accepted it on the record, and the FileFacts macro-invocation census remains
filed as the real fix.
Gates after the rework: cargo fmt --all -- --check clean,
cargo clippy --all-targets clean workspace-wide, cargo test --workspace
green, node editors/vscode/smoke.js OK against the release binary.
2026-09-23 — dev agent (M3.5, implicit connections). The engine rewrote
nothing it could not see a reference for, and .name/.* bindings have no
reference — see "Implicit connections" for the contract, the refusals and the
verifier's new half. Key decisions:
- AST walk, not semantic references. The semantic layer records the port
half of
.name(so a port rename already edited.d→.din) and nothing of the net half or of.*(bind/item.rs::bind_connectionskips*and bindsexpr: Noneto nothing).vlog_semanticis not this lane's to change, so the bindings are re-derived from the parse — one walk (rename/sites.rs) that the engine and the verifier both read, so the two cannot disagree about where an implicit connection is or where its name binds. Filed as a Handshake request. - Insertions only. The shorthand's port half is already the rename's
edit; the net half is an insertion right after it, fused into one
TextEdit(p→q(p)) only after verification, so the verifier sees a pure rename edit plus a pure insertion. A.*gets an appended element, so nothing the source wrote is replaced and no comment can move. check/learned the shape rather than being bypassed. A file with insertions is checked by the splice contract the port refactorings already use plus a four-template shape rule; the binding print is a new check, and it is strictly more than the rename had (every file it prints was already compared by the reference print). Sabotage-verified.- Prefilter.
sites::may_connect_implicitlykeeps the engine and the verifier from parsing files that cannot hold an implicit connection of either name; the parse-budget tests (K + E) are unchanged and pass. - OpenTitan, read-only, on a scratch copy of
hw/ip/prim+hw/ip/aes(393 files, release, whole-scope).prim_fifo_sync's portclr_i→clr_qis refused:prim_fifo_sync_bind_fpv.svwritesbind i_nopass1 prim_fifo_sync_assert_fpv … (.clk_i, .rst_ni, .clr_i, …), abindinto an instance namedi_nopass1— which is aprim_fifo_syncinprim_fifo_sync_tb, so the old engine would have cut those twelve bindings silently. With that one file left out of scope the same rename succeeds (115 ms, 3 files, 16 edits): eleven.clr_i→.clr_q(clr_i)inprim_fifo_sync_tb.sv, andprim_fifo_sync's ownu_fifo_cnt (.clr_i, …)→.clr_i(clr_q)— both directions in one rename. Renaming the testbench's own portclr_i→clr_tbwrites(clr_tb)after the eleven shorthands. A.*user: renamingfi_control_fsm_wrapper's portaes_ctrl_cs→ctrl_csadds, .ctrl_cs(aes_ctrl_cs)tobind aes_control_fsm … u_fi_ctrl_fsm (.*)(the bind's target declaresaes_ctrl_cs) and, .aes_ctrl_cs(ctrl_cs)to the wrapper's ownfi_control_if fi_if (.*); renamingaes_control_fsm's variableaes_ctrl_cs→ctrl_state_qadds.aes_ctrl_cs(ctrl_state_q)to the same bind. Each rename ~110 ms. - The server's fan-out step (2026-09-23, lead ruling on Handshake 1).
Workspace::rename_sources_tracednow adds, after the open buffers, the declaring file of every module instantiated in a handed-over file — one hop down the index'sinstantiations()edges,bindincluded (module_select::instantiated_by, a walk over records; nothing is read). So a.*into a module that declares neither name is handed over and read as binding nothing, instead of refused as unreadable; a.*into a module the workspace does not hold is still refused. The added files count inselectedand in the indirect census (asinstantiation) but not in the per-rung counts:SelectionTrace's counter is private torename_trace.rs, which this lane does not own. Pinned by two wire tests (server/tests/rename_implicit.rs: an open-buffer net rename besidequiet u_quiet (.*)andleaf u_leaf (.*)succeeds with, .d(x)and no edit tou_quiet; the same withquietabsent is refused namingu_quiet) and one unit test of the helper. The engine is unchanged by it. - Deviation from the brief: the MCP tool description's known-limit
sentence was replaced by one saying what happens now (the connection is
written out and listed in
warnings), rather than only deleted.
2026-09-23 — dev agent (M3.5 rework after QA's FAIL).
- Finding 1 — insertions checked for their text, never their place.
check/implicit.rs::insertions_matchnow also asksSlots::takes: each insertion's offset must be a place the before-tree'ssiteswalk (the engine's own) says a connection list takes that template — see "How the verifier accounts for it", item 1. QA's three tests (check/qa_implicit.rs, registration kept incheck/mod.rs) are un-ignored and pass unchanged; two attacks of my own pin that the check keys on the file's sites, not on a byte:(d)at an offset that is a shorthand's end intop2.svis refused in a file where the same offset ends a positional element, and in one file(d)/,after the positionaldof a second instance is refused beside the honest shorthand rewrite of the first. Sabotage-checked: with the position check off, those two and QA's three fail. - Finding 2 — a
bindinto a bare instance name refused unrelated renames.connections.rs::bind_reachesclassifies each bind (module / maybe / elsewhere);instance_ownersresolves a lone instance name throughWorkspaceIndex::instantiations()— the enclosing module's own instances of that name first (upward resolution, IEEE 1800 §23.11, which is what opentitan'sbind dut … (.*)insram_ctrl's andentropy_src'stb.svmeans), every indexed instance of that name otherwise. All owned by other modules → skipped; one is the renamed module's, or none is indexed → refused as before. QA's test un-ignored and passing; two of mine: an instance name owned by bothfifoandcntrefuses acntrename (and is skipped withcnt's bench removed), and a bind written beside its ownfifo dutisfifo's even though another bench has acnt dut. One step past the ruling, stated: the enclosing-module preference. Without itentropy_src'sclk_istays refused oversram_ctrl'sbind dut, since opentitan has eight modules nameddut; with it that rename succeeds, and the refusal still fires wherever the bind's own module declares an instance of the renamed module. Known gap (QA note 1, accepted): abindonto an instance that exists only inside a generate block of the enclosing module is treated as that instance's module's and, when that is another module, skipped silently — upward resolution would not see into the generate block and would look further up. - Size.
check::verify94 → 79 lines: step 1 (token check) is nowtokens_verified, the per-file inserted rangesimplicit::inserted_in, step 3's call a two-liner. Pure moves; no behaviour change, and the same tests pass. - Rework 2 (QA re-check, finding 3).
Slots::takesadmitted a lone,at the end of any.*list;other u_o (.*)→(.*,)verified clean where the list binds neither name, since the tolerant parser reports no error. The comma is now accepted only when the same file's edits also insert a bare.X(Y)into the same list — the comma-before-//pair as a pair, mirroring the requirement the bare connection already had. QA'sqa_r_a_lone_trailing_comma_on_a_wildcard_binding_neither_nameis un-ignored;a_comma_and_its_connection_in_different_lists_are_refused(mine) crosses two lists' halves and is refused. The parser gap is filed in Handshakes. - OpenTitan re-run (scratch copy grown to 489 files:
prim,aes,entropy_src,sram_ctrl; release, whole-set engine):prim_count.err_o→error_oOK (14 files, 17 edits; two shorthands written out);prim_count.clr_iOK;aes_core.clk_iOK (3 files, 24 edits);entropy_src.clk_iOK (5 files, 10 edits, among them theentropy_src_cov_bind.sv.*gaining.clk_i(clock_i));prim_packer_fifo.wready_oOK;prim_fifo_sync.clr_istill refused overbind i_nopass1 …(those instances areprim_fifo_syncs); the twoaes_ctrl_csrenames unchanged.
2026-09-23 (lead, after the final re-check). QA finding 4 fixed by the
lead: check/implicit.rs::Slots::of registers no slot for a list holding
an error element (the engine already refuses such lists); QA's test
un-ignored, and QA's own pin of the old behaviour in
qa_p_a_pair_after_an_error_element flipped to the stricter rule. Gates
through tools/guard.sh: fmt, clippy, vlog_refactor 616 passed, workspace
4 761 passed.
2026-09-30 — dev agent (TODO §65.1, generate-label-rename). A rename of
a generate block label now rewrites every path through it — g[0].x,
g_a.g_b[2].x, u_x.g[1].sig from another file — with the label and its
closing label, and find_references lists them; named procedural blocks'
end : lbl and disable lbl are the same set. The engine and the verifier
are unchanged in code: the fix is in vlog_semantic (a for block's label
declared in the enclosing scope, generate regions transparent, blocks as
member scopes, index-transparent spines, blocks on the index's hierarchical
surface under module.label), after which a missed segment is a reference
that stops resolving and the existing resolution print refuses it — pinned by
eight attacks in check/qa_block_paths.rs. docs/features/generate-label-rename.
2026-10-07 — correction (independent review M-3). The 2026-09-30 entry
above says the engine and the verifier are "unchanged in code"; that held
for the first pass only. The §65.1 reworks added rename-warning modules
(rename/paths.rs, arms.rs, home.rs, scoped.rs, later carry.rs) and
path-qualified file names in every refactoring's messages, the verifier's
included (Scope::name_of). What a rename rewrites, and what the verifier
forgives, did not change. docs/features/generate-label-rename.
QA log
2026-08-24 — QA agent.
Gates
cargo fmt --all -- --check— clean.cargo clippy --all-targets— clean, zero warnings, workspace-wide (verified with a forced re-check aftertouching the new files, since the first run was a no-op cache hit).cargo test --workspace— green, 0 failures across every crate. Counts match the Work log's claims:vlog_refactor55 (14 unit incl. 8 masked-corruption attacks incheck.rs, 39 behavior intests/rename.rs, 2 corpus),lucisv_serverunit suite 212,lucisv_servere2e 12 sessions (the_binary_serves_a_whole_session_over_stdioand friends).- Spot-checked the "no
unwrap/expect/panic!/unsafein library paths" claim: the onlyexpect()calls incrates/vlog_refactor/src/check.rsare inside#[cfg(test)] mod tests(lines 302-303, 380). None incrates/lucisv_server/src/rename.rsoutside its test module. The single#![allow(clippy::mutable_key_type)]inlucisv_server/src/rename.rs:13carries the required explanatory comment (lines 8-12). All confirmed. - All three gates: pass, claims confirmed.
Priority finding — stale end labels (assessed, not fixed)
Reproduced with the crate's public API for every construct that carries an
end label. Given module m; ... endmodule : m, renaming m produces
module top; ... endmodule : m — the label is untouched, and a warning is
attached ("1 occurrence(s) of m ... are not resolved references ... and
were left unchanged."). This is IEEE 1800 non-compiling output (the end
label must match) but the dev's own test
(crates/vlog_refactor/tests/rename.rs:561 an_end_label_is_left_alone_and_reported)
asserts exactly this as intended behavior, and the Work log already flags it
for lead review.
I reproduced the same pattern for every other end-labeled construct, which the milestone spec didn't enumerate individually — all of them are affected, all of them only warned:
function ... endfunction : f→ label staysfafter rename tog.task ... endtask : t→ label staystafter rename tou.class ... endclass : c→ label stayscafter rename tod.package ... endpackage : p→ label stayspafter rename toq.begin : blk ... end : blk(named block) → label staysblkafter rename tonewblk.
Bonus defect while reproducing this: the warning text is a fixed
template that always says `endmodule : X` — literally, regardless of
which construct produced the stray occurrence
(crates/vlog_refactor/src/rename.rs:497). For the function/task/class/
package/block cases above, the warning shown to the user names the wrong
keyword (e.g. renaming a task still says an `endmodule : t` label,
never endtask). Small, but it actively misleads whoever reads the
warning while trying to find and fix the stale label by hand.
Verdict on severity: this is a real, reproducible non-compiling-output
defect, but it is a known, deliberate, tested, and disclosed tradeoff — the
dev flagged it explicitly for review and the Status/TODO says why
(vlog_semantic records no reference for end labels yet). I'm not treating
it as a blocking QA finding on its own; it needs the lead's call on whether
M2 ships with this caveat or waits for the vlog_semantic handshake. I am
flagging the warning-text bug above as new information the lead should have.
New finding (HIGH) — a rename can be accepted while silently making an
untouched third file's existing reference ambiguous
The README's rule 12 / "verification story" claims collision safety is
checked "in both directions ... an existing use of y being captured by
the renamed declaration," over the whole workspace. In the implementation
this is only true for files that themselves received an edit
(crates/vlog_refactor/src/check.rs:47-78 iterates edits/edited, which
only contains files collect_edits touched — i.e. files that spell
old_name). A file that spells only new_name, and never old_name, is
outside the substring prefilter (rename.rs:351) and is never re-analyzed
before/after, even though rebuilt_index (check.rs:86-95) does include
its real, unedited text — so the ambiguity really exists in the rebuilt
index, it's just never diffed against anything.
Reproduction (workspace of 3 files, using the public API directly):
sub.sv: module sub;\nendmodule\n // rename target; nothing else in scope mentions "sub"
child.sv: module child;\nendmodule\n // pre-existing, unrelated module named "child"
top.sv: module top;\n child u1();\nendmodule\n // instantiates child.sv's child; never spells "sub"
rename(&files, &path("sub.sv"), <offset of "sub">, "child") returns Ok
with one edit (sub.sv only) and warnings: []. After applying it, the
workspace has two modules named child (the renamed one in sub.sv, and the
pre-existing one in child.sv), and top.sv's child u1(); — which used to
resolve unambiguously — is now ambiguous. top.sv's bytes are untouched, so
there's no textual corruption, but its meaning silently broke and nothing
in the response says so. This is the same shape as the milestone's own
a_collision_in_another_file_is_refused_too test
(crates/vlog_refactor/tests/rename.rs:474) — except that test's top.sv
already instantiates both sub and child, so top.sv is itself in the
edited set and the existing check catches it. Drop the sub instantiation
from top.sv (nothing else needs to reference the rename target for the
collision to be real) and the refusal silently disappears.
This is not the end-label case: there is no warning, no partial edit, no
indication anything is wrong — rename reports full success. It directly
contradicts the "both directions" claim in the Verification story section
and, I'd argue, the umbrella's "refuses rather than guesses" principle. I
did not fix it (would need check.rs's resolution-identity pass to run over
every in-scope file with a nonempty diff against rebuilt_index, not just
edited — a real design change, not a small fix). Verified reproducible on
a second run. The probe test itself was scratch (not committed); the repro
above is exact enough to rebuild in under a minute.
New finding (HIGH) — macro-invocation arguments are silently never
renamed, with no warning, contradicting the "Preprocessor honesty" section
The README states plainly: "text inside a macro invocation's arguments ... are left alone and warned about." Reproduced the opposite: given
`define BUMP(x) x = x + 1
module m;
int a;
initial `BUMP(a);
endmodule
renaming a → b (from the int a; declaration) returns Ok with the
declaration and no other edits, and warnings: [] — the a inside
`BUMP(a) is left as literal text a, and nothing tells the user.
Root cause: vlog_parser::tokenize lexes an entire macro invocation
(name and its parenthesized arguments) as one opaque Ident token
(confirmed by direct tokenization: `BUMP(a) tokenizes to a single
Ident token with text "`BUMP(a)", span covering the whole thing —
consistent with vlog_semantic's own scan::tests::a_macro_invocation_is_one_opaque_token).
unaccounted_warning (crates/vlog_refactor/src/rename.rs:470-501) looks
for stray Ident tokens whose text equals the target name
(t.kind == TokenKind::Ident && t.text == name, line 488). Since the
argument's text is buried inside a bigger token ("`BUMP(a)" ≠ "a"),
it can never match, so this class of occurrence can never produce the
warning the README promises for it. This is different from the endmodule : m case: there, a warning is correctly produced (the label is its own
plain Ident token). Here, the mechanism that would normally catch "text
the layer records nothing for" structurally cannot see inside an opaque
macro-invocation token, so the specific promise in the README is simply
false as implemented.
This one is worse than the end-label case for the same reason as the
collision finding above: complete silence. A user renaming a variable that
happens to be passed through a function-like macro gets an Ok, zero
warnings, and a file that no longer behaves as documented (the macro
expansion still uses the old name, the declaration doesn't exist under that
name anymore). Whether the right fix is "warn, like macro bodies" or
"refuse when a macro invocation argument spells the name" is a design call
for the dev/lead — the README already committed to "warn," so at minimum the
implementation doesn't match its own contract.
Other attack attempts — passed, no corruption found
- Port name vs. connection signal name,
.p(p). Renaming the port declaration only rewrites the connection-name side (.p(...)→.port_new(...)), leaving the connected signal alone. Renaming the signal only rewrites the expression side (.p(sig_new)), leaving the port name alone. Both directions correct. - Genvar used inside a
generate/forloop. Declaration and every use inside the loop header and body renamed correctly. - Two symbols with the same name in sibling scopes (
begin : b1 int n; end/begin : b2 int n; end). Renamingb1'snleavesb2'snuntouched — matches the dev's owna_name_that_only_shadows_somewhere_the_rename_never_reaches_is_allowedtest, reproduced independently with a different shape. - Module instantiated via
bind.bind top leaf b_leaf ();— renamingleafcorrectly updates thebindstatement's target type along with the declaration. - Hierarchical reference tail,
u_inst.siganddefparam u1.P. Both left unedited and both correctly warned about as "a hierarchical or member tail" — consistent with the README. (Note: likeendmodule : m, this means adefparamtargeting a renamed parameter is left referencing the old parameter name — also non-compiling output, also warned-not- fixed, same class of issue as the priority finding. Didn't reproduce every variant given the time budget; flagging so the lead's end-label decision coversdefparampaths too, not justendmodule/endlabels.) - New name requiring escaping (leading digit, e.g.
1bad) — refused with "not a valid Verilog identifier," as expected. - Rename inside a file with error nodes (tolerant parse, garbage statement present) — renamed the valid declaration/use correctly, no panic, garbage left untouched.
new_name == old_name, comments/strings, ambiguous declarations, unresolved/inherited candidates — all covered by the existing suite; read and spot-re-ran, all still refuse/behave as documented.
Real server binary over stdio
Built target/debug/lucisv-server and drove it directly with a hand-rolled
LSP/stdio client (initialize → initialized → didOpen →
textDocument/rename → shutdown → exit), not just the crate's Rust
tests:
- Multibyte-position case. File with
/* é 🎉 */ wire a;as one line — "é" (1 UTF-16 unit, 2 UTF-8 bytes) and "🎉" (2 UTF-16 units/surrogate pair, 4 UTF-8 bytes) sit before the target identifier on the same line, so byte offset (21), UTF-16 offset (18), and char count (17) all disagree. SenttextDocument/renameat{line: 1, character: 18}(UTF-16, per the server's advertised"positionEncoding": "utf-16"). Got back aWorkspaceEditwith the edit range exactly{18, 19}on that line — the "a" and nothing else. Correct. - Refusal case. Same file, rename to
module(a keyword). Got back a JSON-RPC error,code: -32803(RequestFailed),message: "lucisv: \module` is a Verilog keyword."— matches the documented-32803` refusal convention exactly.
No issues found in the LSP-layer UTF-16 handling or the refusal wiring.
Summary
| Claim | Verdict |
|---|---|
cargo fmt / cargo clippy / cargo test --workspace clean |
Pass |
| Test counts (55 / 212 / 12) | Pass, confirmed |
| No unwrap/expect/panic/unsafe in library paths | Pass, confirmed |
Stale end labels (endmodule/endfunction/endtask/endclass/endpackage/named end) |
Confirmed, all affected, all warned-not-fixed — known/disclosed, lead's call |
| Collision safety "both directions" over the whole workspace | Fails — silent, only checked for files that were themselves edited |
| Macro-invocation-argument occurrences "warned about" | Fails — silently never renamed, never warned, contradicts README |
Everything else attempted (port/signal, genvar, sibling shadowing, bind, hierarchical tails, defparam, escaped names, tolerant parse, UTF-16 offsets, keyword refusal over real stdio) |
Pass |
No fixes applied — none of the findings were small/unambiguous; each needs a
design decision (collision-check scope, macro-argument policy, or the
vlog_semantic end-label handshake) that's the dev's/lead's call, not
QA's. No temporary probe files were left in the tree (added, exercised, then
removed).
2026-08-24 (round 2) — QA agent. Re-verification after the dev's rework of all three round-1 findings, per the lead's rulings.
Gates
cargo fmt --all -- --check— clean.cargo clippy --all-targets— clean, zero warnings, workspace-wide (forced re-check aftertouching every changed file, not a cache hit).cargo test --workspace— green, 1085 tests, 0 failures — matches the Work log's number exactly (was 1072 in round 1).vlog_refactoris now 64 (14 unit, 48 behavior intests/rename.rs, 2 corpus);vlog_semantic'ssemantics.rsgained new tests too (see the count note below).- Corpus rename re-timed in release: still 0.35 s over the 860-file
corpus,
Ok((6, 18))— matches the dev's claim, confirming thewatched_fileswhole-word scan added for the collision fix did not regress the thing round 1's corpus number was checking. - One small count discrepancy, not worth blocking on: the Work log/Handshakes
say "3 new tests" in
vlog_semantic;git diffshows 4 newfns incrates/vlog_semantic/tests/semantics.rs(an_end_label_is_a_use_of_the_declaration_it_closes,an_end_label_never_attaches_to_a_same_named_declaration_elsewhere,a_label_whose_name_is_already_bound_in_the_scope_records_nothing,a_mismatched_end_label_records_nothing_rather_than_guessing), and the test-run total (23, was 19) agrees with 4, not 3. Cosmetic — the count in prose just undercounts what's actually there. - All three gates: pass, claims confirmed (with the harmless count note above).
Round-1 finding #1 (priority) — end labels: verified fixed
Re-ran the exact round-1 reproductions (module/function/task/class/package/
named-begin) plus fork/join and interface, which round 1 didn't try:
module,function,task,class,package, namedbegin/end,fork : f/join : f, andinterface/endinterfaceall now rename their end label along with the declaration. Confirmed for every construct in the dev's list, not just the ones the milestone spec named.- The masked-corruption case (a different construct's end label happens to
spell the renamed name): built independently of the dev's own test —
module m; endmodule module other; endmodule : m(the: monotheris already-illegal SV, since it doesn't matchother) — renamingmleavesother'sendmodule : muntouched, with a warning naming it as "an end label lucisv could not attach to its declaration." Correct: it must never attach by name. -
- The "redeclaration binds no symbol" case: `wire m; initial begin : m ... end
- m
(a block label colliding with an existing net name — pre-existingvlog_semanticcollision-handling, not part of this round's diff). Renaming the wire correctly leaves the block's *end* label unedited and warned; nothing panicked or silently misattached. (The block's own *begin* label did move with the wire, because the pre-existing, untoucheddeclare_with_scope` collision logic treats it as a reference to the wire rather than a fresh declaration — that's inherited behavior from before M2, not a round-2 regression, and it's not this milestone's to fix.)
One dead end worth recording so it isn't retried: I initially wrote a
"nested same-named begin blocks" attack (begin : x inside another
begin : x) nested inside two initial statements — initial begin : x initial begin : x ... end : x end : x. That is not legal SystemVerilog (a
bare statement list cannot contain a second initial), and under that
malformed input the wrong end label moved. I re-ran it with the legal form (a
bare begin nested directly inside the outer block's statement list, no
second initial) and it was correct in both directions — renaming the
outer x moves only the outer begin/end, renaming the inner x moves
only the inner pair, confirmed with the AST (vlog_parser::parse_source_tolerant)
and the Semantics reference table directly: the inner end label
(Reference[0], span 67..68) resolves to SymbolId(2) (inner), the outer
end label (Reference[1], span 77..78) resolves to SymbolId(1) (outer) —
exactly the "binding not lookup" design working as claimed. So: nested
same-named begin blocks are fine; the earlier scare was my own invalid test
input, not a defect. Flagging it in case another QA pass reaches for the same
attack shape and hits the same red herring.
Verdict: fixed. Every construct renames its end label with the declaration; the two documented can't-attach cases (mismatched label, redeclaration) fall through cleanly to a warning with no corruption or misattachment in either.
Round-1 finding #2 — third-file collision: verified fixed
Re-ran the exact round-1 repro (sub.sv/child.sv/top.sv, renaming sub
to the name of a module top.sv already instantiates, where top.sv itself
never spells sub): now correctly refused —
renaming subtochildwould change whatchild means in top.sv; the rename was abandoned. Matches the dev's own new regression test
(a_collision_with_a_third_file_that_never_spells_the_old_name_is_refused).
New attack for round 2: the same 3-file shape, but sub.sv's only mention in
top.sv is inside an `ifdef NEVER_DEFINED-guarded arm (so the
"collision" instantiation of sub is never even active). Still refused, for
the right structural reason: watched_files is a whole-word text search,
which does not know or care about `ifdef, so top.sv is watched
regardless of whether the arm is compiled — the safe, over-inclusive
direction the README argues for. This is consistent, not a new bug: refusing
a rename that's arguably "fine" because the colliding text lives in a dead
`ifdef arm is the conservative failure mode, not a corruption risk.
Also checked the no-false-refusal mirror the dev added
(a_third_file_that_merely_mentions_the_new_name_in_a_comment_is_not_a_collision)
by reading it — it exercises exactly the "over-inclusion costs an analysis,
never a refusal" argument from the Verification story section.
Verdict: fixed, and the fix's stated soundness argument (whole-word
superset of "has a token spelling the name") holds up under an `ifdef
attack that specifically tries to exploit the gap between "spells the name"
and "the code path is actually reachable."
Round-1 finding #3 — macro-invocation arguments: verified fixed
Re-ran the round-1 repro ( `define BUMP(x) x = x + 1 /
`BUMP(a), renaming a): now warned —
"a appears in the arguments of the macro invocation BUMP at m.sv:4 and
was left unchanged; a macro invocation is one opaque token to lucisv, which
does not expand macros." Matches the dev's new test
(the_name_inside_a_macro_invocations_arguments_is_warned_about).
New attack for round 2: split the invocation across lines —
`BUMP(\n a\n );. Still warned, correctly, at the invocation's own
starting line (4). macro_use_warnings scans the whole opaque token's text
for the name as a whole word, so line-splitting inside the argument list
doesn't defeat it (the token itself spans all the lines; the warning names
where the invocation starts, which is reasonable — it's the only stable
anchor an opaque token has). Also spot-checked a_macro_invocation_in_an_ untouched_file_is_warned_about_too in the dev's own suite, which is exactly
the "warn even where nothing gets edited" half of the original finding.
Verdict: fixed.
Additional round-2 attacks — passed, no corruption found
- End label inside a
generate/forloop body (for (...) begin : g ... end : g): both the loop-body label and its end label rename correctly. (Note: this is a single source-level declaration —vlog_semanticdoes no elaboration, so there is no "genblk array" to worry about at this layer; the concern from the attack list doesn't apply to a static analyzer that never unrolls loops.) - Whole-word matching edge cases: target name
anext toa_b(no false match,a_buntouched); target nameainside a based literal8'ha(the literal's preceding bytehis alphanumeric, socontains_wordcorrectly does not treat it as a whole-word occurrence — confirmed the literal is byte-for-byte unchanged in the output). - Escaped identifier
\avs. plaina: renaming barealeft\acompletely untouched, no warning. Checked why:vlog_parser's lexer keeps the backslash in the token's text (lexer.rs:304-317), sovlog_semantictreats\aandaas two unrelated identifier spellings rather than the same identifier IEEE 1800 §5.6.2 says they denote. That is a pre-existingvlog_semantic/vlog_parsersimplification with no connection to this round's diff (nothing inbind.rs/resolve.rs's changes touches escaped identifiers), so I'm not filing it against M2 — noting it only so it's on record if the lead wants it filed againstvlog_semanticseparately. It is not a corruption risk either way: since the two are already unrelated symbols in this codebase's model, leaving\aalone is consistent with that model, not a violation of it. fork ... join : fandinterface ... endinterface : ifc: both rename correctly with their declarations (constructs the round-1 report didn't individually try).
Summary (round 2)
| Round-1 finding | Round-2 verdict |
|---|---|
| Stale end labels (priority finding) | Fixed — verified across every construct including fork/join and interface; masked-corruption case and the redeclaration edge case both still refuse cleanly |
| Third-file collision (silent) | Fixed — verified with the original repro and a new `ifdef-arm variant |
| Macro-invocation arguments (silent) | Fixed — verified with the original repro and a multi-line invocation variant |
| Gates (fmt/clippy/test) | Pass, 1085 tests, 0 failures, corpus rename still 0.35 s |
| New attacks this round (genblk-in-loop, nested same-name labels, whole-word edge cases, escaped identifiers, fork/join, interface) | Pass — no new corruption found; one pre-existing, out-of-scope vlog_semantic observation noted (escaped identifiers), one invalid-syntax red herring from my own probe recorded so it isn't retried |
No fixes applied this round — nothing found needed one. No probe files left
in the tree (crates/vlog_refactor/tests/qa_probe2.rs and the throwaway
/tmp AST/semantics probes were added, exercised, and removed).
Overall verdict: ship. All three round-1 findings are genuinely closed,
not just papered over — I attacked each fix's actual mechanism (whole-word
text search's blind spots, opaque-token scanning across line breaks, binding
vs. lookup under nesting) rather than re-running the original repro
unchanged, and the fixes held. The vlog_semantic change is scoped exactly
as narrow as the Handshakes section says (additive, one target variant, one
helper, no vlog_parser change), and the remaining warned-not-fixed
surface (hierarchical tails, defparam paths, mismatched/redeclared end
labels) is honestly disclosed and consistent with the "lucisv does not
preprocess / does not elaborate" boundary the umbrella already draws.
2026-08-28 — QA agent (performance wave, Lane A). Verified the round that
moves prepareRename and rename off ws.sources(). Adversarial charter:
find a rename that edits, warns or refuses differently than the
whole-workspace path would, or a prepareRename that lies. Worked in
.claude/worktrees/agent-a2cccf825469bf247.
Gates
cargo fmt --all -- --check— clean, after fixing formatting in QA's own additions (cargo fmt --all; the dev's diff itself was already clean).cargo clippy --all-targets— clean, zero warnings, forced re-check aftertouching every file this round changed.cargo test --workspace— green, 0 failures, across every crate (doc-tests included).node editors/vscode/smoke.js target/release/lucisv-server— OK, 10 messages, against a freshly built release binary carrying this round's diff plus QA's added tests.- Numbers reproduced against the actual code under review (not trusted from
the Work log),
cargo test --release -p lucisv_server --bin lucisv-server perf:: -- --ignored --nocapture --test-threads=1:prepareRename238.29 ms → 179 ns;rename466.54 ms → 294.9 µs;willRenameFilesscope-read 11.39 ms → includers-read 15.1 µs. All within noise of the Work log's claims. (Two unrelated corpus-dependent perf tests failed in this worktree becausecorpus/is not checked out here — pre-existing, unaffected by this diff, confirmed present inHEADbefore this round's changes.) - Real OpenTitan checkout (
/Users/guoliangchen/repo/opentitan@0098135264, 3979 files, matchingperformance.md's provenance), driven over real LSP/ stdio with a client pointed at this worktree's owntarget/release/ lucisv-server(not the dev's throwaway probes, and not the earlier "instrumented" binary from the measurer's session): cold workspace scan settled in 2 940.7 ms; six repeatedrenames ofaesaveraged ~104 ms and all edited exactly the 7 files the Work log names (tb.sv,aes.sv,aes_wrap.sv,aes_tb.sv, and the three*_pd_main.svtop-level instantiation sites); four repeatedprepareRenames on the same cursor averaged ~0.05 ms client-observed (the LSP round trip, not the dev's in-process 135 ns — consistent withperformance.md's own 0.02–0.33 ms transport floor: the request now costs essentially nothing but the pipe). All three gates and the numbers: pass, claims confirmed.
Confirmed finding (HIGH, disclosed by the dev, verified real and exactly
as bounded) — the residue's "one lost refusal"
The README's own "The residue" section names a case the fan-out cannot catch:
a file whose only mention of the new name is a bare reference that
resolves to nothing today (an import new_name::* of a package that does not
exist yet, or a type spelled new_name). The whole-workspace verifier refuses
such a rename (capture rule 12: the import would start meaning something);
the fan-out never reads that file, so it returns Ok instead — a materially
weaker answer, not merely a lost warning like the macro-invocation case below
it. I built the minimal repro and pinned it as a permanent regression test,
crates/lucisv_server/src/rename.rs,
known_residue_a_dangling_import_of_the_new_name_is_a_lost_refusal: package
cfg_pkg renamed to taken_pkg, with a third file module strayer; import taken_pkg::*; endmodule that declares, references (under the old name) and
instantiates nothing. vlog_refactor::rename over the whole scope refuses
("...would change what taken_pkg means in stray.sv..."); over
Workspace::rename_sources's real output, it succeeds silently. Confirmed
this is exactly as narrow as documented — every attack in the next section
(new-name declared elsewhere, new-name instantiated elsewhere, new-name
reached via a member connection) is still caught by rungs 1/3/5, so the gap is
precisely "an unresolved bare reference to the new name, nothing else." This
is not a new defect: it is the dev's own disclosed residue, verified to
reproduce exactly as written and correctly bounded. Recorded per CLAUDE.md
invariant 4's spirit (a widened forgiveness needs attack tests proving the
boundary) even though this is a narrowing, not verify.rs, because the same
"guilty until proven innocent, with tests" discipline applies to any new gap
between the fast and slow paths. This is the one item that needs the lead's
explicit ruling before ship — the brief's own honesty gate.
Attacks that held — no divergence found
All added as permanent regression tests in crates/lucisv_server/src/rename.rs
unless noted, run against the real Workspace::rename_sources/
prepare_rename_here production code paths, not reimplementations:
- Escaped-identifier instantiation (
\sub u_weird (...)- a different name tovlog_semanticthansub, a pre-existing simplification this round did not touch):an_escaped_identifier_instantiation_does_not_break_fan_out_parity. Both paths call the identical engine, so the escaped spelling is untouched by both, byte-identical — the fan-out dropping the file (it posts nowhere) changes nothing observable, since the whole-workspace run's own watch of it is also a no-op. - Same spelling, different symbol kind (a module named
subvs. an unrelated wire also namedsubin a different module):a_same_spelling_different_symbol_kind_is_not_captured_by_the_fan_out. The unrelated wire's file and declaration are never touched. - Escape hatch discovered on the second spelling, not the first — the
ambiguity is on the new name only, so
fan_out_of's loop over[name, new_name]must not leak a partially-built, too-narrowwantedset when it bails on the second iteration:the_escape_hatch_fires_when_only_the_new_names_posting_is_ambiguous. Falls back to the whole scope correctly;Workspace::rename_sources's earlyreturn self.sources()on the first ambiguous hit (state.rs,fan_out_of) discards the partial set rather than returning it, exactly as needed. - Prepare parity fuzz beyond the dev's six buffers
(
crates/vlog_refactor/src/rename.rs): a valid head followed by an unparseable tail, CRLF line endings, multi-byte UTF-8 text ahead of the probed identifiers, and a macro-heavy buffer (`ifdef/`define/`BUMP(x)all in one file) — every offset of every buffer, no divergence, no invented refusal. - Include-graph-adjacent attacks on
willRenameFiles, incrates/lucisv_server/src/file_ops.rs: an include chaina.svh -> b.svhwith a third filec.sv -> a.svh(renamingb.svhnarrows toa.svhonly, correctly leavesc.svunedited since it never spellsb.svh,an_include_chain_narrows_to_the_direct_includer_of_the_moved_file), and a case-mismatched include spelling (`include "DEFS.svh"against a realdefs.svhon this case-insensitive filesystem,a_case_mismatched_include_spelling_still_narrows_in_and_rewrites) — both narrow in correctly and rewrite correctly. - Deferred-refusal reachability (rule 11b). Attempted to construct a case
where the declaring file (in another file from the buffer) has an empty
name_span, which is the one row the parity table marks "deferred" rather than "reproduced." Could not construct one through the public parsing API: the name-span contract (vlog-semantic's Handshakes, and this feature's own "every edit span originates in a parsed node") guarantees a non-empty span on every declaring node the binder records, so this refusal looks unreachable through any real workspace state today, in the same way the two "—" rows in the parity table are marked unreachable. Not fixed or asserted either way — flagging for the record rather than claiming coverage the suite does not have.
Not attempted / out of scope for this round
The end-label, hierarchical-tail, defparam, and escaped-identifier
declaration findings from the 2026-08-24 rounds above are pre-existing and
untouched by this diff — re-read, not re-attacked. The willCreateFiles/
willDeleteFiles non-goals in file-operations are unrelated to this round.
Summary
| Claim | Verdict |
|---|---|
| Gates (fmt/clippy/test/smoke) | Pass |
| Numbers (synthetic probes + real OpenTitan, this worktree's own build) | Pass, reproduced independently |
| Sufficiency argument (name-locality lemma) | Holds under every attack tried: escaped identifiers, same-spelling different symbols, mid-walk ambiguity, prepare-parity fuzz, include-chain/case-mismatch narrowing |
| The residue — macro-invocation warning loss | Reproduces exactly as measured on OpenTitan (7→0, 64→61); no edit or refusal lost, only the one warning flavour; already the lead's disclosed call |
| The residue — "one lost refusal" (dangling import of the new name) | Confirmed real, reproducible, and exactly as bounded — a genuinely weaker answer than the whole-workspace path, not just a lost warning. Needs the lead's explicit ruling before ship. |
Verdict: REWORK-gate, not ship-as-is — not because anything is broken by accident, but because the one item the brief calls "gate the subset path behind that honesty (lead decides at review)" has not yet had that decision made. Every other attack in the adversarial charter held. My recommendation, for the lead: this is very likely acceptable to ship (it is a narrowing of a refusal, not an edit — CLAUDE.md invariant 1 is about edits, and none is lost or wrong here), especially since the parallel macro-invocation-warning residue was already accepted; but "very likely acceptable" is not the same as "decided," and the brief was explicit that this exact honesty gate needs a lead ruling, not a QA one.
2026-08-29 — QA agent (re-verification of the rework: rung 6,
WorkspaceIndex::files_spelling). Focused pass, not a full re-run, on the
lead-authorized fix for the HIGH finding above: the flipped test
(a_dangling_import_of_the_new_name_is_refused_by_both_paths) and the new
a_dangling_use_of_the_old_name_needs_no_rung_of_its_own, plus "The
dangling-use case" section's argument (rung 6 is the new name's alone because
a rename only ever removes declarations of the old name). Charter: attack
rung 6's completeness, attack the old-name exemption with a shadowing/
"unmasking" hunt, verify the tests actually assert what they claim, spot-check
the rung's cost, run the gates. Worked in the same worktree.
Rung 6 completeness — three new attacks, all pass
Read WorkspaceIndex::files_spelling (crates/vlog_semantic/src/workspace.rs)
and resolve.rs's Target::{Package,Unit,UnitMember}/miss machinery to find
every way a real reference could spell the new name and end up with a
Resolution whose paths are empty (invisible to files_spelling, since
facts_from_analysis only records ExternalCandidate/InheritedCandidate
with a non-empty path list). The exhaustive case split: every miss on
Target::Package, Target::Unit, Target::UnitMember — including the head
of p::x and an extends/implements base — always pushes at least the bare
name onto its paths (named_at_file_scope's None arm, unit()'s unconditional
external.push(name.to_string()), unit_member's two unconditional
ExternalCandidate arms), so all of those are recorded regardless of whether
they resolve. The only empty-paths cases are this_member/super_member
(always paths: Vec::new()) and a plain Target::Lexical miss inside a class
with extends when no import in scope supplies anything
(miss()'s InheritedCandidate { base, paths: external } with external
empty) — and for exactly these, resolve_external can never produce an
overlay entry (follow_paths on an empty list is StillUnresolved by
construction, unconditionally, both before and after any rename, because the
paths are fixed by the file's own unedited text), so the reference's Anchor
is provably invariant and excluding the file costs nothing on either path.
Three permanent regression tests added to crates/lucisv_server/src/rename.rs
to check this empirically rather than trust the proof alone:
a_new_name_spelled_only_as_an_extends_base_is_still_caught_by_rung_6— a classextends taken_basewheretaken_baseis declared nowhere; renaming a package totaken_baseis refused by both paths, and rung 6 pulls the file in via theTarget::Unitpath (a genuinely different resolution target than the import case rung 6 was built for). Passes.an_unqualified_use_inside_an_extending_class_with_empty_paths_needs_no_rung— the one real empty-paths shape (a bare identifier inside a class that extends an existing, unrelated base, no import in scope). Confirmedfiles_spellingdoes not pull the file in, and confirmed (viasame_answer) that excluding it changes nothing — the rename still succeeds identically on both paths. Passes, both assertions.a_local_only_symbol_sharing_the_new_names_spelling_is_not_a_bogus_refusal— a wire declared and used only locally in a third file, sharing the new name's spelling.files_spellingcorrectly excludes it (it is aReferenceFact::Local, which the function's ownmatcharm returnsfalsefor), and the rename succeeds with no edit to that file. This is also directly whatfiles_spelling_finds_the_uses_no_posting_can_be_keyed_byincrates/vlog_semantic/tests/workspace.rspins at the query's own level (quiet.sv's local wire namedabsent_pkgis excluded fromnamed("absent_pkg")) — read and re-run, still passes.
Old-name exemption — shadowing/"unmasking" hunt, none found
Tried to construct exactly the counterexample the charter asked for: two
packages p_pkg and q_pkg both exporting a member spelled shared_name, a
third file importing both (p_pkg first, so "first-written import wins"
resolves shared_name to p_pkg's declaration today), then renaming away
p_pkg::shared_name — the hypothesis being that the importer's reference
would silently fall through to q_pkg's pre-existing, unrelated declaration
without the importer's file being in the fan-out.
It doesn't happen, and reading why is the actual finding: the importer's
shared_name reference currently resolves to the rename target itself, so
it is not a bystander a removal could silently redirect — it is an edit site.
Scope::collect_occurrences rewrites it to the new name along with the
declaration, so the text never says shared_name again for follow_paths to
re-resolve against q_pkg. Generalizing: any reference that could possibly
be affected by removing declarations of the old name must itself spell the
old name (the workspace tables are keyed by literal name string, so a
reference to an unrelated name cannot be touched by removing entries under a
different key), and by the Lemma such a reference either (a) resolves to the
target — edited away, not orphaned — or (b) resolves to a different
existing declaration of the same name — already in the set, because rung 1
(workspace_symbols, not units) walks every declarer of the name and rung
2 posts against each one, not only the target's — or (c) resolves to nothing
— stays resolving to nothing, since removing a candidate cannot manufacture a
new match. There is no fourth case, so there is no shadowing route the old
name needs a rung for. Verified empirically as well as by this argument:
removing_the_old_names_winning_declaration_does_not_escape_the_fan_out
(added to crates/lucisv_server/src/rename.rs) builds the exact scenario
above and confirms the fan-out includes both q.sv (rung 1, every declarer)
and user.sv (rung 2, posted against p_pkg's declaration), that the rename
succeeds, edits exactly the declaration and the importer's reference, and
never touches q_pkg's unrelated declaration. The old-name exemption
argument held under attack — no counterexample found, and the reason none
exists is now written into the test itself, not just asserted.
Tests genuinely assert what they claim — sabotage-verified
Read every test named above plus the dev's flipped/new ones
(a_dangling_import_of_the_new_name_is_refused_by_both_paths,
a_dangling_use_of_the_old_name_needs_no_rung_of_its_own) end to end, then
sabotaged rung 6 out (Workspace::rename_sources, wrapped the
want_spellers call in if false { … }) and re-ran the whole
rename::tests:: module:
- Failed, as they must:
a_dangling_import_of_the_new_name_is_refused_by_both_paths,a_dangling_use_of_the_old_name_needs_no_rung_of_its_own(the file "the fan-out lost the refusal … and edited 1 files instead" — exactly the pre-rework residue, reproduced on demand), and the newa_new_name_spelled_only_as_an_extends_base_is_still_caught_by_rung_6. - Still passed, as they must (they test cases that provably do not depend on rung 6): the empty-paths test, the local-only-symbol test, the shadowing/unmasking test, and every pre-existing fan-out test.
Reverted the sabotage (git diff crates/lucisv_server/src/state.rs after
reverting shows zero trace of it) and re-ran — all 26 tests in
rename::tests:: pass again. This is the strongest confirmation available
short of formal proof: the tests that claim to depend on rung 6 actually do,
and the tests that claim not to actually don't.
Numbers, spot-checked
Release probe (cargo test --release -p lucisv_server --bin lucisv-server perf::a_rename_before_and_after -- --ignored --nocapture --test-threads=1),
against this worktree's own freshly rebuilt binary: file-set build 137.2
µs, of which files_spelling 52.1 µs; rename fan-out 396.1 µs;
prepareRename whole-workspace 249.5 ms → buffer+index 212 ns. All
within noise of the Work log's 128.7/49.8/370/238/200 µs-and-ns figures.
Real OpenTitan checkout, over actual LSP/stdio with a client pointed at this
worktree's own rebuilt target/release/lucisv-server (not a throwaway
in-process probe): six repeated renames of aes on a cold workspace scan
(3 015.7 ms settle) averaged ~118 ms (107–134 ms), consistent with the
Work log's 105.5 ms and my own prior-round measurement of ~104 ms — the
spread is machine noise, not a regression from rung 6. Re-requested the same
aes → aes_core_renamed_qa2 rename directly (not just repeated identical
renames) and got the same 7 files, same edit counts as my prior-round
spot check, confirming rung 6 changes nothing about the real edit set.
Gates
cargo fmt --all -- --check clean. cargo clippy --all-targets clean (forced
re-check after touching every file this rework changed, zero warnings —
including in the three new tests, one unused_must_use warning caught and
fixed on the way, noted so it isn't mistaken for a dev-side issue). cargo test --workspace: 0 failures, no panics, workspace-wide (34 test binaries
including doc-tests). node editors/vscode/smoke.js target/release/lucisv-server
— OK, 10 messages.
Verdict
SHIP. The rework closes the HIGH finding exactly as claimed: rung 6 is complete under every completeness attack tried (including two shapes — the extends-base case and the empty-paths InheritedCandidate case — the dev's own writeup didn't walk through explicitly), the old-name exemption holds under a genuine shadowing/unmasking attempt (with the reason now understood and tested, not just asserted), the flipped and new tests are not vacuously passing (sabotage-confirmed), and the rung's cost is sub-millisecond on OpenTitan with no measurable end-to-end regression. No new findings. The macro-invocation warning residue is unchanged and remains the lead's already-accepted, separately-tracked call.
2026-09-23 — QA agent, M3.5 QA (implicit connections: .name / .*).
Charter: TODO-MCP §M3.5 — attack the widened rename verifier first
(CLAUDE.md invariant 4), then the rewrite, LSP parity, opentitan copies,
sizes, gates. Worked on the uncommitted master checkout; every experiment in a
scratch copy of the repo and of opentitan hw/ip/{prim,aes,entropy_src}.
Verdict: FAIL — one BLOCKING finding (verifier), one BLOCKING false refusal
Finding 1 (BLOCKING) — an insertion is checked for its text, never its place
check/implicit.rs::insertions_match holds every inserted string to the four
templates ((X), ,, .X(Y), , .X(Y), X/Y the two names) but never asks
where it was inserted; the resolution print then skips every inserted range
(inserted_after) and the binding print only reads named connection lists'
connections. So a template placed anywhere else that still parses is seen by
nothing. Driven through the crate-internal check::verify (the dev exposed no
public hook) with the honest edits of a d → din port rename plus one extra
insertion — each of these verifies Ok(()):
,into a positional list:leaf u_p (clk,, d, q)— every later port shifts by one (silent rewiring);, .din(d)into a parameter override#(.W(8), .din(d));(d)after a net in an expressionf(d, d(d));(d)after a task callinitial t(d);,/, .din(d)into call arguments;,into a concatenation{d,, d}(the tolerant parser reports no diagnostic for the empty element, so the "no new parse error" guard is silent too);- inside a named list, inside an explicit connection's expression:
.clk(clk(d)),.q({q(d), q}),.q({q,, q})(net_halfprints nothing for a non-name expression of a port spelling neither name).
The engine never writes these today, which is why nothing corrupted in the
engine-level tests — but the verifier is the safety net that is supposed to
refuse exactly this, and the history note in invariant 4 is this shape.
Tests: crates/vlog_refactor/src/check/qa_implicit.rs —
qa_a_comma_inserted_into_a_positional_list_is_refused,
qa_connection_text_outside_a_connection_list_is_refused,
qa_connection_text_inside_an_explicit_connection_is_refused, all
#[ignore = "QA finding 1"] (registered with one #[cfg(test)] mod qa_implicit; line in check/mod.rs, outside my file list — needed because
verify is crate-internal; the lead may move it into implicit.rs's tests).
Fix: tie each insertion to the place layout.rs writes it, read off the
before tree's sites: (X) only at c.name_span.end of a shorthand
connection (c.expr.is_none()); ,, .X(Y) and , .X(Y) only at/after the
last element's end of a named list holding .*, before its ) (with the
,-before-// pair as the one two-piece shape). Anything else refused.
Finding 2 (BLOCKING — false refusal on a common opentitan shape)
connections.rs::binds_into treats a bind target that is a lone name no
indexed module answers to as "possibly an instance of the renamed module" and
refuses whenever its list writes .old or a .* reaching old. opentitan's
hw/ip/prim/fpv/tb/prim_fifo_sync_bind_fpv.sv has ten bind i_nopass1 prim_fifo_sync_assert_fpv … (.clk_i, .rst_ni, .clr_i, .wvalid_i, .wready_o, … .err_o) — so on the scratch copy (449 files) renaming prim_count's
err_o or clr_i, aes_core's clk_i, entropy_src's clk_i or
prim_packer_fifo's wready_o is refused, over a bind into a
prim_fifo_sync instance none of them touches (whole-set engine and LSP
alike). The refusal is new in M3.5. Any module-level
declaration named clk_i/rst_ni/err_o/… in any module is affected while
that file is in the workspace; hw/ip/sram_ctrl/dv/tb.sv's bind dut … (.*)
is the same shape. Test: tests/qa_rename_implicit.rs:: qa_a_bind_into_an_instance_of_another_module_does_not_refuse
(#[ignore = "QA finding 2"]). Fix: resolve the lone name as an instance
name through WorkspaceIndex::instantiations() (edges carry their instance
names): if every instance so named instantiates a module other than the
renamed declaration's, skip the site; refuse only when one is the renamed
module's or none is found.
Attacks that held
Verifier (check/qa_implicit.rs::qa_insertions_the_verifier_already_refuses,
plus scratch experiments): an insertion inside a string, a comment, an
attribute; an empty named element (.a(b),, …); (d) after .* or after an
explicit connection; .din(d) before the first element with no comma; a
second , .din(d) beside the honest one (two separate insertions); a
case-only different net (D) (refused by the template: D is neither name);
.d(x) added to an instance in a generate block whose own d shadows the
renamed one (binding print); (d) written after another module's .d
shorthand (harmless, .d(d), accepted — same binding); (din) there (refused).
Rewrite (tests/qa_rename_implicit.rs, 20 passing, public rename only):
port rename over .p / .* / explicit / .clk, .* / .d, .* in one file;
two instances in one instantiation; an instance array leaf u[3:0] (.*); a
non-ANSI port; one-per-line list with a // comment on the last element
(comma before the comment, element on its own line at the element's
indent); an inline list with a trailing // (element lands at column 0 — no
indent to copy; legal, cosmetic); an attribute on a connection and a block
comment after .*; an escaped net \d$x renamed to a plain name (the
terminating blank stays where it was, .\d$x (dd) )); a leaf port under
nested .* (only the direct parent changes); a net rename reaching a bind
in a file spelling neither name (the whole-set caller); a hierarchical-bind
net rename refused; bind top : u_t … (instance-list form) rewritten; an
interface port bound to an interface instance by .*; a generate-scoped
shadow (module-level rename touches only the outer instance, the block's net
only the inner two); module declared twice, ifdef-split list, parent .*
capturing the new name — all refused with the instance named; a parameter
named like the port is no binding; a shorthand into an unreadable module is
still written out. Round trip: d→din→d leaves the declaring file
byte-identical; the parent differs only in the written-out connections —
(.*) becomes (.*, .d(d)) and .d becomes .d(d); no warnings on the way
back.
LSP parity (server/tests/qa_rename_implicit.rs, 3 passing)
Port rename with the users on disk only — the same edits as the engine; an
unsaved open buffer using .* over an on-disk file connecting explicitly —
the buffer's text is the one rewritten; a net rename reaching a bind file that
spells neither name — handed over by leaf's instantiation sites (the bound
module declares the port, so it is a container of the name). instantiated_by
reads only self.index, and current_text drops anything not held, so it
cannot hand over a file outside the workspace. One-hop cost on opentitan
(scratch copy, release, QA_NO_HOP toggle in a scratch build): key_len_q in
aes_core.sv selected 4 → 23 files, select 0.6 → 1.2 ms, request 4 → 22 ms —
and without the hop that rename is refused (u_fi_ctrl_fsm … connects with .* to fi_control_fsm_wrapper, which lucisv cannot read), as are the three aes
fault-injection renames below; prim_count.err_o 121 → 181 files, 46 → 59 ms.
No explosion.
Opentitan dry runs (scratch copy, whole-set engine and LSP agree)
fi_control_fsm_wrapper's portaes_ctrl_cs→aes_ctrl_state:bind aes_control_fsm … u_fi_ctrl_fsm (.*)gains.aes_ctrl_state(aes_ctrl_cs)(bindsaes_control_fsm's own state variable — what.*bound) and the wrapper'sfi_if (.*)gains.aes_ctrl_cs(aes_ctrl_state). Correct by hand.aes_control_fsm's variableaes_ctrl_cs→aes_ctrl_cs_q: the bind gains.aes_ctrl_cs(aes_ctrl_cs_q). Correct; thePRIM_FLOP_SPARSE_FSM/ASSERTinvocations still spelling the old name are warned (existing macro policy).fi_control_if's portaes_ctrl_cs→ctrl_state: the wrapper's.*gains.ctrl_state(aes_ctrl_cs). Correct.entropy_src_fsm_cov_if'sstate_i→st_i: tb.sv'sbind prim_sparse_fsm_flop : dut.… (.clk_i, .state_i, .state_o)becomes.st_i(state_i). Correct.prim_fifo_sync'sclr_i: refused overprim_fifo_sync_bind_fpv.sv's.clr_i— a correct refusal (those binds targetprim_fifo_syncinstances).prim_count/aes_core/entropy_src/prim_packer_fifo: the false refusals of finding 2.- Every rewrite was listed in
warnings, one sentence each.
Sizes / style
Production lines (non-blank, non-// lines before #[cfg(test)] mod tests {):
rename/connections.rs 434, rename/sites.rs 168, rename/layout.rs 82,
rename/mod.rs 433 (HEAD 423), check/implicit.rs 318, check/mod.rs 420
(HEAD 405), module_select.rs 36, state/mod.rs 985 (HEAD 981 — already over,
§55). Functions over 50 lines: check::verify 94 (HEAD 75 — now past the
"investigate at 80" mark), check::implicit::bindings_match 60,
rename::renaming 56 (HEAD 50); verify_move 101 is pre-existing. No
unwrap/expect/panic!/#[allow] in the new production code.
Gates (all through tools/guard.sh, one at a time)
cargo fmt -p vlog_refactor -p lucisv_server -p lucisv_mcp -- --check— clean (after formatting my three files).cargo clippy -p vlog_refactor -p lucisv_server -p lucisv_mcp --all-targets—Finished, no warnings.cargo test -p vlog_refactor— 587 passed, 0 failed, 6 ignored.cargo test -p lucisv_server— 1713 + 99 + 3 passed, 0 failed.cargo test -p lucisv_mcp— 0 failed;qa_rename_never_breaks_an_implicit_port_connection(M3 finding 1, un-ignored) passes.cargo test --workspace— 4 732 passed, 0 failed, 52 ignored (4 707 + 25 QA tests; 4 new ignored findings tests).
2026-09-23 — QA agent, M3.5 re-check (after the dev's rework). Charter:
re-derive both blocking findings against the fix (Slots in
check/implicit.rs; bind_reaches/instance_owners in
rename/connections.rs), confirm the three moves out of verify are pure,
re-run the opentitan copy, gates.
Verdict: FAIL — findings 1 and 2 closed; one new BLOCKING finding (3); one non-blocking note
Finding 3 (BLOCKING, new) — a lone , at the end of any .* list verifies
Slots::takes admits Template::Comma at the end of every .* list, alone.
The engine only ever writes it as the first half of the comma-before-//
pair, whose second half (.X(Y), Template::Connection) is already required
to have the comma (comma_at) — but not the other way round. Where the list
binds one of the two names the binding print refuses the cut; where it binds
neither (a .* into a module declaring neither name, in a file the rename
edits for another reason) nothing refuses: the tolerant parser reports no
diagnostic for (.*,) (the same leniency as {d,, d} in round one), the
pieces match, and the binding print has nothing to compare. Reproduction:
check/qa_implicit.rs::qa_r_a_lone_trailing_comma_on_a_wildcard_binding_neither_name
(#[ignore = "QA finding 3"]) — other u_o (.*) becomes other u_o (.*,)
beside an honest .d → .din(d) rewrite in the same file, and verify
returns Ok(()). Not a shape the engine writes today; a masked corruption the
safety net accepts, the class invariant 4 is about. Fix (a few lines in
Slots::takes): admit Comma at a list's end only when the same edit list
also inserts a Connection into that list (after trivia, before its )) —
the mirror of comma_at. Worth also filing against the tolerant parser: a
trailing , in a named connection list and an empty concatenation element
parse without a diagnostic.
Finding 1 re-derived — the position rule (9 new tests + finding 3, check/qa_implicit.rs::qa_r_*)
All verifier-direct (check::verify, crate-internal), each a corrupt edit set
beside a control that verifies Ok:
, .din(d)appended to a named list without.*— refused "outside a connection list";(d)after an explicit connection's name (.clk(d)(clk),.din(d)(d)) — outside;, .din(d)between.*and a later.clk(clk)— outside (the same text after the last element verifies);, .din(d),(d),,after the)— outside;- a
.*list inside a generate-for: the honest append verifies, a bare.din(d)without its comma is outside, nothing added is a cut; - a lone trailing
,at a.*list's end ((.*,), a legal slot for the comma-before-//shape) where the list bindsd— refused, but by the binding print (dinloses its binding), not by the position rule; where the list binds neither name it verifies — finding 3; - shift accounting:
d→dnewin(.clk,.d,.q)grows the line by exactly the distance from.d's end to.q's end, so a tail computed in after-coordinates lands on.q's shorthand slot in before-coordinates. The before-coordinate tail verifies; the shifted one (.dnew,.q(d)) is refused by the binding print. Slots and edits are both in before-coordinates (Slots::of(before),edit.range.start), so there is no mixed accounting; - an append inside the trailing
//comment (mid-comment and at its end):Slots::takesadmits it (the gap is trivia), the piece ledger refuses it; the honest,+\n .din(d)pair verifies; the bare connection without the comma is outside; the pair with the connection written mid-comment is refused; - a shorthand in a
bind(net rename):(x)after.dverifies, nothing is a cut,(x)after.clk(a legal slot) is refused by the binding print,(d)after.dis refused.
My three round-one tests and the dev's two same-offset tests pass un-ignored.
Finding 2 re-derived — the enclosing-module rule (5 new tests + 1 note, tests/qa_rename_implicit.rs::qa_b_*)
Renaming cnt's err_o, with chk bound by .clk_i, .err_o shorthands:
- a bind in module
aontou, wherea's ownuis afifoandb'suis acnt— skipped,a.svuntouched,b's own.err_owritten out; - swapped (
a'suis thecnt) — refused, namingc_uat a.sv:4; - a bind at file scope onto
uwhere onlytb'suexists, afifo— skipped, no warning; the same wheretb'suis acnt— refused; - a bind onto a name no indexed instance has — refused.
Note 1 (non-blocking, lead-accepted) — the generate-block gap, reproduced
module a with fifo u only inside if (1) begin : g, bind u chk c_u (.clk_i, .err_o) in a, and a parent p holding a u_a () and cnt u.
Upward resolution from a does not see a.g.u, so the bind reaches p.u, a
cnt. The engine counts a.g.u as a's own, returns Elsewhere, and the
rename succeeds with a.sv untouched — the bind's .err_o is cut. Note the
direction: this is a silent skip, not a refusal, and the verifier cannot catch
it (a bind onto an instance prints Opaque on both sides). Exotic shape (a
same-named instance in a generate block of the binding module and in its
parent). Pinned as qa_b_a_generate_scoped_instance_is_not_the_enclosing_modules_own
#[ignore = "QA note 1: accepted generate-block gap"], asserting the refusal.
Cheapest fix if the lead wants it: count an edge as local only when its
instance is declared in the module's own scope, or refuse whenever a local
same-named instance sits inside a generate block.
verify's three moves — pure
Compared the round-one body with the current one line by line: step 1's loop
moved verbatim into tokens_verified (same measure stage — trace.tokens —
per file, names[1] is new_name); the inserted lookup became
implicit::inserted_in(edits, i), the same find + inserted_after +
unwrap_or_default; step 3 binds names to a local before the same call. No
behaviour change. verify is 79 lines.
Opentitan copy, re-run (engine whole-set and LSP fan-out agree on every edit count)
| rename | result |
|---|---|
fi_control_fsm_wrapper.aes_ctrl_cs → aes_ctrl_state |
2 files, 3 edits (bind .* + wrapper .*), as round one |
aes_control_fsm.aes_ctrl_cs → aes_ctrl_cs_q |
2 files, 4 edits, as round one |
fi_control_if.aes_ctrl_cs → ctrl_state |
2 files, 3 edits, as round one |
entropy_src_fsm_cov_if.state_i → st_i |
2 files, 3 edits, as round one |
prim_fifo_sync.clr_i → clear_i |
refused over prim_fifo_sync_bind_fpv.sv's .clr_i — correct, those binds target fifo instances |
prim_count.err_o → error_o |
now succeeds: 13 files, 16 edits; .err_o written out in prim_count_tb.sv and prim_packer.sv |
prim_count.clr_i → clear_i |
now succeeds: 13 files, 16 edits; three .clr_i shorthands written out (tb, prim_fifo_sync_cnt ×2) |
aes_core.clk_i → clock_i |
now succeeds: 3 files, 24 edits |
aes_core.key_len_q → key_len_qq |
1 file, 3 edits |
entropy_src.clk_i → clock_i |
now succeeds: 5 files, 10 edits; .clk_i(clock_i) in three internal instances and two bind entropy_src asserts, , .clk_i(clock_i) on the cov bind's .* |
prim_packer_fifo.wready_o → wready_q |
now succeeds: 5 files, 13 edits; the two bind prim_packer_fifo : dut.… lists get .wready_o(wready_q) |
Each rewrite checked by hand against what the implicit connection bound; each
is listed in warnings. LSP fan-out sizes: 14–312 files, 9–213 ms per
request (clk_i of aes_core/entropy_src are the 312-file ones).
Gates (each through tools/guard.sh, one at a time)
cargo fmt -p vlog_refactor -p lucisv_server -p lucisv_mcp -- --check— clean.cargo clippy -p vlog_refactor -p lucisv_server -p lucisv_mcp --all-targets—Finished, no warnings.cargo test -p vlog_refactor— 609 passed, 0 failed, 4 ignored.cargo test -p lucisv_server— 1713 + 99 + 3 passed, 0 failed.cargo test -p lucisv_mcp— 206 passed, 0 failed, 2 ignored.cargo test --workspace— 4 754 passed, 0 failed, 50 ignored (4 740 + 14 new QA tests; the two new ignored tests are note 1 and finding 3).
2026-09-23 — QA agent, M3.5 final re-check (finding 3 fix: the comma/connection pair).
Charter: re-derive finding 3, attack the pair rule in Slots::takes, confirm
my finding-3 test is unchanged, re-run the opentitan copy, gates.
Verdict: FAIL — finding 3 closed; one new BLOCKING finding (4), same class
Finding 3 — closed
qa_r_a_lone_trailing_comma_on_a_wildcard_binding_neither_name now passes
un-ignored. Diffed against the text I wrote (reconstructed from my own edit):
byte-identical apart from the removed #[ignore = "QA finding 3"] line.
The dev's cross-list test passes.
Pair-rule attacks (check/qa_implicit.rs::qa_p_*, 4 new passing tests)
,in one file's list and its.din(d)in another file's list, both ways — refused "outside a connection list" (each file's edits are checked alone). The honest pair in both files verifies.- two
,and one.din(d)in one list — refused (the tolerant parser does flag.*,,followed by a connection); one,and two.din(d)— refused (binding print). .din(d)before its,at the same offset (.*\n .din(d), // …) and glued (.*.din(d),) — refused (parse). In source order at the same offset (.*,\n .din(d) // the rest) it verifies: a legal list, the same bindings, the comment kept (it now ends the new line) — accepted, harmless.- a pair in a
.*list whose last element is an error element: see finding 4. Where the "error element" is not SV at all (+.din(x)) the before file already does not compile; the verifier admits the pair after it (pinned).
Finding 4 (BLOCKING by the rule; loud, not silent) — a slot at an error element's end
Slots::of registers a .* list whose last element is ListElem::Error,
with the element's end as the append point. .d(type(q)'(q)) is valid SV (a
cast through a type reference — 1800-2017 A.8.4 constant_primary ::= type_reference) that the tolerant parser reads as the error element
.d(type(q)'(q), one byte short of the connection's own ). An append there
lands inside that connection: leaf u_e (.*, .din(type(q)'(q), .din(d)));
— valid input, output that does not compile — and verify returns Ok(()):
the parse check compares diagnostic counts (one before, one after), and the
binding print cannot see into an error element. The engine never writes it
(unreadable_elements refuses a list whose error element spells either
name), so nothing ships broken today; it is the verifier accepting what it
exists to refuse, the class of findings 1 and 3. Reproduction:
check/qa_implicit.rs::qa_p_an_append_at_an_error_elements_end_is_refused
(#[ignore = "QA finding 4"]); the same append after the connection's ) is
refused (qa_p_a_pair_after_an_error_element). Fix (a few lines in
Slots::of): register no list slot — and no tail — for a site whose conns
hold an error element (or, mirroring the engine exactly, one whose error text
spells either name or *). Worth adding to the vlog_parser handshake: type(x)'(y)
in a port connection parses as an error element.
Opentitan copy, re-run — identical
All 11 renames of the previous table, whole-set engine and LSP fan-out: the per-edit and per-warning output is identical to the previous run (diffed with timings stripped).
Gates (each through tools/guard.sh, one at a time; no guard kill)
cargo fmt -p vlog_refactor -p lucisv_server -p lucisv_mcp -- --check— clean.cargo clippy -p vlog_refactor -p lucisv_server -p lucisv_mcp --all-targets—Finished, no warnings.cargo test -p vlog_refactor— 615 passed, 0 failed, 4 ignored.cargo test --workspace— 4 760 passed, 0 failed, 50 ignored, 135 s (4 756 + 4 new QA tests; the new ignored test is finding 4).
2026-09-23 — QA agent, M3.5 final confirmation (finding 4 fix, lead-applied).
Read the change: Slots::of skips every site with site.unreadable() — no
shorthand tail, no append point — with the finding cited; the only change to
my file is the junk-list pin in qa_p_a_pair_after_an_error_element flipped to
outside (correct: that list has no slot now). Re-derived against the built
verifier: the cast-list append inside the connection (.din(type(q)'(q), .din(d)))) is refused; the same append after the connection's ) is
refused; new qa_p_a_clean_list_beside_an_error_element_list_still_verifies
— an honest .* append and .d → .din(d) in clean lists verify beside an
untouched other u_x (.*, .clk(type(clk)'(clk))) in the same file, and an
append into that list is refused "outside a connection list". Consequence
noted, non-blocking: a .* list holding an error element that genuinely needs
a rewrite is now refused by the verifier even where the engine would append
(error text spelling neither name) — a refusal, never a corruption, and only
for lists lucisv cannot parse. tools/guard.sh -- cargo test -p vlog_refactor:
617 passed, 0 failed, 3 ignored. Verdict: PASS — findings 1–4 closed; QA
note 1 (generate-block gap) stands as the lead's accepted known gap.
Review
2026-08-29 — lead, performance-wave Lane A. Reviewed after QA's
initial REWORK-gate, the fix round, and QA's SHIP on re-verification;
gates re-run on the worktree (fmt clean, clippy silent, 2518 workspace
tests green). The round's spine is the name-locality lemma, and the
rework is what made it whole: rungs 1–5 are all keyed by declarations,
so the dangling-use capture case — a refusal, not a warning — needed
rung 6 (files_spelling, over the reference facts the index already
keeps, FACTS_FORMAT untouched), and the lead ruled the residue
unshippable rather than documentable. QA then enumerated resolve.rs's
full miss taxonomy to prove the rung's two blind spots workspace-
invariant, hunted a shadowing counterexample to the old-name exemption
and found the lemma held, and sabotage-verified the parity tests bite.
That is the loop working as designed. prepareRename 1.66 s → 139 ns,
rename 3.47 s → 105 ms with the rung costing 852 µs worst-case,
willRename 249 ms → 14 ms; byte-parity swept at four real cursors and
564 offsets. The accepted macro-invocation warning residue and the
FileFacts macro census stay filed; the includes.rs accessor deviation
was the correct refusal to copy a scan. Accepted; merged by the lead.
2026-08-24 — lead. Reviewed the full diff after QA round 2's ship
verdict; ran the three gates independently (1085 tests, 0 failures, clippy
silent). The two-layer verification in check.rs is the right safety story
and the watched-files superset argument is sound as written. The authorized
vlog_semantic end-label handshake came out smaller and better than
expected — Target::Declaration is binding-not-lookup, so a label can never
attach to the wrong construct, and the parser needed nothing. QA's round-1
HIGHs (third-file collision, macro-argument silence) are closed at the
mechanism level with regression tests from QA's own reproductions. Honest
limitations (hierarchical tails, defparam paths, mismatched end labels,
escaped-identifier equivalence) are documented, warned, and consistent with
the no-preprocessing boundary. Accepted; M2 checked off in the umbrella plan
and TODO.md §8. QA's escaped-identifier note (\a vs a, IEEE 1800
§5.6.2) is recorded as a pre-existing vlog_semantic simplification, not an
M2 defect.
2026-09-02 — amendment (docs/features/sva-bodies/README.md)
A fourth warning family: an assertion the SVA grammar could not structure.
Round §27 gave property/sequence bodies and concurrent-assertion
expressions a real AST, so the ordinary path now edits a signal named inside
one. What it cannot edit is a spec that did not fit the grammar and rewound to
the byte-exact verbatim capture — and silence about that is the same kind of
wrong as silence about a macro argument was, for the same reason: the region
still spells the old name.
Scope::sva_fallback_warnings runs over every in-scope file that spells
the name, not only the edited ones — macro_use_warnings' rule, for
macro_use_warnings' reason. Which byte ranges are assertions is a token scan
(sva_regions, assertion_paren, closing_paren), deliberately generous:
expect(word1[7:0]);, an ordinary task call, is claimed as a region. Which of
them actually fell back is not the scan's answer but the analysis's — a spec
the parser structured records a reference for every name in it, so a name
inside such a region is already covered and already edited, and a generous scan
therefore costs nothing. Both halves are pinned:
a_name_inside_an_assertion_the_grammar_could_not_structure_is_warned_about
and an_assertion_the_grammar_did_structure_is_not_warned_about.
docs/topo.md §2.9-18, restated after being half-closed. The engine has
always handled a file whose only relationship to the name is a macro
argument — a_file_whose_only_relationship_to_the_name_is_a_macro_argument_is_warned_about
pins it — provided that file reaches the engine. It is
Workspace::rename_sources that decides which files do, and fan_out_of
bounds the read set with the index's declaration, site and `define
tables; a macro argument is in none of the three. FileFacts::words /
WorkspaceIndex::files_mentioning does see it. The wiring is one rung and is
written out in the sva-bodies README's Handshakes, not applied: that rung
is unbounded in a way the other five are not — renaming a module's clk port
would pull in every file that writes the word clk, and rename_sources
reads every wanted path, which is the 2.5–3.0 s regression
prepare_rename_here exists to avoid. Accepting the cost, capping the extra
set, or answering it in the server from the index without reading anything are
three real options; the round has no evidence for choosing and does not.
§2.9-18 closed, 2026-09-02 (macro-word-census, TODO §29.2): the third
option. The lead ruled against the rung, for the reason above, and for a
second census instead — one the server can warn from without reading a byte.
vlog_semantic::words::harvest_raw harvests the words a file writes only
inside a macro invocation, a directive line or an attribute; they are stored
per file as FileFacts::macro_words (FACTS_FORMAT 16 → 17) and asked of
WorkspaceIndex::files_naming_in_macros, the twin of files_mentioning over
the shorter list. lucisv_server::rename::rename appends one sentence per file
that census names and rename_sources did not hand the engine:
`sig`also appears inside a macro invocation infar.svh, which this rename did not read; check it by hand — a macro argument cannot be edited.
No rung was added and Workspace gained no method: rename_sources already
returns the path set it built, so the server subtracts it directly — which also
excludes every open buffer, because that set contains them. The engine's own
macro_use_warnings is unchanged and still speaks for every file the engine
read, so a file that is a source is warned about exactly once, in the
engine's more precise words (pinned by the control test
a_macro_file_the_rename_does_read_is_warned_about_exactly_once). The pass
costs under 0.2 ms over all 3 979 OpenTitan files and reads nothing, so the
prepare_rename_here cost stays gone. Details and measurements:
docs/features/macro-word-census/README.md.
Lead, 2026-09-23 (M3.5). The defect was a CLAUDE.md invariant-1
corruption in a shipped engine — a rename cut .name/.* bindings and
verified clean because nothing records what an implicit connection binds —
found only when the MCP block put rename in front of an adversarial QA.
The fix is the right shape: insertion-only rewrites through four spelled
templates, every rewrite in the warnings, every unreadable case refused by
name, and a verifier that prints every implicit binding before and after
(check/implicit.rs). That verifier is a widening of the rename's safety
contract, so invariant 4's discipline applied: three QA rounds attacked it
and found, in order, that it checked what an insertion spells but not where
it lands (fixed: slots keyed on the before-tree's sites), that a lone ,
at the end of a .* list passed (fixed: the comma and its .X(Y) are
accepted only as a pair in one list), and that a list holding an error
element registered a slot at the element's end (fixed by the lead: such a
list has no slot; QA's pin flipped to the stricter rule). Rulings: the
enclosing module's own instances win a bare-name bind (§23.11); the
generate-scoped instance is an accepted, documented gap; the LSP hands the
engine one more hop of instantiated modules so a .* into a module
declaring neither name is read, not refused. Filed for the owner: the
tolerant parser's leniency on a trailing , and {d,, d}, and
type(x)'(y) in a connection parsing as an error element (vlog_parser).
Committed as M3.5; ships in 0.56.0.