Bucket 7: the mirror image of directive-split — an `ifdef opening INSIDE an assign RHS, expression or instantiation head, where all three existing directive features trigger on a closing directive and could not fire. The construct is captured verbatim by two mirror recoveries sharing one capture step (statement-level first, item-level behind it), construct_end classifying the head (Semi / endfunction+label / Unknown -> refuse rather than guess), and terminated_in_arm honoring both real terminator placements. Both flagship tb.sv files needed only take_list_directives to stop harvesting an outer region's `else as a list element. OpenTitan sweep 107 -> 100, exactly the 7 targets (chip_if.sv x2, chip_earlgrey asic/cw340, jtag_dtm_reg_block, both top_* tb.sv), zero regressions, corpus per-file byte-identical to baseline. Also delivers Lane B's Handshake: take_before_open's queue drain was necessary-but-not-sufficient — CallComments::dangling drained the same way — both now behind Parser::take_gap (comments kept only when span.start >= last_end()), verified by composing with Lane B's tree: keymgr_scoreboard.sv formats, closing the last bucket-2 file. Co-Authored-By: Claude Fable 5 <[email protected]>
directive-in-statements
Goal
Stop refusing files where a `ifdef/`else/`endif region opens
part-way through a construct — splitting an assign's right-hand side, an
expression inside a bracketed list, a call's argument list, an instantiation's
parameter value, or a function's port list. This is bucket 7 of
syntax_coverage.md plus its bucket-13 sibling: 7 files across the OpenTitan
sweep, and the specific files are the point — both chips' top-level
synthesizable RTL (chip_earlgrey_asic.sv, chip_earlgrey_cw340.sv), both
chips' DV probe interfaces (top_{earlgrey,darjeeling}/dv/env/chip_if.sv,
anchor B), and both chips' DUT top testbenches
(top_{earlgrey,darjeeling}/dv/tb/tb.sv), plus jtag_dtm_reg_block.sv.
Such a region is not a tree, for the same reason directive-split's already
was not: there is no AST that holds "either this expression or that one", and
no layout to apply to something that only becomes a construct after the
preprocessor has chosen an arm. So it joins the verbatim bucket — the exact
source bytes, re-indented on the first line only — reached by a recovery
after a real parse failure rather than by a grammar rule. This is the sequel
syntax_coverage.md's own implementation note recommends: "the existing
ItemKind::Verbatim pattern extends naturally to capture from the failed
statement/instantiation through the shared terminator, exactly as
directive-split already does for item-level declarations."
Assumptions
The gap, stated as a mirror image
directive-split (2026-08-26) recovers when the failure lands on the directive
that closes a region opened before the construct started, with a bracket
the arm left open. This round is the other half: the failure lands on the
`ifdef that opens a region inside the construct.
// closing shape (directive-split, 2026-08-26) -- the item IS an arm
`ifdef DSIM
privileged_reg_t implemented_csr[] = { <- fails at the `else below
`else
const privileged_reg_t implemented_csr[] = {
`endif
MVENDORID
};
// opening shape (this round) -- the item CONTAINS the region
assign aes_ctrl_rnd_ctr =
`ifdef GATE_LEVEL <- fails right here
`AES_HIER.u_aes_cipher_control.mr_rnd_ctr[3:0];
`else
`AES_HIER.u_aes_cipher_control.rnd_ctr;
`endif
None of the three existing directive features fire on the second shape, and
syntax_coverage.md's Anchor B deep-dive says why: directives-in-lists /
directives-in-instances sit at the element boundaries of four bracketed
lists (port lists, parameter lists, enum members, instantiation
#()/connection lists) — an assign's RHS is a single expression, not a list;
directive-split needs a bracket already open at a closing directive; and
directive pass-through otherwise exists only at item- and statement-list
boundaries. An expression parse has no "this might be a pass-through directive"
branch at all, so it fails immediately, before any bracket is opened and before
directive-split's trigger is ever evaluated.
The opening trigger is two conditions, checked in at_opening_split
- The cursor stands on an
`ifdef/`ifndef. Every other directive mid-expression is still an ordinary parse error —`include, a bare`endif, a macro call. This is what keeps the net narrow: the recovery is about conditional regions, not about directives in general. - The construct is one unterminated run reaching that directive: it has
consumed at least one token (a directive standing where an item or a
statement begins is an ordinary pass-through directive, unchanged), and
there is no
;at bracket depth zero between its first token and the cursor.
Condition 2 is the load-bearing one and it replaces directive-split's
"a bracket is open" test, which cannot be reused here — at chip_if.sv:1192
nothing is open yet, the failure is three tokens into the item. What it buys is
that a failure which propagated up from somewhere deeper cannot capture the
construct that happens to enclose it: by the time an error inside a module body
reaches parse_item_inner, many ; at depth zero have gone by, so the module
is refused as a candidate. Without it, one bad expression would turn an entire
module into opaque bytes on a guess.
The extent follows the first arm, and ends on one of two terminators
scan_opening_split_extent walks from the construct's first token, tracking
brackets and conditional nesting, and — like scan_split_extent — on a
`else/`elsif it skips the alternative arms whole (reusing
skip_conditional_arms), because the arms are rival spellings of one thing and
counting all of their brackets would demand as many closers as there are arms.
Where it stops depends on which side of the region the construct's terminator was written on, and both spellings are in the corpus:
| shape | corpus evidence | ends at |
|---|---|---|
each arm carries the construct's own ; |
chip_if.sv:1189 |
the `endif closing the region |
| the region is balanced inside the construct | chip_earlgrey_asic.sv:621, jtag_dtm_reg_block.sv:173 |
the ; after it |
terminated_in_arm is what tells them apart: a ; met at bracket depth zero
while a region is still open means the tail lives inside the arms. Getting this
wrong in the first direction swallows the next item (there is no ; after
chip_if.sv's `endif); getting it wrong in the second truncates the
construct.
Every exit leaves conditional nesting back at zero. A captured block is
therefore conditional-balanced by construction, which is why this recovery —
unlike directive-split's — needs no open_conds adjustment at all. Pinned by
an_opening_split_leaves_item_scope_nesting_alone.
A head that opens a body does not end at its first ;
The first draft assumed, as directive-split documents it does, that "the
construct's terminator is a ;". jtag_dtm_reg_block.sv:273 is the
counterexample — a split function new( header:
function new(string name = "",
`ifdef USE_DMI_INTERFACE
int unsigned n_bits = 50,
`else
int unsigned n_bits = 41,
`endif
int has_coverage = UVM_NO_COVERAGE);
super.new(name, n_bits, has_coverage);
endfunction : new
That ; closes a header. Stopping there captured the header, left the body
behind as items, and the file failed on super three lines later — a worse
diagnostic than the one it replaced. So construct_end reads the construct's
head and answers one of three things:
Semi— the default, and what every identifier-headed construct gets (instantiation, call statement, assignment) along with every declaration keyword. Unchanged fromdirective-split's assumption.Keyword("endfunction")/Keyword("endtask")— the two body-opening heads the corpus needs. The block runs to the closing keyword and takes the: labelit may carry (past_end_label), because a label left outside would be parsed as an item.Unknown— every other body-opening keyword (BODY_KEYWORDS:module,class,case,begin,for,always, …). Refused outright, because capturing at a;would produce exactly the truncated head above and nothing in the corpus asks for these.
TF_QUALIFIERS (virtual, static, automatic, local, protected) are
skipped in front of function/task. extern and pure are deliberately
not in that list: those spell a prototype, which really does end at its ;,
so they fall through to Semi, which is correct for them.
take_list_directives must not harvest an outer region's seam
The two tb.sv files (bucket 13) fail for a related but distinct reason, and
they need no new recovery at all — directive-split's existing one already
fits, it just never got to see the failure:
`ifdef DISABLE_ROM_INTEGRITY_CHECK
chip_earlgrey_asic #( .SecRomCtrlDisableScrambling(1'b1) ) dut (
`else
chip_earlgrey_asic dut (
`endif
.POR_N(...), ...
);
The parser accepts the first arm's head, opens the shared connection list, and
inside it meets the `else. take_list_directives harvested any
directive found inside a list's brackets as conditioning list elements, so it
took the `else, then read chip_earlgrey_asic (the second arm's module
name) as a positional connection — which succeeds, as a bare identifier — and
failed two tokens later at dut, three lines from the actual seam.
at_outer_arm_split stops that: a `else/`elsif/`endif that
this list did not open (counted over the list's own harvested directives),
while a region opened at item scope is still live (open_conds > 0, the
same "a region is live" guard at_split_conditional makes), is not conditioning
elements — it is the seam. The harvest breaks, the item fails standing on the
directive, and at_split_conditional's four conditions all hold: the whole
instantiation becomes one verbatim block.
Both halves of the guard matter. Without open_conds > 0 an ordinary
list-internal region would be refused; without the "did not open it" count the
`endif of a legitimately list-internal region would be. Pinned from both
sides by an_ifdef_that_splits_an_instantiation_head_is_still_the_closing_shape
and a_list_internal_region_is_still_harvested_as_list_elements, and by the
.cases control entry.
The statement level runs first, and only the opening shape
The recovery is wired into both parse_item_inner and parse_stmt_inner.
The statement one is what keeps jtag_dtm_reg_block.sv:173's capture at the
abits.configure(...) statement instead of at the enclosing class: an error
raised inside a function body propagates outward, and the innermost frame that
recognizes the shape must claim it first. (Condition 2 above would refuse the
enclosing item anyway — the belt to this braces — but the useful capture is the
narrow one.)
Statements get only the opening shape. The closing shape is item-scope by
construction: Parser::open_conds counts the `ifdefs consumed as items,
per directive-split's rule, so mark.conds inside a body would be answering a
question about a different scope. No corpus file asks for it.
What is deliberately still refused
- Any non-conditional directive mid-expression.
- A stray
`else/`endifwith nothing open. - An unterminated region, or a construct with no terminator before EOF.
- Brackets that do not balance across the chosen arm.
- A plain syntax error that merely sits near a directive.
- Any body-opening head other than
function/task.
All seven pinned by the_opening_split_refuses_everything_it_does_not_model
and re-run against the release binary on standalone files.
One deliberate widening, and it supersedes a test
parser.rs's a_directive_inside_a_connection_is_still_a_parse_error pinned
that a conditional region written inside a connection's parens is refused —
"out of scope by design". That premise is exactly what this round changes:
chip_earlgrey_asic.sv:621 writes one inside a parameter value's
concatenation, which is the same shape. The test is renamed
a_directive_inside_a_connection_is_captured_or_refused_by_kind and now pins
both halves — the conditional region is captured verbatim, any other directive
there is still an ordinary parse error. This is the only pre-existing test whose
expectation changed, and the only shape whose accept/refuse verdict moved
outside the seven target files (measured: see the Work log's sweep diff).
A currently-passing file cannot be affected
Both recoveries are reached only from an Err arm, and a file that formats
today produces no such Err. The one exception is at_outer_arm_split, which
runs on the success path — so it was measured rather than argued: the
820-file corpus gate produces byte-identical per-file results before and after,
and the 3,943-file OpenTitan sweep's pass set is a strict superset with no file
moving out.
Handshakes
Consumed
Parser::verbatim_since(start, col)— slicessource[span]into aRawTextand drops the comment copies falling inside the span. Used unchanged.Fmt::raw_text(raw)/Fmt::raw_lines(text, col)— the verbatim printer. Used unchanged; no formatter source file was touched by this round.Parser::skip_conditional_arms—directive-split's arm skipper, reused by the opening-shape scan with the same meaning.Parser::open_conds— read (never written) byat_outer_arm_split, which is its third reader.directive-split's rule that onlynote_item_conditionalandsplit_conditional_itemmay write it is preserved: this round adds no writer, because an opening-split block is conditional-balanced.ItemKind::Verbatim(RawText)gained a sixth producer andStmtKind::Verbatim(RawText)a second (after the concurrent assertions). No signature changed, so no exhaustive match anywhere needed a new arm —format.rs,bind.rs,visit.rs,spans.rsand the linter are untouched. No new AST variant, no new AST field.
Promised / changed for others
crates/vlog_formatter/src/verify.rsis untouched. No normalization was added and no forgiveness widened. Verbatim bytes need none: a captured block is re-lexed as ordinary tokens on both sides, so every token inside it must still match, and all seven newly-passing OpenTitan files go through the runtime safety net (lucisv --check, which verifies) plus a two-pass idempotency check.- Request to whoever next owns
crates/vlog_formatter/tests/verification.rs:directive-splitshipped ten invariant-#4 attack tests there even though it too leftverify.rsalone, on the grounds that a verbatim capture is forgiveness-adjacent. The equivalent tests for this round were not added, becauseverification.rsis Lane B's file this wave and a silent edit would break the merge contract. The seven refusal shapes are pinned inparser.rsinstead (the_opening_split_refuses_everything_it_does_not_model) and were re-run against the release binary. Adding the (input, corrupted output) pairs toverification.rsafter the merge is a QA-sized task and is recommended. - New private parser surface only. Two consts (
BODY_KEYWORDS,TF_QUALIFIERS), one enum plus its reader (ConstructEnd,construct_end), two free functions (directive_word_of— extracted from the existingdirective_wordso a harvestedRawTextcan be classified — andtake_since), and sevenParsermethods (take_gap,at_outer_arm_split,at_opening_split,scan_opening_split_extent,past_end_label,capture_split,split_conditional_stmt). Nothing ispub.split_conditional_item's body was split socapture_splitis shared by both shapes; its behaviour on the closing shape is unchanged. - Delivered:
formatter-bug-fixesround 2'stake_before_openrequest. See that README's Handshakes section, marked DELIVERED, and the work log below.Parser::take_before_openand the empty-callCallComments::danglingharvest now take only the comments written in the gap that ends at the bracket (Parser::take_gap), instead of draining the whole pending queue.
Requests to other clusters
directives-in-lists: a function/task port list (Parser::parse_tf_ports) still has no directive harvest, becauseTfArglists carry noVec<ListDirective>and adding one is an AST change with printer arms.jtag_dtm_reg_block.sv:273is therefore captured verbatim rather than formatted. Teaching that list the existing harvest would be strictly better output for the same file, and belongs to whoever owns thedirectives-in-listssurface plusformat.rs.StmtKind::Returnhas no comment slot, soreturn // c⏎g();still refuses (see the formatter-bug-fixes note). Not a directive matter; recorded because this round's parser change is what isolates it.
Status / TODO
- Baseline recorded: OpenTitan sweep 107 failures at
17633d2, corpus gate 813/820, both re-run from a pristine scratchpad build ofHEAD. - Parser:
at_opening_split(the trigger),scan_opening_split_extent(the extent),past_end_label,construct_end+BODY_KEYWORDS+TF_QUALIFIERS. - Parser:
capture_splitextracted so both shapes share the rewind/walk. - Parser:
at_outer_arm_split, thetake_list_directivesguard, and thedirective_word_ofrefactor it needs. - Parser: statement-level recovery in
parse_stmt_inner(split_conditional_stmt), opening shape only. - Handshake (item 2):
take_before_open+ empty-calldanglingnarrowed totake_gap. - 10 new parser tests, including the 7-shape refusal test and the two
comment-ownership tests; one superseded test rewritten to pin both halves
(
vlog_parserlib suite 224 → 234). - 7 cases in
crates/vlog_formatter/tests/cases/directive_in_statements.cases(the harness asserts idempotency on every one). - All 7 target OpenTitan files parse and format strict-clean; two-pass idempotency and unchanged on-disk md5 confirmed for each.
- Sweep 107 → 100, pass set a strict superset, no message changed on any still-failing file.
- Corpus gate byte-identical to baseline (813/820).
cargo fmt --all,cargo clippy --all-targets,cargo test --workspaceclean.- Not done, deliberately: directive harvesting in function/task port
lists (needs an AST field — see Requests); body-opening heads other than
function/task; any canonical layout for the inside of a captured region — it stays byte-for-byte; the invariant-#4 attack pairs inverification.rs(Lane B's file — see Promised/changed).
Work log
2026-08-29 — dev
Setup. Worktree branched at 34b766c, fast-forwarded to master
(17633d2, Lane A merged) before any edit, so the round builds on the freed
parser.rs. All measurement against the real checkout at
/Users/guoliangchen/repo/opentitan (HEAD 0098135), read-only — every probe
uses --check/--stdout with --no-cache, and each target file's md5 was
compared before and after.
Baseline (pristine git archive HEAD build in the scratchpad, so before and
after are the same corpus and the same commands): OpenTitan sweep 107
failures over 3,943 files; corpus gate
{"passing":813,"total":820,"pct":99.1,...}.
Item 1 — the design choice. Verbatim capture, reached by two recoveries
that share one extent-capture step, rather than new grammar. Justified against
the three existing directive features' contracts in Assumptions above; the
short version is that the arms of a split region are rival spellings of one
construct, there is no tree that holds "either this or that", and the four
existing pass-through sites are all list-element boundaries that an expression
does not have. No AST variant and no AST field was added, so format.rs,
bind.rs, spans.rs, visit.rs and the linter are untouched — which is also
what kept this round inside its file-ownership list while Lane B held the
formatter.
Three things were learned by building it, each recorded above as an assumption:
- The corpus writes the construct's terminator on both sides of the region
(
chip_if.svinside the arms,chip_earlgrey_asic.svafter them), so one terminator rule is not enough — henceterminated_in_arm. directive-split's "the terminator is a;" assumption is false for a function header. The first build of this round capturedjtag_dtm_reg_block.sv'sfunction new(...)header and orphaned its body, moving the file's error from line 173 to line 280.construct_endis the answer, and it refuses by default for every body-opening head it does not model.- The two
tb.svfiles needed no new recovery — only thattake_list_directivesstop hiding the seam from the recovery that already existed. That is the smallest change in the round and the one that fixes the two highest-value files.
Item 1 — result. All 7 target files clean:
| file | before | after |
|---|---|---|
hw/top_earlgrey/dv/env/chip_if.sv |
1192:1: expected expression |
formats |
hw/top_darjeeling/dv/env/chip_if.sv |
894:1: expected expression |
formats |
hw/top_earlgrey/rtl/autogen/chip_earlgrey_asic.sv |
621:1: expected expression |
formats |
hw/top_earlgrey/rtl/autogen/chip_earlgrey_cw340.sv |
502:1: expected expression |
formats |
hw/dv/sv/jtag_agent/jtag_dtm_reg_block.sv |
173:1: expected expression |
formats |
hw/top_earlgrey/dv/tb/tb.sv |
114:22: expected \)` (found "dut")` |
formats |
hw/top_darjeeling/dv/tb/tb.sv |
105:24: expected \)` (found "dut")` |
formats |
Whole-sweep 107 → 100. comm -13 over the sorted failure lists is empty
(nothing regressed); comm -23 is exactly those seven files; and no file that
still fails changed its message. Each of the seven was formatted twice through
--stdout and the passes compared byte-for-byte — idempotent — with the
checkout's md5 unchanged. Corpus gate re-run with both binaries against the
same pinned corpus: 813/820 both times, and diff over the two per-file
result tables is empty, not merely the same total.
Item 2 — the handshake. Implemented as specified —
take_before_open keeps only comments with span.start >= self.last_end() —
and then found by bisection that it was not sufficient on its own: with
before_open fixed, the pinned shape's comment was swallowed one line later by
CallComments::dangling, the empty-() harvest, which drains the queue the
same way. Both now go through one narrow helper, Parser::take_gap(). The
"or better, justified" clause of the brief covers the second site; it is the
same defect at the same struct, and without it the handshake does not deliver.
Verified by composing this lane's parser.rs with Lane B's worktree in a
scratchpad copy — their files were read, never written — and running their whole
workspace suite: everything stays green except
a_comment_before_a_call_in_a_condition_is_still_refused, which flips from pass
to fail, i.e. the shape now formats:
if (
// why
!en() || b
) begin
and the real hw/ip/keymgr/dv/env/keymgr_scoreboard.sv — the 12th and last
bucket-2 file, which Lane B could not fix from inside vlog_formatter — formats
cleanly end to end. Lane B's expect_divergence attack pairs all still pass;
verify.rs is untouched by either lane. Marked DELIVERED in
docs/features/formatter-bug-fixes/README.md.
Deviations from the brief, all flagged:
- No formatter
.casesentry proves the keymgr line-1254 shape in this worktree, because half the fix is Lane B's:Fmt::header_parens(their round 2) is what gives a comment written afterif (a home. At17633d2that shape is refused with or without this round's parser change — confirmed against the pristine baseline binary — so a case asserting it here would fail. The parser side is pinned instead by two new parser tests (a_comment_after_an_opening_bracket_is_not_stolen_by_an_inner_call, which asserts both call comment slots are empty and the comment reaches the body's leading comments whereheader_parenscollects it, anda_comment_actually_written_before_a_bracket_is_still_takenfor the other side), and end to end by the composed run above. The.casesentry belongs to the merged tree and is the natural first QA task after the merge. - Only one pinned refusal test exists, not two. Lane B's README names one
(
a_comment_before_a_call_in_a_condition_is_still_refused) and describesreturn // c⏎g();as a second symptom, which is not pinned as a test. That symptom is not fixed by this round and is refused identically before and after: it needs a comment slot onStmtKind::Return. Recorded as a request above. - One pre-existing parser test's expectation changed
(
a_directive_inside_a_connection_is_still_a_parse_error), because the behaviour it pinned is the behaviour this round adds. Rewritten to pin both halves rather than deleted; rationale in Assumptions. docs/features/formatter-bug-fixes/README.mdwas edited — the Handshake-status edit the brief sanctions. This worktree holds the trunk copy of that file, which does not yet contain Lane B's round-2 Handshakes text, so the new### Round 2's take_before_open request — DELIVEREDsubsection sits where Lane B also appends. A merge conflict there is expected and the resolution is to keep both blocks.
Gates. cargo fmt --all --check clean, cargo clippy --all-targets clean
(no new warnings, no #[allow] added), cargo test --workspace green, corpus
gate exactly at baseline. No git commit, no git push.
QA log
2026-08-29 — QA
Verdict: SHIP. No corruption, no capture-extent bug, no comment
relocation found across the adversarial charter. All claimed numbers
reproduced exactly. vlog_parser lib suite: 234 → 238 (4 new QA regression
tests added, all passing; see below).
Gates, all re-run from a fresh build in this worktree:
cargo fmt --all --check: clean.cargo clippy --all-targets: clean, no new warnings.cargo test --workspace --no-fail-fast: green, every crate, 0 failures.
Reproduction of the round's numbers, against a pristine 17633d2 binary
built in a separate git worktree (never touching this lane's tree) for
every "before" comparison:
- OpenTitan sweep (
/Users/guoliangchen/repo/opentitan, HEAD0098135, read-only,--no-cache --check, both binaries against the identical 3,943-file list): baseline 107, round 100.comm -13(round-only failures, i.e. regressions) is empty.comm -23(fixed) is exactly the 7 named files. Joined the two failure tables on filename and diffed the messages for every file failing in both: zero changed. - The 7 target files: each formats (
--checkexit 0 or 1, never 2), each two-pass idempotent (--stdoutoutput fed back in produces byte-identical output), and each file's on-disk md5 confirmed unchanged before/after. - Corpus gate (
scripts/score.shagainst the real 820-filecorpus/, not reachable by name from inside a worktree — BSDfindon this machine does not descend into a directory given to it as a symlink without-L, whichscore.shdoesn't pass, so the corpus has to be referenced by its real path rather than acorpussymlink dropped in the worktree root): baseline{"passing":813,"total":820,...}, round identical, anddiffover the two-o details.tsvper-file tables is empty — not just the same count, the same outcome for every one of the 820 files. - Composed-tree claim (Lane B's worktree,
.claude/worktrees/agent-a8ee7330b649bc150@d3deacf, read-only — rsynced to a scratch copy, Lane B's files untouched, only this lane'sparser.rsoverlaid on top):cargo test --workspace --no-fail-fastis green except exactlyverification.rs::a_comment_before_a_call_in_a_condition_is_still_refused, which flips from pass to fail because the shape it pins now formats — matching the dev's report precisely, one flip and no other change. Built the composed release binary and confirmedhw/ip/keymgr/dv/env/keymgr_scoreboard.svformats end-to-end and is two-pass idempotent.
Adversarial testing (the charter's three named sins: a capture that eats
too much, a refusal that became corruption, a comment that moved homes).
Built two probe harnesses — a temporary vlog_parser integration test
(deleted after use, not part of the final diff) dumping parsed-tree
summaries, and a set of standalone .sv files run through both the round
and baseline release binaries with --stdout/--check/idempotency:
- Nested
`ifdef(with its own`elsif/`else) fully inside an opening split's first arm, itself inside an outer already-open region: captures the right byte range,open_condslands back at exactly the outer count, next item survives. No prior test combined all three levels at once. - A 4-arm
`elsifchain in an opening split: captured through the final`endif, not an intermediate arm. - A block comment whose text contains the literal string
`endifinside the region: does not fool the extent scan (comments are neverTokenKind::Directive, so this was never actually at risk, but it is now pinned). - A string literal containing the literal text
`endifas data, and a string literal containing a bare;: neither confuses the bracket/;scan, since both are lexed as single opaque tokens. `define/`includewritten inside the captured region: swept as ordinary opaque directive tokens, included verbatim, no special handling needed or present.- The split construct as the last item of its
module/class(no sibling item follows): extent scan stops at its own terminator, never wanders intoendmodule/endclass. - Two independent opening splits back-to-back in the same module: each
captured as its own
Verbatimitem; the first's capture does not bleed into the second's region. - Mismatched bracket nesting across arms (deliberately malformed, adversarial input, not valid SV): the scanner follows only the first arm as documented, produces a verbatim capture, formats and reparses clean — no corruption, matching the documented "follow the first arm, skip the rest whole" policy.
- Comment-ownership sweep for the
take_gaphandshake: comments in empty call parens (both before and after), nested calls each with their own comment, a comment between!and its callee, a bare macro call with a comment inside its parens, a$displaysystem-call comment, and a three-comment instantiation connection list (before/between/trailing) — diffed byte-for-byte between the baseline and round binaries. All six are identical, including the still-refused!en()/returnshapes (refused by both, same diagnostic), confirmingtake_gapchanged nothing for any comment site outside the one it was built to fix.
One false alarm, recorded for the record: an ad hoc probe
(`ifdef/`else/`endif conditioning a bare positional call
argument with no comma, i.e. f( `ifdef A 1 `else 2
`endif );) initially looked like a diagnostic-quality regression —
the round's error landed three lines away from the baseline's. Root cause
was the probe file itself, not the parser: it placed a bare x = 1;
directly as a module item (only legal inside a procedural block), an
unrelated pre-existing syntax error that the baseline never reached because
it failed earlier. Corrected to initial begin ... end, the shape formats
cleanly and idempotently on both sides — not a finding.
Tests added (crates/vlog_parser/src/parser.rs, #[cfg(test)] mod tests, appended after the round's own directive-in-statements block; lib
suite 234 → 238, all green):
a_nested_ifdef_with_its_own_elsif_survives_inside_an_opening_split_under_an_outer_region,
an_elsif_chain_in_an_opening_split_is_captured_through_the_final_endif,
a_block_comment_naming_endif_does_not_fool_the_extent_scan,
an_opening_split_that_is_the_last_item_does_not_eat_the_closing_keyword.
None of these were failing before they were added correctly (the first one
initially failed on a test-construction mistake — a trailing `endif
that closed the "still open" outer region I meant to leave open, and a
wrong item index once the outer `ifdef became a sibling file item —
both fixed in the test, not the parser); they exist to guard the
adversarial coverage above against a future regression, since none of it
was pinned by the round's own 10 tests.
Not independently re-verified: the verify.rs/invariant-#4 attack-test
request the dev's Handshakes section files against verification.rs
(Lane B's file this wave) — correctly left undone here too, per the
merge-contract rule (crates/vlog_formatter/tests/verification.rs is
outside this lane's file-ownership list). Recommended as the first QA task
after the merge, as both this round's and Lane B's READMEs already say.
Review
2026-08-29 — lead. Reviewed after QA's zero-finding SHIP; gates re-run on the worktree. The round's craft shows in what it refused to do: construct_end's Unknown → refuse arm turns "I don't understand this head" into a clean error instead of a guess (the jtag first-build bug caught by the dev's own testing is exactly why that arm exists), and the tb.sv fix being three lines in take_list_directives rather than a new recovery is the smallest-change discipline paying out on the highest-value files. Item 2's bisection — the specified fix necessary but not sufficient, the second drain found and unified behind take_gap — is why "implement exactly that, or better, justified" is written into every such handoff. The composed-tree verification against Lane B's worktree was the right way to prove a cross-lane delivery without a cross-lane edit, and QA reproduced it independently. Deviations all accepted; the two post-merge items (keymgr .cases entry, the standing-template attack pairs in verification.rs) are the lead's and are done in the merge commit's follow-up. Accepted; merged by the lead. OpenTitan sweep: 151 at the wave's start, 100 after this round.