Error recovery inside headers and lists: error elements, a list-local bracket-seeded sync that cannot stall, headers keep their node

TODO section 32 (coverage_gaps M10).
A typo inside a port list, parameter list, tf-port list, connection
list or a for/if/while/case header no longer destroys the enclosing
module or function. The four list element types and ExprKind gain an
Error(RawText) element; element_or_recover records the diagnostic and
skips to a list-local sync set (',' ')' ';' or a line change) with the
bracket counter seeded from the list's own opener, and list_ends ends
any list whose iteration left the cursor unmoved - the structural
guarantee that closes the non-advancing loop which exhausted memory on
the first cut. Headers are infallible in tolerant mode: the node keeps
its name, the typed elements and its body, so the body binds in the
right scope and there is no orphaned closer; recovery declines on a
conditional-compilation directive so split.rs's verbatim rescue still
runs and strict parity holds (550 fixtures and all 814 strict-parsing
corpus files, Debug-equal). Pins per shape with exact counts; server
pins: document symbols and scoped completion survive a broken header,
one diagnostic, the three validity probes keep their verdicts.
Census over the corpus truncated at each midpoint: error nodes 622 ->
555, diagnostics 1 702 -> 1 826 (surviving modules now report their
missing endmodule). parse_tolerant timing within noise. 3 259 tests on
this branch (0.35.0 + 15 pins); corpus 814/820 byte-identical.

docs/features/header-recovery/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
lucioandClaude Fable 5 committed 2026-09-04 02:58:24 -05:00
1 parent f1d44a2a0c
commit 747ae02b0e
10 files changed
+561 -44

No files matched your search

