TODO section 25; closes docs/topo.md 2.9-20, 2.9-21, 2.9-22; opens 2.9-23. A comment written where no AST node had a field was never deleted: bump queued it and take_meta handed it to the next node, so it printed one node later and verify.rs refused the whole file. About seventy named comment fields now own those gaps - SegmentComments on member/scope/ index/range segments (one parse_postfix_segment replacing three hand-copied loops), one [a:b] grammar, BinaryComments on inside, casts, unary/postfix, if/case/for/foreach/do-while headers, @ and # timing, Stmt::before_semi with StmtKind::takes_semi() as the single owner of the ; (debug_assert enforced), labels on ten nodes, qualifier runs as Vec<Qualifier>, function/task/module/package/class/typedef/enum/struct headers, declarators, ports, connections, instantiations. Each prints through Fmt::slot_comments, a no-op when empty: 860 corpus and 3 975 opentitan files are byte-identical to v0.30.0 (QA reproduced from an independent baseline build). Four exhaustive gap fuzzers at zero - covergroup 329, fragment 153, constraint 395 (committed at last), RTL 352 (new) - are the regression gate. verify.rs untouched, ten attack pairs. Expression slots are boxed so Expr stays 96 bytes; ast::size_pins asserts it (QA's one finding). Also: nav::definition gains the macro branch hover already had (H5); a cast's type binds as a type via bind_type_expr, FACTS_FORMAT 13 -> 14 (M11); rename reports the candidate references that stayed unresolved through the overlay, one line per file and unit (2.9-20); the scoped name join keeps an escaped segment's terminator (2.9-21). One flagged edit outside scope: a .. in vlog_linter/src/signals.rs patterns. docs/features/comment-slots/README.md. Co-Authored-By: Claude Fable 5 <[email protected]>
covergroup bodies
Goal
Give covergroup g ... endgroup a real AST — the name, the formal arguments,
the with function sample (...) header, the clocking event, every coverpoint,
cross, bin and option.x = v, and the endgroup : g label — so that the
formatter, the binder, the linter, rename, hover and go-to-definition can all
see inside a covergroup. Until v0.27.0 a covergroup was an
ItemKind::Verbatim(RawText) leaf produced by a flat token scan
(parser.rs::parse_covergroup: expect_kw("covergroup"), then bump until
endgroup): the parsed label was discarded, no name span existed, and
nothing inside bound — so a rename of a rand property left
coverpoint addr untouched and cg.cp was unreachable. This is round 2 of
the constraint-bodies wave (TODO.md §21) and follows that round's shape
exactly: a structured parse behind a Rewind snapshot, a byte-for-byte
fallback, no keywords reserved, a named comment field for every slot, and an
exhaustive gap fuzzer — this time from day one rather than after a rework.
Assumptions
- The covergroup sub-grammar is modelled where real code writes it, and
nowhere else. Everything the parser does not recognise rewinds to the
pre-round verbatim capture. The fallback is measured, not assumed:
SourceFile::covergroups/covergroup_fallbackscount both sides, and the numbers are in the work log. Over OpenTitan's 3 975hwfiles the count is 544 structured, 0 fallbacks. coverpoint,cross,bins,ignore_bins,illegal_bins,wildcard,binsof,intersect,option,type_optionandsampleare matched by text, not reserved. The argument isconstraint-bodies' word for word:is_keywordgatesexpect_nameandBinder::use_member, so reserving ten more words would stop a file that declaresint option;from parsing and would silently drop every reference to a signal calledcross. Inside a covergroup body their position leaves no other reading.default,sequence,iffandwithare already keywords and are read as such. Consequence:token.rs,pairs.rs,tests/grammar.rsand the editor grammar are untouched, so the round does not sit on thetoken.rschoke point at all.- Which grammar a
(opens is decided by where it is written, not by what is inside it. A coverpoint bin's= ( ... )is a transition list (IEEE 1800 §19.5.1.2); a cross bin's is a parenthesized select expression (§19.6.1). That is what the LRM says, and it is the only rule that gets opentitan'sbins zero_delay_5 = (1'b1[*5]);right — a transition list with no=>anywhere in it. See the work log. &&and||in a select expression are read left-associatively at one precedence level. The LRM binds&&tighter. lucisv evaluates neither and prints no parentheses of its own, so the shape of the tree cannot reach the output; recorded because it is a difference, not because it bites — the same noteconstraint-bodiesmade abouta <-> b -> c.- A covergroup is accepted wherever it was before: class, module, interface, package and file scope alike. No new legal-position check.
iteminside a bin'swith ( ... )filter is the coverpoint's own sampled value, not a name of the enclosing class (IEEE 1800 §19.5.1.1). It is bound in a scope of its own — see Design — because a class property calleditemis common in UVM and letting it capture the filter would make renaming that property rewrite a filter that never named it.- A bin declares no symbol. Nothing in SystemVerilog names a bin from an
expression, so a symbol for one would be an outline entry no reference can
ever point at — and
SymbolKindis aFACTS_FORMAT-bumping choke point.cg.cpis the reach the round buys;cg.cp.binis not a thing.
Handshakes
Consumed, unchanged:
classes—verbatim_since/RawTextand theRawText.colre-indent contract, now reached only through the fallback. The fallback re-runs the old function body verbatim (Parser::parse_covergroup_verbatim), so a covergroup the grammar does not know produces byte-identical output to v0.27.0, and the parser testan_unrecognised_covergroup_rewinds_to_exactly_the_old_capturepins the text, the source slice and thecol.constraint-bodies—Rewind/rewind_mark/rewind_to,Parser::gap_before,word_at,takes_semias the single owner of a;, andparse_constraint_expr_set(the{ a, [lo:hi] }range list, which is also a bin's value list and anintersectset). All reused as they stand; none of them changed.escaped-identifiers— every name this round prints goes throughformat::name_doc/named: the covergroup name, theendgrouplabel, coverpoint and cross labels, bin names, and thesamplemethod.dv-statements/ the shared expression grammar — a sampled expression, a bin value, aniffguard and awithfilter are ordinaryExprs.parse_tf_portsandparse_sens_list— a covergroup's formal list and itssamplefunction's aretf_port_lists, and@(posedge clk)is the very event listalways @(...)reads.
Promised to others:
ItemKind::Covergroup(Box<CovergroupDecl>)is a newast.rsvariant. Pertopo.md§3.3 it costs aformat.rsarm (delivered), abind.rsarm (delivered), aspans.rsarm (delivered) and avisit.rsarm — the last one is written and does nothing, deliberately, for the reasonItemKind::Constraint's does: a covergroup body holds cover items, notItems orStmts. Rules that need to see inside read the reference table.FACTS_FORMAT11 → 12.SymbolKind::Covergroup,CoverpointandCrossare new kinds, so a store written by an older build is not read.ScopeKind::Covergroupis new (vlog_semantic). It costs no arm: nothing outsidemodel.rsmatchesScopeKindexhaustively.Parser::at_postfix_segmentno longer takes a[that is immediately followed by*,->or=. No index expression can start with one of those, so this says "that[is not an index" everywhere rather than only inside a covergroup — which was already true, and is now acted on. It is what lets1'b0[*1:10]parse as a transition repetition instead of sending the whole covergroup down the fallback.Parser::no_with— one bool, set only while a bin's spec operand is read, that stopsat_postfix_segmentfrom taking the bin's ownwith ( ... )filter as an array method's iterator argument. Cleared on the error path too, so a failed speculative parse never leaves it set.workspace.rs::collect_membersrecurses into a covergroup, socg_inst.cpfinds a coverpoint declared in another file, exactly as it already recursed into a nested class ortypedef.is_exportedgains aCovergrouparm (its coverpoints, crosses andsample) and listsCovergroupamong what a package or class exports.resolve.rs::member_scopeaccepts a covergroup, so a handle whosetype_nameis a covergroup opens it for a..undriven-netchanges verdict: a net read only by a coverpoint used to have zero reads (the whole block was anopaque_span) and be skipped; it now has a real one and is reported. Pinned incrates/vlog_linter/tests/cases/covergroups.lint.signals.rsno longer routes a covergroup toopaque_spans. A covergroup samples its operands and drives nothing; those reads are ordinary resolved references now. A covergroup that fell back is still anItemKind::Verbatimand keeps the opaque posture.on_type.rs:covergroupleft theOPAQUElist. Its items are laid out from a real tree now, at one indent from the header, which is exactly what an ordinary block frame computes; its bins bodies sit behind a{, where an open bracket already silences the model, so they need no entry for the reason a constraint's do not. Pinned bya_covergroup_body_indents_like_any_other_block.SourceFilegainscovergroups: u32andcovergroup_fallbacks: u32— parse statistics, documented as diagnostic-only, that nothing in the tree depends on.constraint_fallbacksis left exactly as round 1 wrote it rather than folded into a struct: churning a field five tests read to gain symmetry is not worth a line of diff.pairs.rsis untouched and keeps working.pairs::analyzereads tokens, not the tree, socovergroup/endgrouprainbow, folding and thewith function samplerule are unaffected by a structured node. Thepairs.rsunit tests are green and were not edited.
Requests filed, not acted on:
The 52 gaps the fuzzer still fails are— closed 2026-09-02 bydocs/topo.md§2.9-22'sdocs/features/comment-slots/README.md. Every one of them was in shared name, declaration or expression machinery (theclass/moduleheader,parse_tf_ports,parse_label,parse_sens_list,parse_value_range, member expressions,take_member_prefix) and every one failed identically outside a covergroup, whichthe_gaps_the_fuzzer_still_fails_fail_outside_a_covergroup_tooasserted rather than claimed. All eighteen shapes now keep their comment, so that test is deleted anda_comment_in_every_covergroup_gap_still_formatsasserts 329 gaps, 0 failing — both in the same commit, as this entry promised.- Files edited outside the stated ownership list: none, except one new
#[ignore]d probe,crates/vlog_parser/tests/census.rs, which is what produces the sweep numbers in the work log (CENSUS=<dir> cargo test -p vlog_parser --test census -- --ignored --nocapture). It is disclosed here rather than added silently; delete it if the lead would rather the measurement stayed external.
Design
AST
ItemKind::Covergroup(Box<CovergroupDecl {
qualifiers: Vec<String>, // local / static / protected
before_name, name: Name, before_args,
args: Option<Vec<TfArg>>, // None when no parens were written
event: Option<CoverageEvent>, // `with function sample(...)` | `@(...)`
before_semi,
items: Vec<CoverItem>, dangling,
end_label: Option<Name>, before_end_semi, end_semi,
}>)
CoverageEvent::{ Sample(Box<SampleFn>), Clocking { before, sens: SensList } }
SampleFn { before_with, after_with, after_function, name: Name,
before_args, has_parens, args: Vec<TfArg> }
CoverItem { meta, kind, before_semi, span }
CoverItemKind::
Coverpoint(Box<CoverpointDecl { label, after_kw, expr, iff, before_body, body }>)
| Cross(Box<CrossDecl { label, after_kw, items: Vec<ExprItem>, iff, before_body, body }>)
| Option(Box<OptionAssign { target: Expr, comments, value: Expr }>)
| Directive(RawText) | Empty
CoverLabel { name: Name, comments } // the `cp :` a label is written as
CoverIff { before_kw, after_kw, after_open, before_close, expr }
CoverBody { items: Vec<BinItem>, dangling, span }
BinItem { meta, kind, before_semi, span }
BinItemKind::{ Bin(Box<BinDecl>), Option(Box<OptionAssign>), Directive, Empty }
BinDecl { wildcard, after_wildcard, kind: BinKind, before_name, name: Name,
array: Option<Box<BinArray { before, comments, size: Option<Expr> }>>,
eq_comments, spec: BinSpec,
with_expr: Option<Box<BinWith>>, iff: Option<Box<CoverIff>> }
BinKind::{ Bins, IgnoreBins, IllegalBins }
BinSpec::
Values(Vec<ExprItem>) // = { 0, [1:3], $ }
| Transitions(Vec<TransSet>) // = (a => b, c), (d => e)
| Default | DefaultSequence { comments }
| Select(SelectExpr) // = cp_x, = binsof(a) && !binsof(b)
TransSet { meta, ranges: Vec<TransRange>, dangling, span }
TransRange{ arrow_comments, items: Vec<ExprItem>, repeat: Option<Box<TransRepeat>> }
TransRepeat { before, after_open, op: "*"|"->"|"=", comments, lo, hi, colon_comments }
SelectExpr::
Binsof(Box<BinsofSel { after_kw, after_open, before_close, name,
before_intersect, after_intersect, intersect }>)
| Not { comments, expr } | Binary { lhs, op, comments, rhs }
| Paren { comments, expr } | Expr(Expr)
Three deviations from the brief's sketch, argued in the work log:
event is one CoverageEvent rather than a sample field beside an event
field (the LRM makes them alternatives, so two fields could represent a shape
no source can write); OptionAssign.target is the Expr the option path is
written as rather than a keyword plus a Vec<Name> path; and there is no
SymbolKind::Bin.
The fallback
Parser::parse_covergroup takes a Rewind snapshot — cursor, both pending
comment buckets, nesting depth, chain links, open conditional regions,
diagnostics length — attempts parse_covergroup_decl, and on any error
restores the snapshot and re-runs parse_covergroup_verbatim, which is
v0.27.0's parse_covergroup body character for character. The comment buckets
are part of the snapshot because the speculative parse harvests comments into
Metas it then throws away, and hard invariant #3 does not forgive that;
a_covergroup_fallback_keeps_the_comments_written_around_it is the test that
would have caught getting it wrong.
The structured parse closes with expect_kw("endgroup"), not
expect_closer — an unclosed covergroup must fail here so the rewind puts
the old flat scan back, and that is what records the tolerant diagnostic. One
message, from one place, and the same one v0.27.0 wrote:
a_covergroup_with_no_endgroup_falls_back_and_reports_it_once pins that there
is exactly one.
Layout
- The whole header on one line:
covergroup g(args) with function sample(args) @(posedge clk);— the two argument lists break like any port list when they do not fit. The parens hug the name, which is whatfunction f(int a);already does everywhere else in lucisv. - One cover item per line at one indent;
endgroupback at the header's column, with the label the source wrote and a stray;if there was one. cp: coverpoint expr iff (cond) {— a braced body cuddles onto the header line and holds one bin per line at one further indent,}at the header's column: a constraint set's layout, for a construct that reads the same way. An empty body prints{}.bins name[4] = spec with (expr) iff (cond);— the value list breaks like every other braced list,:=-style operators do not exist here, and the three bins keywords,wildcard, the three repetition operators and the twodefaultspellings are printed back exactly as written because each means something different.option.per_instance = 1;prints as the assignment it is.- A directive item prints as raw text, both arms of an
`ifdefstanding as ordinary items of the one body. - A covergroup that fell back prints exactly as it did in v0.27.0.
Comment slots
Every keyword and punctuation position this round introduced owns the comments
written in front of it, in a named field the formatter prints in place — the
rule constraint-bodies arrived at after its rework, applied here from the
first commit. The slots:
| written here | kept in |
|---|---|
covergroup /*c*/ g |
CovergroupDecl::before_name |
g /*c*/ (args) |
CovergroupDecl::before_args |
) /*c*/ with · ) /*c*/ @ |
SampleFn::before_with · Clocking::before |
with /*c*/ function /*c*/ sample /*c*/ ( |
after_with, after_function, before_args |
… /*c*/ ; |
CovergroupDecl::before_semi |
endgroup : g /*c*/ ; |
CovergroupDecl::before_end_semi |
<item> /*c*/ ; |
CoverItem::before_semi |
cp /*c*/ : /*c*/ coverpoint |
CoverLabel::comments |
coverpoint /*c*/ expr · cross /*c*/ a |
after_kw |
… /*c*/ iff /*c*/ ( /*c*/ e /*c*/ ) |
CoverIff's four fields |
) /*c*/ { |
before_body |
wildcard /*c*/ bins /*c*/ v |
after_wildcard, before_name |
v /*c*/ [ /*c*/ 4 /*c*/ ] |
BinArray::before + comments |
] /*c*/ = /*c*/ spec |
BinDecl::eq_comments |
default /*c*/ sequence |
BinSpec::DefaultSequence::comments |
spec /*c*/ with /*c*/ ( /*c*/ e /*c*/ ) |
BinWith's four fields |
a /*c*/ => /*c*/ b |
TransRange::arrow_comments |
b /*c*/ [ /*c*/ * /*c*/ 3 /*c*/ ] |
TransRepeat::before, after_open, comments |
[* 1 /*c*/ : /*c*/ $] |
TransRepeat::colon_comments |
binsof /*c*/ ( /*c*/ a /*c*/ ) /*c*/ intersect /*c*/ { |
BinsofSel's five fields |
! /*c*/ binsof · a /*c*/ && /*c*/ b · ( /*c*/ e /*c*/ ) |
SelectExpr's per-variant fields |
target /*c*/ = /*c*/ value |
OptionAssign::comments |
Two rules keep them from fighting, both inherited from round 1:
one owner per gap — CoverItemKind::takes_semi / BinItemKind::takes_semi
is the single answer to "who writes the ;", read by the parser that consumes
it and the formatter that writes it back (a coverpoint that wrote a { } body
takes none) — and a gap belongs to the construct only when the token that
closes it was written, which is Parser::gap_before.
verify.rs is untouched. Token equivalence is what proves the layout, and
the round ships twelve new attack pairs in tests/verification.rs regardless
(invariant #4's standing pattern: "untouched + rejection tests anyway").
Binder
SymbolKind::Covergroup, declared where the covergroup is written, with aScopeKind::Covergroupchild scope whose parent is that same scope — so every sampled expression, bin value andiffguard binds lexically to a class property withthis.implicit, exactly as a constraint body's names do.- That scope declares the covergroup's formal arguments (
TfArg), thesamplemethod (Function, socg.sample(x)resolves) and its arguments, and oneCoverpoint/Crosssymbol per labelled coverpoint and cross. An unlabelled coverpoint declares nothing, which is what the LRM says: there is no name to reach it by. cross a, bandbinsof(cp_a)are ordinary lexical uses, so they land on thoseCoverpointsymbols.- A clocking event is bound in the enclosing scope: it is written in the header, before anything inside exists.
- An
option.xtarget is not recorded at all — an option names a covergroup built-in, not anything this crate models — while its value is an ordinary expression and is. - A bin's
with ( ... )filter is bound in aScopeKind::Blockchild that declaresitem.itemis never written as a declaration, so the declaration points at the first use of it inside the filter: every name this crate records must be locatable in the source (the corpus test's "0 names unplaced" contract), and an invented span is not. A filter that never saysitemdeclares nothing.
Status / TODO
ast.rs:ItemKind::Covergroup,CovergroupDecl,CoverageEvent,SampleFn,CoverItem(Kind),CoverpointDecl,CrossDecl,CoverLabel,CoverIff,CoverBody,BinItem(Kind),OptionAssign,BinDecl,BinKind,BinArray,BinSpec,BinWith,TransSet,TransRange,TransRepeat,SelectExpr,BinsofSel,SourceFile::covergroups/covergroup_fallbacks- Parser: every header, cover-item, bin and select shape; the exact rewind-to-verbatim fallback
- Formatter: canonical layout; the fallback prints exactly as before
verify.rsuntouched; the two existing covergroup attack pairs re-derived and twelve more added- Binder:
SymbolKind::Covergroup/Coverpoint/Cross,ScopeKind::Covergroup, the implicititem, export rules,FACTS_FORMAT12 - Linter:
visit.rsarm (documented no-op),signals.rsno longer opaque for a structured covergroup,covergroups.lint - Server:
symbols.rslabel + LSP kind,completion.rskind,tokens.rshighlight,covergroupout ofon_type.rs'sOPAQUE - The gap fuzzer, committed, with its classification asserted beside it
- Tests: 29 parser (plus 3 pre-existing ones re-derived), a
spans.rswalker and 2 sources, 30 formatter cases + theclasses.casescase re-derived, 14 verification (12 attack pairs + the fuzzer and its classification), 12 semantic, 2 e2e, 4 lint cases - Gates: fmt / clippy /
cargo test --workspace/ corpus gate / vsix smoke / opentitan read-only sweep - Filed, not done: the 52 shared-machinery comment slots
(
docs/topo.md§2.9-22).
Work log
2026-09-02 — dev
The ten words the round did not reserve. coverpoint, cross, bins,
ignore_bins, illegal_bins, wildcard, binsof, intersect, option,
type_option and sample are all matched by text through round 1's
word_at, plus a two-line bin_kind_at. The argument is round 1's, and the
token.rs choke point is untouched. sequence is the one word that is read
as a keyword — because it already is one (sequence ... endsequence), so
default sequence asks is_kw rather than word_at; the first draft asked
word_at and default sequence fell back, which the probe caught in the
first ten minutes.
Which grammar a ( opens: the round's one real design correction. The
first draft decided between a transition list and a parenthesized select
expression by scanning for a => directly inside the parentheses. It read
opentitan's hw/ip/rom_ctrl/dv/cov/rom_ctrl_cov_if.sv wrong:
bins zero_delay_5 = (1'b1[*5]);
is a transition list of one range with a repetition and no arrow at all, so
the scan said "select expression", 1'b1 is not a name, and the whole
covergroup fell back. The fix is the LRM's own rule: a coverpoint bin's
( ... ) is a trans_list (§19.5.1.2) and a cross bin's is a
select_expression (§19.6.1) — decided by where it is written, which the
parser already knows, so parse_bin_spec takes an in_cross flag and the
lookahead scan is gone entirely. Simpler and correct.
Two guards in shared expression machinery, both stated as global truths.
at_postfix_segmentno longer takes a[immediately followed by*,->or=. Without it1'b0[*1:10]sends the whole covergroup down the fallback, becauseparse_postfix_innertakes the[and then fails on the*. It needs no covergroup context: no index expression can begin with one of those three tokens anywhere in the language, so the guard says something that was already true.a_repeat_bracket_never_steals_an_ordinary_indexpins thatq[3],r[a:b]ands[i +: 2]are unaffected.Parser::no_with— one bool, set only while a bin's spec operand is read.with (is a postfix segment everywhere else (an array method's iterator argument); in a bin spec it introduces the bin's own filter, and the expression parser has to stop in front of it. It is cleared before the?, so a failed parse never leaves it set, anda_bins_with_filter_is_never_read_as_an_array_methodpins both halves in one file. The alternative — a private restricted postfix parser — would have duplicated twenty lines ofparse_postfixto say the same thing.
The bin spec's bare operand is read at the postfix level rather than with
parse_ternary, so it stops in front of the && and || this grammar reads
itself, and it accepts the call opentitan writes in
hw/ip/csrng/dv/cov/csrng_cov_if.sv: bins single_exc[] = single_masks(num_hw_apps);. Tools accept it, the LRM does not spell it, and
reading it costs nothing. Those two files were the round's only two fallbacks
in all of opentitan; both are now structured, and both shapes have parser
pins.
Three AST deviations, all shape-not-substance. CoverageEvent is one
field rather than the brief's sample beside event, because IEEE 1800 §19.3
makes the two spellings alternatives of one coverage_event and two fields
could hold a shape no source can write. OptionAssign.target is the Expr
the path is written as rather than a keyword plus a Vec<Name>: an option
name resolves to nothing lucisv models, the expression printer already writes
a dotted chain back exactly, and splitting it would only have bought
per-segment comment slots that no other member access in the language has
(§2.9-22). And there is no SymbolKind::Bin, for the reason in Assumptions.
item needed a scope, and then it needed a span. Binding a with filter
in the covergroup scope gives a wrong answer whenever the class declares a
property called item — which UVM code does constantly — and then renaming
that property rewrites a filter that never named it. So the filter gets a
Block scope of its own declaring item. The first draft gave that
declaration an empty span, on the theory that rename's unspelled refusal
would then protect it; the corpus test disagreed, loudly and correctly —
every_corpus_file_analyzes_without_panicking asserts 0 names unplaced, and
11 implicit items were unplaced. The declaration now points at the first use
of item inside the filter, which slices back to item exactly. If the
filter never says item, nothing is declared.
visit.rs gets an arm that does nothing, on purpose — round 1's ruling,
unchanged: a covergroup body contains cover items and expressions, not Items
or Stmts, so an item or statement walk has nothing to descend into. The
rules that see inside do it through the reference table, and one of them
changed verdict (below).
One real lint behaviour change, pinned. undriven-net skips a net with
reads == 0. A net read only by a coverpoint used to have zero reads, because
the whole block was an opaque_span; it now has a real one. On
module m;
wire w;
covergroup cg;
cp: coverpoint w;
endgroup
endmodule
v0.27.0 reports nothing and this tree reports w, correctly.
covergroups.lint case 1 pins it, case 2 pins that the verbatim fallback goes
back to silence.
on_type.rs: covergroup left OPAQUE, and the entry it left behind is
the honest one. The list is "scopes whose bodies the formatter keeps
byte-for-byte". A covergroup's no longer is, and an ordinary block frame
computes exactly the right answer — one indent from the header. Its bin bodies
sit behind a {, where an open bracket already silences the model, which is
why a constraint needs no entry either. The old test's fixture was a
covergroup; it is now a property, which is what the list is still for.
The gap fuzzer, from day one. Round 1 built one after QA found six dropped
comment slots; this round wrote it first and shipped it as a test:
a_comment_in_every_covergroup_gap_still_formats puts a /*C*/ in every
inter-token gap of ten fixtures covering the whole sub-grammar — 329 gaps
— and demands format_source succeed and be idempotent for each. It found
exactly one slot of this round's own: the gap between a repetition's [ and
its operator, now TransRepeat::after_open. The other 52 are shared
machinery, and the classification is asserted rather than asserted-in-prose:
the_gaps_the_fuzzer_still_fails_fail_outside_a_covergroup_too runs the
equivalent non-covergroup source for each of the eighteen shapes and requires
it to fail too. All 18 do.
Amended 2026-09-02 (
comment-slots). All 52 are fixed and the classification test is deleted; the count below is history. The fuzzer now readsassert_no_failing_gaps("covergroup", COVERGROUP_FIXTURES, 329)— the same 329 gaps, none of them failing — and shares that helper with three sibling fuzzers (fragment, constraint, RTL), all at zero.
| shape | n | owner |
|---|---|---|
class /*c*/ c / class c /*c*/ ; |
18 | the class header |
module /*c*/ m / module m /*c*/ ; |
2 | the module header |
a tf_port_list type, dimensions and name |
13 | parse_tf_ports |
endgroup /*c*/ : g / endgroup : /*c*/ g |
4 | parse_label |
@ /*c*/ ( / @(posedge /*c*/ clk) |
2 | parse_sens_list |
[ /*c*/ 0 : 3 /*c*/ ] |
8 | parse_value_range |
option /*c*/ . /*c*/ per_instance |
4 | member expressions |
local /*c*/ covergroup |
1 | take_member_prefix |
That is the honest bar and it has not been quietly widened: an
ItemKind::Verbatim body made all of these work before this round, so a file
with a comment in one of them is a real regression for covergroups
specifically — it is just not one this lane can fix without editing machinery
it does not own. Filed as request 1. No opentitan or corpus file hits one:
every file that formatted before still formats.
Measurements.
OpenTitan hw, 3 975 .sv/.svh, read-only --no-cache --check, against a
release build of v0.27.0 (53bc293) in a detached worktree. The checkout had
exactly three modified files before the sweep and exactly the same three after
(the owner's aes/dv/tb/tb.sv and the two ast.svs).
| v0.27.0 | this tree | |
|---|---|---|
| files that fail to format | 12 | 12 |
| newly failing (set difference) | — | 0 |
| newly fixed | — | 0 |
The two error lists are byte-identical when sorted. --check runs
format_source, which runs both halves of the safety net, so "12 failures,
the same 12" is also the statement that 3 963 real files — carrying 544
freshly laid-out covergroups — are token-equivalent to their input and
idempotent. That is why verify.rs needed no widening.
Tolerant-mode diagnostics over the same 3 975 files, measured with the
census probe against each tree's own vlog_parser:
| v0.27.0 | this tree | |
|---|---|---|
| total diagnostics | 1 105 | 1 105 |
| files with any | 12 | 12 |
| per-file difference | — | none (diff of the per-file lists is empty) |
The covergroup census, opentitan hw:
| count | |
|---|---|
| covergroups parsed structured | 544 |
| covergroups that fell back | 0 |
constraint_fallbacks (round 1's number, unmoved) |
29 |
Layout. 81 of the 3 963 opentitan files that format change layout, and
all 81 verify — the count comes from formatting every file through both
binaries' --stdout and diffing, and --stdout only succeeds when
format_source's own token-equivalence check passes.
The DV sweep the brief asked for: every .sv/.svh under hw/dv,
hw/ip/*/dv and hw/top_*/dv containing the word covergroup — 87 files
— formatted with --stdout and then formatted again:
| files | formatted | idempotent | |
|---|---|---|---|
| result | 87 | 87/87 | 87/87 |
A --stdout that succeeds has already had its whole token stream — comments
included, in order — compared against the input by verify_equivalence, so
"87/87 formatted" is "87/87 comment streams preserved and ordered".
Corpus (860 files). scripts/corpus_gate.sh corpus →
{"passing":813,"total":820,...}, 0 verification errors, 0 crashes —
exactly the baseline. 10 of 853 files that both binaries format change
layout, and all 10 verify. Census: 27 covergroups structured, 0 fallbacks
over the 817 .sv/.svh files.
Corpus resolution column (vlog_semantic's
the_corpus_index_finishes_most_external_references, every-file row):
| v0.27.0 | this tree | |
|---|---|---|
| symbols recorded | 27 219 | 27 472 (+253) |
| references recorded | 101 199 | 102 338 (+1 139) |
| resolved in-file | 70.4% | 70.4% |
| nowhere to jump | 1 162 (1.15%) | 1 166 (1.14%) |
Covergroup bodies contributed 1 139 references that did not exist at all before — they were not unresolved, they were unrecorded — and 1 135 of them (99.6%) are answered. The four that are not are names whose declaration is outside the corpus. "0 names unplaced" holds in both trees.
Gates. cargo fmt --all -- --check clean · cargo clippy --all-targets --workspace 0 warnings · cargo test --workspace green (43 binaries,
3 009 passed, 0 failed) · scripts/corpus_gate.sh corpus 813/820, 0
verification errors · cargo build -p lucisv_server + node editors/vscode/smoke.js target/debug/lucisv-server OK · OpenTitan sweep
unchanged, checkout untouched.
QA log
2026-09-02 — QA
Verdict: SHIP. Every gate reproduces the dev's numbers exactly; the two
shared-machinery guards were attacked directly and hold; an independent
89-file/3-fixture re-derivation of the fuzzer classification found zero
covergroup-bodies-specific regressions; the 87-file DV sweep and the full
opentitan/corpus sweeps reproduce byte-for-byte. One gap found in the attack
pairs (a dropped bin-array [] marker had no pin) — closed directly, per
the QA charter's "small unambiguous fixes."
Gates. cargo fmt --all -- --check clean. cargo clippy --all-targets --workspace 0 warnings, verified with a forced rebuild (touched
parser.rs/format.rs/bind.rs first, not a cache hit). cargo test --workspace: 43 binaries, 3 010 passed, 0 failed (3 009 plus the one
attack pair added below). scripts/corpus_gate.sh corpus → 813/820, 0
verification errors — matches the dev's number exactly. cargo build --release clean. node editors/vscode/smoke.js target/debug/lucisv-server
→ OK. cargo test -p lucisv_server --test grammar → 3/3. No
.unwrap()/.expect()/panic! added to library code: checked every hit in
git diff for every changed non-test file (ast.rs, parser.rs,
format.rs, bind.rs, facts.rs, model.rs, resolve.rs, workspace.rs,
signals.rs, visit.rs, completion.rs, on_type.rs, symbols.rs,
tokens.rs) against each file's own #[cfg(test)]/mod tests line number —
every hit in parser.rs falls at or after its test module (line 6781);
every other changed file has zero.
Scope. verify.rs, token.rs, pairs.rs, lexer.rs,
editors/vscode/syntaxes, vlog_refactor: all absent from git diff --stat, confirmed. pairs.rs's own unit tests (65, in
lucisv_server::pairs) are green and untouched. Files touched outside the
README's list: none, except the disclosed census.rs probe (see below) —
plus release-prep files already sitting in the tree ahead of QA
(Cargo.toml/Cargo.lock, CHANGELOG.md, docs/topo.md,
editors/vscode/{CHANGELOG,README,package.json}, all bumped to 0.28.0),
which is the same pattern constraint-bodies' QA noted as its Finding 2 —
not this lane's doing, not re-litigated here.
The two shared-machinery guards, attacked directly.
at_postfix_segment's[* / [-> / [=refusal: constructedarr[i],arr[i:i+2],arr[i+:2],arr[i*2](an index starting with an identifier then*),q[$],q[$-1]— all still parse as ordinary indexes, format, and are idempotent. Grepped opentitanhwfor\[\*and\[->(58 files, zero for\[=): all 58 format with--stdoutwith zero verification errors, and the exact same 50/58 "would reformat" as a v0.27.0 baseline built in a detached worktree (git worktree add --detach /tmp/lucisv_v27_baseline 53bc293) — the reformat set is byte-identical sorted. A syntheticsequence/propertyfile with[*3],[*2:4],[->2]in assertion bodies (verbatim territory) formats and stays idempotent — the guard does not reach into assertion verbatim capture.no_with:arr.find with (item > 0),arr.find(item) with (item > 0),q.sort with (item.x),x = q.sum with (item)all still parse correctly outside a covergroup (no_with is scoped to the bin-spec-operand read only). Inside a covergroup:bins single_exc[] = single_masks(num_hw_apps);andbins b = single_masks(num_hw_apps) with (item > 0);(the two real opentitan shapes the work log names) both parse structured and round-trip. Nestedwith ... within one bin spec (arr.find with (a) with (b), which the LRM does not define) correctly falls back to the verbatim capture rather than mis-parsing — confirmed by injecting ragged whitespace into the bin line and observing it survive untouched in the output, i.e. the covergroup really took the fallback path, not a lucky canonical match.
Corruption + comment hunt. find hw/dv hw/ip/*/dv hw/top_*/dv -name '*.sv' -o -name '*.svh' | xargs grep -l covergroup → 87 files, matching
the dev's count. --stdout twice each, idempotency + a string-aware
////* */ comment-stream extractor comparing content and order against
the original input:
| files | formatted | idempotent | comment stream preserved | |
|---|---|---|---|---|
| result | 87 | 87/87 | 87/87 | 86/87 clean; 1 pre-existing |
The one apparent mismatch (hw/ip/kmac/dv/env/kmac_scoreboard.sv) is a
multi-line block comment whose internal indentation shifts when the
comment block itself is reindented — reproduces byte-for-byte identically
on the v0.27.0 baseline binary, and the file contains no actual
covergroup declaration at all (the grep hit is the word appearing inside
a comment) — not a covergroup-bodies regression by any measure. Eyeballed
10 DV files (csrng_cov_if.sv: with function sample(...) header
breaking like a port list, bins single_exc[] = single_masks(...),
ignore_bins ... binsof(...) intersect {...} with (...);
rom_ctrl_cov_if.sv: all four of zero_delay_5 = (1'b1[*5]),
stall_1 = (1'b1 => 1'b0 => 1'b1), stall_long/stall_repeat with
[*5:10]/[*1:10] — the exact work-log example, correctly not misread as
an index; usbdev_env_cov.sv: eight cross ... { } bodies and
endgroup, no bare endgroup : g mishandling). git -C .../opentitan status --short before and after every read-only run:
unchanged, the same 3 pre-existing owner files
(hw/ip/aes/dv/tb/tb.sv, the two top_*/ip/ast/rtl/ast.svs).
Scratch attacks, each formatted with --stdout and checked for
idempotency: `ifdef/`else/`endif arms as cover items
inside a { } body; a bin body's } at column 0; CRLF line endings;
escaped identifiers as the covergroup name, a coverpoint label and a bin
name; an empty covergroup ({}... actually just endgroup with nothing
between); an unlabelled coverpoint; bins b[] = {[0:$]};; a 3-arrow
transition bins t = (a => b => c);; with function sample(int a, bit b); with a real argument list; a macro-expanded covergroup body
( `define MY_CG(NAME) covergroup NAME; ... endgroup) — byte-identical
output to the v0.27.0 baseline, confirming the fallback capture is
unchanged. All ten formatted and round-tripped cleanly. covergroup cg @@(begin_tr); (the LRM's other coverage-event spelling, which this round's
CoverageEvent does not model) correctly falls back to verbatim — confirmed
with ragged internal whitespace surviving untouched in the output, the same
technique used for the nested-with case above.
Fuzzer re-derivation, independent. Wrote a fresh, standalone Python
tokenizer + gap-injector (not the dev's code) and ran it over three fixtures
of my own, none shared with the dev's ten: a transition-heavy body (four
TransSets including [*2:5], [->3], [=2], a multi-value transition),
a cross with binsof ... intersect ... && !binsof ... intersect, and an
options/wildcard/ignore/illegal/default body.
| fixture | gaps | failing |
|---|---|---|
| transition-heavy | 120 | 11 |
| cross + binsof/intersect | 109 | 9 |
| options/wildcard/ignore/illegal | 111 | 17 |
| total | 340 | 37 |
Classified all 37 by constructing the equivalent non-covergroup source at
the same gap position and running it through the v0.27.0 baseline binary:
five shapes match the dev's own table exactly (class header before/after
name and semicolon, option./type_option. member-dot, a value-range
inside a braced set — binsof(...) intersect {[ /*C*/ 0:3]}); four more do
not appear in the dev's table but reproduce identically on plain
declarations containing no covergroup at all on the same v0.27.0 build:
rand /*C*/ bit x; (a qualifier-to-type gap), bit /*C*/ [3:0] x; (a
declarator's type-to-dimension gap), and the three packed-dimension range
positions bit [ /*C*/ 3:0] / bit [3 /*C*/ :0] / bit [3:0 /*C*/ ]. All
nine shapes fail on v0.27.0. Zero new findings; zero covergroup-bodies-
specific regressions, extending the dev's own §2.9-22 classification
rather than contradicting it.
Corpus resolution column, independently reproduced.
cargo test -p vlog_semantic --release --test corpus -- --nocapture:
860 files, 27472 symbols, 102338 references — 70.4% resolved in-file, ... 1.14% unresolved (1166), 0 names unplaced — matches the dev's table
exactly, cell for cell. CENSUS=<opentitan>/hw cargo test -p vlog_parser --release --test census -- --ignored --nocapture: files=3975 covergroups=544 covergroup_fallbacks=0 constraint_fallbacks=29 diagnostics=1105 files_with_diagnostics=12 — exact match. Same over this
repo's corpus/: files=817 covergroups=27 covergroup_fallbacks=0 — exact
match.
Opentitan full sweep, independently reproduced. --check --no-cache hw
against both this build and the v0.27.0 baseline: 13 files fail on both,
byte-identical error-message sets (the 12→13 drift is the checkout's own
ast.sv mid-edit, not a regression — same phenomenon constraint-bodies'
QA logged at its own re-verification pass). Copied hw/ to two scratch
trees and formatted each in place with its own binary (avoids one-process-
per-file overhead over ~3.9k files): 3 858 files reformatted, 108
unchanged, 13 failed — identical on both binaries. diff -rq between the
two output trees: 81 files differ; every one of the 78 that survived clean
path-extraction contains the word covergroup (0 that don't) — the layout
changes are exactly and only this round's doing. Same exercise over this
repo's corpus/: 10 files differ, all 10 contain covergroup — matches
the dev's "10 of 853" exactly. git -C .../opentitan status --short:
unchanged throughout, the same 3 owner files.
Attack pairs. Read all 14 covergroup-shaped tests (12 new + 2
re-derived, matching the README's count). Re-ran them: all pass, all
correctly reject their corrupted pair. Gap found: no pin existed for a
dropped bin-array [] marker (bins z[] = {0,1}; → bins z = {0,1};,
which changes "one bin per value" into "one bin for both" — a real
semantic change to what the covergroup counts) nor for a widened fixed
array size (z[2] → z[4]). Added
a_dropped_bin_array_marker_is_rejected to
crates/vlog_formatter/tests/verification.rs (right after
a_dropped_bins_qualifier_is_rejected), confirmed it exercises
verify_equivalence genuinely (not a no-op — the two literal strings really
have different token streams) and passes. fmt/clippy clean on the
addition; full cargo test --workspace re-run afterward (see Gates above).
Semantics. Read crates/vlog_semantic/tests/covergroups.rs (356 lines,
12 tests: self/sample/label declaration, sampled-expression binding,
cross-operand-to-coverpoint binding, sample-argument scoping, the item
shadow test with both the "shadowed" and "not shadowed" halves, the
option./type_option. target-vs-value split, a fallback binding nothing,
a clocking event naming the enclosing scope, cross-file coverpoint
reachability, covergroup member export, a base-class property answered
cross-file, and index-determinism) and both e2e tests
(renaming_a_rand_field_rewrites_its_coverpoint_uses,
renaming_a_rand_field_reaches_a_coverpoint_in_another_file) — the second
is non-trivial: definition from the covergroup file into a base class in
another file, then a rename from the base declaration that edits both
files, asserted by URI and line. Ran both explicitly
(cargo test -p vlog_semantic --test covergroups,
cargo test -p lucisv_server --test e2e coverpoint): 12/12 and 2/2. Did not
independently re-drive the LSP session over a raw socket (no separate
client available); relied on reading the talk()-based test bodies plus
the green run, same posture constraint-bodies' QA took for its own e2e
tests.
Linter. crates/vlog_linter/tests/cases/covergroups.lint read: four
cases matching the README (undriven-net now sees a coverpoint read; a
fallback covergroup stays opaque; empty-item does not fire on a null
cover/bin item; an item walk still reaches past a covergroup to a class
member). lucisv check corpus/ with this release binary and the v0.27.0
baseline: 7 932 violations, both binaries, identical — no new false
positive from coverpoint operands now resolving.
Docs. README follows the template, the fallback census and the
work-log numbers all reproduced exactly (see above). The census.rs probe
is #[ignore]d, read-only, touches no other file, and is disclosed in the
README's Handshakes section exactly as it should be — informational, the
lead's call whether it stays. TODO §21 QA line added below.
Small fix made directly, per the QA charter: added
a_dropped_bin_array_marker_is_rejected to
crates/vlog_formatter/tests/verification.rs (see Attack pairs above) —
the one gap this checklist's own guidance asked QA to check for
("a bin array [] dropped"). No other file was modified.
Review
Review
2026-09-02 — lead. Approved and committed; coverage_gaps C1 is closed for both constraints and covergroups.
- The round used the constraint round as its template and improved on the
order of operations: the comment-gap fuzzer was built in from day one
rather than after a QA rework, and its classification is asserted
(
the_gaps_the_fuzzer_still_fails_fail_outside_a_covergroup_tooruns each remaining shape outside a covergroup and requires the same failure) rather than claimed. Zero fallbacks over opentitan's 544 covergroups is the result of replacing a lookahead scan with the LRM's own positional rule for the bin(…)ambiguity — the kind of decision that gets simpler and more correct at once. - The one risk was the two guards in shared expression machinery, and
the lead read both:
at_repeat_bracketis a two-token look for[then*/->/=, which no index can begin with;no_withis reset unconditionally before the?propagates, so an error inside a bin spec cannot leak it into the rest of the file. QA attacked both against 58 opentitan files carrying[*/[->and every array-methodwithshape, in and out of covergroups; the whole corpus and tree re-verified under them. Accepted. verify.rsuntouched; twelve attack pairs from the dev plus QA's thirteenth (a dropped bin-array[], a real semantic change). 87/87 DV covergroup files idempotent with comment streams byte-identical; the sweep's failure set and per-file tolerant diagnostics identical; corpus +1 139 references, 1 135 answered. Renaming arandfield now rewrites the coverpoints that sample it as well as the constraints that bound it.on_type.rskeepingcovergroupopaque is accepted on the dev's argument (bin bodies sit behind a{a bracket already silences); thecensus.rsprobe stays as an#[ignore]d measurement. Lead's one edit: theRewinddoc comment now names its third caller.- Gates re-run by the lead: fmt clean, clippy zero warnings, 3 009 passed /
0 failed over 43 binaries (3 010 with QA's pin), corpus 813/820, smoke
OK.
docs/topo.md: two rows. Ships as 0.28.0 (FACTS_FORMAT 12).