Files
lucioandClaude Fable 5.1 e1679bebc5
ci / checks (push) Successful in 1m29s
ci / corpus (push) Successful in 37s
Inline module: a module's body copied into its instantiator with ports and parameters substituted, and a verifier that knows a copy
TODO §53.2 (docs/features/extract-inline-module), the fifth §8
refactoring; extract → inline round-trips byte-equal after formatting.

`vlog_refactor::inline_module` (inline/{mod,site,source,render}.rs):
every symbol bound in `S`'s module scope is classified once — a port
becomes the name or literal connected to it, anything else `S` declares
at module scope is prefixed `u_S_` only when `M`'s file already spells
one of them; parameters become `localparam`s with the override or
default; the body is copied verbatim except name spans, with `.name`
shorthand connections expanded when their signal is renamed. Refusals:
`.*`, positional lists, expression connections, an unconnected port, an
output into a literal, any hierarchical reference to `u_S` in the handed
files, `S` unknown/twice/in `M`'s own file, interface/`inout`/unpacked/
non-ANSI ports, `initial`/`final`, macros, directives, any `generate`, a
differing `timescale`, collisions prefixing cannot resolve. Server:
`refactor.inline` lazy action, `lucisv.inlineModule`.

Verifier: `Moving` gains `Origin::{Moved, Copied}` — a copied region's
pieces join the transit under rule 0, "a copied file appears in no
edit"; eight attack pairs through the production entry; QA's neutering
map shows every rule load-bearing. QA's MEDIUMs filed: topo §2.9-32
(same blind spot) and §2.9-33 (`module_sources` lacks a transitive-
instantiators rung).

Trials: corpus 5 inlined / 9 refused, opentitan 5 / 56, the lint census
0 → 0 on every pair. 0 of 854 corpus files differ from 0.48.x.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-06 21:04:05 -05:00
..

extract-inline-module

TODO §53 — the dearest of the §8 refactoring backlog, in two halves. §53.1 extract module ships (0.47.0). §53.2 inline module ships (0.49.0), and the round trip between them is pinned.

Goal

A module grows until one of its always blocks is a module of its own. The refactoring every RTL engineer does by hand is: select the items, invent a name, work out which signals cross the boundary and in which direction, write the new module's header, paste the items into it, and write an instantiation where they were. Every step of that is mechanical and every step of it is easy to get wrong — a signal made an input that the block actually drives is a silent, synthesizable bug.

Extract module does it. Given a selection covering one or more contiguous whole module items of a module M, and a name N, lucisv writes a module N whose ports and parameters are inferred from the dataflow across the selection's boundary, into a file N.sv beside M's own, and replaces the selection with N u_N (...) — rendered from N's own text through instantiation_plan, so the skeleton and the module cannot disagree about what N's ports are.

Inline module (§53.2) is the same job read backwards, and the one an engineer does when a module has shrunk into a wrapper. With the cursor on S u_S (...), lucisv deletes the instantiation and writes S's items in its place: every use of a port becomes the name connected to it, every parameter becomes a localparam holding its override (or its default), every name S declares for itself keeps its name unless M already spells it — in which case they all take a u_S_ in front — and S's imports are carried across when M lacks them. S itself is not touched, and neither is anything else that instantiates it: an inline is a copy out of S's file, which is the one structural difference from the extraction and the one thing the verifier had to learn.

Whole-edit-or-nothing, through the crate's own splice verifier (vlog_refactor::check): an Ok is safe to apply, an Err is a sentence for the user and no edits at all. Where lucisv cannot know — the direction of a routine's argument, the direction of a connection to a module the index has no single declaration of, what a macro would expand to inside S — it refuses rather than guesses.

API as built

// crates/vlog_refactor/src/lib.rs
pub enum Home { NewFile, SameFile }

pub struct ExtractSite {          // the cheap gate's answer
    pub module: String,           //   the module the selection is in
    pub default_name: String,     //   `M_extracted`
    pub units: Vec<String>,       //   what the engine will need read
}

pub fn extract_site(text: &str, start: u32, end: u32) -> Option<ExtractSite>;
pub fn extract_title() -> String;
pub fn extract_module(files: &[(PathBuf, String)], file: &Path,
                      start: u32, end: u32, new_name: &str, home: Home)
    -> Result<RefactorEdit, String>;

// widened, additively
pub struct RefactorEdit { pub edits: …, pub warnings: …, pub created: Vec<PathBuf> }

// crates/lucisv_server/src/extract.rs
pub const EXTRACT_MODULE: &str = "lucisv.extractModule";   // [uri, range, name]
pub fn kind() -> CodeActionKind;                            // refactor.extract
pub fn code_actions(ws, uri, range) -> Vec<CodeActionOrCommand>;
pub fn execute(ws, arguments, create_files) -> Result<(WorkspaceEdit, Vec<String>), String>;
pub fn workspace_edit(ws, refactoring) -> Result<WorkspaceEdit, String>;

// editors/vscode/extract.js
executeCommand(deps, command, args, next)   // the language client's middleware
validateModuleName(value)

crates/vlog_refactor/src/extract/ is five files, one question each (and region.rs answers a sixth: an interface and a program are the same AST node as a module, and only the first is one lucisv extracts out of):

file one sentence
mod.rs the entry points, the plan, the edits, the verification
region.rs what the selection covers, and the item kinds that refuse
flow.rs which names cross, and in which direction
boundary.rs what each crossing name becomes: port, parameter, import
render.rs the new module's text, and the instantiation

§53.2, as built

// crates/vlog_refactor/src/lib.rs
pub struct InlineSite {           // the cheap gate's answer
    pub module: String,           //   the module that would be inlined
    pub instance: String,         //   the instance's own name
    pub units: Vec<String>,       //   what the engine will need read
}

pub fn inline_site(text: &str, offset: u32) -> Option<InlineSite>;
pub fn inline_title(module: &str) -> String;   // "lucisv: inline `S` here"
pub fn inline_module(files: &[(PathBuf, String)], file: &Path, offset: u32)
    -> Result<RefactorEdit, String>;

// crates/lucisv_server/src/inline_module.rs
pub const INLINE_MODULE: &str = "lucisv.inlineModule";     // [uri, position]
pub fn kind() -> CodeActionKind;                            // refactor.inline
pub fn code_actions(ws, uri, range) -> Vec<CodeActionOrCommand>;
pub fn execute(ws, arguments) -> Result<(WorkspaceEdit, Vec<String>), String>;

crates/vlog_refactor/src/inline/ is four files, one question each:

file one sentence
mod.rs the entry points, the workspace-wide refusals, the edit, the verification
site.rs what the cursor is on, and the connection shapes that refuse
source.rs what S is made of, and the constructs that refuse
render.rs the substitution, the prefixing rule, and the text

The edit is one replacement in one file — the instantiation's own bytes — and RefactorEdit::created is empty: nothing is created and nothing is deleted, because S stays where it is for everything else that instantiates it.

The substitution, exactly as implemented

The body of S is copied verbatim but for two things: the name spans the substitution rewrites, and the leading whitespace of each line. Everything else — every comment, every attribute, every string, every `define use — arrives byte for byte, which is both what invariant 3 wants and what lets the verifier account for each piece as a copy rather than as an invention.

What a name becomes. S's own module scope is read out of Semantics (instantiable_scope), and every symbol bound in it is classified once:

the name is it is written as
a port the name (or the literal) the instantiation connects to it
anything else S declares at module scope — a net, a variable, a parameter, a localparam, a typedef, an enumeration member, an instance itself, with u_S_ in front iff M's file already spells any of them
a name in a nested scope (a begin's own variable, a routine's argument) itself, untouched — it collides with nothing at module level
anything else (a package, a type from an import, a system task, the module S instantiates) itself, untouched

Every declaration of a renamed name inside the copied bytes and every reference that resolved to one is rewritten, from the symbol table — never by text search.

The one name written once and read twice. .clk_i in S's own body names a port of the module S instantiates and the signal of S connected to it, with a single token. Rewriting it would connect a different port; leaving it alone would bind a name M may not even declare. So the shorthand is expanded — .clk_i becomes .clk_i(clk) — wherever the signal it stands for is one the inline renames, and left exactly as written where it is not. A .* inside S's body names every signal at once and cannot be expanded one name at a time, so it refuses. (This is the trial's counter inside cb_filter; see the work log.)

Parameters. Each entry of S's parameter port list becomes a localparam written above the body, in declaration order, carrying the override the instantiation wrote or the default the header did — with the type as S spells it (a continuation entry inherits the keyword and the type of the one before it) and with names substituted into the type and the default the same way the body's are. A header localparam is emitted too, and an instantiation that tries to override one refuses.

Prefixing is all-or-nothing. If any name S declares at module scope is one M's file already spells, every one of them is prefixed with the instance's name and a _; otherwise none is. The all-or-nothing rule is what keeps the result readable — a body where three names out of twenty are dressed differently is one nobody can check by eye — and the warning says which name collided.

Indentation. Each copied line is moved from S's body indentation to the instantiation's, except a line that begins inside a block comment or a string literal: those bytes are the piece's own text, and the verifier counts a comment by what it says. The result is formatted-shaped rather than formatted; the trials pin that it formats and converges.

The dataflow rule, exactly as implemented

A name is written by a region when, and only when, it is:

  • the left-hand side of a continuous assignment (assign x = …);
  • the left-hand side of a blocking or non-blocking assignment, a for initialiser or step, or the target of a ++/--, anywhere inside an always / initial / final block or a routine body;
  • the target of a force, a release or a deassign;
  • the target of a -> ev;
  • the declarator's own initialiser (wire w = a & b;);
  • connected to an output or inout port of an instantiation — a fact only the instantiated module's declaration holds, so it is looked up through the workspace index (module_definition + instantiation_plan).

Everything else is a read. Two positions are neither, and both refuse rather than guess:

  • an argument of a task or function call — only the routine's prototype says whether it is in or out;
  • a positional or .* connection, and a .p with no expression, which name no port and no signal respectively.

The left-hand side of an assignment writes the base of whatever it selects: a.b[3] = x writes a, which is what resolves. A concatenation or stream on the left writes each element.

The boundary table is then, per declaration of M, four bits per side (read, write, unknown, and the same outside). From it:

the selection… outside… the port
reads only anything input
writes does not write it output
writes also writes it refused
writes passes it to a routine refused
passes it to a routine anything refused

A parameter or localparam of M the selection reads becomes a parameter of N with M's own default, overridden .P(P) at the instantiation — and so does every parameter that parameter's type or default names, transitively, and every parameter a crossing port's own type names (input logic [N-1:0] a carries N across). A name in one of those positions that is declared in M and is not a parameter is a refusal.

import items of M — body imports and header imports alike — are copied into N's header when one of the names N has to resolve could have come through them. "Could have come through" is the binder's own answer: a use of a name a package supplies carries the import paths it walked in Resolution::ExternalCandidate::paths, in the spelling the source wrote (p::*, p::w_t), and an import is copied exactly when one of the needed names names that import. For a package declared in the same file the binder resolves the name on the spot, so the same question is asked of the declaration's position instead: a symbol inside a package item's span is one that package supplies.

Refusals — the whole list, each with its sentence

Shape of the selection (region.rs):

when the sentence says
the selection is not inside one module's body "not inside one module's body"
it is inside an interface "whose signals are its surface … so there is no boundary for lucisv to infer ports across; lucisv extracts out of a module"
it is inside a program "whose items are testbench code whose meaning depends on when it runs"
it cuts an item in half "cuts an item in half; lucisv extracts whole module items"
it covers no item at all "covers no module item"
it holds a port declaration "…a port declaration, which belongs to the module that wrote it"
a parameter/localparam declaration "…a parameter declaration" / "…a localparam declaration"
a genvar "…a genvar declaration"
a bind "…a bind directive"
an initial block "testbench code whose meaning depends on when it runs"
a final block the same
a macro invocation "lucisv does not expand macros, so it cannot tell what would move with it"
a compiler directive "lucisv does not evaluate one"
a verbatim block (an assertion, a property/sequence/constraint/covergroup body it could not read) "it cannot tell which names cross the boundary"
an unparsed leaf "part of the selection did not parse"
a module/package/class declaration "…a declaration of its own"

Dataflow and names (flow.rs, boundary.rs):

when the sentence says
a name is declared inside and used outside "move the declaration of x out of the selection first"
a name is driven on both sides "x is driven on both sides of the selection."
the selection passes a crossing signal to a routine "only that routine's declaration says whether it is an argument in or out"
the selection drives it and something outside passes it to a routine "lucisv will not make it an output over that"
a crossing name is a genvar / function / task / type / enum member / instance / modport / clocking block / class / named block "lucisv makes ports out of signals and parameters and nothing else"
a crossing name has an unpacked dimension "lucisv does not turn one into a port this round"
a crossing declaration has a qualifier (var, const, automatic) "lucisv does not move a qualifier into a port list"
a crossing declaration has a net delay "…does not move a delay into a port list"
a crossing type is an anonymous aggregate, a parameterized reference or a virtual interface (an interface-typed name among them) "a type lucisv does not move into a port list"
a type parameter crosses "lucisv does not carry one into a new module this round"
a parameter's default is written across several lines "lucisv does not re-flow one into a new module's header"
a header (a port's or a parameter's type, a default) names something that is not a parameter "which is neither a parameter nor a name a module in another file could reach"
a hierarchical reference crosses (u_x.sig, either direction) "a hierarchical path does not survive being moved into another module"
a name is declared outside M at file scope (a compilation-unit typedef, localparam, class) — new file only "a module in a file of its own would not see it"
a package name is used unqualified with no import to carry "write the package out, or import it where the new module can see it"

Instantiations inside the selection (flow.rs):

when the sentence says
positional connections "convert it to named connections first"
.* "expand the .* first (lucisv offers that as its own refactoring)"
.p with no expression "which names no expression for lucisv to move"
a connection lucisv could not read "cannot tell what the selection drives"
the module has no single indexed declaration "no single indexed declaration of it"
a .port the module does not declare "cannot tell whether it is driven"
a port with no direction "cannot tell whether the selection drives it"

The workspace and the new file (mod.rs):

when the sentence says
the new name is not a plain identifier (empty, leading digit, a space, an escaped \name) "not a plain SystemVerilog identifier, and lucisv will not name a module — or a file — with anything else"
the workspace already declares the new name "pick a name nothing else uses"
the new name is M's "already the name of the module you are in"
M is declared twice in the workspace "declared in more than one indexed file"
lucisv indexes no M "indexes no module named M"
the file does not parse "does not parse (… at line N)"
there is already a file at N.sv "there is already a N.sv beside this file"
a `timescale, `default_nettype or `resetall is in force before M — new file only "a new file would not inherit it; extract into the same file, or move the directive into an include both files use"

