Files
lucioandClaude Fable 5 5e5813a2a9 Linter expansion, wave 2: per-rule options end to end, options on the naming rules, and eighteen Style rules
TODO section 34 (36 -> 54 rules).
Options: OptionSpec/OptionKind/OptionValue/RuleOptions in vlog_linter
with one validator behind both front ends - [lint.<rule>] tables in
lucisv.toml (accepted now; stored raw by lucisv_core::config, resolved
per file by the CLI with <config>:<line> on the first bad entry) and
the editor's lucisv.lint.options object (bad entries logged and
dropped) - precedence editor > toml > default key by key, --rules-doc
listing every option. A small anchored regex engine of our own: a
Thompson-NFA simulation, linear in pattern x name by construction
(QA's first cut found the backtracking matcher exponential on (a*)*b),
unknown escapes refused by name through both doors, a 71-row table
verified against CPython. The four naming rules take Verible's option
spellings with defaults that keep today's verdicts byte-identical.
Eighteen Style rules, one file each with true positives and near-
misses: line-length (the formatter's width), posix-eof (safe fix),
forbid-consecutive-null-statements (safe fix), generate-label and
generate-label-prefix, package-filename, one-module-per-file (off),
signal/interface/macro/constraint/parameter-type-name-style,
port-name-suffix (off), banned-declared-name-patterns (off),
typedef-enums, typedef-structs-unions (allow_anonymous_nested defaults
true here - opentitan's 3 159 findings were all generated register
packages, and its own config disables the rule), always-comb (unsafe
fix), explicit-begin (off, Verible's eleven enables). Four rules ask
parsed_cleanly() first after a census showed error-recovered UVM files
rebound as generate blocks. package.json regenerated (drift test).
3 549 tests / 48 binaries; corpus 814/820 byte-identical; naming-rule
finding lists identical to 0.36.0; opentitan check timing unchanged.

docs/features/linter-expansion-2/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-09-04 03:36:59 -05:00
..

linter expansion, wave 2 — per-rule options and the first Style rules

Goal

TODO §34. Two things: the option plumbing every configurable rule needs (OptionSpec/OptionKind/OptionValue/RuleOptions in vlog_linter, Rule::options(), LintContext access with the spec default as the fallback, [lint.<rule>] tables in lucisv.toml, a lucisv.lint.options object in the editor, precedence editor over toml over default), and the eighteen Style rules from Verible's list that carry the most weight in a style guide — naming, file layout, generate labels, typedefs, line length. The four naming rules that predate options gain the options Verible gives them, with defaults that reproduce today's behaviour exactly. The registry goes from 36 rules to 54.

Assumptions

  • Verible is the reference for names and defaults. Every rule cites its Verible equivalent in its doc and takes Verible's option spelling. The reference was read at https://chipsalliance.github.io/verible/lint.html during the round, not from memory: typedef-structs-unions' option really is allow_anonymous_nested (default false), line-length really is length (100), package-filename really is allow-dash-for-underscore (false), and parameter-name-style really takes exactly the four keys used here. Every deviation is listed in the work log and named in the rule's own doc.
  • A pattern is not RE2. crates/vlog_linter/src/regex.rs implements the subset a style guide is written in — literals, ., [...] classes, the escapes \d \D \w \W \s \S \n \t \r and \<punctuation>, groups, |, and the postfix * + ? — matched anchored at both ends. Everything else is refused when the option is read, by name: counted repetition, (?...) groups, and every escape the engine does not implement (\b, \1, \A, \p{…}, \x41). Justification for not taking a regex dependency: this crate depends on vlog_parser + std alone, and the whole engine is one file with its own tests. The cost is that a project using a backreference or a lookahead in a Verible style_regex gets an error instead of a rule; no such pattern appears in Verible's own defaults.
  • No pattern can hang a run. The matcher is a Thompson-NFA simulation (a Pike VM without captures): the live set of program counters is advanced one character at a time, each state entered at most once per character, so matching is O(pattern × name) by construction. This replaced a backtracking matcher that was exponential on an ambiguous repeat — see the rework entry of 2026-09-04.
  • A rule never sees "unset". Every read falls back to the spec's declared default; is_set exists for the one rule whose fallback is not a constant (line-length follows the formatter's width) and for the two *_style_regex overrides, where "unset" means "the words decide".
  • Defaults reproduce today's findings character for character. Where a preset became a pattern, a default run still prints the preset's sentence (naming::style_message); only a configured run names the pattern. Proved by diffing the whole finding list against the 0.36.0 binary — see Measurements.
  • The structure-reading new rules (generate-label, generate-label-prefix, one-module-per-file, package-filename) are silent in a file that does not fully parse, the discipline context.rs documents for duplicate-declaration. The naming rules are not: a declaration recovery bound in the wrong scope still is a declaration with that name, so the finding stays true.

Handshakes

  • Consumed — vlog_parser::ast (unchanged), vlog_semantic::Semantics (symbols() for banned-declared-name-patterns), lucisv_core::config's parser shape, vlog_formatter::Config::max_width (the width line-length follows).
  • Promised (new public API of vlog_linter) — OptionSpec, OptionKind, OptionValue, OptionDefault, RuleOptions, Rule::options() (default empty, so no rule outside this round changes), LintContext::with_options / with_line_length (both optional; a caller that lends neither gets exactly the shipped behaviour).
  • lucisv_core::config — FileConfig gains lint_options: Vec<LintOption> (rule, key, raw text, line) and source: Option<PathBuf>, the file a config was read from, so an error about an entry can name the file to edit. [lint.<rule>] is now accepted rather than rejected by name; the old "per-rule lint settings are not supported yet" error is gone, and the test that pinned it now pins the malformed-header errors instead.
  • Files touched outside the brief's list, both minimal and pre-agreed or forced:
    • crates/lucisv_server/src/server/notification.rs — the three-line window/logMessage loop for refused lucisv.lint.options entries (pre-agreed by the lead in the resume brief), plus one comment.
    • crates/lucisv/src/main.rs — stdin_config now returns the FileConfig beside the Config so a stdin buffer can read the same [lint.<rule>] tables a file does, and the stdin lint path builds the options. Unavoidable: lint::check_stdin gained a parameter.
  • Not changed, deliberately: vlog_formatter and verify.rs (untouched — the formatter's corpus output is byte-identical to 0.36.0), lucisv_server/src/format.rs (its ladder is cited, not altered).

Status / TODO

  • 34.0(a) options.rs + regex.rs; Rule::options(); LintContext::with_options/with_line_length and the option_* accessors; registry table tests
  • 34.0(b) [lint.<rule>] tables stored raw in lucisv_core::config; the CLI resolves them per file and fails with file:line
  • 34.0(c) lucisv.lint.options in the editor, validated the same way; a bad entry is dropped and logged
  • 34.0(d) precedence editor > toml > default, key by key
  • 34.0(e) --rules-doc lists every option with kind, default and doc; each toggle's description names the options its rule takes
  • 34.0(f) pins: parse/validate tables, a lucisv.toml that changes the verdict, the editor object over the wire, a bad key naming file:line
  • 34.1 options on the four naming rules; finding lists byte-identical
  • 34.2 the eighteen Style rules, each with tests, a .lint case, corpus + opentitan counts and ten classified findings
  • 34.3 docs (README "Linting", editors/vscode/README.md, the docs-site rules page) + regenerated package.json
  • Gates (guarded): fmt, clippy 0, cargo test --workspace 3 549/48 binaries, corpus 814/820, --stdout byte-identity 0 differing, vsix smoke, opentitan census + timing
  • QA

The rules, measured

Counts are lucisv check --select <rule> --no-config over the 860-file corpus and over ~/repo/opentitan/hw (10 k files, read-only). "V" is Verible's default for the same rule; where lucisv differs, why is in the row. Ten findings per rule were read; the classification column says what they were.

Rule Sev Default (V→here) Verible equivalent Options (default) Corpus opentitan Ten findings read
line-length style on→on line-length length (formatter's width, else 100) 225 375 10 true. All real over-runs; 101 of the 104 in rtl/ are auto-generated (lc_ctrl_state_pkg, rtl/autogen/*), 2 are a 101-char comment duplicated in tlul_adapter_{vh,shim}.sv — genuine, and Verible at opentitan's own line-length=length:100 would report them too
posix-eof style on→on posix-eof — 0 1 1 true (all there is): pulp_riscv_dbg/src/dmi_test.sv really has no final newline. The corpus has none — every file in it ends properly
forbid-consecutive-null-statements style on→on same — 2 1 3 true (all there are): a literal ;; after a $error(…) and after two declarations in cb_filter_tb
generate-label style on→on generate-label — 36 3 10 read (3 on opentitan, 7 more on the corpus), all true: real unlabelled if/for generate blocks in common_cells and ibex fcov, and a generate for … begin in dm_top_sva. 177 phantoms from two unparsable UVM files were closed by the parsed_cleanly gate
generate-label-prefix style on→on same prefix (["g_","gen_"]) 0 0 0 findings on either tree — every labelled generate block in both writes g_/gen_. Behaviour pinned by unit tests and three .lint cases instead, the option included
package-filename style on→on same allow-dash-for-underscore (false) 1 0 1 true, needs judgment (all there is): common_cells/include/common_cells/assertions.svh declares assert_rpt_pkg. A package in an .svh include is a deliberate shape; Verible reports it too, and --ignore or a waiver is the answer
one-module-per-file style off→off same — 37 10 10 true: aes_sbox_*, spi_host_data_stable_sva really declare a second module. Off, as Verible ships it
signal-name-style style off→off same style_regex ([a-z_0-9]+) 72 374 10 true: clk_48MHz_i, IO_CLK, ReadyIsStable, stL, cfg_prefix_6B_i
interface-name-style style on→on same style_regex ([a-z_0-9]+(_if)) 5 6 10 read (6 + 4 more, one overlapping), all true: STREAM_DV, DMI_BUS_DV, JTAG_DV, ibex_mem_intf, mem_assume_t. Every one is vendored code, outside opentitan's own filesets
macro-name-style style on→on same style_regex ([A-Z_0-9]+) 18 12 10 true: `define uvm_object_new, `define add_instr(...). All in dv/ and vendor/, which opentitan's RTL lint does not cover
constraint-name-style style on→on same pattern (([a-z0-9]+_)+c) 15 19 10 true: the c_-prefixed UVM convention (c_clen, c_delay_dist) is the mirror image of Verible's _c suffix. All in dv/+vendor/
parameter-type-name-style style off→off same style_regex ([a-z][a-z_0-9]*_t) 81 133 10 true: type CFG_T, type RAL_T — the UVM convention the rule's doc predicts, which is why it ships off
port-name-suffix style off→off same suffixes (the six) 1 129 1 843 10 true: input active, input clk, output dmi_req_valid. Off, as Verible ships it
banned-declared-name-patterns style off→off same patterns (empty) 0 0 0 by construction — an empty list reports nothing and the rule returns before touching the symbol table. Behaviour pinned by unit tests and two .lint cases with patterns set
typedef-enums style on→on same — 6 4 10 read (4 + 6), all true: anonymous state enums declaring two variables at once (state, state_next, CS, NS), reported per declarator
typedef-structs-unions style on→on same allow_anonymous_nested (false) 69 3 159 10 true (the corpus's 69 are the same shape — a vendored copy of uart_reg_pkg). All 3 159 are nested anonymous structs inside a typedef, in 57 reggen-generated register packages. opentitan's own Verible config disables the rule (-typedef-structs-unions, "we allow nested struct definitions"); here allow_anonymous_nested = true expresses the same choice and takes the file that produced 32 findings to 0
always-comb style on→on same — 23 13 10 read: 4 true (always @( * ) / always (* xprop_off *) @( * ) in the ast behavioural models, outside the RTL filesets), 6 needs judgment — all in plain Verilog-2001 .v files (picorv32.v, prim_clock_gating.v) where always_comb may not be available to the project's toolchain. Verible reads every file as SystemVerilog and reports the same; the fix is unsafe, and a Verilog-2001 codebase turns the rule off with one ignore
explicit-begin style off→off same eleven *_enable (all true) 1 093 4 291 10 true: if (active) initialize();, always_comb x = …;. Off, as Verible ships it

Why a Verible-default rule fires inside opentitan at all: opentitan lints hw/ip/*/rtl filesets with hw/lint/tools/veriblelint/lowrisc-styleguide. rules.verible_lint, which disables typedef-structs-unions outright, sets line-length=length:100 (the same limit lucisv uses) and sets parameter-name-style=localparam_style:CamelCase|ALL_CAPS — the very default §34.1 chose here over Verible's stricter CamelCase. dv/, tb/, pre_dv/ and vendor/ are not in those filesets, which is where most of the remaining findings live.

The default set therefore reports 4 212 findings on opentitan hw/ against 0.36.0's 619; the difference is exactly the twelve new default-on rules (3 159 + 375 + 19 + 13 + 12 + 6 + 4 + 3 + 1 + 1 = 3 593), and 3 159 of those are the one rule opentitan turns off in its own config.

Work log

2026-09-03 — dev (Opus 5), first sitting (paused mid-round)

Wrote 34.0(a) (options.rs, regex.rs, Rule::options, the context accessors) and 34.1 (the four naming rules), plus fifteen of the eighteen rule files, none of them registered. Recorded at the pause in the checkpoint commit 1d4bddf. The two OptionKind additions proposed then — RegexList and Words — were accepted by the lead on resume.

2026-09-04 — dev (Opus 5), second sitting (round finished)

34.2 finished. Registered all eighteen rules alphabetically in rules/mod.rs and registry::all_rules, declared mod module_decls, and wrote the three that were missing: typedef-structs-unions, always-comb (unsafe fix, replacing exactly the always @(*) header read off the tokens so a comment inside the control is not silently dropped) and explicit-begin (Verible's eleven *_enable options, safe fix wrapping the body — statement spans include the terminating ;, verified before relying on it).

Registration surfaced four real problems, all fixed:

  1. module_signals collected a non-ANSI port twice — once from the header's name list, once from the body's input x;. The header list is now skipped: a non-ANSI header names ports, the body declares them, and the declaration is what a rule should point at.
  2. A nested module is illegal SystemVerilog, so the parser recovers by promoting it to file scope. one-module-per-file would have accused the author of a second module; it now asks parsed_cleanly first.
  3. generate-label produced 177 of its 180 opentitan findings from two files error recovery could not put back together, where a procedural if (…) begin is rebound as a generate block. Both generate rules (and package-filename, for the same reason) now ask parsed_cleanly. This is the false-positive class context.rs documents for duplicate-declaration, met again — worth its own line in the next round's brief.
  4. Two existing .lint cases and one unit test named macro-name-style as a rule lucisv does not have. They now name explicit-function-lifetime (§35's), and three case sources gained the labels/suffixes the new default-on rules ask for.

34.0(b)–(e) written. lucisv_core::config grew Table::Rule(name) and stores each entry raw with its line; FileConfig records the file it came from. lucisv check resolves them per file through RuleOptions::set_raw and fails with <config>:<line>: <message> on the first bad entry — the same treatment a bad [lint] select name gets. The editor's lucisv.lint.options goes through RuleOptions::set (one validator, two front ends); a refused entry is dropped, described, and logged by apply_settings. lint_selection gained the options, so changing one republishes every open file exactly as changing a toggle does. --rules-doc prints an option table per rule; the VS Code generator names each rule's options in its description and package.json was regenerated from it (the drift test proves it).

Decisions and deviations, for the lead:

  • OptionKind has seven members, not the plan's five: RegexList (so banned-declared-name-patterns' entries are validated as patterns) and Words(&[&str]) (so parameter_style: CamelCase|ALL_CAPS is validated against a vocabulary — a plain Str would accept snake_case and then match nothing). Accepted by the lead on resume.
  • Naming defaults are stricter than Verible's, on purpose. enum-name-style defaults to [a-z][a-z_0-9]*(_t|_e) where Verible has [a-z_0-9]+(_t|_e); struct-union-name-style to [a-z][a-z_0-9]*_t; module-name-style to [a-z][a-z_0-9]*. Verible's own patterns accept a leading _ or digit, which the presets these replaced rejected — and §34.1 requires the finding lists to be byte-identical. Each rule's doc says so.
  • parameter-name-style keeps CamelCase|ALL_CAPS for localparam where Verible defaults to CamelCase. The reason was already in the rule's doc; opentitan's own Verible config makes the same change, which is as good a vindication as this round could hope for.
  • Options lucisv adds where Verible has none: generate-label-prefix's prefix (§34 asked for it), parameter-type-name-style's and struct-union-name-style's style_regex (§34.1 asked for the latter; Verible spells its own as exceptions), port-name-suffix's suffixes, banned-declared-name-patterns' patterns.
  • .lint harness: added a #options <rule>.<key> = <value> header, so an option-driven case is pinned in the table harness through the same validator a lucisv.toml uses. 246 cases, all green.
  • posix-eof has no marker case: the harness rejoins every case body with a trailing newline, so no case input can lack one. Pinned in the rule's unit tests instead, fix included; the case file says so.
  • Editor beats lucisv.toml for options, key by key — the opposite of format::settings_for's ladder for formatting. Instructed by §34.0(d) and the resume brief; the reason (formatting has a byte-exact contract with CI, a lint option changes what one user is shown) is written into lint::configured's doc comment, README.md and the extension README so nobody has to re-derive it.
  • line-length's width follows the formatting ladder instead (lucisv.toml > editor > 100), because it is not a lint setting but the width the formatter would wrap to; the rule's own length option beats it either way.
  • The server reads the buffer's lucisv.toml once per lint pass, as format::discover does per formatting request. A few stats beside the parse and analysis that pass already pays for; a lucisv.toml edited while the server runs takes effect at the next publish.
  • naming::is_lower_snake_case lost its last caller and was deleted; a test now proves the pattern that replaced it accepts exactly the same names.

2026-09-04 — dev (Opus 5), rework after QA's REWORK verdict

Both HIGH findings were in crates/vlog_linter/src/regex.rs; nothing else QA raised needed a code change.

(1) Catastrophic backtracking — root cause. The matcher was a continuation-passing backtracking search: matches() tried a repeat greedily and handed the rest of the pattern a continuation to fail back into. For an unambiguous pattern that is fine, and every default this round ships is unambiguous (QA measured all four at sub-2 µs on 100-character names). For an ambiguous one — (a*)*b, where the inner and outer repeats can split the same run of as in exponentially many ways — every split is tried before the match fails, which is 2^n in the name's length: QA measured 20 ms / 648 ms / 20.6 s at 20 / 25 / 30 characters and a tools/guard.sh -t 15 kill on the shipped binary. The zero-width guard in repeat() stopped an infinite loop and said nothing about an exponential one. Worse, OptionKind::Regex accepts such a pattern happily, so a lucisv.toml or an editor setting could configure the hang into every future lint run and every keystroke-triggered republish.

The fix is structural, as the brief required: the parser is unchanged (so every error message survives), but its tree is now compiled to a small instruction program (Char/Any/Class/Split/Jump/Match) and run as a Thompson-NFA simulation — the set of live program counters is advanced one character at a time, with a per-character seen array that enters each state at most once. That makes the cost O(prog × name) whatever the pattern is: no backtracking, no continuation, nothing to explode. Regex::compile / Regex::is_match keep their signatures and whole-name semantics, so no rule and no caller changed.

Measured after: the six ambiguous shapes ((a*)*b, (a|aa)*b, (.*)*x, ((a*)*)*b, (a+)+b, (a?)*b) over a 200-character name are asserted under 500 ms in a unit test (they take microseconds); QA's own end-to-end reproduction — a lucisv.toml with style_regex = "(a*)*b" and a file declaring a long a…a wire — now runs under tools/guard.sh -m 1 -t 5 with no kill, and stays flat as the name grows: n = 20 / 25 / 30 / 200 / 1000 characters all at 1.07 s wall, which is guard.sh's own one-second polling floor rather than lucisv's time (exit 1, findings reported, never 137).

(2) Unsupported escapes read as literals — root cause. escape() and class_escape() each matched the escapes they implement and then fell through to other => Node::Char(other), i.e. "any escape I do not know is that character". That is the ordinary rule for \. or \[, and quietly wrong for a letter or digit escape from another dialect: (a)\1 compiled and matched the literal a1, and \bword\b — an RE2 word boundary, and RE2 is exactly what Verible's style_regex values are written in — compiled and matched the literal bwordb. A user pasting a Verible pattern got a naming rule that judged the wrong names with no diagnostic at all, contradicting this README's own "refused by name" assumption.

Now the fallback splits: an escaped character that is_alphanumeric() and is not one of the nine implemented (d D w W s S n t r) is an error naming it and listing what is supported; everything else (punctuation, symbols) stays the literal it has always been. Inside a [...] class the same rule applies, with \D/\W/\S refused separately and specifically — a class here is one range set with one negation flag, and mixing a complemented set into it would need set arithmetic this engine does not do, so it says so rather than guessing. (?...) groups are refused by name too (they used to reach the ?-has-nothing-to-repeat error, which named the wrong thing).

Both front ends surface it unchanged: the CLI prints <config>:<line>: rule signal-name-style style_regex: \bword\bis not a valid pattern: unsupported escape\b (supported: …) — the rule name is new, added so an error read out of a CI log stands without its table header — and the editor logs lucisv.lint.options.signal-name-style.style_regex: … ; ignored and keeps the rule running on its default.

Cross-check. The probe table is now a unit test of 71 (pattern, text, expected) rows — QA's categories (literals, ., classes with ranges and negation, \d\w\s and their negations, groups, alternation, *+?, nested and empty alternatives, anchoring) plus the ambiguous-repeat shapes this rework exists for — and every row was verified against CPython's re.fullmatch before being written down: 71/71 agree, and the Rust test asserts the engine reproduces the same table. QA's two escape cases are the first two rows of the refusal test: (a)\1 and \bword\b no longer compile at all, so neither can match a1 or bwordb.

Gates re-run after the rework (all guarded): fmt; clippy 0 warnings; cargo test --workspace 3 549 passed / 0 failed / 42 ignored / 48 binaries (unchanged — four narrow regex tests were folded into the 71-row probe table, and one option test was added); corpus gate {"passing":814,"total":820}; --stdout over 860 corpus files vs 0.36.0 0 differ; 34.1 identity re-proved (corpus 43, opentitan 35, stdout and stderr byte-identical); the full 18-rule opentitan census identical to the pre-rework run, 10 244 findings — the engine swap changed no verdict anywhere; vsix smoke OK; git -C ~/repo/opentitan status --porcelain still only the three pre-existing files.

Not changed. QA's LOW coverage note (no checked-in tests/e2e.rs case for lucisv.lint.options over the wire) and the tools/guard.sh stdin observation are left for the lead: the first is a test to add in another lane's file, the second is outside §34's file list.

Measurements

All runs under tools/guard.sh; no guard kill at any point.

  • cargo test --workspace: 3 549 passed, 0 failed, 42 ignored over 48 test binaries (baseline 3 393 over the same 48 binaries, 42 ignored) — +156 tests, no binary added or removed. (The brief's "48" is the number of test binaries; the ignored count has been 42 since §33.)
  • fmt: cargo fmt -p for vlog_linter, lucisv_core, lucisv, lucisv_server. clippy: cargo clippy --all-targets --workspace, 0 warnings.
  • Corpus gate: {"passing":814,"total":820,"pct":99.3} — the same six known failures, unchanged.
  • Formatter byte-identity: lucisv format --stdout over all 860 corpus files, this build vs ~/.cache/lucisv-baselines/lucisv-0.36.0: 0 differ. The formatter was not touched.
  • 34.1 byte-identity: check --select enum-name-style,struct-union-name- style,module-name-style,parameter-name-style --no-config, this build vs 0.36.0 — corpus 43 findings, byte-identical; opentitan hw/ 35 findings, byte-identical, stderr included.
  • opentitan check timing (three interleaved runs each, /usr/bin/time -p inside the guard): 0.36.0 0.91 / 0.87 / 0.90 s, this build 0.89 / 0.91 / 0.90 s — no measurable difference, though the new build does strictly more work (twelve more default-on rules).
  • vsix smoke: node editors/vscode/smoke.js target/debug/lucisv-server — OK, 20 messages.
  • opentitan tree after the round: git -C ~/repo/opentitan status --porcelain shows only the three 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). Every opentitan run was read-only.

QA log

2026-09-04 — QA (Sonnet 5)

Verified in the lint-2 worktree only, everything guarded, opentitan read-only. Scratch under .../scratchpad/qa-34/.

1. Gates. All guarded, all reproduced independently of the dev's own numbers: cargo fmt --all -- --check clean; cargo clippy --all-targets --workspace 0 warnings, and git diff 10b63e6 -- shows no new #[allow]; cargo test --workspace --no-fail-fast 3 549 passed / 0 failed / 42 ignored / 48 binaries, exact match. git diff --stat 10b63e6 -- crates/vlog_formatter crates/vlog_parser empty. Corpus gate {"passing":814,"total":820}, exact match. --stdout over the 860-file corpus (this build vs ~/.cache/lucisv-baselines/lucisv-0.36.0): 0 differ. vsix smoke: OK, 20 messages. Changed-file set: every tracked file in git diff --stat 10b63e6 plus the two untracked-then-added rule files is inside vlog_linter/the two disclosed handshake files (lucisv_server/src/server/notification.rs, lucisv/src/main.rs) or the brief's other named files; vlog_linter/src/{decls,module_decls,naming, visit}.rs are touched but not individually named in TODO §34's file list — not a violation, since they are inside the feature's own crate and the work log's item 1–4 already explain each one (non-ANSI double-count, parsed_cleanly gating, a dead helper's removal).

2. The regex engine — two HIGH findings.

Wrote 46 (pattern, text) probes (literals, ., classes with ranges and negation, \d\w\s and their negations, groups, alternation, *+?, nested groups, empty alternatives) and compared every verdict against Python's re.fullmatch in a standalone copy of regex.rs (pub(crate) → pub, compiled outside the crate so nothing in the dev worktree was touched): 46 / 46 agree. Anchoring confirmed: abc vs xabcx → false, abc vs abc → true, matching regex.rs's own the_match_is_anchored_at_both_ends.

  • HIGH — catastrophic backtracking, reproduced end to end on the shipped binary, guard-killed. (a*)*b against a 20–30 a-character name with no trailing b (a name length well inside normal signal-name territory): 20 chars → 20 ms, 25 → 648 ms, 30 → 20.6 s (roughly ×32 per +5 chars, textbook exponential). Reproduced with the real binary, not just the extracted copy: a lucisv.toml with [lint.signal-name-style] style_regex = "(a*)*b" and a file declaring a 30-a wire, tools/guard.sh -t 15 -- lucisv check bad.sv → guard.sh: 15 s exceeded — killing, exit 137. OptionKind::Regex's check() only calls Regex::compile, which has no notion of pathological shape, so this pattern is accepted by both front ends with no warning — a project or an editor session can configure a hang into every future lint run, and the LSP server would freeze on it on every keystroke-triggered republish. The eighteen new rules' own default patterns were also timed against realistic 20–100 char non-matching names (constraint-name-style, signal-name-style, parameter-type-name-style, interface-name-style defaults): all sub-2 µs even at 100 chars, so this is a risk in a user-authored pattern, not in anything shipped. crates/vlog_linter/src/regex.rs's repeat() (lines 119–138) only guards against a zero-width iteration, which stops (a?)*b from looping forever but does nothing about the ambiguous-split blowup a pattern like (X*)* invites. No fix suggested here — flagging for the lead to decide between a matched-position memo (early-exits the classic case cheaply), a step budget, or documenting patterns of this shape as refused by construction (e.g. reject a repeat whose body can itself match zero-or-more of a single class, the RE2-style answer).
  • HIGH — unsupported escapes are silently accepted as a literal instead of refused "by name." The Assumptions section promises "anything else is refused by name when the option is read." escape() (regex.rs:233–247) and class_escape() (regex.rs:289–309) each have an explicit list (d D w W s S n t r) and a fallback arm, other => Node::Char(other), that turns every unrecognized escape into its own literal character. Concretely: (a)\1 (a backreference) compiles and matches the literal string a1; \bword\b (an RE2/Verible word-boundary anchor — the assumption is explicit that "Verible spells every naming convention as an RE2 pattern," and RE2 supports \b) compiles and matches the literal string bwordb, not "word" with boundaries. Both were probed with Regex::compile directly: no Err, and is_match returns a plausible-looking but wrong verdict with no diagnostic at all — exactly the failure mode the brief calls out ("never silently mis-match"). A user who pastes a Verible style_regex containing \b, \B, \A, \Z, \1–\9, or any other dialect escape gets a naming rule that quietly accuses or excuses the wrong names, with no error to notice. {2,3} and (?=...) are correctly refused by name (confirmed both still error as documented); the gap is specifically the escape fallback's catch-all.

3. Options, both front ends. CLI (lucisv check over a lucisv.toml): verdict-changing confirmed (length = 40 flags a 48-char line the default 100 does not); bad key → `<config>:5: rule `line-length` has no option `lenght`; it has: length`; wrong kind → `length` expects an integer, found `"10"`; out of range → `length` must be between 40 and 400, found 999999`; bad regex → `style_regex`: `[a-` is not a valid pattern: unmatched `[ ; unknown rule table → unknown rule no-such-rule ``. All five carry the <config>:<line>: prefix as specified, exit 2. Stdin (lucisv check --stdin-filename … -) honours the same [lint.<rule>] table — confirmed correct once run un-guarded: tools/guard.sh backgrounds its command with "$@" &, which severs the child's stdin (confirmed with plain cat/ wc -c under the guard, piped and redirected both: 0 bytes reach the child either way) — a guard-wrapped stdin run silently lints an empty buffer and reports nothing, which is not a lucisv bug but is a real trap for the next QA/dev pass that tries to "always guard" a stdin check. Noting it here rather than filing as a feature defect: severity LOW, tooling only, tools/guard.sh itself is outside §34's file list. Run un-guarded (single small file, bounded by hand), the stdin path is correct: length = 40 flags, a bad [lint.line-length] length = "oops" fails with the same <config>:<line>: message the file path gives.

Editor (lucisv.lint.options): no tests/e2e.rs case exercises this setting over a live LSP session — settings.rs's own tests cover rule_options() at the unit level only, so "the editor object over the wire" in 34.0(f)'s pin list is a unit-level pin, not an e2e one. Verified it myself with a standalone script speaking framed JSON-RPC at the real lucisv-server binary (same shape as tests/e2e.rs's talk()): initialize → didChangeConfiguration with lucisv.lint.options → didOpen. Five scenarios, all correct: a good style_regex fires the selected rule's diagnostic; a bad key, a wrong-kind value, a bad pattern and an unknown rule table each produce exactly one window/logMessage warning naming the setting and the reason, are dropped, and the rule keeps running on its default (never "the linter turned off"). Precedence: opened a file with a lucisv.toml [lint.line-length] length = 40 flagging a 58-char line, then pushed lucisv.lint.options = {"line- length": {"length": 200}} mid-session — two publishes, the second clearing the diagnostic (editor's 200 beat the toml's 40, and the second publish is the republish-on-change pin). Recommend landing this script (or similar) as a checked-in tests/e2e.rs case in a follow-up — it is the only front end 34.0(f) claims a pin for that the repository does not actually exercise over the wire. Not filed as a severity finding on its own since the behavior itself is correct; filed as a coverage gap.

4. 34.1 byte-identity, re-derived independently. check --select enum-name-style,struct-union-name-style,module-name-style,parameter-name- style --no-config, this build vs ~/.cache/lucisv-baselines/lucisv-0.36.0: corpus 43 findings, opentitan hw/ 35 findings, both stdout and stderr byte-identical (diff empty) in both trees. git -C ~/repo/opentitan status --porcelain before and after every opentitan run: only the three 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) — no CRITICAL.

5. The 18 rules, adversarial. No false positive found on a legal shape in any probe; every probed fix is safe and correct:

  • line-length correctly ignores a bare `include "…140-chars…"`, a bare `LONG_MACRO_INVOCATION line and the same with a trailing ; (still one token); a long string literal inside a statement (multiple tokens on the line) is correctly still reported.
  • posix-eof --fix appends exactly one \n to a file with none; the fix is idempotent (a second --fix run reports nothing).
  • forbid-consecutive-null-statements --fix collapses ;; to ; without touching the statement around it — semantically inert.
  • generate-label stayed silent on a hand-crafted file with a genuine parse error (garbage tokens inside a procedural if), confirming the parsed_cleanly gate from the work log's finding 3, while still flagging an unlabeled generate … endgenerate in an otherwise-clean file.
  • typedef-structs-unions: a nested anonymous struct is flagged by default and silenced by allow_anonymous_nested = true, both confirmed.
  • always-comb --unsafe-fixes --fix rewrites always @(*) begin … end to always_comb begin … end correctly, is refused under a plain --fix (needs --unsafe-fixes, confirmed), matching its documented Applicability::Unsafe.
  • explicit-begin confirmed off by default (a non-begin always_comb body drew nothing from a plain lucisv check) and fires once selected.
  • module-name-style with a custom style_regex = "[A-Z][a-zA-Z0-9]*" accepts MyModule that its own default (lower_snake) would reject — confirmed both ways.
  • banned-declared-name-patterns with patterns = ["[a-z_]+_tmp"] flags foo_tmp and not bar — the option-only rule actually finds something once configured, not just "0 by construction."

6. Opentitan census, re-run. lucisv check --no-config over hw/, this build: 4 212 findings total, exact match. Per-rule counts match the README's table exactly, including the zero-count rows (generate-label-prefix, banned-declared-name-patterns, one-module-per-file off so absent). Five findings read for each of:

  • typedef-structs-unions — all five in adc_ctrl_reg_pkg.sv, all reggen-generated anonymous nested structs, matching the README's characterization exactly (true, and the class opentitan's own config disables).
  • always-comb — all five in top_{darjeeling,earlgrey}/ip/ast/rtl/ *_pgd.sv, all always @(*) in the analog behavioural models the README names as true positives.
  • line-length — all five in hw/dv/sv/*, 101–113 characters, genuine over-runs, matching the "true, opentitan's own veriblelint sets the same 100-column limit" note.
  • generate-label — all three (opentitan only has three) in vendored lowrisc_ibex/pulp_riscv_dbg, matching exactly.
  • interface-name-style — all six (opentitan only has six) in vendored lowrisc_ibex/pulp_riscv_dbg interfaces (DMI_BUS_DV, JTAG_DV, ibex_mem_intf, …), matching exactly.

No misclassification found in any of the twenty-five findings read.

Top five rules by count: typedef-structs-unions (3 159), line-length (375), module-port (161, pre-existing), instance- shadowing (129, pre-existing), explicit-parameter-storage-type (88, pre-existing). Of the twelve new default-on rules, the sum is 3 593, matching the README's arithmetic exactly.

Recommendation for a lint-clean opentitan, rule by rule, Verible-default and opentitan's-own-config side by side:

  • typedef-structs-unions — Verible default on; opentitan's own hw/lint/tools/veriblelint/lowrisc-styleguide.rules.verible_lint disables it outright (-typedef-structs-unions). Do not change lucisv's shipped default (it should still match Verible for every project that has not opted out) — but this is the one rule I'd flag to the lead as "opentitan-shaped projects will want allow_anonymous_nested = true or an ignore," which the option already delivers; no code change needed, a documentation callout would help.
  • line-length — Verible default on at 100; opentitan's own config sets the same 100-column limit. No recommendation; the findings are exactly what opentitan's own tooling would also report.
  • always-comb, generate-label, interface-name-style — Verible default on for all three; nothing in opentitan's own veriblelint config disables any of them, and every finding read is a true positive in vendored or analog-behavioural code outside the RTL filesets opentitan lints most strictly. No recommendation to default any of these off; a project wanting silence there already has --exclude vendor/ and --exclude '*/ast/rtl/*' available, which is a project decision, not a shipped-default one.

7. Docs. README "Linting" rule table: 54 rows, matches --rules-doc's 54 ## sections by name (diffed the two header lists — identical sets). docs/site/src/content/docs/reference/rules.md's 54 headers diffed against --rules-doc's — identical. editors/vscode/README.md documents lucisv.lint.options with the same precedence note as README.md. TODO §34 checkboxes all ticked except QA, consistent with this file's Status/TODO. Drift test: in a throwaway worktree (git worktree add --detach from 1d4bddf, dev's diff applied with git apply, untracked files copied, removed after), added a FakeDriftRule to registry::all_rules() with no matching package.json entry — cargo test -p lucisv_server the_vscode_lint_toggles_match_the_registry FAILED as expected, naming fake-drift-rule in the right (registry) side only. Confirms the drift test is not vacuous. Worktree removed with git worktree remove --force; git worktree list afterward shows only the three worktrees that existed before.

Verdict: REWORK — two HIGH findings in crates/vlog_linter/src/ regex.rs: (a) (a*)*b-shaped user patterns cause exponential backtracking, reproduced hanging the real lucisv check binary until tools/guard.sh killed it (guard kill is itself HIGH per the runaway-guard rule); (b) unrecognized escape sequences (\b, \1–\9, and any other dialect escape lucisv's engine does not name) are silently accepted as a literal character instead of refused, contradicting the feature's own "refused by name" assumption and producing wrong naming verdicts with no diagnostic. Everything else verified clean: gates, both option front ends' validation and precedence (once tools/guard.sh's inability to forward stdin was worked around — a tooling note, not a product defect), 34.1 byte-identity, the 18 rules' behavior and fixes, the opentitan census and its arithmetic, the drift test's teeth, and the docs. One coverage gap noted (LOW): lucisv.lint.options "over the wire" has no checked-in tests/e2e.rs case despite 34.0(f)'s pin list, though the behavior itself is correct by my own live-session probe.

2026-09-04 — QA round 2 (Sonnet 5), re-check of the rework

Re-verified the rework that answers round 1's two HIGHs, in the lint-2 worktree only, everything guarded, opentitan read-only. Scratch under .../scratchpad/qa-34b/.

1. Gates, all reproduced independently. cargo fmt --all -- --check clean. cargo clippy --all-targets --workspace: 0 warnings; git diff 10b63e6 shows no new #[allow] anywhere in the whole diff (grepped the full diff, not just regex.rs). cargo test --workspace --no-fail-fast: 3 549 passed / 0 failed / 42 ignored / 48 binaries — exact match, counted by summing every test result: line, including regex::tests::an_ambiguous_repeat_is_linear_not_exponential, an_unsupported_escape_is_refused_by_name and every_probe_agrees_with_python_re_fullmatch all passing. Corpus gate (scripts/score.sh against the main tree's corpus/, read-only, 860 files): {"passing":814,"total":820,"pct":99.3}, same five failure categories. --stdout byte-identity over the same 860 files vs ~/.cache/lucisv-baselines/lucisv-0.36.0: 0 differ.

2. Linearity, adversarially.

Read regex.rs end to end. Regex::add (the epsilon-closure walk over Split/Jump) marks seen[pc] = true before recursing into that state's targets, and returns immediately on a pc already marked — so a cycle of Split/Jump instructions (exactly the shape (a*)* compiles to: the outer star's Split/Jump wrapping the inner star's own Split/Jump) terminates the moment it revisits a state, rather than looping. Because seen is sized to self.prog.len() and reset once per input character (on_next is cleared before each character's closure is computed, on_current fed by the previous character's on_next via swap), the total work of one character's closure is bounded by the program length regardless of how many epsilon paths reach the same handful of live states — this is the textbook Thompson-NFA/Pike-VM construction, and the reasoning is airtight: a pc's reachable non-epsilon successors are a fixed set, so visiting it a second time within the same character can add nothing add() wouldn't already have added the first time. is_match's outer loop is O(text) characters, each doing O(prog) closure and transition work — O(prog × text) overall, matching the doc comment's claim, and no path through compile/emit/is_match backtracks or holds a continuation.

Timed the shipped release binary (not an extracted copy) under tools/guard.sh -m 1 -t 10, for all nine required patterns — (a*)*b, (a|aa)*b, (.*)*x, ((a*)*)*b, (a+)+b, (a?)*b, (a*)*(a*)*(a*)*b, [a-z]*[a-z]*[a-z]*[a-z]*x, and a 66-character overlapping-word alternation ((ab|abab|ababab|abababab|ababababab|abababababab|ababababababab)*z) — each as a lucisv.toml [lint.signal-name-style] style_regex, against wire names of 30/200/1000/5000 a-characters (36 runs). Every run exits 1 (one violation, the pattern correctly not matching an all-a name) with no guard kill. Wall time including process spawn and guard.sh's own overhead was flat at 1.06 s across every combination — the guard's one-second poll floor, not lucisv's; re-measured the same 36 runs wrapped in /usr/bin/time -p inside the guard to get under that floor: every one reports real 0.00s (below time -p's hundredths-of-a-second resolution) at all four lengths for all nine patterns, a ×166 growth in name length with no detectable growth in time. No super-linear growth anywhere — the ladder is flat, not just sub-second.

3. Correctness vs Python.

Extracted all 71 rows of the dev's probe table (regex.rs's every_probe_agrees_with_python_re_fullmatch) with a character-accurate Rust-string-literal parser (a naive regex-based extractor first mis-split two rows containing \n/\t text escapes and silently dropped them — re-done properly): all 71 checked against CPython 3's re.fullmatch, 71/71 agree.

Wrote 62 probes of my own (nested groups three deep, alternation inside +/*, classes with ranges/negation/\d\s-escapes, . vs \n, (a|)/(|a) empty alternatives including nested and repeated ones, ? after a group, anchoring including abc vs xabcx) — all 62 first verified against CPython, then run against a standalone extraction of regex.rs's actual Regex/Parser (source copied out of the crate, pub(crate) widened to pub, compiled with plain rustc so nothing in the dev's tree was touched, same technique round 1 used): 62/62 agree with both Python and lucisv. One of my first 62 ("a[\\s\\S]*b", intended as an "any character including newline" idiom) was not a lucisv bug but a mistake in my own probe: \S is a documented refusal inside a [...] class (the negated shorthands need set arithmetic this engine deliberately doesn't do), so lucisv correctly refused to compile it; replaced with a valid probe ([a\n]+) before counting it in the 62.

20 refusal probes, exactly the list given (\1 \b \B \A \z \Z \p{L} \x41 A \0 \e \f \v \h \k<n> \Q \E \G \R \X — the bare A in the middle is a deliberate control, not an escape): all 19 real escapes were refused by name (unsupported escape `\c` , naming the supported list), and the one control item, the plain literal A`, correctly compiled — confirming the refusal is specific to unimplemented escapes and not over-broad. No silent acceptance of any listed escape.

Confirmed through the CLI on two of them: a lucisv.toml with [lint.signal-name-style] style_regex = "\bword\b" (a literal backslash in the file, not a doubled one — TOML's own \\ would itself decode to one backslash before reaching the pattern, which is a config-authoring detail, not a parser bug) fails lucisv check with exactly

<config>:2: rule `signal-name-style` `style_regex`: `\bword\b` is not a
valid pattern: unsupported escape `\b` (supported: \d \D \w \W \s \S \n
\t \r, and \<punctuation> for that character)

exit 2; and [lint.constraint-name-style] pattern = "(a)\1" fails the same way naming `\1`. Confirmed through the editor: a standalone script speaking framed JSON-RPC at the real lucisv-server binary (same technique round 1 used, since no checked-in tests/e2e.rs case exists for lucisv.lint.options) pushed didChangeConfiguration with lucisv.lint.options.signal-name-style.style_regex = "\bword\b" then opened a file declaring IO_CLK: exactly one window/logMessage warning, lucisv: lucisv.lint.options.signal-name-style.style_regex: `style_regex`: `\bword\b` is not a valid pattern: unsupported escape `\b` … ; ignored, and the rule kept running on its default ([a-z_0-9]+) — the diagnostic signal IO_CLK is not lower_snake_case still fired. A second push, lucisv.lint.options.constraint-name- style.pattern = "(a)\1", produced the matching second warning. Neither push dropped the linter or crashed the session.

4. Both front ends — item 4's own scenario. Covered by (3) above: the CLI refusal names <config>:<line>:, the rule and the option; the editor logs and keeps the default running. No new finding.

5. Verdict stability. The 18-rule opentitan census (lucisv check --no-config, read-only, over ~/repo/opentitan/hw): 4 212 findings total, exact match to the README. Full per-rule breakdown reproduced independently via --output-format json and counted rule-by-rule: every non-zero row matches the README's opentitan column exactly, including the top five by count (typedef-structs-unions 3 159, line-length 375, module-port 161, instance-shadowing 129, explicit-parameter-storage-type 88) and the zero/absent rows for every off-by-default rule. git -C ~/repo/opentitan status --porcelain before and after: only the three 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) — read-only held.

The four naming rules (--select enum-name-style,struct-union-name- style,module-name-style,parameter-name-style --no-config), re-derived against ~/.cache/lucisv-baselines/lucisv-0.36.0: corpus 43 findings, opentitan 35 findings, stdout and stderr byte-identical in both trees (diff empty both ways) — matching the README and round 1's own numbers exactly.

6. Docs. regex.rs's //! states the supported subset (literals, ., classes with the shorthands, the nine escapes, groups/alternation/ *+?, anchors accepted-and-ignored), the refusals (counted repetition, lookaround, every other escape) and why it cannot hang (Thompson-NFA simulation, O(pattern × name) by construction) — matches the actual escape()/class_escape()/emit_repeat() code exactly, no drift. README.md's "Linting" table: 54 rule rows (filtering out the three-row severity legend that a naive extraction first miscounted as rule rows) match lucisv check --rules-doc's 54 ## sections by name, identical sets. docs/site/src/content/docs/reference/rules.md's 54 headers diffed against the same list: identical. editors/vscode/ README.md documents lucisv.lint.options with the same "this setting, then lucisv.toml, then the default" precedence note as README.md line 349. The feature README's Assumptions bullet on the regex subset and the rework work-log entry both read true against the shipped code. TODO.md §34's checkboxes match this file's Status/TODO (34.0–34.3 and Gates ticked, QA still open pending this entry).

No new findings. Both of round 1's HIGHs are closed: the engine is structurally linear (Thompson-NFA, verified by reading the closure code and by a 36-point timing ladder flat from 30 to 5 000 characters across nine adversarial shapes), and every escape this engine does not implement is refused by name on both front ends, with the rule falling back to its default rather than going silent. The LOW coverage gap from round 1 (no checked-in tests/e2e.rs case for lucisv.lint.options over the wire) still stands — worked around again with a throwaway script, not fixed — and is still the lead's to schedule, not a blocker for this rework.

Verdict: PASS.

Review

2026-09-04 — lead. Accepted after one rework. The option plumbing is the durable part of this wave: one validator behind both front ends, the same message with file and line on the CLI and a logged, dropped entry in the editor, precedence stated once and pinned, --rules-doc as the generated truth. The rework was necessary and the fix is the right kind: QA showed a user pattern could make every lint run exponential and that unknown escapes were silently literal; the matcher is now a Thompson-NFA simulation — linear by construction, proved on nine adversarial shapes at four name lengths — and unknown escapes are compile errors named through both doors, with a 71-row table verified against CPython. The engine swap changed no verdict (the 4 212-finding opentitan census is identical before and after). One ruling at review, applied here: typedef-structs-unions keeps Verible's default of on, but allow_anonymous_nested defaults to true — every one of its 3 159 opentitan findings was a nested struct inside a typedef in a generated register package, and opentitan's own Verible config disables the rule for exactly that; the doc says why and one option restores the stricter reading. The generate-label phantom finding (177 of 180 from error-recovered UVM files) closed by parsed_cleanly() is the kind of census-driven fix this project exists for. Two LOWs left open and noted: no checked-in e2e case for lucisv.lint.options over the wire (QA drove it by hand twice), and always-comb on plain .v files being a judgment call the unsafe fix and one ignore already cover. Ships in 0.38.0; §35 takes the remaining twenty Verible rules.