Every tracked file that can carry a comment (880 of them) now opens with "Author: Guoliang Chen, a Senior Digital Design Engineer" and closes with "Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com", in the file's own comment syntax. No behaviour change: the diff outside the version bump and changelogs is comment lines only. - tools/stamp_author.py: writes the lines; idempotent, `--check` lists what is missing. Headers go under a shebang and under Markdown front matter. - Left alone: test fixtures, cases and snapshots (byte-exact inputs), JSON and JSONL, logs, images, lockfiles, docs/site/dist (regenerated) and the LICENSE files (already carry the copyright line). - tools/linux_check.sh: --help reads its header from line 3, now that the author line sits under the shebang. - tools/gates.sh green on this tree: 5 545 tests, corpus 814/6 as before. Co-Authored-By: Claude Mythos 5.2 <[email protected]>
statement-fences
Goal
// verilog_format: off … // verilog_format: on selected whole items
only. A fence written between two statements of an always block, inside a
function or task body, inside a fork, or between two members of a class
was formatted as an ordinary comment — the hand-aligned tables RTL authors
protect at module scope had no escape hatch one level down, and DV code, which
lives almost entirely inside class bodies and methods, had none at all. This
round adds those scopes: a class body scans as the item list it already is,
and statement lists (begin…end, fork…join*, function/task bodies, the
body of an initial/always/final) scan through a statement twin of the
item scan. Closes coverage_gaps M9 and topo §2.9-3, and closes the asymmetry
shared-fence-filter documented: protected_regions' line scan already
declined to edit inside these fences, while the formatter happily laid them
out. Nothing here widens what a fence is or what it emits — a region is still
a slice of source bytes.
Assumptions
- A statement list is a fence scope; a single-statement body is not. The
bodies of
if,for,while,repeat,forever,foreach,do while, a timing control and an immediateassertare walked into but are not scopes themselves, for the reasonscan_gen_blockrefuses a block-less generate item: there is no list for a region to end in, and the formatter lays that statement out inside aGroup, where a column-0 break-forcingDoc::Verbatimhas no correct place. Only thebegin…endorfork…join*such a body may hold opens a scope. - A fence must begin the content of its line. Nothing but whitespace and
finished block comments may precede it there. This is
fence::opens_line, and statement scanning is what forced it: the parser hands a comment written afterbeginon the same line to the next statement as a leading comment, so without the testalways @(*) begin // lucisv: offwould open a region whose first line was sliced from the middle of a line. It is also what the format-fences README already claimed the rule was — see the deviation in the work log. Stmt.spanis the statement's code extent, its attributes included and its comments excluded, and it reaches its own;. Both halves are load-bearing, exactly asItem.span's are: the attribute half is why splicing a statement reproduces its(* … *), the comment half is why a statement's leading comments can be emitted while its code is skipped, and the;half is why a region ending at a statement never cuts a token in half. Verified by probe (x = 1;spans the;).- A statement scope's end is the last statement's
span.end, extended over the comment trailing it on the same line.Meta.trailingcarries a span now, but the scan reads the source rather than the node, so that one function (with_trailing_comments) answers the question for items and statements alike. Without it an unmatchedoffwould drop that comment — hard invariant #3. - A region never straddles two scopes, so regions are pairwise nested or
disjoint, and
collect's existing "sort byfence, then drop any region whosefenceprecedes the previous region'send" filter still leaves a list sorted by both ends —region_at'spartition_pointprecondition. The argument is unchanged from item scopes and is spelled out under Handshakes. - Every
stmt_seqcaller emits a line break before it.Doc::Verbatim's one contract is that it is only ever emitted right after a line break or at the very start of the output;block_doc, theforkarm,function,taskall push aHardLinebefore the sequence, and the statement-fragment path is the start of the output. Audited by grep, listed in the work log.
Handshakes
Consumed from vlog_parser (nothing new is required of it):
Stmt.meta.leading/Stmt.span— the units of a statement scope, the same pairItemsupplies.- The statement-scope shapes:
StmtKind::Block,StmtKind::ForkJoin,FunctionDecl.stmts+.dangling,TaskDecl.stmts+.dangling, and the bodies reached fromItemKind::{Always, Initial, Final}. - The item-scope shape
ClassDecl { items, dangling }. Fragment::Statements— a statement fragment is one statement list at file scope, socollectscans it as one.
Promised to vlog_formatter callers: no public signature changed.
fence::collect, fence::region_at, fence::protected_regions and
fence::is_protected keep their signatures and their contracts.
crates/lucisv/src/lint.rs and crates/lucisv_server/src/lint.rs are
byte-identical. What did change is collect's answer: it now reports
regions the line scan already reported, which narrows the union
protected_regions returns toward the truth and can only ever decline the
same edits or fewer.
region_at's precondition still holds. Two regions are nested or
disjoint: a region lives in one scope's unit stream, running from its off
fence to an on in the same stream or to that scope's own end, and scopes
nest. A statement region therefore lies wholly inside the item whose body
holds it, and an item-level region either contains that item entirely or ends
before it starts. Sorting by fence and dropping every region whose fence
falls before the previous region's end leaves a disjoint list, which is
sorted by both ends.
verify.rs is untouched. No normalization was added, broadened or
weakened, so CLAUDE.md hard invariant #4's obligation does not arise — and
none was needed: a region is source bytes, so it re-lexes to exactly the
tokens it came from, and the units it replaces are exactly the ones whose
bytes it contains. Equivalence holds by construction and the check runs
unchanged as the backstop. New corrupted-region attack pairs for a statement
region and a class-body region are in tests/fences.rs, modelled on the five
that already guard item regions. Note what a token check cannot see: a
whitespace-only rewrite inside a region is token-equivalent, so the attack
pairs are all token-stream corruptions and the byte-exactness of a region is
asserted separately, by the fenced helper.
range.rs: the plan now carries the fences. range::plan extends its
manufactured verbatim runs with fence::collect's regions before
normalize folds the two into their union. At item level this changes no
answer — a fenced item is already Pick::Verbatim, so its bytes were in a run
either way — but a fenced statement inside a laid-out item has no run
behind it, and without the merge --lines over such an item would have
reformatted bytes the author fenced off. A fence outranks a range, as before.
Recursion budget (docs/features/recursion-limit/README.md): unaffected.
scan_nested_stmt recurses only through statement nesting the parser already
bounds (parse_stmt is gated at the same 320 layers), builds no tree, and
Doc::Verbatim is a leaf.
Requested of nobody. No handshake request was filed; every file this round needed was in its own ownership list.
Deferred, with reasons
- Port and parameter lists, and case-item label lists. Their elements are
printed inside a
Group, mid-line.Doc::Verbatimis column-0 and forces a break — it cannot stand inside a group — andDoc::Inline, the only mid-line verbatim primitive, carries no region indentation, so a region spliced there would drift on every pass. This wants a different printer primitive, not another scan arm. A fence in either place stays an ordinary comment; pinned bythe_three_deferred_places_are_inert_and_never_corruptand by two.casesentries. - Same-line (trailing-trivia) fences.
wire a; // lucisv: offis an ordinary comment. Unblocked sinceMeta.trailinggained a span (comments-round, 2026-08-19) but still deliberately inert: accepting it means deciding whether the region starts on the next line, which is a different rule from "the region starts at the fence's line start", and nothing has asked for it. - The single-statement body of a bodyless
if (x) y = 1;, and the single-item body of a bodyless generateifbefore it — sameGroupreason as the lists above. PropSeqDecl.locals— aVec<Item>that is not printed throughitem_seq:sva.rsprints each local withwith_metaand then the property spec, which is not an item. The list has no end a region could stop at without inventing one. Left alone;InterfaceandProgramneed no arm because both areItemKind::Module, which has been scanned since the first round, and there is noCheckernode in the AST at all.- The cross-level pairing rule is unchanged. An item-level
offclosed by a statement-levelonis still an unmatchedoff— it runs to the end of its own item list — and theonis a strayonin the statement scope, i.e. an ordinary comment. That errs toward more verbatim text, never toward reformatting something the author fenced off.
Status / TODO
- 31.1 class bodies:
ItemKind::Classarm inscan_nested; the other item-list carriers checked and named (Interface/ProgramareItemKind::Module, already scanned; noCheckernode exists;PropSeqDecl.localsdeferred with a reason). Cases: a fence around one member, around a nested class, an unmatchedoffstopping atendclass, comments before theoff. - 31.2 statement lists:
scan_units(the shared unit stream),scan_stmt_scope,scan_nested_stmt, theAlways/Initial/Final/Function/Taskarms, the merge intocollect's sorted list, thestmt_seq/stmt_docsrules, theopens_linegate, the trailing-comment scope end, and therange.rsplanner merge. - 31.3 docs rewritten: format-fences README ("Out of scope" replaced by
the real scope table), classes README handshake ticked,
shared-fence-filter README's asymmetry note corrected,
README.md"Turning the formatter off",docs/coverage_gaps.mdM9 struck. - Attack pairs (a statement region, a class-body region) plus the
fencedtriple for every new scope;verify.rsuntouched. - Gates:
cargo fmt -p vlog_formatter,cargo clippy --all-targets --workspace,cargo test --workspace, corpus 814/820 byte-identical to 0.34.0, opentitan fence census + read-only sweep. - QA: PASS (2026-09-03). No CRITICAL/HIGH findings; two MEDIUM items
for the lead's ruling (
docs/topo.mdedited outside the dev's file list; theopens_linenarrowing, recommended as a drift fix) and one LOW informational note. Full log below.
Work log
2026-09-03 — dev agent (Opus 5)
Baseline measured first, in a throwaway git worktree at HEAD:
cargo test --workspace 3 234 passed, 0 failed, 42 ignored.
31.1 — class bodies (one arm, as planned). ItemKind::Class(c) => scan_scope(src, &c.items, &c.dangling, out) in scan_nested. The other
item-list carriers were checked, since the plan asked for them by name:
Interface and Program are not separate nodes — both are ItemKind::Module
(Module::end_kw picks the closing keyword), so they have been fenceable
since the first round; there is no Checker node in the AST (grep over
crates/vlog_parser/src/ast); GenBlock, GenerateRegion and Package were
already scanned. The only Vec<Item> left unscanned is PropSeqDecl.locals,
deferred above with its reason. format/class.rs needed no change — the
class body has always printed through the fence-aware item_seq/dangling,
which is why one scan arm was the whole feature.
31.2 — statement lists.
scan_scope's body becamescan_units, a scan over an iterator of(leading comments, code extent)pairs plus the scope's dangling comments.scan_scopeand the newscan_stmt_scopeare each three lines on top of it. This is a pure refactor of the item path — the attribute guard (c.span.start < span.start), the high-water mark and the unmatched-offtrailing-comment scan all live in one place now instead of two, and the item-level output is unchanged.scan_nested_stmtwalks the statement tree and opens a scope only atBlockandForkJoin.If/Assert(both arms),Case/RandCase(each item's body),For/While/DoWhile/Repeat/Forever/Foreach/Labeledand theTiming/Waitbodies are walked through. Deviation from the plan, deliberate:AssertandLabeledare not in §31.2's list. They are structurally identical toIf's arms and to a bare body — afoo : begin … endlabelled block is a common DV shape — and including them adds no scope kind, only reach.scan_nestedgained the four item-side entries:Function/Taskscan theirstmts+danglingas a scope;Always/Initial/Finalhand their body statement toscan_nested_stmt, which finds thebegin…endinside it.collectnow dispatches onSourceFile::fragment: aFragment::Statementsfile is one statement list at file scope and scans as one. Deviation, deliberate: §31.2 did not mention fragment mode. It is three lines,itemsis empty for every fragment (verified inparser/directive.rs::read_fragment), and leaving it out would have made "statement lists are fenceable" false on the LSP's fragment path alone.format/stmt.rs:Fmt::stmt_docsis the statement twin ofitem_docs— the region an offset opens, else the leading comments alone when the code is swallowed (with the danglingHardLinedropped), else the statement.stmtis nowconcat(stmt_docs(s))andstmt_seqseparates on "did this unit emit anything" instead of on the index, which is byte-identical to the old formulation when no fence is present — the untouched snapshot suite is the proof.range.rs:planextends its runs withplanner.fencesbeforenormalize. See Handshakes for why;normalize's doc comment already described folding a fence and a run into their union, and this is the caller that makes that sentence true.
The line-start gate, and the one behaviour change outside the new scopes.
step now opens a region only when opens_line(src, start): whitespace and
finished block comments may precede a fence on its line, code may not. It was
forced by always @(*) begin // lucisv: off, which the parser hands to the
first inner statement as a leading comment — mid-line — where a region would
have started at the wrong column. Applying the test only to statement scopes
would have left the rule two rules, so it is applied everywhere, and that
changes one item-level shape: module m; // lucisv: off used to open a region
and now does not. Three reasons this is the right call rather than a
regression: the format-fences README has documented the rule as "it must
start a line (nothing but whitespace, or another comment, before it on that
line)" since the first round, so the code was the thing that drifted; the
existing .cases entry "a fence written after code on the same line is not a
fence" states the same rule for the case where the comment lands as trailing
trivia; and it narrows what fires, which cannot corrupt. The documented
/* a */ // lucisv: off exception is preserved deliberately — a block comment
before the fence is a unit of the same stream. Pinned by
a_fence_sharing_its_line_with_code_is_an_ordinary_comment and two .cases
entries. Corpus impact: none, it holds zero fences. One consequence worth
stating plainly, because it is the only place this round narrows
anything: protected_regions used to protect a module m; // lucisv: off
region (via collect; the line scan never saw it, since the trimmed line is
not a fence text), so lucisv check --fix and the server's quick fixes
declined to edit there. They no longer do — which is right, since that
comment is no longer a fence by any definition, but it is a narrowing and not
just a widening. Probed directly (is_protected false for that shape, true
for a statement fence, a class-body fence and an unmatched off in a task
body).
File sizes, measured (production lines: non-blank, non-comment, outside
#[cfg(test)]): fence.rs 226 → 246, format/stmt.rs 573 → 590,
range.rs 320 → 325. All three stay inside CLAUDE.md's 300–600 band, and
nothing was pushed over a threshold. format/stmt.rs is the one to watch: at
590 it is close enough that the next addition to it should go in a new
module. Splitting it was not done here on purpose — a split is a pure move
and belongs in its own change, not tangled with a behaviour change.
Not changed, on purpose: verify.rs, protected_regions/is_protected,
crates/lucisv/**, crates/lucisv_server/**, format/class.rs,
format/item.rs (the two rules a swallowed unit obeys were already there and
stmt_docs mirrors them rather than sharing a helper — the two take different
node types and factoring them would cost a trait for one caller each).
Results. cargo test --workspace 3 244 passed, 0 failed, 42 ignored
(baseline, measured in a worktree at HEAD: 3 234 / 0 / 42) — +10 tests:
8 in tests/fences.rs, 1 in tests/ranges.rs
(a_statement_fence_outranks_a_range_too, confirmed to fail without the
range.rs merge), 1 unit test in fence.rs for opens_line. fences.cases
goes 25 → 38 entries (+13; the entry "a statement-level fence has no effect
this round" was inverted rather than added, as §31.3 said it would be).
cargo test -p vlog_formatter 285 (was 275).
cargo clippy --all-targets --workspace 0 warnings.
cargo fmt -p vlog_formatter clean — note it reformats the crate's tests
too, which is where the one unrelated-looking hunk in tests/fences.rs comes
from. verify.rs and tests/verification.rs untouched (git diff --quiet
on both).
Corpus: scripts/corpus_gate.sh corpus → {"passing":814,"total":820, "pct":99.3}, the same six failures by the same categories, 0 verification
errors, 0 crashes. Byte-identity against the 0.34.0 release binary
(/tmp/lucisv-0.34.0-baseline), --stdout per file over all 860 corpus
sources: 0 differences — as expected, the corpus contains zero fence
comments (0 files match verilog_format: (off|on)|lucisv: (off|on)).
OpenTitan (read-only; --check and --stdout only). Census first: 9
of 3 947 sources carry fence comments, 33 comment lines in all, and many sit
inside class bodies, task bodies and fork blocks — so files could move,
and four did. Old-vs-new --stdout over the whole tree: 4 differences of
3 947, every one of them the fenced bytes now being preserved:
| file | what changed |
|---|---|
hw/ip/lc_ctrl/dv/env/lc_ctrl_env.sv |
a fenced uvm_config_db#(…)::set(…) call inside a function body keeps its hand-wrapped argument layout instead of being re-broken one-per-line |
hw/ip/lc_ctrl/dv/env/seq_lib/lc_ctrl_errors_vseq.sv |
a fenced class-body region (two virtual tasks, ~110 lines) keeps its hand-written ternaries, comment placement and blank lines |
hw/ip/lc_ctrl/dv/env/seq_lib/lc_ctrl_jtag_access_vseq.sv |
the closing on fence keeps its own (odd, 5-space) indentation, because the fence comment is part of the region |
hw/ip/lc_ctrl/dv/env/seq_lib/lc_ctrl_jtag_priority_vseq.sv |
the blank line written between the on fence and the next statement is dropped — the documented "after the region" rule, now reaching statement level |
Injection stress, the way the first fence round did it (harness in the
scratchpad, not checked in; seed 0x2026_0903_dead_beef, replayable). Four
random off/on line pairs injected into every corpus file that parses, each
compared against a paired control where the same two lines are ordinary
comments of identical width — the control matters, because injecting any
comment into a port list or an expression is a known pre-existing refusal
class (corpus-bugs README) and an unpaired comparison blames it on the fence.
Result over 3 348 trials across 854 files:
trials=3348 fence_refusals=39 plain_refusals=39 new=0
honoured=3309 byte_exact=1976 same_level=1202 same_level_byte_exact=850
Zero verification failures attributable to fencing, and no panic. The
byte-exact figure (1 976 of 3 309 runs reproduce the whole off-line-through-
on-line slice contiguously) is a floor, not a defect rate: a randomly
placed pair lands as often as not in a position where the fence is inert by
design — a port list, a case label, a header line, an expression — or at two
different nesting levels, where the off is unmatched and correctly stops at
its own scope's end instead of reaching the on. Restricting to pairs whose
two lines share an indentation (a crude same-scope proxy, and only a proxy —
two sibling blocks share an indent too) lifts it to 850 of 1 202. What the
run rules out is the thing that matters: no injected fence ever made the
formatter produce output the safety net had to refuse when the same comment
in the same place would not have.
Each diff is assertion-free in the sense that matters: the + side is the
file's own source bytes. All four are fixed points under a second pass
(checked explicitly), and --stdout succeeding at all means
verify_equivalence and verify_convergence both passed inside
format_source. The read-only --check sweep reports identical counts
before and after (3 896 would reformat, 72 unchanged, 11 failed to format),
and git -C ../opentitan status --porcelain shows only the three
pre-existing modified files (hw/ip/aes/dv/tb/tb.sv,
hw/top_darjeeling/ip/ast/rtl/ast.sv, hw/top_earlgrey/ip/ast/rtl/ast.sv).
Files touched: crates/vlog_formatter/src/fence.rs,
crates/vlog_formatter/src/format/stmt.rs,
crates/vlog_formatter/src/range.rs,
crates/vlog_formatter/tests/fences.rs,
crates/vlog_formatter/tests/cases/fences.cases, this README,
docs/features/format-fences/README.md, docs/features/classes/README.md,
docs/features/shared-fence-filter/README.md, docs/coverage_gaps.md,
README.md, TODO.md (§31 only). No git commit/push.
QA log
2026-09-03 — QA agent (Sonnet 5)
All checks run read-only against the uncommitted main tree, plus one
throwaway git worktree (.claude/worktrees/qa-play-31, removed when done)
for the two experiments that needed source edits (the narrowing probe and
the range.rs load-bearing check). Never ran git checkout/stash/
reset/clean in the main tree. git status --porcelain before and after
this pass is identical to what the dev left: no file outside the dev's own
edits was touched.
1. Gates — all confirmed independently, not just re-reading the dev's numbers.
cargo fmt --all -- --check: clean (exit 0).cargo clippy --all-targets --workspace: 0 warnings;git diffof the three touched files has no#[allow].cargo test --workspace --no-fail-fast: summed the 48test result:lines myself — 3 244 passed, 0 failed, 42 ignored, matching the claimed baseline delta (3 234 → 3 244).cargo test -p vlog_formatter: summed to 285 (32+1+5+14+2+23+208+0), matching the claimed 275 → 285.git diff --stat -- crates/vlog_formatter/src/verify.rs crates/lucisv/src/lint.rs crates/lucisv_server/src/lint.rs: empty, all three.- Changed-file set:
git status --porcelainlists exactly the files named in Handshakes/Work log, plusdocs/topo.md, which is not in the ownership list given to me (TODO §31's own "Files:" line marksdocs/topo.md §2.9-3 struck (lead)as the lead's job, not the dev's). The content of that edit is accurate and consistent with everything else (checked below), so this is a process note, not a defect: the edit is already made, uncommitted, in the working tree ahead of lead review. MEDIUM (process, not correctness) — flagging for the lead's ruling, not blocking.
2. Byte-identity — reproduced independently, not by trusting the dev's numbers.
- Built
cargo build --release -p lucisvmyself. - Corpus: copied
corpus/to two scratch trees, formatted one with/tmp/lucisv-0.34.0-baselineand the other with the new binary in-place,diff -rqthe two trees: 0 differences across all 860 files.scripts/corpus_gate.sh corpus→814/820, 99.3%, same failure categories, 0 verification errors, 0 crashes. - OpenTitan (read-only throughout — only
--stdout/--check, and I verifiedgit -C .../opentitan status --porcelainwas clean of anything but the three pre-existing files both before and after):- Census:
grep -rlE 'verilog_format: (off|on)|lucisv: (off|on)'overhw/→ 9 files, matching the dev's count. - Copied the whole
hw/tree (3 947 sources) to two scratch trees, formatted one with each binary,diff -rq: exactly 4 differing files, and they are the same 4 the dev named (lc_ctrl_env.sv,lc_ctrl_errors_vseq.sv,lc_ctrl_jtag_access_vseq.sv,lc_ctrl_jtag_priority_vseq.sv). Both binaries exit 2 (pre-existing parse failures elsewhere in the vendor tree, unrelated). - Read all four diffs.
lc_ctrl_env.sv: the new output's fenced lines are byte-for-byte the same text asgit show HEAD:...at that location (checked directly).lc_ctrl_jtag_access_vseq.sv: confirmed the source really does have 5 leading spaces before thatonfence (awkline dump), so the "odd indentation preserved" claim is real, not a typo.lc_ctrl_jtag_priority_vseq.sv: the blank line after theonfence is dropped, matching the documented after-region rule.lc_ctrl_errors_vseq.sv: found the single real fence pair by grep (lines 918/1030 — the other sixverilog_format: off/oncomments in that file all carry trailing text, e.g. "- avoid bad formatting", so per the fence grammar they are correctly not fences and correctly untouched); a Python regex extraction confirmed the new output's ~110-line fenced slice is identical to the same slice ingit show HEAD:...of the file. - Second-pass fixed point: ran the new binary again on all four new
outputs — byte-identical (
diff -qclean) for all four. - Comment census (counting
//-bearing lines) on all four files: original source, old-binary output, new-binary output all match exactly (8, 196, 41, 21 respectively) — no comment dropped. --checkoverhw/with both binaries: identical counts, 3 896 would reformat, 72 unchanged, 11 failed, both before and after.
- Census:
3. Break it — 15 hand-written files (scratchpad qa-31/breakit/),
one per scope/edge named in the task: begin…end, fork…join, a function
body, a bodyless always_comb (no begin), a whole if/else, a case
item body, a class item and a nested class, an item-level off closed by a
statement-level on (two variants), an unmatched off in a statement list
stopping before endfunction, begin // lucisv: off (same-line, ordinary
comment), a block comment sharing the fence's line (the documented
exception), a fence with trailing text (ordinary comment), deep nesting
(fork inside if inside if), a fenced statement under --lines (five range
specs against the CLI directly, not just the dev's ranges.rs test), and
check --fix on two shapes.
Every file that parsed produced output — format_source calls
verify_equivalence+verify_convergence internally, so every successful
--stdout already proves equivalence; I additionally re-ran the output
through the binary a second time and diffed byte-for-byte for all 15 —
all fixed points. Comment line counts (////* occurrences) match
input to output on all 13 of the scope/edge files. Specific findings:
- The bodyless
always_combcase: confirmed the fence comment survives (never dropped) whilex = 1;is laid out normally (collapsed spacing) — correctly inert, not a scope, as documented. - The nested-fence pairing rule (item
off/ statementon): built a case withwire a;after theinitial begin...endinside the same module, both with distinctive multi-space padding. Confirmed the entire module body up to and including thatwiredeclaration came out byte-for-byte raw (padding preserved), while awire b;written after it was laid out normally — i.e. the unmatched item-leveloffswallows everything to the end of its own item list, the inner statement-levelonis correctly inert, and the fence does not leak into the next item. Matches the documented rule exactly. --lines: ran the CLI directly (not the dev's own test) with--lines 4and--lines 1-9over a file with a mid-block fence: both left the fenced statements untouched while reformatting the surrounding, already-clean statements — a fence outranks a range, confirmed against the real binary.check --fix: crafted two files, one with the narrowing shape (module m; // lucisv: offfollowed by a stray;null item) and one with a genuine statement fence around a stray tab character. Rancheck --fixwith both/tmp/lucisv-0.34.0-baselineand the new binary on copies of each:- Narrowing shape: old binary reports the
empty-itemviolation but does not fix it (declined, protected); new binary fixes it (deletes the;) and the violation disappears from the report entirely. This is the real, user-visible consequence of the narrowing, confirmed live rather than by reading the dev's prose. - Genuine statement fence: both binaries report the
no-tabsviolation but decline to fix it — the tab stays untouched by both. Statement-level protection for--fixholds.
- Narrowing shape: old binary reports the
No dropped comment, no non-fixed-point, no moved byte inside a region in any of the 15 files.
4. The narrowing — reproduced at both the formatter and the
is_protected/protected_regions layer, and the CLI --fix layer
above.
- Quoted the format-fences README exactly as of round 1
(
git show 02f6865:docs/features/format-fences/README.md): "A fence must be a leading comment, i.e. it must start a line (nothing but whitespace, or another comment, before it on that line)." The dev's claim that this rule predates the code is correct — verified by reading round 1's own text, not by trusting the work log's paraphrase. - Built two throwaway worktrees (
qa-play-31at the dev's patch,qa-baseline-31at plainHEAD) and added a temporary probe test to each (tests/fences.rs, never touching the main tree). Confirmed directly:protected_regions/is_protectedonmodule m; // lucisv: off\n wire a;\nendmodulereturns not protected on the dev's patch and protected on plainHEAD— the narrowing is real at the API level the CLI's--fixand the server's quick fixes both call, not just in the formatter's own byte-for-byte splice. - A genuine statement fence and a genuine class-body fence both remain
protected in the same probe, and
collect's own (scope-aware) answer for an unmatchedoffin a task body stops exactly atendtask(verified the region'send <= task_end), never past it — the crude line-scan half ofprotected_regions's union has no notion of scope and may still over-protect further (documented, and I confirmed it: it ran the same unmatched-offregion to end of file), which only ever declines an edit and is unrelated to this feature. - Both worktrees removed after use (
git worktree remove --force);git status --porcelainon the main tree confirmed unaffected throughout.
Recommendation on the narrowing: drift fix, not a regression. The
documented rule predates this round by two releases (round 1, commit
02f6865); the code was the thing out of step with its own spec, not the
other way around; the change only removes protection, it adds none (an
already-verified-safe direction per invariant #1); and the shape it stops
matching (module m; // lucisv: off, comment trailing the header on the
same line) was never advertised as supported in any README, changelog, or
.cases file before this round touched it. I found no place where a user
was told this specific shape worked. Concur with the dev: ship it as a
drift fix, MEDIUM severity recorded for the lead's ruling only because it
is a live user-visible behavior change (a real --fix decision flips),
not because anything is wrong with it.
5. Attack pairs. Read the dev's new corrupted-region pairs in
tests/fences.rs (7 statement-region + 5 class-region corruptions) — all
plausible, all target genuine token-stream changes (literal rewrites,
dropped/added statements or members, fence-comment tampering, swallowed
closer). Added two of my own in the qa-play-31 worktree:
- A single literal changed inside an otherwise-intact statement region —
rejected by
verify_equivalence, as expected. - The
onfence's effective position moved one statement earlier: first tried a whitespace-only variant (y = 2;→y = 2;, fence text left in place) and it was accepted byverify_equivalence— not a bug, the documented boundary ("a whitespace-only rewrite inside a region is token-equivalent") applies identically to item-level regions since round 1 andverify.rsis untouched this round, so there is no new widening to attack-test under invariant #4. Replaced it with two variants that are genuine token corruptions (a literal changed inside the region; theonfence's own text moved a line, laundering a statement from verbatim to laid-out) — both correctly rejected. - LOW note, not a defect: worth restating in the feature README
(already is, in Handshakes) that the safety net's defense against a
whitespace-only corruption inside any fenced region — item or
statement — is the formatter's own verbatim-copy code path, unit- and
snapshot-tested directly, not
verify_equivalenceafter the fact. This is pre-existing and out of scope for this round.
6. range.rs load-bearing claim — reproduced. In qa-play-31,
commented out the one line regions.extend(planner.fences.iter().copied());
in range::plan: cargo test -p vlog_formatter --test ranges a_statement_fence_outranks_a_range_too failed exactly as predicted
(spec 4 reformatted the fenced statement, collapsing b/cc's
spacing). Restored the line: the test passed. The claim is not
decorative — the merge is genuinely load-bearing.
7. Docs. Read all four amended READMEs in full
(format-fences, classes, shared-fence-filter, plus the new
statement-fences) and README.md's "Turning the formatter off" and
docs/coverage_gaps.md's M9 row.
format-fences/README.md: "Out of scope" is now a real "The fenceable scopes" table plus a "Still not fenceable" list; matches the code (checked thescan_nested/scan_nested_stmtmatch arms directly against the table's rows).classes/README.md: the filed handshake is marked delivered with the exact arm quoted; matchesfence.rs's actual diff.shared-fence-filter/README.md: the stale-asymmetry note is correctly marked stale with a dated correction; the "one shape got narrower" paragraph matches finding 4 above word for word.README.md: the new class-method example is realistic UVM shape and formats correctly when I ran it (spot-checked). The "must begin its own line" and "no further" wording matches the code.docs/coverage_gaps.md: M9 struck with an accurate closing note (the two deferred mid-line positions named correctly); the "what's still open" paragraph at the bottom updated consistently.TODO.md§31: all four sub-checklists ticked match delivered work; only the QA line is unchecked, correctly, since QA had not run. Deferrals (port/parameter lists, case-item label lists, same-line fences,PropSeqDecl.locals) are each named with a real, checkable reason in the statement-fences README's own "Deferred, with reasons" section, and I independently exercised the three deferred shapes (break-it §3,t4/port-list/case-label cases already covered by the dev's ownthe_three_deferred_places_are_inert_and_never_corrupttest, which I read and agree models them correctly).
Findings summary.
- MEDIUM:
docs/topo.mdwas already edited in the uncommitted tree, outside the file-ownership list this task gave me and outside what TODO §31's own "Files:" line assigns to the dev (marked "(lead)"). The content is accurate; flagging only the process order for the lead. Not blocking. - MEDIUM (ruling requested, not a defect): the
opens_linenarrowing — see finding 4. Recommend: accept as a drift fix. - LOW (informational, not a defect): the safety net's blind spot for a
whitespace-only corruption inside a region is unrelated to this
round's changes to
verify.rs(there are none) and predates it at item level; noted for the record only. - No CRITICAL or HIGH findings. No corruption, no dropped comment, no
non-fixed-point output, no moved byte inside any region, no reach past
a scope's own end, no range reformatting a fenced byte, and
verify.rsconfirmed untouched (git diff --statempty) with its existing token check independently re-exercised and holding for every genuine corruption I constructed.
Verdict: PASS.
Review
2026-09-02 — lead. Accepted. The round did what the plan asked and
found the two things the plan could not see: that range.rs must merge
fence regions into its plan because a fenced statement has no verbatim
run behind it (proved by breaking it), and that the line-start rule has
to be one rule — opens_line everywhere — because the parser hands a
same-line fence after begin to the first inner statement as a leading
comment. The narrowing that follows (module m; // lucisv: off no
longer opens a region, and the backstop stops protecting that shape) is
ruled a drift fix: the format-fences README has said "it must start a
line" since round 1 (QA quoted the commit), the statement-level case
already behaved that way, and a fence hiding after code is exactly the
ambiguity the rule exists to remove. scan_units as the one scan under
both scope kinds is the right shape; the three extra walker arms add
reach, not scope kinds. Deferred with reasons and recorded: port lists,
case-item labels, same-line fences, a property's locals. Proof:
corpus byte-identical (zero fences there), opentitan's four fenced
files now keep their bytes and are fixed points, 3 348 injection trials
with no new refusals. QA's note that a whitespace-only change inside a
region is invisible to verify_equivalence is a documented, pre-
existing property of item-level fences too (a region is source bytes;
the formatter never rewrites them) and is not this round's obligation.
format/stmt.rs at 590 production lines is the next lane's first
split. Ships in 0.35.0.