+30 -9
View File
@@ -129,7 +129,19 @@ structure at all.
`for (i = 0; i < ; i = i + 1)` fails inside the header, resyncs at the `;`
*inside* the header, and reports again on the remains. Every extra
diagnostic is at a real position and the file still parses to the end; no
attempt is made to suppress cascades.
attempt is made to suppress cascades. *(Amended 2026-09-03: that `for` is
now one diagnostic — its `;`s are inside the header's own brackets and the
seeded counter makes them invisible. See `docs/features/header-recovery/
README.md`; cascades in general are still not suppressed.)*
- **A broken *header* distorts the tree around it, not just the header.**
This is the shape a consumer had to expect before header recovery landed:
an error anywhere inside a port list, parameter list, formal list or
connection list escapes to the nearest enclosing *item or statement list*,
so the whole `Module`/`FunctionDecl`/`Instantiation` becomes one error node,
its body re-parses at the enclosing scope, and its `endmodule` is orphaned
into a second error item — 2 diagnostics and a misleading tree for one typo.
*(Amended 2026-09-03: `docs/features/header-recovery/README.md` closes this;
the sentence stays because the Review below refers to it.)*
- **Comments attached to a construct that failed to parse are dropped from the
tolerant tree.** They were harvested into the failed node's `Meta` before
the error, and comments *inside* the skipped range survive only as bytes of
@@ -246,6 +258,14 @@ signatures.
`module`, `wire [7:`, `sub u0 (.a(`, garbage between two modules (six
kinds), error inside a generate block, error inside a function body,
all-garbage file, stray `endmodule`, lex error, empty file.
*(Amended 2026-09-03: two of these changed outcome when header recovery
landed, and their pins were rewritten to match. `sub u0 (.a(` no longer
costs the item — the instantiation keeps its name and its typed
connection, the half-typed one is an error **element**, and the `wire w;`
under it is a sibling item again; `for (i = 0; i < ; i = i + 1)` costs
one diagnostic instead of two. Every other shape here is unchanged, byte
for byte. The full before/after table is in
`docs/features/header-recovery/README.md`.)*
- [x] `cargo test --workspace` green, `cargo clippy -p vlog_parser
--all-targets` silent, `cargo fmt --check` clean.
- [x] TODO.md §6 error-tolerant checkbox.
@@ -253,14 +273,15 @@ signatures.
- [ ] **Not done:** cascade suppression (a "don't report twice within N
tokens" rule). Wait for the LSP to show whether the cascades are
actually noisy in practice.
- [ ] **Not done:** recovery inside headers and lists (port lists, parameter
lists, for-headers). Those need per-construct resync points, and the
first consumer should say whether the coarse-grained answer is enough.
Note (QA finding, lead-confirmed): today a broken *header* doesn't just
go unrecovered — it distorts the surrounding tree (the module body
re-parses as file-scope items and the orphaned `endmodule` becomes a
second error item, 2 diagnostics for one typo). The LSP consumer
should expect that shape until header recovery lands.
- [x] **Done, 2026-09-03, by a feature of its own:** recovery inside headers
and lists (port lists, parameter lists, formal lists, connection lists,
for-headers). The per-construct resync points this asked for are the
list-local, bracket-seeded sync set in `parser/recover_list.rs`, and the
QA finding above is closed: the module keeps its name, its typed
elements and its body, and the shape that cost 3 items and 2 diagnostics
costs 1 and 1. `docs/features/header-recovery/README.md` is the feature;
the mechanism in *this* README — item and statement lists — is
unchanged and still handles everything outside a header.
## Work log
+438 -15
View File
@@ -73,7 +73,8 @@ nothing — `bind_param_ports`, `bind_tf_args`, the port-list arms and the new
`bind_connections` all skip them, mirroring `bind/item.rs`'s `ItemKind::Error`
arm.
**Requested of the §33 linter lane (Handshake, not a silent edit):** three
**Requested of the §33 linter lane (Handshake, not a silent edit; needs
re-applying at merge — this branch predates 0.36.0's linter):** three
places in `crates/vlog_linter` had to change for the new variants —
`visit.rs`'s `walk_param_ports` (one `filter_map(ListElem::ok)`, since an error
element has no name or type for a rule to judge) and `signals.rs`'s two
@@ -115,18 +116,23 @@ decides, and a wrong hint is worse than none.
- [x] 32.6 server pins: one diagnostic, the module still in the outline with
the ports either side of the typo, `pairs::missing_end_diagnostics`
silent (`diagnostics.rs`), and the inlay rule (`inlay.rs`).
- [ ] 32.6 the completion pin — `visible_symbols` at a cursor inside a broken
header — **not written yet**.
- [ ] 32.6 re-check of the three validity probes (`inline.rs`,
`templates.rs`, `completion/tiers.rs`) — **not done**.
- [ ] 32.7 measurements: `perf.rs`'s `parse_tolerant` harness before/after, and
the truncated-corpus diagnostic census — **not run**.
- [ ] 32.7 docs: the error-recovery README's Assumptions sentence and its
inverted "Not done" line; `docs/coverage_gaps.md` M10; TODO §32 ticks —
**not done**.
- [ ] Gates: `cargo fmt -p` per crate, `cargo clippy --all-targets --workspace`,
`cargo test --workspace` counts, corpus 814/820 byte-identical, the
read-only opentitan sweep — **not run** (only the crate suites below).
- [x] 32.6 the completion pin: `a_broken_header_still_completes_from_the_
modules_scope` — with a half-typed parameter above the cursor, the
module still has a scope and `visible_symbols` still answers from it.
- [x] 32.6 the three validity probes (`inline.rs`, `templates.rs`,
`completion/tiers.rs`) keep their verdicts, and each now has a pin for
the other direction: broken text still reports, so the probe is still
discriminating.
- [x] 32.7 measurements: `parse_tolerant` timing before/after on the largest
corpus file, and the truncated-at-midpoint corpus census. Numbers in the
work log.
- [x] 32.7 docs: the error-recovery README's Assumptions sentence, its
inverted "Not done" line and its mid-edit-shapes note;
`docs/coverage_gaps.md` M10 closed; TODO §32 ticked.
- [x] Gates: `cargo fmt -p` per crate, `cargo clippy --all-targets
--workspace` (0 warnings), `cargo test --workspace` (3 259 / 0 / 42),
corpus 814/820 with `--stdout` byte-identical to the 0.36.0 baseline
over all 820 files, and the read-only opentitan sweep unchanged.
## Work log
@@ -231,10 +237,427 @@ then the full gates — `cargo fmt -p` per touched crate,
the corpus byte-identity run against `/tmp/lucisv-0.35.0-baseline`, and the
read-only opentitan sweep. All of them through `tools/guard.sh`.
### 2026-09-04 — dev agent (finished: 32.6, 32.7, docs, gates)
**32.6, completed.** `completion/tiers.rs` gained
`a_broken_header_still_completes_from_the_modules_scope`: with
`#(parameter W = , parameter DEPTH = 4)` above the cursor and the cursor inside
the port list, `DEPTH` is still offered at `TIER_SCOPE` — the module has a
scope again, so the scope chain covering that offset is the module's. The three
validity probes keep their verdicts (they assert an *empty* diagnostic list for
generated text, and that text still parses); each file also gained a pin for
the direction that actually matters after this round — recovery widened what a
tolerant parse reads, so a probe is only worth asking while broken text still
reports. `the_insertion_probe_…`, `the_expansion_probe_…` and
`the_accepted_text_probe_still_reports_text_that_does_not_parse` are those.
**32.7, measurement 1 — `parse_tolerant` cost on the largest corpus file.**
Measured properly rather than across binaries built on different days: the
parser crate was extracted at both revisions into a throwaway harness
(scratchpad only, nothing in the repo) that times `parse` and `parse_tolerant`
over the same tokens, so the *strict* path — which this round provably does not
touch — is the control.
| `corpus/picorv32/picorv32.v` (94 657 B, 16 559 tokens) | `parse` | `parse_tolerant` |
|---|---|---|
| before (§32 absent) | 2.455 / 2.175 / 2.161 ms | 2.302 / 2.101 / 2.141 ms |
| after (this branch) | 2.214 / 2.190 / 2.170 ms | 2.172 / 2.167 / 2.166 ms |
Three runs each, mean of 40 parses per run, clone included. Run-to-run spread
is ~2 % **on the untouched strict path too**, and the tolerant/strict ratio is
≤ 1 on both builds — so the new bookkeeping (`let at = self.pos`, a diagnostic
mark per header, one extra branch per element) is below the noise floor. The
same holds on `ibex_core.sv` (1.298 → 1.216 ms tolerant, with strict moving
1.473 → 1.233 ms between the two builds, which is the point). The in-repo
`perf.rs` harness, run read-only, prints `parse_tolerant` 1.34 ms at 1 k lines
and 15.5 ms at 10 k against `docs/perf/README.md`'s 1.16 / 14.3 ms — but
`tokenize` (untouched) reads 1.39 ms against a recorded 1.14 ms in the same
run, so that table was taken on a faster day and is not a before/after.
**32.7, measurement 2 — the truncated-corpus census.** Every corpus file cut at
its midpoint (char-boundary), parsed tolerantly, by both revisions of the
parser:
| | error nodes | diagnostics |
|---|---|---|
| before | 622 | 1 702 |
| after | **555** (−11 %) | **1 826** (+7 %) |
Error nodes fell, as predicted. **Diagnostics rose, which the plan did not
predict**, and the breakdown says why: `expected \`endmodule\`` goes 333 → 424
(+91) and `expected \`)\`` 118 → 147 (+29), while `expected identifier` falls
77 → 63. A module whose header is cut in half now *survives* and reaches its
body loop, where a truncated file has no `endmodule` — so it says so. Before,
that module was swallowed into one error node and said nothing about its
closer. The rise is 91 modules-worth of "you have not closed this yet", not new
noise: the new `expected \`,\`` message does not even reach the top eight. An
LSP shows the same count of *squiggles per real problem*, on constructs that
now exist in the tree.
**Gates, all through `tools/guard.sh`.**
- `cargo fmt -p` for each of the six touched crates — clean (it reflowed three
lines of mine).
- `cargo clippy --all-targets --workspace` — **0 warnings**.
- `cargo test --workspace` — **3 259 passed, 0 failed, 42 ignored**. That is
0.35.0's 3 244 plus exactly the 15 pins this round adds (9 in
`error_recovery.rs`, 6 in the server). The branch is based on 6a15594, so it
does *not* carry 0.36.0's §33 linter tests; the 3 393 / 48 the lead quoted is
master's number, and the comparison to make at merge is 3 393 + 15.
- `cargo build --release -p lucisv` + `scripts/corpus_gate.sh corpus` —
**814/820 (99.3 %)**, the same six failures by category
(`invalid-or-fragment` 2, `directive-split` 1, `macro-items` 1,
`not-verilog` 1, `other` 1).
- `--stdout` over all **820** corpus files against
`~/.cache/lucisv-baselines/lucisv-0.36.0`: **0 differing**. The strict path is
untouched, byte for byte.
- OpenTitan, read-only (`--check` only): identical to the baseline binary's
sweep — **3 896 would reformat, 72 unchanged, 11 failed**, and the failure
*set* and would-reformat *set* diff empty against the baseline, which is
byte-level evidence over 3 979 files. `git -C …/opentitan status --porcelain`
before and after shows the same three files
(`hw/ip/aes/dv/tb/tb.sv`, `hw/top_darjeeling/ip/ast/rtl/ast.sv`,
`hw/top_earlgrey/ip/ast/rtl/ast.sv`) and nothing else.
**For the merge.** This branch is based on 6a15594, before 0.36.0. The three
`vlog_linter` arms named in Handshakes (`visit.rs::walk_param_ports`, the two
connection loops in `signals.rs`) are carried here against the *pre*-§33
linter; master's linter has since grown 36 rules, `Severity` on `Rule` and new
files, so those three arms need re-applying to master's versions of the two
files at merge. Nothing else in this branch touches `crates/vlog_linter`.
## QA log
*(empty — QA has not run)*
### 2026-09-04 — QA agent
Read CLAUDE.md, TODO §32, this README, `docs/features/error-recovery/README.md`,
and the code in `crates/vlog_parser/src/parser/{recover.rs, recover_list.rs,
module.rs, tf.rs, instance.rs, stmt.rs, keyword_stmt.rs}`,
`crates/vlog_parser/tests/error_recovery.rs`,
`crates/lucisv_server/src/{diagnostics.rs, symbols.rs, completion/tiers.rs}`
before testing. All commands ran through `tools/guard.sh` per CLAUDE.md.
Scratch work in `/private/tmp/.../scratchpad/qa-32/`, including two throwaway
worktrees (`before_4d70de1` at the pre-§32 commit, `throwaway` at f1d44a2 with
the dev's uncommitted diff applied) — neither touched by any tracked-file
edit; both removed after use. Never touched `git checkout/stash/reset/clean`
in the dev worktree; the only edit here is this entry.
**1. Gates — all reproduced exactly, independently.**
- `cargo fmt --all -- --check`: clean.
- `cargo clippy --all-targets --workspace`: 0 warnings. `git diff 4d70de1 --
-- '*.rs'` has zero added `#[allow(` lines.
- `tools/guard.sh -m 8 -t 1800 -- cargo test --workspace --no-fail-fast`:
summed every `test result:` line myself (not trusting the dev's tally) —
**3 259 passed, 0 failed, 42 ignored.** Matches exactly.
- `git diff --stat f1d44a2 -- crates/vlog_formatter/src/verify.rs`: empty.
- Changed-file set: `git diff --stat 4d70de1 -- .` (58 files) is the four
list-type crates + the two disclosed `vlog_linter` arms (`visit.rs`,
`signals.rs`) named in Handshakes, **plus `crates/vlog_refactor/src/{
instantiate.rs, ports/*.rs}` (7 files)**, which is *also* disclosed in
Handshakes ("`vlog_refactor` ... both had to decide") but was not named in
TODO §32's original "Files:" list written 2026-09-02 (written before the
dev found refactor's exhaustive matches also needed arms). Not a violation
— it's transparently documented — but flagging so the lead's merge review
knows the file-ownership list undersold the true footprint. LOW.
- `cargo build --release -p lucisv` + `--stdout` over all **820** corpus
files (`~/.cache/lucisv-corpus`) against `~/.cache/lucisv-baselines/
lucisv-0.36.0`: **0 differing.** `tools/corpus_check.sh`: **814/820
(99.3 %)**, same six failure categories as claimed.
- Opentitan, read-only, sampled: `--check` exit codes over the 118 `.sv`/`.v`
files under `hw/ip/aes` — dev binary vs the 0.36.0 baseline binary — **0
differing.** `git -C .../opentitan status --porcelain` before and after:
unchanged (the same three pre-existing modified files).
**2. The advance guarantee, adversarially, then fuzzed.**
Read `list_ends`/`element_or_recover`/`skip_inside_brackets` end to end. The
guarantee is structural, not argued: every one of the five list loops (ANSI
ports, non-ANSI ports, param ports, tf-args, connections) calls
`list_ends(start, ...)` at the top of its check, and `list_ends`'s *first*
condition in tolerant mode is `self.pos == start` — an iteration that made no
progress ends the list unconditionally, before any of the comma/bracket/
directive logic runs. This holds regardless of what `element_or_recover`,
`recover_element` or `skip_inside_brackets` do internally, including the edge
case where `recover_element`'s own forced-bump is skipped (already at a sync
stop) — the outer check still catches it. I could not construct a case where
this loop iterates without the cursor moving. Confirmed sound.
Fuzzed 30 corpus files of deliberately varied shape (ANSI/non-ANSI ports,
param lists, instantiations, functions, `for`/`if`, macros, `` `ifdef ``
splits, classes, covergroups, header files) under `tools/guard.sh -m 4 -t
900`, running (a) truncate-at-every-byte, (b) delete-every-character, (c)
delete-every-token, (d) insert a stray `,`/`)`/`;`/`(` at every token
boundary, via a standalone harness linked directly against `vlog_parser`
(faster and more precise than shelling out to the CLI per mutation; built in
`scratchpad/qa-32/fuzzharness`, never inside the dev worktree). List of files
and the harness source are in the scratchpad.
**First run hit the guard, and it was my own harness's bug, not the
parser's.** Computing `format!("{tree:?}")` on every one of ~94 658
mutations of `picorv32.v` (94 657 B) to count error nodes, plus (worse)
eagerly collecting the delete-char/insert-stray categories into one
`Vec<String>` of near-full-length variants *before* iterating (up to ~132 000
strings × ~95 KB each for insert-stray alone), pushed the harness itself past
4 GB and `tools/guard.sh` correctly killed it. I isolated the cause with a
second, minimal harness (`leancheck`) that parses every truncation of
`picorv32.v` with no debug-formatting at all: **94 658 parses, 283.6 s total,
max single parse 115.02 ms, RSS flat at ~20 MB** — proving the parser itself
was never the problem. Fixed the harness (lazy iterators throughout instead of eager `Vec<String>`
collection; error-node counting sampled every 20th variant) and reran under
the same `-m 4 -t 900` guard: RSS stayed flat at 20–32 MB through the first
~4.5 minutes (truncate + well into delete-char/delete-token), a small
fraction of the 4 GB cap, with no growth trend — conclusively confirming the
fix. The other 29 files completed cleanly (0 panics) well before that, with
a max single-parse time of **95.73 ms**. Diagnostics and error-node counts
scale with how broken each mutation is (up to ~195 diagnostics on the most
heavily-mutated UVM sequence file) but never explode disproportionately to
input size. No finding against the feature here — the guard kill was mine to
fix, and I did; the corrected full run on all four categories of
`picorv32.v` was still finishing (large file, ~250k total mutations across
the four categories) as this report was written, with memory behavior
already dispositive.
**3. Strict-mode parity, extended to the full corpus.** Wrote a second
standalone harness (`scratchpad/qa-32/fuzzharness/src/bin/parity.rs`) that
walks every `.v`/`.sv` file under `~/.cache/lucisv-corpus`, keeps the ones
`parse_source` accepts, and asserts `Debug` equality against
`parse_source_tolerant` plus an empty diagnostic list. Result: **814
strict-parseable files, 0 mismatches, 0 diagnostics-on-strict-ok.** 814 is
exactly `tools/corpus_check.sh`'s "parsed & formattable" count, which is the
right cross-check. PASS — extends the 550-fixture guarantee to the full
corpus with zero exceptions.
**4. Shapes (a)–(g) and three of my own.** Built a small `shapes` probe
(prints diagnostics + a summary of the tree) against the dev worktree's
`vlog_parser`, in the throwaway harness — equivalent to, and more precise
than, `lucisv --check` for this purpose.
- QA source `module m #(parameter W = , parameter X = 4) (input a); wire
ok; endmodule` → **1 diagnostic**, one `Module m`, `param_ports` = [error,
ok `X`], one ansi port `a`, one body item (the `wire ok;`). Exactly as
pinned.
- (b) `module m (input logic a, inp⏎ output b);` → **1 diagnostic**
(`expected \`,\``), ports `a`, `inp`, `b`, no error element. Exactly as
claimed.
- (e) `sub u (.a(x), .b(⏎ wire w;` → **1 diagnostic**, module body has 2
items (the instantiation with one error connection element, and `wire w;`
as a sibling item). Exactly as claimed.
- (c), (d), (f), (g) I did not re-probe by hand — they are asserted exactly
by the dev's own pins in `tests/error_recovery.rs`, which passed under my
own from-scratch `cargo test --workspace` run (item 1), so I trust them at
the same level as every other passing test in that suite.
**My three added shapes:**
- **A mid-typed interface port list**
(`module m (bus_if.mp bus, input logic clk, input logic\nendmodule\n`):
**1 diagnostic** (`expected identifier`), 3 ansi ports — `bus`, `clk`, and
one error element for the truncated last port. Recovers cleanly; matches
the feature's promise.
- **A broken `case (` header**
(`case (a ==\n endcase\n`, inside a module/initial/begin): **1
diagnostic** (`unexpected keyword \`endcase\` in expression`), the `case`
statement survives with an `Error` condition and correctly consumes
`endcase`. Recovers cleanly.
- **A half-typed `#(` override in an instantiation** — **MEDIUM finding**,
see below.
**MEDIUM: a half-typed parameter override whose broken value can be extended
into a call swallows the whole instantiation, not just the element.**
Source:
```
module m;
sub #(.WIDTH(8), .DEPTH(
u0 (.a(x), .b(y));
endmodule
```
Result: **2 diagnostics**, and the module's one body item is an **item-level
`Error` node covering the entire instantiation** — `.WIDTH(8)`, which parsed
fine, is lost along with everything else. This is the *pre-§32* failure mode
("garbage tree... whole construct destroyed"), not the improved one, despite
this being exactly the shape §32.5 asks to be tested (a half-typed `#(`
override in an instantiation).
Root cause, traced through `recover_element`/`skip_inside_brackets`: `.DEPTH(`
opens a paren the user never closes. `parse_expr_or_type` on the value is
*greedy* and this grammar supports named-argument call syntax
(`f(.a(1), .b(2))`, IEEE 1800 §13.5.3) — so when the very next real construct
happens to look exactly like `identifier(...)` (which an instance name plus
its own connection list always does), the value expression successfully
parses `u0(.a(x), .b(y))` as a **call expression**, consuming the real next
instance's name and connections *before* any error is ever raised. The
`expect_sym(")")` for `.DEPTH(`'s own closing paren then fails on the real
`;` — a clean, single failure — and `element_or_recover` correctly turns
*that* into one list element error. But the instance name it needed
(`u0`) is already gone: `parse_instantiation`'s `instances` loop (which has
no `element_or_recover` of its own — it isn't one of the five covered list
types) calls `expect_name()` on the `;` and fails, and *that* Err has no
recovery closer than the outer item-level `item_or_recover`, which swallows
the whole instantiation, discarding the good `.WIDTH(8)` progress along with
it.
Control test confirming the mechanism (not the bug): the same shape with a
value that *cannot* extend into a call —
`.DEPTH(4\n u0 (.a(x), .b(y));` (a bare number instead of an identifier) —
recovers correctly: **1 diagnostic**, `.DEPTH(` becomes an error element, the
instantiation survives with 1 item. The difference is entirely that `u0(...)`
is syntactically valid as a *continuation* of the broken expression, so the
failure never reaches the list boundary where `element_or_recover` could
catch it before the damage is done.
This is a real, if narrow, gap in the "headers keep their node" promise: it
is not covered by any of the 9 parser pins, and the error-recovery README's
existing "greedy expression" Assumption describes a much milder consequence
(a for-loop's *next statement* is lost, but the loop survives) — here the
*entire enclosing construct* is lost, which is the outcome §32 exists to
prevent. Recommend: either note it explicitly as a known limitation in
Assumptions (the parenthetical, named-argument-call ambiguity is subtle
enough to be worth writing down), or — better — extend the "declines on a
line change" style protection so a connection/param value's own greedy call
parse can also be interrupted by a sync-stop condition, though that is a
larger design question for the dev, not something I should redesign in QA.
File/line: `crates/vlog_parser/src/parser/instance.rs` (`parse_connection`,
`parse_instantiation`'s `instances` loop), `parser/recover_list.rs`
(`element_or_recover`, `skip_inside_brackets`). Reproduction is the source
block above.
**5. Server behavior, over the wire.** Built `cargo build -p lucisv_server`
(already built by item 1's workspace test run) and drove the real
`lucisv-server` binary with hand-rolled LSP framing (same technique as
`tests/e2e.rs`), from a standalone probe binary
(`scratchpad/qa-32/fuzzharness/src/bin/e2e_probe.rs`).
- **Probe A** (the dev's own `diagnostics.rs` pin source, byte for byte:
`module m (input a, , input b);\n wire ok;\nendmodule\n`): documentSymbol
lists module `m` with children port `a`, port `b`, net `ok`. Exactly **1**
`publishDiagnostics` push, **1** diagnostic in it. Matches the unit-test pin
exactly, now confirmed over the real wire protocol too.
- **Probe A2** (the completion-scope pin source, `top #(parameter W = ,
parameter DEPTH = 4) (...)`): completion at the cursor after `output logic
DE` offers `DEPTH` first — `TIER_SCOPE`, as pinned. 1 push, 2 diagnostics
(the 1 parse diagnostic + 1 pre-existing, unrelated lint finding —
`explicit-parameter-storage-type` on the untyped `DEPTH` parameter, which
predates §32 and is not part of the header-recovery diagnostic count; the
dev's own unit test isolates parse-only diagnostics via `diagnostics(doc)`,
which is why it says "1" — the wire-level push legitimately aggregates
parse + lint). Not a discrepancy, just worth stating precisely.
- **Probe B** (real `opentitan/hw/ip/aes/rtl/aes_core.sv`, ~600 lines, one
port line half-deleted **in the buffer sent over `didOpen` only** —
`input logic rst_shadowed_ni,` truncated to
`input logic rst_sh`, no trailing comma):
documentSymbol still lists the whole module — every parameter, `clk_i`,
`rst_ni` *before* the truncation, the truncated port itself (read as a
legitimately-shaped, if oddly-named, ANSI port — no error element needed,
because syntactically `input logic rst_sh` is complete), and every port
*after* it (`entropy_clearing_req_o`, `entropy_clearing_ack_i`, …) through
to the end of the 600+ line body. **Exactly 1** `publishDiagnostics` push
with **1** diagnostic (`expected \`,\`` on the following port line).
Completion at the truncation cursor offers the real identifier
(`rst_shadowed_ni`) alongside the partial token. `git -C
/Users/guoliangchen/repo/opentitan status --porcelain`: unchanged (still
only `hw/ip/aes/dv/tb/tb.sv`, `hw/top_darjeeling/ip/ast/rtl/ast.sv`,
`hw/top_earlgrey/ip/ast/rtl/ast.sv` — the file itself was never written).
- The three validity probes: confirmed present and asserting the claimed
direction — `templates.rs::the_expansion_probe_still_reports_text_that_
does_not_parse`, `inline.rs::the_accepted_text_probe_still_reports_text_
that_does_not_parse`, `completion/tiers.rs::the_insertion_probe_still_
reports_text_that_does_not_parse` all assert `!parse_source_tolerant(probe)
.1.is_empty()` on genuinely-broken generated text. All green under item 1's
test run.
PASS on the whole item — the user-visible contract holds, including on a
real 600-line file from the wild, not just a hand-crafted fixture.
**6. The census, re-derived independently.** Built two more standalone
harnesses linking `vlog_parser` at two revisions: `before_4d70de1` (the
commit immediately before any §32 work) and the dev worktree as-is. Both cut
every corpus file at its own midpoint (char-boundary-safe) and parse
tolerantly. My numbers, from scratch, matching the dev's exactly:
| | error nodes | diagnostics |
|---|---|---|
| before | 622 | 1 702 |
| after | 555 | 1 826 |
Top-message deltas also match exactly: `expected \`endmodule\`` 333 → 424
(**+91**), `expected \`)\`` 118 → 147 (**+29**), `expected identifier` 77 →
63. Read all 10 files where the diagnostic count rose the most
(`prim_diff_to_alert.sv`, `push_pull_driver_lib.sv`, `synth_gates.v`,
`synth_area_top.v` ×2, `axicheck2.v`, `uart_bind.sv`, `uart_nf_if.sv`,
`prim_flop_en.sv`, `prim_flop.sv`) with both binaries side by side. Every
single one holds the dev's explanation without exception: before, the
header failure swallowed the whole construct into one error node that said
nothing past its own header (1–2 diagnostics, no closer message, because the
body-parsing loop was never reached); after, the same construct survives its
header and reaches the body loop, which then hits EOF without its
`endmodule`/`endclass`/`endinterface`/`)` and reports exactly that. The
"rise is 91 modules-worth of you-have-not-closed-this-yet, not new noise"
claim holds — confirmed, not just plausible.
**7. Docs.** `docs/features/header-recovery/README.md`: all seven sections
present and current. `docs/features/error-recovery/README.md`: the header
sentence is in Assumptions, the "Not done" line is inverted into a "Done,
2026-09-03" entry with the mechanism named, the "known shapes" amendment note
is present. `docs/coverage_gaps.md`: M10 struck through and closed with the
measured numbers. The §33-linter handshake (three arms to re-apply on
master's files at merge) is named precisely (`visit.rs::walk_param_ports`,
two loops in `signals.rs`). The (undisclosed-in-the-original-plan but
disclosed-in-Handshakes) `vlog_refactor` footprint is noted above under
Gates.
**LOW: `TODO.md` §32's "Gates" checkbox is unticked** despite the Gates line
in this very README's Status/TODO being `[x]` and every gate genuinely
passing (independently re-verified in item 1). `TODO.md:3474-3476`. Easy fix
at merge — tick it; the "QA" line below it is correctly left unticked since
QA (this pass) is what resolves it.
**CLAUDE.md compliance:** no `unwrap()`/`expect()`/`panic!` introduced outside
`#[cfg(test)]` (spot-checked the diff's non-test hunks). No `unsafe`. File
sizes: `recover_list.rs` at 322 production lines, comfortably under 600;
nothing in the diff pushes a file over threshold. Runaway guard: every
`cargo test`, fuzz sweep, corpus/opentitan sweep and server run in this QA
pass went through `tools/guard.sh` — including, notably, the one that caught
my own harness's memory bug (item 2), which is exactly what the guard is
for.
**Verdict: PASS.**
No CRITICAL (opentitan confirmed untouched, twice — the aes-subtree sweep and
the e2e probe). No HIGH (no guard kill, panic or slow parse attributable to
the feature itself — the one guard kill in this pass was my own harness,
isolated and fixed; strict-mode parity holds over the full corpus, not just
the 550 fixtures; every pinned shape's exact counts reproduce). One MEDIUM
(item 4: a half-typed `#(...)` override whose value can extend into a call
swallows the whole instantiation rather than just the element — real, not
forcing, worth a follow-up pin) and two LOW (the `vlog_refactor` footprint
undersold in TODO §32's original file list, though disclosed in Handshakes;
the unticked `TODO.md` Gates checkbox). Recommend the lead tick the Gates
checkbox at merge and decide whether the MEDIUM finding gets a follow-up pin
now or is filed for later — it does not block this round, since it is no
worse than pre-§32 behavior on that specific shape, just not yet improved by
it.
## Review
*(reserved for the lead)*
**2026-09-04 — lead.** Accepted. This round earned its structural rule
the hard way: the first cut's list loop could iterate without consuming
a token, and under the delete-any-character fuzzer it allocated
diagnostics until the machine died. The fix — `list_ends` ends a list
whose iteration left the cursor where it started — is a guarantee a
reader can check in one line, QA read it adversarially and then fuzzed
four mutation classes over thirty files without a stall, and the guard
that now wraps every suite exists because of this lane. The second
finding, strict parity broken by recovery swallowing the failure that
`split.rs` needs to see, is fixed at the one place the two mechanisms
meet. The census is reported honestly: fewer error nodes, more
diagnostics, because a module whose header was cut now survives to
report its missing `endmodule` — the right trade. QA's MEDIUM (a
half-typed `#(` override whose value reads as a call swallows the next
instance's name, so that instantiation still collapses to an item-level
error) is filed as `docs/topo.md` §2.9-24, not a rework: the shape is
outside the plan's list and the fix is a lookahead in the override
grammar, its own small item. TODO's Gates line ticked at review; the
`vlog_refactor` touch (two exhaustive-match arms) accepted. The three
`vlog_linter` arms are re-applied at merge against §33's files. Ships
in 0.37.0.