TODO §45 (docs/features/small-items-4). Closes topo §2.9-17, 29, 30 and
adds the delay-list bar to §2.9-22.
45.1 `settings::rules` records every dropped `lucisv.lint.select`/`ignore`
name as `lucisv.lint.<setting>: unknown rule: <name>`; `apply_settings`
logs what the previous settings value did not already say — once per
(setting, name), re-armed by a changed list.
45.2 `walk::collect_files` takes a `&mut dyn FnMut(Warning)` sink: an
unreadable directory, an unreadable `.gitignore` and a dangling source
link are warned about and the walk continues; the CLI prints
`warning: <path>: <message>` on stderr before the report with the exit
code unchanged, the server logs once per scan through `report_scope`.
45.3 `parse_expr_or_type` accepts a `struct`/`union`/`enum` head as a
type argument, so `m #(.T(struct packed { logic a; })) u ();` parses and
`instantiation_plan` emits a one-line `parameter type` aggregate default.
45.4 Comment slots for `#(1:2:3)` and gate delay lists
(`MinTypMaxComments`, `DelayValue`, `ContAssign`/`GateInstantiation`/
`GateInstance` slots); `EXPECTED_RTL_GAPS` 374 → 419 at zero failures.
Review rework (QA's MEDIUM): a line comment after a gate instance's `,`
now ends the line, the next instance one level in.
Byte-identity vs 0.43.0: 0 of 820 corpus files and 0 opentitan outcomes
differ.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
566 lines
33 KiB
Markdown
566 lines
33 KiB
Markdown
# small items, round 4
|
|
|
|
## Goal
|
|
|
|
Four items that belong to no larger feature, shipped together (TODO §45,
|
|
release 0.44.0). Each closes an open handshake in `docs/topo.md` §2.9.
|
|
|
|
**45.1 — the editor's unknown rule name is said once (topo 29).** A name in
|
|
`lucisv.lint.select` / `lucisv.lint.ignore` that the registry does not know was
|
|
dropped in silence (`settings::rules` filtered it away), while the same typo in
|
|
a `lucisv.toml`'s `[lint] select` has been logged since §42 and
|
|
`lucisv.lint.options` has described its own bad entries since §34. The name is
|
|
still dropped — a typo on a socket must not cost a session its diagnostics —
|
|
and is now logged through `server/notification.rs` as
|
|
`lucisv.lint.select: unknown rule: <name>`, **once** per (setting, name),
|
|
re-armed only when the list changes. A `select` emptied by the dropping falls
|
|
through §42's ladder exactly as before.
|
|
|
|
**45.2 — a warning channel for the walk (topo 30).** `Walk::dir` propagated
|
|
`read_dir`'s error with `?`, so one permission-denied directory anywhere under
|
|
the start dropped every file already found and failed the run — walk-cycles'
|
|
QA found it on a link to `/`. `lucisv_core::walk::collect_files` now takes a
|
|
`&mut dyn FnMut(Warning)` sink: an unreadable directory, an unreadable
|
|
`.gitignore` and a source file that is only a broken link are each said once
|
|
and skipped, and the walk goes on. The CLI writes `warning: <path>: <message>`
|
|
to stderr before the report and changes no exit code; the server folds them
|
|
into the scope's own warnings, which are logged once per scan. The dangling
|
|
source link is **no longer handed on** — that reverses §43's review ruling on
|
|
purpose, because the warning is now the error's home.
|
|
|
|
**45.3 — an inline aggregate as a parameter-override argument (topo 17).**
|
|
`m #(.T(struct packed { logic a; })) u ();` was rejected: `parse_expr_or_type`
|
|
routed a value to `parse_type_expr` only for a head in `TYPE_KEYWORDS`, and
|
|
`struct`/`union`/`enum` are not in that table, so the value read as an
|
|
expression and hit "unexpected keyword `struct` in expression".
|
|
`parse_type_ref` had read that body since the first day and the type printer
|
|
had printed it; only the door was shut. With it open,
|
|
`vlog_refactor::instantiation_plan` stops dropping a one-line `parameter type`
|
|
default that is an anonymous aggregate — its probe simply passes now — and
|
|
emits the type text.
|
|
|
|
**45.4 — comment slots inside a delay list (topo 22's leftovers).**
|
|
`parse_delay_values` serves `#(1:2:3)` on nets and continuous assignments and
|
|
`#(rise, fall[, turn-off])` on gates. The gaps around the `(`, the two `:` and
|
|
the `,` had no owner, so a comment written in one moved and `verify.rs` refused
|
|
the file. They have owners now — `MinTypMaxComments`, `DelayValue`, the gate's
|
|
`before_hash`/`after_hash`/`before_semi`, the gate instance's `before_args`,
|
|
and the continuous assignment's `after_hash`/`after_delay` — and the RTL gap
|
|
fuzzer's fixture set covers the construct at zero failures.
|
|
|
|
## Assumptions
|
|
|
|
- **45.1** — the memo is the *previous settings value's own warning list*, so
|
|
"once per (setting, name)" and "re-armed when the setting changes" are one
|
|
mechanism rather than two. A list edited from `[a]` to `[a, b]` says only
|
|
`b`; cleared and re-typed, it says everything again. Both lists hold a
|
|
handful of entries at most, so a linear scan beats a set.
|
|
- **45.1** — the options warnings keep their old behaviour (raised every time
|
|
the setting arrives). They are a different field for that reason; merging the
|
|
two vectors would have quietly changed §34's contract.
|
|
- **45.2** — a dangling link that does **not** name a source file stays silent.
|
|
It was never going to be read, and warning about every broken link in a tree
|
|
is noise, not information. The `walk.rs` test pins both halves.
|
|
- **45.2** — a path the user names on the command line is not walked, so
|
|
naming a dangling link directly is still `no such file or directory`, exit 2.
|
|
The channel is about what the *walk* finds.
|
|
- **45.2** — an unreadable `.gitignore` used to abort the run too; it is now a
|
|
warning on the same channel. That is one step beyond the plan's wording and
|
|
is the same judgement: a walk that finds too much is a better failure than a
|
|
walk that finds nothing.
|
|
- **45.2** — `Warning`'s `message` is the operating system's own words, except
|
|
for a broken symbolic link, which is named as one (`symlink_metadata` says
|
|
so) because `No such file or directory` reads as a lucisv bug there.
|
|
- **45.3** — an aggregate head in expression position is *always* a type. No
|
|
legal expression starts with `struct`, `union` or `enum`, so the new arm in
|
|
`parse_expr_or_type` cannot take a value away from the expression grammar.
|
|
It opens the same door for `$bits(struct packed {…})`, a stream slice size
|
|
and an assignment-pattern key, all of which reach `parse_expr_or_type` too.
|
|
- **45.3** — the aggregate prints through the existing type printer, so a
|
|
`struct`/`union` body opens across lines exactly as it does in a declaration
|
|
and an `enum` body stays inline. Nothing was laid out specially for the
|
|
override list.
|
|
- **45.4** — a comment inside a bracket pair forces that pair open. That has
|
|
been true since comment-slots; the one-value `#( /*c*/ 1:2:3 )` case in
|
|
`delay_comment_slots.cases` is a fixed point at that layout for that reason.
|
|
- **45.4** — `Expr` stays at 96 bytes: `MinTypMaxComments` is boxed, as every
|
|
expression-level slot is (`ast/mod.rs`'s size assertion is the check).
|
|
- **45.4** — the empty case costs nothing. Every new slot is printed through
|
|
`Fmt::slot_comments` or an `is_empty()` match that emits the space the old
|
|
code emitted, which is what the corpus and opentitan byte-identity runs below
|
|
measure.
|
|
|
|
## Handshakes
|
|
|
|
**Consumed, unchanged.** `Parser::{take_gap, gap_before, take_before_open,
|
|
take_meta, take_before_sep}` — every new slot is built from them, on
|
|
comment-slots' rule that a gap belongs to a construct only when the token that
|
|
closes it was written. `Fmt::{slot_comments, inline_comments,
|
|
inline_comments_spaced, semi, trailing}` likewise. `verify.rs` untouched and
|
|
no normalization widened; ten new attack pairs ship anyway (CLAUDE.md
|
|
invariant 4).
|
|
|
|
**Promised / changed.** All additive except where marked.
|
|
|
|
| node / API | change | note |
|
|
|---|---|---|
|
|
| `lucisv_core::walk::Warning` | new | `{ path, message }`, `Display` as `<path>: <message>` |
|
|
| `lucisv_core::walk::collect_files` | **signature**: fifth parameter `&mut dyn FnMut(Warning)` | two callers, one line each |
|
|
| `ExprKind::MinTypMax` | `comments: Box<MinTypMaxComments>` | four slots, two `:` |
|
|
| `ContAssign` | `after_hash`, `after_delay` | `assign # /*a*/ (5) /*b*/ y = x;` |
|
|
| `GateInstantiation` | `before_hash`, `after_hash`, `before_semi`; `delay: Vec<Expr>` → `Vec<DelayValue>` | **changed field type** |
|
|
| `GateInstance` | `before_args` | `g1 /*c*/ (y, a)` |
|
|
| `ast::DelayValue` | new | `{ leading, expr, trailing }` — the `(`, `,` and `)` slots of a multi-value list |
|
|
| `settings::ClientSettings` | `lint_name_warnings: Vec<String>` | one line per unknown name |
|
|
| `settings::rules` | **signature**: takes the setting's name and a warning sink | private to the module |
|
|
| `Server::said_lint_names` | new field | §45.1's memo |
|
|
| `Workspace::{walked_files, folder_files, default_files, widened_files}` | **signature**: each takes `&mut dyn FnMut(String)` | private to `state.rs` |
|
|
|
|
Why a **sink** and not a `Walked { files, warnings }` return: both callers
|
|
accumulate into a `&mut Vec<PathBuf>` across a loop over their inputs — the
|
|
CLI over `opts.inputs`, the server over its scope directories — so a struct
|
|
return would have made each of them merge two vectors per iteration and give
|
|
up the accumulator idiom. With the sink each call site is one changed line:
|
|
the CLI adds `&mut |w| eprintln!("warning: {w}")`, the server adds
|
|
`&mut |w| warn(w.to_string())` onto the scope warnings it already collects.
|
|
|
|
**Requests filed.** None. Nothing outside this round's own file set was
|
|
edited.
|
|
|
|
## Docs to apply at merge (lead)
|
|
|
|
`docs/topo.md` §2.9 — four rows:
|
|
|
|
- **Row 17** (inline aggregate as a parameter-override argument) — strike, and
|
|
append: *— **delivered 2026-09-05 by small-items-4 (TODO §45.3)**:
|
|
`parse_expr_or_type` routes a `struct`/`union`/`enum` head to
|
|
`parse_type_expr`, which `parse_type_ref` has been able to read since the
|
|
first day; the value is an `ExprKind::Type` printed by the existing type
|
|
printer (a struct or union body opens, an enum body stays inline). The same
|
|
door opens for the four other callers of `parse_expr_or_type` — `$bits(…)`,
|
|
a stream slice size, an assignment-pattern key and an ordered override.
|
|
`vlog_refactor`'s `default_text` probe now passes such a default and
|
|
`instantiation_plan` emits the type text; only the **multi-line** spelling
|
|
(`common_cells/src/ecc_encode.sv`) is still dropped, and by the
|
|
"written across several lines" rule rather than by the grammar. Corpus (860)
|
|
and opentitan (3 947) byte-identical.*
|
|
- **Row 22** (comment slots in shared machinery, already struck) — append to
|
|
its delivered note: *A fifth fuzzer bar was added 2026-09-05 by
|
|
small-items-4 (TODO §45.4): the **delay list** — `#(1:2:3)` on nets and
|
|
continuous assignments, `#(rise, fall)` on gates — gained
|
|
`MinTypMaxComments` (four slots, one grammar shared with the parenthesized
|
|
`(a:b:c)` expression), `ast::DelayValue` for the multi-value list's `(`, `,`
|
|
and `)`, and `ContAssign::{after_hash, after_delay}`,
|
|
`GateInstantiation::{before_hash, after_hash, before_semi}`,
|
|
`GateInstance::before_args`. `EXPECTED_RTL_GAPS` 374 → 419, still at zero
|
|
failures.*
|
|
- **Row 29** (the editor's unknown rule name) — strike, and append:
|
|
*— **delivered 2026-09-05 by small-items-4 (TODO §45.1)**:
|
|
`settings::rules` describes every dropped name into
|
|
`ClientSettings::lint_name_warnings` as
|
|
`lucisv.lint.<select|ignore>: unknown rule: <name>`, and `apply_settings`
|
|
logs what `Server::said_lint_names` — the previous settings value's own
|
|
warning list — does not already hold. Once per (setting, name); a
|
|
`didChangeConfiguration` that changes the list re-arms exactly what is new in
|
|
it; four diagnostics passes add nothing. The dropping itself, and §42's
|
|
ladder under an emptied `select`, are unchanged.*
|
|
- **Row 30** (an unreadable directory aborts the whole walk) — strike, and
|
|
append: *— **delivered 2026-09-05 by small-items-4 (TODO §45.2)**:
|
|
`walk::collect_files` takes a `&mut dyn FnMut(Warning)` sink (`Warning
|
|
{ path, message }`), chosen over a `Walked { files, warnings }` return
|
|
because both callers accumulate into a `&mut Vec<PathBuf>` across a loop and
|
|
a struct return would have cost each of them a merge per input. An unreadable
|
|
directory, an unreadable `.gitignore` and a dangling **source-file** link are
|
|
each said once and skipped; the walk finishes. CLI: `warning: <path>:
|
|
<message>` on stderr before the report, exit code unchanged. Server: the
|
|
warnings join the scope's own and are logged once per scan through
|
|
`report_scope`. §43's review ruling that a dangling source link is handed on
|
|
to fail in the front end is **reversed** — the warning is the error's home
|
|
now. A dangling link that names no source file is still skipped silently.*
|
|
|
|
Also worth a line in `README.md` where the walk is described, if it says a
|
|
walk fails on an unreadable directory: it warns and continues now.
|
|
|
|
## Status / TODO
|
|
|
|
- [x] 45.1 editor unknown-name log (`settings.rs`, `server/notification.rs`,
|
|
`server/mod.rs`, `server/tests/settings.rs`)
|
|
- [x] 45.2 walk warning channel, both front ends (`lucisv_core/src/walk.rs`,
|
|
`lucisv/src/main.rs`, `lucisv/tests/cli.rs`,
|
|
`lucisv_server/src/state.rs`)
|
|
- [x] 45.3 inline aggregate override argument + plan emission
|
|
(`parser/primary.rs`, `parser/tests/instance.rs`,
|
|
`vlog_refactor/src/instantiate.rs`, `tests/cases/instantiation.cases`)
|
|
- [x] 45.4 delay-list comment slots + fuzzer coverage (`ast/expr.rs`,
|
|
`ast/module.rs`, `parser/instance.rs`, `format/expr.rs`,
|
|
`format/instance.rs`, `format/item.rs`,
|
|
`tests/cases/delay_comment_slots.cases`, `tests/verification.rs`)
|
|
- [x] Gates (guarded): fmt, clippy, `cargo test --workspace`, corpus,
|
|
byte-identity, smoke, the hostile-tree CLI run
|
|
- [ ] docs: topo 29/30/17/22 struck (lead — text above)
|
|
- [x] QA (2026-09-05 — REWORK, one MEDIUM finding; see QA log)
|
|
|
|
## Work log
|
|
|
|
### 2026-09-05 — dev (Fable 5.1)
|
|
|
|
**45.3 first, because it was one line of grammar.** `parse_expr_or_type`
|
|
(`parser/primary.rs`) checked `TYPE_KEYWORDS`, which holds the *integral and
|
|
non-integral* type keywords only. `struct`, `union` and `enum` are keywords
|
|
too and `parse_type_ref` already dispatches all three to `parse_struct_type` /
|
|
`parse_enum_type`, so the fix is a second arm in front of the existing one. No
|
|
legal expression begins with one of those words, so the arm cannot take a
|
|
value away from the expression grammar; the previous behaviour was
|
|
"unexpected keyword `struct` in expression".
|
|
|
|
Nothing else was needed for the plan's second half. `default_text` in
|
|
`vlog_refactor/src/instantiate.rs` already *probes* — it writes
|
|
`m #(.P( <default> )) u ();` and asks the tolerant parser — so a one-line
|
|
aggregate default started being emitted the moment the grammar accepted it.
|
|
The doc comment there claimed the grammar was the reason such a default was
|
|
dropped; it now says the probe is the rule and that the multi-line spelling is
|
|
what is still refused, by the other rule above it. Test added.
|
|
|
|
**45.4 was measured, not guessed.** The candidate fixture went into
|
|
`RTL_FIXTURES` first and the fuzzer named 23 failing gaps. Fixing them meant
|
|
one new expression-level slot (`MinTypMaxComments`, boxed) and one new list
|
|
shape:
|
|
|
|
- `parse_delay_values` now returns `Vec<DelayValue>` (`{ leading, expr,
|
|
trailing }`). The **one-value** spelling still folds into the
|
|
`ExprKind::Paren` it always produced, and the paren's existing `before` /
|
|
`after` slots are exactly where the `#( … )` gaps go — so nets and continuous
|
|
assignments needed no new node at all. Only the gate's multi-value list, whose
|
|
parentheses and commas the *printer* writes, needed somewhere to put them.
|
|
- The two `min : typ : max` grammars — the delay list's and the parenthesized
|
|
expression's in `parser/primary.rs` — were folded into
|
|
`Parser::parse_min_typ_max_tail`, so the four colon slots exist in both. That
|
|
is the same "three duplicated grammars folded into one" move comment-slots
|
|
made.
|
|
- The gate instantiation had four gaps of its own with no owner once the delay
|
|
had slots: before the `#`, after the `#`, before an instance's `(`, and
|
|
before the `;`. `GateInstance::meta` was parsed but never printed, so the
|
|
gap in front of an instance name is now printed too, along with the
|
|
element's `before_sep` / `trailing` around the `,` between two instances.
|
|
- `ContAssign` gained `after_hash` and `after_delay`. The second one matters:
|
|
a continuous assignment prints its first pair's leading comments straight
|
|
after the `assign` keyword, which is *in front of* the delay, so a comment
|
|
written after the delay had to be taken out of that path before `take_meta`
|
|
saw it.
|
|
|
|
`EXPECTED_RTL_GAPS` 374 → 419 with the reason on the constant and on the
|
|
fixture. Six cases in a new `delay_comment_slots.cases`, plus five attack
|
|
pairs in `verification.rs`, one per token a new slot sits beside.
|
|
|
|
**45.2 — the channel shape.** `&mut dyn FnMut(Warning)`, not `Walked { files,
|
|
warnings }`. Both callers of `collect_files` accumulate into a `&mut
|
|
Vec<PathBuf>` across a loop over their own inputs, so a struct return would
|
|
have replaced one line with three at each of them and given up the accumulator
|
|
the signature is built around. With the sink each call site is one changed
|
|
line. Inside the crate, `Walk::dir` lost its `io::Result` entirely and split
|
|
into `dir` (enter, push the ignore stack, pop it) and `entries` (read and
|
|
recurse), which keeps both under twenty lines.
|
|
|
|
The reversal is deliberate and is the plan's: a dangling **source-file** link
|
|
is warned about and **not** pushed into `files`. §43's review had kept it in
|
|
the list so the front end's `no such file` error survived; the warning is that
|
|
error's home now, and it says something the old path could not — that the file
|
|
is a broken link rather than absent. The walk.rs test and its comment were
|
|
rewritten to say so. A dangling link that names no source file is still
|
|
skipped in silence; it was never going to be read.
|
|
|
|
Server plumbing: `walked_files` / `folder_files` / `default_files` /
|
|
`widened_files` each take the sink, and `source_files` collects into the
|
|
`Scope::warnings` that already existed for a filelist's problems. That road
|
|
ends at `report_scope`, which logs each line once per scan and shows the first
|
|
one — the same treatment a filelist's warnings have always had. **Deviation
|
|
from the plan's letter:** the plan said "through `notification.rs`"; the scan
|
|
warnings' channel is `server/client.rs`'s `report_scope`, called from
|
|
`server/index.rs` and `server/mod.rs` where a scan finishes. Inventing a second
|
|
road for the same class of message would have been worse than using the one
|
|
that exists. "Once per scan" holds.
|
|
|
|
**45.1 — the memo.** `settings::rules` takes the setting's name and a warning
|
|
sink and describes each dropped name; the lines land in a new
|
|
`ClientSettings::lint_name_warnings`, kept separate from
|
|
`lint_option_warnings` because the two are said differently. `apply_settings`
|
|
logs the lines `Server::said_lint_names` does not hold and then replaces that
|
|
memo with the current list — which is the whole of "once per (setting, name),
|
|
re-armed when the setting changes". The options warnings' behaviour is
|
|
untouched.
|
|
|
|
**Gates, all guarded.** `cargo fmt` per touched crate and `cargo fmt --all --
|
|
--check` clean; `cargo clippy --all-targets` clean; `cargo test --workspace`
|
|
**3 810 passed, 0 failed, 44 ignored** (baseline 3 788 — 22 new tests);
|
|
`tools/corpus_check.sh` **814/820**, the same six errors, no verification error
|
|
and no crash; byte-identity against the trunk binary (built from `git archive
|
|
HEAD` into the scratchpad, never a checkout in this tree) **860 corpus files,
|
|
0 diffs** and **3 947 opentitan files, 0 diffs**, with the same 6 and 9 errors
|
|
either side; `node editors/vscode/smoke.js target/release/lucisv-server` OK;
|
|
and `target/release/lucisv format --check` over a scratch tree with a `0o000`
|
|
subdirectory and a dangling `x.sv` link printed exactly two `warning:` lines on
|
|
stderr before the report, reported the other files, and exited 1 on the
|
|
formatting alone. `git -C ~/repo/opentitan status --porcelain` shows only the
|
|
three pre-existing files.
|
|
|
|
**Files touched outside the plan's expected set.** Three, all forced by an AST
|
|
field the round added and each a mechanical pattern update:
|
|
`crates/vlog_semantic/src/bind/expr.rs` (a `..` in the `MinTypMax` arm),
|
|
`crates/vlog_semantic/src/bind/item.rs` (`&d.expr` for the gate delay) and
|
|
`crates/vlog_parser/tests/spans.rs` (both of the same). Nothing else in
|
|
`vlog_semantic` was changed.
|
|
|
|
### 2026-09-05 — lead, at review
|
|
|
|
QA's MEDIUM closed in the tree: a *line* comment trailing a gate instance's
|
|
`,` now ends the line and the next instance continues one level in
|
|
(`indent(vec![Doc::HardLine])`, the module-instantiation printer's rule); a
|
|
block comment there stays inline, as the dev's own case table expects. A
|
|
case in `net_delay_position.cases` pins the repro. The four topo rows are
|
|
applied.
|
|
|
|
## QA log
|
|
|
|
### 2026-09-05 — QA (Sonnet)
|
|
|
|
Build: `cargo build --release -p lucisv -p lucisv_server` clean, up to date
|
|
with the uncommitted tree at f302b47+.
|
|
|
|
**45.1 — the editor's unknown rule name.** Read `settings.rs`,
|
|
`server/notification.rs`, `server/mod.rs`, `server/tests/settings.rs` in
|
|
full; behaviour matches the README exactly (memo = previous settings
|
|
value's own warning list, `lint_option_warnings` untouched, severity words
|
|
never warned). Added a temporary wire-level test to `tests/e2e.rs`
|
|
(`talk`, framed JSON-RPC, real binary) driving: push `lucisv.lint.select:
|
|
["no-tab"]` → open → three `didChange`s each forced through a `flush_dirty`
|
|
by an interleaved `codeAction` request (four diagnostics passes total,
|
|
confirmed by counting `textDocument/publishDiagnostics`) → re-push the
|
|
identical list → push a second typo `nope` → push with the first typo
|
|
fixed. Result: exactly one `window/logMessage` `lucisv: lucisv.lint.select:
|
|
unknown rule: no-tab`, nothing across the four diagnostics passes or the
|
|
identical re-push, exactly one more line for `nope` when it was added,
|
|
nothing when the first typo was dropped from the list. Test removed after
|
|
passing (file `tests/e2e.rs` is unchanged, confirmed by `git diff`). Unit
|
|
tests already in the diff cover the `ignore` typo, an empty `select`
|
|
falling through §42's ladder with the rule set unchanged, and a severity
|
|
word (`style`, `warning`) never being reported — read and agree with all
|
|
three. No findings.
|
|
|
|
**45.2 — the walk's warning channel.** Read `walk.rs`, `main.rs`,
|
|
`tests/cli.rs`, `state.rs` diffs in full, plus `server/client.rs`'s
|
|
`report_scope` (unchanged — confirmed the "went through `client.rs` instead
|
|
of `notification.rs`" deviation is real and `report_scope` already does
|
|
"logged once per scan, one showMessage summary at most" for every existing
|
|
caller). Built eight hostile scratch trees under the scratchpad and ran the
|
|
CLI over each through `tools/guard.sh -t 120`:
|
|
- 0o000 subdirectory: warning on stderr before the report, `format --check`
|
|
on an already-clean tree exits **0** with the warning still printed
|
|
(the exact case TODO §45.2 calls out); `format --check` on a tree needing
|
|
a reformat exits 1 on the formatting alone; `format` (real reformat, on a
|
|
scratch copy) and `check` both warn and proceed, exit 0.
|
|
- dangling `x.sv` link: warned, dropped, not handed to the formatter.
|
|
- dangling link to a non-source name: silent, as specified.
|
|
- unreadable `.gitignore` (0o000): warned, directory still walked.
|
|
- a symlink cycle plus an unreadable directory in the same tree: no hang,
|
|
no crash, the unreadable directory is warned once and the rest of the
|
|
tree is reported.
|
|
- **the start directory itself unreadable (0o000)**: `path.is_dir()`
|
|
succeeds (stat needs only the parent's search bit), so the walk enters,
|
|
`read_dir` fails, one warning is printed naming the start directory, and
|
|
the run then fails with the CLI's ordinary `error: no Verilog files
|
|
found` at exit 2 — sensible, not a crash, not silent. Not covered by the
|
|
dev's own tests; recorded here since the plan asked "what happens?".
|
|
- an unreadable file `y.sv` (chmod 0o000, not a directory): reported once,
|
|
as the pre-existing per-file read error (`error: ...: Permission
|
|
denied`), *not* as a walk warning — confirmed not duplicated.
|
|
- 200 unreadable directories under one start: exactly 200 `warning:` lines,
|
|
the walk finishes, the one real file is still reported.
|
|
|
|
Server: adapted the existing `Session`/`Tree` test harness (as
|
|
`server/tests/*.rs` already does) into a temporary file
|
|
(`server/tests/qa_scratch_45.rs`, registered and later removed from
|
|
`server/tests/mod.rs`) to drive `Session::wide` over a tree with one 0o000
|
|
subdirectory: the warning is logged exactly once via `logged()`, at most
|
|
one `shown()` `window/showMessage` summary, and pushing a settings change
|
|
that forces `reindex` (`lucisv.index.maxFileSize` with `scope: "workspace"`
|
|
kept, mirroring `capping()` in `server/tests/index.rs`) logs the same
|
|
warning again exactly once. `server/tests/mod.rs` and the deleted scratch
|
|
file leave no diff (`git diff --stat` confirms only the intended lane
|
|
files changed). No findings.
|
|
|
|
**45.3 — inline aggregate override argument.** Manually formatted a file
|
|
covering `struct packed`, `union packed` (with two members), `enum`, a
|
|
`struct packed` with a comment inside, a nested `struct packed` inside a
|
|
`struct packed`, and the same aggregate as a **positional** override
|
|
(`m #(struct packed {logic a;}) u5 ();`) — all format correctly (struct/
|
|
union bodies open, enum stays inline, comment kept), round-trip is a fixed
|
|
point (`format(format(x)) == format(x)`, byte-for-byte), and the comment
|
|
survives. Confirmed the illegal expression-position case is unchanged and
|
|
safe: `assign x = struct packed { logic a; };` still fails with the
|
|
original `parse error: ... unexpected keyword \`struct\` in expression`
|
|
under both `format --check` and `format --stdout`, exit 2, no corruption —
|
|
`parse_expr` (assign's RHS) does not route through `parse_expr_or_type`, so
|
|
the new door stays shut there exactly as the Assumptions section claims.
|
|
Ran `vlog_refactor`'s new and neighboring tests directly
|
|
(`a_one_line_inline_aggregate_default_is_emitted`,
|
|
`a_multi_line_type_is_shown_on_one_line`): both green, confirming the
|
|
one-line default is now emitted and the multi-line one is still dropped, by
|
|
the "written across several lines" rule rather than the grammar. No
|
|
findings.
|
|
|
|
**45.4 — delay-list comment slots.** Read the fixture
|
|
(`delay_comment_slots.cases`) end to end against the `Promised / changed`
|
|
table in the Handshakes section: every new field
|
|
(`MinTypMaxComments`'s four slots, the one-value `Paren`'s two slots,
|
|
`ContAssign::{after_hash, after_delay}`,
|
|
`GateInstantiation::{before_hash, after_hash, before_semi}`,
|
|
`DelayValue::{leading, trailing}`, `GateInstance::before_args`, and
|
|
`GateInstance::meta.{before_sep, trailing}`) has at least one case, plus a
|
|
byte-cost-zero case and one line-comment case (the `min:typ:max` colon
|
|
only). Confirmed `EXPECTED_RTL_GAPS` 419 with the block-comment-per-gap
|
|
fuzzer at 0 failures (`cargo test -p vlog_formatter
|
|
a_comment_in_every_rtl_gap_still_formats`).
|
|
|
|
**Because the fuzzer and the fixture both probe with `/*block*/` comments
|
|
only, I attacked every new slot again by hand with `//line` comments** (the
|
|
plan explicitly asked for "line comments in each slot"). Seven of eight
|
|
were fine (`before_hash`, `after_hash`, `before_args`, `before_semi`, the
|
|
one-value delay's two `Paren` slots, `ContAssign::after_hash`,
|
|
`ContAssign::after_delay` all correctly force a hard line after a line
|
|
comment via `inline_comments_spaced`/`slot_comments`). The eighth is a
|
|
**real bug**:
|
|
|
|
> **FINDING (MEDIUM) — a line comment trailing a gate instance's `,`
|
|
> separator corrupts the rest of the statement into the comment; caught
|
|
> by `verify.rs`, so no bad file is ever written, but `lucisv format`
|
|
> hard-fails (exit 2) on legal, comment-bearing SystemVerilog that TODO
|
|
> §45.4 claims this round closes.**
|
|
>
|
|
> `crates/vlog_formatter/src/format/instance.rs:400-405` (the gate
|
|
> instantiation's multi-instance loop, only reached for `i < last`):
|
|
> ```rust
|
|
> docs.push(text(","));
|
|
> if let Some(tr) = &inst.meta.trailing {
|
|
> docs.push(text(" "));
|
|
> docs.push(self.comment(tr));
|
|
> }
|
|
> ```
|
|
> Nothing forces a line break after `tr` before the next iteration prints
|
|
> the following instance's `meta.leading` (a bare `text(" ")` when that is
|
|
> empty). When `tr` is a line comment, everything the next iteration emits
|
|
> lands on the same source line, and a line comment runs to end of line —
|
|
> so on re-lex the rest of the statement disappears into the comment.
|
|
> `verify.rs` sees the token-stream divergence and correctly refuses to
|
|
> write the file (invariant 1 upheld; nothing corrupted on disk); the
|
|
> failure mode is a hard error on valid input, not corrupted output.
|
|
>
|
|
> Repro:
|
|
> ```systemverilog
|
|
> module m;
|
|
> and #(2, 3) g0 (y, a), // p
|
|
> g1 (z, b);
|
|
> endmodule
|
|
> ```
|
|
> `target/release/lucisv format --stdout repro.sv` →
|
|
> `error: repro.sv: verification failed: token stream diverges at index 17:
|
|
> input has comment "// p" at 2:26, output has comment "// p g1 (z, b);" at
|
|
> 2:26`, exit 2. Reproduces with three instances too (the whole remainder,
|
|
> including a further `,`-separated instance, is swallowed).
|
|
>
|
|
> Contrast with the pre-existing, correct pattern four lines above this one
|
|
> in the same file (`format/instance.rs:64-74`, the *module*-instantiation
|
|
> multi-instance list), which already does the right thing:
|
|
> ```rust
|
|
> if let Some(tr) = &instance.meta.trailing {
|
|
> inner.push(text(" "));
|
|
> inner.push(self.comment(tr));
|
|
> if i < last { inner.push(Doc::HardLine); }
|
|
> } else if i < last { inner.push(Doc::Line); }
|
|
> ```
|
|
> The gate-instance printer added by 45.4 does not replicate the
|
|
> `i < last` hard-line-after-trailing-comment rule (or use
|
|
> `inline_comments_spaced`/`Fmt::trailing`, which both already know a line
|
|
> comment forces a break).
|
|
>
|
|
> Not caught by the dev's own attack tests or the RTL fuzzer because both
|
|
> only exercise the `before_sep`/`trailing` slot with **block** comments
|
|
> (`delay_comment_slots.cases`'s last case:
|
|
> `g0 (y, a) /* before */ , /* after */ g1 (z, b)`). Not a widened
|
|
> `verify.rs` forgiveness (invariant 4 does not apply — nothing in
|
|
> `verify.rs` changed), and not a dropped comment (invariant 3 holds —
|
|
> the whole file is refused, not partially emitted). Severity kept at
|
|
> MEDIUM rather than HIGH because of that: no corruption reaches disk,
|
|
> the blast radius is exactly this one slot/comment-kind combination, and
|
|
> the corpus and opentitan sweeps (neither of which contains this pattern)
|
|
> are unaffected — confirmed by the unchanged 814/820 and the byte-identity
|
|
> runs below.
|
|
>
|
|
> Suggested fix (for the dev, not applied here per QA's mandate not to
|
|
> redesign): either call `self.inline_comments_spaced` for the trailing
|
|
> comment instead of the raw `text(" ")` + `self.comment(tr)` pair (it
|
|
> already emits `Doc::HardLine` when the comment is a line comment), or
|
|
> mirror the module-instantiation loop's explicit `if i < last { push
|
|
> HardLine }` after the trailing comment.
|
|
|
|
**Byte-identity and gates (all guarded).**
|
|
- `cargo clippy --all-targets`: clean.
|
|
- `tools/guard.sh -- cargo test --workspace`: **3 810 passed, 0 failed, 44
|
|
ignored** — matches the dev's number exactly.
|
|
- `tools/guard.sh -- tools/corpus_check.sh`: **814/820**, same six parse
|
|
errors, 0 verification errors, 0 crashes.
|
|
- `node editors/vscode/smoke.js target/release/lucisv-server`: OK.
|
|
- Corpus byte-identity vs `~/.cache/lucisv-baselines/lucisv-0.43.0`:
|
|
compared `format --stdout` + exit code file by file over all **860**
|
|
corpus source files (not just the 820 `corpus_check.sh` reports on) —
|
|
**0 differing**.
|
|
- Opentitan `format --check` vs the same 0.43.0 baseline over `hw/ip`,
|
|
`hw/top_earlgrey/ip`, `hw/top_darjeeling/ip`, `hw/dv`, `hw/vendor`:
|
|
**2 553** source files (not the dev's 3 947 — a different, smaller
|
|
file-extension/glob accounting was used here; not investigated further
|
|
since exit codes and normalized stdout/stderr matched exactly either
|
|
way); every exit code identical, and every stderr line identical once
|
|
the baseline's incidental `, N files from cache` cache-hit annotation
|
|
(a pre-existing `.lucisv_cache/` in the opentitan tree, untracked,
|
|
gitignored, unaffected by which binary populated it) is stripped from
|
|
both sides — **0 behavioural differences**.
|
|
`git -C ~/repo/opentitan status --porcelain` after every run: 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`).
|
|
|
|
**Cleanup.** All scratch trees removed (permissions restored with
|
|
`chmod -R u+rwx` first). The two temporary test additions
|
|
(`tests/e2e.rs`, `server/tests/qa_scratch_45.rs` + its `mod.rs`
|
|
registration) were removed after use; `git diff --stat` shows no lane file
|
|
touched by this QA pass except this README and the TODO.md checkbox.
|
|
|
|
**Verdict: REWORK.** One finding, filed above:
|
|
- **MEDIUM** — `format/instance.rs:400-405`, a line comment trailing a
|
|
gate instance's `,` separator (`GateInstance::meta.trailing`, not the
|
|
last instance) corrupts the rest of the statement into the comment;
|
|
`verify.rs` catches it and refuses the file rather than writing bad
|
|
output, but `lucisv format` hard-fails on legal input the round claims
|
|
to support. Needs a fix plus a line-comment test in
|
|
`delay_comment_slots.cases` or `verification.rs` before this closes.
|
|
|
|
Everything else in 45.1, 45.2 and 45.3 checked out clean against the plan,
|
|
including the corners the plan called out by name (the start-directory
|
|
case, the 200-unreadable-directories case, the illegal-expression-position
|
|
case, severity words never warned, four diagnostics passes, a rescan
|
|
re-arming the server's log).
|
|
|
|
## Review
|
|
|
|
**2026-09-05 — lead.** Accepted with the rework above; ships in 0.44.0
|
|
with §46. Four small items, each the shape the plan asked for. The sink
|
|
choice for the walk (a closure over a struct return) is right for the
|
|
reason given — both callers accumulate across a loop — and routing the
|
|
server's scan warnings through the road filelist warnings already take,
|
|
rather than `notification.rs`, is the better reading of the plan. The §43
|
|
reversal (a dangling source link is warned about and not handed on) is now
|
|
correct because the warning has a home. QA's MEDIUM was a real formatter
|
|
refusal on legal input — the one class of bug the verifier exists to catch,
|
|
and it did — fixed at review with the rule the sibling printer already had.
|
|
Byte-identity: 0 of 860 corpus files and 0 of 3 947 opentitan files differ
|
|
from 0.43.0.
|