Files
lucisv/docs/features/lexer-cleanup/README.md
T

520 lines
30 KiB
Markdown

# lexer-cleanup
## Goal
Close the three lexer gaps filed by earlier QA rounds: (1) `@(* )` — an
implicit sensitivity list with whitespace between `(*` and `)` — failed to
lex because `(*` was unconditionally the start of an attribute (TODO §1);
(2) a UTF-8 BOM at the start of a file was a lex error with a mojibake
message (`unexpected character 'ï'` — one byte of the BOM's encoding,
error-recovery QA log); (3) a non-ASCII character produced the same
one-byte mojibake (`'Ã'` for `é`), and — the sneaky half — because the
lexer is all-or-nothing, `lucisv check` on such a file reported *nothing*
and exited 0 while `lucisv format` correctly refused (lint-rules-2 QA log).
The fixes make the lexer's answers honest: real spellings lex, real errors
name the actual character and position, and a file the linter could not
tokenize is a loud per-file error instead of a silent pass.
## Assumptions
- **An attribute instance contains at least one attr_spec** (IEEE 1800
§5.12), and an attr_spec cannot begin with `)`. That is what makes the
backoff safe: `(*` followed — possibly after whitespace — by `)` cannot
be an attribute, so it lexes as the three symbols `(` `*` `)` (the
implicit sensitivity list). A file that really contained `(* )…*)` was
invalid Verilog before and is a parse error now instead of an attribute
token; `(* *)` (first non-whitespace after `(*` is `*`, not `)`) still
lexes as an attribute, exactly as before.
- **A leading BOM is treated like leading whitespace and is not
preserved.** The formatter's output starts at the first token, so
formatting a BOM'd file drops the BOM — a deliberate normalization, the
same one `lucisv_core`'s config parser already applies to `lucisv.toml`. A
BOM anywhere else in the file stays a lex error, now with a message that
names it (`byte order mark (U+FEFF) is only allowed at the start of the
file`).
- **Columns are UTF-8 byte offsets** (the `LineIndex` convention), so the
first token of a BOM'd file reports column 4. `LineIndex` is built over
the same text and agrees.
- **Non-ASCII characters remain invalid in Verilog source** outside
comments, strings and escaped identifiers — the LRM allows only
`[a-zA-Z_$0-9]` in simple identifiers. Only the *message* changed: it
now decodes the whole character (`character 'é' (U+00E9) is not valid in
Verilog source`) instead of the first byte of its encoding. The decode
is defensive (`from_utf8_lossy` over at most 4 bytes) even though
`tokenize` takes `&str` and the cursor always sits on a char boundary.
- **A lex error under `lucisv check` is a per-file error (exit 2), matching
`lucisv format` on the same file** — the frozen exit-code contract's
"error" class. Text-level findings (tabs, trailing whitespace, line
length) are still reported for such a file, because those rules really
did run; the error says the token- and AST-level rules saw nothing, so
the file must not pass as checked.
## Handshakes
**Changed in `vlog_parser::lexer` (consumed by everything downstream):**
- `(*` + whitespace + `)` now lexes as `(` `*` `)`. The parser already
folds `@ ( * )` into `SensList::Star` (probed: `@( * )` — spaces on
both sides of the star — lexed and formatted to `@(*)` before this
round), so no parser change was needed.
- A leading BOM is skipped; `tokenize` on `"\u{feff}…"` succeeds. The BOM
bytes are covered by the losslessness suite's *gap* rule (see below).
- Lex-error messages for non-ASCII bytes changed shape. Nothing parses
messages today (grepped: callers only `Display` them), but tests that
matched the old `unexpected character 'ï'` wording would break — none
did.
**Promised to `vlog_formatter` — verify.rs untouched:** the `@`-collapse
(`collapse_implicit_sensitivity`) already whitelists exactly the `@ ( * )`
token sequence on both sides, which is what `@(* )` now lexes to on the
input side and `@(*)` re-lexes to on the output side. Its comment's
justification ("`(*` followed by anything other than `)` lexes as an
attribute") now has one more exception — whitespace-then-`)` — but the
conclusion it supports is unchanged: the `@ ( * )` sequence still has no
meaning other than an implicit sensitivity list, so the collapse forgives
nothing new. **No normalization in `verify.rs` was added, broadened or
weakened** (hard invariant #4 does not apply; `git diff verify.rs` is
empty). BOM: the formatter's output never contains one, and
`verify_equivalence` re-lexes both sides with the same BOM-skipping lexer,
so a BOM'd input verifies against BOM-less output with no forgiveness
rule at all. Probed end to end: full format, format-twice fixed point, and
`format_range` (verbatim splice starts at the first item's span, past the
BOM) all converge.
**Changed in `vlog_linter::ParsedSource` (consumed by `lucisv check`):** a
new field + accessor, `lex_error() -> Option<&LexError>`, kept from the
`tokenize` failure that previously vanished into the error-tree fallback.
Additive: `lucisv_server` builds contexts via `from_parse` with its own
products and is untouched.
**Changed in `crates/lucisv/src/lint.rs`:** `run_rules` now also returns
the rendered lex error; `check_one`/`check_stdin` put it in the report's
`error` slot — the same slot unreadable files and panics use — so it
prints `error: <path>: lex error: <line>:<col>: <message>` on stderr,
counts into "N files could not be checked", and exits 2. Violations found
by text rules on the same file are still printed.
**Requested of nobody.** The `lucisv_server` publishes lex errors through
its own diagnostics path already; no change needed there.
## The macro space-before-paren item: assessed, PARKED
`docs/features/macro-items/README.md` (Assumptions) defers `` `M (a, b) ``
— a macro call with a space before the argument list — because the lexer
only attaches a `(` that immediately follows the name. The suggested fix
is a whitespace skip before that `(`. Assessed here since this round was
in the lexer anyway. **Verdict: not safe; parked.** The analysis:
1. **Expression position is live, not hypothetical.** Probed:
`x = `A (b);` *parses today* as `ExprKind::Call { callee: `A, args:
[b] }` — a valid tree, no error. Gluing the lexer would silently change
that parse to a single opaque macro token. That is a *meaning* change
candidate, not just an acceptance change, so "the fix only accepts
previously-rejected input" — the argument that would have made it safe
— is false.
2. **Which reading is correct depends on the macro's definition, which
the lexer cannot see.** A macro defined *with* formal arguments
consumes the parenthesized list at usage; one defined *without* does
not — `(b)` after it is ordinary source text (IEEE 1800 §22.5.1). The
definition is routinely in another file (`include), so any fixed
lexer-side answer is provably wrong for one of the two populations.
`` `NOT (a) `` with `` `define NOT ~ `` is the counterexample: gluing
turns a negation of `a` into a bogus one-argument invocation.
3. ~~**The glue would also rewrite the text.**~~ *Struck by the lead per
QA (premise probed false: the formatter reprints a macro token's text
verbatim, internal spacing included, so under the hypothetical glue
there is no text rewrite for the net to miss). The park does not rest
on this argument — arguments 1, 2 and 4 carry it: the reading depends
on a definition lucisv cannot see, a fixed answer is provably wrong for
one population, and today's behavior fails safe.*
4. **Today's behavior fails safe.** Item position: clean parse error
(documented in macro-items). Expression position: the call parses, the
formatter prints `` `A(b) ``, and `verify_equivalence` *refuses* the
result (probed: "token stream diverges … input has identifier "`A" …
output has identifier "`A(b)"") — the file is left untouched with an
error, exit 2. Nothing corrupts. The workaround (write the call tight)
stands; every corpus call site is already written tight.
Filed observation for a future round: that expression-position shape is
a formatter *usability* gap (a parseable file that always errors out of
formatting). A formatter-side fix — preserving the author's space
between a macro identifier and a following `(` — would close it without
touching the lexer, and is the direction to explore if it ever matters
in practice.
## Status / TODO
- [x] `@(* )` family lexes: attribute scan backs off when the first
non-whitespace after `(*` is `)`; real attributes unaffected.
- [x] `@(* )` family through the formatter (`statements.cases`):
canonicalizes to `@(*)`, verify + idempotency green.
- [x] Leading BOM skipped like whitespace; spans suite's gap rule admits
the leading BOM and BOM'd sources joined `SOURCES`; mid-file BOM is
a clear, named error.
- [x] Non-ASCII lex error names the character and codepoint.
- [x] `lucisv check` on a file that does not lex: exit 2, stderr error,
"could not be checked" summary; text-rule findings still reported.
(`ParsedSource::lex_error` + `crates/lucisv/src/lint.rs`.)
- [x] BOM'd file through format AND check (CLI tests); non-ASCII file
through both (CLI test pins the no-longer-silent behavior).
- [x] Losslessness/spans suites green with the BOM decision; error-recovery
truncation fuzz green, plus a dedicated BOM'd-prefix truncation test.
- [x] TODO §1 checkbox; annotations in error-recovery and lint-rules-2 QA
logs.
- [x] Macro space-before-paren: assessed, parked with analysis (above).
## Work log
### 2026-08-19 — dev agent
- Read CLAUDE.md, TODO §1, the error-recovery and lint-rules-2 QA logs,
the macro-items Assumption, `lexer.rs`, `spans.rs`, `verify.rs`'s
`@`-collapse, and `lucisv`'s check driver before touching code. Baseline:
`cargo test --workspace` **791 passed**.
- **Probed before designing** (scratchpad harness, deleted): `@( * )` and
`@( *)` already lexed — only the adjacent-`(*` spellings (`@(* )`,
`@(* )`, `@(*\n)`) failed, as "unterminated attribute" swallowing the
rest of the file. That narrowed the fix to the attribute-scan backoff
the TODO suggested and showed no parser work was needed.
- **Backoff is a lookahead, not a rescan**: `starts_attribute()` peeks
past whitespace after `(*`; first non-whitespace `)` ⇒ not an
attribute. It also subsumes the old special case `(*)` (`peek_at(2) !=
b')'`), so the branch condition got simpler, not hairier. EOF during
the lookahead (`peek_at` returns 0) keeps the old "unterminated
attribute" error.
- **BOM: option (a) — accept it — chosen over erroring.** Consistency
(`lucisv_core` already strips it from config files; editors add it
silently; the LSP will see such buffers constantly) beat strictness.
The losslessness invariant stays meaningful: the gap rule now reads
"whitespace, or the file's leading BOM" — one named exception, only
reachable in the first gap since a BOM anywhere else never lexes.
Skipped in `RawLexer::new` (3 bytes, col 4), not in `skip_whitespace`,
so mid-file BOMs stay errors rather than becoming invisible whitespace.
- **Mojibake fix**: the fallback error arm decodes the full character
(lossy, ≤4 bytes, `unwrap_or` — no `unwrap`) and names it with its
codepoint; U+FEFF gets its own message since the character itself is
invisible. ASCII errors keep their old wording.
- **Check silence**: chose "per-file error, exit 2, keep text findings"
over a synthetic violation. Reasons: it matches how check already
reports unreadable files and panics (same `Report.error` slot, same
stderr line shape, same "could not be checked" summary), it matches
`lucisv format` on the same file (frozen contract: errors are exit 2),
and a violation-shaped entry would imply a rule name and a waiver path
that make no sense for "the file did not tokenize". The linter crate's
only change is keeping the `LexError` it already caught
(`ParsedSource::lex_error()`); rendering and exit policy live in the
CLI, where the other per-file errors live.
- `--fix` on a non-lexing file keeps its old behavior (text fixes still
apply — they are span-based and safe) and now *also* reports the error;
the lex error is re-read each round from `run_rules`, so a hypothetical
fix that made the file lexable would clear it.
- **Corpus verified before and after**: no corpus file contains
`(*<ws>)` or a BOM (grepped), and the after-TSV md5
`e6f12eb7964e22e452655cf517cae766` is byte-identical to the md5 already
recorded by the round-17/18 READMEs — zero delta by path.
- **Concurrency note:** another agent is mid-edit in `vlog_semantic`
(`bind.rs`/`model.rs` currently do not compile), so the final gates are
scoped to the four crates this feature touches; `cargo test --workspace`
is re-run at the end only if their tree compiles. Nothing in this
feature's scope overlaps theirs.
- Did not touch `verify.rs`, `lucisv_server`, `vlog_semantic`. Did not run
`git commit`/`git push`.
**Results:** `cargo test -p vlog_parser -p vlog_linter -p vlog_formatter
-p lucisv`: **589 passed, 0 failed** (+11 tests: 7 lexer unit, 1
error-recovery, 1 linter context, 2 CLI; plus 3 new spans sources and 6
new `.cases` pairs inside existing tests). `cargo clippy -p vlog_parser
-p vlog_linter -p vlog_formatter -p lucisv --all-targets` silent. `cargo
fmt --check` clean on the same four crates. Corpus: 820 files, 77.6%
formattable, 0 verification errors, 0 crashes, TSV byte-identical to the
recorded baseline. Files touched: `crates/vlog_parser/src/lexer.rs`,
`crates/vlog_parser/tests/{spans,error_recovery}.rs`,
`crates/vlog_formatter/tests/cases/statements.cases`,
`crates/vlog_linter/src/context.rs`, `crates/lucisv/src/lint.rs`,
`crates/lucisv/tests/cli.rs`, `TODO.md` (§1 checkbox), two QA-log
annotations, this README.
## QA log
### 2026-08-20 — QA agent
Verified against the working tree (four-crate scope; the concurrent
class-semantics work in `vlog_semantic`/`lucisv_server` was finished and
compiling by the end of the session, so the workspace gate was run too).
All mutation experiments ran in a scratchpad copy of `crates/`; nothing
outside this QA log was written.
**Gates (reproduced, not taken on trust)**
- `cargo test -p vlog_parser -p vlog_formatter -p vlog_linter -p lucisv`:
**589 passed, 0 failed** — exactly the dev's number.
- `cargo test --workspace`: **825 passed, 0 failed** (class-semantics
landed in between; recorded for the lead, not claimed for this feature).
- `cargo clippy -p vlog_parser -p vlog_formatter -p vlog_linter -p lucisv
--all-targets` after touching the three changed sources to defeat the
cache: **0 warnings, 0 errors**. `cargo fmt --check` on the same four:
clean.
- Corpus: `tools/corpus_check.sh corpus`, run **twice**. 820 files,
636/820 (77.6%) formattable, 0 verification errors, 0 crashes, exit 0.
TSV md5 **`e6f12eb7964e22e452655cf517cae766`** both times — byte-equal
to the recorded baseline, zero delta.
- Independently re-ran the dev's corpus grep over 860 `.v/.sv/.svh/.vh`
files: **0** files with a leading BOM, **0** with a BOM anywhere, **0**
matching `\(\*[ \t\r\n]+\)`. The corpus genuinely could not have moved.
**Claim 1 — attribute backoff: PASS.**
- `@(*)`, `@(* )`, `@(* )`, `@(*\t)`, `@(*\n)`, `@(*\r\n)` all lex to the
four symbols `@ ( * )` with correct line/col on the `)`; `(*)` and
`(* )` standalone lex to `( * )`. `@(*)` — the spelling the *old*
`peek_at(2) != b')'` special case handled — goes through the new
lookahead and comes out identical, so the subsumption claim holds.
- Real attributes pinned unchanged: `(*keep*)`, `(* keep *)`,
`(* a = 1, b *)`, `(* = *)`, `(**)`, `(* *)` (degenerate), `(*\n keep
*)`, `(* x=")" *)` — all one `Attribute` token with the exact source
text. `(* keep`, `(*`, `(* ` still error "unterminated attribute", so
the EOF path (`peek_at` returning 0) is preserved.
- **Legal-expression probe (the blocking risk): no misfire.** `a*(b)`,
`a * (b)`, `assign y = a *(b);`, `assign y = a*( *b );`, `foo u1(.*);`,
`foo u1(.* );` all lex to the same token streams they did before —
confirmed the backoff can only fire on a *literally adjacent* `(*`,
which the `*`-as-multiply shapes never produce (the `*` precedes the
`(`). `a*(*b)` / `x = y*(*z);` still error "unterminated attribute" —
unchanged from before the round, and not legal SV anyway.
- The one behaviour that genuinely changed for previously-accepted text:
a source where `(*<ws>)` opened an attribute that ran to a later `*)`
(probed: `module m;\n (* )\n wire w; *)\nendmodule`) now lexes as
symbols and becomes a parse error. Judged correct — IEEE 1800 §5.12
requires at least one attr_spec and an attr_spec cannot begin with `)`,
so every such text was already invalid Verilog. No legal input loses a
parse.
- **verify.rs untouched** (`git diff crates/vlog_formatter/src/verify.rs`
empty), so invariant #4 does not fire. Re-attacked the `@`-collapse
anyway with 10 crafted (input, corrupted-output) pairs, since the
backoff widens the set of *inputs* that can produce the `@ ( * )`
sequence it whitelists. The two benign canonicalizations (`@(* )` →
`@(*)`, `@(* )` → `@*`) are accepted; all 8 corruptions are rejected —
star dropped (`@()`), sens list narrowed (`@(a)`), `@` dropped, RHS
changed under a forgiven `@(* )`, attribute→sens-list, sens-list→
attribute, attribute inner spacing rewritten, a second `@(*)` invented.
The collapse forgives nothing new.
**Claim 2 — BOM: PASS.**
- Leading BOM skipped; first token at `(1, 4)`, `span.start == 3`.
BOM-only and BOM+whitespace-only sources lex to a lone `Eof`.
BOM'd comment-only source lexes. Two BOMs: the second is a clean error
at 1:4 with the named message, and both `check` and `format` exit 2
leaving the file byte-identical (md5 compared).
- Mid-file BOM positions are exact: `module m;\u{feff}` → 1:10,
`module\u{feff}` → 1:7 — **no 3-byte skew**.
- Tolerant parse of a BOM'd broken file (`\u{feff}module m;\n wire ;;;\n
endmodule\n`): file span covers 0..len, both diagnostics slice back to
the exact offending `;`. No skew.
- Losslessness gap rule (`spans.rs:125`) judged **still meaningful**: the
exception is `c == '\u{feff}' && at == 0`, i.e. one named character in
the very first gap only. A BOM anywhere else never lexes, so it can
never reach the walk — the rule cannot be widened accidentally by this
wording. Sabotaging the skip makes
`the_token_stream_covers_every_source_byte` fail (below), so the rule
is load-bearing, not decorative.
- **The drop-normalization reasoning checks out and is written down**
(Handshakes ¶3). Confirmed live: `format_source` on a BOM'd file emits
BOM-free text, `verify_equivalence(bom_input, bomless_output)` is
`Ok`, format-twice is a fixed point, `verify_convergence` is `Ok`, and
`format_range(..., "2-2")` also converges and is idempotent. The
equivalence passes because the BOM never becomes a token, so both
sides' streams are identical — not because of any forgiveness rule.
Attacked that: with a BOM'd input, changing a token, dropping an item,
and dropping a comment in the output are each rejected; a mid-file BOM
in the *output* is rejected as "cannot re-lex the output". The only
extra latitude is symmetric — an output that *added* a leading BOM
would also verify — which is unreachable (the formatter never emits
one) but noted as F6 below.
- CLI: BOM'd file `check`s clean (exit 0, no output) and `format`s to
BOM-free bytes, stable across two runs (md5 equal); `--lines 2-2` on a
BOM'd file converges; BOM'd stdin formats and checks. Text-rule
positions on a BOM'd file are byte-consistent with the `LineIndex`
convention: tab at start of line 1 → `1:4`, trailing whitespace on line
1 → `1:16`, tab on line 2 → `2:1`. That is the documented byte-offset
convention, not a skew (see F3 for the LSP-facing consequence).
- Truncation fuzz: the new `truncating_a_bom_prefixed_file_never_panics`
passes. Note it survives the BOM sabotage (it only asserts no-panic and
span coverage), so the BOM *acceptance* is pinned by the lexer unit
tests, `spans.rs` and the CLI test rather than by this one — fine, but
worth knowing which test guards what.
- Extra 20 000-case randomized fuzz (scratchpad, deterministic seed) over
a piece-pool including BOMs, `(*`, `(* )`, `*)`, `é`, escaped
identifiers and macro calls: no panics; every token span in bounds and
on a char boundary; **every token's `(line, col)` equal to
`LineIndex::line_col(span.start)`** — the README's "`LineIndex` agrees"
assumption verified over 11 294 lexing sources, BOM'd ones included;
every one of 2 930 formattable sources idempotent and BOM-free.
**Claim 3 — non-ASCII message + check silence: PASS.**
- Full-character decode confirmed, no mojibake, no `unwrap`:
`é` → `character 'é' (U+00E9) …` at 1:15; `日` → `(U+65E5)`; `😀` →
`(U+1F600)` — the astral case proves the 4-byte window is right.
Non-ASCII inside comments, string literals and escaped identifiers
still lexes fine (not over-rejected).
- Exit-code matrix, all reproduced live:
| case | exit |
|---|---|
| lex-error file alone | 2, `error: …: lex error: 2:17: …`, "1 file could not be checked" |
| lex-error + clean file | 2, clean file still checked |
| lex-error + violation in another file | 2 (outranks 1), violation still printed, "found 1 violation, 1 file could not be checked" |
| violation only | 1 |
| clean only | 0 |
- **The combination the brief asked for, verified live**: one file with a
tab *and* a bad character (`tabbad.sv`) → `[no-tabs]` finding on
**stdout**, `error: …: lex error: 2:7: …` plus the summary on
**stderr**, **exit 2**. Streams confirmed separately with `2>/dev/null`
and `1>/dev/null`.
- `--fix` on a lex-error file with no text findings: file byte-identical
(md5 before == after), error reported, exit 2. `--fix` on the tab+bad
file: the tab fix is written back, the lex error is still reported, and
the exit is **2** — the error survives the fix rounds as the work log
claims.
- `--output-format json`: stdout is still a single valid JSON array
(parsed with `json.load`) containing only the real violations; the lex
error goes to stderr and exit 2. See F5.
- stdin: `lucisv check -` on non-lexing input → `error: <stdin>: lex error:
…`, exit 2.
- LSP spot-check (cheap, over stdio against `lucisv-server`): a BOM'd
document containing `élan` publishes the new decoded message with a
sane range on the right line, alongside the `no-tabs` warning;
`textDocument/formatting` on it returns `[]` (fail-safe, no edit), and
on a clean BOM'd document returns one whole-document edit starting at
line 0 char 0 whose text is BOM-free. Positions sane throughout.
**Claim 4 — macro space-before-paren, PARKED: verdict PASS, one argument
does not survive.** Every probe claim re-run independently:
- ✅ Argument 1: `assign x = `A (b);` parses **today** with **0
diagnostics** into `Call { callee: Ident("`A"), args: [Ident("b")] }`.
Live, not hypothetical — confirmed.
- ✅ Argument 4: formatting it fails with exactly the quoted error —
`verification failed: token stream diverges at index 6: input has
identifier "`A" at 2:14, output has identifier "`A(b)" at 2:14` — and
the file is left untouched, exit 2. Item position is a clean parse
error (`expected declaration or instantiation (found "`A")`). Fails
safe, confirmed.
- ✅ Argument 2 is the load-bearing one and stands on its own: the
correct reading depends on whether the macro was defined with formals,
which lives in another file, so no fixed lexer-side answer is right for
both populations.
- ❌ **Argument 3's premise is false — see F2.** The formatter does *not*
print a macro-with-args token "tight": it prints the captured text
verbatim. Probed: `` `A( b , c ) `` and `` `A( b ) `` both format
back **byte-identical**, and `` `A( b , c ) `` is one token whose
text keeps every internal space. Under the hypothetical glue the token
would be `` `A (b) `` (the text is taken from the backtick through the
`)`, whitespace included), the formatter would reprint it verbatim, and
the re-lex would match — so there would be no text rewrite for the
equivalence net to mask. The "normalization that hides its own damage"
framing does not apply. **The PARKED verdict is still correct** on
arguments 1, 2 and 4; argument 3 asserts rather than proves and should
be corrected or dropped so a future round does not rely on it.
**Claim 5 — gates: PASS** (numbers above; every figure in the work log's
Results paragraph reproduced exactly).
**Sabotage + revert, diff-verified** (scratchpad copy of `crates/`, the
repo tree never modified):
- Restoring the old special case (`c == b'(' && self.peek_at(1) == b'*'
&& self.peek_at(2) != b')'`) fails, as it must:
`lexer::tests::attribute_scan_backs_off_when_the_contents_are_just_a_star`,
`spans::the_token_stream_covers_every_source_byte`, and
`vlog_formatter tests/cases::case_tables` (the 6 new `.cases` pairs).
- Reverting that and instead removing the BOM skip
(`let pos = 0;`) fails `lexer::tests::a_leading_bom_is_skipped_like_whitespace`,
`lexer::tests::a_bom_only_source_lexes_to_eof`,
`spans::the_token_stream_covers_every_source_byte` and
`cli::a_bom_prefixed_file_formats_and_checks_like_a_plain_one`.
- Both pins are real. The repo tree is unchanged (`git diff --stat`
identical to the session start apart from this QA log).
**Findings** — none blocking. No corruption, no backoff misfire on a real
attribute or on legal expression code, no BOM position skew.
- **F1 (low, stale comment).** `crates/vlog_formatter/src/verify.rs:200`
still reads "`(*` followed by anything other than `)` lexes as an
attribute token". After this round that is only true modulo whitespace.
The Handshakes section acknowledges it, but the comment itself — the
justification a future reader will find when auditing the `@`-collapse
— was not updated. Not fixed here: `verify.rs` is outside this
feature's stated scope and outside my write scope. Suggested one-line
amendment for the lead: "…anything other than (optional whitespace
then) `)`…".
- **F2 (should-fix, analysis accuracy).** README §"The macro
space-before-paren item", argument 3 (lines ~127-130): "The formatter
prints a macro-with-args token tight (`` `A(b) ``)". Probed false — the
formatter reprints the token text verbatim, internal spacing included.
The verdict does not depend on it; the argument does not support the
conclusion it is offered for and should be corrected or removed.
- **F3 (should-note, contract nuance).** `--lines`/`format_range` on a
BOM'd file drops the BOM even when line 1 is not in any selected range
(probed: `--lines 2-2` on a BOM'd file rewrote line 2 *and* removed the
BOM). `lucisv --help`'s range-formatting text promises "emit every other
byte exactly as written"; the leading BOM is now an unstated exception.
Nothing corrupts (converges, verifies, idempotent), but an LSP range
format will return an edit touching offset 0. One sentence in the help
text or in Assumptions would close it.
- **F4 (info).** `lucisv check` prints `error: <path>: lex error: …`;
`lucisv format` prints `<path>: lex error: …` (no `error: ` prefix). Each
is internally consistent with how that command reports its other
per-file errors, and the exit class matches as the Assumptions claim —
recorded only so the difference is not mistaken for a bug later.
- **F5 (info).** `--output-format json` does not carry the lex error into
the JSON array; a consumer reading only stdout sees the file as having
no findings and must look at the exit code. This matches how unreadable
files already behave, so it is consistent, but it is undocumented.
- **F6 (info).** `verify_equivalence` also accepts an output that *adds*
a leading BOM (the skip is symmetric). Unreachable — the formatter
never emits one, and convergence would still hold — but it is a byte
the net will not defend, so it is recorded.
- **F7 (info, pre-existing).** `@(* /* c */ )` still fails with
"unterminated attribute": the backoff skips whitespace, not comments.
Behaviour is identical before and after this round (the old
`peek_at(2)` test also saw `/`), so it is not a regression — just the
remaining edge of the `@(*)` family.
## Review
**2026-08-19 — lead. Verdict: accepted; commits with round 20. Three
old gaps closed the way filed items should be — narrowly, with the
invariants consulted before the code.**
Points reviewed and accepted:
1. **`starts_attribute` as a lookahead, not a special case**: the
backoff subsumes the old `@(*)` peek (QA verified the routing), and
the misfire question — adjacent `(*` in legal expressions — came
back clean across every multiplication shape probed. Eight
corruption pairs re-attacked the `@`-collapse and all were
rejected; invariant 4 never fired because nothing widened.
2. **The BOM decision** (accept-as-named-exception) kept the
losslessness invariant meaningful — QA sabotaged the exception and
the suite caught it — and the drop-normalization argument is the
right kind: equivalence passes because the BOM never becomes a
token, not because anything forgives it. The 20k-case line/col
fuzz settles the position-skew question conclusively.
3. **The check-silence fix routes through the existing error slot**
rather than inventing a violation shape — the frozen exit-code
contract honored, and the tabs+bad-char combination verified live
in both output streams at once.
4. **The macro-paren park survives QA scrutiny minus one argument**:
QA probed argument 3's premise false (macro tokens reprint
verbatim, not tight), and the lead has struck it in the analysis
above — the park stands on the definition-dependence,
provably-wrong-for-one-population, and fails-safe arguments, which
QA verified independently. An analysis that loses a bad argument
and keeps its conclusion is stronger for it.
Lead fixes on acceptance: the struck argument 3; the stale
`verify.rs:200` comment updated to name the backoff; the
range-formatting README gained the BOM-drop edge note (QA's F3).
F4-F7 stand as recorded info items.