§53.2 — inlining

The instantiation (inline/site.rs). Nothing here reads S, so the cheap gate behind the lightbulb asks exactly these questions too:

when the sentence says
the cursor is on no instantiation written directly in a module's body nothing is offered; the command says "there is no module instantiation at this position to inline"
the instantiation is inside an interface/program "lucisv inlines into a module"
it declares more than one instance "each of them is a copy of the module's body; lucisv inlines one instance at a time"
the instance is an array (sub u [1:0] (…)) "is an array of instances, which stands for as many copies … as its range has"
positional connections "convert to named connections first"
positional parameter overrides the same, for parameters
.* "expand .* first (lucisv: expand .*)"
a connection that is not a plain name or a literal "connect .a(x+1) to a named wire first"
the list carries compiler directives "lucisv does not evaluate one"
.P() overriding a parameter with nothing "give it a value first"

S itself (inline/source.rs):

when the sentence says
S is an interface or a program "whose signals are its surface rather than a body lucisv can copy"
S declares its ports non-ANSI "convert them to ANSI ports first (lucisv: convert to ANSI ports)"
a port is an inout "whose two directions lucisv cannot reproduce by substituting a name"
a port has an unpacked dimension "a port array is not one name lucisv can substitute"
a port is of interface type (or a modport of one) "whose signals are named through the port rather than substituted for it"
the port list carries compiler directives "which ports it really declares depends on the configuration"
S holds an initial or a final block "does not mean the same thing written inside another module"
a macro invocation as an item "lucisv does not expand macros, so it cannot tell what it would be copying"
a compiler directive among its items "it cannot tell what its body really is"
a generate construct "whose block names are reachable through the hierarchy (u_S.gen.x) and would become names of M's own"
a bind, a nested module/package declaration, an unparsed leaf the matching sentence
a .* in S's own body "inlining renames the signals those ports bind to; expand .* in S first"

The connection, against S's ports (inline/render.rs):

when the sentence says
a port is unconnected (.a()), or not in the list at all ".a is left unconnected, and S's body uses a as a name of its own; connect it to a wire first"
an output is connected to a literal "drives S's output into a literal, which nothing can be assigned to"

Names and the workspace (inline/mod.rs, inline/render.rs):

when the sentence says
lucisv indexes no S "indexes no module named S" (the same sentence instantiation_plan uses)
S is declared twice "declared in more than one indexed file"
S is declared in M's own file "lucisv inlines a module written in a file of its own this round"
either file does not parse "does not parse (… at line N)"
u_S is named through the design hierarchy anywhere in the files lucisv was handed "is named through the design hierarchy in tb.sv (u_S.…), and inlining it dissolves the scope that path walks through"
S's `timescale differs from M's file's "a timescale changes what every delay in the body means"
the instantiation carries an attribute "says something about that instance and has nothing left to say once there is no instance"
a colliding name is an escaped identifier "an escaped identifier that lucisv cannot prefix its way out of"
a colliding name is one whose declaration carries an end … : name label (a function, a task, a named block, a class, a clocking block, a covergroup, a property, a sequence) — only when prefixing is needed "lucisv does not rewrite the end … : name label that goes with it"
the prefixed name collides too "and so does u_S_x, which is what lucisv would have renamed it to"
S writes a comment inside a parameter's declaration "lucisv would have to copy the comment into M to write the localparam"
a parameter has no default and no override "lucisv has no value to write for it"
the instantiation overrides a header localparam "which S declares as a localparam"

Where the new module goes, and the client capability behind it

A file N.sv beside M's is a CreateFile resource operation, and LSP only lets one be sent inside documentChanges. So the server reads, at initialize, both halves of the capability — workspace.workspaceEdit.documentChanges == true and workspace.workspaceEdit.resourceOperations containing create — the way §37 reads codeAction.resolveSupport (main.rs::create_files_support, ClientAbilities::create_files). Then:

  • can create files (VS Code does): Home::NewFile. The edit is documentChanges: [CreateFile(N.sv), TextDocumentEdit(M.sv), TextDocumentEdit(N.sv)].
  • cannot (or a caller that asked for it): Home::SameFile. N is written below M in M's own file, as one ordinary changes map — no capability of any kind. The `timescale refusal does not apply, because the same file inherits it.

Either way the engine says which happened, in the first of its warnings, so the user is never left guessing where their module went.

The name, and how the user is asked for it

LSP has no prompt. A code action may carry an edit, a command, or both, and only a command can be intercepted by a client that wants to ask the user something first — so the action carries lucisv.extractModule [uri, range, "M_extracted"] and no edit. That is also what makes it the laziest action in the server: the offer is one parse of one buffer (extract_site), and no workspace is read until the user has both picked the action and named the module.

The VS Code extension steps in through the language client's middleware.executeCommand (editors/vscode/extract.js), not through a command of its own: vscode-languageclient registers every command the server advertises in executeCommandProvider with vscode.commands.registerCommand, so a second registration of the same id would collide at activation. The middleware shows an input box prefilled with the default, validates against the same identifier rule the engine enforces, and hands the typed name to next. A cancelled box sends nothing at all. Every other client runs the command as sent and gets the default name — or passes its own, which is the documented API.

The verifier, and the one widening (CLAUDE.md invariant 4)

Everything is one check::verify_move over the whole edit — the splice contract unchanged: the pieces comparison, the parse check, and resolution identity outside the edited ranges, in every watched file.

The widening. never_dropped's three equations used to be kept per file, which is exactly right for every refactoring that stays inside one file and exactly wrong for a move: a comment the selection carries is deleted in M.sv and written in N.sv, so neither file balances on its own. So the counting was factored into a Ledger, and verify_move takes a moving: &[Moving] list.

