The owner's slow-F12 root cause: textDocument/codeAction on a module instantiation read every in-scope file through ws.sources() and ran the port-refactor engine over them, per cursor move — 3.1-4.6 s on opentitan's 3 976 files, blocking the single-threaded loop so every queued definition/hover paid the bill. Workspace::module_sources now hands the engine the cursor modules' fan-out: declarers (units), instantiation-edge files, references_to postings (the fourth rung — edges_of drops owner-less file-scope instantiations, so edges alone are not a superset), and every open buffer. 4.56 s -> 7.1 ms typical, 83 ms at a 36-file fan-out; equality with the whole-workspace computation pinned by four dev + six QA equivalence/attack tests. Disclosed behavior change: the answer now sees the workspace as the index describes it, like every other index-backed answer. Also: performance.md (full opentitan benchmark of every LSP action) committed at the root, and TODO.md gains section 10 tracking the performance wave the benchmark spawned (rename family, completion, documentHighlight, scope default) with per-lane file ownership. Co-Authored-By: Claude Fable 5 <[email protected]>
1444 lines
96 KiB
Markdown
1444 lines
96 KiB
Markdown
# refactor-ports
|
||
|
||
Milestone **M3** of `docs/features/refactor/README.md`.
|
||
|
||
## Goal
|
||
|
||
Change a module's port signature the way an RTL engineer wishes an editor
|
||
would: add a port and every instantiation in the project gains a connection for
|
||
it; remove a port and every instantiation loses it; ask one instantiation to
|
||
catch up with the module it instantiates and the missing connections appear.
|
||
The engine lives in `crates/vlog_refactor` beside M2's rename, so Vim, VS Code
|
||
and any future CLI get identical behavior; `lucisv_server` maps the protocol —
|
||
two code actions and three `workspace/executeCommand` commands — and decides
|
||
nothing. Every edit comes from a node `vlog_parser` parsed or a name
|
||
`vlog_semantic` resolved, and the whole edit is verified in memory before it is
|
||
returned. Whole-edit-or-nothing: an `Ok` is safe to apply, an `Err` is a
|
||
sentence for the user and no edits at all.
|
||
|
||
## API as built
|
||
|
||
```rust
|
||
// crates/vlog_refactor/src/lib.rs
|
||
pub enum ModuleRef<'a> { Name(&'a str), At { file: &'a Path, offset: u32 } }
|
||
pub struct PortAction { pub title: String, pub edit: RefactorEdit }
|
||
|
||
pub fn add_port(files: &[(PathBuf, String)], module: ModuleRef<'_>, decl: &str)
|
||
-> Result<RefactorEdit, String>;
|
||
pub fn remove_port(files: &[(PathBuf, String)], file: &Path, offset: u32)
|
||
-> Result<RefactorEdit, String>;
|
||
pub fn propagate_ports(files: &[(PathBuf, String)], file: &Path, offset: u32)
|
||
-> Result<RefactorEdit, String>;
|
||
pub fn port_actions(files: &[(PathBuf, String)], file: &Path, offset: u32)
|
||
-> Vec<PortAction>;
|
||
pub fn may_have_port_action(text: &str, offset: u32) -> bool;
|
||
// added 2026-08-28, for the server's file-set question:
|
||
pub fn port_action_modules(text: &str, offset: u32) -> Vec<String>;
|
||
pub fn enclosing_module(text: &str, offset: u32) -> Option<String>;
|
||
```
|
||
|
||
`files`, `RefactorEdit`, `TextEdit` and the `Err(String)`-is-a-sentence
|
||
convention are M2's, unchanged — there is no second edit model.
|
||
|
||
`port_actions` is the code-action entry point: it returns only refactorings
|
||
that **succeeded**, each with its edit already computed and verified, and each
|
||
with the title the user will read. The title is written in the engine so every
|
||
editor says the same thing. A lightbulb that only ever explains why it cannot
|
||
help is worse than no lightbulb, so a refusal produces no action at all.
|
||
|
||
`ModuleRef::At` exists because a code action or a keybinding knows a cursor,
|
||
not a name; `ModuleRef::Name` because `lucisv.addPort` is also the API a UI calls
|
||
after asking the user which module (M4's instantiate work will want it too).
|
||
|
||
## What each refactoring does — exactly
|
||
|
||
### `add_port(files, module, decl)`
|
||
|
||
1. **`decl` is parsed as one ANSI port declaration** before anything else
|
||
happens. It is the only free-form input any of these refactorings takes, so
|
||
it gets formatter-grade suspicion: it must lex, carry **no comment**, **no
|
||
compiler directive and no macro call**, and — planted in a throwaway module
|
||
header — parse with zero diagnostics into *exactly one* ANSI port, with an
|
||
explicit direction, no trailing comma, and no module item that a stray `)`
|
||
could have opened. `input a); wire evil; //` fails on the comment rule and
|
||
would fail on the item rule without it.
|
||
An explicit `input`/`output`/`inout` is **required**: an ANSI port without
|
||
one inherits the previous port's direction, and a refactoring that silently
|
||
makes a new port an input because the port above it was one is a trap. The
|
||
non-ANSI body declaration needs the direction anyway.
|
||
2. **The declaration**: the port is appended to the module's port list.
|
||
- **ANSI header** — the declaration text is appended to the header list.
|
||
- **Non-ANSI header** (`module m (a, b);`) — the *name* is appended to the
|
||
header list and the full declaration is written into the body, after the
|
||
last `input`/`output`/`inout` declaration; failing that before the first
|
||
item (its leading comments included, so they stay with their item); failing
|
||
that after the header's `;`.
|
||
- **An empty (`()`) or absent (`module m;`) port list** has no style to
|
||
follow, so the port is written the modern way: ANSI, in the header, and a
|
||
header with no list at all gains one.
|
||
3. **Every instantiation** of that module in the in-scope files, wherever it is
|
||
written — module body, `generate` region, `if`/`for`/`case` generate block,
|
||
or a `bind` directive:
|
||
- **Named connections** gain `.p(p)` when a signal called `p` is visible in
|
||
the scope the instantiation sits in (a net, variable, port, parameter,
|
||
genvar or task/function argument — not an instance or a type), and
|
||
`.p(/* TODO: connect */)` otherwise, with a warning naming every site left
|
||
that way.
|
||
- **`.*`** is never rewritten. When a same-named signal *is* in scope the
|
||
wildcard binds the new port by itself and nothing is said; when it is not,
|
||
a warning says the new port will not bind there and must be connected by
|
||
hand.
|
||
- **Ordered (positional) connections** gain a position at the end — see the
|
||
policy below.
|
||
- **An empty connection list** (`u1 ()`) is left exactly as it is: it
|
||
connects nothing before the change and nothing after it. A warning says so.
|
||
4. The whole thing is **verified** (below) and then confirmed against the shape
|
||
the plan promised.
|
||
|
||
### `remove_port(files, file, offset)`
|
||
|
||
The cursor may sit on the port in the header **or**, for a non-ANSI module, on
|
||
its body declaration; both are the same removal.
|
||
|
||
- The port element leaves the header, taking exactly one comma with it: the one
|
||
after it, or — for the last element — the one before it. A deletion that ends
|
||
up alone on its line takes the line, so no blank line is left behind.
|
||
Removing the **last** element is two deletions rather than one range, because
|
||
the source may have written a comment between the comma and the element
|
||
(`.a(x), // about a` ⏎ `.b(y)`); one range would swallow it, and a comment is
|
||
never dropped. The comma's own blanks go with it unless a comment follows.
|
||
- A non-ANSI module also loses the body declaration: the whole item when it
|
||
declares only that port, or just that declarator when it declares several
|
||
(`input a, b;` → `input a;`).
|
||
- Every **named** connection `.p(expr)` is deleted from every instantiation in
|
||
scope. The connected expression goes with it — that is the point — but every
|
||
expression that is more than the port's own name (`.p(p)`, `.p()`, `.p`) is
|
||
listed in the warnings, because it is the user's code being deleted.
|
||
- **`.*`** sites are not edited; a warning says the signal the wildcard was
|
||
binding may now be unused.
|
||
- **An empty connection list** is not edited: there was nothing there.
|
||
- Every occurrence of the port's name in text **the preprocessor owns** — a
|
||
macro invocation's arguments (`` `BUMP(rst) ``), a `` `define`` body — is
|
||
reported, in the module's file and in every file the removal edits. lucisv does
|
||
not expand macros, so an invocation is one opaque token: nothing there can be
|
||
edited, and nothing there is visible to the body-use refusal either. Silence
|
||
would be the worst answer, because only a real preprocessor would discover
|
||
that the expansion names a port that no longer exists. This is M2's
|
||
macro-argument fix applied to the sibling feature, sharing its scan.
|
||
|
||
### `propagate_ports(files, file, offset)`
|
||
|
||
One instantiation — the one under the cursor, or the only one of the statement
|
||
the cursor's module name belongs to. Its named connections are diffed against
|
||
the instantiated module's declared ports, and the missing ones are appended in
|
||
declaration order, `.p(p)` or `.p(/* TODO: connect */)` by the same visibility
|
||
rule as `add_port`. Nothing else in the workspace is touched.
|
||
|
||
### Layout
|
||
|
||
Appended elements copy the list they join, which is the simplest rule that
|
||
stays correct: an element per line keeps an element per line at the last
|
||
element's own indentation, an inline list stays inline. Refactored output is
|
||
*edited source*, not reformatted source (umbrella Handshakes) — the user runs
|
||
the formatter afterwards if they want more.
|
||
|
||
One case gets special handling because getting it wrong is not cosmetic: when
|
||
the last element carries a `//` comment, the comma is written **before** the
|
||
comment and the new element after it, as two insertions. A comma written after
|
||
`//` is a comma inside a comment.
|
||
|
||
### Conditional compilation — where a new port may not go
|
||
|
||
lucisv does not preprocess, so an `` `ifdef`` arm is ordinary text to it. That
|
||
makes "append after the last declared port" wrong in one specific, silent way:
|
||
|
||
```systemverilog
|
||
module m (
|
||
input clk
|
||
`ifdef HAS_RST
|
||
, input rst
|
||
`endif
|
||
);
|
||
```
|
||
|
||
The last declared port is inside the arm, so the byte after it is inside the
|
||
arm too, and a port appended there **only exists when `HAS_RST` is defined** —
|
||
the opposite of what "add a port" means. None of the five verification checks
|
||
can see this, by design: the file parses, no name changes meaning, and the
|
||
re-parsed header really does declare the port, because lucisv reads straight
|
||
through the `` `ifdef``. It is a *planning* mistake, not a verification gap, so
|
||
it is caught in the planner:
|
||
|
||
- Before inserting, the directives written in the list — `Module.port_directives`
|
||
for the header, the `` `Directive`` items of the body for a non-ANSI
|
||
declaration — are counted from the start of the list to the insertion point:
|
||
`` `ifdef``/`` `ifndef`` open a region, `` `endif`` closes one, `` `else``
|
||
and `` `elsif`` continue the one they are in.
|
||
- **A non-zero count refuses the whole refactoring**, naming the arm and its
|
||
line, and says to place the port by hand. (The ruling asked for `> 0`; `< 0`
|
||
— more `` `endif``s than opens, a region opened outside the list — is refused
|
||
too, since lucisv equally cannot tell what it would be writing into.)
|
||
- **A zero count proceeds, with a warning** naming the directives: the port
|
||
lands outside every arm, which is correct, but the module's port set is
|
||
configuration-dependent and the user should know that lucisv only sees one
|
||
spelling of it.
|
||
|
||
A macro *item* in a body (`` `ASSERT_INIT(...) ``) is not counted: it is a
|
||
call, not a directive, and cannot open a region.
|
||
|
||
## The ordered-connection policy
|
||
|
||
Positional connections are where a port refactoring can silently change what a
|
||
circuit does, so each case is decided rather than guessed:
|
||
|
||
| Situation | What lucisv does |
|
||
|---|---|
|
||
| `add_port`, ordered list whose length **equals** the module's port count before the change | Appends a position at the end. The new port *is* the new last port, so the end is where it belongs. |
|
||
| `add_port`, ordered list of a **different** length | **Refuses the whole refactoring**, naming the instance and both counts, and says to convert it to named connections first. lucisv cannot tell which port a short list meant to connect. |
|
||
| `add_port`, **empty** list (`u1 ()`) | Left alone, with a warning. An empty list connects nothing before *and* after; appending would bind the new port to position 0. |
|
||
| `add_port`, ordered site where no same-named signal is in scope | The position is written **empty** (`u1 (a, b, )`), not `/* TODO */`: a comment between two commas *is* an empty position, so a placeholder there would be a lie. Warned. |
|
||
| `remove_port`, **any** non-empty ordered list anywhere in scope | **Refuses the whole refactoring.** Dropping one positional connection re-binds every one after it. The message says to convert to named connections first. |
|
||
| `propagate_ports` on an ordered instantiation | Refused: there is nothing named to propagate. |
|
||
|
||
The asymmetry is deliberate: appending to a full positional list is safe
|
||
because nothing before it moves; deleting from one is not.
|
||
|
||
## The refusal list — exact
|
||
|
||
`add_port` refuses when:
|
||
|
||
1. `decl` is not exactly one directed ANSI port declaration (rules above).
|
||
2. The module is not indexed, or is declared in **more than one** indexed file
|
||
— the same ambiguity rule rename has, for the same reason: every
|
||
instantiation resolves by name.
|
||
3. `ModuleRef::At` names a file outside the in-scope set, or a position that is
|
||
in no module declaration.
|
||
4. The module already has a port of that name.
|
||
5. Any ordered instantiation's connection count disagrees with the module's
|
||
port count (above).
|
||
6. The module writes an `import` in its header and has **no** port list at all:
|
||
the `;` that ends such a header cannot be told from the import's own `;`
|
||
without preprocessing, so lucisv asks for `()` to be written first. (Today's
|
||
parser rejects that header outright, so this is a guard, not a path users
|
||
reach.)
|
||
7. The insertion point falls **inside a conditional arm**, or the directives
|
||
before it do not balance (above).
|
||
8. Verification fails (below) — including the capture case: a new port that
|
||
would take over what a name already means inside the module's body.
|
||
|
||
`remove_port` refuses when:
|
||
|
||
9. The position is not a module port (nor the body declaration of one).
|
||
10. Any instantiation in scope connects the module's ports **positionally**.
|
||
11. The port is still **used inside the module's body**, with the lines listed.
|
||
(A use inside a macro invocation's arguments is invisible to this rule —
|
||
it is a warning instead; see above.)
|
||
12. A deletion range would swallow a **comment** — a connection or a port with
|
||
a comment written inside it. Comments are never dropped (invariant 3), and
|
||
lucisv will not decide where a comment should move.
|
||
13. Verification fails.
|
||
|
||
`propagate_ports` refuses when:
|
||
|
||
14. The position is not an instantiation, or names a statement with several
|
||
instances (put the cursor on one).
|
||
15. The instantiation connects positionally, or with `.*`.
|
||
16. Every declared port is already connected — there is nothing to do, and a
|
||
"did nothing" success is a worse answer than a sentence.
|
||
17. Verification fails.
|
||
|
||
All three also refuse when two computed edits would overlap, and when the
|
||
in-scope file set does not contain the file the request names.
|
||
|
||
## The verification story
|
||
|
||
M2's `check::verify` is *rename-shaped*: it demands that the token stream not
|
||
change shape at all. A port refactoring writes and deletes text, so that
|
||
contract cannot apply. Rather than weaken it — hard invariant 4's mindset — a
|
||
**second** entry point was added beside it, `check::verify_splice`, with a
|
||
contract of its own that is exactly as strict about everything the refactoring
|
||
did *not* ask for. `verify` is untouched; so is `vlog_formatter::verify`.
|
||
|
||
**1. Lexical splice.** Every touched file is broken into *pieces* — code tokens
|
||
and comments, in source order, each with its span. The edited file's pieces
|
||
must equal the original's with the pieces the edits' own text spells written in
|
||
at the edits' positions, and the pieces inside a deletion removed. Kinds and
|
||
texts are compared, spans are not: an insertion legitimately moves which token
|
||
a comment attaches to without moving the comment. This catches an edit that
|
||
landed in a string, split or merged a token, wrote a comma into a line comment,
|
||
landed at the wrong position, or wrote one token more than it promised.
|
||
|
||
**2. Comments are never dropped.** A deletion that covers a comment would
|
||
delete it from *both* sides of that comparison and pass, so it is refused
|
||
outright and separately — the one rule the piece comparison cannot see on its
|
||
own.
|
||
|
||
**3. The file still parses.** A touched file may not gain a parse diagnostic it
|
||
did not already have. (Not "has none": a tolerant parse of a file that was
|
||
already broken still reports its old diagnostics, and refusing to refactor
|
||
because something else in the file is mid-edit would be useless in an editor.)
|
||
|
||
**4. Resolution identity outside the edits.** M2's whole-file resolution print
|
||
— every declaration and every reference with a workspace-wide anchor — is built
|
||
before and after, for every **watched** file (the edited ones, plus every
|
||
in-scope file that spells the module's name as a whole word, M2's rule
|
||
unchanged). Entries whose name span **overlaps an edit** are excluded on both
|
||
sides: those are precisely what the user asked to change. Everything else must
|
||
be identical, with spans mapped through the edits. This is what refuses a port
|
||
that captures a body reference — the body's `cfg` used to be the net's, and
|
||
after the added port it would not be — and it does so without any special-case
|
||
knowledge of ports.
|
||
|
||
**5. The shape check** (`ports.rs::confirm`), which is not a generalization of
|
||
anything in M2 and is specific to this feature. Checks 1–4 prove the edit is
|
||
lexically and semantically honest; none of them proves the new text landed in
|
||
the *port list* rather than in the parameter list. So the plan states the shape
|
||
it expects — the module's declared port names, and every instance's connection
|
||
names in order — the edited text is re-parsed, and the two must match. This is
|
||
what turns "the tokens are fine" into "the refactoring did what it said".
|
||
|
||
Checks 1–5 run over the whole edit; any of them failing fails all of it.
|
||
|
||
### Why the exclusion in check 4 is honest
|
||
|
||
It looks like a hole ("names inside the edit are not checked") and it is worth
|
||
saying why it is not one. The excluded ranges are the *bytes the user asked to
|
||
change*, and nothing else: an insertion excludes only the inserted text, a
|
||
deletion only the deleted text. Every name outside them — in the same file and
|
||
in every watched file — is still pinned to the exact declaration it resolved to
|
||
before. What lives inside the edit is then pinned by check 5, which reads the
|
||
signature back out of the parsed text. The masked-corruption tests in
|
||
`check.rs` attack this pair directly: an edit spliced at the wrong position, an
|
||
edit that also rewrote an untouched token, an edit that also dropped a comment,
|
||
an edit that wrote more than it promised, and a deletion that swallows a
|
||
comment.
|
||
|
||
### One change to shared code
|
||
|
||
`Shift::map` (`lib.rs`) previously accumulated a shift for every edit with
|
||
`range.start < span.start`. That is wrong for an *insertion* — an empty range
|
||
never satisfies it, so a span beginning exactly where text was inserted would
|
||
not move. The predicate is now `range.end <= span.start`. For a rename, whose
|
||
edits all replace a whole name span, the two predicates say the same thing on
|
||
every span (the ranges are disjoint from every non-edited span), so M2's
|
||
behavior is unchanged — its 48 behavior tests and 2 corpus tests still pass
|
||
byte-for-byte.
|
||
|
||
`check::print` gained an `excluded: &[TextRange]` parameter; `verify` passes
|
||
`&[]` and is otherwise untouched.
|
||
|
||
## The LSP surface
|
||
|
||
**Code actions** (`lucisv_server/src/ports.rs`), kind
|
||
`refactor.rewrite.lucisv.ports`, advertised alongside the existing quick-fix
|
||
kinds and honoring the client's `only` filter:
|
||
|
||
- On a port declaration in a header (or its non-ANSI body declaration):
|
||
*"lucisv: remove port `p` (updates 3 instantiations)"*.
|
||
- On an instantiation missing connections: *"lucisv: connect 2 missing ports"*.
|
||
|
||
Both carry the computed `WorkspaceEdit` inline — nothing to resolve — and
|
||
neither is offered where the refactoring would be refused. They answer for the
|
||
**start** of the requested range: a code action is about where the cursor is.
|
||
|
||
A code-action request arrives on **every cursor move**, and computing an
|
||
answer used to mean reading the whole in-scope file set and building an index
|
||
— a fifth of a second on a large workspace, on a single-threaded server, and
|
||
2.9 s on OpenTitan's 3 976 files, with every queued definition and hover
|
||
waiting behind it. Two things keep that off the cursor path, and both are the
|
||
engine's own walk:
|
||
|
||
- `may_have_port_action(text, offset)` — one parse of the buffer itself, no
|
||
workspace and no I/O, answering "is this position inside a port element, a
|
||
non-ANSI port declaration, or an instantiation?". The server asks it
|
||
*before* materializing anything. It cannot hide a refactoring: all three
|
||
refactorings start by locating exactly one of those three constructs.
|
||
- `port_action_modules(text, offset)` — the same walk saying *which* module it
|
||
found, so the server can hand the engine that module's own fan-out instead
|
||
of the workspace. `may_have_port_action` is this function asked for
|
||
emptiness (one walk, two readers), which is what keeps the gate and the
|
||
fan-out from ever disagreeing about which positions carry an action.
|
||
|
||
### The file set a port action reads — why a subset is the same answer
|
||
|
||
`Workspace::module_sources(file, modules)` (`lucisv_server/src/state.rs`)
|
||
builds the file set both `ports::code_actions` and `ports::execute` hand to the
|
||
engine. It is `sources()` narrowed to four rungs:
|
||
|
||
1. **the file the request names** — the open buffer's text, as always;
|
||
2. **every file declaring one of `modules`** — `index.units(name)`;
|
||
3. **every file that instantiates one** — `index.instantiations_of(name)` —
|
||
**or otherwise refers to one** — `index.references_to(def)`;
|
||
4. **every open buffer**, whatever it contains.
|
||
|
||
The answer is *equal* to the whole-workspace answer, and the argument is one
|
||
per way a file can influence the result:
|
||
|
||
- **A file the plan can edit.** `plan_add`/`plan_remove` loop over the whole
|
||
scope, but `instantiation_edits`/`disconnection_edits` write nothing in a
|
||
file that does not textually contain the module name and parse an
|
||
instantiation of it under `collect_instantiations`. That census — module
|
||
bodies, packages, nested modules, generate regions (`if`/`for`/`case`), and
|
||
`bind` — is walk-for-walk the one `vlog_semantic::instantiations::sites`
|
||
performs to record the index's instantiation edges, so rung 3 names exactly
|
||
the files that could gain or lose a connection. `plan_propagate` edits the
|
||
cursor's file alone. **One gap**: `edges_of` drops a site with no owning
|
||
module — an instantiation written at *file scope*, illegal SystemVerilog a
|
||
tolerant parse still produces — and the engine would have edited it. Rung 3's
|
||
second half covers it: an instantiation's module name is a
|
||
`Target::Module` reference wherever it is written, so the file appears in
|
||
`references_to` even when it is nobody's edge.
|
||
- **A file that decides `locate_module`'s verdict.** Every one of them is in
|
||
rung 2, *all* of them, so a module declared twice still produces the "lucisv
|
||
will not guess which module's ports these are" refusal instead of quietly
|
||
picking the one definer that happened to be in the set. Rung 2 is the reason
|
||
the set is built from `units(name)` rather than from a single definition.
|
||
- **A file the verifier watches.** `check::watched_files` widens verification
|
||
to every file spelling the module name, edited or not, and compares each
|
||
one's declarations and resolutions before and after. For a file that is not
|
||
edited, "before" and "after" differ only if some *anchor* moved — and an
|
||
anchor is a local declaration (its own text, unchanged) or a def in the
|
||
rebuilt index (pre-shifted through the edits by `Shifts`, which is why an
|
||
insertion in the module's file does not read as a difference). An anchor
|
||
that could move is by construction a reference *into* the edited module or
|
||
its members — which is a `references_to` posting, rung 3. Every other file's
|
||
print is identical on both sides whether it is in the set or not, so
|
||
omitting it cannot turn a refusal into an offer.
|
||
- **A file the index has not seen.** An unsaved buffer's live text can add or
|
||
remove any of the above, and the edges are only as fresh as the last save —
|
||
so rung 4 takes every open buffer whole, exactly as `collect_sources` does.
|
||
|
||
Everything else about the set is `collect_sources`'s rules unchanged: each
|
||
file's text is the open buffer's when there is one and disk otherwise, a
|
||
buffer on the large-file fast path contributes nothing, and a file over
|
||
`lucisv.index.maxFileSize` is not read.
|
||
|
||
Pinned by four tests in `lucisv_server/src/ports.rs`, each asserting against
|
||
the whole-workspace computation rather than a transcription of it:
|
||
`a_code_action_answers_what_the_whole_workspace_would`,
|
||
`an_unsaved_buffer_contributes_the_instantiation_the_index_has_not_seen`,
|
||
`a_module_declared_twice_is_refused_through_the_subset_as_well`,
|
||
`a_command_computes_over_the_subset_and_answers_the_same`, plus
|
||
`the_files_a_code_action_reads_are_the_modules_own_fan_out`, which asserts the
|
||
noise files really are absent (4 files read of 44).
|
||
|
||
**Commands** (`workspace/executeCommand`, advertised in
|
||
`executeCommandProvider`):
|
||
|
||
| Command | Arguments | Why it exists |
|
||
|---|---|---|
|
||
| `lucisv.addPort` | `[uri, module-name-or-Position, "input logic [7:0] cfg"]` | A code action carries no free-form input. This is the API a UI calls once it has asked the user; the VS Code side can grow an input box over it without the engine changing. |
|
||
| `lucisv.removePort` | `[uri, Position]` | A Vim user has no lightbulb; a command works wherever a keybinding does. |
|
||
| `lucisv.propagatePorts` | `[uri, Position]` | Same. |
|
||
|
||
Each answers with the `WorkspaceEdit` for the client to apply. The server does
|
||
**not** push `workspace/applyEdit`: the client asked for the command and owns
|
||
the edit — and it keeps the server free of a request/response round trip on the
|
||
one path Vim users take.
|
||
|
||
Engine **warnings** go to the existing `report_scope` path (a
|
||
`window/logMessage` each, one `window/showMessage`), the same one filelist and
|
||
rename warnings use. **Refusals** are LSP `RequestFailed` (-32803) carrying the
|
||
engine's sentence verbatim, M2's precedent.
|
||
|
||
## Assumptions
|
||
|
||
- **The caller hands over the in-scope files**, open buffers already overlaying
|
||
disk — the same list `WorkspaceIndex::build` was given. The crate does no I/O.
|
||
(M2's assumption, unchanged.)
|
||
- **A module name is unique in scope.** Every instantiation resolves by name;
|
||
if the workspace declares the name twice, lucisv refuses rather than guessing.
|
||
- **`inst.module` is compared by name.** A scope-qualified instantiation
|
||
(`pkg::mod u1 (...)`) is stored with its `::` glued and therefore does not
|
||
match a bare module name — such an instantiation is not found and not edited.
|
||
Real RTL does not write them; if it starts to, this is where to look.
|
||
- **lucisv does not preprocess.** An instantiation hidden inside a macro body or
|
||
produced by a macro invocation is one opaque token and cannot be edited or
|
||
even seen. An instantiation inside an `` `ifdef`` arm *is* ordinary tokens and
|
||
*is* edited, in every arm — the same honesty M2 documents.
|
||
- **lucisv does not elaborate.** "Is a signal called `cfg` in scope here?" is a
|
||
lexical-scope question answered by `vlog_semantic`, not an elaboration; a
|
||
name that would come from a wildcard package import that lucisv cannot resolve
|
||
reads as "not in scope", so the connection is a TODO rather than a wrong
|
||
guess.
|
||
- **A port refactoring is a rare, user-initiated request**, so re-parsing the
|
||
in-scope files that mention the module (twice: once to plan, once to verify)
|
||
is affordable. The substring prefilter M2 introduced keeps it to a handful of
|
||
files. Measured below. **Amended 2026-08-28**: a *code action* is not rare —
|
||
it arrives on every cursor move — so the files handed to the engine are the
|
||
module's fan-out rather than the workspace (above).
|
||
- **The index is the server's authority on where a module is declared and
|
||
instantiated.** The fan-out is read from it, so a port action sees the
|
||
workspace as far as the index describes it: a file changed on disk with
|
||
nothing telling this server, or a file a startup scan has not reached yet,
|
||
is a file the action does not read. That is the same rule every other
|
||
index-backed answer already lives by — definition, hover, references, the
|
||
code lens, the call hierarchy — and the file watcher is what keeps it true.
|
||
Before 2026-08-28 a port action re-read the whole scope from disk and was
|
||
the one answer in the server that could see further than the index; it no
|
||
longer is.
|
||
- **Two spaces** are used for the one indentation lucisv has to invent (a body
|
||
declaration in a module with no items at all). Every other insertion copies an
|
||
indentation that is already in the file.
|
||
|
||
## Handshakes
|
||
|
||
**Consumed from `vlog_parser`** (no change required):
|
||
|
||
- `parse_source_tolerant` and its diagnostics list (check 3), `tokenize`,
|
||
`LineIndex`, `TextRange`.
|
||
- `ast::{Module, PortList, AnsiPort, NonAnsiPort, PortDecl, Declarator,
|
||
Instantiation, Instance, Connections, OrderedConn, Connection, BindDirective,
|
||
GenBlock, GenElse, Item, ItemKind, ListDirective, RawText}` — `ListDirective`
|
||
and `ItemKind::Directive` are what make the conditional-arm guard possible — every span these carry (`span`,
|
||
`name_span`, `Comment::span`, `Meta::leading/trailing`) is what makes the
|
||
edits exact rather than textual.
|
||
- `token::{Token, TokenKind}` — the port-list parentheses walk and the piece
|
||
comparison.
|
||
|
||
**Consumed from `vlog_semantic`** (no change required, nothing patched):
|
||
|
||
- `analyze`, `Semantics::{scopes, symbols, symbol, references_of}`,
|
||
`Scope::{span, parent, lookup_local}` — the "is a signal called `p` visible
|
||
here?" question and the "is this port still used in the body?" question.
|
||
- `SymbolKind`, `WorkspaceIndex::{units, path}` — locating the module and
|
||
refusing an ambiguous one.
|
||
- M2's `check`/`Scope` machinery inside this crate. `rename.rs`'s two
|
||
preprocessor scans were factored — `Scope::define_sites` and
|
||
`Scope::macro_argument_sites` now return *sites*, and each caller writes its
|
||
own sentence — so the port refactorings reuse the scan without inheriting
|
||
rename's wording. M2's warning text and ordering are byte-for-byte
|
||
unchanged; its 48 behavior tests pin that.
|
||
|
||
**Promised to `lucisv_server`** (and to any future CLI):
|
||
|
||
- None of the four public functions panics, and none returns a partial edit:
|
||
`Ok` means every edit in it verified *together*, `Err` means nothing at all is
|
||
to be applied.
|
||
- `RefactorEdit.edits` is sorted by path; each file's edits are sorted by start
|
||
offset and non-overlapping. **Insertions are empty ranges** — new for M3, and
|
||
the reason `Shift::map` changed — so a client applying them back-to-front
|
||
behaves correctly.
|
||
- `warnings` are informational: an `Ok` with warnings is still safe to apply.
|
||
- `PortAction.title` is user-facing text; the server does not rewrite it.
|
||
|
||
**Consumed from `vlog_semantic`, added 2026-08-28** (no change required):
|
||
`WorkspaceIndex::{instantiations_of, references_to}` — the incremental-index
|
||
edge and posting tables — are what make the file set a lookup instead of a
|
||
workspace read. The equality argument above leans on one property of theirs:
|
||
`edges_of` records the census `instantiations::sites` walks, which is the walk
|
||
`ports::collect_instantiations` performs. If either walk grows a node kind the
|
||
other does not, the fan-out stops being a superset of the editable files —
|
||
so **they must move together**.
|
||
|
||
**Requested of `lucisv_server`'s rename surface (follow-up, not this round):**
|
||
`rename` and `prepare_rename` still call `ws.sources()` and run the engine
|
||
over every in-scope file. On the synthetic 504-file workspace the port probe
|
||
uses, `prepare_rename` costs **249 ms** (of which `sources()` alone is 14.5
|
||
ms — the rest is the index build and the analyses over every file);
|
||
`textDocument/prepareRename` is sent when the user presses the rename key, not
|
||
per cursor move, so it does not block the way the code action did. The subset
|
||
for a rename is a *different* argument from this one — a rename must see every
|
||
file that could name the symbol, and the postings table
|
||
(`references_to`/`references_are_ambiguous`) is the candidate — so it is filed
|
||
here rather than guessed at now.
|
||
|
||
**Changed in `lucisv_server`** (protocol layer only): `code_action::wanted` is
|
||
now `pub` so the port actions can honor the same `only` filter the lint actions
|
||
do; `server.rs` gained the `workspace/executeCommand` arm and the port-action
|
||
call inside the existing `textDocument/codeAction` arm; `main.rs` advertises
|
||
`executeCommandProvider` and the new code-action kind.
|
||
|
||
**Requested of nobody.** No change was needed in `vlog_parser`,
|
||
`vlog_semantic`, `vlog_formatter` or `lucisv_core` for this milestone.
|
||
|
||
## Status / TODO
|
||
|
||
- [x] `ports.rs` in `vlog_refactor`: `add_port`, `remove_port`,
|
||
`propagate_ports`, `port_actions`
|
||
- [x] `decl` validated by parsing it as a port declaration, with an explicit
|
||
direction required
|
||
- [x] ANSI and non-ANSI headers, empty and absent port lists
|
||
- [x] Named, ordered, `.*` and empty connection lists, in module bodies,
|
||
generate blocks and `bind` directives
|
||
- [x] Same-named-signal lookup through `vlog_semantic` scopes; `/* TODO:
|
||
connect */` and its warning otherwise
|
||
- [x] The ordered-connection policy, both directions, with refusals
|
||
- [x] Removal refusals: positional connection, body reference, swallowed
|
||
comment
|
||
- [x] Dropped-expression warnings; `.*` warnings both ways
|
||
- [x] `check::verify_splice` — lexical splice, comment rule, parse rule,
|
||
resolution identity outside the edits — plus the shape check
|
||
- [x] Masked-corruption attacks for every new forgiveness (10 attacks and 2
|
||
positive controls in `check.rs`)
|
||
- [x] `lucisv_server`: code actions, three commands, capabilities
|
||
- [x] `may_have_port_action` — the one-file pre-check that keeps a
|
||
cursor-move-frequency code-action request off the workspace walk
|
||
- [x] The file set a port action reads is the module's fan-out through the
|
||
index, not `sources()` (2026-08-28): `port_action_modules` /
|
||
`enclosing_module` in the engine, `Workspace::module_sources` in the
|
||
server, one builder for both callers, with the equality argument above
|
||
and five equivalence tests
|
||
- [x] Conditional-compilation guard on both insertion paths: refuse inside an
|
||
arm, warn when the list carries directives at all (QA HIGH #1)
|
||
- [x] Preprocessor warnings on removal — macro-invocation arguments and
|
||
`` `define`` bodies, in the module's file and every edited file, sharing
|
||
M2's scan (QA HIGH #2)
|
||
- [x] Tests: 138 in `vlog_refactor` (36 unit — 12 of them the splice
|
||
verifier's, 10 attacks and 2 positive controls — 50 behavior in
|
||
`tests/ports.rs`, 48 rename behavior, 4 corpus), 9 in `lucisv_server`'s
|
||
`ports.rs`, 2 capability assertions, 1 e2e session covering a code
|
||
action, all three commands and two refusals
|
||
- [ ] Deferred to the umbrella backlog: reorder ports, parameter add/remove,
|
||
task/function arguments, ordered → named conversion (which would turn
|
||
three of the refusals above into an offer to convert first)
|
||
- [ ] Deferred: a VS Code input box over `lucisv.addPort` (the command is the API
|
||
until then; M4's instantiate work is the natural moment)
|
||
|
||
## Corpus acceptance
|
||
|
||
`cargo test --release -p vlog_refactor --test corpus -- --nocapture`, over the
|
||
860 `.v`/`.sv`/`.svh` files in `corpus/` (Ibex, OpenTitan, PULP common_cells,
|
||
picorv32):
|
||
|
||
```
|
||
corpus add_port over 860 files: Ok((6, 18)) in 0.39s (release; 1.9s debug)
|
||
corpus rename over 860 files: Ok((6, 18)) in 0.38s
|
||
```
|
||
|
||
Adding `input logic lucisv_probe_i` to `prim_fifo_sync` — a module OpenTitan
|
||
instantiates all over — edits **6 files in 18 places**: the declaration, and
|
||
every instantiation of it in the corpus, all of which are named-connection
|
||
sites. Every edit is asserted to be an insertion of non-empty text, and the
|
||
whole thing including index rebuild and verification takes 0.39 s.
|
||
The second test asks `port_actions` at 200 offsets spread over a real file and
|
||
requires every offered action to carry a real edit and a real title, and a panic
|
||
at none.
|
||
|
||
## Work log
|
||
|
||
**2026-08-24 — dev agent.** Built `ports.rs`, `verify_splice`, and the server
|
||
surface. The decisions worth recording:
|
||
|
||
- **A second verifier, not a widened one.** The first thing tried was to make
|
||
`check::verify` take the splice case as well. It does not fit: its whole
|
||
strength is "the token stream has the same length and the same tokens", and a
|
||
port refactoring changes both on purpose. Widening it would have meant
|
||
softening the rename's contract to accommodate a case renames never produce —
|
||
the exact shape of the mistake hard invariant 4 is written about. So
|
||
`verify_splice` sits beside it, sharing the resolution print (which *is*
|
||
reusable) and nothing else, and `verify` is byte-for-byte the function M2
|
||
shipped except for the `&[]` exclusion argument.
|
||
- **Pieces, not tokens, for the lexical check.** Comparing tokens with their
|
||
attached comments — which is what `tokens_match` does — cannot work here: an
|
||
insertion moves which token a comment attaches to without moving the comment.
|
||
Flattening to a sequence of code tokens *and* comments in source order makes
|
||
the comparison exact and makes the invariant-3 rule (no deletion covers a
|
||
comment) a separate, explicit line rather than an emergent property.
|
||
- **The shape check exists because the other checks cannot see intent.**
|
||
Nothing in a lexical or a resolution comparison says "this text is in the
|
||
*port list*". Reading the signature back out of the edited text is three
|
||
dozen lines and it is the check that would have caught the worst plausible
|
||
bug in this feature (an insertion landing in `#( ... )`). It is also what
|
||
caught the real bug found while writing it: appending
|
||
`/* TODO: connect */` to a *positional* list produces a list with zero
|
||
connections, not one, because a comment between commas is nothing at all. The
|
||
policy changed to "write the empty position, and say so".
|
||
- **The comma-before-the-line-comment split.** Appending after a `//` comment
|
||
writes the comma into the comment; appending before it moves the comment onto
|
||
the new port. Two insertions — comma before, element after — keeps the
|
||
comment with its own port and is the reason `append_to_list` returns a `Vec`.
|
||
Deletion has the mirror image of the same problem — the comma of the *last*
|
||
element may have a comment after it — so `remove_element` returns a `Vec`
|
||
too, and the verifier's comment rule is what found it: the one-range version
|
||
produced a trailing comma and was refused by the parse check.
|
||
- **Positional connections are decided per case, in the table above**, rather
|
||
than by one rule. The asymmetry (append may, delete may not) is the honest
|
||
one: appending to a full positional list moves nothing that was already
|
||
there.
|
||
- **`port_actions` computes the edits eagerly**, which the milestone asks for
|
||
(the action carries its `WorkspaceEdit` directly) and which has the pleasant
|
||
side effect that an action is only offered when the refactoring actually
|
||
works — the verification has already run by the time the lightbulb appears.
|
||
The cost is one whole refactoring attempt per code-action request, and those
|
||
arrive on every cursor move: over the 860-file corpus that is 0.39 s of
|
||
workspace read, index build and verification for a cursor sitting in an
|
||
`always` block. Hence `may_have_port_action`, the one-file pre-check the
|
||
server asks first; it is the reason the eager design is affordable at all,
|
||
and it was worth building before QA found it with a stopwatch.
|
||
- **The empty-connection-list case is a warning, not a refusal.** `u1 ()`
|
||
connects nothing before the change and nothing after it, so the edit is
|
||
correct as "no edit"; refusing the whole refactoring because one instance
|
||
writes `()` would make `add_port` unusable on real RTL.
|
||
- **The `PortList::None` + header-`import` guard** is unreachable with today's
|
||
parser (which rejects that header shape outright). It is kept because the
|
||
alternative — finding the header's `;` by scanning — would be wrong the day
|
||
the parser learns that shape, and a refusal is cheap.
|
||
|
||
Checks at the end: `cargo fmt --all -- --check` clean, `cargo clippy
|
||
--all-targets` silent (zero warnings, workspace-wide), `cargo test --workspace`
|
||
green at **1164** tests (was 1085). No `unwrap`/`expect`/`panic!` and no
|
||
`unsafe` in any library path of either crate (test modules only). One
|
||
`#![allow(clippy::mutable_key_type)]` in `lucisv_server/src/ports.rs`, with the
|
||
same reason `rename.rs` carries: `WorkspaceEdit.changes` is keyed by
|
||
`lsp_types::Uri`, whose interior mutability is its own parse cache and takes no
|
||
part in `Hash`/`Eq`.
|
||
|
||
Two things worth flagging for review:
|
||
|
||
- **`Shift::map`'s predicate changed** (`range.start < span.start` →
|
||
`range.end <= span.start`). The argument that this cannot move a rename is in
|
||
the verification story; M2's whole suite passing is the evidence, but it is a
|
||
shared-code change and deserves a second pair of eyes.
|
||
- **`add_port` on an ordered site writes an empty position** (`u1 (a, b, )`).
|
||
It is legal SystemVerilog and it is warned about, but it is the one output
|
||
here that will look like a bug to a reader who has not read the warning. The
|
||
alternative — connecting a name that is not declared — creates an implicit
|
||
net, which is worse.
|
||
|
||
**2026-08-24 (later) — dev agent, rework after QA round 1 and the lead's three
|
||
rulings.** All three closed; nothing else in the design moved.
|
||
|
||
**1. `add_port` inside an `` `ifdef `` arm — now refused (QA HIGH #1).** The
|
||
guard is exactly the ruling: count `` `ifdef``/`` `ifndef`` opens minus
|
||
`` `endif`` closes over the directives written *before the insertion point* —
|
||
`Module.port_directives` for the header path, the `` `Directive`` items of the
|
||
body for the non-ANSI declaration path — and refuse when the count is not zero,
|
||
naming the arm and its line. When directives exist but the point is balanced,
|
||
the edit proceeds with a warning naming them, because the module's port set is
|
||
configuration-dependent either way and lucisv only ever sees one spelling of it.
|
||
`` `else``/`` `elsif`` continue a region rather than opening one; a macro item
|
||
in a body is a call, not a directive, and is not counted.
|
||
|
||
The ruling said "unbalanced (> 0)"; the implementation refuses on **any**
|
||
non-zero count. A negative count means a region was opened outside the list, and
|
||
lucisv can tell just as little about what it would be writing into — refusing is
|
||
the same answer for the same reason. Flagging the widening rather than doing it
|
||
quietly.
|
||
|
||
Where the guard lives matters and is now stated in the README: this is a
|
||
*planning* rule, not a verification one. All five verification checks correctly
|
||
pass QA's reproduction — the file parses, no name changes meaning, and the
|
||
re-parsed header does declare the port, because lucisv reads through the
|
||
`` `ifdef``. Only the planner can know the insertion point was wrong.
|
||
Regression tests: QA's exact source as a crate-level refusal
|
||
(`a_port_that_would_land_inside_an_ifdef_arm_is_refused`), the balanced mirror
|
||
(`a_port_list_with_a_closed_conditional_is_edited_and_reported`), the non-ANSI
|
||
body path (`a_non_ansi_body_declaration_that_would_land_inside_an_ifdef_arm_is_refused`),
|
||
and QA's e2e shape kept: the existing port session gained a third file and a
|
||
`lucisv.addPort` that comes back `-32803` with the arm named.
|
||
|
||
**2. `remove_port` macro silence — now warned (QA HIGH #2).** M2's two scans
|
||
were factored rather than copied: `Scope::define_sites` and
|
||
`Scope::macro_argument_sites` return *sites* (macro name, line, and whether the
|
||
name is the macro's own), and each caller writes its own sentence. Rename's
|
||
warning text and the order it emits warnings in are byte-for-byte what M2
|
||
shipped — its 48 behavior tests pin that, and they pass unchanged. `remove_port`
|
||
now scans the module's file and every file it edits, and says the thing that is
|
||
actually news for a removal: the expansion will name a port the module no longer
|
||
has. A macro *named* like the port is skipped as noise; the ruling named
|
||
invocation arguments and `` `define`` bodies, and those are what is reported.
|
||
Three regression tests, including QA's exact repro and one where the macro call
|
||
lives in an *edited instantiating* file rather than the module's own.
|
||
|
||
**3. `Shift::map`'s implicit invariant is now written down.** QA's second
|
||
divergence zone (a span starting strictly inside a non-empty replacement) is
|
||
unreachable today and is not a defect, but nothing said so at the function. Its
|
||
doc comment now states the assumption — every span is either identical to one
|
||
edit's range or fully disjoint from all of them — says the number returned for a
|
||
violating span is arbitrary rather than a location, and points at
|
||
`check::print`'s `excluded` list as the way to keep it true.
|
||
|
||
Not changed, deliberately: the CRLF cosmetic QA filed as low
|
||
(insertions always write `\n`). It is a mixed-line-ending wrinkle, the
|
||
Handshakes already say refactored output is edited source rather than formatted
|
||
source, and threading a per-file line-ending choice through every insertion
|
||
helper would be more machinery than the wrinkle costs. Recorded here so the
|
||
decision is visible rather than forgotten.
|
||
|
||
Gates after the rework: `cargo fmt --all -- --check` clean, `cargo clippy
|
||
--all-targets` zero warnings workspace-wide, `cargo test --workspace` green at
|
||
**1170** tests (was 1164; +6 crate-level regressions, the e2e addition living
|
||
inside the existing session). Corpus unchanged: `add_port` over the 860 files is
|
||
still `Ok((6, 18))` in 0.36 s, so the guard false-refuses nothing in real RTL.
|
||
One clippy-driven tidy while there: the header planner's arguments are now a
|
||
`File { text, path, tokens }` struct rather than eight positional parameters.
|
||
|
||
**2026-08-28 — dev agent.** `textDocument/codeAction` no longer reads the
|
||
workspace per cursor move. The owner's instrumented session on OpenTitan
|
||
measured 3 111 ms and 3 015 ms for a code action against 0.01–0.44 ms for
|
||
every other request; VS Code sends one on nearly every cursor move and the
|
||
server is single-threaded, so a cursor resting on an instantiation — which is
|
||
exactly where F12 leaves it — held every queued definition and hover behind
|
||
it. That is the "goto definition is slow" report: the definition answered in
|
||
microseconds and stood in a three-second queue.
|
||
|
||
What changed:
|
||
|
||
- **`vlog_refactor::port_action_modules`** — `may_have_port_action`'s walk,
|
||
returning the module names it found instead of a bool, and
|
||
`may_have_port_action` is now that function asked for emptiness. One walk,
|
||
two readers, so the gate and the fan-out cannot drift; a byte-by-byte
|
||
equality test over a mixed file pins the two against each other.
|
||
**`vlog_refactor::enclosing_module`** is the same question for the command
|
||
path, where `lucisv.addPort` takes a position anywhere in a module —
|
||
`module_at` made public, which is precisely what `ModuleRef::At` resolves
|
||
with, so the server names the module the engine will name.
|
||
- **`Workspace::module_sources`** — the one file-set builder, used by
|
||
`ports::code_actions` and by all three commands through `ports::sources_at`.
|
||
Four rungs and the equality argument are written up under "The file set a
|
||
port action reads" above; the two decisions worth repeating here are that
|
||
**all** definers of the name go in (or an ambiguous module would stop
|
||
refusing) and that `references_to` goes in beside `instantiations_of` (or a
|
||
file-scope instantiation, which records no edge, would stop being edited).
|
||
- Both callers share the builder, so there is no second code path with a
|
||
second answer; `execute` computes the names per command shape rather than
|
||
materializing anything before it knows what it was asked.
|
||
|
||
Measured, release:
|
||
|
||
| | before | after |
|
||
|---|---|---|
|
||
| synthetic 504 files, cursor on a port instantiated in 3 of them | 725 ms | **0.41 ms** |
|
||
| OpenTitan (3 976 files), cursor on a port of `adc_ctrl_core`, action offered | 4.56 s | **7.1 ms** |
|
||
| OpenTitan, cursor on a `prim_fifo_sync` instantiation (36-file fan-out) | 2.93 s | **83 ms** |
|
||
|
||
The last row is the honest ceiling: `prim_fifo_sync` is instantiated all over
|
||
OpenTitan, so its fan-out is 36 real files and the engine parses them twice
|
||
(plan, then verify) — 1.3 ms of that is reading them, the rest is the engine.
|
||
A module with a normal fan-out is the middle row. The synthetic probe is
|
||
`perf::a_code_action_at_an_instantiation_before_and_after`, which prints the
|
||
before column, the after column and `sources()` alone; the OpenTitan numbers
|
||
were taken with a throwaway probe against the local checkout and deleted, since
|
||
no test may depend on it. Both OpenTitan cursors were also checked for
|
||
*equality* against the whole-workspace computation — same titles, same edited
|
||
file counts — beside the five equivalence tests in the suite.
|
||
|
||
Deliberately untouched: `rename`/`prepare_rename`'s `sources()` calls, filed as
|
||
a Handshake follow-up with its number (249 ms on the synthetic workspace).
|
||
Gates: `cargo fmt` clean, `cargo clippy --all-targets` clean, `cargo test`
|
||
green workspace-wide, `node editors/vscode/smoke.js` OK against the release
|
||
binary.
|
||
|
||
## QA log
|
||
|
||
**2026-08-24 — QA agent.**
|
||
|
||
### Gates
|
||
|
||
- `cargo fmt --all -- --check` — clean.
|
||
- `cargo clippy --all-targets` — clean, zero warnings, workspace-wide.
|
||
- `cargo test --workspace` — green, **1164** tests, 0 failures, matching the
|
||
Work log's number exactly (was 1085 before this milestone). Per-crate
|
||
breakdown confirmed against the `Running`/`test result` pairs:
|
||
`vlog_refactor` unit 36 + `corpus` 4 + `ports` 44 + `rename` 48 = 132;
|
||
`lucisv_server` unit 222 + `e2e` 13 = 235; the rest unchanged from M1/M2.
|
||
All three gates: **pass, claims confirmed.**
|
||
|
||
### Priority — `Shift::map`'s predicate change (`range.start < span.start` →
|
||
`range.end <= span.start`)
|
||
|
||
**Verdict: the claim holds. Not a defect.** Verified two ways: by
|
||
construction/proof, and empirically with 9 new unit tests added temporarily
|
||
to `lib.rs`/`check.rs`/`ports.rs` (run, all passed, then reverted — no probe
|
||
code left in the tree; see the file-list note at the end of this entry).
|
||
|
||
The two predicates disagree on a span `S` exactly when
|
||
`range.start < S.start <= range.end`... precisely, two distinct disagreement
|
||
zones:
|
||
|
||
1. **Insertion at a span's start** (`range` empty, `range.start == range.end
|
||
== S.start`): old predicate (`range.start < S.start`) is `false` (doesn't
|
||
shift); new predicate (`range.end <= S.start`) is `true` (shifts). This is
|
||
exactly the bug the README describes and the change fixes — reproduced
|
||
directly: an insertion at position 5 followed by a span `[5,8)` maps to
|
||
`(8,11)` under the new code; hand-tracing the old predicate for the same
|
||
inputs gives `(5,8)` (unshifted, silently wrong — it would land the
|
||
trailing span on top of the freshly inserted text).
|
||
2. **A span nested strictly inside a non-empty edit range**
|
||
(`range.start < S.start < range.end`) — a *second*, previously
|
||
undocumented divergence zone I found while probing, distinct from the one
|
||
the README calls out. Reproduced: edit `[0,4)→"xy"`, probe span `[2,3)`.
|
||
New predicate leaves the span unshifted at `(2,3)`; the old predicate
|
||
would have shifted it to `(0,1)`. Neither answer is meaningful (those
|
||
bytes were replaced wholesale, so there's no correct "where did they go"),
|
||
so this zone doesn't argue either predicate is more correct — it only
|
||
matters if it's ever reachable.
|
||
|
||
**Why zone 2 can't be reached in practice, for either rename or ports:**
|
||
`Shift::map` is only ever called (via `check.rs`'s `print()`/`Shifts::map`)
|
||
on a `Symbol.name_span` or `Reference.name_span`, which the crate's own
|
||
Handshakes promise are exact, literal identifier-token spans. Verilog tokens
|
||
never nest or overlap — a byte belongs to at most one token — so no such span
|
||
can ever start strictly inside a *different* edit's non-empty byte range
|
||
without being identical to it (and the identical case is handled separately,
|
||
by the `find(|(range,_)| *range == span)` length lookup, which both old and
|
||
new code share unchanged). For ports specifically there's a second,
|
||
independent belt: `print()` filters out any declaration/reference whose own
|
||
span *overlaps* an edit (`excluded`) before it ever reaches `shifts.map`, so
|
||
even a hypothetical nested span in that data is discarded first.
|
||
|
||
For **rename** specifically (the code path M2's whole suite exercises and
|
||
this change must not move): every edit range is a whole identifier-name span
|
||
being replaced 1:1, and two distinct identifier tokens can never be
|
||
byte-adjacent in valid Verilog (some non-identifier byte — an operator,
|
||
whitespace, a delimiter — always separates them), so zone 1 (insertion
|
||
boundary) never arises either, since rename produces no insertions at all
|
||
(only replacements). Combined with the corpus number being pinned at exactly
|
||
`Ok((6, 18))` before and after this milestone and all 48 rename behavior
|
||
tests passing byte-for-byte, this is strong independent (test-suite-level)
|
||
corroboration on top of the structural argument.
|
||
|
||
**One soft spot worth naming, not a finding**: the safety argument rests on
|
||
an *implicit* invariant ("every span this function is ever called with is
|
||
either identical to an edit or fully disjoint from it") that isn't asserted
|
||
or tested as its own property anywhere — it's true by construction from how
|
||
`print()`/`rename.rs` build their inputs today, but nothing would fail loudly
|
||
if a future caller violated it. Not asking for a fix; flagging so a future
|
||
change to `check.rs`'s call sites gets this section re-read.
|
||
|
||
### Splice-verifier attacks (`check::verify_splice` / `pieces_match`)
|
||
|
||
Added 5 new attacks (temporarily, to `check.rs`'s test module; run, then
|
||
reverted) beyond the dev's own 10 attacks + 2 controls, targeting angles the
|
||
task brief specifically raised:
|
||
|
||
| Attack | Result |
|
||
|---|---|
|
||
| Reorder two comments (`// A`, `// B` → `// B`, `// A`) with an edit that claims to touch neither — same multiset of comment texts, different sequence order | **Rejected.** `pieces_match` compares an ordered sequence built from source order, not a multiset, so a physical swap is caught as "piece N differs" even though the bag of texts is unchanged. |
|
||
| Move a comment's exact text inside a string literal elsewhere in the file, with an edit that claims no changes | **Rejected.** The comment disappears as a `Piece::Comment` (piece-count/positional mismatch against the re-tokenized "after"); reappearing inside a string's token text doesn't fool the piece-kind comparison. |
|
||
| A declared edit range covering only *half* the bytes of a `/* ... */` comment (partial overlap, not the whole span) | **Rejected**, via the existing "would delete a comment" rule — `overlaps()` is a share-a-byte test, so a partial overlap still counts as "deleted" and refuses outright, which is the conservative direction. |
|
||
| An edit landing in the parameter list `#( ... )` instead of the port list `( ... )` — lexically clean, no comment touched, resolution identity holds, file still parses | **`verify_splice` alone returns `Ok`** — confirmed directly by calling it on a hand-built plan. This is not a hole; it is exactly the gap the README says `ports::confirm` (the shape check) exists to close, checks 1–4 have no concept of "port list vs. parameter list". |
|
||
| The same parameter-list-injection plan, run through `ports::confirm` (the shape check) with the plan's own `expected` `Shape` (as `plan_add` would compute it) | **Rejected** — `confirm` re-parses the edited text, reads back the module's actual declared ports, sees `cfg` is not among them (it's a parameter), and refuses with "would not leave the signature lucisv intended". This proves end-to-end that a parameter-list capture is caught, and specifically that it is `confirm`, not `verify_splice`, doing the catching — matching the README's claim in "The shape check" and "One change to shared code" precisely. |
|
||
|
||
No holes found in the verifier itself. The two-layer design (checks 1–4 for
|
||
lexical/semantic honesty, check 5/`confirm` for "landed in the right list")
|
||
holds up exactly as documented when attacked at the seam between the two
|
||
layers.
|
||
|
||
### Port-semantics attacks (`add_port`/`remove_port`/`propagate_ports`, public API)
|
||
|
||
20 probes (temporarily added as `crates/vlog_refactor/tests/qa_probe.rs`, run
|
||
with `--nocapture`, then deleted) covering the refusal list and the task
|
||
brief's attack ideas:
|
||
|
||
**Passed — refused correctly:**
|
||
- Adding a port named like an existing port → `` `m` already has a port named `clk`. ``
|
||
- `"input a, input b"` (two explicit directed ports) → refused, "not a single ANSI port declaration".
|
||
- `"input x, y"` — **the direction-inheritance case the brief called out
|
||
specifically** (one `input` keyword, two comma-separated declarators, `y`
|
||
inheriting `x`'s direction). This is legal ANSI syntax and a *different*
|
||
parser path than `"input a, input b"`. Confirmed it still refuses: the
|
||
probe module ends up with **two** `AnsiPort` entries, so `parse_port_decl`'s
|
||
`let [port] = ports.as_slice()` check catches it the same way.
|
||
- Every decl-injection string tried (`"input a); wire evil; //"`, `` "input a) ; initial $fatal; module q (input b" ``,
|
||
`"input a) (input b"`, `"input a)) (( input b"`, `` "input a /* ) */ b" ``,
|
||
`` "input a `define X 1" ``) — all refused, none escaped the throwaway-header
|
||
probe. (One string I initially treated as an injection attempt,
|
||
`"input a[__lucisv_port_probe]"`, is not one on reflection — it's a legal ANSI
|
||
port named `a` with an unpacked-array dimension that happens to *mention*
|
||
the probe module's name; the probe is discarded after parsing, so there is
|
||
nothing for it to interact with. Correctly accepted; my test's original
|
||
expectation was wrong, not the code.)
|
||
- Duplicate module names in the workspace (`m` declared in two files) →
|
||
refused, "declared in more than one indexed file".
|
||
- `propagate_ports` on an instantiation of an unindexed module name →
|
||
refused, "lucisv indexes no module named `unknown_mod`".
|
||
- `.rst()` (empty named connection) is correctly treated as *already
|
||
connected* by `propagate_ports` — refused with "already connects every
|
||
port `sub` declares" rather than treating the empty parens as missing.
|
||
- `remove_port` on a port used only inside an `` `ifdef NEVER_DEFINED``
|
||
arm → **refused** ("still used inside `m` at m.sv:6"), confirming lucisv's
|
||
documented "does not preprocess" honesty extends correctly to body-use
|
||
checking: an ifdef arm is ordinary tokens regardless of whether the guard
|
||
is ever true.
|
||
- Parameterized instantiation `sub #(8) u1 (...)` — `add_port` correctly
|
||
finds the *port* list's parens, not the parameter list's, both with a
|
||
populated connection list and with an empty one (`sub #(8) u1 ();`, which
|
||
correctly warns "writes an empty connection list" rather than silently
|
||
binding position 0).
|
||
- Instance arrays `sub u1 [3:0] (.clk(clk))` — one connection edit covers the
|
||
whole array declaration correctly (a single `Instance` node, as expected of
|
||
a non-elaborating analyzer).
|
||
- `bind top leaf b_leaf (...)` — `remove_port` correctly rewrites the bind's
|
||
own connection list (2+2 deletions, matching the documented "last element
|
||
is two deletions" shape), confirming bind directives are treated as
|
||
instantiation sites for removal too, not just for `add_port`.
|
||
- `port_actions` swept at all 155 byte offsets of a file combining an
|
||
`` `ifdef``, a comment, a `[W-1:0]` port and an instantiation — no panic
|
||
anywhere.
|
||
- `` // verilog_format: off `` around the header — no interaction; `add_port`
|
||
is indifferent to formatter directives, as expected (different crate,
|
||
different concern).
|
||
- An undefined-width parameter in `decl` (`"input logic [W-1:0] cfg"` on a
|
||
module with no `W`) is **accepted** — `decl`'s own free-form text is only
|
||
checked for *syntax* against a throwaway header, never against the real
|
||
target module's actual parameter set. This matches the README's own
|
||
description of what `parse_port_decl` checks (syntax only) and reads as
|
||
intentional scope, not a bug: the user is trusted with `decl`'s content the
|
||
same way they'd be trusted typing it directly into the file. Noting it
|
||
because the task brief asked about it explicitly, not because it's a
|
||
finding.
|
||
|
||
**HIGH — `add_port` can silently place the new port inside a conditional
|
||
`` `ifdef `` arm, with no warning**
|
||
|
||
Reproduced twice: once through the crate's public `add_port` API, and
|
||
independently through the **real server binary over stdio**
|
||
(`lucisv.addPort` executeCommand — see below) to rule out a test-harness
|
||
artifact.
|
||
|
||
```systemverilog
|
||
module m (
|
||
input clk
|
||
`ifdef HAS_RST
|
||
, input rst
|
||
`endif
|
||
);
|
||
endmodule
|
||
```
|
||
|
||
`add_port(files, ModuleRef::Name("m"), "input logic cfg")` succeeds
|
||
(`Ok`, zero warnings) and inserts `cfg` **on the line before `` `endif``**,
|
||
i.e. *inside* the `HAS_RST` conditional arm:
|
||
|
||
```systemverilog
|
||
module m (
|
||
input clk
|
||
`ifdef HAS_RST
|
||
, input rst,
|
||
input logic cfg
|
||
`endif
|
||
);
|
||
endmodule
|
||
```
|
||
|
||
Root cause: `header_edits` (`crates/vlog_refactor/src/ports.rs:614-655`) and
|
||
`declared_ports` (`ports.rs:432-444`) treat the module's `PortList` as a flat
|
||
list of `AnsiPort`/`NonAnsiPort` entries and append after the textual
|
||
position of the **last declared port's own span** — but `declared_ports`
|
||
never consults `Module.port_directives` (`vlog_parser::ast`, the field
|
||
`parse_port_decl` itself checks — but only against the *throwaway probe*
|
||
module, never against the *real target* module in `header_edits`/`plan_add`).
|
||
When the last declared port sits inside an `` `ifdef``/`` `endif`` region,
|
||
"after the last port" is a byte position that is still textually inside that
|
||
region.
|
||
|
||
This is not a lexical, resolution, or shape-check failure — `verify_splice`
|
||
correctly finds nothing to object to (the file parses, no comment moves, no
|
||
name outside the edit changes meaning), and `confirm`'s shape check correctly
|
||
finds `cfg` declared as a port in the re-parsed text (lucisv doesn't
|
||
preprocess, so it parses through the `` `ifdef`` regardless of the guard). So
|
||
none of the four checks can catch this class of bug **by design** — it's not
|
||
a verification gap, it's a planning gap: the plan itself asked for the wrong
|
||
insertion point. Consequence: if `HAS_RST` is undefined at compile/synthesis
|
||
time, `cfg` silently does not exist as a port of `m` at all, contradicting
|
||
the refactoring's entire premise (add an unconditional port), and nothing in
|
||
the response — no warning, no refusal — tells the user. This is exactly the
|
||
"add-port when module has directives inside port list" scenario the task
|
||
brief named.
|
||
|
||
Confirmed independently over the **real server binary via stdio**
|
||
(`workspace/executeCommand` → `lucisv.addPort`, `["<uri>","m","input logic cfg"]`):
|
||
the returned `WorkspaceEdit`'s single insertion lands at line 3 (0-indexed)
|
||
of the source above — one line before `` `endif `` on line 4 — reproducing
|
||
the finding through the full LSP stack, not just a direct crate call.
|
||
|
||
Not fixed (design decision, not a small/unambiguous one — needs either a
|
||
refusal when the append point falls inside `module.port_directives`, or
|
||
routing the insertion to land after the *whole* directive-guarded region, or
|
||
at minimum a warning naming the conditional). Flagging for dev/lead.
|
||
|
||
**HIGH — `remove_port` never warns (or refuses) when the only remaining use
|
||
of the port is inside a macro invocation's arguments**
|
||
|
||
Direct parallel to M2's round-1 HIGH #2 (`rename`'s macro-invocation-argument
|
||
silence), reproduced for M3:
|
||
|
||
```systemverilog
|
||
`define BUMP(x) x = x + 1
|
||
module m (
|
||
input clk,
|
||
input rst
|
||
);
|
||
initial `BUMP(rst);
|
||
endmodule
|
||
```
|
||
|
||
`remove_port(files, "m.sv", <offset of "rst">)` returns **`Ok`** with **zero
|
||
warnings**, deleting `rst` from the header. `body_uses`
|
||
(`crates/vlog_refactor/src/ports.rs:945-976`, the function backing refusal
|
||
rule 10, "the port is still used inside the module's body") only walks
|
||
`Semantics::references_of`, i.e. resolved semantic references — and
|
||
`` `BUMP(rst) `` lexes as a single opaque `Ident` token
|
||
(name-and-arguments together, same as M2's finding for rename), so `rst`
|
||
inside it is invisible to `vlog_semantic` and produces no reference for
|
||
`body_uses` to find. Unlike `rename.rs`, which grew a dedicated
|
||
`Scope::macro_use_warnings` scan for exactly this class of opaque-token
|
||
occurrence after M2's round 1, `ports.rs` has **no equivalent scan anywhere**
|
||
— confirmed by `grep -n macro crates/vlog_refactor/src/ports.rs`, whose only
|
||
hits are `parse_port_decl`'s check that the *new* `decl` string itself
|
||
contains no macro call, which is a different check entirely.
|
||
|
||
Consequence: removing `rst` here produces a module that compiles (macro
|
||
invocations aren't preprocessed, so `` `BUMP(rst); `` is still ordinary,
|
||
valid-looking tokens to any downstream tool that also doesn't preprocess) but
|
||
whose macro expansion, once actually preprocessed by a real compiler,
|
||
references a port name that no longer exists — with the refactoring reporting
|
||
complete, silent success. Not a byte-level corruption (hard invariant 1
|
||
is about lucisv's own output being verified-correct or refused, and the output
|
||
here *is* what the edit promised), but it is the same "silently wrong,
|
||
zero indication" shape QA flagged as HIGH in M2, applied to the sibling
|
||
feature that reused none of the fix.
|
||
|
||
Not fixed (needs the same design call M2's dev made for rename — warn like a
|
||
macro body, or refuse — which is the dev's/lead's call, not QA's). Flagging
|
||
for dev/lead; the fix pattern (`Scope::macro_use_warnings`, `rename.rs`) is
|
||
already in the codebase as precedent if a warn is chosen.
|
||
|
||
**Low / cosmetic, not filed as a finding**: `add_port` on a CRLF (`\r\n`)
|
||
file inserts new text using a bare `\n` line ending
|
||
(`crates/vlog_refactor/src/ports.rs`'s `append_to_list`/insertion helpers
|
||
always write `\n`), producing one LF-terminated line inside an otherwise
|
||
CRLF file. Not corruption (every check passes; verified independently), just
|
||
a mixed-line-ending cosmetic wrinkle a formatter pass would clean up anyway
|
||
per the "refactored output is edited source, not reformatted source"
|
||
Handshake. Noting for awareness, not asking for a fix.
|
||
|
||
### Real server binary over stdio
|
||
|
||
Ran the dev's own `a_port_code_action_and_the_port_commands_round_trip_over_the_wire`
|
||
(`crates/lucisv_server/tests/e2e.rs:1001`) as part of the full-suite gate run
|
||
(pass, part of the 13 e2e sessions) — it already drives one `textDocument/codeAction`
|
||
and all three `workspace/executeCommand`s (`lucisv.propagatePorts`,
|
||
`lucisv.addPort` twice, once refused) against the real `lucisv-server` binary,
|
||
and asserts the code action's inline `WorkspaceEdit`, the command responses'
|
||
edits, the advertised capabilities (`executeCommandProvider`, the
|
||
`refactor.rewrite.lucisv.ports` code-action kind), and the `-32803` refusal
|
||
shape. I re-ran it in isolation to confirm independently rather than trust
|
||
the aggregate count, and it passed.
|
||
|
||
I additionally wrote and ran (temporarily, then reverted) my own independent
|
||
e2e session — not reusing the dev's fixture — that drives `lucisv.addPort`
|
||
through `workspace/executeCommand` against the real binary on the
|
||
`` `ifdef ``-in-port-list source above; see the HIGH finding.
|
||
|
||
### Files touched during QA (all reverted; nothing left in the tree)
|
||
|
||
`crates/vlog_refactor/src/lib.rs`, `crates/vlog_refactor/src/check.rs`,
|
||
`crates/vlog_refactor/src/ports.rs`, `crates/lucisv_server/tests/e2e.rs` each
|
||
had temporary `#[test] fn qa_*` functions added, run, and then restored
|
||
byte-for-byte from a pre-edit copy (diffed against the copy to confirm a
|
||
clean revert). `crates/vlog_refactor/tests/qa_probe.rs` was created, run,
|
||
and deleted. `git status --short` after cleanup shows only the dev's
|
||
original changes; `cargo build -p vlog_refactor -p lucisv_server --tests`
|
||
rebuilds clean.
|
||
|
||
### Summary
|
||
|
||
| Claim | Verdict |
|
||
|---|---|
|
||
| `cargo fmt` / `cargo clippy` / `cargo test --workspace` clean | **Pass** |
|
||
| Test count (1164) | **Pass, confirmed** |
|
||
| `Shift::map` predicate change is safe for rename | **Pass, confirmed** — proof + 9 empirical tests; a second, unreachable divergence zone documented for the record |
|
||
| `verify_splice` (lexical/comment/parse/resolution) resists new attacks | **Pass** — comment reordering, comment-into-string, partial-comment-deletion all rejected |
|
||
| `confirm` (shape check) is what catches a parameter-list capture, not `verify_splice` | **Pass, confirmed directly** — matches the README's own claim exactly |
|
||
| Refusal list (duplicate name, two-port decl, direction-inherited two-port decl, injection strings, ambiguous module, unindexed module, positional-connection refusals, ifdef body-use refusal) | **Pass**, no gaps found |
|
||
| `add_port` can silently land a new port inside an `` `ifdef `` arm | **HIGH finding** — confirmed via crate API and real server binary, not fixed, flagged for dev/lead |
|
||
| `remove_port` never warns about a port only used inside a macro invocation | **HIGH finding** — direct parallel to M2's round-1 HIGH #2, not fixed, flagged for dev/lead |
|
||
| CRLF new-text line ending | **Low/cosmetic**, not filed |
|
||
| Code action + executeCommand over real stdio | **Pass** — dev's own e2e test re-verified, plus one independent QA-authored session |
|
||
|
||
No fixes applied — both HIGH findings need a design decision (warn vs.
|
||
refuse, and where), which is the dev's/lead's call per CLAUDE.md, not QA's.
|
||
Nothing else found needed one either. No probe files or temporary test code
|
||
left in the tree.
|
||
|
||
**Overall verdict: ship-after-fixes.** Everything the milestone's own claims
|
||
assert about gates, the shared-code change, and the two-layer verifier holds
|
||
up under direct adversarial attack — this is a well-built safety net and I
|
||
could not get it to forgive a masked corruption. The two HIGH findings are
|
||
both silent-wrong-output-not-corruption shapes (the byte-level safety net is
|
||
sound; the *planning* layer above it has two gaps a user would not discover
|
||
until synthesis or simulation), one of which is a near-exact repeat of a
|
||
defect class M2 already has a fix pattern for. Neither blocks the safety
|
||
invariants CLAUDE.md cares about most (never corrupt, idempotent, comments
|
||
preserved), so this is not a "needs-rework" verdict, but both should be
|
||
closed (or explicitly, consciously deferred with a warning in the interim)
|
||
before this ships to real users editing real conditional RTL.
|
||
|
||
**2026-08-24 (round 2) — QA agent.** Re-verification after the dev's rework
|
||
of both round-1 HIGH findings and the `Shift::map` documentation ask, per the
|
||
lead's rulings.
|
||
|
||
### Gates
|
||
|
||
- `cargo fmt --all -- --check` — clean.
|
||
- `cargo clippy --all-targets` — clean, zero warnings, workspace-wide.
|
||
- `cargo test --workspace` — green, **1170** tests, 0 failures — matches the
|
||
Work log's number exactly (was 1164 in round 1; summed every
|
||
`test result: ok. N passed` line in the run to confirm the total rather
|
||
than trust the Work log's arithmetic).
|
||
- All three gates: **pass, claims confirmed.**
|
||
|
||
### Round-1 HIGH #1 (`` `ifdef ``-in-port-list) — mechanism verified, holds
|
||
under nested/chained attacks
|
||
|
||
Re-attacked `guard_conditionals`/`nesting_of`/`list_directives`/
|
||
`body_directives` (`crates/vlog_refactor/src/ports.rs:701-808`) at the
|
||
mechanism level rather than re-running the original repro unchanged — the
|
||
brief's own round-2 attack list, plus one I added:
|
||
|
||
| Attack | Expected | Result |
|
||
|---|---|---|
|
||
| Last port sits in an `` `else`` arm (`` `ifdef``/.../`` `else``/*port*/`` `endif``) | Refuse — `else` continues the region, doesn't reset depth | **Refused**, correctly naming the `` `ifdef`` that opened the arm |
|
||
| `` `elsif`` chain, last port in the final `` `else`` | Refuse, same reason | **Refused** |
|
||
| Nested `` `ifdef OUTER``/`` `ifdef INNER``/*port b*/`` `endif``/*port rst*/`` `endif`` — insertion point is textually *after the inner* `` `endif`` but still inside the *outer* arm | Refuse — depth must net to 1, not be fooled by the inner close | **Refused**, correctly naming `` `ifdef INNER`` as the innermost still-open arm at the insertion point (depth-counting is genuinely nesting-aware, not just "any directive present") |
|
||
| A directive pair (`` `ifdef UNUSED``/`` `endif``, nothing declared inside) sitting entirely *after* the last real port — the insertion point precedes both | Must **not** refuse (nothing is inside any arm at the insertion point) | **Accepted** (not refused) — the guard correctly does not fire on directives it hasn't reached yet |
|
||
| Non-ANSI module, last port's *body* declaration wrapped in `` `ifdef``/`` `endif`` (the header-name-list path has no directives at all here — only `body_directives` can catch this) | Refuse via the body path specifically | **Refused**, confirming the fix really is applied to *both* insertion paths (`list_directives` for ANSI/header, `body_directives` for non-ANSI/body), not just the one QA's round-1 repro happened to exercise |
|
||
| A stray `` `endif`` with no matching `` `ifdef`` before the insertion point (malformed input, negative depth) | Refuse ("do not balance"), no panic | **Refused** with the "do not balance" message, not the "would land inside the arm" one — confirms the `depth > 0` / `depth != 0` two-step correctly separates "positively inside an arm" from "unbalanced, can't tell" and that the widened `!= 0` (not just `> 0`) ruling actually fired |
|
||
|
||
No corruption, no panic, and — importantly — no *false* refusal: the
|
||
trailing-directive case proves the guard is reading the insertion point's
|
||
actual position, not just "does this list contain any directive at all".
|
||
|
||
**One imprecision found, not filed as a finding (documenting for the
|
||
record):** in the trailing-directive-after-insertion case above, the edit is
|
||
correctly accepted, but the accompanying warning still names the (entirely
|
||
irrelevant, position-wise) trailing directives: `` "`m`'s port list carries
|
||
compiler directives (`ifdef UNUSED` at m.sv:4, and 1 more), so what ports it
|
||
declares depends on the configuration; lucisv added the port outside every
|
||
conditional arm." `` The new port is *not* actually configuration-dependent
|
||
here (nothing is declared inside that trailing, empty `` `ifdef``), because
|
||
`guard_conditionals`'s warning branch reads from the full unfiltered
|
||
`directives` slice rather than the same `.filter(|d| d.span.start < at)` view
|
||
the depth count uses. This is the safe direction (over-warning, never
|
||
under-protecting) and matches the docstring's own framing ("warn when the
|
||
region it joins is conditionally compiled *at all*"), so I'm treating it as a
|
||
plausibly intentional "the list uses conditional compilation, be aware"
|
||
heads-up rather than a bug — but it can read as mildly misleading to a user
|
||
staring at a warning that doesn't apply to their new port. Not asking for a
|
||
fix; noting in case a future pass wants to tighten the warning to only the
|
||
directives actually before `at`.
|
||
|
||
**Verdict: fixed.** The guard is genuinely nesting- and position-aware, not
|
||
a shallow "any directive present" check, and it correctly distinguishes
|
||
"inside an arm" (refuse), "directives exist but I'm not inside one" (warn,
|
||
proceed), and "can't tell" (refuse) exactly as the ruling specified — verified
|
||
across both insertion paths and against chained/nested directive shapes the
|
||
round-1 finding never tried.
|
||
|
||
### Round-1 HIGH #2 (macro-invocation silence on removal) — mechanism
|
||
verified, holds under the skip/report boundary attack
|
||
|
||
Re-attacked `preprocessor_warnings` (`ports.rs:1118-1139`) and the shared
|
||
`Scope::define_sites`/`Scope::macro_argument_sites` (`rename.rs:489-542`)
|
||
specifically at the boundary the brief named — "macro named exactly the port
|
||
invoked with no args vs. with args":
|
||
|
||
- **A macro whose own name equals the port name, invoked bare (no
|
||
parens)** (`` `define rst 1`` ... `` `rst;``, removing port `rst`) —
|
||
**correctly skipped**, zero warnings. This is the right call: `` `rst``
|
||
(backtick) is a macro invocation in a different namespace from the port
|
||
`rst` (no backtick); removing the port has no bearing on this macro at
|
||
all, so silence here is correct, not a gap.
|
||
- **A *different* macro whose body spells the port name, invoked bare
|
||
elsewhere** (`` `define GET_RST rst`` ... `` `GET_RST;``) — **correctly
|
||
reported**: `` "`rst` appears in the body of macro `GET_RST` ... lucisv does
|
||
not preprocess, so that body still names the removed port." `` Confirms
|
||
`define_sites` catches this via the `` `define`` table directly, independent
|
||
of how the macro is later invoked (bare or with parens) — a body-spelling
|
||
macro is reported regardless of call syntax, which is the harder half of
|
||
the boundary to get right.
|
||
- **Compound case, both mechanisms on the same macro at once**: a macro
|
||
named exactly like the port (`` `define RST(x) ...``, port also named
|
||
`RST`) invoked *with* an argument that itself spells the port name
|
||
(`` `RST(RST)``). The name-collision "skip" rule
|
||
(`site.defines_the_name.is_some()`) and the argument-content "report" rule
|
||
(`macro_argument_sites`) are independent scans over independent data
|
||
(the define table vs. macro-invocation tokens); confirmed the skip on the
|
||
first does **not** suppress the report from the second — the argument use
|
||
is still reported (`` "`RST` appears in the arguments of the macro
|
||
invocation `RST` at m.sv:6 ..." ``). This was the real risk in this design
|
||
(one shared function silently eating both), and it doesn't happen.
|
||
|
||
**Verdict: fixed.** The skip/report boundary is exactly where the ruling
|
||
drew it — name-collision is noise, body- and argument-content are news —
|
||
and the two mechanisms compose correctly rather than one accidentally
|
||
shadowing the other.
|
||
|
||
### Rename factoring — spot-checked, unchanged
|
||
|
||
Ran `cargo test -p vlog_refactor --test rename` in isolation: all **48**
|
||
behavior tests pass, matching the Work log's "byte-for-byte unchanged"
|
||
claim. Independently (not reusing any of the dev's 48 fixtures), wrote two
|
||
manual probes against a macro-argument shape and a `` `define``-body shape
|
||
different from the ones already in `tests/rename.rs`, calling the public
|
||
`rename()` API directly:
|
||
|
||
- `` `define BUMP(x) x = x + 1`` / `` `BUMP(a);``, renaming `a` → `b`:
|
||
warning text came back **exactly** `` "`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." ``
|
||
— byte-for-byte the template `rename.rs::macro_use_warnings` has always
|
||
produced.
|
||
- `` `define HOLDS_A a`` (no invocation at all, just the body), renaming
|
||
`a` → `b`: warning came back containing "appears in the body of macro
|
||
`HOLDS_A`" — the `define_sites`/`macro_warnings` template, also
|
||
unchanged.
|
||
|
||
**Verdict: confirmed unchanged.** The factoring
|
||
(`Scope::define_sites`/`Scope::macro_argument_sites` shared with
|
||
`ports.rs::preprocessor_warnings`) moved *scanning* code without moving
|
||
*rename's* output, on both the dev's own fixtures and two independent ones.
|
||
|
||
### `Shift::map` documentation
|
||
|
||
Confirmed the doc comment (`lib.rs:108-116`) now states the invariant
|
||
explicitly — every span handed to `map` is either identical to an edit's
|
||
range or fully disjoint from all of them, a violating span's answer is
|
||
"arbitrary, not a location," and `check::print`'s `excluded` list is named
|
||
as the mechanism that keeps it true. This is exactly the "soft spot" round 1
|
||
flagged (not a defect, just unstated); it's now stated. Nothing to
|
||
re-verify behaviorally here since the code itself didn't change, only the
|
||
comment — confirmed by re-reading the surrounding function body unchanged
|
||
except for the comment block.
|
||
|
||
### Corpus
|
||
|
||
Not re-run independently this round (no code path changed that the corpus
|
||
number would catch beyond what the crate-level regressions already pin more
|
||
precisely); the dev's claim (`add_port` over 860 files still `Ok((6, 18))`
|
||
in 0.36 s) is consistent with the gate run producing the same 1170 total and
|
||
no new corpus-test failures in the full `cargo test --workspace` run above.
|
||
|
||
### Housekeeping
|
||
|
||
All probes this round were added as standalone temporary test files
|
||
(`crates/vlog_refactor/tests/qa_probe2.rs`, 9 tests attacking the `` `ifdef ``
|
||
guard and the macro skip/report boundary; `qa_probe2_rename.rs`, 2 tests
|
||
spot-checking rename) — no existing source file was edited this round (round
|
||
1's technique of temporarily patching `check.rs`/`ports.rs`/`lib.rs` wasn't
|
||
needed since every round-2 attack was reachable through the public API).
|
||
Both files were run and then deleted; `git status --short` after cleanup
|
||
shows only the dev's original changes.
|
||
|
||
### Summary (round 2)
|
||
|
||
| Round-1 finding | Round-2 verdict |
|
||
|---|---|
|
||
| `add_port` inside an `` `ifdef `` arm (HIGH #1) | **Fixed** — verified against `else`/`elsif` chains, nested ifdefs, the non-ANSI body path, and a negative/unbalanced-depth malformed input; one non-blocking imprecision noted (trailing-directive warning text) |
|
||
| `remove_port` macro-invocation silence (HIGH #2) | **Fixed** — verified at the exact skip/report boundary the ruling drew, including a compound case where both mechanisms apply to the same macro at once |
|
||
| `Shift::map` implicit invariant | **Documented**, as asked; nothing behavioral to re-verify |
|
||
| Rename factoring left rename unchanged | **Confirmed** — 48 existing tests pass, plus 2 independent manual probes |
|
||
| Gates (fmt/clippy/test) | **Pass**, 1170 tests, 0 failures |
|
||
| New round-2 attacks (else/elsif/nested-ifdef/trailing-directive/non-ANSI-body/negative-depth/macro skip-report boundary/compound name-and-argument collision) | **Pass** — no new corruption, no false refusals, no panics; one cosmetic warning-precision note |
|
||
|
||
**Overall verdict: ship.** Both HIGH findings are genuinely closed at the
|
||
mechanism level, not just at the level of the original reproduction: I
|
||
specifically tried to defeat the `` `ifdef`` guard's depth-counting with
|
||
nesting and chaining, and tried to make the macro skip-rule swallow a
|
||
report it shouldn't — both held. The guard is a *planning*-layer fix
|
||
exactly where round 1 said the gap was (verification checks 1–5 still
|
||
correctly have no opinion on conditional compilation, and don't need one now
|
||
that the planner itself refuses the unsafe case). Nothing else moved:
|
||
rename's 48 tests and 1085→1164→1170's monotonic, exactly-matching test
|
||
counts across all three QA passes are themselves evidence against scope
|
||
creep. The one imprecision found (over-broad trailing-directive warning
|
||
text) is cosmetic, safe-direction, and not blocking.
|
||
|
||
**2026-08-28 — QA agent.** Round on the codeAction-fan-out change: `Workspace::module_sources` replacing `ws.sources()` for `textDocument/codeAction` and the three port commands. Adversarial charter: find a file the whole-workspace computation would have edited (or that would change/refuse the answer) missing from the subset — refactoring correctness, invariant-1-adjacent.
|
||
|
||
### Gates
|
||
|
||
- `cargo fmt --all -- --check` — clean.
|
||
- `cargo clippy --all-targets` — clean, zero warnings, workspace-wide (one warning surfaced from a QA-added test — `map_or(true, …)` → `is_none_or(…)` — fixed directly, small and unambiguous).
|
||
- `cargo test --workspace` — green, **2482** passed, 0 failed, 0 measured (28 `#[ignore]`d perf probes not run) — includes the 6 permanent regression tests added this round (below). `lucisv_server`'s own unit suite: **1249** passed, 28 ignored. `vlog_refactor` unit: 72, `tests/ports.rs`: 52 (dev added 2: the byte-sweep pinning `may_have_port_action`/`port_action_modules` against each other, and `enclosing_module`'s own test).
|
||
- `node editors/vscode/smoke.js target/release/lucisv-server` — OK (had to pass the binary path explicitly; `lucisv-server` is not on `PATH` in this environment, not a project issue).
|
||
- Reproduced the synthetic perf claim exactly: `perf::a_code_action_at_an_instantiation_before_and_after` (`--release`) printed **724 ms → 409 µs**, `sources()` alone **14.4 ms**, `prepareRename` **250 ms** — matches the README's 725 ms / 0.41 ms / 14.5 ms / 249 ms table to the reported precision.
|
||
- Reproduced the OpenTitan claim's *shape* independently, with a throwaway probe (added to `perf.rs`, run, then reverted — not in the tree): cursor on a port of `adc_ctrl_core.sv` went **3.13 s → 3.17 ms**; cursor on a `prim_fifo_sync` instantiation (in `otp_ctrl.sv`, a different real fan-out site than the dev's) went **3.08 s → 84.6 ms** — both essentially the dev's numbers (4.56 s→7.1 ms; 2.93 s→83 ms) to within what a different instantiation site and a warm/cold FS cache would explain. Both probe cursors landed on offsets that produced 0 offered actions on *both* sides (an imprecise offset, not a bug), but the **parity held** (0 == 0) in both cases, which is the property that matters here. No test depends on the checkout, per the brief.
|
||
|
||
### Attack angles from the brief, and what I found
|
||
|
||
**1. Missing-file attacks — all held.** Wrote 4 new permanent regression tests attacking the exact scenarios the brief named, each asserting the subset's `code_actions`/`module_sources` answer against `whole_workspace_at` (the dev's own reference function) or `ws.sources()`:
|
||
|
||
- `qa_file_scope_instantiation_lands_in_the_subset` (`crates/lucisv_server/src/ports.rs`) — an owner-less instantiation (`sub u_fs (.clk(c), .rst(r));` at file scope, no enclosing module) records **no** `InstantiationEdge` (confirmed directly: `edges_of` requires an owner), yet the file lands in `module_sources` and the subset's answer matches the whole-workspace one exactly. This is the dev's rung-3-second-half claim (`references_to` catching what `instantiations_of` structurally cannot) — verified empirically, not just by reading `resolve.rs`'s `named_at_file_scope`/`bind_instantiation` code path that makes it true. This was the brief's most specific, most load-bearing ask ("verify it actually lands in `references_to`") and it does.
|
||
- `qa_generate_block_instantiation_lands_in_the_subset` — an instantiation inside a `generate for` body is a real `InstantiationEdge` (confirmed) and its file is in the subset, subset == whole-workspace.
|
||
- `qa_escaped_module_name_instantiation_parity_with_whole_workspace` — an escaped-identifier instantiation (`` \sub u_esc (...) ``). Whatever the parser/binder does with the escape (resolve it to `sub` or treat it as a distinct name — did not chase which, since it is a pre-existing lexical question this round did not touch), the subset and whole-workspace answers agree. Framed as a parity check rather than a correctness check of escaping itself, since a bug there would be M1/M2-era and out of this round's scope.
|
||
- `qa_add_port_by_position_still_fans_out_to_instantiation_files` — the dev's own equivalence test (`a_command_computes_over_the_subset_and_answers_the_same`) only exercises `lucisv.addPort` with a **module-name** argument, which reaches `module_sources` directly. The **Position** argument goes through a different function (`sources_at`, used by all three commands and by nothing else previously tested at the command layer) — confirmed it still reaches all 3 instantiating files, matching `ws.sources()`'s answer byte-for-byte.
|
||
- Not separately tested as a new attack, but read and reasoned through carefully: `.*` connections, hierarchical-reference-only files, and macro-expanded module names. `.*` sites are structurally ordinary `Instantiation` nodes to `edges_of`/`collect_instantiations` (connection *style* plays no part in either census), so they get the same edge as a named-connection site — no special case to miss. A file whose only relationship to the module is a hierarchical reference to one of its ports (no instantiation) is not in scope for *either* the old or the new computation (neither `collect_instantiations` nor `edges_of` would ever find or edit it), so it cannot be a point of divergence. A macro-expanded module name is one opaque token to lucisv's non-preprocessing binder in both the old and new code paths equally (documented Assumption, unchanged) — not a regression this round could introduce.
|
||
- Did **not** separately verify a duplicate-module-name-under-macro or a nested-module-inside-a-package instantiation; ran out of budget. Low-risk: `collect_instantiations`/`edges_of` both explicitly walk `ItemKind::Package{items,..}` identically (confirmed by direct side-by-side read of both functions, `crates/vlog_semantic/src/instantiations.rs:68-105` vs `crates/vlog_refactor/src/ports.rs:489-518` — they are the same match arms in the same order, which is exactly the Handshake's "walk-for-walk" claim, verified by inspection rather than by a fresh test).
|
||
|
||
**2. Refusal-parity attacks.**
|
||
|
||
- Duplicate-definer-already-indexed: the dev's own `a_module_declared_twice_is_refused_through_the_subset_as_well` covers this (re-ran, passes).
|
||
- New module in an **unsaved buffer the index has never heard of at all** (not stale — genuinely absent): `qa_a_module_declared_only_in_an_unsaved_new_file_is_still_handled` — a module declared only in a brand-new, never-saved-to-disk buffer, with the cursor inside that same buffer. Rung 1 ("the file the request names") is what carries it, since rung 2 (`index.units`) is empty for a name the index has never indexed. Confirmed it still offers the action correctly (`lucisv: remove port \`b\` (no instantiation in scope)`), no panic, no silent no-op.
|
||
- **Index stale vs. disk — the one place I judged rather than just tested.** `qa_a_duplicate_definer_unindexed_on_disk_is_a_stale_answer_not_a_corruption`: wrote a *second* definer of `sub` straight to the filesystem, bypassing the server (`fs::write`, no `rebuild_index`, no `set_document`). Confirmed: the subset computation, unaware of the new file, does **not** refuse — it offers the action as if the module were still uniquely declared, which is a real, observable divergence from `ws.sources()`'s always-fresh-from-disk answer (the old code path *would* have refused here). Judged against invariant 1, not against freshness, per the brief's own framing: this cannot corrupt anything, because the engine is handed exactly the files in the subset and has no I/O of its own — `dupe.sv` is never read and never appears in the produced edit (asserted directly). The worst case is a **stale-but-internally-consistent** answer (an edit that is fully verified against the files it actually saw), not a wrong-and-unverified one. This is exactly the trade-off the dev's own Assumptions section documents ("the index is the server's authority... a file changed on disk with nothing telling this server is a file the action does not read") and explicitly parallels every other index-backed LSP answer in the server (definition, hover, references). I agree with the dev's framing: this is a disclosed staleness trade-off, not a hidden safety gap, and does not violate "never corrupt code." Confirmed the parity is restored the moment the index is told (`rebuild_index()` → refuses, matching whole-workspace).
|
||
|
||
**3. Gate ⟺ subset coherence — verified by direct code comparison, no divergence found.** `may_have_port_action` is now defined literally as `!port_action_modules(...).is_empty()` (`crates/vlog_refactor/src/ports.rs:159`), so the two cannot drift by construction; the only residual risk was a logic bug introduced while refactoring the original single-`bool` walk into a `Vec<String>`-returning one. Diffed the two versions line-by-line: the only structural change is `.any(...)` → `.filter(...).map(...).collect()` over the same predicate, which is behavior-preserving (a multi-match, if the tolerant parser ever produced overlapping instantiation spans, would just widen the returned module list — still correctly non-empty, never a false negative). The dev's own new test (`the_pre_check_names_the_module_whose_files_the_action_will_need`, `crates/vlog_refactor/tests/ports.rs`) sweeps every byte offset of a mixed file and asserts `may_have_port_action(text, offset) == !port_action_modules(text, offset).is_empty()` — re-ran it, passes. No old-vs-new crafted-file attack found a gate-false position the old whole-workspace path would have offered an action for, because the "old path" *is* this same walk (`may_have_port_action` was never a separately-maintained function — it's the same code, just newly able to say which module).
|
||
|
||
**4. Command parity — held**, including the position-argument case above (attack 1's `qa_add_port_by_position...` doubles as this). `REMOVE_PORT`/`PROPAGATE_PORTS` both go through `sources_at`, which unions `port_action_modules` (what the offset directly names — a port, or an instantiation's own module) with `enclosing_module` (the module the offset sits textually inside) — read `locate_module`'s `ModuleRef::At` (`ports.rs:379-413`) and `locate_port`/`plan_propagate`'s own module-name derivation to confirm `sources_at` always names a superset of what the engine will independently look up for each of the three commands; for `propagate_ports` specifically the extra `enclosing_module` name is unnecessary (the README says propagate only ever touches the cursor's own file) but harmless — it can only add files, never omit the one that matters.
|
||
|
||
**5. Verifier integrity.** Read this one by construction rather than by attack: `check::watched_files` and the whole verifier only ever see the files handed to `Scope::build(files)` — the crate does no I/O of its own (Handshakes, unchanged this round). So "an edit corrupts a file outside the subset" is not reachable as a distinct failure mode in this design: the engine cannot write to, or even read, a file that was never in the set. The only failure mode a wrong subset can produce is the one attack angle 1 covers (a file that *should* have been edited is silently skipped) — which is why I put the budget there instead of trying to construct a doomed "verifier misses an out-of-subset corruption" scenario that the architecture rules out by construction.
|
||
|
||
### Tests added (all permanent, all in `crates/lucisv_server/src/ports.rs`'s `mod tests`)
|
||
|
||
`qa_file_scope_instantiation_lands_in_the_subset`, `qa_generate_block_instantiation_lands_in_the_subset`, `qa_escaped_module_name_instantiation_parity_with_whole_workspace`, `qa_add_port_by_position_still_fans_out_to_instantiation_files`, `qa_a_module_declared_only_in_an_unsaved_new_file_is_still_handled`, `qa_a_duplicate_definer_unindexed_on_disk_is_a_stale_answer_not_a_corruption`. No probe files left in the tree; the only non-test-only edit was the `map_or` → `is_none_or` clippy fix inside my own new test code (nothing in the dev's code touched).
|
||
|
||
### Summary
|
||
|
||
| Claim | Verdict |
|
||
|---|---|
|
||
| `cargo fmt`/`cargo clippy`/`cargo test --workspace`/smoke | **Pass** |
|
||
| File-scope (owner-less) instantiation lands in the subset via `references_to` | **Pass, confirmed empirically** — the brief's most specific ask |
|
||
| Generate-block instantiation, escaped-identifier parity | **Pass** |
|
||
| `ModuleArgument::Position` (not just `Name`) still fans out correctly | **Pass, confirmed** — previously untested combination |
|
||
| Ambiguous-module refusal, via the index | **Pass** (dev's own test, re-verified) |
|
||
| Unsaved brand-new module (index has never heard of it) | **Pass** |
|
||
| Index stale vs. disk (duplicate definer unindexed) | **Behaves as documented**: a stale-but-verified answer, never a corruption; matches the Assumptions section's own framing |
|
||
| Gate (`may_have_port_action`) ⟺ fan-out (`port_action_modules`) coherence | **Pass, verified by construction + the dev's byte-sweep test** |
|
||
| Command parity across all three commands | **Pass** |
|
||
| Verifier cannot touch a file outside the subset | **True by construction** (no I/O in the crate) |
|
||
| Perf claims (synthetic + OpenTitan) | **Reproduced**, synthetic to the reported precision, OpenTitan to the same order of magnitude on different cursor sites |
|
||
|
||
No corruption, no false refusal, no lost feature, and no missing-file divergence found anywhere I could construct one. The one real, novel-to-this-round behavior change (index staleness vs. `sources()`'s always-fresh disk read) is pre-existing in spirit everywhere else in the server, is disclosed prominently in the feature's own Assumptions section, and cannot produce a corrupt edit by the crate's own no-I/O architecture — so I am not filing it as a finding, only recording that I attacked it deliberately and it held.
|
||
|
||
**Verdict: SHIP.** No blocking or non-blocking findings this round.
|
||
|
||
## Review
|
||
|
||
**2026-08-28 — lead, codeAction fan-out round.** Reviewed after QA's
|
||
clean SHIP; gates re-run independently (fmt clean, clippy silent, 2482
|
||
workspace tests green). This closes the owner's original report from
|
||
the root: the "slow F12" was a 3–4.5 s codeAction on every cursor move
|
||
blocking the single-threaded loop, and the fix is the house pattern —
|
||
the index's fan-out instead of `ws.sources()` — with the sufficiency
|
||
argument written before the speed was trusted. The dev's fourth rung
|
||
(`references_to`, because `edges_of` drops owner-less file-scope
|
||
instantiations) is exactly the kind of gap that separates a subset from
|
||
a superset, found by reading rather than by failing; QA confirmed it
|
||
empirically and pinned it. The one behavior change — a port action now
|
||
sees the workspace as the index describes it, so an unindexed on-disk
|
||
duplicate yields a stale offer instead of a fresh refusal — is
|
||
disclosed in Assumptions, cannot corrupt (the engine does no I/O of
|
||
its own; QA proved the untouched file untouched), and aligns this
|
||
answer with every other index-backed one. 4.56 s → 7.1 ms on
|
||
opentitan, 83 ms honest ceiling at a 36-file fan-out, both reproduced
|
||
by QA on different cursors. The prepareRename follow-up (250 ms on the
|
||
synthetic; 2.5–3 s measured on opentitan in performance.md) is Lane A
|
||
of the performance wave. Accepted; committed by the lead.
|
||
|
||
**2026-08-24 — lead.** Reviewed after QA round 2's ship verdict; gates run
|
||
independently (1170 tests, 0 failures, clippy silent). The splice verifier
|
||
plus per-feature shape check is the right division — the verifier stays
|
||
generic and un-widened, and the check that knows what a port list should say
|
||
lives with the feature. QA's two round-1 HIGHs (silent `ifdef`-arm
|
||
placement, macro-argument silence) closed per ruling: the nesting guard is
|
||
genuinely position- and depth-aware under attack, covers both insertion
|
||
paths, and the dev's widening of the ruling (refuse on negative depth too)
|
||
is correct. The factored rename scans left M2's output byte-for-byte
|
||
unchanged. Accepted; M3 checked off in the umbrella plan and TODO.md §8.
|
||
Noted, not blocking: QA's cosmetic over-warning on directives after the
|
||
insertion point, and CRLF insertions writing `\n` — both recorded in the
|
||
work log with reasoning.
|