Commit Graph
30 Commits
Author SHA1 Message Date
lucioandClaude Fable 5 b77b61e7de directive-split: recover conditional-split constructs as verbatim items
An `ifdef/`else region whose arms are each an incomplete fragment of one
declaration (alternative heads sharing a body; alternative struct bodies
sharing a closing) no longer refuses: the strict parser recovers the whole
construct as a verbatim item, exact source bytes, the constraint/covergroup
precedent. The trigger requires an unmatched open bracket inside a region
genuinely open at item scope — `Parser::open_conds` counts only at the
single ItemKind::Directive producer, so opaque verbatim walks cannot
perturb it, and a recovered block hands back the nesting it swallows.

Corpus: 800 -> 813 / 820 (97.6% -> 99.1%), +13 files (12x
riscv_core_setting.sv, riscv_instr_pkg.sv), pass set a strict superset.
verify.rs untouched. Three dev passes, two adversarial QA rejections
(stray-`endif laundering; open_conds pollution via opaque bodies), QA
round 5 PASS. 26+12 new tests; workspace 1672 passed / 0 failed.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-26 01:26:28 -07:00
lucio eeaffafd56 Rename the tool to lucisv (Language Utility for Coding In SystemVerilog) 2026-08-25 23:36:00 -07:00
lucioandClaude Fable 5 d8e37086df Refactoring M5: keyword + project-wide identifier completion; v0.3.0
Five completion tiers in one response: module skeletons (M4, unchanged
gate), scope-visible symbols with real kinds, workspace-index names and
`define macros (backtick-aware, never inventing punctuation), Verilog/SV
keywords (single-source KEYWORDS list factored from the lexer's table,
lexing unchanged), and token-harvested project words — comments and
strings contribute nothing and get no completions. Candidate tables build
with the index over the M1 scope ladder (94 ms / 860 files, ~1.4 MiB);
a keystroke answers in ~300 µs, budget-tested. Version 0.3.0 across the
workspace and extension, CHANGELOG covers the M1-M5 refactoring layer.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-24 15:07:57 -07:00
lucioandClaude Fable 5 a4f8476894 Fix round-1 QA findings: Inline width in fits(), action-block nesting, comment gaps
printer::fits() now measures from a multi-line Doc::Inline's last line and
keeps measuring the rest of the group (a with {...} block no longer hides
an overflow). skip_action_stmt tracks begin/end, fork/join, case/endcase
nesting so a concurrent assertion's action block is captured whole.
Comments between bind/target/module and around randomize(...) with are
attached and reprinted instead of being refused by the safety net.
All 800 passing corpus files format byte-identically before and after.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-21 02:11:59 -07:00
lucioandClaude Fable 5 e35da292bd Add mop-up-2: macro items ending their line, new shallow copy, 32'h`MACRO
A macro invocation that ends its line is a complete item whatever opens
the next line; new <expr> shallow-copy constructor; a based number whose
digits come from a macro (32'h`BOOT_ADDR) lexes as a base-only number
joined with the macro in the parser. verify.rs untouched, attack tests added.

Coverage loop round 2: 796 -> 800 / 820 (97.1% -> 97.6%).
Feature README: docs/features/mop-up-2/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-21 01:42:53 -07:00
lucioandClaude Fable 5 f1db1e5746 Add dv-statements: with clauses, foreach targets, randcase, let, labels
randomize()/std::randomize() with { ... } (block verbatim), array-method
with (expr), foreach over scoped/hierarchical/indexed arrays, randcase,
wait fork, import as a statement, let declarations, empty call arguments,
general statement labels, and endtask: name; (stray semicolon kept).
Also fixes a pre-existing verification failure for a comment between a
then-branch and its else.

Coverage loop round 1, cluster 8: 772 -> 796 / 820 (94.1% -> 97.1%).
Feature README: docs/features/dv-statements/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-21 01:19:49 -07:00
lucioandClaude Fable 5 c2ea1656e1 Add expressions-2: casts, streaming, ->, drive strengths, pattern replication
Casts with parenthesized/keyword/scoped bases, streaming operators, -> and <-> implication, assign (weak0, pull1) drive strengths, (* attr *) on named connections, '{N{x}} replication in assignment patterns, x inside `MACRO, const ref tf arguments.

Coverage loop round 1, cluster 7: 751 -> 772 / 820 (91.6% -> 94.1%).
Feature README: docs/features/expressions-2/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-21 00:46:39 -07:00
lucioandClaude Fable 5 d071957393 Add types-decls: inline aggregates, typedef'd types with packed dims
Anonymous enum/struct/union declarations, struct packed as a parameter type default, user_t [N:0] x; at item and statement position, typedef enum with a typedef'd base, nested anonymous structs, localparam type as a body item, multi-declaration for-loop inits.

Coverage loop round 1, cluster 6: 740 -> 751 / 820 (90.2% -> 91.6%).
Feature README: docs/features/types-decls/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-21 00:24:04 -07:00
lucioandClaude Fable 5 2a63faf9a2 Add interfaces, modport, clocking blocks and virtual interface types
interface...endinterface shares the module header/body machinery (ItemKind::Module with kw == "interface"); modport and clocking are structural items; virtual <iface>[#(...)] is accepted in every type position. module-filename now applies to interfaces.

Coverage loop round 1, cluster 5: 712 -> 740 / 820 (86.8% -> 90.2%).
Feature README: docs/features/interfaces/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-21 00:01:53 -07:00
lucioandClaude Fable 5 e24d33afab Add concurrent assertions, sequence and property as verbatim items
assert/assume/cover/restrict property (...) [action block], optionally labeled, at item and statement position; sequence...endsequence and property...endproperty declarations. Verbatim pass-through like constraint/covergroup; verify.rs untouched, attack tests added.

Coverage loop round 1, cluster 4: 699 -> 712 / 820 (85.2% -> 86.8%).
Feature README: docs/features/assertions/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-20 23:38:22 -07:00
lucioandClaude Fable 5 f7c66c79bf Add bind directives
bind <target> [: inst, ...] <module> [#(...)] <inst> (...); reusing the instantiation AST and layout wholesale.

Coverage loop round 1, cluster 3: 671 -> 699 / 820 (81.8% -> 85.2%).
Feature README: docs/features/bind/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-20 23:23:41 -07:00
lucioandClaude Fable 5 8007a71932 Add dpi-export: DPI-C import/export and package export
import "DPI-C" [context|pure] function/task prototypes, export "DPI-C" function/task, and export pkg::*; / pkg::item.

Coverage loop round 1, cluster 2: 661 -> 671 / 820 (80.6% -> 81.8%).
Feature README: docs/features/dpi-export/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-20 23:09:49 -07:00
lucioandClaude Fable 5 f52beff48f Add item-misc: spaced macro calls, line-aware macro items, `error, elab tasks
Macro invocations with whitespace before the argument list, a bare macro on its own line followed by a declaration, `error/`warning directives, and $error/$fatal/$warning/$info as module/generate items.

Coverage loop round 1, cluster 1: 636 -> 661 / 820 (77.6% -> 80.6%).
Feature README: docs/features/item-misc/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-20 22:54:47 -07:00
lucioandClaude Fable 5 54b0ca3896 Add class-semantics and lexer-cleanup (round 20)
class-semantics: classes are first-class in vlog_semantic -- class
scopes and symbols, member/method/prototype binding, this.x
(nearest-class-only), super.x, cls::x with lexical unit heads,
out-of-body cls::method bound into the class's scope with the extern
prototype as the definition (rule 10), and the honest
InheritedCandidate{base, paths} shape: a member miss in an extending
class records what the unknown base might supply (import paths
included) and is never chased, not even in-file -- the future
inheritance round's worklist, measured at 1303 candidates. Unit-name
misses stay ExternalCandidate (QA-found, lead-ruled: bases supply
members, not package names; +170 recovered navigations, pinned).
Workspace index gains classes as units (246) and their members
(11399). scan.rs migrated to parser name-spans: 26 call sites down
to the 2 documented consumers. 114044 spans, 0 unplaced, 0 panics;
UVM code now has hover/definition/references/outline.

lexer-cleanup: the three filed gaps -- @(* ) lexes via a
starts_attribute backoff (an attribute cannot begin with `)`; real
attributes pinned, no misfire on legal expressions), a leading BOM
is accepted as a named losslessness exception (mid-file BOM errors
clearly; 20k-case position fuzz clean), and non-ASCII lex errors now
decode the full character AND surface through vfmt check's error
slot (exit 2, matching format, text-rule findings still reported --
the silent-pass hole closed). The macro space-before-paren item is
parked with a QA-hardened analysis: the reading depends on a
definition vfmt cannot see, any fixed answer is provably wrong for
one population, and today's behavior fails safe.

827 workspace tests. Dev: 2 Fable agents; QA: 2 Opus agents; reviews
in docs/features/{class-semantics,lexer-cleanup}/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-20 00:56:32 -07:00
lucioandClaude Fable 5 da1448ecd0 Add dynamic-types and one-parse (round 19)
dynamic-types: queues ($ as an expression primary -- one grammar
addition and [$], [$:N], q[$-1] all fall out of existing machinery),
dynamic [] and wildcard [*] dims (DimKind, the round's one
non-additive AST change: three consumers, all updated), empty {}
literals, named call arguments f(.a(x)) as ExprKind::NamedArg,
case ... inside with range labels, bare @event sensitivities (also
fixing a pre-existing invented-parens refusal), and macro items
before ident-dot statements. Everything structural, nothing
verbatim; verify.rs and fence.rs byte-identical. Corpus 578 ->
636/820 formattable (70.5% -> 77.6%), parse-error 242 -> 184, 58
gained / 0 lost by path, all 636 round-tripped, all 578 previously-
formattable files byte-compared old-vs-new with zero differences.
Two newly-reachable comment drops fixed in-round (one pre-existing,
one this round's own new code -- split documented honestly post-QA).
New top blockers: interface (25), the `else head-swap (13).

one-parse: LintContext::from_parse accepts pre-built parse products
(Backing enum forced by SourceFile: !Clone; new() stays a one-line
wrapper -- all 12 rule files byte-untouched); ParsedSource::parse
lexes once; vfmt check parses once per file; the server lints from
Document's own products, eliminating the per-keystroke second parse.
Behavior identity proven at the byte level (2.4MB corpus JSON, 13
server publishes, corpus-wide --fix); check --threads 1 20% faster,
server didChange latency roughly halved. protected_regions left
alone per its documented anti-drift signature. Lead fixes on
acceptance: the from_parse contract-cost doc sentence, and a stale-
tree guard test in the server (QA's sabotage passed all 773 tests --
nothing pinned text/tree agreement; now one test does, through the
merged diagnostics path where the stale warning actually lives).

791 workspace tests. Dev: 2 Fable agents; QA: 2 Opus agents; reviews
in docs/features/{dynamic-types,one-parse}/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 20:22:18 -07:00
lucioandClaude Fable 5 7f2e78fc1c Add classes: SystemVerilog class support, corpus 58.0% -> 70.5%
The top corpus blocker (142 extends-blocked UVM/DV files) falls.
Structural support: class/virtual class with parameter ports,
extends (named/ordered params), implements, property qualifiers
(rand/randc/local/protected/static/const), virtual interface
properties, parameterized types, method qualifiers with extern and
pure-virtual prototypes plus out-of-body cls::method definitions,
typedef class, scoped parameterized calls, disable fork. Class
bodies reuse the existing item loop, so Meta, directives, macros and
nesting work with no per-site code. Constraint blocks, covergroups
and parameterized-type #() arguments are span-sliced verbatim leaves
-- their internals are a distinct sub-language where formatting has
no payoff and corruption risk is highest, so 9 masked-corruption
rejection tests ship although verify.rs is byte-identical
(invariant-4 discipline, voluntarily; QA's sabotage recreated the
historical in-string corruption and exactly one pin turned red).

Corpus: 476 -> 578/820 formattable (70.5%), parse-error 344 -> 242,
zero regressions by path, all 578 formattable files round-tripped
individually. 72 of the 142 extends files format; 70 advance to
named next blockers -- queues/dynamic arrays are now the top corpus
blocker (41 files). Two verification failures fixed en route: a
pre-existing lexer blank-line-after-continuation bug (proven
pre-existing on a HEAD worktree) and raw_inline convergence for
mid-line verbatim starts.

Handshakes filed: fences inactive inside class bodies; the four
AST-walking lint rules skip class members (line-based rules still
fire); vlog_semantic treats class bodies as opaque -- the LSP
navigation gap is that crate's natural next round. parse() now takes
the source (verbatim capture in strict mode); single caller updated.

612 workspace tests (397 cases). Dev: Opus agent; QA: Sonnet agent
(pre-feature worktree diff, full 578-file round-trip, UVM torture,
two reverted sabotages); review in docs/features/classes/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 13:45:18 -07:00
lucioandClaude Fable 5 692496fb89 Add directives-in-instances and shared-fence-filter (round 15)
directives-in-instances: `ifdef/`else/`elsif/`endif/`define/`include
now parse between elements of instantiation #() override lists and
connection lists (param_directives on Instantiation, conn_directives
on Instance -- an all-in-arm list is Connections::Ordered(vec![]),
so the vector cannot live inside it; commas stored on Connection and
OrderedConn, never derived). All six named corpus targets format and
converge; no corpus file is blocked on a compiler directive any more
(backtick parse errors 6 -> 0); corpus 476/820 formattable (58.0%),
clean-file external resolution 94.0%. One bug found en route and
fixed: directive_entry overwrote before_sep, dropping a comment
(net-caught; pinned by directives_in_lists.cases:780, sabotage-
verified).

shared-fence-filter: one definition of "which bytes are fenced" --
protected_regions/is_protected in vlog_formatter::fence (the CLI's
scan MOVED in, not copied; grep finds one owner). The CLI filter is
byte-identical (isolated-diff worktrees, 8 shapes, 48 CLI tests
diff-empty); the server's quickfix and fixAll paths now drop fixes
touching protected bytes -- off means hands-off in the editor too.
Sabotage: removing the scan union fails six tests across three
crates. Lead fix: the good-tree test now genuinely pins the collect
path (QA found it only exercised the scan).

(The stale corpus-check-results.tsv two QAs flagged turned out to be
an untracked ignored working file, not a committed one -- deleted
from disk after this commit; it regenerates on every corpus run.)

589 workspace tests. Dev: 2 Opus agents; QA: 2 Sonnet agents;
reviews in docs/features/{directives-in-instances,
shared-fence-filter}/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 12:09:51 -07:00
lucioandClaude Fable 5 6e6aacb392 Add directives-in-lists: ifdef/define/`include between list elements
Roadmap item 6: conditional-compilation directives are now accepted
between elements of port lists, parameter-port lists and enum member
lists, carried as parallel ListDirective vectors (source order via a
before-index; additive AST so vlog_semantic and vlog_linter compile
unmodified) and emitted verbatim. Commas are STORED, never derived:
two real corpus shapes (comma inside the `ifdef arm; no comma at all
in `else alternatives) kill any derivation rule in opposite
directions. A comma printed on a directive's line would be swallowed
into the condition on re-parse -- prevented by a forced break,
sabotage-verified against the safety net.

Corpus: parse-error 352 -> 350 (ibex_core.sv formats), six more
files advance to later blockers -- picorv32.v parses 1986 lines
further but still refuses on restrict property (item 7). The real
payoff is the workspace index: picorv32/_axi/_wb now index
(530 modules, 9174 members), cross-file external resolution
87.0% -> 93.6% on clean files, unresolved externals 2.6% -> 1.3%.
0 verification errors, 0 crashes, verify.rs byte-identical.

563 workspace tests (20 new cases, 9 verification, 7 parser units).
Dev: Opus agent; QA: Sonnet agent (both semantic baselines
reproduced from a detached worktree); review in
docs/features/directives-in-lists/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 11:31:14 -07:00
lucioandClaude Fable 5 3a503e1cf7 Fix comment drops before brackets and attribute/comment reordering
Resolves the owner's comment-drop report (comments-round-2). Three
root causes: (1) a comment between a module header's imports and its
#( landed as the first parameter port's leading comment, printed
inside the brackets -- fixed by take_before_open (the opening-bracket
twin of take_before_sep, no-op unless the cursor is on the bracket)
feeding new bracket-comment slots on Module/Instantiation/Instance;
(2) Meta kept attributes and leading comments in two lists and the
formatter emitted list order, swapping (* attr *) with an adjacent
comment -- fixed by merging on span.start, with the fence check
hoisted so fenced items still emit attrs as source bytes only;
(3) found in the sweep survivors: a lone instance's leading comments
were parsed and never printed (latent invariant-#3 violation).

Acceptance: the reported 14 corpus insertion failures -> 0; the
exhaustive 62k-trial per-line sweep fixed 95 positions with 0 newly
refusing; all 240 survivors are in families already parked by
comments-round and refuse on HEAD too. verify.rs byte-identical
(8 new rejection tests, sabotage-verified); corpus TSV md5
unchanged; fences suite untouched and green. 524 workspace tests.

Dev: Opus agent; QA: Sonnet agent (14/14 reproduced, HEAD-diffed
sweep, attack pass on every new slot); review in
docs/features/comments-round-2/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 10:47:20 -07:00
lucioandClaude Fable 5 1ac9746c45 Add workspace-index and name-spans (jointly: round 10)
workspace-index (vlog_semantic): cross-file resolution -- the
owner's `import pkg::*;`-anywhere requirement delivered.
WorkspaceIndex maps modules/packages/file-scope typedefs, package
exports, module ports/params and per-file define tables; built
tolerantly (broken files still contribute), deterministic by
construction (FileIds assigned after path sort). resolve_external
answers ExternalCandidates in a two-layer overlay keyed by
ReferenceId -- Semantics stays a pure single-file fact; local
declarations outrank imports. Corpus: 87% of external candidates
answered (external rate 19.6% -> 2.6% on clean files), ambiguity
kept honest (OpenTitan prim_generic/prim_xilinx), 0.7s build,
workspace_symbols substring search.

name-spans (vlog_parser): the approved vlog-semantic handshake --
the parser records every declared name's span at parse time (28
fields across 21 node kinds; Name/ImportPath bundles where parallel
Vecs could desync; ImportPath splits p::x for the index). Content-
pinned by the exhaustive walker on every source, mutation-tested
three ways, zero behavior change (corpus md5 exact, QA byte-compared
formatter output against a HEAD worktree). scan.rs is now one
consumer away from deletion (DataType span, handshake item 2).

TODO §6 foundations complete: spans, error recovery, define table,
single-file semantics, workspace index. Next: vfmt_server.

Dev: 2 Opus agents; QA: 2 Sonnet agents; reviews in
docs/features/{workspace-index,name-spans}/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 07:09:04 -07:00
lucioandClaude Fable 5 982e37063b Add comments-round: close the comment-attachment gaps
Meta.trailing is now Option<Comment> (line/col/span — delivers the
format-fences handshake; same-line fences stay deliberately inert),
and Meta::before_sep keeps a comment on its element's side of the
separator across every list kind, including the closing-bracket
buckets. take_before_sep is a no-op unless the cursor is on the
separator, which is why all 299 pre-existing cases stayed
byte-identical. Also fixes: EnumType::dangling comments parsed but
never printed (a latent invariant-#3 violation), the double-blank
between leading comments (six corpus files became fixed points), and
five documented expression refusals (replication interior,
compact-bracket operator position, assign-value, concat brace,
header imports via HeaderImport).

Reproducible acceptance metrics (HEAD-worktree control): line-
position comment injection refusals 2.3% -> 0.4%; exhaustive gap
probe 90 -> 22 refused; delimiter-position 61% -> 36%. Remaining
parked positions documented. verify.rs byte-identical; +7 rejection
tests; corpus 0 verification errors, 0 crashes, parse 468/820.

229 workspace tests, clippy silent. Dev: Opus agent; QA: Sonnet
agent (sabotage-verified pins, independent probes); review in
docs/features/comments-round/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 06:11:53 -07:00
lucioandClaude Fable 5 0ba29d4635 Add define-table: record every `define for LSP hover expansion
collect_defines() is a post-lex pass over Directive tokens (zero
lexer changes) building an ordered DefineTable: name, params (as
written, defaults included), body normalized exactly as a
preprocessor joins continuations (backslash-newline removed, every
other byte preserved -- string values survive), span and name_span.
Redefinitions and `undef events are all recorded in source order
(latest()/all()); position-aware resolution is deliberately left to
the future hover implementation, which needs the history.

Pure data feature: no behavior change anywhere. 24 tests including
mutation-testing of the normalization rule against alternatives that
would rewrite string values. QA swept 502 defines from the corpus
with zero span/name mismatches and hand-verified prim_assert.sv
macros; CRLF continuations confirmed at lexer and table layers.

TODO §6 data foundations now complete (spans, error recovery,
define table).

Dev: Opus agent; QA: Sonnet agent; review in
docs/features/define-table/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 05:39:56 -07:00
lucioandClaude Fable 5 02f68655b5 Add error-recovery and format-fences (jointly: entangled in format.rs)
error-recovery (vlog_parser): parse_source_tolerant never fails —
errors become positioned ParseDiagnostics and ItemKind::Error /
StmtKind::Error leaves (raw text + span, nesting invariant intact),
with recovery at documented sync tokens, bracket-balanced skipping,
and stray-closer collapse. Strict parse_source is byte-identical in
behavior (shared grammar, tolerant flag). Guarantees tested:
tolerant==strict on 500 valid sources; depth/links budgets neither
reset nor leak across recovery (mutation-tested); no panic across
27k+ truncation cuts, every single-char fixture deletion, 1MB of
semicolons (500k recoveries, 344ms). The future LSP parses mid-edit
code; the formatter still refuses on the first error.

format-fences (vlog_formatter): // verilog_format: off|on and
// vfmt: off|on emit fenced item ranges as exact source bytes via
spans (Doc::Verbatim), Verible-style item-level regions per scope,
unmatched off to end of scope, byte-exact including indentation and
idempotent at every join (24 adversarial probes). ~2000 corpus fence
injections: zero region byte changes, zero new verification
failures. verify.rs untouched; with no fences output is
byte-identical (corpus TSV md5 unchanged).

Also surfaced and queued in TODO: comment-in-list refusals
(112/1868 injection trials) and the double-blank leading-comment
nit — the next comments round.

Dev: 2 Opus agents; QA: 2 Sonnet agents; reviews in
docs/features/{error-recovery,format-fences}/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 05:23:05 -07:00
lucioandClaude Fable 5 901a78ccb2 Add spans: byte ranges on every token and AST node, plus LineIndex
The LSP cornerstone (TODO §6) and the prerequisite for format-off
fences and range formatting. Convention: node span = code extent
(first to last token; attributes included, comments excluded and
carrying their own spans) — chosen because it makes child-nests-in-
parent a total, assertable invariant. Expr became {kind, span};
element structs carry spans; payload structs whose extent equals
their wrapper's deliberately don't (one fact, one place). LineIndex
maps offset <-> 1-based line:col in UTF-8 bytes, with clamping.

A token-level losslessness test asserts every source byte is covered
by token/trivia spans (whitespace aside) and concatenation
reconstructs the input — it immediately surfaced and documented two
pre-existing lexer normalizations (sized-literal tick spacing,
merged same-line trailing comments), both whitespace-only.

Zero behavior change, proven: corpus TSV md5-identical, and QA
diffed formatter output on all 820 corpus files against a pre-spans
worktree binary — no differences. Mutation-tested by dev and QA;
one unpinned span QA found (GenIf content) is now pinned by a
lead-added slice test. 161 workspace tests.

Dev: Opus agent; QA: Sonnet agent; review in
docs/features/spans/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 04:44:51 -07:00
lucioandClaude Fable 5 dc2181e1a2 Fix the four corpus-found formatter bugs: 46 verification errors -> 0
Every fix makes the AST carry a fact the formatter used to invent or
discard: SensSep preserves each event-list separator as written
(, stays , / or stays or, mixed lists round-trip); module-header
imports keep one statement per import; Instantiation::params and
Module::param_ports become Option<Vec> so empty #() survives; and
seven distinct comment-motion shapes (closing paren, empty
connection, declarator-to-;, after binary operator, case labels,
ternary, assign-to-value) keep comments where the source put them,
with Fmt::inline_comments as the single comment-run printer.

verify.rs is byte-identical: the net was right on all 46 refusing
files. Seven new rejection tests pin that judgment (sabotage-checked
by QA). Also removes a latent split_off underflow panic
(Parser::take_around) that QA reproduced on the pre-fix binary, and
fixes the ternary comment refusal from the earlier bug round.

Corpus after: 468/820 parse, 0 verification errors, 0 crashes —
corpus_check.sh exits 0 for the first time. Exactly 46 files moved
verification-error -> would-reformat by path diff; nothing else
changed. 111 workspace tests (was 98), case table 237 entries,
clippy silent.

Dev: Opus agent; QA: Sonnet agent (all claims independently
reproduced); review in docs/features/corpus-bugs/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 04:07:58 -07:00
lucioandClaude Fable 5 3325905f21 Add macro-items: macro invocations at item/statement position
The corpus-measured #1 blocker (~60% of RTL parse errors). Macro
invocations (`NAME, `NAME(args), optional trailing ;) now parse
wherever a module item or statement can appear; the invocation is an
AST leaf (MacroCall{RawText, semi}) emitted verbatim with column-
aware re-indent, semicolon reproduced only if written. Disambiguation
is safe by construction: both readings emit identical token streams.
The lexer's balanced-arg scan is hardened (strings, comments, 256-cap
nesting counter, iterative). Corpus parse rate: 35.2% -> 57.1%
(179 files gained, 0 regressed).

Round 1 was rejected in review: QA proved the new verify.rs
normalization could mask real corruption -- a string literal spanning
lines inside a macro arg had its bytes changed by re-indent, with
exit 0. The rework widened the finding to `define bodies and
attributes (same pre-existing defect, same shared root) and fixed
both sides: line_starts_inside_string, a lexer-mirroring scanner, is
the single shared definition of "which line breaks are data" -- the
verifier trims only outside strings, and the formatter emits any
token with an in-string line break fully verbatim (idempotent by
construction). Re-QA attacked the scanner on ten edge shapes and
found no hole; corpus TSV byte-identical pre/post fix.

Process consequence, codified as CLAUDE.md hard-invariant #4: any
widening of verify.rs forgiveness ships with masked-corruption attack
tests, dev-written and QA-re-attacked.

Dev + rework: Opus agent; QA + re-QA: Sonnet agent; full history in
docs/features/macro-items/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 03:22:13 -07:00
lucioandClaude Fable 5 a49131fc5f Add recursion-limit: bounded parser depth and AST chain length
Two budgets, both measured rather than guessed: MAX_NESTING_DEPTH=64
gates the five recursion cycles in the parser (debug frames run to
~50KB; 64 peaks at ~3.9MiB against the 8MiB stack), and
MAX_CHAIN_LENGTH=256 charges postfix segments and binary/inside
operators, whose loops deepen the AST without parser recursion.
Restore-by-assignment makes the chain budget correct on every early
return. Invariant: AST depth on any root-to-leaf path <= 64+256,
so the formatter's structural recursion is bounded too.

Deep or chain-heavy inputs now get a clean "nesting too deep" /
"expression chain too long" parse error with position, exit 2, batch
unaffected -- replacing an uncatchable stack-overflow abort that
killed whole runs (3KiB of a.b.b... sufficed before).

Round 1 was rejected in review: QA found postfix chains ungated and
the leak test unable to detect missing releases (proven by sabotage).
The rework widened the finding to binary/inside chains, added the
second budget, and made leak tests sabotage-complete (7/7); re-QA
attacked the additive-composition invariant and found no hole, with
no acceptance regressions (128-term sums, 10k statements still fine).

Dev + rework: Opus agent; QA + re-QA: Sonnet agent; full history in
docs/features/recursion-limit/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 01:20:38 -07:00
lucioandClaude Fable 5 9f1a6cf1d2 Fix six formatter bugs; case table grows to 200 with zero skips
All five briefed bugs fixed, plus a sixth found during the work:

1. Block-comment continuation drift: token::Comment gained line/col;
   continuation lines are dedented by the comment's original column
   before re-indenting, making reformatting a true fixed point while
   preserving the author's relative indentation inside the comment.
2. Comments inside expression groups (concat, parens, call args,
   assignment patterns, binary operands) now force the group to break
   instead of being lifted out.
3. Closing block labels preserved for end/join*/endfunction/endtask/
   endpackage, matching endmodule.
4. Multi-instance declarations fit on one line when they fit and
   indent their continuations when they break.
5. @( /* c */ * ) keeps its comments (SensList::Star before/after).
6. Multi-line `define/attribute bodies no longer drift (RawText.col).

verify.rs comparison logic untouched (diagnostic positions only) —
QA audited the diff to confirm the safety net was not weakened.
All four #SKIP cases un-skipped verbatim as spec; 17 cases added
(183 -> 200, 0 skipped). QA triple-formatted 204 inputs with zero
regressions. Clippy is now fully silent workspace-wide.

Remaining comment-placement refusals (4) and a pre-existing @(* )
lexer limitation are documented as open items, not hacked around.

Dev: Opus agent; QA: Sonnet agent; review in
docs/features/formatter-bug-fixes/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 00:15:50 -07:00
lucioandClaude Fable 5 d2cd44c428 Normalize whole tree with cargo fmt under rustfmt.toml
One-time mechanical pass; no behavior change (full test suite green
before and after). From here on, cargo fmt --check is the standard.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-18 23:41:18 -07:00
lucioandClaude Fable 5 d3d9786791 Initial commit: vfmt — ruff-style Verilog/SystemVerilog formatter
Workspace with comment-preserving parser (vlog_parser), prettier-style
document IR + formatting rules (vlog_formatter), and CLI (vfmt).
Includes snapshot/idempotency tests and a TODO backlog of practices
adopted from ruff and Verible.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-18 23:12:01 -07:00