# Independent review: uncommitted TODO §65.1 work (2026-10-06) ## Scope This review covers the uncommitted working tree on `master`, on top of `b9ee399`. That is 47 modified files and 16 new ones, about 4.8k lines including tests: - §65.1, generate-label rename and references; - rename warnings and mentions scoped to the renamed declaration (the "home set", reworks 3–5); - the MCP `block` refusal lifted; - `duplicate-declaration` extensions; - R1, path-qualified file names in messages. It is a read-only review. The only file written is this one. **Method:** - I checked the gates and the docs myself. - Two Opus reviewers took a slice each: - A: `vlog_semantic`, `vlog_refactor/src/check`, `vlog_linter`; - B: `vlog_refactor/src/rename`, `ports`, `lucisv_server`, `lucisv_mcp`. - The reviewers reproduced their findings with scratch probe crates in the scratchpad, not in the repo. - I re-read the code for each high finding and for the confirmed bug. ## Gates (run by me, all through `tools/guard.sh`) | Gate | Result | |---|---| | `cargo fmt --all --check` | clean | | `cargo clippy --workspace --all-targets` | exit 0, 0 warnings | | `cargo test --workspace --all-targets` | guard exit 0 (no kill); 79 suites, **5 064 passed, 0 failed, 51 ignored** | | doc-tests | **not run**. Excluded on purpose because of the open §65.3 stall, so this gate is still open for the release. | | corpus / opentitan byte-identity | not run (no formatter change in the diff) | | File size | Every touched production file is under 600 lines. Largest: `resolve.rs` 559, `rename/warnings.rs` 529, `rename/connections.rs` 477. Functions are all under 50 lines (reviewer A). | **Verdict:** the generate-label part (§65.1 proper) is sound. Two high findings are in the newer warning-scoping work: it silently drops warnings that 0.59.0 gave. That breaks the feature's own rule that scoping may drop a warning only when the spelling provably cannot reach the declaration. **I would not ship 0.60.0 until H-1 and H-2 are fixed or the scoping is reverted to unscoped for those shapes.** --- ## HIGH > **H-1 and H-2 fixed 2026-10-06:** new `vlog_refactor/src/rename/carry.rs` (carried macro arguments, binder macros); tests `vlog_refactor/tests/rename_macro_carry.rs` (8) and 4 unit tests in `carry.rs`; work log in `docs/features/generate-label-rename/README.md`. OpenTitan warnings unchanged on the renames measured (no added noise). ### H-1. A bare macro argument that the macro body turns into a path or a named connection is silently dropped (regression vs 0.59.0) — **FIXED 2026-10-06** - **Where:** - `crates/vlog_refactor/src/rename/scoped.rs:149-158` (`bare_is_news`) - `crates/vlog_refactor/src/rename/warnings.rs:255-259` (the filter in `macro_use_warnings`) - **The cause:** in a file that is not the declaring file and not an included or including fragment, `bare_is_news` returns `false` unconditionally. Edited instantiators and testbenches are such files. I confirmed this in the code. That is only safe if the macro uses its formal as a plain expression. It is wrong whenever the body puts the formal after a `.`, after a `` `` `` paste, or into a `.x(x)` connection. - **Repros** (reviewer B; rename `m.state_q`, where `state_q` is a port of `m`). Each one renames with **no warning**; at HEAD each one warned: - **PC (realistic):** `` `define CONN(x) .x(x) `` with `m u_m (.clk(clk), `CONN(state_q));` in `top.sv`. - The port is renamed and the instantiation breaks. - The MCP also drops the mention (`mentions.rs`: no `.` right before it). - **PA:** `` `define FORCE(sig) force u_m.sig = 1'b0; `` invoked as `` `FORCE(state_q) `` in `tb.sv`. The result is the same when `tb.sv` is edited. - **PA2:** `` `define PEEK(sig) u_m.``sig ``. - **Suggested fix:** drop a bare argument only when every definition of the invoked macro in the set uses that formal nowhere after `.`, after `` `` ``, or as `.formal(`. If the macro is unknown or ambiguous, keep the warning. The bodies are already collected (`define_bodies`). - **Missing tests:** PC, PA and PA2 in `qa_warning_scope.rs`. The existing tests only use `` `Q(x) x `` and `ASSERT`. ### H-2. A `bind` produced by a macro expansion is invisible to K2 and H3 — **FIXED 2026-10-06** - **Where:** `scoped.rs:162-174` (`files_binding_into`) and `scoped.rs:~236` (`binds_into`). - **The cause:** both functions look only at literal `bind` tokens. - **Effect:** take a `` `define`` whose body is `bind m chk u (.s(state_q));`, invoked from a file outside the home set. That file is never added to the home set, so the bare `state_q` in the body is silenced (reviewer B, repro PD). - **Related:** this has the same root cause as H-1: macro expansion moves text into `m`'s scope. One "macro body may carry the name into the unit" rule would cover both. --- ## MEDIUM ### M-1. The H4 fragment warning reports uses the rename *did* edit as "left unchanged" — **FIXED 2026-10-07** - **Where:** `scoped.rs:~181-231` (`fragment_use_warnings` / `bare_unbound_uses`). It ignores the rename's edit ranges. - **Repro** (reviewer B, PI): - `all.sv` includes `m.sv` and `n.sv`; - `n.sv` has `m u_m(...)`; - renaming module `m` edits `n.sv:2`, yet the engine warns "`n.sv:2`: `m` is used in a file that includes `m.sv` or is included with it and was left unchanged". - **Effect:** it misleads users and agents, and it fires for modules, packages (`p::X`) and every include-wrapper layout. - **Suggested fix:** skip tokens covered by this rename's edits. ### M-2. Naming files in warnings is quadratic: about 0.5 s per rename on opentitan — **FIXED 2026-10-07** - **Where:** - `vlog_refactor/src/scope.rs:~341-345` (`name_of`) scans every source on each call. - `define_warnings` (`warnings.rs:~202`) and `macro_use_warnings` (`warnings.rs:242`) compute `name_at(file)` for every file of the set **before** checking for sites. - **Measured** (reviewer B): - One pass over the 3 979 files takes 245 ms, and there are two passes. - That is about 490 ms of a 2.93 s `entropy_src_main_sm.state_q` rename. - **Suggested fix:** compute the name only when sites exist, or build base-name counts once per `Scope`. - **Same pattern, smaller cost:** `ports/offer.rs:251` (`name_among` per mentioning file, on the code-action path). ### M-3. The docs contradict the code and leave out the last fix — **FIXED 2026-10-07** - **README says engine and verifier are unchanged.** `docs/features/generate-label-rename/README.md:68-69` says "The rename engine (`vlog_refactor/src/rename/`) and the verifier (`check/`) are unchanged in code". `refactor-rename/README.md` (the 2026-09-30 work log) and topo row 43 say the same. All three are stale: - reworks 2–5 added `rename/{arms,home,paths,scoped}.rs` and rewrote `warnings.rs`; - `check/{implicit,ledger,mod}.rs` changed for R1 message naming. - Reviewer A confirmed the `check/` change is message-only and widens no forgiveness, so invariant 4 is not triggered. The sentence is still false as written. - **"What changed" stops at the first pass.** Reworks 1–5 are only in the work log. - **Status / TODO does not list reworks 2–5 or the §65.6 filing** (it ends at "§65.4 filed"). - **The P1/P2 fix after QA's closing check is undocumented:** - The QA log (line ~984) records 2 ignored tests (P1, P2) as open findings. - The code now handles both (`keeps_define_body` checks `dotted` first and takes `default_bare`), and both tests run un-ignored and pass. - There is no dev work-log entry for this fix, and no QA re-check. - The doc comment of `rework5_a_shadowing_parameter_does_not_hide_a_dotted_body_spelling` (`tests/qa_warning_scope.rs:463-467`) still says "rework 5 does not". - **Topo row 40 not amended.** Topo row 43 says the fix "also answers row 40's second half", but row 40 itself is not amended. - **CHANGELOG 0.60.0 has two scoping bullets that disagree.** - The first ("only … in the declaring module … or in a file the rename edits") is superseded by the second (the home set). They should be merged. - The text says "a macro whose parameter is named like the declaration … [is] not" reported, without the dotted-body exception that now applies. --- ## LOW ### L-1. The closing-label fallback attaches a mismatched label to the wrong block (confirmed bug) — **FIXED 2026-10-14** - **Where:** `vlog_semantic/src/bind/mod.rs:366-369` (`use_end_label`). - **The cause:** when the body has no owner, the fallback takes the first same-scope symbol named like the *closing* label, if it is a `Block`. It never compares against the opening label of the construct being closed. The later `name != label` check is then trivially true. I confirmed this in the code. - **Repro 1** (reviewer A): ``` initial begin : a … end : a initial b: begin … end : a ``` - The mismatched `end : a` resolves to block `a`. - `rename a → z` rewrites it. - This contradicts the function's own doc ("a label that does not spell the declared name … records nothing"). - **Repro 2:** ``` if (1) begin : g … end : g function … g(); … endfunction : g ``` - The `endfunction : g` becomes a use of block `g`, contrary to the README's F3 assumption ("neither is a use of the other"). - The verifier refuses the rename here, so nothing is corrupted. - **Effect:** only already-invalid code reaches this. - **Suggested fix:** limit the fallback to block constructs. For the `lbl: begin` form, compare against the statement's own label. ### L-2. `duplicate-declaration` misses repeated generate labels, and the result depends on order — **FIXED 2026-10-14** - **Where:** `vlog_linter/src/rules/duplicate_declaration.rs:97-103` (`collides`, the `(true,true)` arm). - **The cause:** the arm skips any pair whose first label opens a generate scope. That is meant for the arms of one `if`/`case`, but it also hides two sibling `for … begin : g` loops. Both elaborate, so that is a compile error. - **Order dependence:** `initial begin : g` followed by `if (1) begin : g` is flagged; the reverse order is not. - This is not a regression. ### L-3. Dotted detection skips only whitespace — **FIXED 2026-10-14** - **Where:** `scoped.rs:~309` (`spellings`). - **Missed shapes:** `u_m.``state_q`, `u_m./*x*/state_q`, and a macro argument `` `Q(u_m. /* c */ state_q) `` are all treated as bare and silenced in non-home files (reviewer B, repros PL, PM, PE). ### L-4. A file that fails to lex drops its warnings without saying so — **FIXED 2026-10-14** - `files_binding_into` (`scoped.rs:171`) treats a lex failure as "no bind", so the macros invoked there are not followed (repro PH: an unterminated string in `binds.sv`). - `fragment_use_warnings` (`scoped.rs:~190`) silently skips a fragment that fails to lex or analyse. - By the feature's own rule, any doubt should fall back to unscoped. ### L-5. Paths through an interface port or virtual interface into an interface's generate block stay unresolved - **Where:** `vlog_semantic/src/workspace/hierarchy.rs:~114`. `Block` is only on the interface's *hierarchical* surface, but `bus.g_mon.seen` and `vif.g_mon.seen` are looked up on the connection surface. - **Effect:** the rename leaves them unchanged. It does warn ("could not be resolved"), so the rename is not silently partial. But the Goal and CHANGELOG read as if every path through a block is covered. - **Suggested fix:** document this shape, or add `Block` to the interface's connection surface. ### L-6. `binds_into` misses a bind whose target is a bare instance name - **Where:** `scoped.rs:~244-248`. - **Missed shape:** `bind u_m chk …` written inside the parent, which the LRM allows. Rare. ### L-7. Macro names passed as arguments are not followed - **Where:** `home.rs:~215` (`macro_names`). - **Missed shape:** with `` `define APPLY(m) `m ``, the call `` `APPLY(CHK) `` never follows `CHK`'s body. Contrived. ### L-8. A child module's bare call to a parent function is not covered - Upward name resolution (IEEE 1800 §23.8) lets a child call a module function `f()` bare. - A macro-argument spelling of `f` in the child is now dropped. The plain-code case was never handled. - Rare. ### L-9. The MCP and the engine disagree on what counts as dotted, and on the home set - `mentions.rs:109-113`: the MCP counts a mention as dotted only when the byte right before it is a `.`. The engine skips blanks first. - `edit.rs:169` and `find.rs:130`: `Focus::local` uses `home_set`, which does not include the K2 bind files. - **Effect:** in both cases the engine still warns and only the MCP mention is dropped. Not silent, just inconsistent. ### L-10. `Semantics::member_key` disagrees with its doc for inline nested struct members - **Where:** `vlog_semantic/src/lib.rs:298-304`. It returns the bare `owner.name`, but the index files these members under `nested_key` (`reg2hw_t.ctrl`, `record.rs:541-544`). - Not a regression (it matches the old `nav.rs` behaviour), but the new public API's doc promises the index key. ### L-11. `generate … endgenerate` stopping being a scope is a visible behaviour change - Two regions that each declare `genvar i;` now give `duplicate-declaration`. This is correct per IEEE 1800 §27.3, and the opentitan differential shows no change. - Older Verilog-2001-style code will see new findings. The CHANGELOG mentions the scope change but not this lint consequence. ### L-12. Unchecked slice in library code — **FIXED 2026-10-14** - **Where:** `vlog_refactor/src/rename/arms.rs:39`, `text[..other.name_span.start as usize]` with a `""` fallback for `text`. - It panics only if the analysis and the text disagree. `.get(..)` would follow the no-panic rule. ### L-13. R1 is incomplete — **FIXED 2026-10-14** - These multi-file messages still use bare `display()` instead of `name_of`: - `inline/mod.rs:225` and `:313`; - `ports/expand.rs:103` and `:320`; - `extract/boundary.rs:158`. --- ## NIT - **The index-transparency assumption is worded too broadly.** The README and `bind/expr.rs:241-249` claim it holds for every link the walk continues from. It is false for a scalar struct (`s[0].f` resolves) and for multi-dimensional packed struct arrays. Both are illegal SystemVerilog, so this is harmless. The cases that matter are fine: unpacked arrays, instance arrays and interface arrays still stop at the head. - **Doc line too long.** `vlog_semantic/src/bind/item.rs:4`: a module doc line of 100 characters, not reflowed. --- ## Checked and found sound - **Verifier (`check/`):** the only change is how files are named in messages. These names are never map keys, so no balancing can merge two files, and no normalization was added. The attack files `check/qa_block_paths.rs` (8 tests) and `check/qa_block_attacks.rs` (5) pin left-out, misplaced and extra edits on labels, closing labels, same-file and cross-file paths, split arms and genvar capture. Invariant 4 is not triggered. - **Scoping:** - A `for` label is declared in the enclosing scope, and the genvar does not leak. - `g.x` looks only in the block's own scope. - The outline is unchanged. - Completion after `blk.` works. - **Index:** - `block_key` and `member_key` agree, including for function-local blocks (`m.ff().fb`). - Block members go only into `hier_members`, so the port checks, the implicit-connection checks and the linter's interface checks are unaffected. - `FACTS_FORMAT` is bumped to 21. - **`home.rs`:** - Include cycles end, and the upward closure is transitive. - An include resolves by path suffix, then falls back to base name, taking every match. - A macro-built include or an include of a file outside the set falls back to unscoped. - `home_set` costs about 0.17 s in MCP `find refs` on opentitan. - **`nav.rs`:** `member_key` equals `owner.name` for every non-block owner, so non-block references are unchanged. - **MCP:** - The `block` refusal is lifted, and `qa_m7` asserts the full rename. - `path_warned` de-duplication is asserted in `wire.rs` and `qa_m7`. - `rooted` builds its name table once per set. - **Code rules:** no `unwrap`/`expect`/`panic` in new library code (L-12 is the one slice risk). ## Recommended before commit 1. Fix H-1 and H-2, or fall back to unscoped for a bare macro argument whose macro body carries it after `.`, `` `` `` or into a connection, or expands to a `bind`. Add tests PC, PA, PA2 and PD. 2. Fix M-1 by skipping edited ranges. Fix M-2 by computing names lazily. 3. Make L-4 conservative: fall back to unscoped when a file fails to lex. 4. Bring the docs up to date (M-3): the README's "What changed" and Status sections, a dev work-log entry for the P1/P2 fix plus a QA re-check, the stale test comment, topo rows 40 and 43, and the CHANGELOG bullets. 5. Run the doc-tests gate (§65.3) before release.