diff --git a/CLAUDE.md b/CLAUDE.md index b38ef83..eebf840 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -58,8 +58,17 @@ Measured 2026-09-02 (production lines): `vlog_parser/src/parser.rs` `vlog_semantic/src/bind.rs` 2 378, `vlog_semantic/src/workspace.rs` 1 975, `vlog_refactor/src/ports.rs` 1 778, `lucisv_server/src/completion.rs` 1 716 — thirteen files over 800. -These are decomposition work (TODO §28), and every one of them is where -feature lanes collide, which is the other reason to split them. +Every one of them was where feature lanes collided, which is the other +reason to split them. **Decomposed the same day by TODO §28** (four +lanes, pure moves, output byte-identical): `parser/` (19 modules) and +`ast/` (8), `format/` (15), `server/` (11 + tests) and `completion/` +(6), `bind/` (8), `workspace/` (5), `ports/` (6), `rename/` (4). Measured +after the round (non-blank, non-comment, outside tests): two files over +600 — `lucisv_server/src/perf.rs` 895 (one cohesive subsystem; the reason +is in the decomposition-server README) and `vlog_parser/src/lexer.rs` +762 — and 183 under it. Nothing new may push a file back over the +thresholds: a dev adding to a file near 600 puts the code in a new +module. ## Rust standards diff --git a/TODO.md b/TODO.md index a662ce1..fa16396 100644 --- a/TODO.md +++ b/TODO.md @@ -3008,8 +3008,9 @@ module names, `README.md`'s architecture section updated. Runs AFTER - [x] Lane C `lucisv_server` — server/ and completion/ module maps; tests out of server.rs first; counts; e2e unchanged; vsix smoke - [x] Lane D `vlog_semantic` + `vlog_refactor` -- [ ] Docs: decomposition README, topo §3.1, README.md architecture -- [ ] QA per lane: `cargo test` counts equal to the lane's baseline, +- [x] Docs: decomposition README (one per lane: decomposition-{parser, + formatter,server,semantic}), topo §1.3/§3.3, README.md architecture +- [x] QA per lane: `cargo test` counts equal to the lane's baseline, corpus + opentitan `--stdout` byte-identical (0 differing), no public path changed (`cargo doc` item list diffed against the baseline), longest-function census reported before/after diff --git a/docs/topo.md b/docs/topo.md index aba4fb3..71561d8 100644 --- a/docs/topo.md +++ b/docs/topo.md @@ -144,7 +144,7 @@ what a change on the pointed-to side must not silently break. - `vlog_parser` depends on nothing. It is also the **highest-contention module in the workspace**: six crates depend on it, five consume the AST (the CLI takes only `LineIndex`/`TextRange`), and two of those match it - exhaustively — `vlog_formatter/src/format/` and `vlog_semantic/src/bind.rs` + exhaustively — `vlog_formatter/src/format/` and `vlog_semantic/src/bind/` — with `vlog_parser`'s own `tests/spans.rs` as a third exhaustive walker. `vlog_linter`, `vlog_refactor` and `lucisv_server` walk it with catch-all arms. See §3.3. @@ -179,12 +179,16 @@ CLAUDE.md invariant #4 territory, see §3.3); `fence.rs` (format-off regions + `align.rs` (alignment inference). `format_source` = parse → format → verify; an error means emit nothing. -**`vlog_semantic`** — `bind.rs` (AST → scopes/symbols/references) → +**`vlog_semantic`** — `bind/` (AST → scopes/symbols/references; since +2026-09-02 `mod` = the `Binder`, then `item`, `decl`, `class`, `cover`, +`stmt`, `sva`, `expr`) → `model.rs`; `resolve.rs` (the lexical walk; misses become `ExternalCandidate`/`InheritedCandidate` carrying candidate paths); `scan.rs` (residual text-scanning for the one span the parser doesn't carry — `DataType`; shrinks to zero when open handshake §2.9-2 lands); -`workspace.rs` (`WorkspaceIndex`: units, members, defines, instantiation and +`workspace/` (`mod` = the tables, `index` = queries and `build`, `update` = +incremental update and `fingerprint`, `record` = the `FileFacts` read-off, +`external` = the overlay; `WorkspaceIndex`: units, members, defines, instantiation and inheritance edge tables, incremental `update_file`/`remove_file`, reference postings, `files_spelling`, batch `absorb`, declaration `DeclLines`, `fingerprint`); `facts.rs` (`FileFacts` codec for the persistent cache; @@ -208,10 +212,12 @@ lazy `semantics()`), `visit.rs` (the item/statement walk), `waiver.rs`, table for the three semantic rules), `naming.rs`, `rule_docs.rs` (`rules_markdown()` — docs generated from the registry). -**`vlog_refactor`** — `rename.rs` (the `Scope` cache + occurrence walk — +**`vlog_refactor`** — `rename/` (`mod` = the rename, `scope` = the crate-wide +`Scope` cache, `warnings` = the text scans, `tests` = the parity suite; also the engine of `references.rs::find_references`; publishes the cheap `prepare_rename_here`/`rename_name_at` selectors whose parity with the full -engine is test-pinned), `ports.rs` (add/remove/propagate plus +engine is test-pinned), `ports/` (one file per refactoring: `find`, `add`, +`remove`, `propagate`, `list`; `port_action_modules`/`enclosing_module`, the names the server uses to bound the input set), `instantiate.rs` (plans + rendering; the one layout both plain and snippet spellings go through), `check.rs` (whole-edit verification: @@ -672,15 +678,15 @@ ownership explicitly. | choke point | owner (feature) | consumers | the rule | |---|---|---|---| -| `vlog_parser/src/ast/` | the grammar lane collectively | formatter, semantic, linter, refactor, server, `tests/spans.rs` | A new variant costs, at minimum: a `format/` arm, a `bind.rs` arm, a `spans.rs` arm. `visit.rs` is catch-all for compilation only — a variant containing items/statements still needs an arm there or AST lint rules never see inside it. Prefer **additive fields / parallel vectors** over changing vector element types — that is why `ListDirective` sits beside the lists instead of inside them (two rounds chose it independently for blast-radius reasons). | +| `vlog_parser/src/ast/` | the grammar lane collectively | formatter, semantic, linter, refactor, server, `tests/spans.rs` | A new variant costs, at minimum: a `format/` arm, a `bind/` arm, a `spans.rs` arm. `visit.rs` is catch-all for compilation only — a variant containing items/statements still needs an arm there or AST lint rules never see inside it. Prefer **additive fields / parallel vectors** over changing vector element types — that is why `ListDirective` sits beside the lists instead of inside them (two rounds chose it independently for blast-radius reasons). | | `vlog_formatter/src/verify.rs` | safety-net | every formatter feature; the CLI's exit-2 promise | CLAUDE.md invariant #4. Never widen a normalization without masked-corruption attack tests; the standing pattern is "untouched + rejection tests anyway". The single widening in history is macro-items' backtick-`Ident` arm in `normalize` — which produced lucisv's one real corruption; its repair, `trim_lines_outside_strings`, is a *narrowing*, and the pattern to copy: the widening shipped without attack tests, the fix shipped with them. `line_starts_inside_string` is the one definition of "which line breaks are data" — both `format.rs` and `verify.rs` must read it. | | `vlog_formatter/src/fence.rs` | format-fences | range-formatting, shared-fence-filter, CLI `--fix` (`lucisv/src/lint.rs`), server quick fixes (`lucisv_server/src/lint.rs`) | `protected_regions`/`is_protected` are the **only** supported way to ask "may an automatic edit touch these bytes". One answer, **two** front ends — and `vlog_linter` is deliberately not one of them (it stays fence-blind; the filter lives in each front end). Open gap: no `Class` arm in `scan_nested` (§2.9-3). | | `lucisv_server/src/pairs.rs` | editor-scopes | documentHighlight, missing-closer diagnostics, scopePairs rainbow, folding, completion gates, on-type indent, inline-templates, expand-selection (`selection.rs`) | The `RULES` table + no-closer guard list is shared truth. Any keyword added to/removed from `token.rs` requires re-checking it (a word that stops being a keyword silently stops being matched). | | `lucisv_server/src/server/` | lucisv-server; amended by cancel-request, change-debounce, scan-interleave, index-scope, verbose-timing | every request/notification and every rebuild trigger | One ordered loop owns all mutable server state. A startup scan may publish a prefix and answer queued work between files; a request queued behind a rescan trigger is held until that rescan lands, and its cancel travels with it. Never make the distinction time-based: machine load must not change which index a request sees. Verbose timing may observe each wrapper/lifecycle but must be entirely silent when off and must not move protocol ordering. The queue thread only forwards protocol messages and must never parse. | | `lucisv_server/src/state.rs` | lucisv-server; amended by filelist, index-scope, scan-interleave, indexing-ux, incremental-index, index-persistence, hover-line-index, large-file-mode, one-parse (`Document.tree`), editor-settings + folders-and-config (`set_client_settings`/`change_roots`), include-nav (the include graph), completion-core (candidates), file-watching, interactive-latency (`first_token_reaching`/`first_token_from`), refactor performance fan-outs | every handler | `Workspace` is immutable through request handlers except the interior-mutable four-entry/8 MiB `FileView` cache. The scope ladder (filelist > `index.scope: "workspace"` > folder-scope at shipped depth 2; a rootless session never climbs and always reads its own directory flat) and open-buffer overlay are contracts. `Scan` has whole/widen shapes but one step/finish path; index/candidate/include prefixes publish together. `module_sources`, `rename_sources`, and `include_sources` must remain supersets of what their engines can edit/refuse over; `rename_sources` falls back to `sources()` when an ambiguous posting prevents a proven bound. `update_one` and a completed scan must equal a fresh build (`fingerprint`). Handlers reading `doc.text` instead of tokens/tree must check `doc.large`. | | `lucisv_server/src/settings.rs` | editor-settings | folders-and-config, indexing-ux, index-scope, index-persistence, inline-templates, will-save-wait-until, filelist, large-file-mode | One parser for both doors (push and pull, via `from_section` re-wrapping). Every key drops garbage independently; defaults that are not "silence" (1 MiB cap, log on, persist on, 4 MiB large-file threshold) are hand-written in `Default`. `set_client_settings` returns whether a reindex is owed — new keys must decide that question explicitly. | -| `vlog_semantic/src/workspace.rs` (+ `facts.rs`) | workspace-index; extended by incremental-index, index-persistence, index-scope, hover-line-index, scan-interleave, refactor-rename performance | server state, hierarchy/lens/type-hierarchy, refactor, completion | Determinism (same inputs → same index, any order), the `paths` spelling coupling with `resolve.rs`, `FACTS_FORMAT` bumped on any codec change (currently 4), edge/posting tables built by the same lifted walks the engines use. `DeclLines` must round-trip and participate in `fingerprint`; `absorb` must equal one build over the resulting record set; `files_spelling` must continue to include unresolved non-empty external/inherited paths or rename loses its dangling-use refusal. | -| `vlog_refactor/src/rename.rs` | refactor-rename; shared by references-nav and the performance wave | server rename/prepareRename/references and port refactor verification | `Scope` remains the whole-scope authority and `collect_occurrences` the one rename/references walk. The fast `prepare_rename_here` answer/refusal and `rename_name_at` target are parity contracts, not alternate semantics. Any new refusal must be expressible on the fast path or force a deferral; any new occurrence shape must be reflected in the server fan-out or trigger its all-sources fallback. | +| `vlog_semantic/src/workspace/` (+ `facts.rs`) | workspace-index; extended by incremental-index, index-persistence, index-scope, hover-line-index, scan-interleave, refactor-rename performance | server state, hierarchy/lens/type-hierarchy, refactor, completion | Determinism (same inputs → same index, any order), the `paths` spelling coupling with `resolve.rs`, `FACTS_FORMAT` bumped on any codec change (currently 4), edge/posting tables built by the same lifted walks the engines use. `DeclLines` must round-trip and participate in `fingerprint`; `absorb` must equal one build over the resulting record set; `files_spelling` must continue to include unresolved non-empty external/inherited paths or rename loses its dangling-use refusal. | +| `vlog_refactor/src/rename/` | refactor-rename; shared by references-nav and the performance wave | server rename/prepareRename/references and port refactor verification | `Scope` remains the whole-scope authority and `collect_occurrences` the one rename/references walk. The fast `prepare_rename_here` answer/refusal and `rename_name_at` target are parity contracts, not alternate semantics. Any new refusal must be expressible on the fast path or force a deferral; any new occurrence shape must be reflected in the server fan-out or trigger its all-sources fallback. | | `vlog_parser/src/token.rs` keyword table | completion-core (`KEYWORDS` export) | lexer, pairs.rs, editor grammar (test-locked), completion | Adding a keyword = lexer change + `pairs.rs` re-check + a hand edit to the grammar (`tests/grammar.rs` names the missing word) + potentially `verify.rs`-adjacent behavior. dv-statements added `randcase`/`let` to `is_keyword` and recorded it as shared with the adjacent lexer-cleanup round — the precedent for treating this file as coordinated even between back-to-back rounds. | | `editors/vscode/package.json` | editor-packaging | editor-settings, editor-scopes (colour ids), editor-snippets, index-persistence, verbose-timing, platform-vsix, marketplace-page | Settings/colour/snippet ids referenced from `extension.js` or the server must move in lockstep; mismatches are *silent* (VS Code ignores unknown ids). `lucisv.verbose` is special: it changes a spawn argument and therefore restarts the server instead of flowing through the ordinary settings push. Version number is one of the four version files. | | `tools/release.sh` artifact names | release-prep / editor-platform-vsix | ci-release (`prune_release_assets.sh`), `audit_artifacts.sh`, extension `bin/` layouts | Renaming a `.vsix` is a two-file change (`release.sh` + `prune_release_assets.sh`'s suffix list); renaming a per-triple binary is a two-file change (`release.sh` + `audit_artifacts.sh`, which skips `.vsix` and hard-fails on an unknown binary name). Get the wrong pair and the release fails by name. |