diff --git a/TODO.md b/TODO.md index fa16396..e9aed90 100644 --- a/TODO.md +++ b/TODO.md @@ -3014,3 +3014,200 @@ module names, `README.md`'s architecture section updated. Runs AFTER 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 + +## 29. Small items, round 1 (planned 2026-09-02) — `Scope` promotion, the macro-word census for rename warnings (§2.9-18 server half), `lucisv check --rules-doc` (§2.9-5, M12's second half) + +Three independent items in one lane; disjoint from §30's files. Dev +Opus 5, QA Sonnet 5. Feature README: `docs/features/macro-word-census/ +README.md` (Goal names all three; Work log per item). + +**29.1 `vlog_refactor::rename::scope` → crate root.** `rename/scope.rs` +(69 production lines) holds `Scope`/`Analysis`/`display` — the in-scope +files, the index built from them, the analyses computed so far — and its +own `//!` says nothing in it is rename-specific; `ports/`, `references` +and `instantiate` reach it through `rename`. Pure move: `git mv +crates/vlog_refactor/src/rename/scope.rs crates/vlog_refactor/src/scope.rs`; +`lib.rs` gains `mod scope;` (crate-private); `rename/mod.rs` keeps +`pub(crate) use crate::scope::{display, Scope};` so every in-crate path +(`crate::rename::Scope`, `super::scope::…` in `warnings.rs`) still +resolves — change the importers to `crate::scope::` where you touch +them anyway and leave the re-export for the rest; the `//!` loses its +"it lives under `rename` because …" sentence. Proof: `cargo test -p +vlog_refactor` counts identical (86/5/52/63/0), workspace green, no +public path changes (`Scope` is `pub(crate)`). + +**29.2 Macro-word census, and the rename warning it enables.** Today +`FileFacts::words` (§24) is one sorted list of every identifier-shaped +word in a file, plain tokens and raw text (macro invocations, directive +lines, attributes) folded together, so it cannot say *where* a word was +seen. Rename's `macro_use_warnings` (engine, pinned in §27 by +`a_file_whose_only_relationship_to_the_name_is_a_macro_argument_is_warned_about`) +only runs over the files `Workspace::rename_sources` hands the engine, +and a file whose only relationship to the name is a macro argument is +in none of its rungs — the lead's ruling in `docs/topo.md` §2.9-18: no +`files_mentioning` rung (untagged, so it would re-read every file +spelling `clk` and bring back the 2.5–3.0 s `prepareRename` cost), but a +separate census the server can *warn from without reading*. Plan: +(a) `vlog_semantic::words`: alongside `harvest`, a `harvest_raw(tokens) +-> Vec` (sorted, deduped) of the words `raw_words` finds inside +macro-invocation `Ident`s, `Directive` and `Attribute` tokens only — +factor the raw-token match out of `harvest` so the two cannot drift; +pin `harvest_raw ⊆ harvest` and that a word seen only as a plain +identifier is absent from it. (b) `FileFacts::macro_words: Vec` +written and read beside `words` (tag `M`), `FACTS_FORMAT` 16 → 17 with +the reason in the doc comment (a 0.33.0 store has no `M` records and +would answer "no file names it in a macro"), `fingerprint` unchanged +(the census is derived from the same text). (c) `WorkspaceIndex:: +files_naming_in_macros(name) -> impl Iterator` by binary +search, the twin of `files_mentioning`; `update_file`/`remove_file`/ +`absorb` carry the field the way they carry `words` (they do, if it +lives in `FileFacts`; say so). (d) `lucisv_server/src/rename.rs`: after +the engine returns `(edit, warnings)`, append one warning per file in +`files_naming_in_macros(old_name)` that is **not** among the paths the +engine was handed (`rename_sources` result) and not an open buffer: +"`old` also appears inside a macro invocation in , which this +rename did not read; check it by hand — a macro argument cannot be +edited." Same for `prepareRename`? No — a prepare answers a range, not +warnings. (e) Pins: `vlog_semantic` unit tests for `harvest_raw` and the +codec round-trip (FACTS 17 record with and without `M`); a server test +with three files — `sub.sv` declares `wire sig`, `top.sv` uses `u.sig`, +`far.svh` contains only `` `uvm_info("x", $sformatf("%0d", sig), UVM_LOW) `` +and nothing else naming `sub` — asserting the rename edits `sub.sv` and +`top.sv`, that `far.svh` is not in `rename_sources`, and that the +returned warnings name `far.svh`; a control where `far.svh` also +instantiates `sub` (then it IS a source and the engine's own warning +appears exactly once — no double warning). (f) `docs/topo.md` §2.9-18 +struck by the lead; the refactor-rename and semantic-lints-on READMEs +amended; index-persistence README notes format 17. + +**29.3 `lucisv check --rules-doc`.** `vlog_linter::rules_markdown()` has +existed since lint-rules-2 with only an example binary +(`crates/vlog_linter/examples/rules_markdown.rs`) to print it. Plan: +`args.rs` — `Options::rules_doc: bool`, parsed from `--rules-doc`, +listed in `check_flag_scopes` as lint-only, documented in the usage +text under `lucisv check`; `main.rs::run_check` — when set, print +`rules_markdown()` to stdout and return exit 0 before `select_rules` +and before any path is gathered (paths given alongside are an error: +"--rules-doc takes no files"); a `crates/lucisv/tests/` case running +the binary with `--rules-doc` and asserting the first line and that +every registered rule name appears once; if `docs/lint-rules.md` (or +the docs-site rules page) is checked in, a drift test that it equals +the generated text, and regenerate it in this round; the example +binary's doc comment updated (or the example removed — the lead +prefers removed, the flag is the tool now). `docs/topo.md` §2.9-5 +struck by the lead; the lint-rules-2 README's handshake ticked. + +Files: crates/vlog_refactor/src/{lib.rs, scope.rs (moved), +rename/mod.rs, rename/warnings.rs, ports/*.rs, references.rs, +instantiate.rs (imports only)}, crates/vlog_semantic/src/{words.rs, +facts.rs, workspace/{mod,index,update,record}.rs} + tests, +crates/lucisv_server/src/rename.rs (+ state.rs only if +`rename_sources` must expose its path set — prefer returning it from +the existing function rather than a new rung) + tests/e2e.rs, +crates/lucisv/src/{args.rs, main.rs} + tests, crates/vlog_linter/ +examples/rules_markdown.rs (removed), docs/lint-rules.md (regenerated +if present), docs/features/macro-word-census/README.md (new), +amendments in refactor-rename / semantic-lints-on / index-persistence / +lint-rules-2 READMEs, TODO §29. Runs in parallel with §30 (disjoint +files; topo: §29 touches the FACTS handshake, §30 the AST — no shared +edge). +- [ ] 29.1 `Scope` at the crate root, counts identical +- [ ] 29.2 `harvest_raw` + `FileFacts::macro_words` (FACTS 17) + + `files_naming_in_macros` + the server warning; the three-file pin + and its control +- [ ] 29.3 `--rules-doc`; usage text; tests; example removed; + `docs/lint-rules.md` regenerated if present +- [ ] Gates: fmt/clippy/`cargo test --workspace`; corpus gate 814/820; + store measurement (+bytes for `M` on corpus and opentitan, expect + small); opentitan read-only sweep unchanged +- [ ] QA: rename of `clk` in an opentitan IP with the server, timing + before/after (must not regress; the warning list must name only + files outside the source set), the pins re-derived + +## 30. Small items, round 2 (planned 2026-09-02) — M13: modport method prototypes, `const` tf arguments, unnamed DPI formals + +Three grammar arms `docs/coverage_gaps.md` M13 lists as "each a small +grammar arm"; zero corpus population, so the value is that an interface +or DPI file written by the book opens without an error node. Dev Opus 5, +QA Sonnet 5. Feature README: `docs/features/interface-dpi-arms/README.md`. + +**30.1 Modport method prototypes** (IEEE 1800-2017 §25.5.4, +`modport_tf_port ::= method_prototype | tf_identifier`). Today +`parse_modport` (`parser/module.rs`) reads `import`/`export` followed +by a name list; `import task drive(int x)` errors at `task`. Plan: +(a) `ast/module.rs`: `ModportPort` gains `prototype: Option>` where `TfPrototype { kind: TfKind (Function|Task), ret: +Option, name: Name, ports: TfPorts, after_kw/before_name/ +before_args comment slots }` — one struct, since a modport prototype is +a header with no body; `names` is empty when `prototype` is `Some`. +(b) `parser/tf.rs`: factor the header parse — keyword, lifetime +qualifiers, return type, name, `parse_tf_ports` — out of +`parse_function_decl`/`parse_task_decl` into `parse_tf_header(kind) -> +PResult`-shaped code both call (a pure refactor inside +the file; counts unchanged), and call it from `parse_modport` when the +token after `import`/`export` is `task` or `function`; the prototype +ends at the `,`/`)` of the modport list, never at `;`. Comments in +every new gap get an owner (the comment-slots rule); a `/*c*/` before +`task`, before the name, inside `()` are the cases. (c) `format/ +module.rs`: print `import task name(args)` through the same header +printer `routine.rs` uses (factor it the same way), one prototype per +list element, alignment untouched. (d) `bind/item.rs`: the prototype's +name is a use (`Target::Lexical`, resolving to the interface's task or +function) and its formals are declared in a `ScopeKind::Block` opened +for the prototype so they neither leak nor go unbound; types bind as +types. (e) `tests/spans.rs` arm; parser tests; `interfaces.cases` +entries (import and export, task and function, with and without +formals, mixed with `input` groups, comments); a semantic test that +hover on `drive` in the prototype lands on the interface's task. + +**30.2 `const` task/function arguments.** `parse_tf_ports` already +accepts `const ref` (tf.rs:177, the corpus shape). Verify with a probe +whether anything M13 meant is still missing — `const ref int q[$]` +formats today; a bare `const` direction is not legal (LRM 13.5.2 only +has `const ref`) — and close the item with a pinned case rather than +code, unless the probe finds a real gap (then fix it in the same arm). +Correct the M13 row in `docs/coverage_gaps.md` either way. + +**30.3 Unnamed DPI formals** (§35.5.5: `import "DPI-C" function int +f(int, chandle);` — a formal may omit its name in a DPI import +prototype only). Today `parse_tf_ports` does `expect_name` and errors +at `,`. Plan: (a) `parse_tf_ports(allow_unnamed: bool)` — the DPI path +(`parse_dpi_import` → `parse_function_decl(Some(dpi))`/`parse_task_decl`) +passes `true`, every other caller `false`; when allowed and the token +after the type is `,` or `)`, the formal has **no name**. (b) AST: keep +`TfArg::name: Name` and use the crate's existing empty-name convention +(`foreach (arr[, j])`, `declare` ignores an empty name) — `name.text` +empty, `name_span` empty — rather than an `Option` that would touch +every consumer (formatter, binder, ports refactoring, signature help); +document it on the field. (c) Formatter: an unnamed formal prints its +direction and type only; `tf_args` alignment treats the missing name +as zero width. (d) Binder: `declare` already ignores empty names — pin +it. (e) Signature help (`lucisv_server/src/signature.rs`) shows the +type alone for such a parameter — check and pin. (f) Cases in +`dpi.cases` (or the file DPI imports live in): `int`, `chandle`, +`logic [7:0]`, a mix of named and unnamed, `input int` unnamed, and +the negative: an unnamed formal in a non-DPI function is still an +error naming the position. + +Files: crates/vlog_parser/src/{ast/module.rs, ast/decl.rs (TfArg doc), +parser/module.rs, parser/tf.rs, parser/item.rs}, tests/spans.rs + +parser tests, crates/vlog_formatter/src/format/{module.rs, routine.rs}, +tests/cases/{interfaces.cases, dpi.cases or where DPI lives}, +crates/vlog_semantic/src/bind/item.rs + tests, crates/lucisv_server/ +src/signature.rs (check + pin only) + tests, docs/coverage_gaps.md +(M13 row), docs/features/interface-dpi-arms/README.md (new), +amendments in interfaces / dpi-export READMEs, TODO §30. Runs in +parallel with §29. +- [ ] 30.1 modport prototypes end to end (parse, format, bind, spans, + hover pin) +- [ ] 30.2 `const` arguments verified and pinned (or fixed), M13 row + corrected +- [ ] 30.3 unnamed DPI formals (parse behind the DPI flag, format, + bind, signature help pin, negative pin) +- [ ] Gates: fmt/clippy/`cargo test --workspace`; `cargo test -p + vlog_formatter`; corpus 814/820 byte-identical to 0.33.0 (zero + population, so nothing may move); opentitan read-only sweep + unchanged +- [ ] QA: hand-written interface + DPI files in every listed shape, + idempotent, comments kept; the negative pin; sweep unchanged +