# decomposition-semantic — TODO §28 Lane D: `vlog_semantic` and `vlog_refactor` ## Goal Split the four over-size files of the two semantic crates into module directories a human can navigate, one sentence per file: `vlog_semantic/src/bind.rs` (2 377 lines) → `bind/` (eight files, one per grammar domain of the binding walk), `vlog_semantic/src/workspace.rs` (1 974) → `workspace/` (five files: vocabulary, queries, incremental update, per-file records, the overlay), `vlog_refactor/src/ports.rs` (1 925) → `ports/` (six files: the spine, finding, one file per refactoring, list editing), `vlog_refactor/src/rename.rs` (1 249) → `rename/` (the rename, the shared `Scope`, the warnings, the tests). A **pure move**: no behaviour change, no renamed item, every public and `pub(crate)` path preserved by re-exports from the old module so `lib.rs`, `facts.rs`, `resolve.rs`, `check.rs`, `references.rs`, `instantiate.rs`, `lucisv_server` and `lucisv` compile unchanged; formatter output byte-identical over the corpus; `lucisv check` findings identical over the corpus and opentitan; test counts unchanged per binary. `resolve.rs` (489 lines) stays whole. ## Assumptions - `FACTS_FORMAT` and the facts codec (`facts.rs`) are untouched; the records it encodes (`FileFacts`, `Decl`, `SiteFact`, `ReferenceFact`, `DeclLines`, `DeclPositions`, `DeclSite`, `InstanceOccurrence`, `Utf16Pos`, `Utf16Range`) keep their fields and their `pub(crate)` paths through `workspace/mod.rs`, so a persisted store is as valid as before — nothing about a record's shape moved, only the file it is declared in. - Every public item keeps its public path. `vlog_semantic`'s public surface is the crate root's `pub use workspace::{…}` (the `workspace` module itself is private) and `vlog_refactor`'s is `pub use ports::{…}` / `pub use rename::{…}`; both `lib.rs` files are untouched, and each `mod.rs` re-exports what its siblings define. The crate-root page set of `cargo doc` is identical before and after (68 pages). - Children of a module see its private items, so `Binder`'s private fields, `Plan`/`Shape`, `WorkspaceIndex`'s tables and the free helpers each `mod.rs` keeps need no visibility change. A method a *sibling* file calls is `pub(super)` — visible inside the directory and nowhere else — and that marking is the reader's list of a module's entry points. The set was taken from the compiler, not guessed. - `bind_stmt` (148), `bind_item` (117) and `bind_expr` (116) are dispatch tables over `StmtKind`, `ItemKind` and `ExprKind`; they are under the 150-line line, so they carry no comment and were not split. No function in either crate is over 150 lines before or after, and no function was split. - Byte-identity is measured over the Verilog files under `corpus/` (`.sv .svh .v .vh`, 860 files), `--stdout` only, against `/tmp/lucisv-0.33.0-baseline`; formatting does not depend on either crate, so that gate is the sanity check and the semantic gate is `lucisv check` (the linter, which builds a `WorkspaceIndex`) over the corpus and over `opentitan/hw`, both binaries, finding lists compared. ## Handshakes - **Consumes** (unchanged): `vlog_parser::ast::*`, `vlog_parser::{defines, span, token, LineIndex, parse_*, tokenize}`; inside `vlog_semantic`: `crate::model`, `crate::scan`, `crate::classes`, `crate::instantiations`, `crate::words`, `crate::analyze`; inside `vlog_refactor`: `crate::check`, `crate::{apply, RefactorEdit, TextEdit}`, `vlog_semantic::*`. - **Promises** (unchanged): `vlog_semantic::{index_order, resolve_external, DeclLines, DeclPositions, DeclSite, Def, Definition, DefinitionKey, ExternalResolutions, ExternalTarget, FileFacts, FileId, IndexBuilder, IndexCounts, InheritanceEdge, InstanceOccurrence, InstantiationEdge, ReferenceSite, Utf16Pos, Utf16Range, WorkspaceIndex, WorkspaceSymbol}` and the crate-internal `crate::bind::{Binder, Pending, Target}`, `crate::workspace::{Decl, ReferenceFact, SiteFact, …}` at the same paths with the same signatures; `vlog_refactor::{add_port, enclosing_module, may_have_port_action, port_action_modules, port_actions, propagate_ports, remove_port, ModuleRef, PortAction, contains_word, prepare_rename, prepare_rename_here, rename, rename_name_at, RenameTarget}` and the crate-internal `crate::ports::{find_module, visible_in}`, `crate::rename::{display, Scope}` likewise. - **Requests**: none. Nothing outside `crates/vlog_semantic/src/{bind, workspace}/`, `crates/vlog_refactor/src/{ports,rename}/`, this README and the Lane D line of `TODO.md` changes. ## Status / TODO - [x] Baseline pinned: per-binary test counts, `cargo doc` page list and warning set, longest-function census, `/tmp/lucisv-0.33.0-baseline` present (`lucisv 0.33.0`) - [x] `git mv` each file to its `mod.rs`; siblings carved from a range manifest that tiles the pristine file and reassembles it byte for byte - [x] `bind/` (8 files), `workspace/` (5), `ports/` (6), `rename/` (4) carved; `cargo build -p` green after each - [x] `cargo test -p vlog_semantic` 28/12/27/13/1/12/3/8/24/40/31/31/18/9/5/83/0 = 345 and `cargo test -p vlog_refactor` 86/5/52/63/0 = 206 — identical to the pinned baseline, per binary - [x] Purity: line multiset and function-signature census against the pristine files — only `use`/`mod`/`impl` wrappers, banners, module docs, `pub(super)`, explicit-path doc links and rustfmt rewraps differ - [x] `cargo fmt -p vlog_semantic` / `-p vlog_refactor` (`--check` clean), `cargo clippy --all-targets --workspace` 0 warnings, `cargo doc` 6 + 1 warnings (the baseline set, nothing new), `cargo test --workspace` 48 binaries / 3 215 passed / 0 failed - [x] Public paths: crate-root `cargo doc` page set identical (68 pages) - [x] Byte-identity: corpus `--stdout` 860 files, 0 differing (stdout, stderr, exit code) - [x] Semantic proof: `lucisv check` over the corpus (7 978 lines) and over `opentitan/hw` (225 lines) identical between the two binaries; opentitan status unchanged (the three pre-existing modified files) - [x] `TODO.md` Lane D line ticked ## Work log ### 2026-09-02 — baseline Branch `decomp-semantic` at 35f0b8d (lane B merged), worktree `.claude/worktrees/decomp-semantic`. Pinned `cargo test` (per binary): | crate | binary | tests | |---|---|---| | vlog_semantic | `src/lib.rs` unit tests | 28 | | | `tests/binds.rs` | 12 | | | `tests/classes.rs` | 27 | | | `tests/constraints.rs` | 13 | | | `tests/corpus.rs` | 1 | | | `tests/covergroups.rs` | 12 | | | `tests/deep_nesting.rs` | 3 | | | `tests/fragments.rs` | 8 | | | `tests/interfaces.rs` | 24 (+1 ignored) | | | `tests/member_access.rs` | 40 (+1 ignored) | | | `tests/member_site.rs` | 31 | | | `tests/semantics.rs` | 31 | | | `tests/struct_members.rs` | 18 | | | `tests/sva.rs` | 9 | | | `tests/vendor_formal.rs` | 5 | | | `tests/workspace.rs` | 83 | | | doc-tests | 0 | | | **sum** | **345** | | vlog_refactor | `src/lib.rs` unit tests | 86 | | | `tests/corpus.rs` | 5 | | | `tests/ports.rs` | 52 | | | `tests/rename.rs` | 63 | | | doc-tests | 0 | | | **sum** | **206** | `cargo doc -p vlog_semantic -p vlog_refactor --no-deps`: 140 HTML pages (68 at the crate roots), 7 warnings — `DeclLines`/`DeclPositions` link to private `Decl`, `absorb` to `WorkspaceIndex::merge`, `members_of_chain` to `base_chain`, `contains_word` to `Scope::define_sites`, and two unresolved links (`chase_inherited`, `Target::Port`). All seven pre-exist. Longest functions before (production lines, brace-matched; "prod" is non-blank, non-comment, outside `#[cfg(test)]`): | file | prod | longest functions | |---|---|---| | `bind.rs` | 1 718 | `bind_stmt` 148, `bind_item` 117, `bind_expr` 116, `bind_prop_expr` 55, `bind_deferred` 45 | | `workspace.rs` | 1 111 | `fingerprint` 86, `merge` 83, `facts_from_analysis` 68, `is_exported` 48 | | `ports.rs` | 1 391 | `instantiation_edits` 122, `plan_propagate` 109, `disconnection_edits` 64, `header_edits` 57 | | `rename.rs` | 760 | `locate` 47, `collect_occurrences` 43, `sva_fallback_warnings` 40 | Nothing over 150; seven over 80. The three in `bind.rs` are dispatch tables over an enum; `instantiation_edits` and `plan_propagate` are single-pass planners with the refusals inline. None was split (§28 allows a split only over 150 lines). ### 2026-09-02 — method `git mv .rs /mod.rs` first, so history follows the file that keeps the public items. Every sibling was then written by a range manifest (`scratchpad/carve.py` + one JSON per file): each new file is a list of literal parts (module doc, `use` lines, `impl … {` / `}`) and 1-based line ranges of the *pristine* file (`git show HEAD:…`). Before anything is written the script requires the ranges plus an explicit `drop` list (the section banners, the old `use` block, the blank lines between segments) to tile lines 1..N exactly once, and re-concatenates them in original order and compares byte for byte with the original. The only edit it makes to copied text is `fn x(` → `pub(super) fn x(` for a named list of functions, and, for four structs whose fields a sibling reads (`ModuleSite`, `DeclaredPort`, `NewPort`, `AfterElement`, and the `index` field of `Scope`), a literal substitution with a required hit count. `mod.rs` is never written by the script: it writes the *expected* text to the scratchpad, `mod.rs` was written by hand through the Write tool, and the two were `diff`ed (identical, all four). No sed/Python deletion touched any source file. Deviations from a literal move, all documentation-only: - Section banners (`// ---- Items ----`, `// the plan`, …) became each file's `//!` module doc; every `mod.rs` gained a paragraph naming the siblings and the cut. - `bind.rs` had a doc slip: the two lines "`p::x`: the head names a unit (package or class), the tail is looked up inside it." sat above `bind_type_expr`'s own doc (old 2173–2174) and describe `bind_scoped`; they now sit on `bind_scoped`. - Ten intra-doc links in `workspace/` that pointed at an item no longer in the file's scope were given an explicit path so `cargo doc` stays at its baseline warning set: `[`IndexBuilder::finish`]` ×4, `[`IndexBuilder::add_facts`]` ×2, `[`IndexBuilder::add_file`]` ×2, `[`resolve_external`]` ×2 became `[`X`](super::X)` (rendered text unchanged); the three of those lines that then exceeded 100 columns were rewrapped. - `rename.rs`'s 190-line parity-test block moved to `rename/tests.rs` (`#[cfg(test)] mod tests;`), with `contains_word`'s one test beside it in `rename/warnings.rs`; two of its lines re-joined under rustfmt because they are one indent level shallower now. `ports.rs`'s eleven unit tests went beside the code they test: nine list/paren tests to `ports/list.rs` (with the `at` helper), `parse_port_decl`'s to `ports/add.rs`, the interface-locating one to `ports/find.rs`. - Visibility: `pub(super)` on exactly the cross-file entry points listed under each map below; the `Affected` struct became `pub(super)` because it is a parameter type of the now-`pub(super)` `merge`. Five signatures in `bind/`, four in `ports/` and one in `rename/` rewrapped under rustfmt once `pub(super)` pushed them past 100 columns. ### 2026-09-02 — module maps "prod" is production lines; "total" is `wc -l`. Old line numbers are those of the pristine file at 35f0b8d. **`vlog_semantic/src/bind.rs` (2 377 total, 1 718 prod) → `bind/`** | new file | one sentence | prod | total | old `bind.rs` lines | |---|---|---|---|---| | `mod.rs` | What every part of the walk shares: `Pending`, `Target`, `Deferred`, the `Binder` state, and the table plumbing (`new_scope`, `declare*`, `use_name`/`use_member`, `use_end_label`, `exact_or_empty`, `type_name_of`). | 208 | 358 | 1–3, 13–126, 128–154, 160–336, 2338–2345 | | `item.rs` | The item-level walk: file/fragment, `ItemKind` dispatch, modules and interfaces (ports, modports, clocking), imports, instantiations and `bind`, generate, functions and tasks. | 410 | 536 | 342–560, 586–606, 803–995, 1011–1092 | | `decl.rs` | Declared names and the types written on them: `#(...)` parameter ports, tf arguments, typedefs, enum/struct bodies, data/port declarations, declarators, `bind_data_type`, `modport_tail`, `param_kind`. | 218 | 339 | 562–584, 997–1005, 608–801, 2216–2288, 2316–2330 | | `class.rs` | Classes: header and bases, `use_scoped_unit`, constraint blocks (declaration, out-of-block form, `randomize() with`), the deferred out-of-body definitions and the unit-scope lookup they need, `last_segment`, `randomize_head`. | 307 | 428 | 1098–1139, 1448–1475, 1145–1239, 1421–1446, 1477–1648, 2347–2350, 2352–2377 | | `cover.rs` | Covergroups: header, coverpoints/crosses, bins and their specs, the `with` filter's `item`. | 151 | 196 | 1245–1419 | | `stmt.rs` | Statements: `StmtKind` dispatch, case items, timing controls, sensitivity lists. | 189 | 218 | 1654–1818, 1967–2002 | | `sva.rs` | Assertions: property/sequence declarations, concurrent assertions, the property-expression walk. | 132 | 160 | 1824–1965 | | `expr.rs` | Expressions: `ExprKind` dispatch, casting types, `p::x`, dimensions, `spine`, `member_tail`. | 182 | 254 | 2008–2171, 2175–2203, 2173–2174 + 2205–2214, 2291–2314, 2332–2336 | Dropped: the nine section banners, the old `use` block (5–11), the `impl` close (2289). `pub(super)` entry points: `item::{bind_item, bind_import_path}`, `decl::{bind_param_ports, bind_tf_args, bind_typedef, bind_enum_members, bind_data_decl, bind_port_decl, bind_declarators, bind_data_type, param_kind}`, `class::{bind_class, bind_constraint, bind_with_constraint}`, `cover::{bind_covergroup, bind_cover_item}`, `stmt::{bind_stmts, bind_stmt, bind_sens_list}`, `sva::{bind_prop_seq_decl, bind_assertion}`, `expr::{bind_opt_expr, bind_dims, bind_expr}`. `mod.rs` keeps `pub(crate)` on exactly what `lib.rs` and `resolve.rs` used before (`Binder::{new, file_scope, bind_items, bind_fragment, bind_deferred}`, the three fields, `Pending`, `Target`). Cut points that differ from §28's sketch (`{mod, items, stmts, exprs, types, classes, sva}`), and why: `types` is `decl` because what the code groups is *declared names with their types* — a declarator, a port, a parameter, a typedef all go through `declare_typed` + `bind_data_type`, and both items and statements declare through it; covergroups are their own `cover.rs` rather than part of `class.rs` on the same reasoning lane B gave, and because a cover-item *fragment* binds through the same entry point an item does; constraints stay in `class.rs` because a constraint body *is* class scope (`this.` implicit, §18.5) and its out-of-block form takes the same deferral as a method. Several files are under the 300-line target on purpose: each is one grammar domain a feature lane owns whole (the last three rounds were a constraint round, a covergroup round and an SVA round), and merging `stmt`/`sva`/`expr` into one 500-line "body walk" would put those lanes back in one file. **`vlog_semantic/src/workspace.rs` (1 974 total, 1 111 prod) → `workspace/`** | new file | one sentence | prod | total | old `workspace.rs` lines | |---|---|---|---|---| | `mod.rs` | The index's vocabulary: every record it hands out (`FileId`, `Def`, `DeclLines`, `Utf16*`, `DeclPositions`, `DefinitionKey`, `ReferenceSite`, `WorkspaceSymbol`, `DeclSite`, the edges) and the `WorkspaceIndex` tables themselves, plus `IndexCounts`. | 142 | 340 | 1–14, 28–257, 259–297, 1544–1572 | | `index.rs` | What a built index answers by map reads (`impl WorkspaceIndex` queries), plus `build`, `index_order`, `IndexBuilder`, `contains_ignore_ascii_case`. | 236 | 492 | 300–668, 1454–1474, 1476–1542, 1676–1682 | | `update.rs` | Changing an index after it is built: `update_file`/`update_facts`/`absorb`/`remove_file`, `fingerprint`, `merge`, `merge_references`, `Affected`. | 280 | 397 | 674–1018, 1021–1050 | | `record.rs` | What one file contributes: `Decl`, `SiteFact`, `FileFacts`, `ReferenceFact`, `facts_of`/`facts_from_analysis`, `edges_of`, `inheritance_of`, `collect_members`, `nested_key`, `parse_and_collect`, `is_unit`, `is_exported`. | 329 | 528 | 1052–1452, 1574–1674 | | `external.rs` | The overlay: `ExternalTarget`, `ExternalResolutions`, `Definition`, `resolve_external`, and the walks it shares with `index` (`resolve_fact`, `member_chain`, `base_chain`, `fold_path`, `aliased_unit`, `target`, `last_segment`, `follow_paths`, `follow_one`). | 162 | 301 | 1688–1974 | Dropped: the two banners, the old `use` block (15–27), the `impl` open/close (299, 1019). `pub(super)`: `update::merge` (and `Affected`), `record::{facts_of, Decl::def, ReferenceFact::occurrence}`, `external::{resolve_fact, member_chain, base_chain, fold_path, last_segment}`. `mod.rs` re-exports `pub use external::{resolve_external, Definition, ExternalResolutions, ExternalTarget}`, `pub use index::{index_order, IndexBuilder}`, `pub use record::FileFacts`, `pub(crate) use record::{Decl, ReferenceFact, SiteFact}` — the names `lib.rs` and `facts.rs` import. §28 sketched `{mod, index, scan, resolve_external, persistence}`. There is no persistence code in `workspace.rs` (that is `facts.rs`, untouched), and the per-file read-off is `record` rather than `scan` because `crate::scan` already exists (the name scanner) and every doc comment calls this thing "the record". The `WorkspaceIndex` struct sits in `mod.rs` rather than `index.rs` so that both `index` and `update` — the two `impl` blocks that read its tables — see the fields as a parent's private items, with no `pub(super)` field in sight. **`vlog_refactor/src/ports.rs` (1 925 total, 1 391 prod + 147 test) → `ports/`** | new file | one sentence | prod | total | old `ports.rs` lines | |---|---|---|---|---| | `mod.rs` | The surface and the spine: `ModuleRef`, `PortAction`, the entry points (`add_port`, `remove_port`, `propagate_ports`, `port_actions`, the `codeAction` gate, `enclosing_module`), and the `Plan` → `finish` → `confirm`/`Shape` every planner goes through. | 242 | 371 | 1–16, 32–232, 238–306, 312–366 | | `find.rs` | Finding what a request points at: `locate_module`, `module_at`, `find_module`, `declared_ports`, `collect_instantiations`, `name_visible`/`visible_in`; the interface-locating test. | 189 | 252 | 372–526, 1735–1777, tests 1787–1812 | | `add.rs` | Adding a port: `parse_port_decl`, `plan_add`, `header_edits`, the `` `ifdef`` guard, `non_ansi_declaration`, `instantiation_edits`; the `parse_port_decl` test. | 432 | 543 | 532–588, 594–734, 740–1032, tests 1814–1829 | | `remove.rs` | Removing a port: `locate_port`, `plan_remove`, `preprocessor_warnings`, `body_uses`, `non_ansi_declaration_removal`, `disconnection_edits`. | 254 | 307 | 1038–1317 | | `propagate.rs` | Propagating the missing connections of one instantiation: `plan_propagate`. | 121 | 139 | 1323–1440 | | `list.rs` | Editing a comma-separated list and finding its parentheses: `append_to_list`, `remove_element`, `whole_line`, comment/indent/comma helpers, `port_list_parens`, `header_semicolon`, `skip_group`, `conn_list_open`, `close_paren`; nine tests. | 226 | 401 | 1446–1634, 1640–1729, tests 1783–1785 + 1831–1924 | Dropped: the twelve banners, the old `use` block (17–31), the test module's own frame. `pub(super)`: `find::{locate_module, not_in_scope, module_at, declared_ports, collect_instantiations, name_visible}` and the fields of `ModuleSite`/`DeclaredPort`; `add::{parse_port_decl, plan_add, not_indexed, element_spans, missing_parens}` and `NewPort`'s fields; `remove::{locate_port, plan_remove}`; `propagate::plan_propagate`; `list::{insert, append_to_list, remove_element, whole_line, after_same_line_comments, line_indent, port_list_open, header_semicolon, conn_list_open}` and `AfterElement`'s fields. `mod.rs` re-exports `pub(crate) use find::{find_module, visible_in}` for `instantiate.rs`. §28 sketched `{mod, plan, execute, warnings}`. The code has no "execute" — what executes is `finish`/`confirm`, twenty lines that belong beside the entry points that call them — and its warnings are inline in each planner, so the cut that reads top-to-bottom is one file per refactoring. `propagate.rs` is small (121) because that refactoring is one function; folding it into `remove.rs` would make that file "removing a port and propagating connections", two sentences. **`vlog_refactor/src/rename.rs` (1 249 total, 760 prod + 205 test) → `rename/`** | new file | one sentence | prod | total | old `rename.rs` lines | |---|---|---|---|---| | `mod.rs` | The rename itself: `RenameTarget`, `prepare_rename`/`prepare_rename_here`/`rename_name_at`/`rename`, `check_new_name`, `Found`/`Target`, `Scope::{locate, declaration, declaration_across_files, declaration_span, collect_occurrences, collect_edits, edits_from_spans}`, the refusal sentences. | 362 | 491 | 1–7, 23–191, 199–215, 292–521, 855–890 | | `scope.rs` | The in-scope files, the index built from them and per-file analyses on demand — `Analysis`, `Scope::{build, len, path, text, sources, file_id, index_of, analysis, cached, index}`, `display`. | 69 | 105 | 193–197, 217–229, 232–290, 813–816, 1008–1012 | | `warnings.rs` | What a rename could not account for: `Scope::warnings` and its seven scans, `unresolved_unit`, `DefineSite`, `ArgumentSite`, `stray_reason`, `sva_regions`, `assertion_paren`, `closing_paren`, `macro_name_of`, `contains_word`; the `contains_word` test. | 354 | 513 | 523–811, 819–853, 892–1006, 1014–1043, test 1241–1248 | | `tests.rs` | The new-name test and the `prepare_rename_here` ⇄ `prepare_rename` parity suite. | (145 test) | 197 | 1049–1239 | Dropped: the old `use` block (8–22), the `impl` open/close and the test frame. `pub(super)`: `scope::Scope::file_id` and the `index` field, `warnings::Scope::warnings`. `mod.rs` re-exports `pub use warnings::contains_word` and `pub(crate) use scope::{display, Scope}` — what `lib.rs`, `check.rs`, `references.rs` and `ports/` import. The split was warranted: `rename.rs`'s one sentence needed two "and"s — "the rename, *and* the `Scope` every refactoring in the crate builds its in-scope files into, *and* the scans that word its warnings". `scope.rs` is 69 production lines and is the point of the split: it is the crate-wide workspace abstraction and had no name of its own. No file is over 600 production lines (`add.rs` at 432 is the largest). No function is over 150 lines. The longest-function census after is identical to the census before, function for function: `bind_stmt` 148 (`stmt.rs`), `bind_item` 117 (`item.rs`), `bind_expr` 116 (`expr.rs`); `fingerprint` 86, `merge` 83 (`update.rs`), `facts_from_analysis` 68 (`record.rs`); `instantiation_edits` 122 (`add.rs`), `plan_propagate` 109 (`propagate.rs`), `disconnection_edits` 64 (`remove.rs`); `locate` 47, `collect_occurrences` 43 (`rename/mod.rs`). ### 2026-09-02 — gates and proofs - `cargo build -p` and `cargo test -p` after each of the four carves; the only compiler-driven fixes were the `pub(super)` set above, one `Affected` visibility, and one unused import in `ports/mod.rs` (`ModuleSite` is never named there). - `cargo fmt -p vlog_semantic` and `-p vlog_refactor` applied; `-- --check` clean on both. - `cargo clippy --all-targets --workspace`: 0 warnings. No `#[allow]` introduced (the one pre-existing `#[allow(clippy::too_many_arguments)]` on `bind_out_of_body` moved with its comment to `class.rs`). - `cargo doc -p vlog_semantic -p vlog_refactor --no-deps`: 6 + 1 warnings, the same seven as the baseline. Page list, both sides built into a clean doc directory (the baseline from a `git archive` of 35f0b8d in the scratchpad): 140 pages each; the 68 crate-root pages — the public paths — identical; the only difference is eight pages under the *private* `workspace`/`rename` module trees, which moved to the submodule each item is now defined in (`workspace/enum.Definition.html` → `workspace/external/enum.Definition.html`, …, `rename/fn.contains_word.html` → `rename/warnings/fn.contains_word.html`). Those paths were never nameable outside the crate — `workspace` and `rename` are private modules — so no public path changed; the workspace test run is the compile-level proof. - `cargo test -p vlog_semantic`: 28/12/27/13/1/12/3/8/24/40/31/31/18/9/5/83/0 — identical to the pinned baseline, sum 345. `cargo test -p vlog_refactor`: 86/5/52/63/0 — identical, sum 206. - `cargo test --workspace --no-fail-fast`: 48 binaries, 3 215 passed, 0 failed. - Purity (`scratchpad/purity.py`, pristine file vs `cat dir/*.rs`, lines trimmed, `pub(super) ` stripped, blank lines dropped, multisets): `bind` old-only 34 / new-only 133, `workspace` 20 / 90, `ports` 39 / 116, `rename` 8 / 55 — every old-only line is a banner, a `use` line, a rustfmt-rewrapped signature or one of the ten reworded doc-link lines; every new-only line is a `//!` doc, a `use`/`mod`/`pub use` line, an `impl … {`/`}` wrapper, a wrapped signature continuation or a doc-link line. Function-signature census (name + params + return, whitespace-normalized, visibility stripped): 81 = 81, 79 = 79, 74 = 74, 61 = 61, no signature added, removed, renamed or retyped. - Byte-identity: `target/release/lucisv` (this worktree) vs `/tmp/lucisv-0.33.0-baseline`, `--stdout` on every `.sv/.svh/.v/.vh` under `corpus/`, stdout, stderr and exit code compared per file: ``` corpus --stdout: files=860 stdout_differing=0 exit_code_differing=0 stderr_differing=0 exit0=854 exit_nonzero=6 ``` - Semantic proof (`lucisv check` builds a `WorkspaceIndex` and runs the semantic lints): `check .` in `corpus/` with both binaries — 7 978 lines each, 7 976 violations + 1 file that could not be checked, exit 2 on both, `cmp` identical raw (so also in order). `check hw` in `/Users/guoliangchen/repo/opentitan` — 225 lines each, 223 violations, exit 2 on both, `cmp` identical. Opentitan was touched with `check` only; `git -C …/opentitan status --porcelain` before and after shows exactly `hw/ip/aes/dv/tb/tb.sv`, `hw/top_darjeeling/ip/ast/rtl/ast.sv`, `hw/top_earlgrey/ip/ast/rtl/ast.sv`. - The `vlog_refactor` (`tests/rename.rs` 63, `tests/ports.rs` 52, `tests/corpus.rs` 5) and `lucisv_server` suites are inside the workspace run above, all green. Git state note: the four `git mv`s were staged first; after the siblings were added the index shows `D .rs` + `A /*.rs` rather than `R`, because git labels a rename only while the new file is ≥50 % similar and no `mod.rs` is — the `git blame` discontinuity §28 accepts. Nothing was committed. Handshake requests: none. Files changed: `crates/vlog_semantic/src/ bind.rs` → `bind/{mod,item,decl,class,cover,stmt,sva,expr}.rs`, `crates/vlog_semantic/src/workspace.rs` → `workspace/{mod,index,update, record,external}.rs`, `crates/vlog_refactor/src/ports.rs` → `ports/{mod,find,add,remove,propagate,list}.rs`, `crates/vlog_refactor/src/rename.rs` → `rename/{mod,scope,warnings, tests}.rs`, this README, and the Lane D line of `TODO.md`. ## QA log ### 2026-09-02 — independent verification All checks below were re-derived independently (own scripts in `scratchpad/qa-d/`, own throwaway worktree at 35f0b8d for baselines), not by re-running the dev's `carve.py`/`purity.py`/`census.py`. No corruption, no behaviour difference, no public-path change found. **Verdict: PASS.** **1. Gates.** - `git status --porcelain` confined exactly to `TODO.md`, `crates/vlog_semantic/src/{bind,workspace}.rs` (D) + `{bind,workspace}/*` (A), `crates/vlog_refactor/src/{ports,rename}.rs` (D) + `{ports,rename}/*` (A), `docs/features/decomposition-semantic/README.md`. `git diff --cached` on both `lib.rs` files, `facts.rs`, `resolve.rs`, `model.rs`, `scan.rs`, and every file under `crates/lucisv_server` / `crates/lucisv` — all empty. `TODO.md`'s only change is the Lane D line, `- [ ]` → `- [x]`. `FACTS_FORMAT` read directly: `113:pub const FACTS_FORMAT: u32 = 16;` — unchanged (and its file has an empty diff, so this was never in question). - `cargo fmt -p vlog_semantic -- --check` and `-p vlog_refactor -- --check`: both exit 0. - `cargo clippy --all-targets --workspace` after `touch`ing every file in the four new directories (forced rebuild): 0 warnings. Grepped the diff for `#[allow`: exactly one, `class.rs:322` `#[allow(clippy:: too_many_arguments)]`, matching the pristine file's `bind.rs:1575` (same attribute, moved with `bind_out_of_body`) — no new `#[allow]`. - `cargo test --workspace --no-fail-fast`: 48 binaries, 3 215 passed, 0 failed — matches the pin exactly. Per-binary counts for the two crates extracted from the raw log by binary hash (not just summed): vlog_semantic 28/12/27/13/1/12/3/8/24/40/31/31/18/9/5/83 = 345, vlog_refactor 86/5/52/63 = 206 — identical to the README's pinned baseline, digit for digit. - `cargo doc -p vlog_semantic -p vlog_refactor --no-deps`: 6 + 1 warnings, same seven (private-link `Decl` ×2, `base_chain`, `WorkspaceIndex::merge`, `Scope::define_sites`, unresolved `chase_inherited` and `Target::Port`) — built the baseline into a separate `CARGO_TARGET_DIR` from a fresh worktree at 35f0b8d and diffed the warning text; identical set, identical locations relative to each file's own new position. **2. Pure move, independently.** Own Python multiset-diff (own script, not `purity.py`): pristine `git show 35f0b8d:` vs the concatenation of the new siblings, blank lines dropped, no other normalization. - `bind.rs`: old-only 53 / new-only 151. `workspace.rs`: 30 / 100. `ports.rs`: 70 / 147. `rename.rs`: 10 / 57. (Different totals from the dev's own 34/133, 20/90, 39/116, 8/55 because this script does not strip `pub(super) ` before diffing — every promoted signature counts as one old-only + one new-only line here.) Read every one-sided line by hand: every old-only line is a `use`, a section banner, or a bare `fn`/`struct` signature whose new counterpart gained `pub(super)`; every new-only line is a `//!` module doc, a `mod`/`use super::…`/`pub(crate) use` line, an `impl … {` / closing `}` wrapper, a `pub(super)`-promoted signature (or its rustfmt-wrapped continuation), or one of the ten explicit-path doc links. Nothing else. Confirmed by hand the one exact case the work log calls out: `rename.rs`'s `let files = […]` and `const BROKEN: &str = "…"` each split across two old-only lines but rejoined into one new-only line under rustfmt — the only two-line-to-one-line reflow, exactly as logged. - Function-signature census (own regex-based extractor, not `census.py`): 81 = 81, 79 = 79, 74 = 74, 61 = 61. `workspace.rs` is an exact multiset match with no normalization needed. The other three each show a handful of mismatches that are purely a trailing comma from a rustfmt line-wrap my normalizer doesn't strip: 5 in `bind.rs` (`bind_param_ports`, `bind_constraint`, `bind_covergroup`, `bind_with_constraint`, `bind_prop_seq_decl`), 4 in `ports.rs` (`locate_module`, `plan_add`, `plan_remove`, `conn_list_open`), 1 in `rename.rs` (`warnings`) — 5+4+1, matching the work log's claimed rewrap count exactly, function for function. No signature added, removed, retyped, or split. - Test names: `bind.rs`/`workspace.rs` have 0 `#[test]` fns (their tests live in `tests/*.rs`, untouched) — 0 = 0 both sides. `ports.rs`: 11 = 11. `rename.rs`: 14 = 14. Every name present in the new tree exactly once (Counter-equality, not just count-equality). Spot-checked 10 test bodies (all from `ports.rs`, tokenized and compared as token sequences to be rustfmt-insensitive): all 10 token-identical. **3. Public API.** Built `cargo doc` for both crates at 35f0b8d in a throwaway worktree (`git worktree add --detach … 35f0b8d`, removed after). 140 pages each side. Partitioned by path depth: exactly-two-component paths (`crate/item.html`, i.e. crate-root pages) are 68 = 68 and byte-set identical (`diff` empty). The 72 deeper pages per side are also equal in count; the eight that moved are the ones the dev names (`workspace/{external,index,record}/*` and `rename/warnings/fn. contains_word.html`). Confirmed `workspace` (`mod workspace;`, no `pub`) and its four submodules (`mod external;` / `index` / `record` / `update;`, all bare `mod`) are private in `vlog_semantic/src/lib.rs` and `workspace/mod.rs`; confirmed `rename` and `rename::warnings` are likewise private `mod` in `vlog_refactor/src/lib.rs` and `rename/mod.rs` — none of the eight moved pages was ever reachable by a public path. `cargo test -p lucisv_server --no-fail-fast` run directly (not just as part of the workspace run): 1435 + 85 + 3 passed, 0 failed, confirming both dependent crates compile and behave unchanged. **4. Behaviour, independently.** Built `--release -p lucisv` in this worktree and in the throwaway 35f0b8d worktree. - `--stdout` over all 860 corpus files (own script, per-file stdout/stderr/ exit-code compare, not the dev's harness): `files=860 stdout_differing=0 stderr_differing=0 exit_code_differing=0 exit0=854 exit_nonzero=6` — matches the README's line exactly. - `lucisv check .` over `corpus/` with both binaries: 7 978 lines each, exit 2 both, `cmp` byte-identical. - Before touching opentitan: `git -C …/opentitan status --porcelain` showed exactly the three expected pre-existing modifications (`hw/ip/aes/dv/tb/ tb.sv`, `hw/top_darjeeling/ip/ast/rtl/ast.sv`, `hw/top_earlgrey/ip/ast/ rtl/ast.sv`). `lucisv check hw` with both binaries: 225 lines each, exit 2 both, `cmp` byte-identical. After: `git status --porcelain` showed the same three files and nothing else — `check`/`--stdout` are read-only here, confirmed, not just assumed. No CRITICAL. **5. Size rule.** Own brace-matching line-counter (not `census.py`), production = non-blank, non-`//`-only, outside `#[cfg(test)]`. All 23 new files: exact match to the README's per-file "prod" column, e.g. `bind/ item.rs` 410, `ports/add.rs` 432, `workspace/update.rs` 280 — except `rename/mod.rs`, where this script counts 360 against the README's 362 (a 2-line discrepancy from a heuristic difference in how a doc-comment/blank boundary is categorized, not a real content difference — the line-multiset and signature census above already prove the content match exactly). Largest file confirmed `ports/add.rs` at 432, nothing over 600. Independently re-measured all 8 pinned longest functions by name (brace-depth walk from each `fn` line, tracking paren depth so a multi-line signature doesn't fool the brace search): `bind_stmt` 148, `bind_item` 117, `bind_expr` 116, `fingerprint` 86, `merge` 83, `facts_from_analysis` 68, `locate` 47, `collect_occurrences` 43 — plus `instantiation_edits` 122, `header_edits` 57, `disconnection_edits` 64 in `ports/`. All exact matches to the README's before-and-after census; nothing over 150; no function split. `rename/scope.rs` (69 lines) judged: a module, not a fragment. It is one complete, self-contained abstraction — the `Scope` struct's full field list plus every one of its ten methods (`build`, `len`, `path`, `text`, `sources`, `file_id`, `index_of`, `analysis`, `cached`, `index`) and the one free function (`display`) that reads it — not an arbitrary slice of a bigger thing. Its own one-sentence doc ("the in-scope files, the index built from them, and the analyses computed so far") has no "and" joining unrelated concerns; the "and" in it lists parts of one data structure. Recommend leaving it as is — merging it back into `mod.rs` would put a distinct, nameable abstraction back in a file about something else ("the rename itself"), which is the failure mode §28 is meant to prevent, just because it is short. Under-fragmentation would look like this file being *split further* (e.g., pulling `display` out alone); nothing here suggests that. Two LOW "and"-file observations for the lead, neither blocking: `ports/ list.rs`'s own description reads "editing a comma-separated list *and* finding its parentheses" — two verbs, though both are text-level utilities the three planners share, so the coupling argument holds. `workspace/ index.rs` bundles "what a built index answers" with "plus … `build`, `index_order`, `IndexBuilder`" — read queries and construction in one file; defensible (both are "the built-index API surface") but is the one file of the 23 whose one-sentence test needs a "plus" to hold together. Neither is over any size threshold (236 and 226 lines) and neither is a behaviour or purity concern. **6. Docs.** README has all six required sections (Review correctly left for the lead). Spot-checked 8 line ranges (2 per module map) from the pristine file against the new tree by content, not just line-number arithmetic: `bind.rs:1654` (`bind_stmts`/`bind_stmt`) → `bind/stmt.rs`, `bind.rs:2008` (`bind_opt_expr`/`bind_dims`) → `bind/expr.rs`, `workspace.rs:300` (`build`'s doc) → `workspace/index.rs`, `workspace.rs:1688` (`ExternalTarget`) → `workspace/external.rs`, `ports.rs:740` (`struct Directive`) → `ports/add.rs`, `ports.rs:1038` (`locate_port`) → `ports/remove.rs`, `rename.rs:523` (`fn warnings`) → `rename/warnings.rs`, `rename.rs:232` (`Scope::build`) → `rename/scope.rs` — all 8 found at the claimed destination, content-identical modulo the logged `pub(super)`/rewrap changes. **Severity summary:** no CRITICAL, no HIGH. Two LOW "and"-file notes above (`ports/list.rs`, `workspace/index.rs`) and one LOW measurement-noise note (`rename/mod.rs` prod count, 360 vs 362 — not a content difference). `rename/scope.rs`'s size is judged intentional, not a smell. **Verdict: PASS.** ## Review **2026-09-02 — lead.** Accepted; merged onto master as the last lane of §28. The two crates that model meaning are now readable in the order they run: `bind/` walks items, declarations, classes, covergroups, statements, assertions and expressions in separate files under one `Binder`; `workspace/` separates the record a file contributes from the tables, the incremental update and the overlay; `ports/` is one file per refactoring, which is the honest cut the code supports rather than the sketch's `plan/execute/warnings`; `rename/` separates the rename from the crate-wide `Scope` and the warning scans it had grown. `facts.rs` and `FACTS_FORMAT` untouched, as a pure move must. Proof: every per-binary count identical, the `lucisv check` finding lists byte-identical across corpus and opentitan (the semantic proof the formatter's byte-identity cannot give), signature and multiset census done by the dev and redone by QA, private-only page relocations. `rename/scope.rs` stays where it is for now with its doc saying it is not rename-specific — promoting it to the crate root behind a re-export is a one-move follow-up if a second refactoring ever needs to import it without going through `rename`. QA's two LOW "and" notes on `ports/list.rs` and `workspace/index.rs` are left as filed; both files are under 250 lines and the "and" is between two halves of one job.