29 KiB
lucisv-core-lift
Goal
The CLI and the language server were answering two different questions with
two different pieces of code: lucisv discovers lucisv.toml and walks a tree
honoring .gitignore and --exclude, while lucisv-server formatted with
built-in defaults and indexed everything it could find, because both rules
lived inside the lucisv binary crate where nothing else could reach them
(the two Handshake requests filed by docs/features/lucisv-server/README.md).
That is the classic way an editor's format-on-save drifts away from CI's
lucisv --check. This round lifts config.rs and walk.rs — unchanged — into
a new std-only library crate crates/lucisv_core, re-points the CLI at it with
no behavior change at all, and wires the server through the same code: one
discovery rule, one walk, two front ends.
Assumptions
- The lift is mechanical, and is proven mechanical. Both modules moved as
100% renames (
git diff -Msays so) — not one line of logic, and not one line of their 31 unit tests, was edited. The modules kept their names inside the new crate, so even the import paths in the moved tests (use super::*) needed no change. Everything the CLI does is therefore unchanged by construction, and the untouchedcrates/lucisv/tests/cli.rs(48 tests) plus a byte-identical 820-file corpus (count corrected by lead per QA) run are the evidence. lucisv_coreis two modules, not a framework.pub mod config; pub mod walk;and nothing else — no re-export layer, no new traits, no configuration struct invented for a third caller that does not exist. The crate has no dependencies, std only, as both modules already did.- Precedence in the server is
lucisv.toml> the client'stabSize> the built-in default, which is deliberately not the CLI's--flag > config > default. The CLI's flag is typed by a human for one run, so it outranks a file.FormattingOptions::tab_sizeis not that: LSP requires the client to send it on every formatting request, and what it sends is the editor's own default (VS Code'seditor.tabSize, 4 unless changed) or its guess from the file's existing indentation. Treating an editor default as a deliberate override would let an unconfigured editor silently beat a checked-inlucisv.toml— reintroducing exactly the CLI/editor divergence this feature exists to delete, and making format-on-save fightlucisv --checkin CI. Where the config file is silent,tabSizestill beats the built-in default, so a project with nolucisv.tomlbehaves exactly as the server did before this round.line-lengthhas no client analog at all and comes from the config file or not at all. - A broken
lucisv.tomlwarns the editor; it does not fail it. The CLI's contract for an unparsable config is fatal: exit 2, nothing written, all configs resolved before any file is touched (docs/features/config-discovery/README.md). That is right for a batch tool where a half-applied run is the danger. It is wrong for an editor: a user who types a typo intolucisv.tomlin one tab must not find that format-on-save has stopped working in every other tab, with an error where their code should be. So the server formats with the built-in defaults (never a partial mix of the broken file's keys — nothing at all is taken from a file that failed to parse) and reports the problem as awindow/showMessagewarning carrying the samepath:line: messagestring the CLI would have printed. This is a deliberate divergence in reporting, not in discovery: the file searched for, the rule that finds it, and the settings taken from it when it parses are identical. - The warning is said once per file change. A format-on-save loop asks to
format on every save; repeating the same config error forever would train the
user to dismiss lucisv's messages. The server remembers which documents it has
warned about and re-arms a document when its text changes (
didOpen,didChange,didSavewith text) or when it is closed. - The index scan anchors its excludes on the workspace root.
excludeis resolved once per command-line input in the CLI, never mid-walk (config-discovery's own assumption); the server's analog of "an input" is a workspace root, so the config governing the root supplies the exclude patterns for that root's whole scan. Alucisv.tomlin a subdirectory still governsline-length/indentfor files under it when they are formatted — discovery there is per-document — it just cannot add excludes mid-scan, exactly as in the CLI. .gitignoreis always honored by the scan. It is the CLI's default and an editor has no--no-gitignoreto type. Likewise the scan always runs discovery enabled: there is no--no-configin an editor.- A broken config does not stop the scan. During
initializethere is no good way to refuse: a server that indexes nothing because of a typo simply looks broken. The scan proceeds with no excludes, and the same error reaches the user through the formatting path, which is where they will look. - The server's walk-depth cap is gone, deliberately. The old plain walk
capped recursion at 64 directories to survive a symlink cycle; the lifted
walk has no cap, because the CLI's does not. Keeping the cap would mean the
index silently covering fewer files than
lucisvformats — the divergence this round exists to remove — and adding a cap to the shared walk would silently drop deep files from CLI runs, which is a behavior change this mechanical lift must not make. Cycle detection belongs in the shared walk where it would protect both front ends; recorded as a follow-up below, not smuggled in here. - Untitled buffers get no config. A buffer with no path has no directory to
search from, so it is formatted with
tabSize-or-defaults, as before. - Discovery is rebuilt per formatting request.
Discovery's cache is per-instance and the server is long-lived, so a cached answer would go stale the moment a user editslucisv.toml. A freshDiscoveryper request costs one file read on an explicit, user-initiated action — cheaper than any invalidation scheme that could be wrong. (config-discovery's Handshakes anticipated exactly this: "a server can drop and rebuild one when a config file changes on disk".)
Handshakes
- New crate
lucisv_core, consumed bylucisvandlucisv_server. Public surface, unchanged from what it was insidecrates/lucisv:lucisv_core::config:FileConfig { line_length, indent, exclude },parse(&str) -> Result<FileConfig, String>,Discovery::{new, for_input, for_file, for_dir}.lucisv_core::walk:EXTENSIONS,collect_files(input, exclude, gitignore, &mut Vec<PathBuf>) -> Result<(), String>,is_excluded(&Path, &[String]). Every item already carried the one-line doc comment CLAUDE.md asks for; no signature changed, so no crate-public boundary moved in a way that needed a new one. The rules themselves stay documented where they were:docs/features/config-discovery/README.mdanddocs/features/parallel-files/README.md.
crates/lucisvconsumeslucisv_coreand keeps nothing of its own: the two modules are gone from itssrc/,mod config;/mod walk;are gone frommain.rs, and the three call sites now saylucisv_core::…. No duplicated logic was left behind.- Discharges both Handshake requests filed by
docs/features/lucisv-server/README.md(items 1 and 2, config discovery and the ignore-aware walk). Both are annotated DELIVERED in that README, one line each, as the only edits made to another feature's document. - Request to the lead — stale prose in
docs/features/lucisv-server/README.mdandTODO.md, deliberately not edited here (out of this feature's stated scope, and a concurrent editor-packaging round is live in the same files):- lucisv-server README, Assumptions: "The workspace walk is plain …
.gitignoreand--excludeare not honored" and "lucisv.tomlis not discovered … The server usesConfig::default()… with the client's tab size overriding the indent" are both now false, and the tab-size sentence is contradicted by the precedence decided above. - lucisv-server README, Status/TODO: "Not done:
lucisv.tomldiscovery,.gitignore-aware indexing — both blocked on the two Handshake requests above" is now done. TODO.md:103andTODO.md:120point atcrates/lucisv/src/config.rsandcrates/lucisv/src/walk.rs; both files now live incrates/lucisv_core/src/.docs/features/spans/README.md:308names the old config path in a work-log sentence about a concurrent round — historical, best left alone.
- lucisv-server README, Assumptions: "The workspace walk is plain …
- Follow-up for whoever next touches
lucisv_core::walk: the walk has no symlink-cycle detection (a depth cap, or device+inode tracking). It never had; the CLI has always been exposed to it, and the server now shares the exposure since its own 64-directory cap was removed for parity. Fixing it in the shared walk protects both front ends at once — but it changes CLI behavior (deep trees, cyclic links), so it wants its own round with its own tests, not a quiet addition inside a mechanical lift. TODO.md: no matching checkbox. The §3 config and.gitignoreitems and the §6lucisv_serveritem are already checked; this round moves code and wires the server, and adds no item of its own. Nothing was checked off.
Status / TODO
crates/lucisv_corecreated with a compiling skeleton first, built standalone, and only then added to the rootmembers(round 11's ordering lesson, taken literally).config.rsandwalk.rsmoved as 100% renames, unit tests and all.crates/lucisvre-wired tolucisv_core(Cargo.toml,main.rs,args.rs); no logic left behind, no CLI behavior change.- Server formatting discovers
lucisv.tomlanchored at the document's own path, by the CLI's rule. - Precedence
config > tabSize > built-in default, decided and documented. - Broken config → one
showMessagewarning per file change, formatting proceeds with defaults, never a crash and never a partial config. initialize's scan uses the lifted walk: same extensions,.gitignorehonored, excludes from the workspace root's config.- Tests:
lucisv_coreinherits its 31 moved unit tests; server gains 8 unit tests (config-beats-tabSize,lucisv.tomlgoverning a real buffer, broken config, untitled buffer, gitignore-honoring scan, root-config excludes, broken root config, extension filter) and 2 e2e tests through the real binary over stdio. - Both lucisv-server Handshakes annotated DELIVERED.
- Gates:
cargo test --workspace,cargo clippy --workspace --all-targets,cargo fmt --all --check, corpus check. - Not done, deliberately: symlink-cycle detection in the shared walk (see Handshakes — a real behavior change, wants its own round).
- Not done: re-resolving
excludeper directory during a scan. The CLI does not either; the two agree, which is the point of this round. - Not done: watching
lucisv.tomlfor changes (workspace/didChangeWatchedFiles). Discovery is re-run per formatting request, so an edited config takes effect at the next format without it.
Work log
2026-08-19 — dev agent
- Read
CLAUDE.md, the two Handshake requests indocs/features/lucisv-server/README.md, all ofdocs/features/config-discovery/README.mdand the behavior half ofdocs/features/parallel-files/README.md(both QA logs included), andcrates/lucisv/src/{config,walk,main,args,lint}.rsbefore writing anything. - Ordering lesson taken literally.
crates/lucisv_corewas created with a literal-versioned manifest carrying an empty[workspace]table — making it its own workspace — the two modules weregit mv'd in, andcargo testwas run standalone (31 passed) before the rootmembersentry existed. Only then was the manifest switched toversion.workspace = trueand the members line added. Amembersentry pointing at a crate that does not build breaks the workspace for every other agent in the tree, and the editor-packaging round was live in it. - The lift is provably mechanical.
git diff -M --summaryreports both moves as(100%). The 31 unit tests moved with their modules and did not need even an import-path edit, because the modules kept their names. The brief allowed edits to those imports; none were required. - Behavior preservation, measured rather than asserted.
crates/lucisv's unit count is unchanged in total (58 = 27 that stayed + 31 that moved), andcrates/lucisv/tests/cli.rs— 48 CLI integration tests — is byte-untouched and green. Then the strongest check available: a releaselucisvbuilt from a cleangit worktreeatHEADand the working-treelucisvwere both run over the 820-file corpus (count corrected by lead per QA), and their per-file TSVs are byte-identical (diffsilent; verification-error: none, crash: none in both). The committedcorpus-check-results.tsvin the repo predates several landed rounds and was not touched — it is stale againstHEADitself, which the HEAD-vs-working comparison isolates cleanly. - The precedence decision was the one real design call, and it goes against
the CLI's shape on purpose. Reasoning is in Assumptions above; the short
version is that LSP forces the client to send
tabSizeon every request, so it is a default, not an intent, and a default must not beat a file a human checked in. The rule is pinned bya_config_file_beats_the_editors_tab_size(unit) and bya_lucisv_toml_governs_formatting_over_the_editors_tab_size(e2e: the client asks fortabSize: 2, the config saysindent = 4, the wire carries four spaces). - Split
format::formattingin two rather than letting it talk to the connection:settings_for(doc, options) -> Settings { config, problem }resolves,formatting(doc, &config)formats. The handler inserver.rscomputes both, then warns, which also keeps the immutable borrow of the document from colliding with the&mut selfthe warn-once set needs. - Warn-once is a
HashSet<Uri>onServer, cleared by a newServer::set_documentwrapper that every text-changing notification now goes through, and ondidClose. The e2e test sends two formatting requests with no edit between them and asserts exactly onewindow/showMessagearrives on the wire — the assertion that would catch a regression here, since a per-request warning would pass every unit test. state.rs's hand-rolled walk is deleted, not wrapped:MAX_WALK_DEPTH,SOURCE_EXTENSIONS,walk()andis_source()are gone, replaced bycollect_files. Its unit testthe_walk_finds_only_source_extensionstested a now-private-elsewhere helper, so it was replaced bythe_scan_takes_only_source_extensions, which asserts the same thing one level up — through a real scratch directory and the resulting index — and so survives the next refactor.- The new scan tests use the index as the observation point (does
WorkspaceIndex::memberknow this package?) rather than reaching for the private file list, so they pin the behavior a user sees. - The format unit tests that need a real tree write a
.gitmarker into their scratch directory. That stops the upward discovery walk at the temp dir, so alucisv.tomlin some real ancestor of/tmpcan never leak into a test result — the.git-stops-the-walk rule config-discovery documents, used as a test-hermeticity tool. - Two clippy fixes on the way through, both in the e2e test:
&PathBuf→&Pathin the new session helper, and the original test's inline spawn/write/read block replaced by the sharedtalk()helper it now needs anyway. No#[allow]was added anywhere. - No
unwrap/expect/panic!outside#[cfg(test)]in any file touched: the scan swallows a config error withunwrap_or_default()and a walk error withlet _ =, both with a comment saying why refusing would be worse. - Did not touch
editors/**, rootREADME.md,TODO.md, the corpus TSV, or any engine crate (vlog_parser,vlog_formatter,vlog_semantic,vlog_linterhave no diff at all). Did not rungit commit/git push.
Results (settled tree, all re-run at the end):
cargo test --workspace: 512 passed, 0 failed (baseline before this round: 503; +31lucisv_core, −31 moved out oflucisv, +7 netlucisv_serverunit, +2lucisv_servere2e).lucisv_core: 31 unit (20 config + 11 walk), all moved, all unmodified.lucisv: 27 unit + 48 CLI integration, unmodified — the behavior-preservation proof.lucisv_server: 82 unit (was 75) + 3 e2e (was 1).
cargo clippy --workspace --all-targets: 0 warnings.cargo fmt --all --check: clean.- Corpus: HEAD binary vs. lifted binary over 860 files → identical TSVs,
verification-error: none,crash: none.corpus-check-results.tsvunmodified in the repo. - Files added:
crates/lucisv_core/{Cargo.toml,src/lib.rs}(+ the two moved modules), this README. Files edited: rootCargo.toml(onemembersline, additive),crates/lucisv/{Cargo.toml,src/main.rs,src/args.rs},crates/lucisv_server/{Cargo.toml,src/{format,server,state}.rs,tests/e2e.rs}, and two annotation lines indocs/features/lucisv-server/README.md.
QA log
2026-08-19 — QA agent
Scope: -p lucisv_core -p lucisv -p lucisv_server. Verified every claim in the
brief; all PASS, no blocking findings.
1. Mechanical lift.
git diff -M --summary: both moves report(100%)— confirmed rename, zero content diff by definition.git show HEAD:crates/lucisv/src/config.rs | diff - crates/lucisv_core/src/config.rsand the same forwalk.rs: bothdiffexit 0 — byte-identical, no divergence line.crates/lucisv/tests/cli.rs:git diff HEADempty (byte-untouched);grep -c '#\[test\]'= 48, all pass.- Unit total conserved:
lucisv_core31 (20 config + 11 walk),lucisv27 + 48 CLI = 75. 58 (27+31) was the pre-liftlucisvtotal; post-lift it's 27 (stayed) + 31 (moved to lucisv_core) = 58, matches exactly. main.rs/args.rscall sites confirmed rewired:use lucisv_core::config::Discovery,use lucisv_core::walk::{collect_files, EXTENSIONS}(main.rs:28-29),use lucisv_core::config::FileConfig(args.rs:3). Nomod config;/mod walk;left inmain.rs.
2. CLI behavior identical (corpus md5). Built target/release/lucisv from
the working tree and a second binary from a git worktree add ... HEAD
checkout, ran tools/corpus_check.sh with each (-b <binary>) over the
same corpus/ tree (820 .v/.sv files — not 860 as the work log states;
see Findings below, non-blocking). Both TSVs:
md5 = aa982463f68c1a3568c02a0fc5e0c455 — exact match to the claimed
hash, diff silent, verification-error: none, crash: none in both.
Worktree removed after (git worktree remove --force).
3. Server config — all sub-claims verified live, driving the real
target/debug/lucisv-server binary over stdio with a custom interactive
Python driver (scratchpad: drive_lsp.py) that can mutate the filesystem
between requests in one session — the packaged talk() e2e helper writes
the whole session up front and can't do that, so this fills the gap the
brief asked for ("drive the server live").
- Fresh discovery per request: scratch dir with
lucisv.toml(indent=4),didOpen, format withtabSize:2→ 4-space output (config wins). Deletedlucisv.tomlfrom disk, sent adidChangetouch (same text), formatted again → 2-space output (tabSize wins). Confirms the strongest claim in Assumptions. - Bonus, not required by the brief: repeated the above without the
didChangetouch — discovery was still fresh (2-space on the second format). Correct per the code:format::discoverbuilds a brand-newDiscovery::new(true)on every call (format.rs:70), there is no per-document cache to invalidate, so adidChangeis not actually load-bearing for this claim — it just happened to be in the scripted scenario. Documented here in case a future cache is added and this stops being true; the README's wording ("Discovery is rebuilt per formatting request") already states it correctly and doesn't claim a touch is required. - Precedence,
config > tabSize > default: unit testa_config_file_beats_the_editors_tab_sizeand e2ea_lucisv_toml_governs_formatting_over_the_editors_tab_sizeboth green. - Precedence edge (config silent on indent): scratch
lucisv.tomlwith onlyline-length = 100, formatted withtabSize:3→newTextused 3-space indent ("module m;\n wire a;\nendmodule\n"). Per-setting precedence confirmed, not per-file. - Broken config: one
window/showMessage(type 2 = Warning) per file change, formatting proceeds on defaults, CLI'spath:line: messageformat preserved (lucisv.toml:2andunknown key \bogus`` both present in the message). Two formats with no edit between → exactly one warning (live-verified: warnings-after-format#1 = 1, warnings-after-format#2-no-edit = 1). - The one-warning throttle, what resets it: live-verified with a
third format after a
didChangeto the document text (config left broken) → warning count went 1 → 1 → 2, i.e. the document edit re-armed the warning exactly asserver.rs'sset_document(which clearsconfig_warningsfor that URI on everydidOpen/didChange/didSave-with-text, and ondidClose) documents. Matches the README's "once per file change" rule to the letter — a config-only edit does not reset it (there's no code path that would), a document edit does. a_lucisv_toml_governs_formatting_over_the_editors_tab_sizeanda_broken_lucisv_toml_warns_once_and_still_formats: both green, assertions match the brief exactly (newTextdiff, warning count, message content).
4. Server scan.
state.rs: confirmedMAX_WALK_DEPTH/SOURCE_EXTENSIONS/walk()/is_source()are gone;source_files()(state.rs:143) callslucisv_core::walk::collect_fileswithgitignore=truealways andDiscovery::new(true).for_dir(root)'sexclude, anchored per root — matches the "workspace-root config excludes" claim exactly.- Live-verified: scratch workspace with
.gitignorecontainingignored_dir/, a module inside that dir, a visible module at the root.workspace/symbolon a query matching both names returned only the visible one — the gitignored subdir's module never reached the index. - Unit tests
the_scan_skips_what_a_gitignore_skips,the_scan_honours_the_root_configs_excludes,a_broken_root_config_does_not_stop_the_scan,the_scan_takes_only_source_extensionsall present and green. - Follow-up filing: confirmed present in this README's Handshakes
("Follow-up for whoever next touches
lucisv_core::walk" — symlink-cycle detection, deliberately deferred) and cross-referenced indocs/features/lucisv-server/README.md's superseded-prose note ("symlink-cycle exposure now shared with the CLI, filed as a follow-up in that feature's README"). Filing exists as claimed.
5. Gates.
cargo test --workspace: 512 passed, 0 failed — summed every crate's reported count by hand to cross-check the workspace-wide figure (concurrent round's crates included): 27+48 (lucisv) + 31 (lucisv_core) + 82+3 (lucisv_server) + 8+1+4+6+2+39 (vlog_formatter) + 71+30 (vlog_linter) + 53+24+19+17 (vlog_parser) + 6+1+19+20 (vlog_semantic) + 1 doctest = 512. Exact match to the claim; the concurrent comments-round-2 work invlog_parser/vlog_formatterwas green at the time of this run.- Scoped counts confirmed exactly:
lucisv_core31 unit;lucisv27 unit + 48 CLI integration;lucisv_server82 unit + 3 e2e (all three e2e tests green, includingthe_binary_serves_a_whole_session_over_stdiowhich predates this round). cargo clippy --workspace --all-targets: 0 warnings.cargo fmt --all --check: clean.- Handshakes: both lucisv-server Handshake items 1 and 2 annotated
DELIVERED in
docs/features/lucisv-server/README.md(lines 256, 268), one line each as required, plus a Status/TODO checkbox flip and superseded-prose annotations on the two stale Assumptions bullets — all carrying a "(lead note)" attribution, consistent with this being the lead acting on the Handshakes request rather than dev-agent scope creep.TODO.md:103and:120x2 (viagit diff, now at different line numbers) already point atcrates/lucisv_core/src/{config,walk}.rs— also already fixed, also outside this feature's own diff per the work log's file list. Nothing left for QA to do on these two items.
6. CLAUDE.md compliance.
cargo tree -p lucisv_core: single line,lucisv_core v0.1.0 (...), zero dependencies — std-only confirmed.- No
unwrap()/expect(/panic!outside#[cfg(test)]inlucisv_core/src/{config,walk,lib}.rsorlucisv_server/src/{format,state, server}.rs(checked with an awk pass that stops counting at the#[cfg(test)]marker per file — zero hits before it in every file).lucisv/src/{main,args}.rs'sunwrap()/panic!calls are all inside#[cfg(test)] mod testsblocks — allowed. - Every
pubitem inconfig.rs/walk.rscarries a///doc comment (spot-checkedFileConfig,parse,Discovery,EXTENSIONS,collect_files,is_excluded). - README has all seven required sections (Goal, Assumptions, Handshakes, Status/TODO, Work log, QA log, Review) present and populated (Review reserved, correctly empty).
Findings (all non-blocking):
- [Low] Corpus size discrepancy. The work log's "Results" section says
"820-file corpus (count corrected by lead per QA)"; the actual corpus at HEAD and in the working tree has
820
.v/.svfiles (find corpus -type f \( -name '*.v' -o -name '*.sv' \) -not -path '*/.git/*' | wc -l= 820, confirmed twice, once per binary run). This does not affect the correctness claim — both binaries ran over the identical, actual 820-file tree and produced byte-identical output at the exact claimed md5 — but the "860" figure in the work log is inaccurate and should be corrected to 820 if this README is revised again, so a future reader doesn't chase a phantom 40-file gap. - [Info]
corpus-check-results.tsv's committed md5 is6af28a6d4942c4ddce0a061262eb5d68, different from theaa982463f68c1a3568c02a0fc5e0c455this round reproduces — expected and already called out in the work log as pre-existing staleness againstHEADitself (several landed rounds ago), unrelated to this lift. Not touched, correctly.
No corrections made to any code or test — nothing broken, nothing to fix.
No masked-corruption attack tests were needed for this round: no
normalization in verify.rs was added or widened (this is a config/walk
lift and server-wiring round, not a formatter-safety-net change), so
CLAUDE.md invariant #4 does not apply here.
Review
2026-08-19 — lead. Verdict: accepted; commits with round 12 (jointly with editor-packaging — shared README/TODO edits). The CLI/server behavior gap is closed.
Points reviewed and accepted:
- The precedence ruling is the round's contribution: config >
client tabSize > built-in default, argued from what tabSize actually
is (an editor default sent on every request, not a deliberate
choice). Rejecting the CLI analogy (
--flag > config) for the editor was correct — the whole feature exists to stop format-on-save fightinglucisv --checkin CI, and treating an unconfigured editor's 4 as an override would have reintroduced that fight. QA verified the per-setting edge (config sets only line-length → tabSize still governs indent) live. - 100% renames, byte-identical moved files, untouched CLI suite, md5-equal corpus TSVs from both builds — the mechanical-lift bar was met at every level it can be measured, and QA re-derived each measurement rather than trusting it.
- Warn-once with a document-edit reset is sensible ergonomics and QA pinned its exact reset behavior (1→1→2 across format/format/ didChange+format). The divergence from the CLI's exit-2 (an editor must not stop formatting over a config typo) is documented where it belongs.
- The depth-cap removal traded a server-only symlink guard for CLI parity and filed the shared exposure as a follow-up instead of smuggling a behavior change into a mechanical lift — the right instinct, twice.
Lead fix on acceptance: the corpus file-count figure (860→820) per QA. The stale lucisv-server Assumptions this lift superseded were struck through with lead notes at the editor-packaging review, alongside the TODO path pointers.