The widening is bound to the bytes that move, not to the files (the 2026-09-06 rework; QA's finding V1). moving names every file the move touches: a source, with the byte range the move takes its text out of — the selection — and a destination, a file that only receives, with an empty range. A ledger is one file's, always. Per file f and per never-dropped text t, with before/after the file's own counts, gone the old pieces a non-empty edit range covers, wrote the pieces the edits' own text spells, and out the pieces of gone inside f's region:

  1. after_f + out_f >= before_f — nothing is lost; a file may end short only by exactly what left through its own region.
  2. wrote_f <= (gone_f - out_f) + in_f, unless the text is one a refactoring generated — nothing is duplicated. in_f is the whole transit (Σ out) for a destination and zero everywhere else, so a deletion outside the region is an ordinary deletion that has to be written back in its own file.
  3. after_f == before_f - gone_f + wrote_f — the applied text says exactly what the edits say, transit out counted as gone and transit in as wrote.
  4. Σ over destinations of (wrote - gone) == Σ over sources of out — the transit lands, exactly once, in the files the move named.

A file moving does not name keeps the per-file contract untouched, so a piece in transit to a file the move never named is refused twice over (by that file's rule 2 and by rule 4). verify_splice is verify_move(…, &[]) and is byte-for-byte the old behaviour. The positional piece comparison is untouched and still runs per file.

The masked-corruption attacks — crafted (plan, corrupted plan) pairs the widening could plausibly forgive. All of them go through the production entry point: a real Scope over the two files, the raw TextEdits, and check::verify_move itself, positions_match and all (QA's V1: the six they replace went through a ledger-only test helper, which is why the first row below was invisible). In check/ledger.rs's and check/mod.rs's test modules:

# the pair verdict
1 the honest extraction the engine produces — comment and (* keep *) in transit accepted
2 M holds the same comment twice; the plan deletes the copy outside the region as well and writes the moved one into N twice, so the pair balances 2-in/2-out rejected — "comments are never dropped", naming m.sv
3 the comment in transit written twice into N rejected — "never duplicated"
4 deleted in the region and also written back into M above the instantiation rejected — "never duplicated"
5 deleted in the region and written nowhere rejected — "would move … and write it back nowhere; comments are never dropped"
6 the same for an attribute (* keep *) rejected — "attributes are never dropped"
7 N writes a comment nothing put in transit rejected — "never duplicated"
8 N writes /* TODO: connect */, the generated whitelist accepted — the whitelist is unchanged
9 the module text written into a third file the move did not name rejected — that file keeps the per-file contract
10 the deletion widened past the region swallows // the rest rejected — naming that comment
11 the moving range does not cover what the edits delete (the planner lied about its region) rejected — "comments are never dropped"
12 the honest extraction with an empty moving rejected — the widening is opt-in

The second widening: a file the edit only copies out of (§53.2)

An inline is the mirror move, and the mirror breaks the accounting in one place: S's comments arrive in M with nothing deleted anywhere, because S's file is not edited at all. Rule 2's wrote ≤ gone refuses that, and correctly — it is exactly the shape of an invented comment.

So moving's entries carry an Origin. Moving::source(f, region) and Moving::destination(f) are what they always were (Origin::Moved); Moving::copy(f, region) is new (Origin::Copied) and says the bytes in this region are copied out of a file the edit does not touch. A copy sends its region's pieces into the transit exactly as a source does — so a destination may write each of them once per copy — and is held to one rule of its own, checked before the equations:

  1. A copied file is not edited. It appears in no edit at all; anything else is a contradiction rather than a plan, and is refused naming the file.

Rules 1–3 are untouched. Rule 4 gains the copies on its sending side: what a region sends, whether by moving or by copying, has to land exactly once in the destinations the move named — so a copied comment written twice is a duplication and one written nowhere is a drop, each said in those words. The allowance stays bound to the bytes: a comment in S's header, outside the region the inline names, has no origin at all and M may not write it, which is why the engine refuses a parameter declaration with a comment inside it rather than lifting the type text out of one.

inline_module names exactly two files: Moving::destination(M) and Moving::copy(S, S's body). Everything else — the pieces comparison, the parse check, resolution identity outside the edited range — is the splice contract unchanged. The resolution check is what catches an inlined declaration that captures a name M was reading from somewhere else, and it refuses with the ordinary "would change what x means" sentence.

The masked-corruption attacks on the copy allowance (check/mod.rs, all through the production verify_move with a real Scope and the edits inline_module really produces, over a sub whose body carries both a comment and a (* keep *)):

# the pair verdict
1 the honest inline the engine produces — the comment and the attribute copied, sub.sv unchanged accepted
2 the copied comment written twice into M rejected — "never duplicated"
3 the copied comment written nowhere rejected — "would carry … and write it back nowhere; comments are never dropped"
4 the same for the attribute rejected — "attributes are never dropped"
5 M writes a comment the copied region does not hold rejected — "never duplicated", naming the comment
6 M writes /* TODO: connect */ — the generated whitelist accepted — unchanged by the widening
7 the plan also edits sub.sv (deleting the very comment being copied, so the halves would balance as a move) rejected — "which it only copies out of", naming sub.sv
8 the honest inline with an empty moving rejected — the allowance is opt-in

confirm is the second net, as in ports: the edited text is read back and the new module's header must declare exactly the ports and parameters the plan promised — verify_move proves the edit is honest, nothing in it proves the header lucisv wrote is the header it meant to write.

Assumptions

  • The selection covers whole module items. An item's own comments and attributes travel with it exactly when the selection covers them too, so a selection starting on the item's line leaves the note above it behind and one starting a line earlier takes it along. An empty selection — a bare cursor — is read as the item it is on, because that is what an editor sends when nothing is selected.
  • The region's text moves verbatim. Items are module items in M and module items in N, at the same nesting depth, so the source's own indentation is already right and every comment, attribute and string travels byte for byte — which is what lets the splice verifier count them. The header lucisv writes around them is two-space-indented; the formatter reconciles the two on the next save, and the tests pin that the result formats and converges.
  • A hierarchical reference inside the selection is judged by §49's surface. Resolution::ExternalCandidate { surface: Hierarchical } is recorded exactly when the head resolved to an instance; the head is found as the nearest earlier reference resolving to an Instance with only a dotted path between the two. A hierarchical path whose head instance the selection also moves is allowed; every other one refuses.
  • A module, an interface and a package are visible from every file, so one declared beside M never becomes a port and never refuses. A typedef, a localparam or a class at file scope is a compilation-unit declaration and does refuse — for a new file.
  • M is declared exactly once in the workspace lucisv was handed. The server hands the engine the fan-out of the units the selection names, so a second M the index knows about is one the engine sees.
  • The extraction does not rename anything and does not reorder anything. If the user wants the new module's ports in a different order, that is remove_port/add_port's job.

§53.2

  • S's body means the same thing inside M. That is the whole bet, and every refusal in source.rs is a construct for which it is false: a generate names scopes the hierarchy can reach, an initial block's meaning depends on when it runs, a macro's body is text lucisv never read, a `timescale changes what a delay means. What is left — declarations, continuous assignments, always blocks, instantiations, routines — is position-independent module-item code.
  • Substituting a name for a port is sound because a connection is a plain name or a literal. Both are primary expressions, so the substitution is safe in every position the port's name could appear in — a bit-select, a left-hand side, a connection to a further instantiation. Any other connection refuses: .a(x+1) written wherever a is read would duplicate the expression and, on a left-hand side, would not be assignable at all.
  • The hierarchical check sees the files it was handed. It is a lexical scan — an identifier spelling the instance's name with a . on either side of it — over every in-scope file, prefiltered by a whole-word search. The server hands the engine the fan-out of S and M (module_sources), the same narrowing every other refactoring in the crate gets; an XMR from a file the index does not connect to either name is outside what lucisv can see, as it is for a rename. The scan errs towards refusing: another module's own u_S.x refuses this one too.
  • M's file is the collision set. Every symbol name in M's file, not just M's own module scope — deliberately a superset, so a name the inline introduces cannot quietly capture a file-scope declaration. A name M references without declaring is not in the set; an inlined declaration that captures one of those is caught by the resolution half of the verifier instead, as a refusal.
  • S is declared in a file of its own. Inlining a module declared in M's own file is refused this round: the copy allowance is granted on the strength of the copied file coming out unchanged, and lucisv would rather refuse than widen rule 0 to "unchanged over the copied bytes". The corpus trial shows what it costs — 5 of 9 refusals in common_cells are this one.
  • The .name shorthand is expanded, never rewritten. The port half of the token belongs to the module being instantiated and never moves; only the signal half is written out. .* in S's body refuses because it has no port half to keep.
  • An unconnected output refuses, not only an unconnected input (TODO §53.2 names the input). Making one work means declaring a signal for it in M, which is a declaration with a type read out of S's header and a name of lucisv's own invention; that is a round of its own.

Handshakes

  • vlog_refactor::RefactorEdit (widened, additive). New field created: Vec<PathBuf> — the files the refactoring creates, each of which also appears in edits with one insertion at offset 0. Every existing producer sets it to Vec::new(); every existing consumer that ignores it gets exactly what it got before.
  • vlog_refactor::check (internal). verify_splice now delegates to verify_move(scope, edits, watched_names, what, moving), where moving is &[Moving] — a file with its moved region (Moving::source), a file that only receives (Moving::destination), or, since §53.2, a file the edit only copies out of (Moving::copy, Origin::Copied), which must appear in no edit; never_dropped is now Ledger::of + Ledger::check with Transit holding the two halves of a move to each other, and pieces_match takes a pre-lexed Split. watched_files takes a &[&str] of names rather than two. check.rs is now check/mod.rs plus check/ledger.rs (a pure move; the paths are unchanged). All crate-internal; no call site outside vlog_refactor sees any of it.
  • lucisv_server::server::ClientAbilities (new field). create_files: bool, read at initialize by create_files_support.
  • lucisv_server — one new module (extract.rs), one new code-action kind (refactor.extract) in capabilities, one new command in commands(), and two new branches in server/dispatch.rs (the codeAction fan-out, and the executeCommand split — the extract command is routed before ports::execute because it needs the client's own capability). ports::workspace_edit is reused unchanged for the same-file case.
  • editors/vscode — one new module (extract.js) and its test (extract_test.js), plus clientOptions.middleware.executeCommand in extension.js. No package.json change: the command is registered by the language client from the server's own executeCommandProvider, and contributing it again would put it in the command palette without its arguments.
  • Request to vlog_semantic: none. Everything the engine needed was already public (Semantics, Resolution, Surface, WorkspaceIndex, Semantics::instantiable_scope).
  • §53.2 — lucisv_server — one new module (inline_module.rs; the name inline.rs is taken by textDocument/inlineCompletion), one new code-action kind (refactor.inline) in capabilities, one new command in commands(), and two new branches in server/dispatch.rs (the codeAction fan-out and the executeCommand split, routed before ports::execute as the extract command is). ports::workspace_edit is reused unchanged — an inline creates nothing, so the ordinary changes map is enough, and no client capability is involved.
  • §53.2 — editors/vscode: no change. The action carries no prompt: the command takes [uri, position] and the language client registers it from the server's own executeCommandProvider.
  • §53.2 — vlog_refactor::instantiate::ends_escaped is now read by inline::render as well as by instantiate's own renderer. Already pub(crate); no signature change.

Status / TODO

  • 53.1 extract: dataflow ports, parameters, imports, the new file, refusals, action + command + extension input box
  • 53.2 inline: substitution, prefixing, refusals, action + command
  • the extract → inline round trip pinned (tests/inline.rs, extracting_a_region_and_inlining_it_back_returns_the_original)
  • docs; §8 lines annotated; site rows (lead — see below)
  • Gates (guarded); byte-identity vs 0.48.0; corpus + opentitan scratch trials
  • QA (§53.1)
  • QA (§53.2)

Gate numbers for §53.2 (2026-09-06, all guarded)

Gate Result
cargo fmt --all clean
cargo clippy --all-targets clean; one new #[allow(clippy::mutable_key_type)], the same one and for the same reason as extract.rs's (a WorkspaceEdit's Uri key)
cargo test --workspace 4 133 passed, 0 failed, 44 ignored (baseline 4 081; +52 — 37 in tests/inline.rs, 8 verifier attacks, 6 in lucisv_server/src/inline_module.rs, 1 corpus trial)
tools/corpus_check.sh 814/820 (99.3%), the same six parse errors, 0 verification errors, 0 crashes
format --stdout vs ~/.cache/lucisv-baselines/lucisv-0.48.0 over the 860 corpus files 854 identical, 0 differing, 6 refused by both
cargo build --release -p lucisv -p lucisv_server ok
node editors/vscode/smoke.js target/release/lucisv-server OK — initialize/didOpen/shutdown/exit, 20 messages

The corpus inline trial (corpus/, 860 files, unmodified)

cargo test -p vlog_refactor --test corpus five_instantiations… -- --nocapture. The trial prints every accepted inline with its census and every refusal with its sentence, so the table below is what it says. 5 inlined, 9 refused.

module → into outcome
addr_decode_dync → addr_decode, addr_decode_napot refused — a compiler directive among its items
heaviside → boxcar (twice) inlined, 0 names newly unbound
hash_block → cb_filter (three times) refused — declared in the same file
counter → cb_filter inlined, 0 names newly unbound
cdc_2phase_src, cdc_2phase_dst → cdc_2phase refused — declared in the same file
cdc_2phase_src_clearable, cdc_2phase_dst_clearable → cdc_2phase_clearable refused — .valid_i(src_valid_i & !s_src_isolate_req) is an expression
cdc_reset_ctrlr → cdc_2phase_clearable inlined, 0 names newly unbound
sync → cdc_2phase_src_clearable inlined, 0 names newly unbound

Every result parses, formats and converges, and lucisv check --select unused-signal,undriven-net over each pair of files (LUCISV_INLINE_OUT=… writes case_N/{before,after}/) reports 0 violations before and 0 after, for all five. The counter case is the one that reported 1 after before the shorthand rule was added — see the work log.

The opentitan inline trial (506 files, scratch copies)

Scratch copies of hw/ip/{aes,hmac,uart,spi_host,prim} (506 .sv/.svh files), LUCISV_INLINE_ROOT pointed at the copy. 5 inlined, 56 refused.

module → into outcome
aes_tb_reqs → aes_tb inlined; 1 name newly unbound (requests, which only an `include declares and which aes_tb_reqs.sv itself already leaves unbound)
aes_reg_status → aes_control_fsm inlined, 0
prim_sec_anchor_buf → aes_core (three times) inlined, 4 names each, all of them ones prim_sec_anchor_buf.sv already leaves unbound

The 56 refusals are the refusal list doing its job: .* (the AES fault-injection wrappers), interfaces, positional connections, expression connections (.edn_o(edn_if[0].req), .prd_i(prd[Width-1:0])), generate inside S (aes_cipher_core), and modules the scratch subset does not declare. All five results parse, format and converge, and lucisv check --select unused-signal,undriven-net reports 0 before and 0 after for every pair.

git -C …/opentitan status --porcelain shows the same three pre-existing files before and after; nothing but rsynced scratch copies was read.

Gate numbers after the rework (2026-09-06, all guarded)

Gate Result
cargo fmt -p vlog_refactor clean
cargo clippy --all-targets clean, no new #[allow]
cargo test --workspace 4 081 passed, 0 failed, 44 ignored (4 073 + 5 verifier attacks + 3 extract tests)
tools/corpus_check.sh 814/820 (99.3%), the same six parse errors, 0 verification errors
corpus extraction trial (860 files) 5 extracted, 6 refused, unchanged; the census holds at 10 268 for every one
opentitan extraction trial (237 files, scratch copies of hw/ip/{aes,uart,spi_host,hmac}) 5 extracted, 5 refused; census 10 614 → 10 614 for every extraction

The opentitan trial is now reproducible as run: copy hw/ip/{aes,uart,spi_host,hmac} (237 .sv/.svh/.v files, opentitan at 0098135264) to a scratch tree and point LUCISV_EXTRACT_ROOT at the copy. The trial prints each accepted extraction with its census and each refusal with its sentence, so the list below is what it says.

file module outcome
aes/dv/sva/aes_idle_check.sv aes_idle_check extracted, census 10 614 → 10 614
aes/dv/sva/aes_masking_reseed_if.sv aes_masking_reseed_if refused — inside an interface (QA's V2; this one used to extract and cost four names)
aes/dv/sva/aes_reseed_if.sv aes_reseed_if refused — inside an interface
aes/dv/tb/tb.sv tb refused — tb declared in more than one indexed file
aes/pre_dv/aes_cipher_core_tb/rtl/aes_cipher_core_tb.sv aes_cipher_core_tb extracted, census unchanged
aes/pre_dv/aes_sbox_lec/aes_sbox_masked_wrapper.sv aes_sbox_masked_wrapper refused — prd_masking passed to a routine outside
aes/pre_dv/aes_sbox_tb/rtl/aes_sbox_tb.sv aes_sbox_tb extracted, census unchanged
aes/pre_dv/aes_tb/rtl/aes_tb.sv aes_tb refused — entropy_q passed to a routine outside
aes/pre_dv/aes_tb/rtl/aes_tb_c_dpi.sv aes_tb_c_dpi extracted, census unchanged
aes/pre_dv/aes_tb/rtl/aes_tb_reqs.sv aes_tb_reqs extracted, census unchanged

(The trial stops at five extractions, which is why the scan ends inside aes/.) git -C …/opentitan status --porcelain shows the same three pre-existing files before and after; nothing but scratch copies was read.

Gate numbers (2026-09-05, all guarded)

Gate Result
cargo fmt -p vlog_refactor -p lucisv_server clean
cargo clippy --all-targets clean, no new #[allow]
cargo test --workspace 4 073 passed, 0 failed, 44 ignored (baseline 4 020)
tools/corpus_check.sh 814/820 (99.3%), the same six
format --stdout vs ~/.cache/lucisv-baselines/lucisv-0.46.0 over 860 corpus files 854 identical, 0 differing, 6 refused by both
cargo build --release -p lucisv -p lucisv_server ok
node editors/vscode/smoke.js target/release/lucisv-server OK
node editors/vscode/extract_test.js OK, 31 checks
corpus extraction trial (860 files) 5 extracted, 6 refused, every result parses, formats, converges; the design's unresolved-name census unchanged
opentitan extraction trial (244 files, scratch copies) 5 extracted, 11 refused, same checks

Not this lane's: docs/coverage_gaps.md is modified in the working tree (the L9 row, about §37's lazy resolve). It was already modified when this lane started and nothing here touched it — flagged rather than reverted, per the file-ownership rule.

Measurements

Production lines (non-blank, non-comment), all under the 600 target:

file lines
vlog_refactor/src/extract/mod.rs 381
vlog_refactor/src/extract/flow.rs 534
vlog_refactor/src/extract/boundary.rs 352
vlog_refactor/src/extract/render.rs 303
vlog_refactor/src/extract/region.rs 155
lucisv_server/src/extract.rs 286 (incl. tests)

check.rs reached 702 production lines with the rework's equations on board, over the 600 target, so it was split (2026-09-06, a pure move — public paths, behaviour and output all unchanged):

file production lines one sentence
vlog_refactor/src/check/mod.rs 392 verify the whole edit — token identity, the parse check, resolution identity — or refuse it whole
vlog_refactor/src/check/ledger.rs 334 the pieces a file is made of, the comparison that says an edit wrote what it promised, and the ledger of the ones that are never dropped

§53.2's own (2026-09-06, production lines outside #[cfg(test)]):

file lines
vlog_refactor/src/inline/render.rs 332
vlog_refactor/src/inline/mod.rs 252
vlog_refactor/src/inline/source.rs 244
vlog_refactor/src/inline/site.rs 164
lucisv_server/src/inline_module.rs 67 (+126 test)

check/mod.rs is 426 production lines (from 392) and check/ledger.rs 366 (from 334) with the copy allowance on board — both still under the 600 target; the growth is 8 new attack tests, which do not count, plus Moving/Origin and Transit::copy.

Work log

2026-09-06 — dev (§53.2, inline module). Read §53.1's engine and this README, check/{mod,ledger}.rs, instantiate.rs's reading of a declaration, §49's surface and the server's lazy-action plumbing. Then, in order:

  1. The verifier first, as §53.1 did, so the engine could be built on a verifier that admits a copy. moving became &[Moving] with an Origin — Moved (a source, or the empty-range destination: byte-for-byte the old behaviour) and Copied, a file the edit does not touch whose region's pieces join the transit. Rule 0 ("a copied file is not edited") is checked before the equations and refuses naming the file; Transit gained a copied list that feeds sent and the lands sentence. Eight masked-corruption attacks written at the same time (invariant 4), all through the production verify_move with the edits inline_module really produces — including the one that would balance as a move (attack 7) and the opt-in pin (attack 8). The extraction's twelve are untouched and still pass; the only wording change is "would move the comment" → "would carry the comment", which now covers both origins.
  2. inline/site.rs — what the cursor is on. The cheap gate and the engine share it, so the lightbulb and the command refuse for the same reasons.
  3. inline/source.rs — what S is made of, and the constructs that do not mean the same thing inside M.
  4. inline/render.rs — the substitution, driven by S's module scope out of Semantics::instantiable_scope: ports to connected names, everything else S declares to itself-or-prefixed, rewritten from the symbol table.
  5. inline/mod.rs — the workspace-wide refusals, the single edit, the verification, the warnings.
  6. The server (inline_module.rs) and its wiring; no extension change.

Two decisions worth the ink. Prefixing is all-or-nothing — a body where three names out of twenty are dressed differently is one nobody can check by eye — and the end … : name label problem is dodged rather than solved: when prefixing is needed and S declares a function, a task or a named block, lucisv refuses, because it does not rewrite that label and a mismatched one is a legal file that means something else. When prefixing is not needed nothing is rewritten at all, so those modules inline fine.

The bug the trial caught, and the rule it produced. The first common_cells run inlined counter into cb_filter and left cnt_overflow read but never driven — lucisv check --select undriven-net went 0 → 1 while every other check passed, the verifier included. counter's own body instantiates delta_counter with the .q_o shorthand, which names a port of delta_counter and the signal q_o of counter with one token: substituting over it would connect a different port, and leaving it alone binds a name cb_filter does not declare. The fix is to expand the shorthand — .q_o(filter_usage_o) — wherever the signal half is one the inline renames, and to refuse a .* in S's body, which has no port half to keep. Pinned by a_dot_name_shorthand_in_the_body_is_spelled_out_when_the_name_it_stands_for_changes and a_wildcard_inside_the_inlined_body_is_refused. It is the reason the lucisv check half of the trial is worth running: nothing else in the suite saw it.

The trial's census had to change too. An inline copies, so unresolved_over's whole-design count legitimately grows by one per name S already could not resolve (opentitan's aes_tb_reqs reads a requests that only an include declares). The inline trial holds the exact property instead: every other file's census is unchanged, and every name the edited file newly fails to bind is one some other file already fails to bind — census and borne in tests/corpus.rs. The extraction's own trial is untouched.

2026-09-05 — dev (§53.1). Read §52's engine and README, ports/'s splice/confirm spine, instantiate.rs, check.rs, vlog_semantic's model and §49's surface, and the server's lazy-action and command plumbing. Then, in order:

  1. check.rs: the widening first, so the rest could be built on a verifier that admits a cross-file move. never_dropped became Ledger::{add,check}, pieces_match became Split::read + Split::positions_match + a per-file pieces_match over the pair, and verify_splice became a verify_move with an empty moving list. Six masked-corruption attacks written at the same time (invariant 4), including one that pins the widening as opt-in.
  2. extract/region.rs — the selection, the whole-item rule and the item-kind refusals. Decision: an item's extent includes its own comments only when the selection covers them, which is what makes a selection do what the user's mouse said. Second decision: an empty selection is the item under the cursor, so the action is available without dragging.
  3. extract/flow.rs — the dataflow. The classification is a second implementation of a question vlog_linter::signals also answers, and that was deliberate: vlog_refactor may not depend on vlog_linter (it would pull in lucisv_core), the linter's table is pub(crate), and the two questions differ where it matters — the linter's rule is say nothing when unsure, this one's is refuse when unsure. Recorded here rather than hidden: if a third caller ever wants it, the shared home is vlog_semantic.
  4. extract/render.rs, extract/mod.rs — the header, the new module, the instantiation through instantiation_plan. The new file joins the in-scope set as an empty file before anything else happens, so the index, the analysis and the verification all ask about it exactly the way they ask about a file that was always there.
  5. lucisv_server/src/extract.rs, the capability, the dispatch, and editors/vscode/extract.js.

Two defects the trials found, both fixed and both pinned by a test.

  • The corpus. common_cells/src/binary_to_gray.sv extracted into a module whose ports read input logic [N-1:0] a with no N anywhere: the parameter is named by the port's own type, and no statement in the selection names it, so a closure over the region's references alone never wanted it. Fixed by seeding the parameter closure with the words of every port's rendered prefix (and of every parameter's, transitively) — boundary::depends. Pinned by a_parameter_a_ports_own_width_names_crosses_with_it.
  • opentitan. hw/ip/aes/rtl/aes_ctr.sv writes module aes_ctr import aes_pkg::*; and the extraction copied no import at all, leaving sp2v_e and Sp2VWidth naming nothing. The binder records a wildcard import in a reference's paths as p::* — the spelling the source wrote — and the judgement was matching p::<name>. Fixed by comparing against Import::path(), which is that same spelling, with Import::supplies as the gate. Pinned by a_wildcard_import_in_the_header_is_carried_across and a_named_import_is_carried_across_only_when_the_name_it_supplies_is_needed.

Both were caught by the census — the number of names the design cannot resolve, before and after — which is why the trial asserts on it rather than on "it parsed". Neither would have failed a parse check.

One split, mid-round. extract/mod.rs reached 685 production lines, over the 600 target, so the boundary classification moved to extract/boundary.rs (pure move; the test count did not change). mod.rs is 376.

Deviations from the plan, all deliberate and all named:

  • 53.2 is unstarted. §53.1 alone consumed the round, as the brief anticipated; a finished half beats two unfinished ones. The round-trip pin is blocked on it.
  • The refusal for a routine's argument is broader than the plan's letter. The plan says "a task/function call's output argument"; lucisv cannot tell an output argument from an input one without the prototype, so it refuses on any argument position that names a crossing signal. A crossing parameter in an argument ($clog2(WIDTH)) is untouched — a parameter has no direction. In practice the common case is already refused a step earlier, because a routine declared in M outside the selection and called inside it refuses on its own.
  • The hierarchical refusal is conservative in one shape. A hierarchical path whose head instance the selection also moves is allowed, and that is decided by a nearest-earlier-instance-reference-with-a-dotted-path heuristic. Where the heuristic cannot find a head at all, the extraction refuses (naming ….sig), which is the safe direction.
  • A file-scope typedef in M's own file refuses for a new file and is allowed for the same file. The plan does not name this refusal; it is forced by the language (a compilation-unit declaration does not reach a file that was not compiled with it), and the same-file fallback is exactly the escape hatch.
  • The action carries a command rather than a resolvable edit. The plan says "lazy"; a command with no edit is lazier, and it is the only shape a client can put an input box in front of.

2026-09-06 — dev, rework (QA's V1, V2 and the LOW).

V1 — the pool was bound to the wrong thing. verify_move pooled one never-dropped ledger over whole files, so a pair of individually-honest edits could balance in aggregate while one file lost content nothing ever moved: QA's m.sv deletes an untouched second copy of a comment, n.sv writes a duplicate of the moved one, 2 in and 2 out, accepted. Fixed by binding the allowance to the bytes that move. moving is now &[(usize, TextRange)] — a source with its region, a destination with an empty range — a Ledger is one file's again, and Transit holds the halves of a move to each other. The four equations are written out above and in verify_move's doc comment; the one that does the work is rule 2's wrote_f <= (gone_f − out_f) + in_f, which says that a deletion outside the region is an ordinary deletion, to be written back in its own file, exactly as it always was. QA's pair now refuses with "comments are never dropped", naming m.sv.

The twelve attack pairs in the table above all go through the production verify_move with a real Scope and raw TextEdits — the pooled() helper QA objected to is gone, and with it the last place a corruption could be judged without positions_match also having its say. Corruption is expressed as a corrupted plan rather than a corrupted applied text, which is one notch more real: the verifier applies the edits itself.

check.rs was 618 production lines before this and 702 after, so it was split into check/mod.rs (392) and check/ledger.rs (334) — a pure move: the same items, the same crate::check::… paths, the same tests, cargo test -p vlog_refactor unchanged but for the rework's own additions.

V2 — the kw gate. vlog_parser writes module, interface and program as one ItemKind::Module distinguished only by Module::kw, and region.rs::module_at never asked. Region::read now calls extractable, which accepts module/macromodule and refuses the other two with the sentences the refusal table promises. extract_site reads the same Region, so the code action is no longer offered inside an interface either. Pinned by a_selection_inside_an_interface_or_a_program_is_refused and the_action_is_not_offered_inside_an_interface_or_a_program, and by the opentitan trial above: aes_masking_reseed_if.sv and aes_reseed_if.sv are now refusals, and every accepted extraction leaves the census at 10 614.

The LOW — a member access names its head. boundary::visible refused with the field (data, f), which reads as if the field were a signal of M's own; what crosses the boundary is the port or the variable. A text-side access_head reads s out of s.f and b out of b.data, and the refusal is now "the selection uses b.data, and b is declared with a type written outside m in the same file…". Pinned by a_crossing_member_access_names_the_head_and_the_field_second.

No existing expectation was altered. The three tests whose text changed are the ones the rework replaces (the six pooled() attacks became the twelve verify_move ones); everything else — 40 in tests/extract.rs, the corpus trial's 5/6, the workspace's other 4 000 — is as it was. tests/corpus.rs gained two println!s (the census per extraction and each refusal's sentence), so a trial run is reproducible without patching it first.

Docs to apply at merge (lead)

docs/site/ — language-tools row. Add beside organize-imports:

Extract module — select the always blocks, assignments or instantiations that have grown into a module of their own, name it, and lucisv writes it: ports and parameters inferred from what the selection reads and drives, imports carried across, the items moved byte for byte, and the instantiation that replaces them rendered from the new module's own text. A file of its own where the editor can create one, below the module it came from where it cannot. Refuses — with a sentence — wherever a direction cannot be known: a routine's argument, a .*, a positional connection, a module the index cannot pin down, a name both sides drive.

README.md — the refactorings list gains one entry beside the port ones:

  • extract module (refactor.extract, lucisv.extractModule) — a selection of whole module items becomes a module of its own, with ports inferred from the dataflow across the boundary.

docs/topo.md — two edges to record:

  • vlog_refactor::RefactorEdit::created — a new public field, read by lucisv_server::extract only. lucisv_server ◀── vlog_refactor, widened.
  • lucisv_server::server::ClientAbilities::create_files — a new capability read at initialize, consumed by server/dispatch.rs only.

TODO.md §8 — the extract-module line is annotated in place (done by the §53.1 lane); §53's own checkboxes are ticked except the QA line.

§53.2 (2026-09-06)

docs/site/ — language-tools row. Add beside extract-module:

Inline module — put the cursor on an instantiation and lucisv writes the module's body where it stood: every port replaced by the signal connected to it, every parameter written out as a localparam holding its override, every internal name kept — or prefixed with the instance's, if the enclosing module already spells it — and the module's imports carried across. The module itself is left exactly where it is, and so is everything else that instantiates it. Refuses, with a sentence, wherever the substitution would not be honest: a .*, a positional connection, an expression where a name belongs, an unconnected port, a generate or an initial inside the module, a macro, a differing `timescale, or a hierarchical path into the instance from anywhere in the workspace.

README.md — the refactorings list gains a second entry beside extract:

  • inline module (refactor.inline, lucisv.inlineModule) — an instantiation becomes the module's own items, with ports substituted by the names connected to them and parameters written out as localparams.

TODO.md §8 — annotate the inline-module line in place, the way the extract line was.

docs/topo.md — one edge to amend:

  • vlog_refactor::check::verify_move's moving list is now &[Moving] with an Origin (Moved/Copied). Crate-internal — no edge leaves vlog_refactor — but the §2.9 note on the widening should say the allowance now covers a copied region as well as a moved one, and that a copied file is asserted unedited.
  • lucisv_server::inline_module ──▶ vlog_refactor::{inline_module, inline_site, inline_title}: a new consumer edge of the same shape as lucisv_server::extract's.

QA log

2026-09-06 — QA (§53.1 only). Read this README, the diffs (check.rs, vlog_refactor/src/extract/{mod,region,flow,boundary,render}.rs, tests/{extract,corpus}.rs, lucisv_server/src/extract.rs, server/{dispatch,mod}.rs, main.rs, editors/vscode/{extract,extension}.js), then attacked the verifier, attacked the dataflow rule with hand-picked shapes, read the server/extension wiring, and re-ran the trials and every gate. Two confirmed defects, both HIGH, below; verdict is REWORK.

Priority 1 — the verifier widening (check.rs)

All six of the dev's own attack tests were re-read and re-run (cargo test -p vlog_refactor --lib check::, 44/44 pass, including all six under the pooled ledger, and the attacks on it). They are sound, but they all go through the dev's own pooled() test helper, which calls Ledger::add/Ledger::check directly and never calls Split::positions_match — so they exercise the aggregate-count equations in isolation, not the full verify_move path a real refactoring goes through. I re-attacked through the production entry point instead: a Scope built from real files, raw TextEdits, and check::verify_move itself (temporary tests, removed after; reproductions below use the same shape so the dev can paste them back in).

# attack via result
1 comment deleted in M, written in N once verify_move ACCEPTED (correct)
2 comment deleted in M, written in N twice dev's pooled() REJECTED — "never duplicated"
3 deleted in M, written in N and left in M dev's pooled() REJECTED — "nothing was edited"
4 deleted in M, written nowhere dev's pooled() REJECTED — "never dropped"
5 written in N, never deleted in M (invented) flow.rs makes this unreachable via the real edits, but the equation (writes > deleted) rejects it directly in Ledger::check REJECTED
6 deleted in M, written into a third file not in moving verify_move, 3 files, moving=[m,n] REJECTED — the third file's own per-file pieces_match sees an invented write ("never duplicated"); confirmed by re-attack
7 same honest move, moving empty dev's test 6 REJECTED — "never dropped" (opt-in confirmed)
8 attribute (* keep *) in transit, balanced / lost dev's tests 1–2 ACCEPTED / REJECTED correctly
9 two identical comments, one moved and one left untouched, corrupted so the pool balances (2 in, 2 out) but m.sv alone loses the untouched copy while n.sv gains a duplicate of the moved one verify_move, real Scope + hand-edits ACCEPTED — FORGIVEN. HIGH.
10 moving naming a file the edits never touch verify_move inert — honest move still verifies, no false accept
11 moving naming the same file index twice verify_move same as naming it once
12 edit outside moving (file left out) deletes a comment verify_move REJECTED — old per-file contract, unwidened

Finding V1 (HIGH) — the pooled ledger can forgive a per-file loss when a second, textually-identical never-dropped piece is in play. Ledger::check (crates/vlog_refactor/src/check.rs:617) only ever compares counts of a (noun, text) key summed over every file named in moving (Ledger::add, check.rs:602). Split::positions_match (check.rs — the per-file token-position comparison) still runs for every pooled file, but it only checks that applying that file's own edits produces that file's own claimed text — it says nothing about whether a piece that disappeared from position N in file A was legitimately moved to file B or simply invented/lost independently. Two edits that are each "positionally honest" for their own file can therefore corrupt correctness as a pair: m.sv's edit deletes an extra copy of a comment nobody meant to move, n.sv's edit writes an extra copy of the one that did, and the pool's aggregate math (before=2, deleted=2, writes=2, after=2) is satisfied by construction, even though m.sv alone lost content it never gave up. Reproduction (paste into check.rs's test module, real verify_move, no pooled() helper):

const TWO_NOTES: &str = "module m (\n  input logic a,\n  input logic b,\n  output logic p,\n  output logic q\n);\n  assign p = a; // note\n  assign q = b; // note\nendmodule\n";
// m_edits: delete the untouched first "// note" (own TextEdit, empty
// new_text) AND replace "assign q = b; // note" with an instantiation.
// n_edits: one insertion of a whole `module second` whose body writes
// "// note" twice.
// files sorted by Scope::build: m.sv, second.sv.
verify_move(&mut scope, &plan, &["m", "second"], MOVED_WHAT, &[0, 1]) == Ok(())
// ^ should be Err; it is Ok.

This is not a shape the current extract engine is known to produce today (no corpus or opentitan trial hit it) — it is the shape CLAUDE.md invariant 4 asks every widening to be attacked with regardless, because a future bug in render.rs's comment-carrying code (or a second consumer of verify_move, which RefactorEdit::created's Handshakes note §53.2 will be) could produce exactly this pair and the safety net would wave it through. Needs: either a per-piece identity (not just count) carried through the pool — e.g. an edit-relative source position tag on each Piece::Comment/Piece::Attr so a piece can only balance against its own counterpart — or an explicit bound that a file's own per-file delta (after - (before - deleted)) can only be negative (a piece leaving) when moving is non-empty and the piece actually appears in another pooled file's writes at least once per occurrence, not just in aggregate. Left to the dev; QA does not redesign.

Priority 2 — the dataflow rule and the extraction

Read region.rs, flow.rs, boundary.rs, render.rs, mod.rs in full. Cross-referenced every row of the brief's dataflow matrix against tests/extract.rs's existing 33 tests (thorough — combinational, sequential, parameter+import, parameter-in-port-type, wildcard/named import, file-scope-typedef refusal, both-sides-write, routine-argument refusal, hierarchical refusal, unpacked-dimension refusal, positional/.*/no-such-port instantiation refusals, timescale/default_nettype, name-collision refusals, cursor-as-selection, the reference census). Then ran additional scratch extractions (temporary tests/qa_scratch_53_1.rs, removed after) for rows the existing suite does not cover:

row result
struct member write s.f = a (S declared as a port) ACCEPTED, s becomes output — correct, but see Finding L1
same, s.g also written outside the region REJECTED — "s is driven on both sides" (base-of-lvalue rule confirmed for Member)
part-select write x[3:0] = a alone ACCEPTED, x becomes output
same, x[7:4] also written outside REJECTED — "x is driven on both sides"
interface signal write b.data = a (bus_if.mp b port) REJECTED — "declared outside m" (see Finding L1: names the field, not the interface)
pure-function-read argument twice(a) + twice(a) REJECTED — confirms the dev's documented over-refusal (any argument position, not just outputs)
hierarchical reference whose head instance is inside the selection ACCEPTED — confirmed the allowed case
whole-module-body selection ACCEPTED — M is left holding only the instantiation
localparam used inside ACCEPTED — becomes a parameter of N with the default carried, matches README
comment on a standalone line between two selected items travels into N with both items' own trailing comments, all three intact
case expression read ACCEPTED as input

Finding V2 (HIGH) — region.rs::module_at accepts a selection inside an interface or program body, contradicting the documented refusal ("a selection in an interface/program (refused)", TODO §53.1 and this README's refusal table), and produces a measurable correctness regression on real RTL. vlog_parser's AST uses one Module node for module/interface/program (crates/vlog_parser/src/ast/module.rs:8-16, distinguished only by Module::kw). Region::read's module_at (crates/vlog_refactor/src/extract/region.rs:80-92) matches ItemKind::Module(module) and never inspects module.kw, so it treats an interface (or program) exactly like a module. Nothing downstream catches it either — extract_site (the cheap gate offered as the code action) uses the same Region::read, so the action is even offered inside an interface.

Minimal repro (ran directly, extract_module on a 5-line interface):

interface bus_if;
  logic [7:0] a;
  logic [7:0] q;
  assign q = a;
endinterface

→ ACCEPTED. Produces module n (...); assign q = a; endmodule as a new file, and rewrites the interface body to n u_n (.a(a), .q(q)); — a module instantiated inside what remains an interface.

Confirmed as a real regression, not just a spec gap, via an independent opentitan trial: copied hw/ip/{aes,uart,spi_host,hmac} (237 files, read-only source, scratch copies only — hw/ip/aes/dv/sva/aes_masking_reseed_if.sv is an interface) and ran the same automated region-scan the dev's own corpus trial uses. The very first interface region it reached (aes_masking_reseed_if's always_comb block, driven off interface header parameters/ports and package imports) extracted "successfully" — both halves parsed, formatted and converged — but the unresolved-name census over the two files went from 10614 to 10618, i.e. four names that used to resolve no longer do. This is exactly the regression class the census assertion exists to catch (same mechanism as the two defects the dev's own work log documents), and it did: cargo test -p vlog_refactor --test corpus five_regions_of_real_rtl… with LUCISV_EXTRACT_ROOT pointed at the scratch copy fails at the census assertion, not the parse/format ones. (opentitan repo left untouched — git -C .../opentitan status --porcelain before and after this run shows only the three pre-existing baseline diffs named in the task brief.)

Fix is a one-line gate at the top of region.rs::module_at (refuse unless module.kw is "module"/"macromodule", with the existing NO_MODULE sentence or a dedicated one) — left to the dev, along with a regression test pinning both the direct refusal and the census non-regression on the aes_masking_reseed_if shape (or a corpus-sized equivalent) once fixed.

Priority 3 — the server and extension over the wire

Read lucisv_server/src/extract.rs, server/dispatch.rs, server/mod.rs, main.rs's create_files_support, editors/vscode/{extract,extension}.js. Confirmed by reading and by the existing test suite (all green, see Gates): codeAction for a whole-item range returns the refactor.extract action with a Command and no edit (a_selection_of_whole_items_is_offered_the_action_with_a_command_and_a_default_name); not offered for a half-item range (a_selection_that_covers_no_whole_item_is_offered_nothing); executeCommand lucisv.extractModule with create_files=true returns documentChanges: [CreateFile, TextDocumentEdit×2] (the_command_creates_the_new_file_for_a_client_that_can); with create_files=false a changes map writing N below M (the_command_writes_the_module_into_the_same_file_for_a_client_that_cannot); create_files_support needs both documentChanges and resourceOperations containing create (create_files_support_needs_both_halves_of_the_capability, 5 sub-cases). The extract command is dispatched before ports::execute in server/dispatch.rs as documented. grep -n registerCommand editors/vscode/*.js shows no second registration of lucisv.extractModule — only extract.js's doc comment mentioning the collision it avoids, and hierarchyView.js's unrelated commands. node --test editors/vscode/extract_test.js — 31 checks, OK; the full editors/vscode/*_test.js run (extract, hierarchyModel, hierarchyView, restart) — 4/4 suites pass, no regressions.

Priority 4 — trials

  • Corpus (cargo test -p vlog_refactor --test corpus five_regions_of_real_rtl…, unmodified corpus/): 5 extracted, 6 refused, matches the dev's claim exactly.
  • Opentitan, dev's own claim: not independently re-run at the dev's exact 244-file selection (the checkout revision/subset used was not recorded reproducibly in the README); instead ran the same automated trial against an independently-chosen 237-file scratch subset (hw/ip/{aes,uart,spi_host,hmac}, read-only source untouched) — this is what surfaced Finding V2 above rather than reproducing "5/11". Given the finding, the dev's original 244-file number cannot be taken as clean either without knowing whether an interface region was among its refusals or its "successes".
  • Five hand-picked opentitan-style regions (struct member write, part select, hierarchical head-inside, whole-body, localparam-in-expression) — folded into the Priority 2 table above rather than run as a second batch, given time budget; all passed parse/format/convergence where accepted.
  • lucisv check --select unused-signal,undriven-net,multiply-driven before/after was not run separately from the reference census (the corpus/opentitan trials assert an equivalent, stronger, whole-reference census rather than a three-lint-rule census); not flagged as a gap since the stronger check subsumes it, but noted for completeness.

Gates (guarded, all via tools/guard.sh)

Gate Result
cargo clippy --all-targets clean
cargo test --workspace 4 073 passed, 0 failed, 44 ignored — matches the dev's claim exactly
tools/corpus_check.sh 814/820 (99.3%), same six parse errors
format --stdout vs ~/.cache/lucisv-baselines/lucisv-0.46.0 over the 860 corpus files (independently scripted, not via corpus_check.sh) 854 identical, 0 differing, 6 refused by both — matches the dev's claim exactly
cargo build --release -p lucisv -p lucisv_server ok
node editors/vscode/smoke.js target/release/lucisv-server OK
node --test editors/vscode/extract_test.js OK, 31 checks
node --test editors/vscode/*_test.js (full suite) 4/4 suites, 0 failures

All temporary QA tests and scratch copies were removed before finishing; git diff --stat on check.rs is back to exactly the dev's own diff (416+/145-). git -C .../opentitan status --porcelain shows only the three pre-existing files named in the task brief, both before and after this QA pass.

Note to the lead, not this lane's to touch: CHANGELOG.md, editors/vscode/CHANGELOG.md, editors/vscode/README.md, docs/topo.md, docs/site/**, and TODO.md's [x] marks on "docs" and "Gates" changed during this QA pass (not by this session) — merge-time docs work appears to already be in flight in this tree. Given Finding V2 in particular, the already-ticked TODO.md "Gates (guarded)" line should be revisited once the dev fixes it, since the opentitan trial number behind that tick is now in question.

Verdict: REWORK

Two HIGH findings, both requiring a code change plus a regression test before re-review:

  1. V1 — the pooled ledger (check.rs, Ledger::check) can forgive a masked corruption where one pooled file loses an untouched never-dropped piece while another pooled file gains a duplicate, as long as the aggregate count balances. Confirmed via the real verify_move entry point, not just the pooled() test harness.
  2. V2 — extract's selection gate (region.rs::module_at) does not check Module::kw, so it accepts a selection inside an interface or program body, contradicting the documented refusal and producing a confirmed reference-resolution regression on real RTL (aes_masking_reseed_if.sv, opentitan).

One LOW note, not blocking: struct-member and interface-member-access refusal sentences ("the selection uses f…") name the accessed field rather than the type/port that is actually the crossing name, which is technically correct (the field genuinely has its own symbol at file scope) but reads as if f were expected to be a module-level signal. Cosmetic; no correctness risk since the refusal (not an accept) is the safe direction.

The §53.1 QA checkbox in TODO.md is left unticked pending a fix and a second QA pass on V1 and V2.

2026-09-06 — QA re-attack of the rework (§53.1 only). Read the dev's "2026-09-06 — dev, rework" entry above, check/{mod,ledger}.rs in full (the four equations, Ledger, Transit, Split::positions_match), the twelve verify_move attack tests in check/mod.rs's "the moved-piece rule" section, and extract/region.rs's extractable/module_at. Re-ran all twelve — all still pass and all still go through the production verify_move (a real Scope, raw TextEdits, positions_match included; no pooled()-style helper remains anywhere in the crate: grep -rn "fn pooled" crates/vlog_refactor finds nothing). Then attacked the equations further with temporary tests (crates/vlog_refactor/src/check/mod.rs's test module, crates/vlog_refactor/ tests/extract.rs; both removed before finishing — git status --porcelain on both shows them as the dev's own untracked additions, unchanged in line count from before this pass).

Attack table (all through production verify_move)

# attack result
1a two real sources (a.sv, b.sv), one destination (n.sv), transit sums correctly accepted
1b crosswise: b's piece written into a.sv (a source, not the named destination) instead of n.sv rejected — a.sv isn't credited to receive anything (receives is false for any file whose region is non-empty), so the write is an unexplained duplicate
1c can one file be both a source and a destination? no, structurally — region_of (check/ledger.rs:187) returns the first moving entry for a file index, and Moved::receives (check/ledger.rs:384) is derived solely from whether that one range is empty; a file cannot carry a real region and the transit allowance at once
2 a source declares its own transit region as empty while its edit genuinely deletes-and-moves a piece rejected (rule 1) — within() credits no out for an empty region, so the deletion has to balance on its own and can't
3a moving names the same file index twice with different ranges inert — region_of's .find only ever sees the first entry; the second is dead weight, confirmed by comparing the dup-list outcome to the single-entry outcome (identical); reversing the order (empty entry first) does change the outcome, as expected, since now that entry is the one .find returns
3b region covering the whole file no panic, ordinary accept, nothing special about size
4a a region honestly containing two identical comments, both really moved accepted
4b same byte shape, but framed as "the region was widened to swallow an unrelated second occurrence" also accepted — the equations are byte-counting; they cannot and do not distinguish "the selection legitimately covers two occurrences" from "someone lied about what the selection covered." In production this never diverges because extract/mod.rs:211,220 sets the edit's own delete-range and the moving region to the same region.span value, and region.span is built by region.rs::Region::read from real AST item spans — so the guarantee lives in the planner, not in the verifier. Recorded, not a new defect (same shape as the existing "region that does not cover what the edits delete" test, from the other side)
4c destination n.sv already has one occurrence of the moved text before the edit; plan writes it once more / zero more / twice more once → accepted (after = 2); zero → rejected, "never dropped"; twice → rejected, "never duplicated" — matches the spec exactly
5 /* TODO: connect */ genuinely inside the moved region (not merely coincidentally generated text absent from the source), deleted once from m.sv, written twice into n.sv rejected, "never duplicated" — rule 2's generated() whitelist (check/ledger.rs:312) exempts only the per-file duplicate rule; Transit::lands (rule 4, check/ledger.rs:413) has no such exemption and still catches it, because the piece is present in sent (it really was deleted from inside the source's region). The whitelist only ever "wins" for text that was never in transit at all (a_generated_placeholder_the_new_file_writes_is_not_a_duplicate, where the key never enters sent)
6 a same-file relocation: a piece outside the transit region, deleted at one position and written back at a different position in the same source file, alongside a legitimate cross-file move accepted — see Finding QA-1 below

Finding QA-1 (MEDIUM) — positions_match cannot see a same-file relocation expressed as ordinary edits, through the production entry point

Item 6 of the brief expected positions_match to refuse this ("the per-file rule accepts, but positions_match should refuse the relocation — confirm"). It does not. Reproduction (temporary test, check/mod.rs, qa_a_same_file_relocation_outside_the_region_is_caught_by_positions_match, removed after): m.sv legitimately sends one comment to n.sv in transit, and — unrelated, outside the region — deletes a second, distinct comment // stray from one position and re-inserts identical text a few lines later in m.sv itself, as two ordinary, well-formed, non-overlapping TextEdits. verify_move returns Ok(()).

Why: verify_move (check/mod.rs:194-203) always computes the post-edit text itself, as apply(scope.text(*i)?, edits) — no production caller (verify_move, extract_module, convert_to_ansi, ports::*) ever hands the verifier an independently-authored "after" text. Split::positions_match (check/ledger.rs:101-165) builds its expected piece sequence by re-walking the same edits list and interleaving their own declared written pieces — which is a second, piece-level implementation of "apply the edits," not an independent oracle. Since both apply() and positions_match's reconstruction agree by construction whenever the edits are individually well-formed (sorted, non-overlapping), there is no discrepancy left for positions_match to catch: the relocation is what the (valid) edits define, and both edits are innocent-looking in isolation.

This means the one existing test that demonstrates a positional rejection — check::ledger::tests::a_move_that_left_the_comment_where_it_was_is_rejected — is not reachable through verify_move at all. It calls the lower-level, test-only pieces_match(before, after, edits, …) directly with an after built by hand-editing the honestly-applied text with .replace(...) beyond what move_edits() declares — a shape no real caller can produce, because every real caller derives after from apply() over its own edits.

Consequence for invariant 4: Eq3 (after == before - gone + wrote, check/ledger.rs:325-339) is in the same position. None of the twelve verify_move attack tests isolates it (see the equation map below), and by the same reasoning it cannot be reached in production either — any test that would need Eq3 to fire (an "applied text disagrees with what the edits' own bookkeeping predicts") requires an independently-supplied after, which verify_move never receives. Eq1 (grounded in the truly re-lexed after text) is the actual backstop for content loss/gain in production; Eq3 adds protection only against a divergence between apply()'s byte-level splice and the ledger's own piece-level counting (e.g. malformed/overlapping edits from a buggy future planner) — a scenario I attempted to construct (deliberately overlapping edits, exploiting apply()'s documented silent-skip of an overlapping edit) and could not turn into a case where Eq1 didn't already catch the resulting loss first.

Severity and recommendation, not a redesign: this is not a regression from the rework (the same structure predates it, in the non-move pieces_match/Ledger too) and no current planner (extract's flow.rs/ boundary.rs/region.rs, ports::ansi) produces an edit pair shaped like this — extract's only same-file, non-transit edits are the instantiation replacement and, for Home::SameFile, one pure append. But per CLAUDE.md invariant 4 ("any equation no test proves is a finding"), Eq3 and positions_match's value in the move context are currently unproven by any attack that goes through a real entry point, and a future bug in a planner (§53.2's inline, or a second consumer of verify_move) that computes correct counts but a wrong position for a never-dropped piece within one file would pass silently. Left to the dev/lead to decide whether a follow-up test (or accepting the gap as documented, since position-correctness for extraction is region.span's job, not the verifier's) is warranted — not blocking this pass.

Equation-to-test map (the twelve verify_move tests, check/mod.rs)

equation proves it via
Eq1 after_f + out_f ≥ before_f a_copy_deleted_outside_the_region_is_not_one_the_move_may_balance (QA's V1 pin), a_deletion_wider_than_the_region_is_an_ordinary_deletion, a_region_that_does_not_cover_what_the_edits_delete_is_rejected, and negatively via the_widening_is_opt_in_… (same equation, no out credit at all without moving)
Eq2 wrote_f ≤ (gone_f − out_f) + in_f, generated-exempt a_comment_that_lands_twice_in_the_new_file_is_rejected, a_comment_left_behind_as_well_as_moved_is_rejected, a_comment_the_new_file_invents_with_nothing_in_transit_is_rejected; positively (whitelist) a_generated_placeholder_the_new_file_writes_is_not_a_duplicate; and, via the old, unwidened per-file path (a file moving does not name), a_piece_in_transit_to_a_file_the_move_did_not_name_is_rejected
Eq3 after_f == before_f − gone_f + wrote_f none of the twelve — see Finding QA-1; empirically and structurally unreachable via verify_move today
Eq4 Σ_dest(wrote−gone) == Σ_src out (Transit::lands) a_comment_the_move_carries_that_lands_nowhere_is_rejected, an_attribute_the_move_carries_that_lands_nowhere_is_rejected (a_comment_that_lands_twice_… and the third-file test are caught earlier, by Eq2, before lands() ever runs)
(positive control) the_move_the_engine_actually_produces_verifies needs all four to pass at once

The kw gate (V2) and the opentitan reproduction

region.rs::extractable (region.rs:106-115) accepts only "module" / "macromodule" and refuses "interface"/"program" with the documented sentences; Region::read calls it right after module_at, and extract_site goes through the same Region, so the action is not offered either. Both pinned tests (a_selection_inside_an_interface_or_a_program_is_refused, the_action_is_not_offered_inside_an_interface_or_a_program, tests/extract.rs) re-read and re-run, green. macromodule itself had no dedicated test before this pass; added one temporarily (module.kw == "macromodule", closes with endmodule — a macromodule's end keyword is endmodule, not endmacromodule, which is exactly the kind of thing worth having pinned) and confirmed it extracts and is offered identically to module; removed with the rest of the temporary tests since it wasn't asked for as a permanent addition, but worth the dev adding as a one-line permanent case given macromodule is the other accepted keyword and had zero coverage.

A nested module declared inside a generate block: region.rs::module_at (region.rs:82-94) only scans the file's top-level items, one level, not recursively into a module's own items or a GenBlock's. Read through by hand rather than tested: a selection actually inside such a nested declaration is always caught by the existing whole-item/extent machinery first — the enclosing generate item (or the nested module item itself) is treated as one indivisible item wider than any inner selection, so the result is a safe refusal ("cuts an item in half" or "a declaration of its own"), never a silent misattribution to the wrong module. Cosmetic at worst (the refusal's stated reason may not name the real cause); no correctness risk found.

Opentitan reproduction (scratch copy, hw/ip/{aes,uart,spi_host,hmac}, 237 files, opentitan at the checkout named in the README, copied to /private/tmp/.../scratchpad/ot_reattack and pointed to via LUCISV_EXTRACT_ROOT, deleted after): tools/guard.sh -- cargo test -p vlog_refactor --test corpus five_regions_of_real_rtl… -- --nocapture prints 5 extracted, 5 refused, both aes_masking_reseed_if.sv and aes_reseed_if.sv refused for being inside an interface, and every extraction holds the census at 10614 → 10614 — matches the README's table row for row. git -C .../opentitan status --porcelain unchanged before and after (the same three pre-existing files named in the task brief). The default corpus trial (corpus/, no env var) reproduces 5 extracted, 6 refused, census 10268 → 10268, also matching.

Gates (guarded)

Gate Result
cargo fmt -p vlog_refactor -- --check clean
cargo clippy --all-targets clean, no new #[allow]
cargo test -p vlog_refactor -p lucisv_server all green
cargo test --workspace 4081 passed, 0 failed, 44 ignored — matches the dev's claim exactly (measured as 4090/44/0 with 9 temporary QA tests still in place, all of which also passed; 4090 − 9 = 4081)
opentitan extraction trial (scratch, 237 files) 5 extracted, 5 refused, census 10614 → 10614, opentitan checkout untouched
corpus extraction trial (860 files) 5 extracted, 6 refused, census 10268 → 10268

All temporary tests removed before finishing (check/mod.rs back to 1025 lines; tests/extract.rs has no qa_-prefixed test remaining); both files remain the dev's own untracked additions, git status --porcelain confirms no other tracked file was touched by this pass.

Verdict: PASS

Both HIGH findings from the first QA pass are fixed and hold up under re-attack through the real production entry point:

  1. V1 (the pooled ledger) — confirmed fixed. All twelve attack pairs, including two-source/one-destination sums, crosswise misdirection, empty and duplicated moving entries, pre-existing destination content, and the generated whitelist's interaction with the cross-file lands rule, come out exactly as the equations promise.
  2. V2 (the kw gate) — confirmed fixed, including the opentitan regression it was written against; macromodule (the gate's other accept arm) checked too and found sound, just untested until now.

One new, non-blocking finding (QA-1, MEDIUM): positions_match, and by the same reasoning Eq3, provide no protection against a same-file relocation of a never-dropped piece expressed as two well-formed edits, because in production after is always internally derived from the very edits being checked — this is pre-existing crate structure, not something the rework introduced, and no current planner produces this shape, but it means neither equation is currently proven by any attack that goes through a real entry point. Left to the dev/lead as a documentation note or a follow-up test, not a blocker.

2026-09-06 — QA (§53.2, inline module). Read this README's §53.2 sections in full (the substitution table, the .name shorthand rule, the prefixing rule, the refusal list, the assumptions, the copy allowance and its eight attack pairs), the diffs in check/{mod,ledger}.rs, inline/{mod,site,source,render}.rs, lib.rs, tests/{inline,corpus}.rs, lucisv_server/src/inline_module.rs, main.rs, server/dispatch.rs. Then re-attacked the verifier through the production verify_move beyond the dev's own eight, attacked the substitution/prefixing/refusal matrix on hand-picked shapes, confirmed the server wiring by reading, and re-ran every trial and gate. Verdict is PASS, with two MEDIUM findings (neither blocking, both documentation/follow-up) and one QA-caused incident, fully remediated, recorded below for the record.

Priority 1 — the verifier's copy allowance

All eight of the dev's own attack tests (check/mod.rs, "the copied-piece rule" section) were re-read and re-run — cargo test -p vlog_refactor --lib check:: — 57/57 pass, all still through the production verify_move with a real Scope and the edits inline_module really produces (no pooled()-style helper anywhere: grep -rn "fn pooled" crates/vlog_refactor finds nothing). Re-attacked with nine more (temporary tests, added to check/mod.rs's test module and tests/inline.rs, removed before finishing — see "Cleanup" below):

# attack via result
1–8 the dev's own eight (honest; written-twice; lands-nowhere ×2 comment/attribute; invented outside the region; the generated whitelist; rule 0 on the very comment being copied; the opt-in pin) production verify_move all as documented, re-confirmed
9 a real comment from sub.sv's header, outside the declared copy region (not a synthetic // invented string) verify_move, real edits + one appended line rejected — "never duplicated", naming the real comment text; confirms the region boundary is exact, not "whatever the render happened to read"
10 rule 0 with an edit to the copied file far from the copied region (an unrelated insertion at offset 0) verify_move rejected — "only copies out of", naming sub.sv — confirms rule 0 does not ask where the edit lands
11 rule 0 against a pure code edit to the copied file that touches no never-dropped piece (assign s = a; → assign s = a & a;, no comment/attribute involved) verify_move rejected — "only copies out of" — see the neutering table below for why this one matters
12 two Moving::copy entries of the same region, destination writes the comment+attribute twice verify_move accepted — two honest copies, two landings, exactly as the brief predicted
12b the same doubled write with one copy entry verify_move rejected — "never duplicated"
13 Moving::copy naming a file index outside the Scope (99, out of range) verify_move no panic — Scope::path/Scope::text return None (scope.rs:57-63, .get()-based), the rule-0 loop's let (Some(path), Some(text)) = … else { return Err(abandoned) } fires; clean refusal
14 a Moving::source (moved) and a Moving::copy in the same plan, three files: honest one-landing-each, then swapped so the moved piece lands twice and the copied one lands zero times (same pool total) verify_move honest accepted; swapped rejected — no cross-talk between origins, the swap is caught (each piece's own sent/lands accounting is per-text-key, not pooled across origins in a way that would let one type's excess hide the other's shortfall)
15 the "coincidence" the brief names: top.sv's own (deleted) instantiation already carries a comment textually identical to the one sub.sv's body copies out hand-crafted TextEdits (not the real engine's own output — see below) through verify_move see Finding QA-2

Finding QA-2 (MEDIUM, non-blocking) — the copy allowance inherits QA-1's (§53.1) blind spot into the copy-origin context; not reachable by anything inline_module produces today. Hand-crafted (not engine-produced) edits where top.sv's pre-existing instantiation held a comment (sub u_sub (.a(x), .q(z)); // the and) textually identical to the one sub.sv's body copies out: an edit that deletes it without carrying it forward (gone=1, wrote=1) is correctly rejected (Transit::lands: gained = wrote − gone = 0 ≠ out = 1, "write it back nowhere"); the same deletion with the written text carrying the comment twice (gone=1, wrote=2) is accepted (gained = 1 = out). Traced by hand through every shape the real comments_in/render.rs code can actually produce for this input (the real engine's own comments_in captures the instantiation's own comment as carried and writes it back once, giving exactly wrote=2, gone=1 — the legitimate, correct case: one comment carried locally, one landed by copy, both real, both wanted) and could not construct a reachable bug shape the equations would wrongly accept: any planner defect that over-writes (a duplicated carried entry, or a duplicated copy landing) pushes wrote past gone−out+in and is caught by rule 2 first, every time this was tried. The Ok(()) in row 15 above is a case of two interpretations of the identical final bytes (carried once + copied once vs. an invented duplicate replacing a silently-dropped original) being indistinguishable because the bytes really are identical — this is exactly Finding QA-1 from the §53.1 pass ("positions_match… provide no protection… because after is always internally derived from the very edits being checked") restated one level up, in the copy transit's own lands equation rather than in positions_match. Same root cause, same non-reachability argument, same recommendation (a per-piece identity/position tag would close both at once). Left to the dev/lead exactly as QA-1 was: a documentation note or a follow-up test, not a blocker — flagging here so QA-1 and QA-2 get closed together if either is ever addressed.

Neutering (check/mod.rs, temporary edits, reverted before finishing — diff against the dev's own file confirmed byte-identical after):

stubbed what failed interpretation
rule 0's if edits.iter().any(...) { return Err(...) } replaced with if false && … check::tests::an_edit_to_the_file_the_move_only_copies_out_of_is_rejected and check::tests::qa_rule_0_fires_for_an_edit_to_the_copied_file_far_from_the_copied_region still failed (i.e. still correctly rejected the corruption) — but for the wrong reason: the copied file's own edit fell through to the ordinary per-file pieces_match path (since region_of no longer credits it as Copied), which independently caught the comment deletion/insertion in sub.sv on its own. check::tests::qa_a_pure_code_edit_to_the_copied_file_touching_no_never_dropped_piece (added specifically to close this gap) failed outright — Ok(()) where an Err was expected confirms rule 0 is load-bearing specifically for an edit to the copied file that touches no never-dropped piece (a pure code/semantic change) — the ordinary per-file ledger has nothing to say about it, and nothing else in verify_move reads the copied file's edited text at all (the copy's tally is always taken from scope.text(), the original)
transit.copy(...) call replaced with a discard 12 tests failed, all of them: a_copied_attribute_that_lands_nowhere_is_rejected, a_copied_comment_that_lands_nowhere_is_rejected, a_copied_comment_written_twice_is_rejected, a_generated_placeholder_the_destination_writes_is_not_a_duplicate, a_piece_written_into_the_destination_that_the_region_does_not_hold_is_rejected, an_edit_to_the_file_the_move_only_copies_out_of_is_rejected, the_copy_allowance_is_opt_in_and_an_inline_that_asked_for_none_gets_none, the_inline_the_engine_actually_produces_verifies, plus four of mine — every one of them failed at the construction step (inline_edits()/inline_module(...) itself now returns Err, rejecting the engine's own honest output as "would write the attribute once… without deleting it") confirms transit.copy is what makes the copy allowance exist at all: without it, no real inline verifies, ever

Both stubs reverted immediately after; diff against a saved copy of the dev's check/mod.rs (via git show HEAD:… | patch < check_mod.diff) confirmed byte-identical to the dev's own file once the nine QA tests were removed.

Priority 2 — the inline matrix

Read inline/{site,source,render}.rs in full. site.rs::of checks module.kw ("module"/"macromodule") before anything else reads the instantiation — the §53.1 V2 mistake (accepting a selection inside an interface) is not repeated here. Cross-referenced every row of the brief's matrix against tests/inline.rs's existing 42 tests (thorough: two-port substitution, literal-on-input, .clk implicit shorthand, parameter override and default, parameter used in a port's type (WIDE), name-collision prefixing and its warning, no-collision, import copied in, every refusal in the table — expression/.*/positional/unconnected input/output-to-literal/hierarchical (same file and another file)/bind/ generate/initial/macro/directive/inout/unpacked/interface port/declared twice/unknown/same-file/differing timescale/array of instances/escaped-name collision, the cheap gate, the round trip, the .name shorthand expand-and-refuse, a string parameter's embedded spaces). Five rows the existing suite does not cover, attacked with temporary tests in tests/inline.rs (removed after — file diffed back to the dev's own 604 lines, confirmed identical):

row result
a port connected to a name sub also declares internally (.a(s) where top has its own wire s, and sub's own body also declares logic s) handled correctly: the port substitution uses the connected name s verbatim wherever a is used (never subject to collision handling); sub's own internal s collides with top's file (which spells s — the connecting wire's own declaration is a symbol in top's file, and "M's file is the collision set" is deliberately that literal) and is prefixed to u_sub_s. Result: logic u_sub_s; // the and, assign u_sub_s = s & b;, assign z = u_sub_s; — no self-assignment, no corruption
two instances of the same S in M, inlined one at a time (as the server would, one command per instance) first inline untouched-second confirmed; re-running against the edited file inlines the second independently — it collides with the first inline's own s (now declared in top) and is correctly prefixed u_sub2_s, its own collision, not contaminated by or reusing the first instance's naming
an unconnected output (.q()) refused with the same sentence as an unconnected input — `.q` is left unconnected — confirms the README's explicit note ("An unconnected output refuses, not only an unconnected input")
a named block that does not collide (always_comb begin : blk … end : blk, nothing in M spells blk) inlines untouched, begin : blk intact, no u_sub_ anywhere — the end-label refusal is confirmed to fire only when prefixing is needed
the same named block where M does declare blk (forcing prefixing) refused, naming the end … : blk label, exactly as render.rs::labelled promises

All five pass; no defect found in this batch.

Priority 2, continued — the handed-files narrowing

Read lucisv_server/src/state.rs::module_sources (state.rs:1478-1500) in full against rename_sources (state.rs:1565-1591) to answer the brief's question directly: does module_sources include every file that mentions u_S, or only files that reference S/M by name? module_sources(file, modules) unions: the requesting file, every file declaring one of modules (WorkspaceIndex::units), every file with a direct references_to/instantiations_of posting for one of them, and every open buffer. Both references_to and instantiations_of are keyed by direct uses of the exact declaration/name (workspace/index.rs:245,312) — there is no rung for a file that reaches u_S only through an intermediate instance it does not itself name (rename_sources has a hierarchical_declarations rung for exactly this shape on renamed members; module_sources has no equivalent).

Confirmed concretely, not just by reading (tests/inline.rs, temporary, removed after): wrapper.sv instantiates top directly (so it is in a real fan-out) and tb.sv instantiates wrapper (not top, not sub) and writes u_wrapper.u_top.u_sub.s — a genuine XMR into the instance being inlined, one hop further than module_sources looks. With tb.sv handed to inline_module (simulating a workspace where the index also connects it), the inline is refused, naming it — no_hierarchy sees what it is given. With exactly the file set module_sources(top.sv, ["sub","top"]) would actually compute for this shape (top.sv, sub.sv, wrapper.sv — not tb.sv), the same inline is silently accepted.

Finding QA-3 (MEDIUM) — the hierarchical scan's blind spot is real, reproducible, and one hop worse than a rename's. This is the README's own documented assumption ("the hierarchical check sees the files it was handed… an XMR from a file the index does not connect to either name is outside what lucisv can see, as it is for a rename") — not a hidden defect, and the safe direction is the one taken (it's an under-refusal, not a corruption the verifier's own contract claims to catch: the no_hierarchy scan is inline/mod.rs's own workspace-wide refusal, not part of check::verify_move, so this isn't a CLAUDE.md invariant-4 question). Rated MEDIUM rather than LOW because the concrete trigger — a testbench or SVA bind file reaching into an instance through one or more wrapper levels, which is common in verification code for exactly the kind of IP this feature targets (common_cells, opentitan prim_*) — is not exotic, and unlike a rename's hierarchical_declarations rung, inline has no rung at all for it. Not a fix requested here (QA verifies, does not redesign); worth the lead's attention as a documented, known gap rather than a surprise, and worth deciding whether inline should get its own "instantiates something that (transitively) instantiates M" rung the way rename's does for members.

Priority 3 — the round trip

extracting_a_region_and_inlining_it_back_returns_the_original (tests/inline.rs) re-run — passes, part of the full suite (see Gates). Traced by hand: extract writes sum u_sum (...) from the region's own dataflow-inferred ports; inline reads that same instantiation back and substitutes the identical names, since nothing renamed anything on the way out. format_source twice on both sides confirms byte-equal after formatting, for the one pinned shape (combinational, single file). The brief's "three shapes" (sequential-with-parameters, with-imports) are not separately pinned — only the one shape has a dedicated round-trip test — but both underlying halves (extract's parameter/import handling, inline's localparam/import copying) are independently tested and nothing in either side is shape-specific to the combinational case; not re-litigated given the time budget, flagged rather than silently assumed clean.

Priority 4 — the server, over the wire

Read lucisv_server/src/inline_module.rs, main.rs, server/dispatch.rs in full (diffs above). Confirmed by reading and the existing (green) test suite: code_actions returns refactor.inline with a Command and no edit (the_cursor_on_an_instantiation_is_offered_the_action_with_its_command) — the offer is exactly one parse of one buffer (vlog_refactor::inline_site), no workspace read, matching the "lazy" cost claim; not offered elsewhere (a_cursor_on_anything_else_is_offered_nothing); execute reads ws.module_sources(&path, &site.units) and calls inline_module, wiring confirmed identical in shape to extract's. server/dispatch.rs: the inline_module::kind() branch in the codeAction fan-out and the INLINE_MODULE branch in executeCommand are both routed before ports::execute, matching the README and the same ordering extract uses. ports::workspace_edit reused unchanged — confirmed by reading (ports.rs:435-458): an ordinary changes map, no Uri/CreateFile capability read anywhere in the inline path, matching "no client capability is involved". No same-title-key collision risk analogous to §50 was found: commands() appends inline_module::commands() once, and grep -rn "lucisv.inlineModule" finds it declared in exactly one place. The "one parse" cost claim was not independently profiled against a real opentitan buffer (time budget); the code path matches extract_site's (same cheap-gate shape, same parse_source_tolerant call), so this is a reading-based confirmation, not a measurement.

Priority 5 — the trials

Corpus (cargo test -p vlog_refactor --test corpus five_instantiations_of_real_rtl_inline…, unmodified corpus/, 860 files): 5 inlined, 9 refused, the exact module-pair table the README prints, reproduced line for line. The extraction trial (five_regions_of_real_rtl_extract…) re-run alongside it as a sanity check: 5 extracted, 6 refused, unchanged.

Opentitan — not independently reproducible at the dev's exact 506-file selection for the same reason the §53.1 pass flagged for the extraction trial: the checkout subset used was not pinned reproducibly. Ran the same automated trial against an independently-built scratch copy of hw/ip/{aes,hmac,uart,spi_host,prim} — 741 .sv/.svh files (more than the dev's 506; prim/ alone is 504 files in this checkout, so the subsets evidently differ) — read-only source, scratch copies only: 5 inlined, 356 refused (prim_secded_22_16_enc→_tb, prim_secded_28_22_enc→_tb, and three more not re-derived here since the trial stops at five). Every accepted case parses, formats, converges, and the census property (borne) holds. 356 vs. the README's 56 is almost entirely prim/'s own `ifdef/macro/generate``-heavy FPV testbenches contributing many refusals per file (prim_alert_, prim_esc_, prim_fifo_sync` with indexed connections, etc.) — not a discrepancy in behaviour, a difference in what was scanned.

Three different opentitan instantiations, inlined and checked independently (the same parse/format/converge/census checks, over targeted scratch copies of just the files each needs):

module → into outcome
prim_secded_22_16_enc → prim_secded_22_16_tb inlined, 0 names newly unbound
prim_secded_28_22_enc → prim_secded_28_22_tb inlined, 0 names newly unbound
prim_secded_39_32_enc → prim_secded_39_32_tb inlined, 0 names newly unbound (confirmed via the same test harness pointed at a 3-file scratch copy; the harness's own "exactly five" assertion was expected to — and did — fail on this deliberately tiny set, after the parse/format/converge/census checks for the one accepted case had already run clean)

All three are .name-shorthand connections (.data_i) into a module whose instance is named the same as the module itself (prim_secded_39_32_enc prim_secded_39_32_enc (...)) and whose endmodule carries its own : name label — a shape not in the dev's or the first three's own trial rows, and it inlines cleanly.

Incident, fully remediated. Building the 741-file scratch copy, a first rsync invocation omitted a trailing destination argument (rsync … opentitan/hw/ip/aes/ … opentitan/hw/ip/prim/, five source-only arguments), so rsync silently treated the last path (opentitan/hw/ip/prim/) as the destination and copied aes/'s, hmac/'s, uart/'s and spi_host/'s .sv/.svh files into the real, read-only opentitan checkout at hw/ip/prim/{rtl,dv,pre_dv}/ — caught immediately by the mandatory post-read git -C …/opentitan status --porcelain check, which showed ~130 unexpected untracked files/directories under hw/ip/prim/ beyond the three baseline diffs. Nothing tracked was modified (every stray entry was a new, untracked file), nothing was committed or pushed. Remediated by removing exactly the paths git status --porcelain -- hw/ip/prim/ listed as untracked (rm -rf per path — git clean itself is denied by this environment's own permission classifier for a QA session, which is the correct behaviour); git -C …/opentitan status --porcelain re-checked clean afterward, back to exactly the three pre-existing baseline diffs (hw/ip/aes/dv/tb/tb.sv, hw/top_darjeeling/ip/ast/rtl/ast.sv, hw/top_earlgrey/ip/ast/rtl/ast.sv). Recorded here in full rather than quietly fixed, per the spirit of the task's own read-only rule.

A second, unrelated slip in the same vein: the first byte-identity pass (below) was run as a plain shell loop without tools/guard.sh and without redirecting the CLI's stdin, and one corpus file left it blocked on a stdin read for what ps reported as an implausible multi-hour elapsed time with near-zero CPU consumed — a hang, not a slow computation. Killed by hand (kill -9), re-run through tools/guard.sh -t 600 with < /dev/null on both invocations, and it completed in well under a minute. No repo state was affected (it only ever read corpus files and a release binary); flagged because CLAUDE.md's guard rule exists for exactly this shape of mistake and it is the QA lane's own job to model following it, not only to enforce it on the dev.

Gates (guarded throughout, all via tools/guard.sh)

Gate Result
cargo fmt --all -- --check clean
cargo clippy --all-targets clean, no new #[allow]
cargo test --workspace 4 133 passed, 0 failed, 44 ignored — matches the dev's claim exactly
tools/corpus_check.sh 814/820 (99.3%), the same six parse errors, 0 verification errors, 0 crashes — matches
format --stdout vs ~/.cache/lucisv-baselines/lucisv-0.48.1 over 860 corpus files (independently scripted) 854 identical, 0 differing, 6 refused by both — matches (see the incident note above for the first, failed attempt at this)
cargo build --release -p lucisv -p lucisv_server ok
node editors/vscode/smoke.js target/release/lucisv-server OK — 20 messages
cargo test -p vlog_refactor --lib check:: / --test inline / --test corpus / -p lucisv_server inline_module (post-cleanup, on the restored tree) 57/57, 37/37, 11/11, 6/6 — all green

All temporary tests and scratch copies removed before finishing. check/mod.rs diffed against the dev's own (git show HEAD:… | patch < check_mod.diff) — byte-identical. tests/inline.rs (604 lines) and tests/corpus.rs (233-line diff) both confirmed identical to their state at the start of this pass. git -C …/opentitan status --porcelain shows only the three baseline diffs, both before and after (see the incident note). git status --porcelain on this tree shows exactly the dev's own file set plus this README's QA-log edit and the TODO.md checkbox — CHANGELOG.md and editors/vscode/CHANGELOG.md are modified in the working tree by what reads as the lead's own in-flight 0.49.0 release-notes work (a ## 0.49.0 section already describing this feature), present when this pass started and untouched by it — flagged per the file-ownership rule, exactly as the §53.1 pass flagged docs/coverage_gaps.md.

Verdict: PASS

No blocking defect found. Two MEDIUM, non-blocking findings, both documentation/follow-up rather than fixes:

  1. QA-2 — the copy allowance's Transit::lands equation cannot, in principle, distinguish "a piece landed twice" from "one piece landed locally (carried) and a second, textually-identical one landed by copy" when both share the same (noun, text) key — the exact same root cause as §53.1's QA-1, one level up. Traced through every shape inline_module's real code produces today and found not reachable by any current planner; a hand-crafted edit is needed to exhibit it. Same recommendation as QA-1: a per-piece identity/position tag, if either is ever addressed.
  2. QA-3 — module_sources's fan-out (lucisv_server/src/state.rs) has no rung for a file that reaches the instance being inlined through an intermediate module it does not itself instantiate, so no_hierarchy's scan can silently miss a real XMR one hop further out than a direct reference — confirmed reproducible, not hypothetical. Matches the README's own documented assumption; flagged with severity because the trigger shape (testbench/SVA reaching through a wrapper) is ordinary in the RTL this feature targets, not exotic.

Every priority-1 verifier attack the brief named was run through the production entry point (dev's eight re-confirmed, nine more added); the neutering table shows both rule 0 and the copy transit are load-bearing, each catching a distinct, real class of corruption nothing else in verify_move would. The inline substitution/prefixing/refusal matrix was attacked on five previously-uncovered shapes and none of them broke. The handed-files narrowing was confirmed concretely rather than left as a reading-based guess. Corpus and opentitan trials reproduce the dev's claims (or, where the exact file set could not be reproduced, an independently-built and larger one gives the same qualitative result plus three genuinely new accepted inlines). All gates are green and match the dev's own numbers exactly. One QA-caused incident (a stray rsync briefly touching the read-only opentitan checkout, and an unguarded, unredirected shell loop that hung) is recorded in full and was fully remediated before this pass finished.

Review

2026-09-06 — lead (53.1). Accepted after one rework; see the 53.1 paragraph below for the record. 53.1 shipped in 0.47.0.

2026-09-06 — lead (53.2). Accepted; ships in 0.49.0 with §54. Inline is the mirror of extract and is built as one: substitution from the symbol table rather than text search, prefixing only where the file already spells a name, the .name shorthand expanded rather than rewritten — that last one found by the corpus trial, which is what the trials are for. The verifier's Copied origin is the honest model of a copy (the source file must appear in no edit; each copied piece lands once per copy), pinned by eight attack pairs through the production entry, and QA's neutering map shows every rule load-bearing. The deviations are all in the conservative direction (same-file S, unconnected outputs, any generate, prefixing past an end label refuse). QA's two MEDIUMs are recorded, not actioned here: QA-2 is topo §2.9-32's blind spot in a new coat, same fix; QA-3 — the hierarchical scan sees only the files module_sources hands over, and a bench reaching u_S through a wrapper it does not instantiate is not among them — is filed as topo §2.9-33 with the rung it wants. The extract → inline round trip is pinned byte-equal after formatting.

2026-09-06 — lead. 53.1 accepted after one rework; ships in 0.47.0 with §52. 53.2 is unstarted and runs as its own lane after §56, as the plan allowed — a finished half over two unfinished ones. The dataflow rule is the right reading (a routine argument refuses rather than guesses; a positional or .* connection refuses), the new-file path reads both halves of the client capability, and the naming flow goes through the language client's middleware rather than a second command registration. The two trial-found defects (a parameter named only by a port's type; a header import recorded as p::*) are exactly why the trials assert on the unresolved-name census and not on a parse. QA's two HIGHs were both real: a whole-file pool balanced an unrelated deletion against a duplicate write, and one AST node for module/interface/program let an interface body extract. The rework binds the pool to the moved bytes — four equations, twelve attack pairs through the production entry, the opentitan trial reproducible file by file with the census held — and QA's re-attack found only a MEDIUM that predates this lane (a same-file relocation of a never-dropped piece written as two well-formed edits is not caught, and equation 3 is unreachable through any real caller); no planner produces that shape, so it is filed as topo §2.9-32 for a later round rather than widened here.

(empty — for the lead)