Files
lucisv/docs/features/lint-rules-2/README.md
T

661 lines
36 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# lint-rules-2
## Goal
Finish the practical rule set `linter-core` started, inside `vlog_linter`
only. Three things ship: (1) `visit.rs` now walks **class bodies**, which
closes the handshake `docs/features/classes/README.md` filed — the four
AST-walking rules stopped at `endclass` and now do not; (2) five new rules —
four **naming** rules with built-in style presets and no regex dependency,
plus `wire-reg-mixup`, the SystemVerilog-ness decision the linter-core round
parked; (3) `vlog_linter::rules_markdown()`, a rule reference generated from
the registry so the docs cannot drift from the rules (Verible's
`--generate_markdown`, ruff's generated rule pages). Everything slots into the
existing registry, so `lucisv check`, `--select`/`--ignore` and `lucisv-server`'s
diagnostics pick the new rules up with **zero wiring** — verified live, not
assumed.
## Assumptions
- **A class body is an ordinary scope.** `ItemKind::Class`'s `items` are
walked exactly like a module's, so every AST rule sees class properties,
class localparams, class typedefs and class methods. Nothing about a rule
is class-aware; the walk is what changed.
- **Naming presets are fixed per rule this round.** Verible spells its
conventions as RE2 patterns and lets you override them; lucisv spells the same
conventions as character-class predicates (`src/naming.rs`) and does not
let you override them yet. Per-rule style configuration needs the `lint`
key in `lucisv.toml`, which is still parked (see Handshakes).
- **Escaped identifiers (`\my$name`) are exempt from every naming rule.**
Their whole purpose is to carry characters no convention allows.
- **A name's style is judged on ASCII.** A non-ASCII identifier fails
`lower_snake_case` etc. and is reported. Verilog identifiers are ASCII by
the standard (outside escaped ones, which are exempt), so this has no
practical population.
- **`wire-reg-mixup` decides SystemVerilog-ness from the file extension
alone** — `.sv`/`.svh`, compared case-insensitively. Not from content, not
from a config key, and never for a buffer with no name: `lucisv check -`
without `--stdin-filename` is silent. This is the whole SV-ness decision,
deliberately: any content heuristic ("it uses `logic`, so it's SV") would
make the rule's own subject its input.
- **`wire-reg-mixup` reads tokens, not the tree**, so a file that does not
parse is still checked, and a `reg` inside a `constraint`/`covergroup`
verbatim block is still seen. A `reg` inside a `` `define`` body is *not*:
a directive is one `TokenKind::Directive` token and its body is never
lexed as keywords. Consistent with lucisv's no-preprocessing stance.
- **`rules_markdown()`'s "Fix" column is declarative metadata**
(`Rule::fix()`), not derived from running the rules. A unit test probes the
rules against a file that trips every fixable one and asserts the two
agree, which catches the drift direction that matters (a rule gains a fix
and forgets to declare it) for any rule that fires on that probe.
## Handshakes
**Consumed** (all unchanged from `linter-core`)
- `vlog_parser`: `ast::{ItemKind::Class, ClassDecl, ParamPort, Typedef,
TypedefKind, StructType}`, `token::{Token, TokenKind}`, `span::TextRange`.
New this round is only that the class arm of `ItemKind` is now read.
`StructType::kw` is read for the `struct`/`union` word in a message.
- Nothing else. `cargo tree -p vlog_linter` is still `vlog_parser` + std —
**no new dependency**, which is also the naming rules' central design
decision (below).
**Promised**
- Three new public items: `rules_markdown()`, and two new methods on the
`Rule` trait, `default_on()` (defaults to `true`) and `fix()` (defaults to
`None`). Both have defaults, so an out-of-crate implementor of `Rule` — if
there ever is one — is not broken by them.
- `default_rules()` is no longer `all_rules()`: it filters on `default_on()`.
Callers are unaffected (`crates/lucisv` calls `select_rules`,
`crates/lucisv_server/src/lint.rs` calls `default_rules()`); both keep
compiling and keep meaning what they meant.
- Rule *names* are stable API — they appear in users' waivers. The five new
names are `enum-name-style`, `module-name-style`, `parameter-name-style`,
`struct-union-name-style`, `wire-reg-mixup`. Four of the five are spelled
exactly as Verible spells its equivalent, on purpose: a codebase already
annotated `// verilog_lint: waive enum-name-style` is honored by lucisv
unedited.
**Requested of others (not done here)**
- *`crates/lucisv`'s owner (concurrent this round)*: a `lucisv check --rules-doc`
flag that prints `vlog_linter::rules_markdown()` to stdout and exits 0.
One `println!`; no other wiring. Until then the same output is available as
`cargo run -p vlog_linter --example rules_markdown`.
- *config-discovery's owner*: the `lint` key in `lucisv.toml` is what
per-rule naming-style configuration waits on — the shape wanted is
`[lint.parameter-name-style] style = "CamelCase"` picking one of the named
presets, not a regex. Restated from `linter-core`, unchanged.
- No request to `vlog_formatter`, `vlog_semantic`, `lucisv_server` or
`lucisv_core`; none of them was touched.
## Status / TODO
- [x] `visit.rs` walks `ItemKind::Class` bodies — the classes handshake.
- [x] `visit.rs::walk_param_ports` — module **and** class header `#( ... )`
parameter ports, shared by the two parameter rules.
- [x] `src/naming.rs`: `lower_snake_case`, `UPPER_SNAKE_CASE`, `CamelCase`
predicates + escaped-identifier exemption, no regex dependency.
- [x] `parameter-name-style` (default on).
- [x] `enum-name-style` (default on).
- [x] `struct-union-name-style` (default on).
- [x] `module-name-style` (default **off** — see the defaults table).
- [x] `wire-reg-mixup` (default on).
- [x] `Rule::default_on()` + `Rule::fix()`; `default_rules()` filters.
- [x] `rules_markdown()` + golden shape test + "every rule appears" test +
fix-metadata consistency test.
- [x] `examples/rules_markdown.rs` so the reference is renderable today.
- [x] Violating/clean/waived/unused-waiver quartets for all five new rules;
class-body coverage tests for all four original AST rules.
- [x] Corpus baseline re-run, before/after per rule.
- [ ] Per-rule style **configuration** — needs the `lucisv.toml` `lint` key.
- [ ] `lucisv check --rules-doc` — `crates/lucisv`, handshake above.
- [ ] Parked naming rules, listed with their Verible names below.
- [ ] External waiver files — untouched, still `linter-core`'s open item.
## Rules shipped, and where each default comes from
Verible's own rule list was checked against
<https://chipsalliance.github.io/verible/lint.html> rather than recalled.
That check changed two decisions, both recorded honestly below.
| Rule | Default | Verible equivalent | Verible's default |
|---|---|---|---|
| `parameter-name-style` | **on** | `parameter-name-style` | enabled |
| `enum-name-style` | **on** | `enum-name-style` | enabled |
| `struct-union-name-style` | **on** | `struct-union-name-style` | enabled |
| `module-name-style` | **off** | *none — no such rule* | — |
| `wire-reg-mixup` | **on** | *none — no such rule* | — |
**`parameter-name-style`** — accepts `CamelCase` or `ALL_CAPS` for both
`parameter` and `localparam`. Verible's defaults are `parameter_style:
CamelCase|ALL_CAPS` and `localparam_style: CamelCase`, i.e. stricter for
`localparam`. lucisv accepts the union for both, deliberately: matching
Verible's `localparam` default would flag `localparam int ADDR_W` — an
overwhelmingly common spelling — in a rule that is on by default, and lucisv
has no per-rule config key yet to relax it with. When that key lands, the
strict split is the natural first setting to offer. Covers item- and
statement-level declarations and the `#( ... )` ports of module *and* class
headers; `type` parameters are skipped (they name a type, which is Verible's
separate `parameter-type-name-style`, parked).
**`enum-name-style`** — Verible's default pattern is literally
`[a-z_0-9]+(_t|_e)`; lucisv checks `lower_snake_case` ending in `_e` or `_t`,
the same shape. Only `typedef enum` is judged: an anonymous enum has no name,
and *requiring* the typedef is Verible's separate `typedef-enums` (parked).
**`struct-union-name-style`** — Verible requires `lower_snake_case` ending in
`_t` for `struct` and `union`; lucisv checks the same. Only `typedef struct` /
`typedef union`; requiring the typedef is Verible's `typedef-structs-unions`
(parked).
**`module-name-style` ships OFF, which is a deliberate deviation from the
round's brief.** The brief said "snake_case default-on per Verible".
Verible has **no `module-name-style` rule at all** — the documentation check
above is explicit about it, and the nearest things it does have are
`module-filename` (enabled by default, which lucisv already implements) and
`interface-name-style` for the sibling construct. The instruction for this
round was to default a naming rule on *only* where Verible defaults its
equivalent on, and there is no equivalent to inherit a default from, so the
rule ships selectable but quiet: `lucisv check --select module-name-style`.
The rationale in `Rule::doc` cites the lowRISC/Google SystemVerilog style
guide, which does require `lower_snake_case` for module names. Flipping it on
is a one-line change (`fn default_on`) if the lead prefers the brief's
reading; the corpus evidence (**one** finding over 860 files) says it would
be quiet either way.
**`wire-reg-mixup` ships ON, and TODO.md's provenance note for it is wrong.**
TODO §4 lists it under "all from Verible's default set"; Verible has no
wire/reg rule of any kind. It ships on anyway because it is an explicitly
requested seed rule, because the corpus says it is silent on real
SystemVerilog (0 findings over 860 files, see below), and because its
rationale stands on IEEE 1800 (`logic` and `reg` are the same type) and the
lowRISC style guide's "use `logic`" without needing Verible. The README is
the place that record lives; `TODO.md`'s item text is left intact per
CLAUDE.md.
What `wire-reg-mixup` deliberately does **not** flag:
- **`wire` itself.** A net is a distinct kind of object in SystemVerilog too,
and `wire x = expr;` is a perfectly good continuous assignment. Flagging
`wire` would be a house-style opinion, not a mixup.
- **Anything in a `.v`/`.vh` file**, or in a nameless stdin buffer. `reg` is
Verilog's spelling; the rule has no opinion about Verilog.
- **`reg` inside a `` `define`` body**, which is never lexed as a keyword.
- It offers **no fix**, though `reg` → `logic` would be a meaning-preserving
one in SystemVerilog. A `reg` in a `.sv` file is usually a symptom of code
carried over wholesale, and the repair worth making is bigger than the
keyword. A Safe fix is the obvious follow-up if the corpus ever grows a
population for it.
### Parked, with their Verible names
Listed so the next round does not have to rediscover them:
`signal-name-style` (Verible: off by default), `interface-name-style`,
`constraint-name-style`, `macro-name-style`, `parameter-type-name-style`,
`create-object-name-style`, `port-name-suffix`, `dff-name-style`,
`typedef-enums`, `typedef-structs-unions`, `package-filename`.
`genvar-name-style` is parked too and is *not* a Verible rule: genvars are
conventionally one-letter (`i`, `j`) or `gen_*`, and no preset here has
anything useful to say about `i`.
## Why no regex dependency
Verible spells naming conventions as RE2 patterns. lucisv spells them as three
character-class predicates in `src/naming.rs`, roughly 20 lines:
```
lower_snake_case first char [a-z], then [a-z0-9_]
UPPER_SNAKE_CASE first char [A-Z], then [A-Z0-9_]
CamelCase first char [A-Z], then [A-Za-z0-9] (no underscore)
```
The justification CLAUDE.md asks for, in full: every preset anyone actually
uses *is* "these character classes, in this order". A regex crate would buy
user-supplied patterns — which this round explicitly does not ship, because
they need a config key that does not exist — at the cost of the crate's only
real property, that `cargo tree -p vlog_linter` is `vlog_parser` + std. When
the `lint` key lands, the setting it should offer is a **named preset**, not
a pattern: "no option explosion" is TODO §7, and a regex field in a config
file is the option explosion of naming rules. A lower-first `camelCase`
predicate was specified for this round and deliberately **not** written: no
rule needs it, and an unused predicate is an abstraction for a second user
that does not exist.
## Class-body coverage: what changed and what it found
One arm in `visit.rs::items()`:
```rust
ItemKind::Class(class) => items(&class.items, f),
```
plus `walk_param_ports`, which yields the `#( ... )` parameter ports of both
module and class headers and is now what both parameter rules use (previously
`explicit-parameter-storage-type` inlined a module-only version).
All four originally-AST-walking rules were verified firing inside a class
body by test, not by inspection:
| Rule | Class-body test |
|---|---|
| `case-missing-default` | `case_missing_default_reaches_a_class_method` |
| `explicit-parameter-storage-type` | `explicit_parameter_storage_type_reaches_a_class_body_and_header`, `a_class_inside_a_module_is_reached_too` |
| `always-comb-blocking` | `the_always_rules_reach_a_class_body_too` |
| `always-ff-non-blocking` | `the_always_rules_reach_a_class_body_too` |
Honest caveat on the last two: **SystemVerilog forbids an `always` block
inside a class**, so that test pins walk uniformity, not a real-world
population. The tolerant parser accepts the shape and the rules fire on it;
in real code these two rules gain nothing from this change, and the corpus
agrees (both deltas are 0).
## Corpus baseline
860 files (`corpus/`: ibex, opentitan, picorv32, common_cells), read-only,
0.08–0.09 s wall on 10 cores. Byte-identical across repeated runs and between
`--threads 1` and the default pool.
**Before** is this working tree at the start of the round, *not* the number in
`docs/features/linter-core/README.md`: the concurrent classes/parser work has
already moved what parses, so linter-core's 7806/93 no longer reproduces here
(it reads 7875/88 before any of this round's changes). Comparing against a
stale number would misattribute someone else's delta to this round.
| Rule | Before | After | Δ | Files after | Cause of Δ |
|---|---|---|---|---|---|
| `no-tabs` | 7527 | 7527 | 0 | 45 | — |
| `explicit-parameter-storage-type` | 182 | 183 | **+1** | 51 | class-body walk |
| `no-trailing-whitespace` | 85 | 85 | 0 | 7 | — |
| `case-missing-default` | 60 | 65 | **+5** | 21 | class-body walk |
| `parameter-name-style` | — | 39 | **+39** | 11 | new rule |
| `module-filename` | 17 | 17 | 0 | 17 | — |
| `always-ff-non-blocking` | 4 | 4 | 0 | 1 | — |
| `struct-union-name-style` | — | 1 | **+1** | 1 | new rule |
| `always-comb-blocking` | 0 | 0 | 0 | 0 | — |
| `enum-name-style` | — | 0 | 0 | 0 | new rule |
| `wire-reg-mixup` | — | 0 | 0 | 0 | new rule |
| `unused-waiver` | 0 | 0 | 0 | 0 | — |
| **default-rule total** | **7875** | **7921** | **+46** | **96 files** | |
| `module-name-style` (off) | — | 1 | — | 1 | new rule, `--select` |
Read honestly:
- **Nothing was lost.** Diffing the two runs by `(file, rule, byte range)`:
46 findings appear, **0 disappear**. The change is purely additive, which is
what an added walk arm should be.
- **The class-body growth is +6 findings in 4 files, all DV code**, exactly as
predicted. The five new `case-missing-default` are `case` statements in UVM
scoreboards/sequences (`opentitan/hw/ip/uart/dv/env/uart_scoreboard.sv` ×3,
`uart_intr_vseq.sv`, `ibex/dv/uvm/core_ibex/tests/core_ibex_test_lib.sv`);
the one new `explicit-parameter-storage-type` is `localparam BusWidth = 32;`
inside a class in `ibex_icache_scoreboard.sv`. These are new *findings*, not
new *violations* — the code always looked like this; the linter could not
see it.
- **`parameter-name-style`'s 39 are concentrated in testbenches and
picorv32** (14 in `picorv32.v`, 9 in `spiflash.v`, the rest ≤3 per file),
and every one is a `lower_snake_case` constant. Synthesizable lowRISC RTL
is essentially clean, which is the point: it is written to the style guide
this rule encodes.
- **`enum-name-style` scoring 0 was checked, not assumed.** A separate scan
found **166** `typedef enum` names in the corpus's `.sv`/`.svh` files and
**0** of them violate `[a-z_0-9]+(_t|_e)`. The rule is silent because the
corpus conforms.
- **`wire-reg-mixup` scoring 0 was checked the same way**, and this one
needed proving because a silent rule and a broken rule look identical. The
corpus's `.sv`/`.svh` files contain no `reg` at all, while `picorv32.v` is
full of them. Copying `picorv32.v` to `picorv32.sv` and re-running gives
**209** findings; the identical bytes as `.v` give **0**. The extension
gate works and the rule works.
- **`module-name-style`'s single finding** is
`common_cells/src/deprecated/generic_LFSR_8bit.sv` — in a directory named
`deprecated`. That is the entire population over 860 files, which is why
its default costs nothing either way.
## The generated rule reference
`vlog_linter::rules_markdown() -> String` renders the whole registry as one
markdown document — 139 lines today. Shape:
```markdown
# lucisv lint rules
Generated from the rule registry by `vlog_linter::rules_markdown` — do not edit by hand.
A rule marked **default** runs for a plain `lucisv check`; the others need `--select <name>`. ...
| Rule | Default | Fix |
|---|---|---|
| [`always-comb-blocking`](#always-comb-blocking) | **on** | none |
...
| [`module-name-style`](#module-name-style) | off | none |
| [`no-tabs`](#no-tabs) | **on** | safe |
...
## always-comb-blocking
Assign with `=` inside always_comb.
- Default: **on**
- Fix: none
A non-blocking assignment in a combinational block schedules its update ...
```
An index table (name → anchor, default, fix applicability) followed by one
`##` section per rule carrying the capitalized summary, the two metadata
lines and `Rule::doc` verbatim. Nothing is written per rule outside the rule's
own source, which is the whole point: the reference cannot drift.
Three tests hold it:
- `every_registered_rule_appears_with_its_summary_and_doc` — iterates
`all_rules()` and asserts each name, summary and doc text is present. A new
rule that forgets the docs cannot exist.
- `the_document_shape_is_pinned` — the golden test: the first eight lines
verbatim, plus the exact per-rule section template rendered from the first
registered rule and asserted to appear. It pins the *shape*, not the prose,
so improving a rule's `doc` does not churn a snapshot.
- `declared_fix_metadata_matches_what_the_rules_return` — the drift guard
described in Assumptions.
`cargo run -p vlog_linter --example rules_markdown` prints it today; the
`lucisv check --rules-doc` flag is filed as a handshake because `crates/lucisv`
belongs to a concurrent agent this round.
## Zero-wiring claim, verified
The claim that a new rule needs no wiring outside the registry was checked by
running the built binary, not by reading the code:
- `lucisv check corpus/` reports the four new default-on rules with no CLI
change (the table above is that run).
- `lucisv check ... --select module-name-style` runs an off-by-default rule,
and `--select wire-reg-mixup` an on-by-default one; both were used to
produce numbers above.
- `--ignore <new-rule>` and `// lucisv: waive <new-rule>` work by construction
(they key on `rule_by_name`), and each new rule has a waiver test.
- `crates/lucisv_server/src/lint.rs` was read **read-only**: it calls
`default_rules()` with no filtering of its own, so the four new default-on
rules appear as editor diagnostics automatically, and `module-name-style`
correctly does not. `cargo test -p lucisv_server` stays green.
## Work log
### 2026-08-19 — dev
- **Verified Verible's rule set against its documentation instead of
recalling it**, which changed two of the round's stated decisions:
Verible has no `module-name-style`, no `genvar-name-style` and no wire/reg
rule, so `module-name-style` ships default-**off** (deviation from the
brief, argued above) and `wire-reg-mixup`'s "it's Verible-default"
provenance is recorded as incorrect while the rule still ships on. Also
confirmed the exact default patterns now implemented: `[a-z_0-9]+(_t|_e)`
for enums, `lower_snake_case` + `_t` for structs/unions, and the
`CamelCase` / `CamelCase|ALL_CAPS` split for parameters.
- **Named the typedef rules after Verible's two rules** (`enum-name-style`,
`struct-union-name-style`) rather than inventing one `typedef-name-style`.
Rule names are what appear in users' waivers, so matching Verible's
spelling means a `// verilog_lint: waive enum-name-style` already in
vendored code is honored instead of ignored. Typedef *aliases*
(`typedef logic [7:0] x;`) are judged by neither, matching Verible.
- `visit.rs`: one arm for `ItemKind::Class`, plus `walk_param_ports` so the
two parameter rules share one answer for "every `#( ... )` port" —
`explicit-parameter-storage-type` was rewritten onto it, which also gave it
class-header parameter ports (0 additional corpus findings; the class
headers in this corpus are all `type` parameters or typed).
- `Rule` gained `default_on()` and `fix()`, both with defaults so no existing
rule file had to change except the two that offer fixes. `default_rules()`
filters on the former. The one off-by-default rule is what keeps that
mechanism from being a phantom: the registry test asserts the default set
is a strict subset, so it cannot silently become "all of them" again.
- `rules_markdown()` lives in its own module rather than in `registry.rs`:
the registry is about *selecting* rules, and rendering has three tests of
its own.
- **Test counts**: `vlog_linter` 116 unit (was 71) + 55 inline-marker
integration (was 30) + 1 doctest, all green. New: 5 quartets, 4 class-body
reach tests, 3 walk tests, 5 naming-predicate tests, 4 rule-doc tests, 2
registry default-set tests, and the per-rule unit tests in each new rule
file.
- **Gates**: `cargo test -p vlog_linter` green (116/55/1);
`cargo test --workspace` green; `cargo clippy -p vlog_linter --all-targets`
silent; `cargo fmt -p vlog_linter --check` clean. The workspace has one
clippy warning (`methods called from_* usually take no self`) and one
`cargo fmt --check` diff, **both in `crates/vlog_formatter`** — the
concurrent agent's churn, untouched here.
- **Scope**: files changed are `crates/vlog_linter/**`, this README, and
`TODO.md` §4 checkboxes. `crates/lucisv`, `lucisv_server`, `vlog_parser`,
`vlog_formatter`, `vlog_semantic` and `lucisv_core` were not modified;
`lucisv_server/src/lint.rs` was read only.
- **TODO.md §4**: checked the naming-rules item (with the "styles are fixed
presets, configuration waits on the `lint` key" caveat spelled out) and the
`--generate_markdown` item; checked the `wire`/`reg` sub-item of the seed
rules. Left external waiver files, the `lint` config key and "one parse,
two tools" unchecked.
## QA log
### 2026-08-19 — QA
Scope: `-p vlog_linter` only, plus a read-only look at `crates/lucisv/src/lint.rs`
and `crates/lucisv_server/src/lint.rs` for the wiring/fence claims. Did not touch
`vlog_formatter`, `lucisv_server`, `vlog_parser` or `vlog_semantic` (concurrent
this round). All six claims verified; no corpus regression; no preset false
positive/negative found. Two documentation-gap findings, no functional bugs.
**Gates** — `cargo test -p vlog_linter`: 116 unit + 55 inline-marker + 1
doctest, all green, exact match to the claimed counts. `cargo clippy -p
vlog_linter --all-targets`: silent. `cargo fmt -p vlog_linter --check`: clean.
`cargo tree -p vlog_linter`: `vlog_parser` + std, no new dependency. Bonus:
`cargo clippy --workspace --all-targets` and `cargo fmt --all --check` are
*both* silent right now — the "1 clippy warning + 1 fmt diff in
vlog_formatter" the work log flags as the concurrent agent's churn is not
present in the tree as I found it (their round must have landed since the
work log entry was written); not this feature's concern either way.
**Verible citations, checked against the live page, not just the README's
claim** — fetched <https://chipsalliance.github.io/verible/lint.html>
independently. `parameter-name-style`: enabled by default, `parameter_style`
default `CamelCase|ALL_CAPS`, `localparam_style` default `CamelCase` — matches
the README's claim of a deliberate union-not-split deviation. `enum-name-style`:
enabled by default, pattern `[a-z_0-9]+(_t|_e)` — exact match. `struct-union-
name-style`: enabled by default, lower_snake_case ending `_t` — exact match.
No `module-name-style`, no `genvar-name-style`, no wire/reg rule of any kind —
all three "no such rule" claims confirmed independently. Claim 1: **pass**,
externally verified, not just internally consistent.
**visit.rs / class-body walk** (claim 2) — `cargo test -p vlog_linter`
includes all the class-body reach tests named in the README and they pass.
Additionally probed live: `parameter-name-style` fires on a class header
`#(parameter int bad_name = 1)` (`walk_param_ports`), `case-missing-default`
fires on a `case` inside a class method. **Pass.**
**Corpus** (claim 3) — reproduced deterministically.
- After: built `lucisv --release` at the current working tree, ran `lucisv check
corpus/ --output-format json`. Total **7921**, 96 files, and the per-rule
breakdown (no-tabs 7527/45, explicit-parameter-storage-type 183/51,
no-trailing-whitespace 85/7, case-missing-default 65/21,
parameter-name-style 39/11, module-filename 17/17, always-ff-non-blocking
4/1, struct-union-name-style 1/1) matches the README's table exactly, cell
for cell.
- Before: rather than trust the README's number, rebuilt it independently
with `git worktree add <scratch> HEAD` (last commit, before this round's
`vlog_linter` changes) and ran the same corpus check there:
**7875**, 88 files, breakdown (no-tabs 7527/45,
explicit-parameter-storage-type 182/50, no-trailing-whitespace 85/7,
case-missing-default 60/18, module-filename 17/17, always-ff-non-blocking
4/1) — an exact match to the README's claimed "before", which is itself
*not* `linter-core`'s stale 7806/93 (confirming the attribution reasoning:
HEAD already carries the concurrent classes/parser round's commits).
- Diffed both JSON dumps by `(filename, rule, range.start, range.end)`:
**46 appeared, 0 disappeared** — purely additive, exact match, broken down
identically to the README (case-missing-default +5, parameter-name-style
+39, struct-union-name-style +1, explicit-parameter-storage-type +1).
- `--select module-name-style`: **1** finding,
`common_cells/src/deprecated/generic_LFSR_8bit.sv` — exact match.
- Proven zero #1: extracted every `typedef enum ... name;` in the corpus's
`.sv`/`.svh` with an independent regex scan (not the linter) — **166**
names, **0** violate `[a-z_0-9]+(_t|_e)`. Matches the claimed 166/0 exactly.
- Proven zero #2: `lucisv check corpus/picorv32/picorv32.v --select
wire-reg-mixup` → 0. Copied the identical bytes to `picorv32.sv` in the
scratchpad and re-ran → **209**. Matches exactly.
- Claim 3: **pass**, every number reproduced independently and exactly, not
just re-read from the README.
**Zero-wiring** (claim 4) — `lucisv check <file> --select nope` lists all
**13** known rules in its error, alphabetical, as `registry.rs`'s own test
already pins. `crates/lucisv_server/src/lint.rs` read (not modified): both call
sites use `default_rules()` unfiltered, so the four new default-on rules and
not `module-name-style` reach server diagnostics automatically, by
construction. **Pass.**
**Attack probes — preset predicates** (`crates/vlog_linter/src/naming.rs`):
`Camel_Case` (mixed) → flagged by `parameter-name-style` (fails both
presets, correct). `ALL_CAPS2` (digit suffix) → accepted (correct, digits are
in the `ALL_CAPS` character class). `_WIDTH` (leading underscore) → flagged
(correct, `starts_with` requires an uppercase *first* char). `N`
(single letter) → accepted (correct, passes both presets trivially, matches
the doc). `weird_E` (uppercase suffix) → flagged (`_e`/`_t` check is
case-sensitive on the suffix, matches the documented pattern shape).
`weird_t`/`weird_e` → accepted. `foo_t` → accepted, `foo_s` → flagged
(`_e`-suffixed name is correctly not exempted from struct's `_t`
requirement). Escaped identifier `\weird+name` as a parameter name → the file
parses cleanly (confirmed via the unrelated `module-filename` rule still
firing on the same file) and `parameter-name-style` is silent on it, i.e. the
exemption is `is_escaped` working, not a parse failure hiding it. No panics
anywhere. **Pass**, with one documentation nit below.
**Attack probes — wire-reg-mixup scoping**: `.sv` fires, `.svh` fires
(case-insensitive extension check confirmed via `.SV` too, in the existing
unit tests), `.v` silent, stdin without `--stdin-filename` silent, stdin
*with* `--stdin-filename x.sv` fires. `reg` inside a class body in a `.sv`
file fires. `reg` inside a string literal (`"reg in a string"`) and inside a
leading comment do **not** false-positive — confirmed live, not just by
reading the token-kind filter. **Pass.**
**Attack probes — class-body coverage and the fence/waiver asymmetry**:
`// lucisv: waive case-missing-default` inside a class method body suppresses
the finding — confirmed live. The fence question (does `// lucisv: off` inside
a class body protect a `--fix` edit, given the classes round found the
*formatter's own* `scan_nested` inactive there) — built a probe file with a
tab fenced inside a class body:
```systemverilog
class c;
// lucisv: off
int a;
// lucisv: on
endclass
```
`lucisv check --select no-tabs` **still reports** the tab (fences gate fixes,
not diagnostics — confirmed, not assumed). `lucisv check --select no-tabs
--fix` on the same file leaves the tab **untouched** — the fix is correctly
declined. `lucisv format` on the identical file, no `--fix`, silently
reformats the tab away, exactly reproducing the classes round's finding that
the formatter's own fence is inactive there. Read `fence::protected_regions`
(`crates/vlog_formatter/src/fence.rs:96`) to understand *why* these two
disagree: it is `collect` (the AST/`scan_nested`-based answer, which does not
recurse into class bodies, per the classes README) **unioned with**
`scanned_regions` (a pure line-based text scan with no notion of scope at
all, `fence.rs:124`) — the backstop exists for "the broken files only the
linter and the server see" but it fires unconditionally, so it also catches
a fence the AST scan missed. That is a real, confirmed mechanism, not a
guess — and it means `--fix` is *more* conservative inside a class body than
the formatter itself is, which is the harmless direction but is currently
**undocumented in both `docs/features/classes/README.md` and this README**.
Filed as a should-fix below. **Pass on behavior; documentation gap found.**
**Sabotage** — broke `is_upper_snake_case` in `naming.rs` to accept any
uppercase-first alphanumeric-or-underscore name (i.e. `"Width"` would wrongly
pass as `ALL_CAPS`). `cargo test -p vlog_linter`: exactly **one** test failed,
`naming::tests::upper_snake_case_accepts_what_parameters_write` (the negative
case `"Width"`). No `parameter-name-style` test caught it, because every
mixed-case name in that rule's own test file already happens to be valid
`CamelCase` regardless of the `ALL_CAPS` predicate, so the coverage for this
predicate lives only in `naming.rs`'s own unit tests — which is sufficient
(the failure is unambiguous and points straight at the broken predicate) but
worth knowing if a future preset gets a fourth caller. Reverted; `cargo test
-p vlog_linter` green again; `git diff -- crates/vlog_linter/src/naming.rs`
empty, confirmed byte-identical to the pre-sabotage state.
**Findings**
- *Should-fix, documentation gap (not a corruption, not a corpus regression;
the actual behavior is the safe/conservative direction).* Neither
`docs/features/classes/README.md` nor this README states that a
`// lucisv: off` fence inside a class body **does** protect `lucisv check
--fix` (via `fence::protected_regions`'s line-based backstop scan), even
though the classes round documented, correctly, that the same fence is
**inactive** for `lucisv format` itself (the AST-scoped `scan_nested` doesn't
recurse into class items). Both facts are true and now confirmed by test;
neither README says both in one place, so a reader of either document alone
would reasonably conclude the fence does nothing at all inside a class
body, which is false for the `--fix` path. Suggest a short paragraph in this
README's "Class-body coverage" section (or a line in
`docs/features/classes/README.md`'s existing fence-inactive note) stating
the asymmetry plainly, with the mechanism (`collect` vs `scanned_regions`)
named. Not fixed directly — it's a cross-cutting note that belongs to
whichever agent owns `crates/lucisv/src/lint.rs` / the fence handshake, not a
typo I can fix unambiguously in-place.
- *Minor nit, not blocking.* The Assumptions section says "A non-ASCII
identifier fails `lower_snake_case` etc. and is reported." In practice a
genuinely non-ASCII byte in an identifier does not reach any naming rule at
all: `vlog_linter::context`'s own comment says "a lex error leaves no
tokens (the lexer is all-or-nothing)", confirmed live — `lucisv check` on a
file containing `parameter int élan = 1;` exits 0 with **zero** findings
(not even the unrelated `module-filename`), while `lucisv format` on the same
file correctly refuses with a `lex error` (invariant intact, nothing
corrupted). So the practical claim is even truer than stated ("no practical
population" because it's unreachable, not just because it's rare) but the
wording "is reported" is not literally accurate for that case — pre-existing
`context.rs` behavior, not introduced by this round, not worth a code
change, just a one-clause wording fix if the README is touched again.
*(2026-08-19: delivered by lexer-cleanup — `lucisv check` on a file that
does not lex now reports the lex error and exits 2 instead of silently
passing; `docs/features/lexer-cleanup/README.md`.)*
- No preset false positive or false negative found on any probed shape.
No panic on escaped, non-ASCII, or unparseable input.
No corpus regression: diff is exactly and only additive.
**Verdict**: all six claims **pass**. Nothing blocking. Two documentation
gaps filed above, both pre-existing/cross-cutting rather than owned by this
round's code.
## Review
**2026-08-19 — lead. Verdict: accepted; commits with round 18. The
linter now stands at 13 rules with Verible-compatible names and
evidence-based defaults.**
Points reviewed and accepted:
1. **Both brief premises were falsified against Verible's published
docs and the deviations argued**: module-name-style ships OFF
because no Verible default exists to inherit (my brief said on —
the agent was right to override it with the round's own
default-rule); wire-reg-mixup's provenance correction is recorded
where the wrong claim lives. Checking the source instead of
trusting the brief is exactly what the house rewards, and QA
independently re-fetched the docs to confirm.
2. **Using Verible's exact rule names** (enum-name-style,
struct-union-name-style) instead of an invented umbrella means
vendored `verilog_lint:` waivers now suppress instead of being
ignored — compatibility as a design input, not an afterthought.
3. **The class-body walk closes the classes handshake** with honest
deltas (+6 findings, all real UVM code; always-* uniformity noted
as population-free) and the corpus baseline correctly re-measured
on this tree rather than inherited stale.
4. **Both zeroes proven** (166 conforming enums; the .v→.sv rename
yielding 209) — a zero you've probed is evidence; a zero you
assumed is a blind spot.
5. QA's fence-asymmetry finding is now documented in both owning
READMEs (lead notes in classes and shared-fence-filter): a fence
inside a class body protects fixes via the scan backstop even
though the formatter ignores it there. The non-ASCII lexing nit
belongs to the lexer's existing gap list.
Remaining §4 items stay honestly open: external waiver files,
per-rule style configuration (needs the lucisv.toml lint key), and the
--rules-doc CLI flag (handshake filed; rules_markdown() is ready).