12 KiB
12 KiB
Round 6 — Formatter Alignment Completeness, lowrisc Fidelity, Selective [format] Overrides, and Full Cache Keying
Note
Live working note. Final gate and OpenTitan sweep results are recorded under QA log after the last verification pass.
Goal
Close four remaining formatter/configuration gaps in Round 6 without touching parser/linter semantics, without weakening safety-net invariants (CLAUDE.md #1, #2, #4), and keeping every modified production .rs file within <= 600 non-blank non-comment production lines:
- Alignment completeness for
#(...)module/interface parameter ports and#(...)named parameter overrides: alignModule::param_ports(PARAM_PORT_COLS) andInstantiation::params(connection_cols) cleanly under bothAlignment::InferandAlignment::Always, preserving single-row / comment / directive / attribute / continuation / no-default / budget-overflow splits and leavingclassparameter headers (classes.cases) untouched. lowriscfidelity (connection_align_min = 0): addconnection_align_min: usizetovlog_formatter::Style(0forlowrisc,1forlucisv,google,ansi,microsoft,nxp), aligning the widest named connection / parameter override tight (.long_port(sig)), while still padding narrower entries to the aligned(column cleanly and keeping fixed-point convergence under bothAlwaysandInfer.- Selective
[format]overrides on top of named presets (Owner Decision #5): allow explicit per-knob overrides (begin,else,else-after-label,port-lists,list-indent,alignment,connection-align-min) inlucisv.toml[format], VS Code settings (editors/vscode/package.jsonlucisv.format.*),lucisv_server,lucisv_mcp, andlucisvCLI — layering over any active named preset and over every competing preset understyle = "auto". - Full
lucisv_core::cache::Entryserialization: record every effective formatting knob (content,line_length,indent,uvm_utils_indent,style,begin,else_keyword,else_after_label,port_lists,list_indent,alignment,connection_align_min) in.lucisv_cache/cache(14-field format), invalidating in both directions on any[format]toggle (including un-overridden vs explicitly overriddenauto) and dropping older 5-/6-/7-field cache lines individually as stale.
Exact Preset Table
| style | indent | width | begin |
else |
else_after_label |
port_lists |
list_indent |
alignment |
connection_align_min |
|---|---|---|---|---|---|---|---|---|---|
lucisv (default) |
2 | 100 | same-line |
same-line |
same-line |
fit |
block |
infer |
1 |
google |
2 | 100 | same-line |
same-line |
own-line |
one-per-line |
wrap |
infer |
1 |
lowrisc |
2 | 100 | same-line |
same-line |
own-line |
one-per-line |
block |
always |
0 |
ansi |
4 | 80 | own-line |
own-line |
own-line |
fit |
block |
infer |
1 |
microsoft |
4 | 120 | own-line |
own-line |
own-line |
one-per-line |
block |
infer |
1 |
nxp |
2 | 80 | same-line |
own-line |
own-line |
one-per-line |
block |
always |
1 |
Assumptions
lucisv_coreremains zero-dependency (Cargo.toml); enum string tables (PLACEMENT_NAMES,PORT_LISTS_NAMES,LIST_INDENT_NAMES,ALIGNMENT_NAMES,CONNECTION_ALIGN_MIN_{MIN,MAX}) live inlucisv_core::configand are cross-checked againstvlog_formatterinlucisv::args::testsand againsteditors/vscode/package.jsoninlucisv_server::settings::tests.ClassDecl::param_portsandextends #(...)stay unaligned (class.rs), preserving existingcases/classes.casesexpectations.ParamPortalignment uses 2 columns[ColSpec { flush: 1, min: 1 }, ColSpec { flush: 1, min: 1 }](type/kw prefix, parameter name + unpacked dims,= default) matchingPARAM_DECL_COLS, and falls back to 1 unaligned cell whenkw/is_type/tyare all empty,defaultisNone, or inline gap comments / attributes exist.- Under
style = "auto", un-overridden per-knob cache fields serialize as"auto"(Noneforconnection_align_min) so toggling e.g.[format] begin = "same-line"on top ofstyle = "auto"still misses cached entries recorded under plainstyle = "auto". connection-align-minallows integer bounds0..=8in bothlucisv.tomland VS Code settings.
Handshakes
vlog_formatter::style::{Style, StyleOverrides, Placement, PortLists, ListIndent, Alignment}<->lucisv_core::config::FileConfig: string spelling lockstep verified inlucisv::args::tests::the_core_format_override_choices_match_the_formatter.vlog_formatter::auto::{format_auto, resolve_style, resolve_concrete}<->lucisv_server::auto_style::AutoStyles:fixed(...)appliesconfig.overridesonto candidate presets, andAutoStyles::concreteresolves the base preset bypreset.namebefore re-applying currentconfig.overrides.lucisv_core::cache::Entry(14 fields) <->lucisv::main::entry_for: all 12 formatting keys +VERSION+pathwritten/parsed strictly, older 5-/6-/7-field lines discarded individually.editors/vscode/package.json(lucisv.format.*) <->lucisv_server::settings::ClientSettings<->lucisv_server::format::config_from:lucisv.tomloutranks pushedClientSettings, which outranks editor tab options and preset defaults.
Status / TODO
Module::param_portsandInstantiation::paramsalignment (Infer&Always)Style::connection_align_min(lowrisc=0, others =1) andtests/styles.rsalignmentStyleOverrides+Config::{apply_overrides, with_overrides, effective}+autolayeringlucisv_core::configstrict[format]override keys & validationlucisv_core::cache::Entryfull 14-field keying & legacy 5/6/7-field staleness handlinglucisvCLI,lucisv_mcp,lucisv_server, andeditors/vscode/package.jsonwiring- Final verification gates (
fmt,stamp_author,clippy, workspace tests,gates.sh, OpenTitan sweeps)
Work log
- Added
StyleOverrides,Placement/PortLists/ListIndent/Alignmentparse & string helpers, andStyle::connection_align_min(0forLOWRISC,1for others) incrates/vlog_formatter/src/style.rs. - Wired
Config::overridesandeffective()throughcrates/vlog_formatter/src/{lib.rs, auto.rs, format/mod.rs}so concrete presets,auto,--lines, and selection formatting all honor overrides cleanly. - Implemented
#(...)header parameter port alignment (PARAM_PORT_COLS, reusingdecl::eq_offset) incrates/vlog_formatter/src/format/module.rsand#(...)named parameter override alignment +connection_cols(min = connection_align_min) incrates/vlog_formatter/src/format/instance.rs. - Extended
lucisv_core::config::FileConfig(begin,else,else-after-label,port-lists,list-indent,alignment,connection-align-min) andlucisv_core::cache::Entry(14 tab-separated fields, 5/6/7-field legacy lines individually dropped as stale). - Wired override layering into
crates/lucisv/src/{args.rs, main.rs},crates/lucisv_mcp/src/tools/format.rs,crates/lucisv_server/src/{settings.rs, format.rs, auto_style.rs}, andeditors/vscode/package.json. - Updated
README.mdnamed-styles note forlowrisctight.clk(clk).
QA log
- Round 6 QA Verdict: PASS (adversarial audit of uncommitted changes on
4cf50a0). - Invariants & code hygiene:
- Production LOC before
#[cfg(test)]/mod testsacross all touched.rsfiles (<= 574, ceiling600;crates/lucisv/src/main.rs= 574,crates/vlog_formatter/src/format/stmt.rsuntouched = 570,crates/vlog_formatter/src/format/module.rs= 467,crates/lucisv/src/args.rs= 456,crates/vlog_formatter/src/format/instance.rs= 388,crates/vlog_formatter/src/format/decl.rs= 381,crates/lucisv_core/src/config.rs= 352,crates/lucisv_server/src/settings.rs= 295,crates/vlog_formatter/src/format/mod.rs= 293,crates/vlog_formatter/src/style.rs= 223,crates/lucisv_core/src/cache.rs= 221,crates/lucisv_mcp/src/tools/format.rs= 168,crates/lucisv_server/src/format.rs= 139,crates/vlog_formatter/src/auto.rs= 128,crates/lucisv_server/src/auto_style.rs= 57,crates/vlog_formatter/src/lib.rs= 16). - Zero
.unwrap(),.expect(),panic!, orunsafein non-test production code acrosslucisv_core,lucisv,lucisv_server,lucisv_mcp, andvlog_formatter. - Non-blocking observations:
FileConfig -> StyleOverridesconversion is repeated inlucisv/src/args.rs,lucisv_mcp/src/tools/format.rs, andlucisv_server/src/format.rs(alongsideoverrides_from_client) due tolucisv_core's zero-dependency boundary;--help(args.rs) and rootREADME.mdConfig/Cache sections only namestyleanduvm-utils-indent.
- Production LOC before
- Adversarial technical checks:
- Alignment (
#(...)param ports/overrides,connection_align_min: 0vs1,InfervsAlways, single-item.p(v)/#(.P(v)),.Pimplicit params, positional#(1), escaped identifiers, inline gap comments,`ifdefsplits, multi-instance#47underlowrisc, unpacked dims +typeparams + continuation params): verified fixed-point idempotency and exact behavior. - Selective
[format]& editor overrides (editors/vscode/package.json<->ClientSettings<->lucisv_server<->lucisv_mcp<->lucisv): schema, enum/null/range validation (0..=8),lucisv.toml > ClientSettings > tabSize > preset,auto+ overrides +AutoStylescache invalidation/reapplication verified. - Cache keying (
lucisv_core::cache::Entry14-field format &main.rs::entry_for): verified bidirectional invalidation acrossconnection-align-min(0 <-> 1underlowrisc),else-after-label(own-line <-> same-lineundergoogle),style = "auto"un-overridden vs overridden, individual drop of legacy 5/6/7-field rows, and wholesale discard on corrupt lines.
- Alignment (
python3 tools/stamp_author.py --check: pass (249 untouched,0missing stamps)../tools/gates.sh(all 17 steps, logtarget/gates/20261126-145646): PASSstamp,fmt,clippy,build,cross: pass (0warnings/errors).suite:vlog_parser(527/0),suite:vlog_semantic(438/0),suite:vlog_refactor(769/0),suite:vlog_formatter(383/0),suite:vlog_linter(672/0),suite:lucisv_core(123/0),suite:lucisv(162/0),suite:lucisv_server(2195/0),suite:lucisv_mcp(399/0),docs(1/0): all pass.corpus: pass (814/820,99.3%,0verification errors).node: pass (37/0).
- Release
target/release/lucisv(/Users/lucio/repo/opentitan/hw, tested in/tmpscratch copies;/Users/lucio/repo/opentitanverified clean viagit status --porcelain):- Default (
--no-config):3967 reformatted, 72 left unchanged, 7 failed(4,039/4,046,0verification errors); pass 2--check:4039 unchanged,0would reformat. --style lowrisc(--no-config):3976 reformatted, 63 left unchanged, 7 failed(4,039/4,046,0verification errors); pass 2--check:4039 unchanged,0would reformat.--style auto(--no-config):3967 reformatted, 72 left unchanged, 7 failed(4,039/4,046,0verification errors); pass 2--check:4039 unchanged,0would reformat.- Selective
[format]overrides (style = "google",begin = "own-line",else = "own-line",else-after-label = "same-line",port-lists = "one-per-line",list-indent = "block",alignment = "always",connection-align-min = 0):3985 reformatted, 54 left unchanged, 7 failed(4,039/4,046,0verification errors); pass 2--check:4039 unchanged,0would reformat.
- Default (
Review
Lead Self-Inspect (2026-11-26): APPROVED for trunk commit.
- Production LOC invariant verified across all modified
.rsfiles (<= 574prod LOC before#[cfg(test)], ceiling600;format/stmt.rsuntouched at 570). - Zero
.unwrap(),.expect(),panic!, orunsafein non-test production code across modified files. - Verified Round 6 QA PASS across all 17
./tools/gates.shsteps (5,668Rust tests passed,1doc,814/6corpus,37/0node,cross,stamp) and all 4 OpenTitanhw/sweeps (default,lowrisc,auto, selective overrides — each4,039/4,046with0verification errors and 100% pass-2 idempotency). - OpenTitan repository
/Users/lucio/repo/opentitanverified clean (git status --porcelainempty).