Compare commits

...
4 Commits
Author SHA1 Message Date
lucioandClaude Fable 5.1 73799f3d53 Release 0.43.0 — the repository analysis's three findings
ci / checks (push) Successful in 58s
ci / corpus (push) Successful in 31s
release / build-and-publish (push) Successful in 6m27s
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-05 02:43:10 -05:00
lucioandClaude Fable 5.1 ec9ec42276 Walker cycle policy by directory identity, and comment slots around a net delay's #
TODO §43 (docs/features/walk-cycles). Closes topo §2.9-8 and §2.9-27 and
repository-analysis finding 3; §2.9-30 filed.

43.1 `lucisv_core::walk::Walk` keeps a `visited` set keyed on `(dev, ino)`
(the canonical path off unix): each directory is entered once, a symlink
to one already entered is skipped, one not yet entered is followed once,
a dangling directory link is skipped. A dangling link that names a source
file is still handed on, so the front end's "no such file" error survives
(review ruling on QA's finding). Both front ends share the walk unchanged
in signature; a cyclic workspace indexes and a cyclic tree formats, each
file once.

43.2 `NetDelay::{before_hash, after_hash}`: the gaps around `#` have
slots, printed inline; the `#SKIP` in net_delay_position.cases is live
and the RTL gap fuzzer covers the construct (374 gaps, 0 failures).

Byte-identity vs 0.42.0: 0 of 820 corpus files differ. On opentitan the
only per-file change is §41's dedup reporting a same-directory symlink
alias once.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-05 02:43:10 -05:00
lucioandClaude Fable 5.1 4b2dad87fe One lint-configuration contract for project and editor: the server picks the editor's selection when set, else the project's, and logs rejected project entries once
TODO §42 (docs/features/lint-config-contract). Closes topo §2.9-28 and
repository-analysis finding 2.

`enabled_rules(settings, project, has_oracle)`: rung 2 is
`lucisv.lint.select` when non-empty else `[lint] select`, rung 5 the same
for `ignore` — the CLI's `pick` applied to the editor — so one buffer
linted two ways is linted the same way (asserted equal over the wire for
three configurations). `lint::project`: `ProjectLint` read from the
`Discovery` result `configured` already computes (no extra read per
pass); an unknown rule name in a project list is dropped and said rather
than silently emptying the selection. `ConfigProblems`/`ProblemLog`:
rejected `[lint.<rule>]` options, unknown names and bad `[lint] waivers`
lines are logged once per (config file, entry) in `lucisv check`'s
wording, re-armed when the config's lint content changes; the buffer
keeps linting with the entry dropped.

Docs applied: README, the linter guide, configuration.md, the analysis,
topo (28 struck; 29 filed for the editor-side unknown-name silence), site
rebuilt.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-05 01:45:48 -05:00
lucioandClaude Fable 5.1 3b08c0753c Same-target atomic writers: exclusive per-operation temps, mode before bytes, CLI dedup by canonical identity
TODO §41 (docs/features/atomic-write-coordination). Closes topo §2.9-26
and repository-analysis finding 1.

`atomic::write_atomic` names its temp `.{name}.{pid}.{n}.lucisv-tmp` with
a per-process counter and opens it create-new (O_EXCL), retrying a used
name up to 32 times; on unix the temp is created 0600 when a target
exists and takes the target's mode through the open handle before the
bytes are written, so a 0600 file never has a readable moment. The CLI's
`dedup` keys on the canonical path when the file exists, so a symlink
alias reaches one worker; the reported path is the first spelling. Two
processes on one target remain last-writer-wins (rename is atomic, the
formatter idempotent), stated in the module doc. The audit's probe is a
test: 0 write errors in 200 calls.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-05 00:40:48 -05:00
46 changed files with 2871 additions and 157 deletions

No files matched your search

+27
View File
@@ -4,6 +4,33 @@ All notable changes to lucisv are recorded here. Versions follow
[semantic versioning](https://semver.org/); until 1.0 the CLI's exit codes
(see `README.md`) are the only frozen contract.
## 0.43.0 — 2026-09-05
### The repository analysis's three findings
- **Atomic writers cannot collide.** In-place writes use an exclusive,
per-operation temp file (`.{name}.{pid}.{n}.lucisv-tmp`, created
0600 when a target exists and given the target's mode before the bytes
land); the CLI deduplicates its inputs by canonical identity, so a
symlink alias of a file reaches one worker and is reported once. Two
processes on one target remain last-writer-wins, which the formatter's
idempotence makes safe.
- **One lint-configuration contract.** The editor now honours a project's
`[lint] select` and `[lint] ignore` the way the CLI honours its flags:
`lucisv.lint.select` when set, else the project's, key by key, with the
editor-only severity switches and per-rule toggles applied over whichever
stands. A project entry the server cannot use — a rejected `[lint.<rule>]`
option, an unknown rule name, a bad waiver directive — is logged once with
file and line in `lucisv check`'s wording and dropped; the buffer keeps
linting. The CLI's and the server's rule lists are asserted equal over
the wire.
- **Directory walks terminate on symlink cycles.** Each directory is
entered once by identity; a link to a directory already entered is
skipped, one not yet entered is followed once, a dangling directory link
is skipped and a dangling source-file link is still reported. Both the
CLI and the server's index scan.
- A comment before a net delay's `#` (`wire /* c */ #5 w;`) now formats.
## 0.42.0 — 2026-09-05
### External waiver files, and the two vendor shapes the sweep skipped
Generated
+8 -8
View File
@@ -97,7 +97,7 @@ dependencies = [
[[package]]
name = "lucisv"
version = "0.42.0"
version = "0.43.0"
dependencies = [
"lucisv_core",
"rayon",
@@ -108,11 +108,11 @@ dependencies = [
[[package]]
name = "lucisv_core"
version = "0.42.0"
version = "0.43.0"
[[package]]
name = "lucisv_server"
version = "0.42.0"
version = "0.43.0"
dependencies = [
"lsp-server",
"lsp-types",
@@ -248,14 +248,14 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "vlog_formatter"
version = "0.42.0"
version = "0.43.0"
dependencies = [
"vlog_parser",
]
[[package]]
name = "vlog_linter"
version = "0.42.0"
version = "0.43.0"
dependencies = [
"lucisv_core",
"vlog_formatter",
@@ -265,11 +265,11 @@ dependencies = [
[[package]]
name = "vlog_parser"
version = "0.42.0"
version = "0.43.0"
[[package]]
name = "vlog_refactor"
version = "0.42.0"
version = "0.43.0"
dependencies = [
"vlog_parser",
"vlog_semantic",
@@ -277,7 +277,7 @@ dependencies = [
[[package]]
name = "vlog_semantic"
version = "0.42.0"
version = "0.43.0"
dependencies = [
"vlog_parser",
]
+1 -1
View File
@@ -12,7 +12,7 @@ members = [
]
[workspace.package]
version = "0.42.0"
version = "0.43.0"
authors = ["Guoliang Chen"]
edition = "2021"
license = "MIT"
+15 -6
View File
@@ -424,14 +424,23 @@ the first workspace folder). External and inline waivers are a union: a
finding either covers is suppressed, and one both cover leaves neither
reported as dead. A missing file or an unparsable directive fails `lucisv
check` with `<file>:<line>: <message>` and exit 2; in an editor the bad line
is dropped and the rest of the file applies — a bad line in a file named by
the editor setting is written once to the lucisv log, one named by
`lucisv.toml` is not (run `lucisv check` to see it). Unused external waivers
is dropped and the rest of the file applies, and the bad line is written once
to the lucisv log whether the file was named by the editor setting or by
`lucisv.toml`. Unused external waivers
are reported under `unused-waiver` at their line of the waiver file, by
`lucisv check` only and only after the whole run.
The server currently selects rules from `lucisv.lint.*` editor settings;
project `[lint] select/ignore` lists affect the CLI only. Project per-rule
options are read by both front ends. Full rules:
Both front ends read the same configuration, and the editor's settings play
the role the CLI's flags play: `lucisv.lint.select` when it is set, else
`[lint] select` from the buffer's `lucisv.toml`, else the default set — and
the same for `ignore`, decided independently. `lucisv.lint.severity.*` and
`lucisv.lint.rules.*` have no project counterpart and apply over whichever
selection stands. Project per-rule options are read by both front ends. A
project entry lucisv cannot use — an unknown rule name in `[lint]
select`/`ignore`, a rejected `[lint.<rule>]` option, an unreadable waiver
file or a directive that does not parse — fails `lucisv check` with
`<file>:<line>: <message>` and exit 2; in an editor it is dropped, written
once to the lucisv log in the same words, and everything lucisv did
understand still lints the buffer. Full rules:
`docs/features/linter-core/README.md`.
## Architecture (the ruff mapping)
+22 -19
View File
@@ -4360,7 +4360,7 @@ pre-existing modified files stay as they are). Every run under
path), `hover`, `inlayHint` (workspace scope and default scope, with
§37.2's ruling restated), `references`, `documentSymbol`,
`workspaceSymbol`, `semanticTokens/full`, diagnostics publish. Driven
over the wire against `target/release/lucisv-server` at 0.42.0 and,
over the wire against `target/release/lucisv-server` at 0.43.0 and,
for the rows that exist there, the 0.39.0 baseline
(`~/.cache/lucisv-baselines/` holds CLI binaries only — build the
0.39.0 server from the tag in a scratch worktree under the scratchpad,
@@ -4368,7 +4368,7 @@ pre-existing modified files stay as they are). Every run under
- **CLI sweeps** over `hw/ip`, `hw/top_earlgrey/ip`, `hw/top_darjeeling/ip`,
`hw/dv`, `hw/vendor`: `format --check` (cold cache and warm), `check`
(all rules on; default rules), wall time and peak RSS (`/usr/bin/time
-l`), 0.42.0 vs 0.39.0 vs 0.41.0; the failure counts per tree and the
-l`), 0.43.0 vs 0.39.0 vs 0.41.0; the failure counts per tree and the
list of files whose outcome changed since 0.39.0 (expected: exactly
jtag_if.sv and SimDTM.sv from §38).
- **Method** as take 2 §9: three tries per row, first try and repeat
@@ -4378,7 +4378,7 @@ pre-existing modified files stay as they are). Every run under
item with a reproduction; anything faster is credited to the section
that did it.
- [ ] server table re-measured, 0.42.0 vs take 2 vs 0.39.0
- [ ] server table re-measured, 0.43.0 vs take 2 vs 0.39.0
- [ ] CLI sweeps, three binaries, RSS included
- [ ] `docs/performance_take3.md` + perf README entry
- [ ] opentitan status unchanged after every run
@@ -4421,16 +4421,17 @@ workers; and any two threads in one process writing one path.
uniqueness; the 0600 window (the temp is never readable by others —
assert its mode right after creation in the test's own thread).
- [ ] 41.1 exclusive unique temps, mode before bytes
- [ ] 41.2 dedup by canonical identity, reported path unchanged
- [ ] docs: feature README; topo §2.9-26 struck (lead); analysis finding
- [x] 41.1 exclusive unique temps, mode before bytes
- [x] 41.2 dedup by canonical identity, reported path unchanged
- [x] docs: feature README; topo §2.9-26 struck (lead); analysis finding
1 annotated "fixed by §41" (lead)
- [ ] Gates (guarded): fmt/clippy/workspace tests; corpus unchanged;
- [x] Gates (guarded): fmt/clippy/workspace tests; corpus unchanged;
byte-identity vs 0.42.0
- [ ] QA: the probe re-run under the guard at 4 threads; alias attacks
- [x] QA: the probe re-run under the guard at 4 threads; alias attacks
through the CLI (relative/absolute/`..` spellings + symlink); a
target that is itself a symlink into another directory; RSS of the
100-round probe
100-round probe — PASS, see QA log in the feature README
(2026-09-05)
## 42. Repository-analysis fix 2 (planned 2026-09-04) — one lint-configuration contract for project and editor (topo §2.9-28)
@@ -4477,11 +4478,11 @@ when given, else the project file. The server does the same, key by key:
back to empty restores the project's; the CLI's and the server's rule
lists for the same buffer are asserted **equal** for three configs.
- [ ] 42.1 project selection into the ladder, editor-when-set-else-project
- [ ] 42.2 rejected project options logged with file:line
- [ ] docs + tests above; topo §2.9-28 struck (lead); finding 2 annotated
- [ ] Gates (guarded); e2e green
- [ ] QA: the four-way matrix over the wire; the CLI/server equality on
- [x] 42.1 project selection into the ladder, editor-when-set-else-project
- [x] 42.2 rejected project options logged with file:line
- [x] docs + tests above; topo §2.9-28 struck (lead); finding 2 annotated
- [x] Gates (guarded); e2e green
- [x] QA: the four-way matrix over the wire; the CLI/server equality on
an opentitan IP (read-only) with its real `lucisv.toml` if one
exists, else a scratch one
@@ -4523,12 +4524,14 @@ mechanism and its gap fuzzer), the formatter prints it inline before `#`,
the `#SKIP` in `net_delay_position.cases` goes live, the gap fuzzer covers
the new slot.
- [ ] 43.1 visited-by-identity walker, both front ends, tests
- [ ] 43.2 `NetDelay::before_hash`, the `#SKIP` retired
- [ ] docs; topo §2.9-8 and §2.9-27 struck (lead); finding 3 annotated
- [ ] Gates (guarded): fmt/clippy/workspace tests; corpus unchanged;
- [x] 43.1 visited-by-identity walker, both front ends, tests
- [x] 43.2 `NetDelay::before_hash`, the `#SKIP` retired
- [x] docs; topo §2.9-8 and §2.9-27 struck (lead); finding 3 annotated
— done at review 2026-09-05; §2.9-30 filed (unreadable directory
aborts the walk)
- [x] Gates (guarded): fmt/clippy/workspace tests; corpus unchanged;
byte-identity vs 0.42.0; a cyclic scratch tree through both binaries
- [ ] QA: cycles of depth 1–3 through the CLI and the server (guarded,
- [x] QA: cycles of depth 1–3 through the CLI and the server (guarded,
time-limited); the comment slot attacked with every comment shape
and position; the gap fuzzer re-run
+47 -4
View File
@@ -415,13 +415,25 @@ fn filelist_files(opts: &Options) -> Result<Vec<PathBuf>, String> {
fn dedup(files: Vec<PathBuf>) -> Vec<PathBuf> {
let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
let mut seen = HashSet::new();
files.into_iter().filter(|file| seen.insert(absolute(&cwd, file))).collect()
files.into_iter().filter(|file| seen.insert(identity(&cwd, file))).collect()
}
/// The key two spellings of one file share: the file's canonical path when it
/// is there, and the lexical fold when it is not.
///
/// Canonical means symlinks resolved, which is the only way to see that
/// `b.sv -> a.sv` is the file `a.sv` already named — two rayon workers on one
/// target otherwise, each rewriting what the other just wrote. A path with no
/// file behind it has no canonical form, and the lexical fold is then the
/// best two names for it can be compared by. Neither is ever the path lucisv
/// reports: that stays the first spelling seen.
fn identity(cwd: &Path, path: &Path) -> PathBuf {
std::fs::canonicalize(path).unwrap_or_else(|_| absolute(cwd, path))
}
/// `path` folded to the absolute, `.`/`..`-free spelling two names for one
/// file share. Lexical, like `lucisv_core`'s own normalization: symlinks are
/// deliberately left unresolved, so this is only ever a dedup key and never
/// the path lucisv reports.
/// file share. Purely lexical, like `lucisv_core`'s own normalization — it
/// answers for paths that do not exist, where there is nothing to resolve.
fn absolute(cwd: &Path, path: &Path) -> PathBuf {
let joined = if path.is_absolute() { path.to_path_buf() } else { cwd.join(path) };
let mut out = PathBuf::new();
@@ -602,6 +614,37 @@ mod tests {
assert_eq!(dedup(files), [cwd.join("rtl/a.sv")]);
}
#[cfg(unix)]
#[test]
fn dedup_folds_a_symlink_onto_the_file_it_points_at() {
// A directory walk lists `b.sv` as a file of its own; lexically the
// two names share nothing, and two workers would rewrite one file.
let dir = std::env::temp_dir().join(format!("lucisv-dedup-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).expect("temp dir");
let real = dir.join("a.sv");
let link = dir.join("b.sv");
std::fs::write(&real, "module m;\nendmodule\n").expect("seed");
std::os::unix::fs::symlink(&real, &link).expect("symlink");
assert_eq!(dedup(vec![real.clone(), link.clone()]), std::slice::from_ref(&real));
// Whichever spelling comes first is the one kept and reported.
assert_eq!(dedup(vec![link.clone(), real.clone()]), std::slice::from_ref(&link));
// And a `..` detour through the same link is still the same file.
std::fs::create_dir(dir.join("sub")).expect("sub dir");
let detour = dir.join("sub/../b.sv");
assert_eq!(dedup(vec![real.clone(), detour]), std::slice::from_ref(&real));
// A file that is not there has no canonical path: the key is lexical,
// which still folds `.` and `..`, and two missing files stay two.
let gone = dir.join("gone.sv");
let same = dir.join("./sub/../gone.sv");
let other = dir.join("other.sv");
assert_eq!(dedup(vec![gone.clone(), same, other.clone()]), [gone, other]);
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn format_contained_reports_parse_errors() {
let err = format_contained("module", &Config::default(), None).unwrap_err();
+51
View File
@@ -136,6 +136,57 @@ fn formats_files_in_place() {
assert!(stderr(&out).contains("2 files left unchanged"), "{}", stderr(&out));
}
/// A directory walk lists a symlink as a file of its own, so `b.sv -> a.sv`
/// used to put two workers on one file: two report lines for one file, and
/// two writers racing to replace it. It is one file now, named once.
#[cfg(unix)]
#[test]
fn a_symlink_and_its_target_are_one_file() {
let dir = TempDir::new("alias");
dir.write("a.sv", UNFORMATTED);
std::os::unix::fs::symlink(dir.path.join("a.sv"), dir.path.join("b.sv")).expect("symlink");
let out = run(&["--check", &dir.root()]);
assert_eq!(code(&out), 1, "{}", stderr(&out));
let reported = stdout(&out);
let named: Vec<&str> = reported.lines().filter(|l| l.contains("would reformat")).collect();
assert_eq!(named.len(), 1, "one file, one line: {named:?}");
assert!(named[0].ends_with("a.sv"), "the first spelling walked is the one reported: {named:?}");
assert!(stderr(&out).contains("1 file would be reformatted"), "{}", stderr(&out));
let out = run(&[&dir.root()]);
assert_eq!(code(&out), 0, "{}", stderr(&out));
assert!(stderr(&out).contains("1 file reformatted"), "{}", stderr(&out));
assert_eq!(dir.read("a.sv"), FORMATTED);
assert_eq!(dir.read("b.sv"), FORMATTED, "and the link still reaches it");
assert!(
std::fs::symlink_metadata(dir.path.join("b.sv")).expect("stat").file_type().is_symlink(),
"the link was not replaced by a copy"
);
}
/// A directory that links back into itself. Before the walk kept a visited
/// set (`docs/features/walk-cycles/README.md`) this run recursed until the
/// OS refused the path; now each directory is entered once, so each file is
/// named once — under the first spelling that reaches it.
#[cfg(unix)]
#[test]
fn a_symlink_cycle_terminates_and_names_each_file_once() {
let dir = TempDir::new("cycle");
dir.write("rtl/a.sv", UNFORMATTED);
dir.write("rtl/sub/b.sv", UNFORMATTED);
// `rtl/self` is `rtl` itself; `rtl/sub/up` is `rtl` from one level down.
std::os::unix::fs::symlink("../rtl", dir.path.join("rtl/self")).expect("symlink");
std::os::unix::fs::symlink("..", dir.path.join("rtl/sub/up")).expect("symlink");
let out = run(&["--check", &dir.root()]);
assert_eq!(code(&out), 1, "{}", stderr(&out));
let reported = stdout(&out);
let named: Vec<&str> = reported.lines().filter(|l| l.contains("would reformat")).collect();
assert_eq!(named.len(), 2, "two files, two lines: {named:?}");
assert!(stderr(&out).contains("2 files would be reformatted"), "{}", stderr(&out));
}
#[test]
fn check_reports_without_writing() {
let dir = TempDir::new("check");
+263 -14
View File
@@ -7,11 +7,24 @@
//! gets the bytes, and a `rename` over the target publishes them in one step
//! that either happened or did not.
//!
//! See `docs/features/small-items-3/README.md`.
//! Two threads of one process may write one target: the temp names carry a
//! per-process counter as well as the pid and are created with `O_EXCL`, so
//! each writer owns its own file and neither can see the other's bytes.
//!
//! Two *processes* writing one target are not coordinated, and deliberately
//! so. Both renames are atomic, the later one wins, and the loser's bytes are
//! discarded whole — never merged. Both processes formatted the same input
//! and `format` is idempotent, so whichever rename lands last leaves the
//! file complete and correctly formatted. A lock would buy nothing and would
//! be one more thing to leave behind after a `^C`.
//!
//! See `docs/features/small-items-3/README.md` and
//! `docs/features/atomic-write-coordination/README.md`.
use std::fs;
use std::io;
use std::fs::{self, File, OpenOptions};
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicU64, Ordering};
/// Writes `bytes` to `path`, replacing whatever was there in one step.
///
@@ -21,6 +34,12 @@ use std::path::{Path, PathBuf};
/// sees either the old file or the new one and never a truncated one. A
/// failure anywhere after the temp exists removes it before returning.
///
/// The temp is the caller's alone: [`temp_path`] hands out a name no other
/// writer in this process will be given, and the file is created with
/// `create_new`, so a name that somehow exists is an error and not a shared
/// file. Two threads writing one target therefore both succeed, and the
/// target ends up holding one thread's whole buffer.
///
/// A symlinked target is resolved first: `fs::write` writes *through* a
/// symlink, so replacing the link itself would silently redirect it at a new
/// file and leave the real one stale. The canonical path is what gets
@@ -28,26 +47,22 @@ use std::path::{Path, PathBuf};
/// filesystem — `rename` cannot cross one.
pub fn write_atomic(path: &Path, bytes: &[u8]) -> io::Result<()> {
let target = fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf());
let perms = target_permissions(&target);
// A rename replaces a file whatever its mode, so a read-only target would
// be silently overwritten where `fs::write` refuses it. Keep the refusal:
// a file someone made read-only is asking not to be rewritten in place.
if fs::metadata(&target).is_ok_and(|m| m.permissions().readonly()) {
if perms.as_ref().is_some_and(fs::Permissions::readonly) {
return Err(io::Error::new(
io::ErrorKind::PermissionDenied,
format!("{} is read-only", path.display()),
));
}
let tmp = temp_path(&target)?;
if let Err(e) = fs::write(&tmp, bytes) {
let (tmp, mut file) = create_temp(&target, perms.is_some())?;
if let Err(e) = fill_temp(&mut file, &tmp, perms, bytes) {
let _ = fs::remove_file(&tmp);
return Err(e);
}
// A file someone made read-only, or executable, keeps its mode: the temp
// was created with the process umask, not with the target's bits. No
// target means a new file, which takes the umask as `fs::write` would.
if let Ok(meta) = fs::metadata(&target) {
let _ = fs::set_permissions(&tmp, meta.permissions());
}
drop(file);
if let Err(e) = fs::rename(&tmp, &target) {
let _ = fs::remove_file(&tmp);
return Err(e);
@@ -55,16 +70,106 @@ pub fn write_atomic(path: &Path, bytes: &[u8]) -> io::Result<()> {
Ok(())
}
/// How many temp names one write tries before giving up.
///
/// A name is only ever handed out once per process, so a collision means a
/// leftover from a *previous* process that crashed mid-write and whose pid
/// this process now has. A handful of those may sit in one directory; a
/// hundred is a directory to clean up by hand, not a race to retry through.
const TEMP_ATTEMPTS: u32 = 32;
/// Creates the temp file, exclusively, and returns it with its path.
///
/// `replacing` says there is a target whose mode the temp is about to take.
/// Then it is born 0600 on unix rather than at the umask's mode: a chmod does
/// not revoke a descriptor someone already opened, so the only way a private
/// file's replacement can never be read by anyone else is for the temp to be
/// private from the moment it exists. With no target there is no earlier mode
/// to honour and the umask decides, as `fs::write` would.
fn create_temp(target: &Path, replacing: bool) -> io::Result<(PathBuf, File)> {
let mut opts = OpenOptions::new();
opts.write(true).create_new(true);
#[cfg(unix)]
if replacing {
use std::os::unix::fs::OpenOptionsExt;
opts.mode(0o600);
}
#[cfg(not(unix))]
let _ = replacing;
for _ in 0..TEMP_ATTEMPTS {
let tmp = temp_path(target)?;
match opts.open(&tmp) {
Ok(file) => return Ok((tmp, file)),
Err(e) if e.kind() == io::ErrorKind::AlreadyExists => continue,
Err(e) => return Err(e),
}
}
Err(io::Error::new(
io::ErrorKind::AlreadyExists,
format!("no free temp file name beside {} after {TEMP_ATTEMPTS} tries", target.display()),
))
}
/// Puts the target's mode on the temp, then the bytes in it.
///
/// The order is the point on unix: a 0600 target's replacement must not spend
/// even an instant holding the file's contents under the umask's broader
/// bits. Chmod does not close the handle opened before it, so a mode without
/// an owner-write bit still takes the write. Elsewhere `set_permissions`
/// takes a path rather than a handle and the mode goes on after the bytes,
/// which is the order this always had.
fn fill_temp(
file: &mut File,
tmp: &Path,
perms: Option<fs::Permissions>,
bytes: &[u8],
) -> io::Result<()> {
if cfg!(unix) {
copy_mode(file, perms);
file.write_all(bytes)
} else {
file.write_all(bytes)?;
if let Some(perms) = perms {
let _ = fs::set_permissions(tmp, perms);
}
Ok(())
}
}
/// Puts the target's mode on the temp through its open handle, which is what
/// lets it happen while the temp is still empty. No target means no earlier
/// mode to honour, and the umask's stands.
fn copy_mode(file: &File, perms: Option<fs::Permissions>) {
if let Some(perms) = perms {
let _ = file.set_permissions(perms);
}
}
/// The mode the temp must end up with: a file someone made executable, or
/// private, keeps its bits, because the temp was created with the process
/// umask (or 0600) and not with the target's. `None` means there is no target
/// — a new file, which takes the umask as `fs::write` would.
fn target_permissions(target: &Path) -> Option<fs::Permissions> {
fs::metadata(target).ok().map(|m| m.permissions())
}
/// Names handed out by [`temp_path`], one per call for the life of the
/// process. Wrapping after 2^64 names is not a scenario.
static TEMP_COUNTER: AtomicU64 = AtomicU64::new(0);
/// The temp file's path: hidden, in the target's own directory, and stamped
/// with the process id so two lucisv runs over one tree cannot collide.
/// with the process id and a per-process counter — the pid keeps two lucisv
/// runs apart, the counter keeps two threads of one run apart, and together
/// they mean no two writers anywhere are ever given the same name.
fn temp_path(target: &Path) -> io::Result<PathBuf> {
let dir = target.parent().unwrap_or_else(|| Path::new("."));
let name = target
.file_name()
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, "no file name to write"))?;
let n = TEMP_COUNTER.fetch_add(1, Ordering::Relaxed);
let mut tmp = std::ffi::OsString::from(".");
tmp.push(name);
tmp.push(format!(".{}.lucisv-tmp", std::process::id()));
tmp.push(format!(".{}.{n}.lucisv-tmp", std::process::id()));
Ok(dir.join(tmp))
}
@@ -199,4 +304,148 @@ mod tests {
);
assert_eq!(fs::read_to_string(&link).expect("read"), "new\n", "and still points at it");
}
/// The audit's probe (`docs/repository-analysis.md` finding 1), which
/// used to produce 100 write errors in 200 calls: both threads derived
/// the same temp name from the target and the pid, so one deleted the
/// other's file under it. Now every writer owns its own temp, so every
/// call succeeds and the target holds one writer's whole buffer.
#[test]
fn two_threads_writing_one_target_never_collide() {
const MIB: usize = 1024 * 1024;
const ROUNDS: usize = 100;
let dir = TempDir::new("race");
let file = dir.file("a.sv");
fs::write(&file, "seed\n").expect("seed");
// Three parties: the two writers and this thread, which inspects the
// target between rounds. Nobody starts a round until everyone has
// finished the last one.
let start = std::sync::Arc::new(std::sync::Barrier::new(3));
let done = std::sync::Arc::new(std::sync::Barrier::new(3));
let writers: Vec<_> = (*b"ab")
.into_iter()
.map(|tag| {
let (path, start, done) = (file.clone(), start.clone(), done.clone());
std::thread::spawn(move || {
let bytes = vec![tag; MIB];
let mut errors = Vec::new();
for _ in 0..ROUNDS {
start.wait();
if let Err(e) = write_atomic(&path, &bytes) {
errors.push(e.to_string());
}
done.wait();
}
errors
})
})
.collect();
for round in 0..ROUNDS {
start.wait();
done.wait();
let got = fs::read(&file).expect("read");
assert_eq!(got.len(), MIB, "round {round}: a partial buffer landed");
let tag = got[0];
assert!(tag == b'a' || tag == b'b', "round {round}: neither writer's byte");
assert!(got.iter().all(|&b| b == tag), "round {round}: two buffers were mixed");
assert_eq!(dir.names(), vec!["a.sv".to_string()], "round {round}: a temp was left");
}
let errors: Vec<String> =
writers.into_iter().flat_map(|w| w.join().expect("writer thread")).collect();
assert!(
errors.is_empty(),
"{} write errors in {} calls: {errors:?}",
errors.len(),
2 * ROUNDS
);
}
#[test]
fn every_thread_gets_its_own_temp_name() {
const PER_THREAD: usize = 200;
let dir = TempDir::new("names");
let target = dir.file("a.sv");
let threads: Vec<_> = (0..4)
.map(|_| {
let target = target.clone();
std::thread::spawn(move || {
(0..PER_THREAD)
.map(|_| temp_path(&target).expect("temp name"))
.collect::<Vec<_>>()
})
})
.collect();
let names: Vec<PathBuf> =
threads.into_iter().flat_map(|t| t.join().expect("name thread")).collect();
let unique: std::collections::HashSet<&PathBuf> = names.iter().collect();
assert_eq!(unique.len(), names.len(), "a temp name was handed out twice");
}
/// The mode goes on while the temp is still empty, so a 0600 file's
/// replacement never holds its contents under the umask's wider bits.
#[cfg(unix)]
#[test]
fn the_temp_takes_the_targets_mode_before_any_bytes() {
use std::os::unix::fs::PermissionsExt;
let dir = TempDir::new("modewindow");
let target = dir.file("secret.sv");
fs::write(&target, "old\n").expect("seed");
fs::set_permissions(&target, fs::Permissions::from_mode(0o600)).expect("chmod");
let perms = target_permissions(&target);
let (tmp, mut file) = create_temp(&target, perms.is_some()).expect("temp");
// Born private, before any mode is copied onto it: an fd opened by
// someone else in this instant would not see the bytes to come.
assert_eq!(
fs::metadata(&tmp).expect("stat").permissions().mode() & 0o777,
0o600,
"the temp was created readable by others"
);
copy_mode(&file, perms.clone());
let meta = fs::metadata(&tmp).expect("stat");
assert_eq!(meta.len(), 0, "the mode is set before a single byte is written");
assert_eq!(meta.permissions().mode() & 0o777, 0o600, "the temp is not world-readable");
// And the chmod does not close the door on the handle opened before it.
fill_temp(&mut file, &tmp, perms, b"new\n").expect("fill");
assert_eq!(fs::read_to_string(&tmp).expect("read"), "new\n");
let _ = fs::remove_file(&tmp);
}
/// The same window seen from outside, through a real `write_atomic`: a
/// big enough buffer that the temp is usually observable while it is
/// being filled. It asserts about what it sees and never about seeing it,
/// so a scheduler that hides the window cannot fail the test.
#[cfg(unix)]
#[test]
fn a_temp_seen_mid_write_is_never_world_readable() {
use std::os::unix::fs::PermissionsExt;
let dir = TempDir::new("window");
let target = dir.file("secret.sv");
fs::write(&target, "old\n").expect("seed");
fs::set_permissions(&target, fs::Permissions::from_mode(0o600)).expect("chmod");
let path = target.clone();
let writer = std::thread::spawn(move || {
let bytes = vec![b'x'; 8 * 1024 * 1024];
write_atomic(&path, &bytes)
});
while !writer.is_finished() {
for entry in fs::read_dir(&dir.path).expect("read dir").flatten() {
if !entry.file_name().to_string_lossy().ends_with(".lucisv-tmp") {
continue;
}
let Ok(meta) = entry.metadata() else { continue };
assert_eq!(
meta.permissions().mode() & 0o777,
0o600,
"a temp for a 0600 target was readable by others"
);
}
}
writer.join().expect("writer thread").expect("write");
assert_eq!(fs::metadata(&target).expect("stat").permissions().mode() & 0o777, 0o600);
}
}
+215 -9
View File
@@ -2,6 +2,7 @@
//! `.gitignore` subset documented in
//! `docs/features/parallel-files/README.md`.
use std::collections::HashSet;
use std::path::{Path, PathBuf};
/// File extensions lucisv formats when walking a directory.
@@ -22,7 +23,14 @@ pub fn collect_files(
) -> Result<(), String> {
let path = Path::new(input);
if path.is_dir() {
let mut walk = Walk { exclude, gitignore, ignores: Vec::new(), rel: Vec::new(), files };
let mut walk = Walk {
exclude,
gitignore,
ignores: Vec::new(),
rel: Vec::new(),
visited: HashSet::new(),
files,
};
walk.dir(path).map_err(|e| format!("{input}: {e}"))?;
} else if path.is_file() {
files.push(path.to_path_buf());
@@ -32,20 +40,55 @@ pub fn collect_files(
Ok(())
}
/// How a directory is recognised as one the walk has already entered. Two
/// names for the same directory — a symlink and its target, or two symlinks
/// pointing at one place — must map to the same identity, or a cycle has no
/// end. On unix that is `(dev, ino)`, the pair the filesystem itself uses;
/// elsewhere it is the canonical path, which resolves symlinks the same way
/// at the cost of a real path lookup.
#[cfg(unix)]
type DirId = (u64, u64);
#[cfg(not(unix))]
type DirId = PathBuf;
/// The identity of the directory at `path`, or `None` when it cannot be
/// read — a dangling symlink, or a directory that vanished mid-walk.
#[cfg(unix)]
fn dir_id(path: &Path) -> Option<DirId> {
use std::os::unix::fs::MetadataExt;
let meta = std::fs::metadata(path).ok()?;
Some((meta.dev(), meta.ino()))
}
#[cfg(not(unix))]
fn dir_id(path: &Path) -> Option<DirId> {
std::fs::canonicalize(path).ok()
}
/// True when `path` names one of the source files lucisv formats.
fn is_source(path: &Path) -> bool {
path.extension().and_then(|e| e.to_str()).is_some_and(|ext| EXTENSIONS.contains(&ext))
}
/// One directory walk. `rel` is the path of the directory currently being
/// read, in components relative to the walk root, which is what
/// `.gitignore` rules are matched against; `ignores` is the stack of
/// ignore files seen from the root down to it.
/// ignore files seen from the root down to it; `visited` is every directory
/// already entered, by identity rather than by spelling.
struct Walk<'a> {
exclude: &'a [String],
gitignore: bool,
ignores: Vec<Ignore>,
rel: Vec<String>,
visited: HashSet<DirId>,
files: &'a mut Vec<PathBuf>,
}
impl Walk<'_> {
fn dir(&mut self, dir: &Path) -> std::io::Result<()> {
if !self.enter(dir) {
return Ok(());
}
let pushed = self.push_ignore(dir)?;
let mut entries: Vec<_> = std::fs::read_dir(dir)?.collect::<Result<_, _>>()?;
entries.sort_by_key(|e| e.path());
@@ -54,15 +97,26 @@ impl Walk<'_> {
if is_excluded(&path, self.exclude) {
continue;
}
let is_dir = path.is_dir();
// One `metadata` call per entry, exactly as before — it follows
// symlinks, so it answers "directory?" for a symlinked directory
// the way `is_dir()` did. A dangling symlink has no metadata at
// all. One that *names a source file* is still handed on, so the
// front end reports "no such file" for it as it always has (§43's
// QA: a silent skip loses the user an error they had); one that
// names anything else is neither a directory to walk nor a file
// to read, and is skipped.
let Ok(meta) = std::fs::metadata(&path) else {
if is_source(&path) {
self.files.push(path);
}
continue;
};
self.rel.push(entry.file_name().to_string_lossy().into_owned());
if !is_ignored(&self.ignores, &self.rel, is_dir) {
if is_dir {
if !is_ignored(&self.ignores, &self.rel, meta.is_dir()) {
if meta.is_dir() {
self.dir(&path)?;
} else if let Some(ext) = path.extension().and_then(|e| e.to_str()) {
if EXTENSIONS.contains(&ext) {
self.files.push(path);
}
} else if meta.is_file() && is_source(&path) {
self.files.push(path);
}
}
self.rel.pop();
@@ -73,6 +127,20 @@ impl Walk<'_> {
Ok(())
}
/// Records `dir` as entered, and answers whether it had not been entered
/// already. Identity, not spelling: `a/loop -> a` and `a/b/up -> ..` name
/// a directory the walk is already inside, and following either is the
/// cycle that only ends when the OS refuses a path. A symlink to a
/// directory the walk has *not* seen is followed once, so
/// `rtl -> ../shared/rtl` still contributes its files; the second link to
/// one target contributes nothing further, and the files are reported
/// under the first spelling that reached them.
///
/// A directory whose identity cannot be read is not entered.
fn enter(&mut self, dir: &Path) -> bool {
dir_id(dir).is_some_and(|id| self.visited.insert(id))
}
/// Reads `dir`'s `.gitignore`, if there is one, onto the rule stack.
/// Returns whether anything was pushed, so `dir` can pop it again.
fn push_ignore(&mut self, dir: &Path) -> std::io::Result<bool> {
@@ -214,6 +282,8 @@ fn glob_component(pattern: &str, name: &str) -> bool {
#[cfg(test)]
mod tests {
use super::*;
#[cfg(unix)]
use std::sync::atomic::{AtomicUsize, Ordering};
fn excluded(path: &str, pattern: &str) -> bool {
is_excluded(Path::new(path), &[pattern.to_string()])
@@ -320,6 +390,142 @@ mod tests {
assert!(!ignored_at(&[(0, "/x.sv")], "sub/x.sv"));
}
// ------------------------------------------------------------------
// Symlink cycles — `docs/features/walk-cycles/README.md`
//
// Every test below builds a real tree with real symlinks, because the
// question is what the filesystem answers, not what a mock does. Each
// one would run until the OS refused a path before the visited set.
// ------------------------------------------------------------------
/// A throwaway directory tree under the system temp dir, removed on
/// drop. `remove_dir_all` unlinks a symlink instead of following it, so
/// a tree with a cycle in it is cleaned up like any other.
#[cfg(unix)]
struct TempTree {
path: PathBuf,
}
#[cfg(unix)]
impl TempTree {
fn new(tag: &str) -> TempTree {
static COUNTER: AtomicUsize = AtomicUsize::new(0);
let n = COUNTER.fetch_add(1, Ordering::Relaxed);
let path =
std::env::temp_dir().join(format!("lucisv-walk-{}-{tag}-{n}", std::process::id()));
let _ = std::fs::remove_dir_all(&path);
std::fs::create_dir_all(&path).expect("create temp dir");
TempTree { path }
}
fn write(&self, rel: &str, text: &str) {
let path = self.path.join(rel);
if let Some(parent) = path.parent() {
std::fs::create_dir_all(parent).expect("create parent");
}
std::fs::write(&path, text).expect("write");
}
/// A source file with enough in it to be worth finding.
fn source(&self, rel: &str) {
self.write(rel, "module m;\nendmodule\n");
}
/// `rel` as a symlink to `target`, which is relative to `rel`'s own
/// directory — the spelling a checked-in symlink actually uses.
fn link(&self, rel: &str, target: &str) {
let path = self.path.join(rel);
if let Some(parent) = path.parent() {
std::fs::create_dir_all(parent).expect("create parent");
}
std::os::unix::fs::symlink(target, &path).expect("symlink");
}
/// The walk from `rel` (empty for the root), as sorted paths
/// relative to the tree root.
fn walk(&self, rel: &str) -> Vec<String> {
let start = if rel.is_empty() { self.path.clone() } else { self.path.join(rel) };
let mut files = Vec::new();
collect_files(start.to_str().expect("utf-8 temp path"), &[], true, &mut files)
.expect("the walk finishes");
let mut out: Vec<String> = files
.iter()
.map(|p| p.strip_prefix(&self.path).unwrap_or(p).to_string_lossy().into_owned())
.collect();
out.sort();
out
}
}
#[test]
#[cfg(unix)]
fn a_directory_linking_to_itself_is_entered_once() {
let tree = TempTree::new("selfloop");
tree.source("a/x.sv");
tree.link("a/loop", "../a");
assert_eq!(tree.walk(""), ["a/x.sv"]);
}
#[test]
#[cfg(unix)]
fn a_link_to_an_ancestor_terminates_from_a_nested_start() {
let tree = TempTree::new("uplink");
tree.source("root.sv");
tree.source("a/x.sv");
tree.link("a/up", "..");
// Starting *inside* the cycle: `a` is entered, then `a/up` is the
// root, which the walk has not seen yet and so does enter — once.
// Its own `a` is the directory already being walked, and stops.
assert_eq!(tree.walk("a"), ["a/up/root.sv", "a/x.sv"]);
}
#[test]
#[cfg(unix)]
fn two_links_to_one_directory_yield_its_files_once() {
let tree = TempTree::new("twolinks");
tree.source("shared/x.sv");
// Sorted after `shared`, so the real directory is the spelling that
// reaches the file first; whichever name wins, the file is reported
// exactly once.
tree.link("z1", "shared");
tree.link("z2", "shared");
assert_eq!(tree.walk(""), ["shared/x.sv"]);
}
#[test]
#[cfg(unix)]
fn a_link_to_a_directory_not_yet_walked_is_still_followed() {
let tree = TempTree::new("sibling");
tree.source("shared/rtl/x.sv");
tree.link("proj/rtl", "../shared/rtl");
// The `rtl -> ../shared/rtl` of a real checkout: the target is
// outside the walk, so the link is the only way to it.
assert_eq!(tree.walk("proj"), ["proj/rtl/x.sv"]);
}
#[test]
#[cfg(unix)]
fn a_dangling_directory_link_is_skipped_and_a_dangling_source_link_is_reported() {
// The directory link cannot be entered; the source-file link is kept
// so the front end's "no such file" error survives (0.42.0 parity).
let tree = TempTree::new("dangling");
tree.source("a/x.sv");
tree.link("a/gone.sv", "nowhere.sv");
tree.link("a/gonedir", "nowhere");
assert_eq!(tree.walk(""), ["a/gone.sv", "a/x.sv"]);
}
#[test]
#[cfg(unix)]
fn a_cycle_inside_an_ignored_directory_is_never_entered() {
let tree = TempTree::new("ignoredcycle");
tree.write(".gitignore", "build\n");
tree.source("keep.sv");
tree.source("build/y.sv");
tree.link("build/loop", "../build");
assert_eq!(tree.walk(""), ["keep.sv"]);
}
#[test]
fn unsupported_syntax_degrades_to_plain_globbing() {
// `**` is just two stars inside one component; documented.
+120 -28
View File
@@ -10,6 +10,16 @@
//! table `lucisv.toml` now carries. See
//! `docs/features/semantic-lints-on/README.md` and
//! `docs/features/server-lint/README.md`.
//!
//! Since §42 the two halves of that selection are one contract: the editor's
//! settings play the role the CLI's flags play, and the project's `[lint]`
//! table is what stands when the editor says nothing —
//! `docs/features/lint-config-contract/README.md`, and [`project`] for the
//! project's half.
mod project;
pub use project::{ConfigProblems, ProblemLog, ProjectLint};
use std::collections::BTreeSet;
use std::path::{Path, PathBuf};
@@ -47,6 +57,10 @@ pub struct LintRun<'a> {
/// `lucisv.toml` and from `lucisv.lint.waivers`. Empty unless one is
/// configured, and then costing the pass nothing.
external: ExternalWaivers,
/// What the buffer's `lucisv.toml` asked for and did not get. Reported by
/// whoever can talk to the client — [`ProblemLog`] keeps it to once per
/// (config file, message) — and never fatal here: §42.2.
problems: ConfigProblems,
}
impl Default for LintRun<'_> {
@@ -57,6 +71,7 @@ impl Default for LintRun<'_> {
options: RuleOptions::new(),
line_length: DEFAULT_LINE_LENGTH,
external: ExternalWaivers::default(),
problems: ConfigProblems::default(),
}
}
}
@@ -78,11 +93,28 @@ impl<'a> LintRun<'a> {
let index = ws.index();
let own = doc.path.as_deref().and_then(|path| index.file_id(path));
let workspace = index.files().len() > usize::from(own.is_some());
let rules = enabled_rules(ws.client_settings(), workspace);
let oracle = workspace.then_some(IndexMentions { index, own });
let (options, line_length, file) = configured(ws.client_settings(), doc);
let external = external_waivers(&waiver_paths(ws.client_settings(), ws.roots(), &file)).0;
LintRun { rules, oracle, options, line_length, external }
// One discovery for the whole pass: the selection, the options, the
// width and the waiver paths all read the same `FileConfig`, so
// reading the project's rules costs no extra stat and no extra open.
let (options, line_length, file, mut messages) = configured(ws.client_settings(), doc);
let (from_file, bad_names) = ProjectLint::read(&file);
messages.extend(bad_names);
let rules = enabled_rules(ws.client_settings(), &from_file, workspace);
let (mut external, bad_waivers) = external_waivers(&project_waivers(&file));
messages.extend(bad_waivers);
// The editor's own waiver files are read separately and their
// problems dropped: `notification::apply_settings` already said them
// once, where the setting arrived.
external.absorb(external_waivers(&editor_waivers(ws.client_settings(), ws.roots())).0);
let problems = ConfigProblems::new(&file, messages);
LintRun { rules, oracle, options, line_length, external, problems }
}
/// What this buffer's `lucisv.toml` asked for and did not get, for a
/// caller that can tell the user about it.
pub fn config_problems(&self) -> &ConfigProblems {
&self.problems
}
/// A run carrying these external waivers — for the tests that pin what a
@@ -125,23 +157,33 @@ impl<'a> LintRun<'a> {
/// reads it per formatting request: a `lucisv.toml` edited while the server
/// runs takes effect at the next publish, and the read is a few stats beside
/// a parse and an analysis the same pass already paid for.
fn configured(client: &ClientSettings, doc: &Document) -> (RuleOptions, usize, FileConfig) {
fn configured(
client: &ClientSettings,
doc: &Document,
) -> (RuleOptions, usize, FileConfig, Vec<String>) {
let file = doc
.path
.as_deref()
.and_then(|path| lucisv_core::config::Discovery::new(true).for_file(path).ok())
.unwrap_or_default();
let mut options = RuleOptions::new();
let mut problems = Vec::new();
for entry in &file.lint_options {
// A broken entry in the file is dropped here rather than reported:
// `format::settings_for` already surfaces a `lucisv.toml` problem to
// the user, and `lucisv check` fails the run over it with file and
// line, which is where a config error belongs.
let _ = options.set_raw(&entry.rule, &entry.key, &entry.raw);
// A broken entry in the file is dropped rather than fatal — an editor
// cannot fail a run — but it is *said*, in the words `lucisv check`
// fails with, once per (config file, entry): §42.2. Silently dropping
// it left a user's option doing nothing with nothing to read about it.
if let Err(problem) = options.set_raw(&entry.rule, &entry.key, &entry.raw) {
let source = file
.source
.as_ref()
.map_or_else(|| "lucisv.toml".to_string(), |path| path.display().to_string());
problems.push(format!("{source}:{}: rule `{}` {problem}", entry.line, entry.rule));
}
}
options.overlay(&client.lint_options);
let width = file.line_length.or(client.line_length).unwrap_or(DEFAULT_LINE_LENGTH);
(options, width, file)
(options, width, file, problems)
}
/// The waiver files governing one buffer: its `lucisv.toml`'s `[lint] waivers`
@@ -153,17 +195,38 @@ fn configured(client: &ClientSettings, doc: &Document) -> (RuleOptions, usize, F
/// first workspace root, exactly as `lucisv.filelist` is; a `lucisv.toml`'s
/// paths were already resolved against that file's own directory.
pub fn waiver_paths(client: &ClientSettings, roots: &[PathBuf], file: &FileConfig) -> Vec<PathBuf> {
let mut paths: Vec<PathBuf> = file.lint_waivers.iter().flatten().cloned().collect();
for setting in &client.lint_waivers {
let path = Path::new(setting);
paths.push(match roots.first() {
Some(root) if path.is_relative() => root.join(path),
_ => path.to_path_buf(),
});
}
let mut paths = project_waivers(file);
paths.extend(editor_waivers(client, roots));
paths
}
/// The `[lint] waivers` of one config file, already resolved by `Discovery`
/// against that file's own directory.
///
/// Read apart from the editor's since §42.2, because a problem in one of
/// *these* is the project's and belongs in the output channel with the
/// `lucisv.toml` that named it, while a problem in the editor's was already
/// said where the setting arrived.
fn project_waivers(file: &FileConfig) -> Vec<PathBuf> {
file.lint_waivers.iter().flatten().cloned().collect()
}
/// The waiver files `lucisv.lint.waivers` names, a relative one anchored at
/// the first workspace root exactly as `lucisv.filelist` is.
fn editor_waivers(client: &ClientSettings, roots: &[PathBuf]) -> Vec<PathBuf> {
client
.lint_waivers
.iter()
.map(|setting| {
let path = Path::new(setting);
match roots.first() {
Some(root) if path.is_relative() => root.join(path),
_ => path.to_path_buf(),
}
})
.collect()
}
/// Those files, read: the waivers and one message per file or line that could
/// not be used.
///
@@ -188,32 +251,45 @@ pub fn external_waivers(paths: &[PathBuf]) -> (ExternalWaivers, Vec<String>) {
(waivers, problems)
}
/// Which rules a buffer is linted with, given what the editor's settings say.
/// Which rules a buffer is linted with, given what the editor's settings and
/// the buffer's own `lucisv.toml` say.
///
/// **The one ladder**, top rung last — every rung may undo the one above it:
///
/// 1. the base set is what the rules themselves declare: `default_on`, plus
/// the `needs_workspace` rules when `has_oracle`;
/// 2. a non-empty `lucisv.lint.select` **replaces** that base set, exactly as
/// `--select` replaces it on the command line;
/// `--select` replaces it on the command line; when the editor names
/// nothing, the project's `[lint] select` replaces it instead — the flag
/// when there is one, else the file, which is `lucisv check`'s own `pick`;
/// 3. a `lucisv.lint.severity.<class>` switched off **removes** every rule of
/// that class;
/// 4. a `lucisv.lint.rules.<name>` set to `on` or `off` sets or clears that
/// one rule — the per-rule word beats the class word, which is what makes
/// "all style off except `no-tabs`" expressible;
/// 5. `lucisv.lint.ignore` **removes** — the off switch of last resort, the
/// one a user reaches for when nothing else worked.
/// one a user reaches for when nothing else worked; when the editor names
/// nothing there either, the project's `[lint] ignore` removes instead.
///
/// Rungs 2 and 5 accept a severity word wherever a rule name fits.
pub fn enabled_rules(settings: &ClientSettings, has_oracle: bool) -> Vec<&'static dyn Rule> {
let base = if settings.lint_select.is_empty() {
/// Rungs 3 and 4 are the **editor's alone**: a `lucisv.toml` has no such
/// keys, and the command line has no such flags. Rungs 2 and 5 are decided
/// independently — a project that selects and a user who only ignores keep
/// both halves. Every list accepts a severity word wherever a rule name fits,
/// the project's as much as the editor's.
pub fn enabled_rules(
settings: &ClientSettings,
project: &ProjectLint,
has_oracle: bool,
) -> Vec<&'static dyn Rule> {
let select = pick(&settings.lint_select, &project.select);
let base = if select.is_empty() {
if has_oracle {
workspace_rules()
} else {
default_rules()
}
} else {
named(&settings.lint_select)
named(select)
};
let mut on: BTreeSet<&'static str> = base.iter().map(|rule| rule.name()).collect();
@@ -232,12 +308,22 @@ pub fn enabled_rules(settings: &ClientSettings, has_oracle: bool) -> Vec<&'stati
on.remove(rule.name());
}
}
for rule in named(&settings.lint_ignore) {
for rule in named(pick(&settings.lint_ignore, &project.ignore)) {
on.remove(rule.name());
}
vlog_linter::all_rules().into_iter().filter(|rule| on.contains(rule.name())).collect()
}
/// The editor's list when it said anything, else the project's — the twin of
/// `lucisv/src/lint.rs`'s `pick`, which is the whole of §42's contract.
fn pick<'a>(editor: &'a [String], project: &'a [String]) -> &'a [String] {
if editor.is_empty() {
project
} else {
editor
}
}
/// Every rule a list of `--select`-style words names, unknown words skipped —
/// they were already dropped when the settings were parsed, and a name that
/// survived that filter always resolves.
@@ -619,8 +705,14 @@ mod tests {
/// be true of the result).
#[test]
fn the_enabled_rules_ladder_is_the_documented_one() {
// The project's half of the ladder is `lint::project`'s own table
// test; this one holds it empty, which is the editor-only ladder
// §33.1 wrote.
let names = |settings: &ClientSettings, oracle: bool| -> Vec<&'static str> {
enabled_rules(settings, oracle).into_iter().map(|rule| rule.name()).collect()
enabled_rules(settings, &ProjectLint::default(), oracle)
.into_iter()
.map(|rule| rule.name())
.collect()
};
let with = |f: &dyn Fn(&mut ClientSettings)| {
let mut settings = ClientSettings::default();
+398
View File
@@ -0,0 +1,398 @@
//! What a buffer's `lucisv.toml` says about linting, and what could not be
//! used from it.
//!
//! The contract (§42): **the editor's settings play the role the CLI's flags
//! play**. `lucisv check` picks the flag when one was given and the project
//! file otherwise (`lucisv/src/lint.rs`'s `pick`); the server picks
//! `lucisv.lint.select` when it is non-empty and `[lint] select` otherwise,
//! key by key, so one buffer linted two ways is linted the same way. See
//! `docs/features/lint-config-contract/README.md`.
use std::collections::hash_map::DefaultHasher;
use std::collections::{BTreeSet, HashMap};
use std::hash::{Hash, Hasher};
use std::path::PathBuf;
use lucisv_core::config::FileConfig;
/// The selection a buffer's `lucisv.toml` carries: `[lint] select` and
/// `[lint] ignore`, exactly as `--select` and `--ignore` carry them.
///
/// [`ProjectLint::default`] — both lists empty — is a buffer with no config
/// file, or one whose `[lint]` table says nothing about rules: the editor's
/// settings and the base set then decide everything, which is what this
/// server did before §42.
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct ProjectLint {
/// `[lint] select`: run exactly these rules, replacing the base set —
/// unless the editor named some, which outranks it.
pub select: Vec<String>,
/// `[lint] ignore`: rules dropped from whatever `select` left — unless
/// the editor named some.
pub ignore: Vec<String>,
}
impl ProjectLint {
/// One config file's selection, with every name the registry does not
/// know dropped and reported.
///
/// `lucisv check` *fails the run* over an unknown name, which an editor
/// cannot do — but it must not silently obey a typo either: a
/// `select = ["no-tab"]` taken at face value would resolve to no rules at
/// all and blank the file's squiggles, which reads as "lucisv is happy"
/// rather than "lucisv could not understand your config". So the name is
/// dropped, said once, and the rest of the list still applies; a `select`
/// left empty by the dropping falls back to the base set.
pub fn read(file: &FileConfig) -> (ProjectLint, Vec<String>) {
let mut problems = Vec::new();
let select = known(file, "select", file.lint_select.as_deref(), &mut problems);
let ignore = known(file, "ignore", file.lint_ignore.as_deref(), &mut problems);
(ProjectLint { select, ignore }, problems)
}
}
/// The names of one `[lint]` list that name something, the others reported.
fn known(
file: &FileConfig,
key: &str,
list: Option<&[String]>,
problems: &mut Vec<String>,
) -> Vec<String> {
let mut kept = Vec::new();
for name in list.unwrap_or(&[]) {
if vlog_linter::rules_named(name).is_some() {
kept.push(name.clone());
} else {
// No line number: `lucisv_core::config` records one per
// `[lint.<rule>]` entry, because those are checked one by one,
// and the list keys are one value each.
problems.push(format!("{}: [lint] {key}: unknown rule: {name}", source_of(file)));
}
}
kept
}
/// The config file's path as an error should name it.
fn source_of(file: &FileConfig) -> String {
file.source.as_ref().map_or_else(|| "lucisv.toml".to_string(), |p| p.display().to_string())
}
/// What one buffer's `lucisv.toml` asked for and did not get: a
/// `[lint.<rule>]` entry the registry refused, a name in `[lint] select` that
/// is not a rule, a `[lint] waivers` file that is not there or holds a
/// directive that does not parse.
///
/// Every message is written the way `lucisv check` writes it —
/// `<file>:<line>: <message>` — so the same mistake reads the same in CI and
/// in an editor's output channel. **Nothing here is fatal**: the entry is
/// dropped and the buffer is still linted with everything that was
/// understood, because a server cannot fail a run the way a command can.
#[derive(Debug, Default, Clone)]
pub struct ConfigProblems {
/// The config file they came from. `None` — no config file was found —
/// means there is nothing to complain about and `messages` is empty.
source: Option<PathBuf>,
/// A stamp of that file's lint content, so an edited config gets a fresh
/// hearing: see [`ProblemLog`].
stamp: u64,
/// The messages, in file order.
messages: Vec<String>,
}
impl ConfigProblems {
/// The problems found in this config file.
pub fn new(file: &FileConfig, messages: Vec<String>) -> ConfigProblems {
ConfigProblems { source: file.source.clone(), stamp: stamp_of(file), messages }
}
/// Whether anything at all could not be used.
pub fn is_empty(&self) -> bool {
self.messages.is_empty()
}
}
/// A stamp over everything in a config file that [`ConfigProblems`] can be
/// about, so that editing the file re-arms the report and editing a source
/// beside it does not.
///
/// A hash rather than a modification time: the file is re-read on every lint
/// pass anyway (`configured`), and a hash of what was parsed cannot be fooled
/// by a filesystem whose timestamps are coarse.
fn stamp_of(file: &FileConfig) -> u64 {
let mut hasher = DefaultHasher::new();
file.lint_select.hash(&mut hasher);
file.lint_ignore.hash(&mut hasher);
file.lint_waivers.hash(&mut hasher);
for entry in &file.lint_options {
entry.rule.hash(&mut hasher);
entry.key.hash(&mut hasher);
entry.raw.hash(&mut hasher);
entry.line.hash(&mut hasher);
}
hasher.finish()
}
/// Which config problems have already been said, so each is said **once**.
///
/// Once per (config file, message), not once per lint pass: the pass runs on
/// every keystroke and every index rebuild, and a hundred copies of one line
/// in the output channel is not a report, it is noise. The editor-settings
/// path has said its own problems once since §34 — this is the same promise
/// for the file a project checks in.
///
/// A config file whose lint content changed clears its own memo, so a user
/// who edits `lucisv.toml` and gets it wrong again is told again. The memo is
/// keyed by path, so it holds one small entry per config file a session ever
/// linted through.
#[derive(Debug, Default)]
pub struct ProblemLog {
said: HashMap<PathBuf, Said>,
}
/// One config file's memo: the content it was taken under, and what was said.
#[derive(Debug, Default)]
struct Said {
stamp: u64,
messages: BTreeSet<String>,
}
impl ProblemLog {
/// The messages that have not been said yet for this config file, marked
/// as said. An empty answer means the user has already been told.
pub fn unsaid(&mut self, problems: &ConfigProblems) -> Vec<String> {
let Some(source) = problems.source.clone() else { return Vec::new() };
if problems.is_empty() {
return Vec::new();
}
let said = self.said.entry(source).or_default();
if said.stamp != problems.stamp {
said.stamp = problems.stamp;
said.messages.clear();
}
problems
.messages
.iter()
.filter(|message| said.messages.insert((*message).clone()))
.cloned()
.collect()
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::settings::ClientSettings;
use crate::state::{Document, Workspace};
use lsp_types::Uri;
use std::str::FromStr;
use vlog_linter::Severity;
fn config(text: &str) -> FileConfig {
let mut file = lucisv_core::config::parse(text).expect("the config parses");
file.source = Some(PathBuf::from("/rtl/lucisv.toml"));
file
}
fn names(settings: &ClientSettings, project: &ProjectLint, oracle: bool) -> Vec<&'static str> {
super::super::enabled_rules(settings, project, oracle)
.into_iter()
.map(|rule| rule.name())
.collect()
}
fn editor(select: &[&str], ignore: &[&str]) -> ClientSettings {
ClientSettings {
lint_select: select.iter().map(|s| (*s).to_string()).collect(),
lint_ignore: ignore.iter().map(|s| (*s).to_string()).collect(),
..ClientSettings::default()
}
}
fn project(select: &[&str], ignore: &[&str]) -> ProjectLint {
ProjectLint {
select: select.iter().map(|s| (*s).to_string()).collect(),
ignore: ignore.iter().map(|s| (*s).to_string()).collect(),
}
}
/// §42.1's table: every combination of {toml select, editor select} ×
/// {toml ignore, editor ignore}, against the ladder. The editor's list
/// wins when it says anything, the project's is used when it does not,
/// and the two keys are decided **independently** — the CLI's `pick`,
/// applied twice.
#[test]
fn the_editor_outranks_the_project_key_by_key() {
// Four rules stand in for the whole registry: two the project may
// name and two the editor may, so a row's answer says which list was
// consulted rather than which happened to be shorter.
// (toml select, editor select, toml ignore, editor ignore, expected).
type Row = (
&'static [&'static str],
&'static [&'static str],
&'static [&'static str],
&'static [&'static str],
&'static [&'static str],
);
let rows: [Row; 8] = [
// (toml select, editor select, toml ignore, editor ignore) => rules
(&[], &[], &[], &[], &[]),
(&["no-tabs"], &[], &[], &[], &["no-tabs"]),
(&[], &["no-tabs"], &[], &[], &["no-tabs"]),
(&["module-name-style"], &["no-tabs"], &[], &[], &["no-tabs"]),
(&["no-tabs", "module-name-style"], &[], &["no-tabs"], &[], &["module-name-style"]),
(&["no-tabs", "module-name-style"], &[], &[], &["no-tabs"], &["module-name-style"]),
(
&["no-tabs", "module-name-style"],
&[],
&["module-name-style"],
&["no-tabs"],
&["module-name-style"],
),
(
&["module-name-style"],
&["no-tabs", "module-name-style"],
&["no-tabs"],
&["module-name-style"],
&["no-tabs"],
),
];
for (toml_select, ed_select, toml_ignore, ed_ignore, want) in rows {
let settings = editor(ed_select, ed_ignore);
let from_file = project(toml_select, toml_ignore);
let got = names(&settings, &from_file, false);
if want.is_empty() {
// The empty row is the base set, which is too long to spell.
assert_eq!(
got,
super::super::default_rules().iter().map(|r| r.name()).collect::<Vec<_>>(),
"neither list said anything, so the base set stands"
);
} else {
assert_eq!(
got, want,
"{toml_select:?} {ed_select:?} {toml_ignore:?} {ed_ignore:?}"
);
}
}
}
/// A severity word stands for its whole class in the toml's lists exactly
/// as it does in the editor's, and as `--select style` does.
#[test]
fn a_severity_word_works_in_the_projects_lists_too() {
let styled = names(&ClientSettings::default(), &project(&["style"], &[]), true);
assert!(!styled.is_empty());
assert!(styled
.iter()
.all(|name| vlog_linter::rule_by_name(name).expect("a rule").severity()
== Severity::Style));
let quiet = names(&ClientSettings::default(), &project(&[], &["style"]), true);
assert!(!quiet.is_empty());
assert!(quiet
.iter()
.all(|name| vlog_linter::rule_by_name(name).expect("a rule").severity()
!= Severity::Style));
}
/// A rung 3 or 4 switch is the editor's alone, and still applies over a
/// selection the project made.
#[test]
fn the_editor_only_rungs_still_apply_over_a_project_selection() {
let mut settings = ClientSettings::default();
settings.lint_severity.insert(Severity::Style, false);
let from_file = project(&["no-tabs", "wire-reg-mixup"], &[]);
assert_eq!(
names(&settings, &from_file, false),
vec!["wire-reg-mixup"],
"the class switch removes the project's style rule"
);
settings.lint_rules.insert("no-tabs".to_string(), true);
assert_eq!(
names(&settings, &from_file, false),
vec!["no-tabs", "wire-reg-mixup"],
"and the per-rule word puts it back"
);
}
/// A name the registry does not know is dropped and reported — the run
/// `lucisv check` would have failed keeps going here with what was
/// understood.
#[test]
fn an_unknown_name_in_the_projects_list_is_dropped_and_said() {
let (from_file, problems) =
ProjectLint::read(&config("[lint]\nselect = [\"no-tab\", \"no-tabs\"]\n"));
assert_eq!(from_file.select, vec!["no-tabs"]);
assert_eq!(problems, vec!["/rtl/lucisv.toml: [lint] select: unknown rule: no-tab"]);
assert_eq!(names(&ClientSettings::default(), &from_file, false), vec!["no-tabs"]);
// Every name unknown leaves the list empty, which is the base set —
// the safe direction: some rules rather than none.
let (none, problems) = ProjectLint::read(&config("[lint]\nselect = [\"nope\"]\n"));
assert!(none.select.is_empty());
assert_eq!(problems.len(), 1);
assert_eq!(
names(&ClientSettings::default(), &none, false),
super::super::default_rules().iter().map(|r| r.name()).collect::<Vec<_>>()
);
}
/// §42.2: a `[lint.<rule>]` entry the registry refuses is reported once,
/// however many lint passes run, and the buffer keeps being linted.
#[test]
fn a_rejected_option_is_said_once_and_the_lint_still_runs() {
let dir = std::env::temp_dir()
.join(format!("lucisv_lint_project_{}_rejected", std::process::id()));
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).expect("temp dir");
std::fs::write(dir.join("lucisv.toml"), "[lint.line-length]\nlength = \"wide\"\n")
.expect("write config");
let path = dir.join("m.sv");
let text = "module m;\n\twire a;\nendmodule\n";
std::fs::write(&path, text).expect("write source");
let uri = Uri::from_str(&format!("file://{}", path.display())).expect("uri");
let mut ws = Workspace::default();
ws.set_document(uri.clone(), text.to_string());
let mut log = ProblemLog::default();
let mut said = Vec::new();
for _ in 0..3 {
let doc: &Document = ws.document(&uri).expect("open");
let run = super::super::LintRun::for_document(&ws, doc);
// The lint still runs: the tab is still a finding.
assert!(
super::super::violations_in(doc, &run).iter().any(|v| v.rule == "no-tabs"),
"the buffer is still linted with the entry dropped"
);
said.extend(log.unsaid(run.config_problems()));
}
assert_eq!(said.len(), 1, "said once across three passes: {said:#?}");
let expected = format!("{}:2: rule `line-length` ", dir.join("lucisv.toml").display());
assert!(said[0].starts_with(&expected), "the wording `lucisv check` prints: {}", said[0]);
let _ = std::fs::remove_dir_all(&dir);
}
/// An edited config gets a fresh hearing: the memo is keyed by the file's
/// lint content, so the same mistake made again after a change is said
/// again.
#[test]
fn an_edited_config_re_arms_the_report() {
let first = config("[lint.line-length]\nlength = \"wide\"\n");
let problems = ConfigProblems::new(&first, vec!["/rtl/lucisv.toml:2: bad".to_string()]);
let mut log = ProblemLog::default();
assert_eq!(log.unsaid(&problems).len(), 1);
assert!(log.unsaid(&problems).is_empty(), "and not twice");
// Same message, different file content: the user has been editing.
let edited = config("# a comment\n[lint.line-length]\nlength = \"wide\"\n");
let again = ConfigProblems::new(&edited, vec!["/rtl/lucisv.toml:3: bad".to_string()]);
assert_eq!(log.unsaid(&again).len(), 1, "a changed config is heard again");
// A buffer with no config file has nothing to report.
let nowhere = ConfigProblems::new(&FileConfig::default(), vec!["never".to_string()]);
assert!(log.unsaid(&nowhere).is_empty());
}
}
+38 -4
View File
@@ -94,10 +94,44 @@ impl Server {
fn diagnostics_of(&self, uri: &Uri) -> Vec<lsp_types::Diagnostic> {
let Some(doc) = self.workspace.document(uri) else { return Vec::new() };
// The lint pass is given the project: the rule selection
// `lucisv.lint.*` resolved to, and the index's identifier census, which
// is what lets the semantic rules default on here without accusing a
// signal another file reads (`docs/features/semantic-lints-on/`).
diagnostics::all_in(doc, &crate::lint::LintRun::for_document(&self.workspace, doc))
// `lucisv.lint.*` and the buffer's `[lint]` table resolved to, and the
// index's identifier census, which is what lets the semantic rules
// default on here without accusing a signal another file reads
// (`docs/features/semantic-lints-on/`).
let run = crate::lint::LintRun::for_document(&self.workspace, doc);
self.report_config_problems(&run);
diagnostics::all_in(doc, &run)
}
/// Say, once, what this buffer's `lucisv.toml` asked for and did not get.
///
/// Once per (config file, entry), not once per pass: this runs on every
/// keystroke and every index rebuild. The words are the ones `lucisv
/// check` fails the run with, `<file>:<line>: <message>`, so one mistake
/// reads the same in CI and here — but nothing is fatal, the entry is
/// dropped and the buffer is still linted with everything understood
/// (§42.2). Logged, not shown: a typo in a checked-in config is not worth
/// a popup on every editor in the project.
fn report_config_problems(&self, run: &crate::lint::LintRun) {
let problems = run.config_problems();
if problems.is_empty() {
return;
}
// The borrow is released before anything is sent: `notify` takes
// `&self` and could otherwise reach a second borrow one day.
let unsaid = match self.lint_config_problems.try_borrow_mut() {
Ok(mut log) => log.unsaid(problems),
Err(_) => return,
};
for message in unsaid {
self.notify(
LogMessage::METHOD,
LogMessageParams {
typ: MessageType::WARNING,
message: format!("lucisv: {message}; ignored"),
},
);
}
}
/// Publish everything known about a buffer — parse errors and lint
+7
View File
@@ -121,6 +121,12 @@ pub struct Server {
/// for a document whenever its text changes, so the warning is said once
/// per file change rather than once per format-on-save.
config_warnings: HashSet<Uri>,
/// Which `[lint]` entries of which `lucisv.toml` have already been
/// reported (§42.2). Interior-mutable because a lint pass runs behind
/// `&self` — the pull models compute diagnostics inside a `map` over the
/// open buffers — and the memo is the one thing a pass has to write.
/// Nothing is called while it is borrowed.
lint_config_problems: std::cell::RefCell<crate::lint::ProblemLog>,
abilities: ClientAbilities,
/// The id of the file-watcher registration in force, if any. Kept so a
/// changed `lucisv.filelist` can replace it: the watched filelist path is
@@ -300,6 +306,7 @@ impl Server {
connection,
workspace: Workspace::default(),
config_warnings: HashSet::new(),
lint_config_problems: std::cell::RefCell::default(),
abilities,
watchers: None,
registrations: 0,
+23
View File
@@ -2730,6 +2730,29 @@ mod tests {
);
}
/// A workspace whose tree links back into itself. Before the walk kept a
/// visited set (`docs/features/walk-cycles/README.md`) this scan never
/// finished — the editor's index simply never came up. Each directory is
/// entered once now, so each package is registered exactly once: a second
/// registration would make the name *ambiguous*, and `indexed` only
/// counts a name found exactly once.
#[cfg(unix)]
#[test]
fn a_cyclic_workspace_is_scanned_once_and_finishes() {
let tree = Tree::new("cycle");
tree.package("rtl/a.sv", "a");
tree.package("rtl/sub/b.sv", "b");
// `rtl/self` is `rtl` itself; `rtl/sub/up` is `rtl` from one level
// down. Either one alone runs until the OS refuses a path.
std::os::unix::fs::symlink("../rtl", tree.path.join("rtl/self")).expect("symlink");
std::os::unix::fs::symlink("..", tree.path.join("rtl/sub/up")).expect("symlink");
let mut ws = Workspace::default();
ws.open_whole_workspace(vec![tree.path.clone()]);
assert_eq!(indexed(&ws, &["a", "b"]), ["a", "b"]);
assert_eq!(ws.walked_files(from_ref(&tree.path)).len(), 2, "two files, once each");
}
#[test]
fn a_folder_change_that_changes_nothing_asks_for_no_rescan() {
// Every no-op shape a client can send. Each must leave the root set
+205
View File
@@ -7758,3 +7758,208 @@ fn a_property_declaration_hovers_and_appears_in_the_outline() {
let _ = std::fs::remove_dir_all(&dir);
}
// ---------------------------------------------------------------------------
// §42 — one lint-configuration contract for the project file and the editor.
//
// `docs/features/lint-config-contract/README.md`: the editor's settings play
// the role the CLI's flags play, so a `lucisv.toml` a project checks in
// governs an editor exactly as it governs CI, and a `lucisv.lint.*` setting
// replaces it the way a flag replaces it.
// ---------------------------------------------------------------------------
/// A buffer with one tab and one trailing space: two style findings from two
/// rules, so a selection that keeps one and drops the other is visible.
const TWO_FINDINGS: &str = "module lint_contract;\n\twire a; \nendmodule\n";
/// The rule codes of every `publishDiagnostics` for one URI, in the order
/// they arrived, with a repeat of the previous answer collapsed: a republish
/// that says the same thing is not a step.
fn published_codes(messages: &[serde_json::Value], uri: &str) -> Vec<Vec<String>> {
let mut steps: Vec<Vec<String>> = Vec::new();
for message in messages {
if message["method"] != "textDocument/publishDiagnostics"
|| message["params"]["uri"] != serde_json::Value::String(uri.to_string())
{
continue;
}
let mut codes: Vec<String> = message["params"]["diagnostics"]
.as_array()
.expect("an array")
.iter()
.filter_map(|d| d["code"].as_str().map(str::to_string))
.collect();
codes.sort();
codes.dedup();
if steps.last() != Some(&codes) {
steps.push(codes);
}
}
steps
}
/// The `initialize`/`didOpen` prefix every session below opens with.
fn lint_session_start(dir: &Path, uri: &str, text: &str) -> String {
let root = format!("file://{}", dir.display());
[
frame(&format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"initialize","params":{{"processId":null,"rootUri":"{root}","capabilities":{{}}}}}}"#
)),
frame(r#"{"jsonrpc":"2.0","method":"initialized","params":{}}"#),
frame(&format!(
r#"{{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{{"textDocument":{{"uri":"{uri}","languageId":"systemverilog","version":1,"text":{}}}}}}}"#,
serde_json::to_string(text).expect("json")
)),
]
.concat()
}
/// A `didChangeConfiguration` carrying one `lucisv.lint.select` list.
fn select_push(rules: &str) -> String {
frame(&format!(
r#"{{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{{"settings":{{"lucisv":{{"lint":{{"select":[{rules}]}}}}}}}}}}"#
))
}
#[test]
fn a_projects_lint_select_governs_an_editor_until_a_setting_replaces_it() {
let dir = temp_dir("lint_contract_select");
std::fs::write(dir.join("lucisv.toml"), "[lint]\nselect = [\"no-tabs\"]\n")
.expect("write config");
let file = dir.join("lint_contract.sv");
std::fs::write(&file, TWO_FINDINGS).expect("write");
let uri = format!("file://{}", file.display());
let session = [
lint_session_start(&dir, &uri, TWO_FINDINGS),
// The editor names a rule of its own: it replaces the project's, as
// `--select` replaces it on the command line.
select_push("\"no-trailing-whitespace\""),
// ... and taking the setting back restores the project's.
select_push(""),
frame(r#"{"jsonrpc":"2.0","id":9,"method":"shutdown","params":null}"#),
frame(r#"{"jsonrpc":"2.0","method":"exit","params":null}"#),
]
.concat();
let steps = published_codes(&talk(&session), &uri);
assert_eq!(
steps,
vec![
vec!["no-tabs".to_string()],
vec!["no-trailing-whitespace".to_string()],
vec!["no-tabs".to_string()],
],
"the project selects, the editor replaces, and an emptied setting hands it back"
);
let _ = std::fs::remove_dir_all(&dir);
}
/// A `[lint.<rule>]` entry the registry refuses is said **once** in the
/// output channel — in the words `lucisv check` fails the run with — and the
/// buffer keeps being linted with the entry dropped (§42.2).
#[test]
fn a_rejected_project_option_is_logged_once_and_the_buffer_is_still_linted() {
let dir = temp_dir("lint_contract_option");
let config = dir.join("lucisv.toml");
std::fs::write(&config, "[lint.line-length]\nlength = \"wide\"\n").expect("write config");
let file = dir.join("lint_contract.sv");
std::fs::write(&file, TWO_FINDINGS).expect("write");
let uri = format!("file://{}", file.display());
// Three settings pushes, each of which republishes every open buffer, so
// the lint pass runs at least four times over the same bad config.
let session = [
lint_session_start(&dir, &uri, TWO_FINDINGS),
select_push("\"no-tabs\""),
select_push("\"no-trailing-whitespace\""),
select_push(""),
frame(r#"{"jsonrpc":"2.0","id":9,"method":"shutdown","params":null}"#),
frame(r#"{"jsonrpc":"2.0","method":"exit","params":null}"#),
]
.concat();
let messages = talk(&session);
let complaints: Vec<&str> = messages
.iter()
.filter(|m| m["method"] == "window/logMessage")
.filter_map(|m| m["params"]["message"].as_str())
.filter(|line| line.contains("line-length"))
.collect();
assert_eq!(complaints.len(), 1, "said once, not once per pass: {complaints:#?}");
assert!(
complaints[0].starts_with(&format!("lucisv: {}:2: rule `line-length` ", config.display())),
"the file and line `lucisv check` would name: {}",
complaints[0]
);
assert!(
!messages.iter().any(|m| m["method"] == "window/showMessage"),
"logged, not shown: {messages:#?}"
);
// And the lint kept running with the entry dropped.
let steps = published_codes(&messages, &uri);
assert!(
steps.iter().any(|codes| codes.contains(&"no-tabs".to_string())),
"the buffer is still linted: {steps:#?}"
);
let _ = std::fs::remove_dir_all(&dir);
}
/// The rules `lucisv check` runs over a file and the rules the server runs
/// over the same buffer, for three `lucisv.toml`s. Equal, or the two halves
/// of lucisv disagree about what a violation is — which is the whole reason
/// §42 exists.
#[test]
fn the_cli_and_the_server_run_the_same_rules_for_the_same_buffer() {
let Some(lucisv) = lucisv_binary() else {
eprintln!("skipped: the `lucisv` binary is not built next to `lucisv-server`");
return;
};
let configs = [
// No `[lint]` table at all: both front ends fall back to the base set.
("none", "line-length = 80\n"),
// A selection of one rule.
("one", "[lint]\nselect = [\"no-tabs\"]\n"),
// A severity word, and an `ignore` that takes one back out of it.
("class", "[lint]\nselect = [\"style\"]\nignore = [\"no-trailing-whitespace\"]\n"),
];
for (tag, config) in configs {
let dir = temp_dir(&format!("lint_contract_agree_{tag}"));
std::fs::write(dir.join("lucisv.toml"), config).expect("write config");
let file = dir.join("lint_contract.sv");
std::fs::write(&file, TWO_FINDINGS).expect("write");
let uri = format!("file://{}", file.display());
let output = Command::new(&lucisv)
.args(["check", "--output-format", "json"])
.arg(&file)
.output()
.expect("the lucisv binary runs");
let json: serde_json::Value =
serde_json::from_slice(&output.stdout).expect("the CLI prints one JSON array");
let mut from_cli: Vec<String> = json
.as_array()
.expect("an array")
.iter()
.filter_map(|item| item["rule"].as_str().map(str::to_string))
.collect();
from_cli.sort();
from_cli.dedup();
let session = [
lint_session_start(&dir, &uri, TWO_FINDINGS),
frame(r#"{"jsonrpc":"2.0","id":9,"method":"shutdown","params":null}"#),
frame(r#"{"jsonrpc":"2.0","method":"exit","params":null}"#),
]
.concat();
let from_server =
published_codes(&talk(&session), &uri).pop().expect("the server published something");
assert_eq!(from_server, from_cli, "the two front ends disagree under {config:?}");
assert!(!from_cli.is_empty(), "a config that reports nothing proves nothing: {config:?}");
let _ = std::fs::remove_dir_all(&dir);
}
}
+23 -12
View File
@@ -296,29 +296,40 @@ impl<'a> Fmt<'a> {
pub(super) fn data_decl(&self, d: &DataDecl) -> Doc {
let mut docs = Vec::new();
if let Some(net) = &d.net {
docs.push(text(format!("{net} ")));
docs.push(text(net.clone()));
self.net_delay(d, false, &mut docs);
}
self.net_delay(d, false, &mut docs);
self.qualifier_run(&d.qualifiers, &mut docs);
if let Some(t) = self.data_type(&d.ty) {
docs.push(t);
docs.push(text(" "));
self.net_delay(d, true, &mut docs);
}
self.net_delay(d, true, &mut docs);
// Neither arm needs an `else`: a delay before the type is only read
// after a net keyword, and one after the type only when a type was
// actually written, so an implicit type has none to print.
docs.push(self.declarators(&d.declarators));
concat(docs)
}
/// `#5 ` — the declaration's net delay and the space after it, but only
/// when it was written on the side of the data type `after_type` names.
/// IEEE 1800 §6.7 allows either side and lucisv prints it where the
/// source put it; moving it across the type would reorder tokens, which
/// `verify.rs` refuses.
/// The separator that follows the word just emitted, and then `#5` when
/// the declaration's net delay was written on the side of the data type
/// `after_type` names. IEEE 1800 §6.7 allows either side and lucisv
/// prints it where the source put it; moving it across the type would
/// reorder tokens, which `verify.rs` refuses.
///
/// The separator is the delay's `before_hash` comments when it has any
/// (`wire /* c */ #5 w;`) and a plain space otherwise — so a declaration
/// with no comment there is laid out exactly as it was before the slot
/// existed, delay or no delay.
fn net_delay(&self, d: &DataDecl, after_type: bool, docs: &mut Vec<Doc>) {
let Some(delay) = d.delay.as_ref().filter(|n| n.after_type == after_type) else {
return;
};
let delay = d.delay.as_ref().filter(|n| n.after_type == after_type);
match delay.map(|n| &n.before_hash).filter(|c| !c.is_empty()) {
Some(comments) => self.inline_comments_spaced(comments, docs),
None => docs.push(text(" ")),
}
let Some(delay) = delay else { return };
docs.push(text("#"));
self.slot_comments(&delay.after_hash, docs);
docs.push(self.expr(&delay.expr));
docs.push(text(" "));
}
@@ -53,20 +53,45 @@ module SimDTM (input clk, output [31:0] exit);
wire [31:0] #0.1 __debug_resp_bits_data = debug_resp_bits_data;
endmodule
====
# SKIP a comment written directly in front of the `#` has no slot to be
# printed from, so `verify.rs` refuses the file rather than moving it. This
# is *pre-existing* for the before-the-type position — it behaves the same
# way with no `[7:0]` in front — and the after-the-type position inherits
# it unchanged. Recorded, not fixed: giving the delay a comment slot is a
# `comment-slots` change, not a §38 one.
# a comment written directly in front of the `#` is the delay's own —
# `NetDelay::before_hash`, TODO §43.2. It was the `#SKIP` §38 recorded and
# `verify.rs` refused the file for; the slot prints it back where it was
# written, on either side of the data type.
module m;
wire /* c */ #5 x;
wire [7:0] /* d */ #1 z;
wire [3:0] /* one */ /* two */ #3 w;
endmodule
----
module m;
wire /* c */ #5 x;
wire [7:0] /* d */ #1 z;
wire [3:0] /* one */ /* two */ #3 w;
endmodule
====
# the delay's other gap, between the `#` and the value: `after_hash`. Both
# slots at once on one declaration, since the fuzzer asks for both
module m;
wire # /* why */ 5 x;
wire [7:0] /* a */ # /* b */ 1 z = q;
endmodule
----
module m;
wire # /* why */ 5 x;
wire [7:0] /* a */ # /* b */ 1 z = q;
endmodule
====
# a line comment in the same slot runs to end of line, so the `#` cannot
# follow it: it starts the next one, the way the `wire #5 /* after */` case
# below breaks before its declarator
module m;
wire // why the delay
#2 y;
endmodule
----
module m;
wire // why the delay
#2 y;
endmodule
====
# the other three gaps around a delay do have slots and round-trip
+5 -1
View File
@@ -2350,6 +2350,10 @@ const RTL_FIXTURES: &[&str] = &[
"package p;\n typedef struct packed {\n logic [3:0] hi;\n logic [3:0] lo;\n } word_t;\n typedef enum logic [1:0] {A = 2'd0, B, C} st_e;\nendpackage\n",
"module m;\n sub #(.W(8)) u0 (.clk(clk), .d(d[3:0]), .q());\nendmodule\n",
"module m;\n assign y = cond ? a[3:0] : pkg::f(b).c;\nendmodule\n",
// A net delay on either side of the data type: the gap in front of the
// `#` is `NetDelay::before_hash` (TODO §43.2), and the fuzzer is what
// says the other gaps around it kept their owners.
"module m;\n wire #5 a;\n wire [7:0] #1 b = c;\nendmodule\n",
];
#[test]
@@ -2358,7 +2362,7 @@ fn a_comment_in_every_rtl_gap_still_formats() {
}
/// Inter-token gaps across [`RTL_FIXTURES`].
const EXPECTED_RTL_GAPS: usize = 352;
const EXPECTED_RTL_GAPS: usize = 374;
// ----------------------------------------------------------------------
// Vendor and formal collateral — `vendor-formal-grammar`
+9
View File
@@ -246,6 +246,15 @@ pub struct ParamDecl {
/// `verify.rs` rightly refuses.
#[derive(Debug)]
pub struct NetDelay {
/// Comments written between whatever precedes the delay and its `#`:
/// the `/* c */` of `wire /* c */ #5 w;` and of
/// `wire [7:0] /* c */ #1 w;`. Without a slot here the comment would be
/// printed one node later and `verify.rs` would refuse the file.
pub before_hash: Vec<Comment>,
/// Comments written between the `#` and the delay value — the delay's
/// other gap, and the one the gap fuzzer asks about the moment the
/// first one has an owner.
pub after_hash: Vec<Comment>,
/// The delay itself: the `5` of `wire #5 w;`.
pub expr: Expr,
/// True when it stood between the data type and the declarators.
+6 -1
View File
@@ -284,8 +284,13 @@ impl<'a> Parser<'a> {
if !is_net || !self.cur().is_sym("#") {
return Ok(None);
}
// The `#` is written, so the gap in front of it is the delay's own:
// `wire /* c */ #5 w;`. Taken only here — when the read does not
// happen the gap belongs to whatever comes next.
let before_hash = self.take_gap();
self.bump();
Ok(Some(NetDelay { expr: self.parse_delay_value()?, after_type }))
let after_hash = self.take_gap();
Ok(Some(NetDelay { before_hash, after_hash, expr: self.parse_delay_value()?, after_type }))
}
pub(super) fn parse_port_decl(&mut self) -> PResult<PortDecl> {
@@ -0,0 +1,359 @@
# atomic write coordination
## Goal
Two writers of one file, inside one lucisv process, must not fight over the
temp file the atomic write goes through (TODO §41, `docs/repository-analysis.md`
finding 1, topo handshake §2.9-26). `atomic::temp_path` named its temp from the
canonical target and the process id, so every thread of one process derived the
*same* name for one target: the audit's probe — two threads writing 1 MiB each
to one file, 100 rounds — produced 100 write errors in 200 calls (no mixed
bytes, because `fs::write` truncated and rewrote the whole buffer, but half the
writes failed outright and each failure removed the other writer's temp). Two
ways in existed: the CLI's `dedup` folded `.` and `..` lexically but left
symlinks unresolved, so `b.sv -> a.sv` reached two rayon workers as two files;
and any two threads of one process asked to write one path.
Both are closed here. Every writer now gets a temp name no other writer in the
process will be given (a per-process `AtomicU64` beside the pid) and creates it
with `create_new`, so the name is owned, never shared. `dedup` keys on the
canonical path when the file exists, so two spellings of one file are one job —
while the path lucisv *reports* stays the first spelling the user gave. And the
target's mode goes on the temp before its bytes do, so a 0600 file's replacement
never holds the file's contents at a wider mode.
## Assumptions
- **A rename is atomic within a directory**, on every filesystem lucisv ships
to. That was already this module's premise; nothing here weakens it.
- **Two *processes* writing one target are not coordinated, deliberately.**
Both renames are atomic and the later one wins; the loser's bytes are
discarded whole, never merged. Both processes formatted the same input and
`format` is idempotent, so whichever rename lands last leaves the file
complete and correctly formatted. A lock file would buy nothing and would be
one more thing left behind by a `^C`. This is stated in the `atomic.rs`
module doc, which is where a reader will look for it.
- **A temp-name collision means a leftover, not a race.** A name is handed out
once per process, so `AlreadyExists` can only mean a temp from an *earlier*
process that died mid-write and whose pid this process now carries. The write
retries with the next counter value, at most `TEMP_ATTEMPTS = 32` times; 32
stale temps for one file in one directory is a directory to clean by hand,
not a race to keep retrying through.
- **`fs::canonicalize` is the identity of a file that exists.** Two names that
canonicalize alike are one file (hardlinks aside — two hardlinks to one inode
have two distinct canonical paths and stay two jobs, which is what a user who
made hardlinks asked for). A path with no file behind it has no canonical
form, and the old lexical fold answers for it.
- **A chmod does not revoke an already-open descriptor.** That is why, when
there is a target, the temp is *created* 0600 on unix rather than created at
the umask's mode and narrowed afterwards: narrowing later would leave a
window in which someone could open the empty temp and then read the bytes
through the descriptor they kept. With no target there is no earlier mode to
honour and the umask decides, exactly as `fs::write` would.
- The dedup key is computed on the main thread, before any worker exists, so
the extra `canonicalize` per input is one `realpath` per file at startup and
not per write.
## Handshakes
- **`lucisv_core::atomic::write_atomic` — unchanged signature, unchanged
contract**, plus one promise it did not make before: two threads of one
process writing one target both succeed, and the target ends up holding one
writer's whole buffer. Callers (`lucisv/src/main.rs`, `lucisv/src/lint.rs`,
`lucisv_core/src/cache.rs`) need no change.
- The two behaviours other tests already pin are kept exactly: a read-only
target is refused with `PermissionDenied`, and a symlinked target is
resolved so the link is not replaced.
- The temp file's *name* changed shape: `.{name}.{pid}.{n}.lucisv-tmp`. Any
tool that matched the old `.{name}.{pid}.lucisv-tmp` (nothing in this
repository does; the tests match on the `.lucisv-tmp` suffix) must match
the suffix instead.
- A file created where there was no target still takes the umask's mode. The
0600 creation applies only when a target's mode is about to be copied on.
- **`lucisv::dedup` — same signature, same output order, same reported paths.**
It only folds *more* than it used to: two spellings that reach one file are
now one job. `absolute` stays the lexical fold and is now reached only for
paths that do not exist; its doc comment says so.
- Nothing is requested of another module.
## Status / TODO
- [x] 41.1 exclusive unique temps (per-process `AtomicU64` + `create_new`,
bounded retry), mode before bytes
- [x] 41.2 dedup by canonical identity, reported path unchanged
- [x] Last-writer semantics for two processes stated in the `atomic.rs` module
doc and above; no lock built
- [x] Tests: the audit's probe (2 threads × 100 rounds × 1 MiB, 0 write
errors, one whole buffer per round); temp-name uniqueness across
threads; the 0600 window, twice (a unit test on the mode step, and a
live poll of the directory during a real 8 MiB write); `dedup` with a
symlink alias in both spelling orders, with a `..` detour, and with
missing files; a CLI test where `dir/b.sv -> dir/a.sv` is formatted and
reported once
- [x] Gates (guarded): fmt, clippy, workspace tests, corpus, write-path
byte-identity
- [ ] QA (see the brief in TODO §41)
## Docs to apply at merge (lead)
- `docs/topo.md` §2.9-26 (same-target atomic writers) is closed by this lane:
the temp name carries a per-process counter and is created `O_EXCL`, and the
CLI dedups by canonical identity so one file cannot reach two workers.
Suggested strike-through note: *"closed by §41 (0.43.0): unique `O_EXCL`
temps, dedup on `fs::canonicalize`; two *processes* remain last-writer-wins
by design, stated in `atomic.rs`."*
- `docs/repository-analysis.md` finding 1: annotate **fixed by §41** — the
probe now runs as `atomic::tests::two_threads_writing_one_target_never_collide`
and reports 0 write errors in 200 calls; the symlink alias closes as
`cli::a_symlink_and_its_target_are_one_file`.
- `README.md` needs no change: no user-visible behaviour moved. The only
externally observable difference is the temp file's name shape,
`.{name}.{pid}.{n}.lucisv-tmp`, which the README does not document.
## Work log
**2026-09-05 — dev (Opus 5).** TODO §41 implemented in full.
Files touched, all inside the plan's expected set:
- `crates/lucisv_core/src/atomic.rs` — the write path.
- `crates/lucisv/src/main.rs` — `dedup`/`identity`/`absolute` and their tests.
- `crates/lucisv/tests/cli.rs` — the symlink-alias end-to-end test.
- `docs/features/atomic-write-coordination/README.md` — this file.
- `TODO.md` — §41's own checkboxes (the QA line left alone).
Nothing outside that set was touched.
**41.1.** `temp_path` now stamps the name with a per-process `AtomicU64`
counter as well as the pid: `.{name}.{pid}.{n}.lucisv-tmp`. `create_temp`
opens it with `OpenOptions::new().write(true).create_new(true)`, so a name
that somehow exists is `AlreadyExists` and the next counter value is tried,
up to `TEMP_ATTEMPTS = 32`, after which the write fails with a message naming
the target and the bound (reasoning for 32 in Assumptions). `write_atomic`
now stats the target once, at the top, and passes the `Option<Permissions>`
down: the read-only refusal, the decision to create the temp 0600, and the
mode copy all read that one stat instead of three.
`fill_temp` puts the mode on before the bytes on unix (`File::set_permissions`
through the handle opened before the chmod, so a mode without an owner-write
bit does not stop the write); on non-unix it keeps today's order, because
`set_permissions` there takes a path and there is nothing to gain from
reordering. The write itself is `write_all` on the owned handle rather than
`fs::write`, which is what makes both the exclusive create and the early chmod
possible.
**Deviation from the plan, deliberate.** The plan asked only that the mode be
copied before the bytes. Writing the window test showed that was not enough:
the temp is *created* at the umask's mode, so for one instant an empty
world-readable file exists at a name anyone can open — and a chmod does not
revoke a descriptor already opened through it, so an observer holding that
descriptor would then read the private file's contents as they were written.
The temp is therefore created with `mode(0o600)` on unix *when there is a
target whose mode it is about to take*; with no target it is created at the
umask's mode, so a brand-new file's permissions are exactly what they were
before this change. This is strictly narrower than the plan's ask, not wider.
The first run of `a_temp_seen_mid_write_is_never_world_readable` caught the
gap (observed mode 0644 on a temp for a 0600 target); it passes now.
**41.2.** `dedup` keys on `identity(cwd, path)`: `fs::canonicalize(path)` when
it answers, else the old `absolute(cwd, path)` lexical fold. The reported path
is untouched — `dedup` still keeps the *first* spelling of each file and its
order. `absolute`'s doc comment now says it is the fold for paths that do not
exist rather than a deliberate refusal to resolve symlinks.
**Tests (6 new, all guarded).**
- `atomic::tests::two_threads_writing_one_target_never_collide` — the audit's
probe: two writers and this thread meet at a pair of barriers each round, so
the target is inspected between rounds with nobody mid-write. 100 rounds,
1 MiB per writer, distinct buffers: 0 write errors, and every round the file
holds exactly one writer's whole buffer with no temp left behind.
- `atomic::tests::every_thread_gets_its_own_temp_name` — 4 threads × 200 names
for one target, all 800 distinct.
- `atomic::tests::the_temp_takes_the_targets_mode_before_any_bytes` — the
unit-testable step: the temp is 0600 the moment it exists, `copy_mode` puts
the target's mode on while `len() == 0`, and `fill_temp` still writes
through the handle afterwards.
- `atomic::tests::a_temp_seen_mid_write_is_never_world_readable` — the same
window from outside, polling the directory during a real 8 MiB
`write_atomic`. It asserts about what it sees and never about *seeing* it,
so a scheduler that hides the window cannot make it flaky.
- `lucisv::tests::dedup_folds_a_symlink_onto_the_file_it_points_at` — the
alias in both spelling orders (the first spelling is the one kept), a `..`
detour through an existing directory, and missing files falling back to the
lexical key (two different missing files stay two).
- `cli::a_symlink_and_its_target_are_one_file` — `dir/b.sv -> dir/a.sv`
through the real binary: `--check` prints exactly one `would reformat:` line
and it names `a.sv`; the format run says "1 file reformatted"; the link is
still a link afterwards.
**Both new tests were checked for teeth** by temporarily reverting the fix in
the working tree and restoring it immediately: without the counter the probe
reports *exactly* "100 write errors in 200 calls" — the audit's number, to the
call — and with lexical dedup the CLI test sees two `would reformat:` lines,
for `a.sv` and `b.sv`.
**Gates, all through `tools/guard.sh` (no guard kill anywhere).**
- `cargo fmt -p lucisv_core -p lucisv` clean.
- `cargo clippy --all-targets` clean, zero warnings. Two of my own drew
warnings on the way (`cloned_ref_to_slice_refs` in the dedup test,
`byte_char_slices` in the probe) and were fixed rather than allowed.
- `tools/guard.sh -- cargo test --workspace`: **3 771 passed, 0 failed**
(baseline 3 765 + the 6 above).
- `tools/guard.sh -- tools/corpus_check.sh`: **814/820 (99.3 %)**, the same
six failures, `verification-error: none`, `crash: none`.
- Write-path byte-identity: 300 corpus files copied to a scratch directory
(one of them chmod 0600) and formatted in place — 292 reformatted, 4
unchanged, 4 pre-existing parse failures; a second run reports all 296
unchanged (idempotent); the 0600 file is still 0600; no `.lucisv-tmp` left
behind. Every one of the 296 files' in-place bytes is byte-identical to the
same file formatted through stdin, which never touches `write_atomic` —
so the new write path delivers exactly the formatter's bytes.
- Peak RSS of the probe test, `/usr/bin/time -l` around the single test under
the guard: **36 995 072 B (35.3 MiB)** max resident, 0.38 s wall. The two
1 MiB buffers and the read-back are the only allocations the test adds.
Nothing is unfinished. The one judgement call a reviewer may want to weigh is
the 0600 creation described under "Deviation" above.
## QA log
**2026-09-05 — QA (Sonnet 5).** Verified against the §41 QA brief. All
experiments ran on copies under the scratchpad or on a standalone scratch
crate path-depending on `lucisv_core`; nothing in `corpus/` or
`/Users/guoliangchen/repo/opentitan` was written to. Every probe and gate ran
through `tools/guard.sh` (no guard kill anywhere). Two temporary `#[test]`
functions were added to poke at private functions (`create_temp`/`copy_mode`
in `atomic.rs`, `identity`/`dedup` symlink cases in `main.rs`), run, and then
removed — `git diff` on both files verified byte-identical to the dev's diff
before and after.
1. **Multithread probe, 4 and 8 threads** (standalone scratch binary linking
`lucisv_core`, `/usr/bin/time -l`, guarded). 4 threads × 100 rounds: 0
write errors in 400 calls, 0 bad rounds, 0 leftover temps, peak RSS
8 749 056 B (8.3 MiB). 8 threads × 100 rounds: 0 write errors in 800
calls, 0 bad rounds, 0 leftover temps, peak RSS 13 107 200 B (12.5 MiB).
Matches the dev's 2-thread number scaled up; no error rate creeps back in
with more contention.
2. **The 0600 window.** Black-box directory polling (mirroring the dev's own
`a_temp_seen_mid_write_is_never_world_readable`, generalized): a 0600
target under continuous 8 MiB rewrites for 3s — 88 053 samples, widest
temp mode ever seen `0600`, final mode `0600`. A 0644 target: widest seen
`0644` (never wider), final `0644`. A 0755 target: widest seen `0755`,
final `0755`. Brand-new target vs. a plain `fs::write` in the same
directory: both land at `0644` under umask `022` — match. The "0600 at
creation, then widened by the rename" half of the inverse case is not
observable black-box (`copy_mode` runs before `write_all` with no yield
point, so the 0600 instant is sub-microsecond) — confirmed instead with a
temporary source-level test calling `create_temp`/`copy_mode` directly for
0644 and 0755 targets: the temp is born 0600 in both cases, then
`copy_mode` widens it to the target's real mode before any byte is
written. Removed after passing.
3. **Retry bound.** Predicted the temp names from the diff
(`.{name}.{pid}.{n}.lucisv-tmp`, counter from 0, one static per process)
and pre-created all 32 (`n=0..31`) in a fresh process before its first
`write_atomic` call: the write fails with `"no free temp file name beside
.../a.sv after 32 tries"`, naming the target and the bound, and leaves
exactly the 32 pre-created temps (no new one added). Pre-creating 31
(`n=0..30`, one slot free) in a fresh process: the write succeeds
(consuming `n=31`), the target holds the new bytes, and exactly 31 stale
temps remain — no extra temp left by the successful write itself.
4. **Symlink and identity.** Temporary unit tests against `identity`/`dedup`
covered: `dir2 -> dir1` containing the file (both spelling orders, first
spelling kept and reported); an absolute vs. relative spelling through
the dir symlink; a `../` detour; a dangling symlink (canonicalize fails,
falls back to the lexical key — two lexical spellings of *one* dangling
link still fold, two *different* dangling links stay two); a symlink to a
file outside the pair being compared (folds onto the real file by
canonical identity regardless of "was it walked"). All passed; removed
after. Then the mandated real-binary run (`cargo build --release -p
lucisv`, `dir/b.sv -> dir/a.sv`): `--check` printed exactly one `would
reformat:` line naming `a.sv`, exit 1; `--diff` printed exactly one diff
block naming `a.sv`, exit 1; a real format run reported "1 file
reformatted", exit 0, both `a.sv` and (through the link) `b.sv` read back
the formatted text, and `b.sv` was still a symlink pointing at `a.sv`
afterwards (`readlink` unchanged); a second `--check` reported "1 file
left unchanged, 1 file from cache", exit 0. Also checked by hand: a
dangling symlink inside a walked directory errors
`"...dead.sv: No such file or directory"` (the user's own spelling, not a
resolved one) without a panic, exit 2; a symlink to a file *outside* the
walked directory formats correctly through the link, and passing both the
link and the real outside file explicitly on the command line dedups to
one job, one report line, one write — verified with `--check` and with a
real write (outside file correctly formatted, link left intact).
5. **Two processes.** Two `lucisv format` processes launched at the same
moment (both under `tools/guard.sh`, backgrounded, `wait`ed) against one
shared scratch copy of `corpus/common_cells/src` (100 files): both exited
0. The resulting tree is byte-identical (`diff -rq`) to a fresh copy
formatted by a single process. No `.lucisv-tmp` anywhere afterward. A
follow-up `--check` on the two-process tree reports "100 files left
unchanged, 100 files from cache", exit 0 — no truncation, no corruption,
consistent with the documented last-writer-wins semantics (both writers
were formatting the same input to the same idempotent output, so there
was nothing for a "loser" to lose).
6. **Refusals and mid-run failures.** A read-only (0444) target: refused with
`PermissionDenied` ("... is read-only"), file content and mode (444)
untouched, no temp created. A target in a read-only (0555) directory:
refused with a plain OS `Permission denied (os error 13)` (temp creation
itself fails — expected, since `write_atomic`'s own read-only check is
for the *target's* mode, not the directory's), file untouched. Directory
deleted mid-write: 200 rounds of racing `fs::remove_dir_all` against a
concurrent 8 MiB `write_atomic` in a scratch binary with
`catch_unwind` around the writer thread — 139 writes completed before the
delete won the race, 61 got a plain `io::Error` (`No such file or
directory` / `Invalid argument`), **0 panics**. No corruption claim
applies once the directory itself is gone.
7. **Behaviour parity.** 300 files copied from `corpus/ibex` (path structure
preserved) into a scratch tree. `--stdout` of every file saved first (4
pre-existing parse failures unrelated to this feature — a `.tpl.sv`
template, a Yosys-primitive `.v`, and two vendor files with unsupported
constructs, all already known corpus failures). In-place format of the
300: "283 files reformatted, 13 files left unchanged, 4 files failed to
format" — same 4 files, same error text, byte-identical to the `--stdout`
errors. All 296 successfully-formatted files are byte-identical between
the in-place result and `--stdout` of the original (0 mismatches). The 4
failed files are byte-unchanged from their originals (hard invariant #1
held). A follow-up `--check` on the tree: "296 files left unchanged, 296
files from cache, 4 files failed to format" — idempotent.
**Gates (all guarded, no kill).**
- `cargo clippy --all-targets`: clean, 0 warnings.
- `tools/guard.sh -- cargo test --workspace`: **3 771 passed, 0 failed, 44
ignored** — matches the dev's reported 3 771 exactly.
- `tools/guard.sh -- tools/corpus_check.sh`: **814/820 (99.3%)**, the same
six failures (5 parse-error + 1 lex-error), `verification-error: none`,
`crash: none` — matches the dev's reported number exactly.
**Findings.** None at any severity. No corruption, no panic, no leftover
temp, no mode widening, no dedup miss, no parity break, and no gate
regression across any of the seven attacks.
**Repo hygiene.** `git status --porcelain` on the four `corpus/*` checkouts
shows only a pre-existing untracked `.vfmt-corpus-rev` marker (identical
41-byte file, mtime 2026-08-19, present in all four — predates this session,
not written by anything here); no tracked file in any corpus checkout is
modified. In the main tree, `git diff` on `crates/lucisv_core/src/atomic.rs`,
`crates/lucisv/src/main.rs` and `crates/lucisv/tests/cli.rs` is byte-identical
to the dev's diff at the start of this QA pass (verified before and after
every temporary test was added/removed). All scratch experiments and the
standalone `probe` crate lived under the scratchpad and have been removed.
**Verdict: PASS.** No rework needed.
## Review
**2026-09-05 — lead.** Accepted; ships in 0.43.0. The fix is the plan's plus
one tightening the plan should have asked for: a temp created at the umask's
mode and chmod'ed later would leave an empty world-readable file at a
guessable name for an instant, and a descriptor opened through it would
survive the chmod — so creating the temp at 0600 when a target exists, then
widening through the open handle before the bytes, is the correct order and
the dev's deviation is accepted as written. The retry bound of 32 is the
right shape (a name is issued once per process, so only a dead earlier
process with the same pid can collide, and 32 of those is a directory to
clean, not a race). QA's attack was thorough — 4 and 8 threads, the window
polled from outside, the bound hit exactly, two real processes over one
tree, a directory deleted mid-write with 0 panics — and found nothing. Two
processes on one target stay last-writer-wins by design; the formatter's
idempotence is what makes that safe, and the module doc says so.
@@ -0,0 +1,455 @@
# lint-config-contract
TODO §42. Repository-analysis finding 2, topology handshake 28.
## Goal
One lint-configuration contract for the two front ends. Before this round the
CLI read a project's `[lint] select` / `ignore` out of `lucisv.toml` and the
server did not: `enabled_rules` selected rules from `ClientSettings` alone,
and `configured` discovered the same config file only to read its rule options
and its line length. A team that checked in `select = ["no-tabs"]` therefore
got one answer from CI and a different one from every editor in the project,
and the docs had to say so. The server also *dropped* a `[lint.<rule>]` entry
the registry refused (`let _ = options.set_raw(...)`) with nothing said, while
the same mistake made in `lucisv.lint.options` was logged.
The contract, which is the CLI's today applied to the editor: **the editor's
settings play the role the CLI's flags play.** `lucisv/src/lint.rs` picks the
flag when one was given and the project file otherwise (`pick`); the server
now picks `lucisv.lint.select` when it is non-empty and `[lint] select`
otherwise, and the same for `ignore`, key by key. And a project entry that
cannot be used is *said* — once per (config file, entry), in the words
`lucisv check` fails the run with — rather than silently dropped.
## Assumptions
- **A server cannot fail a run.** Everything the CLI treats as fatal (an
unknown rule name, a rejected rule option, a waiver file that is not there
or holds an unparsable directive) is here a dropped entry plus one log line.
The buffer keeps being linted with everything that *was* understood. This is
the standing rule of `lint.rs` and `settings::rule_options`, applied to the
project file for the first time.
- **Rungs 3 and 4 are the editor's alone.** `lucisv.lint.severity.<class>` and
`lucisv.lint.rules.<name>` have no counterpart in `lucisv.toml` and none on
the command line, so nothing about them changed. They still apply *over* a
selection the project made, which is what "all style off except `no-tabs`"
needs.
- **One discovery per pass, no new file read.** `configured` already ran
`Discovery::new(true).for_file(path)` once per `LintRun::for_document`;
the project's selection is read out of the `FileConfig` that discovery
already produced, so 42.1 costs zero stats and zero opens. The waiver files
are now read in two calls instead of one (the project's paths, then the
editor's) so a problem in the project's can be attributed to the
`lucisv.toml` that named it — the same files, the same number of reads.
- **The memo is keyed by (config path, message), re-armed by content.** The
server has no "config generation": nothing invalidates on a `lucisv.toml`
write, because the file is re-read on every pass. So `ProblemLog` stamps
each config path with a hash of that file's lint-relevant content
(`[lint] select`/`ignore`/`waivers` and every `[lint.<rule>]` entry) and
clears that path's memo when the stamp moves. A user who edits the file and
gets it wrong again is told again; a user who types in a `.sv` buffer is
not told a hundred times. A problem in a *waiver file* named by an unchanged
`lucisv.toml` is said once per session, which is the one edge the stamp does
not see; it is a log line, not a diagnostic, and `lucisv check` is the place
that fails over it.
- **The memo lives behind a `RefCell`.** A lint pass runs behind `&self` — the
pull models compute diagnostics inside a `map` over the open buffers — and
the memo is the one thing a pass writes. `try_borrow_mut` with an early
return, so no panic is reachable even if a future caller nests.
- An unknown rule name in the project's lists is dropped rather than obeyed:
see the Work log's "beyond the plan".
## Handshakes
**Consumed**
- `lucisv_core::config::{Discovery, FileConfig, LintOption}` — `lint_select`,
`lint_ignore`, `lint_waivers`, `lint_options` (with `LintOption::line`) and
`source`. Unchanged by this round; `source` and `line` are what let a server
message name the file and line `lucisv check` names.
- `vlog_linter::{rules_named, rule_by_name, all_rules, default_rules,
workspace_rules, RuleOptions::set_raw, ExternalWaivers::{read, absorb}}` —
unchanged. `set_raw`'s error text is reused verbatim, so the server's line
and the CLI's are the same sentence.
- `crate::settings::ClientSettings` — unchanged.
**Promised**
- `lint::enabled_rules` **changed signature**:
`enabled_rules(&ClientSettings, &ProjectLint, has_oracle)`. The only caller
outside the module's own tests was `LintRun::for_document`. A caller that
wants the editor-only ladder passes `&ProjectLint::default()`.
- `lint::LintRun::config_problems() -> &ConfigProblems` is new, and
`server::diagnostics` is the one place that reports them. A future caller
that builds a `LintRun` outside the diagnostics path (today: the code-action
entry in `server/dispatch.rs`) says nothing, deliberately — one reporter, so
the memo cannot be raced by two.
- `lint::waiver_paths` keeps its signature and its behaviour (project paths
first, then the editor's, resolved as before); `server::notification` still
calls it with a default `FileConfig` to check the editor's alone.
**Requested of others (not done here)**
- `README.md`, `docs/site/src/content/docs/start/configuration.md` and
`docs/repository-analysis.md` carry the old sentence. The replacement text
is below, for the lead to apply at merge.
- `docs/features/server-lint/README.md` line 228 still reads "Not done,
deliberately: rule selection. No `lucisv.toml` `lint` key…", which was
already stale before this round (the key landed in §33) and is now doubly
so. Out of this lane's file set; flagged for the lead.
## Status / TODO
- [x] 42.1 project selection into the ladder, editor-when-set-else-project
- [x] 42.2 rejected project options logged with `<file>:<line>: <message>`,
once per (config file, entry), the lint still running
- [x] unit tests: the four-way table, severity words in the toml lists, the
editor-only rungs over a project selection, the once-only log across
three passes, the re-arm on an edited config
- [x] e2e tests: the project selects / the editor replaces / an emptied
setting hands it back; the rejected option logged once over the wire;
the CLI and the server asserted equal for three configurations
- [x] docs text for README / site / repository-analysis (below)
- [ ] topo §2.9-28 struck (lead); finding 2 annotated (lead)
- [x] QA
## Work log
**2026-09-05 — dev (Opus 5)**
New module `crates/lucisv_server/src/lint/project.rs` (Rust 2018 lets
`lint.rs` own a `lint/` directory), so nothing was added to `lint.rs`'s test
block, which already dwarfs its 201 production lines. It holds `ProjectLint`,
`ConfigProblems`, `ProblemLog` and their tests.
The ladder as implemented, in `lint::enabled_rules`:
1. base = `default_on`, plus the `needs_workspace` rules when `has_oracle`;
2. `pick(lucisv.lint.select, [lint] select)` — the editor's list when it is
non-empty, else the project's — **replaces** the base when it names
anything;
3. `lucisv.lint.severity.<class>` off **removes** that class (editor only);
4. `lucisv.lint.rules.<name>` sets or clears one rule (editor only);
5. `pick(lucisv.lint.ignore, [lint] ignore)` **removes**.
`pick` is a five-line twin of the CLI's, and rungs 2 and 5 are picked
independently — a project that selects and a user who only ignores keep both
halves. Every list takes a severity word wherever a rule name fits, the
project's as much as the editor's, because both go through
`vlog_linter::rules_named`.
`configured` now returns its problems instead of `let _`-ing them away, in
`lucisv check`'s wording (`{file}:{line}: rule `{rule}` {error}` — the format
string is `lucisv/src/lint.rs`'s `rule_options`, copied deliberately rather
than shared, since the two crates are bins and neither can depend on the
other). `for_document` reads the project's waiver files apart from the
editor's and keeps the project's problems; the editor's are still said once by
`notification::apply_settings`, so nothing is said twice.
`Server::report_config_problems` (in `server/diagnostics.rs`, on the one path
that publishes) filters them through `ProblemLog` and logs the survivors as
`lucisv: <file>:<line>: <message>; ignored` at `MessageType::WARNING` —
`window/logMessage`, not `showMessage`: a typo in a checked-in config is not
worth a popup on every editor in the project.
**Beyond the plan (one addition, deliberate).** `ProjectLint::read` also drops
and reports a name in `[lint] select` / `ignore` that the registry does not
know. The plan named only the rejected `[lint.<rule>]` entry and the bad
waiver directive. The reason for adding it: `named()` skips an unknown word,
so `select = ["no-tab"]` taken at face value resolves to *no rules at all* and
blanks the file's squiggles, which reads as "lucisv is happy" rather than
"lucisv could not read your config" — the same silent-drop failure §42.2
exists to close, one line up. `lucisv check` fails the run over it; the server
drops the name, says it once, and applies the rest of the list (a `select`
left empty by the dropping falls back to the base set, which is the safe
direction: some rules rather than none). The message has no line number,
because `lucisv_core::config` records one per `[lint.<rule>]` entry and not
per list element: `<toml>: [lint] select: unknown rule: no-tab`.
**Cost.** No new file read per diagnostics pass: the project selection comes
out of the `FileConfig` the pass's single `Discovery` already produced, and
the waiver files are the same files read the same number of times, just in two
calls instead of one. The only new work per pass is a `DefaultHasher` over the
config's `[lint]` entries (a handful of short strings) and a `HashMap` probe,
both of which are skipped entirely when the config has no problems —
`ConfigProblems::is_empty` returns before the memo is touched, which is every
buffer in a project whose config is correct.
**Files touched** (all within the expected set):
- `crates/lucisv_server/src/lint/project.rs` (new)
- `crates/lucisv_server/src/lint.rs`
- `crates/lucisv_server/src/server/mod.rs` (the memo field)
- `crates/lucisv_server/src/server/diagnostics.rs` (the one reporter)
- `crates/lucisv_server/tests/e2e.rs` (three tests appended)
- `TODO.md` (§42's own checkboxes)
- this README
## Docs to apply at merge (lead)
### `README.md`, the two sentences at the end of the linter section (~line 432)
Replace:
> The server currently selects rules from `lucisv.lint.*` editor settings;
> project `[lint] select/ignore` lists affect the CLI only. Project per-rule
> options are read by both front ends.
with:
> Both front ends read the same configuration, and the editor's settings play
> the role the CLI's flags play: `lucisv.lint.select` when it is set, else
> `[lint] select` from the buffer's `lucisv.toml`, else the default set — and
> the same for `ignore`, decided independently. `lucisv.lint.severity.*` and
> `lucisv.lint.rules.*` have no project counterpart and apply over whichever
> selection stands. Project per-rule options are read by both front ends. A
> project entry lucisv cannot use — an unknown rule name in `[lint]
> select`/`ignore`, a rejected `[lint.<rule>]` option, an unreadable waiver
> file or a directive that does not parse — fails `lucisv check` with
> `<file>:<line>: <message>` and exit 2; in an editor it is dropped, written
> once to the lucisv log in the same words, and everything lucisv did
> understand still lints the buffer.
Also, five lines above, the waiver sentence "a bad line in a file named by the
editor setting is written once to the lucisv log, one named by `lucisv.toml`
is not (run `lucisv check` to see it)" becomes:
> a bad line is written once to the lucisv log whether the file was named by
> the editor setting or by `lucisv.toml`.
### `docs/site/src/content/docs/start/configuration.md`
The Keys table, rows 33–34 — the "Used by" column becomes "CLI and editor":
| `[lint].select` | string array | defaults | rule names or severity classes | CLI and editor |
| `[lint].ignore` | string array | `[]` | rule names or severity classes | CLI and editor |
The "Editor settings" paragraph (~line 91) replaces:
> For lint selection, the server currently reads editor settings only. Project
> `[lint] select/ignore` lists affect the CLI and are not inherited by the
> server. Selection proceeds through defaults → select → severity switches →
> per-rule toggles → ignore. Editor rule options overlay project rule options
> key by key. Invalid editor options are logged and dropped. Invalid project
> rule-option entries are currently dropped by server linting without a
> per-entry log; `lucisv check` reports them as configuration errors.
with:
> For lint selection, the editor's settings play the role the CLI's flags
> play. Selection proceeds through defaults → select → severity switches →
> per-rule toggles → ignore. `select` is `lucisv.lint.select` when that
> setting is non-empty and the project's `[lint] select` otherwise; `ignore`
> is decided the same way and independently. The severity switches and
> per-rule toggles are editor-only — a `lucisv.toml` has no such keys — and
> apply over whichever selection stands. Editor rule options overlay project
> rule options key by key. An entry that cannot be used is dropped and logged
> once per configuration file and entry, in the same `<file>:<line>:
> <message>` wording `lucisv check` fails with: an invalid editor option, an
> invalid `[lint.<rule>]` entry, an unknown rule name in `[lint]
> select`/`ignore`, or an unreadable waiver file. `lucisv check` treats each
> of these as a configuration error and exits 2; the server keeps linting with
> the entry dropped.
The Discovery section (~line 57) sentence "A bad configuration is an error for
the CLI, preventing partial writes. In an editor, the server reports the
problem and falls back to the next available setting." is still true and needs
no change.
### `docs/repository-analysis.md`, finding 2
Replace the "The docs now describe the implemented behavior…" paragraph with a
fix note in the shape finding 1 already uses:
> **Fixed by TODO §42 (0.43.0, 2026-09-05):** `enabled_rules` now takes the
> project's selection beside the editor's and picks the editor's list when it
> is non-empty, the project's otherwise, key by key — the CLI's `pick` applied
> to the editor. Rejected project entries are logged once per (configuration
> file, entry) as `<file>:<line>: <message>`, the wording `lucisv check` fails
> with, and the buffer is still linted with the entry dropped. Pinned by
> `lint::project`'s four-way table test and by three wire-level tests in
> `crates/lucisv_server/tests/e2e.rs`, one of which asserts the CLI's and the
> server's rule lists equal for three configurations. See
> `docs/features/lint-config-contract/README.md`.
## QA log
**2026-09-05 — QA (Sonnet)**
Read the plan (TODO §42), the finding/handshake it answers (repository-
analysis finding 2, `docs/topo.md` §2.9-28), and this feature's README in
full, including the "beyond the plan" deviation (unknown rule names in
`[lint] select`/`ignore` dropped and logged) and the waiver-file edge
(memo keyed by the toml's stamp, not the waiver file's). Read the diffs of
`lint.rs`, the new `lint/project.rs`, `server/diagnostics.rs`,
`server/mod.rs`, and the three tests appended to `tests/e2e.rs`, and the
CLI's own `lucisv/src/lint.rs` (`pick`, `rule_options`) and
`vlog_linter::registry::select_rules`/`rules_named` for the wording and
precedence this feature is required to mirror.
Built `cargo build --release -p lucisv -p lucisv_server` once. Wrote a
throwaway attack suite as extra `#[test]` functions appended to
`crates/lucisv_server/tests/e2e.rs` (never committed to the dev's file —
removed before this pass ends; verified by `git diff --stat` matching the
dev's original 205-line insertion both before and after), driving the real
server binary over framed JSON-RPC, plus one wire-level test against a real
file copied read-only out of opentitan (`hw/ip/aes/dv/tb/tb.sv`, no write).
Two attack tests needed a raw child process with an explicit read/write
interleaving (rather than `talk()`'s single write-then-read-to-EOF) to test
disk-edit timing without a race, and to drive a `hover` request as a
synchronization barrier between passes — documented inline while they
existed; removed with the rest.
**Verified, all as specified:**
- The four-way matrix {toml select ∅/set, editor select ∅/set} ×
{toml ignore ∅/set, editor ignore ∅/set} over the wire, using a buffer
with findings in all three severities (`no-tabs`/`no-trailing-whitespace`/
`line-length` = style, `unused-signal`/`undriven-net` = warning,
`duplicate-declaration` = error) rather than the unit test's two rules —
every cell matches the documented ladder, and select/ignore are confirmed
decided **independently** (a project select plus a project ignore both
apply when the editor names neither).
- Severity words in the toml's lists (`select = ["style"]`,
`ignore = ["style"]`), including mixed with a rule name in the same list.
- Rungs 3/4 (editor-only class switch, per-rule toggle) apply over a project
selection, including the per-rule word beating the class word (note: the
editor's `rules.<name>` setting takes the **string** `"on"`/`"off"`, not a
JSON boolean — confirmed against `settings.rs`'s `rule_toggles` after an
initial test mistake).
- `didChangeConfiguration` transitions: editor `select` set then cleared
restores the project's; same, independently, for `ignore`.
- Nested `lucisv.toml`s: an outer and an inner buffer in one workspace each
follow their own nearest config file. (First attempt used identical
buffer text in both files and got `[]` for the inner buffer — not a
product bug: the shared file-scope oracle correctly saw the identically-
named `unused-signal` candidate declared in the other indexed file and
suppressed it, `docs/features/semantic-lints-on/README.md`'s documented
false-negative-safe direction. Fixed by giving each file's declarations
distinct names.)
- An unknown rule name in `[lint] select`: dropped, logged once
(`<toml>: [lint] select: unknown rule: no-tab`), the rest of the list
still applies, and the buffer keeps being linted — confirmed against
`lucisv check` on the identical config, which exits 2 and prints the same
`unknown rule: no-tab` wording before failing the run. The two front
ends' *reactions* differ by design (a server cannot fail a run); their
*diagnosis* of the same mistake does not.
- A rejected `[lint.<rule>]` option (`length = "wide"`): exactly one
`window/logMessage` across five `didChange` passes over the same bad
config; the message's core (`<toml>:<line>: rule `<rule>` <detail>`) found
verbatim inside `lucisv check`'s own stderr on the identical config (the
CLI prepends `error: `, which the server's log line has no equivalent
of — compared by substring, not equality, for that reason); the buffer
still linted with the entry dropped. Edited live to a *different* bad
value (`length = "-1"`) mid-session: logged again, once. Then fixed
(`length = 100`): silence from there on. (This needed the raw
read/write-interleaved harness — a `talk()` one-shot builds the whole
session string, `std::fs::write`s included, before the server is even
spawned, so every edit would already be on disk before anything runs;
used a `hover` request after each edit as a synchronization barrier,
since `Server::answer_request` flushes the dirty buffer before answering
any request.)
- A bad directive in a waiver file named by `[lint] waivers`: logged once,
naming the **waiver file's own** path and line, not the toml's.
- Extra probe beyond the plan, for the README's stated waiver/toml-stamp
edge: fixed the waiver file, then brought back the **exact same** bad
line, toml untouched throughout — not logged a second time, confirming
the memo really is keyed by exact message text under an unchanged toml
stamp, not merely "one waiver problem per session" in some coarser sense.
Contrast: two *different* bad lines in the same unedited-toml waiver file
during one session are each logged once (not suppressed by the first) —
consistent with `ProblemLog`'s `BTreeSet<String>` keyed by message text,
not a defect, but worth the lead/dev knowing the precise grain the
"once per session" sentence in Assumptions describes.
- CLI/server rule-set equality: five configurations (none, an explicit
select, `select=["style"]` + one ignored, `ignore=["style"]`, a select
containing an unknown name) plus one real file copied read-only out of
opentitan (`hw/ip/aes/dv/tb/tb.sv`, no `lucisv.toml` in that repo, so a
scratch one governed the copy) — server and CLI rule-code sets equal in
every case.
- Robustness: `select = []` (explicit empty) falls back to the base set,
same as absent; duplicate names in `select` collapse harmlessly; a name
in both `select` and `ignore` ends up ignored (ignore is the top rung); a
`[lint]` key the parser rejects outright fails `parse()` entirely, which
the CLI turns into an exit-2 run failure and the server (via the
pre-existing `.ok()` fallback in `configured`, **unchanged by §42**)
swallows into defaults across several passes with **zero** log lines —
confirmed it does not newly start logging under this feature.
- Performance: 20 consecutive diagnostics passes over a 2000-line buffer
with a valid config, this server against a 0.42.0 server built in a
scratch worktree (`git worktree add .../scratchpad/base v0.42.0`, removed
with `git worktree remove` before finishing). Three runs: ratios 0.985,
1.001, 0.983 (new server negligibly faster or equal, never slower) — no
measurable regression, as the README's cost analysis claims.
- Gates, guarded: `cargo clippy --all-targets` clean; `cargo test
--workspace` — **3780 passed, 0 failed** (matches the dev's count
exactly); `tools/corpus_check.sh` — **814/820 (99.3%)**, the same six
pre-existing parse errors; `node editors/vscode/smoke.js
target/release/lucisv-server` — OK.
- `git -C /Users/guoliangchen/repo/opentitan status --porcelain` after use:
unchanged, the same three pre-existing modified files
(`hw/ip/aes/dv/tb/tb.sv`, the two `ast.sv`s) as before this session — no
`lucisv.toml` was written there.
**Findings.**
- **LOW, pre-existing, not introduced by §42** — a `didChange` sent in the
same message burst as `shutdown` is never flushed: `lsp_server::
Connection::handle_shutdown` (called from
`crates/lucisv_server/src/server/mod.rs`'s `process_batch`) answers
shutdown directly, bypassing `Server::answer_request`'s `flush_dirty()`.
A dirty buffer's last edit is silently dropped — no republish, no
config-problem log for that pass — if the client shuts down before the
150ms `CHANGE_DEBOUNCE` fires or before another request arrives. This
interacts with §42's own "a `lucisv.toml` edited on disk takes effect at
the next publish" claim: that claim holds only when *some* republish
actually happens before the session ends, which is not the same as
saying the edit's diagnostics are guaranteed to reach the client at all
in a fast open-edit-shutdown session. Reproduced in the (removed) attack
test by sending a `didChange` immediately before `shutdown` in one write
and observing zero further publishes; fixed the test by sleeping past
the debounce instead of treating it as a §42 bug, since the behavior
predates this feature and is a property of the `lsp-server` crate's own
shutdown handling, not of anything `lint.rs`/`lint/project.rs` changed.
Not a §42 regression; flagging for whoever owns `change-debounce` next.
- **LOW, pre-existing, not introduced by §42** — an unknown name in the
*editor's* `lucisv.lint.select`/`ignore` is silently dropped at
settings-parse time (`crates/lucisv_server/src/settings.rs`'s `rules`,
called from `from_payload`), with no log line — unlike `lucisv.lint.
options`, whose rejected entries are logged (`lint_option_warnings`).
§42 makes the *project* side of the same mistake (`[lint] select`/
`ignore` in `lucisv.toml`) both dropped and logged (the "beyond the
plan" addition in the Work log), which is more informative than the
editor's own settings for the identical typo. Not this feature's
handshake to fix (`ClientSettings` is unchanged by §42) and not asked
for by the plan, but the asymmetry is now sharper than before this
round landed; worth a line in the lead's notes for a future pass over
`settings.rs`.
- No correctness, idempotency, or comment-preservation issues found; no
masked-corruption concern applies (this feature touches lint
configuration, not `verify.rs`'s forgiveness).
**Verdict: PASS.** No blocking findings. The two LOW findings above are
pre-existing behavior outside this feature's stated handshakes, not
regressions introduced by §42; recorded for whoever picks them up next.
Ticked TODO §42's QA checkbox and this feature's own `Status / TODO`
"QA" line.
## Review
**2026-09-05 — lead.** Accepted; ships in 0.43.0. The contract is the ruled
one and it is now the same sentence on both front ends: the editor's list
when set, else the project's, key by key, with the editor-only rungs applied
over whichever stands — and the wire-level equality test is what makes that
a fact rather than a description. The dev's one step beyond the plan
(dropping and logging an unknown rule name in a project list) is accepted:
an editor cannot fail the run, and a typo that silently resolves to "no
rules" reads as a clean file, which is the wrong kind of quiet. The
once-only memo keyed by config content is the right shape for a server with
no config generation; its stated edge (a waiver file's bad line under an
unchanged toml is said once per session) is acceptable and documented. QA's
two LOWs are pre-existing and out of scope; the second — an unknown name in
the *editor's* `lucisv.lint.select` still silently dropped — is worth a line
in a later round and is filed in topo §2.9 as item 29. Docs applied to
README, the linter guide, configuration.md, the analysis and topo.
+4 -2
View File
@@ -102,7 +102,8 @@ the last two shapes in that sweep that were grammar work rather than
before-type spelling has behaved this way since the delay was first
parsed — and the new position inherits it unchanged. Recorded as a `#SKIP`
case in `net_delay_position.cases`, not fixed: giving the delay a comment
slot is a `comment-slots` change. The other gaps around a delay (an
slot is a `comment-slots` change. **Closed by walk-cycles (TODO §43.2),
2026-09-05:** `NetDelay::{before_hash, after_hash}`; the `#SKIP` is live. The other gaps around a delay (an
attribute in front of the declaration, a comment after the delay) do
round-trip.
@@ -151,7 +152,8 @@ the last two shapes in that sweep that were grammar work rather than
- **`comment-slots`**: a net delay has no slot for the comment written
immediately in front of its `#`, so such a file is refused by the safety
net rather than reformatted. Pre-existing, both positions, recorded as a
`#SKIP` case (see Assumptions).
`#SKIP` case (see Assumptions). **Answered by walk-cycles (TODO §43.2),
2026-09-05.**
## Status / TODO
+4 -2
View File
@@ -225,8 +225,10 @@ TODO §2 `--lines`), `completion`, `rename`, `signatureHelp`, and cross-file
capability's kinds on the wire, quick fixes + fixAll, and a filtered
fix-on-save request.
- [x] `docs/features/lucisv-server/README.md` deferred list annotated.
- [ ] **Not done, deliberately:** rule selection. No `lucisv.toml` `lint` key
exists (Handshake 2); the server runs `default_rules()`.
- [x] ~~**Not done, deliberately:** rule selection. No `lucisv.toml` `lint` key
exists (Handshake 2); the server runs `default_rules()`.~~ Delivered by
**linter-expansion-1** (editor toggles, 0.36.x) and **lint-config-contract**
(project `[lint] select/ignore`, TODO §42, 0.43.0).
- [ ] **Not done, deliberately:** offering Unsafe fixes. No rule ships one, and
when one does it wants a decision (a separate `source.fixAll` kind? a
client setting?), not a silent inclusion.
+447
View File
@@ -0,0 +1,447 @@
# walk cycles
## Goal
Two unrelated residues of the repository analysis (finding 3), landed
together as TODO §43 because each is small and neither collides with the
other.
**43.1 — a cycle policy for the shared walk.** `lucisv_core::walk` recursed
on `Path::is_dir()` with no memory of where it had been. A symlink that
points back into the tree it sits in — `a/loop -> ../a`, `a/sub/up -> ..`,
the `rtl -> ../shared/rtl` pair a vendored checkout writes twice — made the
walk descend forever, one directory deeper each time, until the operating
system refused the path. Both front ends share that walk: `lucisv` (and so
`format`, `check`, `--check`, `--diff`) and the language server's index scan,
where the symptom is not an error message but an index that never comes up.
The policy is now **each directory is entered once, by identity**: a symlink
naming a directory the walk has already entered is skipped silently, and a
symlink naming one it has not is still followed, once. No traversal budget —
identity *is* the policy, and a budget would be a second, weaker rule
answering the same question differently.
**43.2 — the net delay's comment slots.** `wire /* c */ #5 w;` and
`wire [7:0] /* c */ #1 w;` were refused outright: `NetDelay` had no field for
a comment written in front of its `#`, so the comment was printed one node
later and `verify.rs` — correctly — refused the whole file (exit 2, no
output). `NetDelay` now owns both of its gaps, `before_hash` and
`after_hash`, and the `#SKIP` `parser-skips` left in
`net_delay_position.cases` is retired.
## Assumptions
- **Directory identity on unix is `(dev, ino)`.** `fs::metadata` follows
symlinks, so the link and its target return the same pair, which is exactly
the question being asked. Elsewhere (there is no non-unix CI today, but the
crate compiles there) it is `fs::canonicalize`, which resolves the same way
at the cost of a path lookup. Both are `Option`: a name whose metadata
cannot be read is not a directory the walk can enter.
- **A hard link is not a cycle, and is not treated as one.** Two hard-linked
*files* have one inode and the visited set never sees them: only
directories are recorded. (Hard-linked directories are not creatable on any
filesystem lucisv runs on.)
- **The visited set lives for one `collect_files` call.** Two inputs named on
one command line each get their own walk, so a directory reachable from
both is still walked twice — unchanged, and the CLI's own path dedup is
what answers that (`§41`). Inside one walk the same file reached under two
spellings is reported once, under the first spelling that reaches it: entry
order is `read_dir` sorted by path, so `link_a/x.sv` wins over `shared/x.sv`
and `shared/x.sv` wins over `zlink/x.sv`. This is the same rule §41 already
applies to a symlinked *file*.
- **A dangling symlink is not an input.** `metadata` fails on it, so it is
neither walked nor collected. Before this round a dangling `x.sv` link was
collected and failed later, at read time, with a "no such file" error the
user did not write.
- **The `.gitignore`/`--exclude` decision still comes first.** A cycle inside
an ignored or excluded directory is never entered at all, so the visited
set never sees it; the ignore rules were not touched.
- **A comment in front of a `#` belongs to the delay** (43.2), the way
`Typedef::before_name` owns the gap in front of its name: the gap is taken
only on the branch that actually consumes the `#`, so a `#` that is not a
net delay leaves the comment for whoever comes next.
## Handshakes
- **`lucisv_core::walk` → `lucisv` and `lucisv_server`** (topo §2.9-8, struck
by this round). `collect_files`'s signature is unchanged. What changed is
what it returns for a tree containing symlinked directories: it terminates,
and a directory reachable under several names contributes its files once.
`lucisv_server::state::Workspace::walked_files` is the server's only caller
and needed no change — its `sort`/`dedup` still runs, and now has less to
do. `vlog_linter` uses `walk::is_excluded` only, which is untouched.
- **`vlog_parser::ast::NetDelay` → `vlog_formatter`** (topo §2.9-27, struck).
Two new public fields, `before_hash` and `after_hash`, both
`Vec<Comment>`. The only constructor is `Parser::parse_net_delay`; the only
reader is `Fmt::net_delay`. `vlog_semantic`, `vlog_linter` and
`vlog_refactor` do not name the type.
- **Not taken:** the gaps *inside* a delay's `#( … )` — `#( /*c*/ 1:2:3 )`
and each side of its two `:` — are still refused. They are
`parse_delay_values`, shared with a gate instantiation's delay list, and
they fail identically outside a net declaration; they belong with the rest
of the shared expression machinery in topo §2.9-22, not here. Recorded
below and left for a future round.
## Status / TODO
- [x] 43.1 `Walk::visited`, `Walk::enter`, `dir_id` per platform; `dir()`
checks-and-inserts before `read_dir`
- [x] 43.1 a dangling symlink is skipped rather than collected
- [x] 43.1 unit tests: self-loop, ancestor link from a nested start, two
links to one target, a link to a directory not yet walked, a dangling
link, a cycle inside an ignored directory
- [x] 43.1 CLI test (`--check` over a cyclic tree names each file once)
- [x] 43.1 server test (a cyclic workspace scans once and finishes)
- [x] 43.2 `NetDelay::before_hash` + `after_hash`, parser and formatter
- [x] 43.2 the `#SKIP` in `net_delay_position.cases` retired, three live
cases in its place
- [x] 43.2 the RTL gap fuzzer covers a net delay (352 → 374 gaps, still zero
failures)
- [x] Gates: fmt, clippy, workspace tests, corpus, both binaries over a
cyclic tree
## Docs to apply at merge (lead)
- `docs/topo.md` §2.9-8 — strike: **delivered 2026-09-05 by walk-cycles
(TODO §43.1)**: `lucisv_core::walk::Walk` keeps a `visited` set keyed on
`(dev, ino)` on unix and the canonical path elsewhere; each directory is
entered once, a symlink to a directory already entered is skipped
silently, a symlink to one not yet entered is still followed, a dangling
symlink is skipped. Both front ends: CLI `--check` over a cyclic tree names
each file once; the server's `walked_files` scan finishes.
- `docs/topo.md` §2.9-27 — strike: **delivered 2026-09-05 by walk-cycles
(TODO §43.2)**: `NetDelay::before_hash` and `after_hash` own the two gaps
around the `#`; the formatter prints them inline; the
`net_delay_position.cases` `#SKIP` is retired and the RTL gap fuzzer covers
the construct. The gaps *inside* `#( 1:2:3 )` remain refused and belong to
§2.9-22 (`parse_delay_values`, shared with gate delays).
- `docs/repository-analysis.md` finding 3 — annotate as closed by TODO §43.1
with the identity policy above, and note that the "no traversal budget"
ruling was the lead's.
- `docs/features/parser-skips/README.md` — its Assumptions (line ~103),
Handshakes (line ~151) and QA log (lines ~343, ~409) describe the net-delay
comment as a live `#SKIP` and as a handshake request to `comment-slots`.
That request is now answered; a one-line "closed by walk-cycles (TODO
§43.2), 2026-09-05" under each is the honest amendment. Not edited here —
it is another feature's README, and this lane owns none of it.
- `README.md` — no change needed: the walk's user-visible contract
(extensions, `--exclude`, `.gitignore`) is unchanged. If a line is wanted,
it is in the CLI section: "a symlinked directory is walked once; a cycle
terminates".
## Work log
**2026-09-05 — dev (Opus 5).**
*43.1, `crates/lucisv_core/src/walk.rs`.* `Walk` gained
`visited: HashSet<DirId>` and one method, `enter`, which is the whole policy:
`dir_id(dir).is_some_and(|id| self.visited.insert(id))`. `dir()` calls it
first and returns `Ok(())` when it answers false, so a directory already
entered costs one `metadata` call and nothing else — no `read_dir`, no
ignore-stack push, no recursion. `DirId` is `(u64, u64)` under `#[cfg(unix)]`
from `MetadataExt::dev`/`ino`, and `PathBuf` from `fs::canonicalize`
otherwise; `dir_id` returns `Option`, and `None` (a dangling link, a
directory that vanished mid-walk) means "not entered".
The entry loop's `path.is_dir()` became one `fs::metadata(&path)` — the same
single stat, and it follows symlinks exactly as `is_dir()` did, so a
symlinked directory is still recognized as a directory. Three things fall out
of having the metadata rather than a bool: `meta.is_dir()` for the walk arm,
`meta.is_file()` for the collect arm, and a dangling link (no metadata at
all) skipped by the `let … else { continue }` in front of both. The extension
test moved into a small `is_source` helper so the collect arm stays one line.
The one behaviour change beyond termination that a user could notice: a
dangling symlink named `x.sv` used to be *collected* and then failed at read
time. It is now skipped. That is in the plan's test list ("a dangling symlink
is skipped") and is the same judgment as the directory case.
Six unit tests in `walk.rs`, all `#[cfg(unix)]` because they need real
symlinks, over a `TempTree` helper in the test module (the third such helper
in the crate — `config.rs` and `cache.rs` have their own; a fourth copy is
cheaper than a shared test-support module for two dozen lines). Each of them
would have run until the OS refused a path before this change.
*43.2, three crates.* `NetDelay` gained `before_hash` and `after_hash`.
`parse_net_delay` takes the first with `take_gap()` **after** the
`cur().is_sym("#")` check — the `gap_before("#")` contract, spelled out
rather than called, because the check is already there for the `is_net` gate
— and the second with `take_gap()` after the `bump()`.
`Fmt::net_delay` now owns the separator in front of the delay as well as the
delay: it emits the `before_hash` comments *instead of* the plain space when
there are any, and the plain space when there are not, so a declaration with
no comment there is laid out byte-identically to before. That moved the
trailing space off `net` (`text(format!("{net} "))` → `text(net.clone())`)
and off the data type, which is why `data_decl` changed shape slightly; the
two call sites are now inside the `if let Some(net)` and
`if let Some(t) = self.data_type(…)` arms, which is also correct, since a
delay is only ever read after a net keyword, and an after-type delay only
after a data type that was actually written.
*Deviation from the plan: `after_hash`.* The plan asks for `before_hash`
only, and also asks that the gap fuzzer cover the new slot. Those two are in
tension: `assert_no_failing_gaps` demands **zero** failures across a fixture
set, and the smallest fixture that exercises `before_hash` (`wire #5 a;`)
also contains the gap between `#` and `5`, which had no owner either. So the
fixture could not be added without it. `after_hash` is four lines (one field,
one `take_gap`, one `slot_comments`) on the same construct, and closes the
delay's own gaps completely; the alternative was to leave the fuzzer without
a net-delay fixture, which is the thing the plan explicitly asked for. Flagged
here for the lead.
The gaps inside `#( 1:2:3 )` are *not* closed — eight of them, measured with
the fixture `wire [7:0] #(1:2:3) b = c;` before it was narrowed to `#1`. They
live in `parser/instance.rs::parse_delay_values`, shared with gate
instantiation delay lists, fail identically there, and are §2.9-22 shared
machinery. The RTL fuzzer fixture is `wire #5 a;` / `wire [7:0] #1 b = c;`,
which covers both sides of the type and both new slots; `EXPECTED_RTL_GAPS`
352 → 374, zero failures.
*Files touched outside the plan's expected set.* None beyond what the plan
names, with one addition: `crates/vlog_formatter/tests/verification.rs` (the
gap fuzzer's fixture and count — the plan says "find how the fuzzer
enumerates slots and add this one", which is this file). Full list:
`crates/lucisv_core/src/walk.rs`, `crates/lucisv/tests/cli.rs`,
`crates/lucisv_server/src/state.rs` (test only),
`crates/vlog_parser/src/ast/decl.rs`,
`crates/vlog_parser/src/parser/decl.rs`,
`crates/vlog_formatter/src/format/decl.rs`,
`crates/vlog_formatter/tests/cases/net_delay_position.cases`,
`crates/vlog_formatter/tests/verification.rs`, `TODO.md`, this README.
*Do the tests have teeth?* Asked directly rather than assumed: the `enter`
call was short-circuited (`if false && !self.enter(dir)`) and the walk tests
re-run. Three of the six failed — the self-loop, the ancestor link and the two
links — with paths 31 levels of `a/up/` deep, which is what the OS refuses at
rather than a hang. The other three (the sibling link, the dangling link, the
ignored cycle) pass either way by construction: they are about the *other*
half of the policy. The short-circuit was reverted immediately and the file
compared against a copy taken before it; `walk::` is green again.
*Gates, all guarded.* `cargo fmt --check` on the five touched crates: clean.
`cargo clippy --all-targets`: clean, no new `#[allow]`. `cargo test
--workspace`: **3 788 passed, 0 failed** (baseline 3 780 + the 8 tests this
round adds: 6 in `walk.rs`, 1 CLI, 1 server). `tools/corpus_check.sh`:
**814/820 (99.3%)**, the same six failures (five parse, one lex) and the same
10 already-clean files. Byte-identity: no corpus file writes a comment before
a net delay's `#` — checked with a direct grep over `corpus/`, 0 hits — and
the empty-slot path emits exactly the `text(" ")` it did before, so the
formatter's output over the corpus cannot have moved; the corpus counts
confirm it. `node editors/vscode/smoke.js target/release/lucisv-server`: OK,
20 messages. The cyclic scratch tree (a self-link, a `..` link one level down,
a `../../..` link three levels down, a second name for one directory, and a
dangling `x.sv` link) through both release binaries under
`tools/guard.sh -t 120`: `lucisv --check` finishes in ~1s and names its three
files once each; an LSP session (initialize with that `rootUri`, `initialized`,
one `didOpen`, `workspace/symbol`) finishes in ~1s with each package indexed
exactly once. No guard kill anywhere in the round.
### 2026-09-05 — lead, at review
QA's MEDIUM (the dangling-symlink change made a "no such file" error
silent) is ruled and fixed: a dangling link that *names a source file* is
handed on again, so the front end reports it exactly as 0.42.0 did (exit 2);
a dangling link to anything else is skipped as the dev wrote. The test is
renamed to say both halves. QA's LOW (a link to `/` is followed and the
first permission-denied directory aborts the whole walk, dropping the files
already found) is pre-existing `?` propagation and is filed as topo §2.9-30
together with the warning channel the walk lacks. The opentitan
`tlul_adapter_vh.sv` divergence QA root-caused is §41's canonical dedup
reporting a same-directory symlink alias once — the intended change, noted
in 0.43.0's release notes.
## QA log
**2026-09-05 — QA (Sonnet).** Built `target/release/{lucisv,lucisv_server}` once
and attacked both halves of the round on scratch trees under
`tools/guard.sh -t 120`; nothing was ever killed (no memory or wall-clock hit)
in this pass.
*Diff review.* Read `crates/lucisv_core/src/walk.rs`,
`crates/vlog_parser/src/{ast,parser}/decl.rs`,
`crates/vlog_formatter/src/format/decl.rs`, the two test files, and
`crates/lucisv/tests/cli.rs` / `crates/lucisv_server/src/state.rs` line by
line against the plan. Traced the `data_decl` reshuffle by hand for the
empty-slot case on both sides of the type: `net_delay`'s separator branch
degrades to the same `text(" ")` the old unconditional call emitted, so a
declaration with neither a delay nor a comment is unaffected — confirmed
this holds for the "after_type but no data_type" case too, which cannot
arise (`parse_net_delay(is_net, true)` only ever succeeds after
`parse_opt_data_type` actually consumed tokens, since an omitted type
leaves the `#` for the `before` call to claim first).
*43.1 — cycle attacks (all via `tools/guard.sh -t 120`, actual wall times
well under that in every case).*
- Depth 1/2/3 cycles (`a/loop -> a`, `a/b/up -> ..`, `a/b/c/top -> ../../..`):
terminate, each file named once. Two-link cycle (`a/x -> ../b`,
`b/y -> ../a`): terminates, `ma.sv` and `mb.sv` each reported once, `mb.sv`
under the alias spelling `a/x/mb.sv` (first spelling reached, as documented).
Chain of 50 symlinked directories collapsing to one target: resolved
correctly and fast (single `metadata` call per hop, no manual recursion) —
no `ELOOP`, no slowdown.
- **Ancestor-of-start escape.** Built `start/out -> ../..` where the target is
*outside* `start` entirely (not just the walk's own root) and ran
`--check` with `start` as the CLI argument (not its parent). The link is
followed once — per the ruling, identity is the policy, not location — and
pulls in a sibling file and a grandparent-level file that are not inside
`start` at all. It terminates (~1s) because the walk eventually re-enters
`start` itself from the other direction and that's already visited. Not a
bug — this is the plan's own explicit choice (no budget, `rtl ->
../shared/rtl` must keep working) — but it is a real, user-visible
consequence: pointing lucisv at a subdirectory can pull in files from
outside it if that subdirectory contains an upward-and-back symlink.
Flagged as **LOW / informational** for the lead's record, not a defect.
- **Link to `/`.** Followed once, as the ruling implies it must be; spent
~14.6s doing real `readdir`/`stat` work under `/System`, `/Library`,
`/private` etc. before hitting a permission-denied directory, at which
point the *entire* run aborted with `error: <original start path>:
Permission denied` — none of the user's own files were reported, not even
the ones already found. Reproduced this abort-on-any-`read_dir`-error
behaviour with a controlled example (`crates/lucisv_core/src/walk.rs`'s
`dir()` uses `?` on `read_dir(dir)?.collect::<Result<_,_>>()?`, unchanged
by this diff) — it is pre-existing, not introduced by 43.1: the old,
cycle-blind walker would have followed `/` identically and hit the same
wall. Filed as **LOW / informational**, since it predates this round, but
worth the lead's attention because 43.1 is what makes "follow a link
outside the tree" a documented, intentional feature rather than an
accident — a link to `/` (or to any tree with a permission-restricted
subdirectory anywhere under it) now silently costs the *entire* check, not
just the linked file. Link to a real bounded tree (`/usr/share`, 250 MB):
walked completely in ~1s, correctly found and lex-errored on a
coincidentally `.sv`-named file (`vim/vim91/tutor/tutor1.sv`, Swedish
locale code) — confirms outside-of-start links are followed and that nothing
hangs on a moderately large real directory.
- Hard-linked **files**: reported twice, once per directory, confirming
identity is directory-only as documented. Two directories with identical
content but different inodes: both walked (not deduped) — confirmed
content-blind, inode-based identity.
- Gitignore interplay: a cycle inside an ignored directory never runs
(confirmed — the `loop` symlink inside `build/` was never touched); an
ignored symlinked directory name is skipped by that spelling but the real
target directory (different name, not itself ignored) is still walked
directly — this is unchanged, pre-existing per-spelling ignore matching,
not a 43.1 regression; a `.gitignore` inside a followed link's target
applies to the walk (its `sub/` pattern correctly hid the target's own
subdirectory when reached through the link).
- **The dangling `x.sv` behaviour change**, `lucisv format --check dir`
with a dangling `x.sv` link, new binary vs.
`~/.cache/lucisv-baselines/lucisv-0.42.0`: confirmed exactly as the
work log describes — 0.42.0 collects it, fails at read time
(`error: .../x.sv: No such file or directory`, exit 2, "1 file would be
reformatted, 1 file failed to format"); the new binary skips it silently
(exit 1, "1 file would be reformatted", no mention of `x.sv` anywhere).
**Finding, MEDIUM, for the lead's ruling** (this is what the plan and
TODO explicitly asked for, so not a defect against the dev — but the
silence itself is worth a second look): a dangling symlink named like a
source file usually means something real broke (a missing vendor drop, a
bad checkout), and the user now gets no signal at all instead of a
specific, actionable error. The CLI already has a precedent for this exact
tension — a missing file named in a `-f` filelist is a **warning on
stderr**, changing no exit code — and the same shape (warn, don't fail,
don't stay silent) seems like it would keep 43.1's win (no more hard
crash on a broken symlink) without losing the signal. Recommend the lead
decide whether `walk.rs` should carry a callback/return channel for this
one case, or whether silence is accepted as-is.
- **Both front ends.** CLI `--check` over a two-directory cyclic tree
(`rtl/self -> ../rtl`, `rtl/sub/up -> ..`): 2 files, once each. The same
tree over `lucisv_server` (drove the real binary over stdio, same framing
`talk_with` uses: `initialize` with that `rootUri` +
`workspace/didChangeConfiguration` for the wide index scope +
`workspace/symbol` queries): both declared modules found exactly once,
finished in-process with no hang. **File counts agree between CLI and
server for the same tree (2 and 2).**
Explicit file argument that is a symlink to a directory, and a start
directory that is itself a symlink: both work, both find the expected
file under the given spelling.
*43.2 — comment-slot attacks, all via `format --stdout`, then idempotency
(format twice) and a before/after comment-count check on every shape:*
`wire /* c */ #5 w;`, `wire // c` + `#5 w;` on the next line, `wire [7:0]
/* c */ #1 b = c;`, `wire # /* c */ 5 w;` (`after_hash`), both slots at once
(`wire /* c1 */ # /* c2 */ 5 w;`), two comments in one slot
(`wire /* one */ /* two */ #5 w;`), a comment on the after-type side
(`wire [7:0] /* c */ #1 b = c;`), `tri`/`wand` with a delay comment,
an attribute ahead of the module. All ten: format cleanly, round-trip
idempotent, comment count preserved exactly. The refused shapes stayed
refused and did **not** corrupt: all four gaps inside `#(1:2:3)` — before
`1`, around each `:`, after `3` — still fail with a `verification failed:
token stream diverges` error and no output, matching the "not taken" scope
in Handshakes (topo §2.9-22). Ran the gap fuzzer directly
(`cargo test -p vlog_formatter a_comment_in_every_rtl_gap_still_formats`
under guard): passes; confirmed `EXPECTED_RTL_GAPS` is 374 in the tree and
that the added fixture (`wire #5 a;\n wire [7:0] #1 b = c;`) genuinely
exercises both new slots (both are comment-free in the fixture itself, but
the fuzzer inserts a comment into every inter-token gap in turn, which is
what raised the count from 352).
*Gates, all guarded.* `cargo fmt --check` (five touched crates): clean.
`cargo clippy --all-targets`: clean, 0 warnings. `cargo test --workspace`:
**3 788 passed, 0 failed** — matches the work log exactly. Re-ran just
`lucisv_core`'s `walk::tests` in isolation: 17 passed (11 pre-existing + the
6 new ones), including the 6 cycle tests as their own filtered run.
`tools/corpus_check.sh`: **814/820 (99.3%)**, same 6 failures
(`ibex/dv/formal/check/peek/compare_helper.sv`,
`ibex/dv/uvm/core_ibex/riscv_dv_extension/riscv_core_setting.tpl.sv`,
`ibex/syn/rtl/latch_map.v`,
`ibex/vendor/google_riscv-dv/src/riscv_instr_cover_group.sv`,
`picorv32/scripts/romload/testbench.v`,
`picorv32/scripts/smtbmc/mulcmp.v`), same 10 already-clean files.
`node editors/vscode/smoke.js target/release/lucisv-server`: OK, 20
messages.
*Byte-identity vs 0.42.0.* Over the 820-file corpus, each file individually
through `format --stdout` (bypasses directory-walk dedup, isolates the
formatter itself): **0 differing**, exit codes included. Opentitan
`format --check` (using `--no-cache` on both sides after the first pass
showed cache-hit-count noise from a shared `.lucisv_cache`; see below) over
`hw/ip`, `hw/top_earlgrey/ip`, `hw/top_darjeeling/ip`, `hw/dv`, `hw/vendor`:
`hw/top_earlgrey/ip`, `hw/top_darjeeling/ip`, `hw/dv`, `hw/vendor` are
byte-identical between the two binaries (including exit codes: 1, 2, 1, 2
respectively). **`hw/ip` differs by exactly one file**:
`hw/ip/tlul/rtl/tlul_adapter_vh.sv` is reported "would reformat" by 0.42.0
and silently absorbed (not reported at all) by the new binary — 1773 vs.
1772 files. Root-caused, not a §43 regression: `hw/ip/tlul/rtl` contains
`tlul_adapter_shim.sv -> tlul_adapter_vh.sv`, a **symlinked file next to its
own target in the same directory**, and `crates/lucisv/src/main.rs`'s
`dedup()` (canonical-path fold, keeps the first spelling — this is §41,
already in trunk, *not* touched by this diff, and shipped in a release
*after* 0.42.0 per the loop order in `TODO.md`) now folds
`tlul_adapter_shim.sv`/`tlul_adapter_vh.sv` onto one entry, keeping
`tlul_adapter_shim.sv` (alphabetically first) and dropping the other.
Reproduced in isolation on a two-file scratch directory
(`real.sv` + `shim.sv -> real.sv`) with both binaries, `--no-cache`: 0.42.0
reports both, the new binary reports one — confirms this is `main.rs`'s
existing dedup (unmodified by 43.1/43.2) becoming visible only because the
0.42.0 baseline predates it, not anything in this round's diff. Filed as
**informational**, not a §43 finding: the "byte-identity vs 0.42.0" gate is
not a clean isolation of this round alone once §41/§42 sit between the
baseline and trunk; recommend future rounds diff against trunk-before-the-
lane (or the `wip-43` backup already under
`~/.cache/lucisv-baselines/`) for a true delta, and use 0.42.0 only for the
"nothing has moved since the last *release*" question. Confirmed
`git -C ~/repo/opentitan status --porcelain` still shows only the three
expected pre-existing modifications (`hw/ip/aes/dv/tb/tb.sv`,
`hw/top_darjeeling/ip/ast/rtl/ast.sv`, `hw/top_earlgrey/ip/ast/rtl/ast.sv`)
after all opentitan runs; `.lucisv_cache/` is gitignored and untouched by
this statement either way.
*Verdict:* **PASS.** No corruption, no idempotency break, no dropped
comment, in any attack. Both hard invariants around cycles (identity,
no budget) and the two new comment slots hold up under adversarial input,
and the refused inside-`#(...)` gaps stay refused rather than silently
accepted. Two behavioural points are flagged above for the lead's ruling
(the dangling-symlink silence, MEDIUM; the link-to-`/` full-run abort on a
permission wall, LOW/pre-existing) plus one informational note on the
baseline choice for byte-identity gates — none of them block this round.
## Review
**2026-09-05 — lead.** Accepted; ships in 0.43.0. 43.1 is the ruled policy
in one method — identity is the whole rule, and QA's cycles of every shape,
the 50-link chain and the two-link cycle all terminate with each file once.
The dev's `after_hash` slot beyond the plan is accepted: the gap fuzzer's
zero-failure bar made it necessary, and four lines on the same construct is
the right size; the `#(1:2:3)` interior stays §2.9-22's. The one behaviour
change QA flagged is corrected above so no user loses an error they had.
Both front ends share the walk unchanged in signature, and the byte-identity
gate over the corpus is 0 differing.
+26 -6
View File
@@ -102,6 +102,13 @@ The existing temp-and-rename helper is useful for sequential replacement, but
its tests do not justify a same-target concurrency guarantee. Tracked as
[topology handshake 26](topo.md).
**Fixed by TODO §41 (0.43.0, 2026-09-05):** the probe now runs as
`atomic::tests::two_threads_writing_one_target_never_collide` and reports
0 write errors in 200 calls (QA re-ran it at 4 and 8 threads: 0 in 400 and
0 in 800); the symlink alias closes as `cli::a_symlink_and_its_target_are_one_file`.
Two processes writing one target remain last-writer-wins, stated in
`atomic.rs`. See `docs/features/atomic-write-coordination/README.md`.
### 2. Define a consistent project lint configuration contract
Evidence: [server linting](../crates/lucisv_server/src/lint.rs) selects rules in
@@ -112,12 +119,16 @@ project selection. The server also discards invalid project option entries
with `let _ = options.set_raw(...)`; only invalid *editor* option settings
receive the corresponding per-entry log.
The docs now describe the implemented behavior: project selection controls CLI
runs; editor selection requires `lucisv.lint.*` settings; valid project rule
options are shared. Recommended follow-up: specify and test project/editor
selection precedence and surface rejected project rule options. Tracked as
topology handshake 28. This finding is from source inspection; no dedicated
wire-level configuration reproduction was run in this audit.
**Fixed by TODO §42 (0.43.0, 2026-09-05):** `enabled_rules` now takes the
project's selection beside the editor's and picks the editor's list when it
is non-empty, the project's otherwise, key by key — the CLI's `pick` applied
to the editor. Rejected project entries are logged once per (configuration
file, entry) as `<file>:<line>: <message>`, the wording `lucisv check` fails
with, and the buffer is still linted with the entry dropped. Pinned by
`lint::project`'s four-way table test and by three wire-level tests in
`crates/lucisv_server/tests/e2e.rs`, one of which asserts the CLI's and the
server's rule lists equal for three configurations. See
`docs/features/lint-config-contract/README.md`.
### 3. Keep traversal and semantic gaps explicit
@@ -134,6 +145,15 @@ suite also retains a refusal for comments immediately before a net-delay `#`
(27). These limitations should remain visible when widening grammar or index
coverage; formatter verification must continue to reject unsupported output.
**Fixed by TODO §43 (0.43.0, 2026-09-05):** the walker enters each directory
once by identity (`(dev, ino)` on unix, the canonical path elsewhere); a
symlink cycle terminates and a doubly reachable file is reported once. The
"no traversal budget" ruling was the lead's: identity is the policy. The
net-delay comment refusal (handshake 27) is closed by `NetDelay`'s comment
slots. Still open from this finding: handshakes 2, 16, 17, 23, and the new 30
(an unreadable directory aborts the walk). See
`docs/features/walk-cycles/README.md`.
## Documentation changes from this audit
- Expanded the README's architecture to cover all eight crates and documented
+4 -4
View File
@@ -110,10 +110,10 @@ CLI and the editor), and the editor setting <code dir="auto">lucisv.lint.waivers
the first workspace folder). External and inline waivers are a union: a
finding either covers is suppressed, and one both cover leaves neither
reported as dead. A missing file or an unparsable directive fails <code dir="auto">lucisv check</code> with <code dir="auto">&lt;file&gt;:&lt;line&gt;: &lt;message&gt;</code> and exit 2; in an editor the bad line
is dropped and the rest of the file applies — a bad line in a file named by
the editor setting is written once to the lucisv log, one named by
<code dir="auto">lucisv.toml</code> is not (run <code dir="auto">lucisv check</code> to see it). Unused external waivers
is dropped and the rest of the file applies, and the bad line is written once
to the lucisv log whether the file was named by the editor setting or by
<code dir="auto">lucisv.toml</code>. Unused external waivers
are reported under <code dir="auto">unused-waiver</code> at their line of the waiver file, by
<code dir="auto">lucisv check</code> only and only after the whole run.</p>
<p>See the <a href="/reference/rules/">complete rule reference</a>.</p>
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/guides/linter.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-05T04:37:55.000Z">Sep 5, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/guides/formatter/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Formatter</span></span></a><a href="/guides/editors/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Editors &amp; LSP</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/guides/linter.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-05T05:03:07.000Z">Sep 5, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/guides/formatter/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Formatter</span></span></a><a href="/guides/editors/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Editors &amp; LSP</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
{"version":"1.5.2","languages":{"en":{"hash":"en_a31252bf8c","wasm":"en","page_count":12}},"include_characters":["_","‿","⁀","⁔","︳","︴","﹍","﹎","﹏","_"]}
{"version":"1.5.2","languages":{"en":{"hash":"en_e88e94fa5c","wasm":"en","page_count":12}},"include_characters":["_","‿","⁀","⁔","︳","︴","﹍","﹎","﹏","_"]}
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -271,4 +271,4 @@
</tbody>
</table>
<p>An error outranks “would change.” Every file involved in an error is left untouched.</p>
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/reference/cli.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-05T04:37:55.000Z">Sep 5, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/guides/syntax/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Supported syntax</span></span></a><a href="/reference/rules/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Lint rules</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/reference/cli.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-05T05:03:07.000Z">Sep 5, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/guides/syntax/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Supported syntax</span></span></a><a href="/reference/rules/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Lint rules</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
+15 -10
View File
@@ -120,14 +120,14 @@
<td>string array</td>
<td style="text-align: right">defaults</td>
<td>rule names or severity classes</td>
<td>CLI</td>
<td>CLI and editor</td>
</tr>
<tr>
<td><code dir="auto">[lint].ignore</code></td>
<td>string array</td>
<td style="text-align: right"><code dir="auto">[]</code></td>
<td>rule names or severity classes</td>
<td>CLI</td>
<td>CLI and editor</td>
</tr>
<tr>
<td><code dir="auto">[lint].waivers</code></td>
@@ -285,13 +285,18 @@ not enable a rule that is off by default.</p>
indentation, then editor tab size supplies an indent fallback, then built-in
defaults apply. For regular VS Code format-on-save, use <code dir="auto">editor.formatOnSave</code>;
do not also enable <code dir="auto">lucisv.formatOnSave</code>.</p>
<p>For lint selection, the server currently reads editor settings only. Project
<code dir="auto">[lint] select/ignore</code> lists affect the CLI and are not inherited by the server.
Selection proceeds through defaults → select → severity switches → per-rule
toggles → ignore. Editor rule options overlay project rule options key by key.
Invalid editor options are logged and dropped. Invalid project rule-option
entries are currently dropped by server linting without a per-entry log;
<code dir="auto">lucisv check</code> reports them as configuration errors.</p>
<p>For lint selection, the editor’s settings play the role the CLI’s flags
play. Selection proceeds through defaults → select → severity switches →
per-rule toggles → ignore. <code dir="auto">select</code> is <code dir="auto">lucisv.lint.select</code> when that
setting is non-empty and the project’s <code dir="auto">[lint] select</code> otherwise; <code dir="auto">ignore</code>
is decided the same way and independently. The severity switches and
per-rule toggles are editor-only — a <code dir="auto">lucisv.toml</code> has no such keys — and
apply over whichever selection stands. Editor rule options overlay project
rule options key by key. An entry that cannot be used is dropped and logged
once per configuration file and entry, in the same <code dir="auto">&lt;file&gt;:&lt;line&gt;: &lt;message&gt;</code> wording <code dir="auto">lucisv check</code> fails with: an invalid editor option, an
invalid <code dir="auto">[lint.&lt;rule&gt;]</code> entry, an unknown rule name in <code dir="auto">[lint] select</code>/<code dir="auto">ignore</code>, or an unreadable waiver file. <code dir="auto">lucisv check</code> treats each
of these as a configuration error and exits 2; the server keeps linting with
the entry dropped.</p>
<div class="sl-heading-wrapper level-h2"><h2 id="cache">Cache</h2><a class="sl-anchor-link" href="#cache"><span aria-hidden="true" class="sl-anchor-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 1 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 0 0-1.42-1.42m8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 1 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l3.88-3.89a4.49 4.49 0 0 0 0-6.33M8.83 15.17a1 1 0 0 0 .71.29 1 1 0 0 0 .71-.29l4.92-4.92a1 1 0 1 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42"></path></svg></span><span class="sr-only" data-pagefind-ignore>Section titled “Cache”</span></a></div>
<p>Successful “already formatted” verdicts are cached under <code dir="auto">.lucisv_cache/</code>. Entries are keyed by file, content hash, line length, indentation, and lucisv version. Files that would change or fail are never cached. Use <code dir="auto">--no-cache</code> to disable reads and writes or <code dir="auto">--cache-dir</code> to relocate the store.</p>
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/start/configuration.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-05T04:37:55.000Z">Sep 5, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/start/quick-start/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Quick start</span></span></a><a href="/guides/formatter/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Formatter</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
</div><footer class="sl-flex astro-xhxjzfa7"><div class="meta sl-flex astro-xhxjzfa7"><a href="https://git.luci.ooo/lucio/verilogrustformatter/src/branch/master/docs/site/src/content/docs/start/configuration.md" class="sl-flex print:hidden astro-xk5gmzsg"><svg aria-hidden="true" class="astro-xk5gmzsg astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.2em;"><path d="M22 7.24a1 1 0 0 0-.29-.71l-4.24-4.24a1 1 0 0 0-1.1-.22 1 1 0 0 0-.32.22l-2.83 2.83L2.29 16.05a1 1 0 0 0-.29.71V21a1 1 0 0 0 1 1h4.24a1 1 0 0 0 .76-.29l10.87-10.93L21.71 8c.1-.1.17-.2.22-.33a1 1 0 0 0 0-.24v-.14l.07-.05ZM6.83 20H4v-2.83l9.93-9.93 2.83 2.83L6.83 20ZM18.17 8.66l-2.83-2.83 1.42-1.41 2.82 2.82-1.41 1.42Z"/></svg>Edit page</a><p>Last updated: <time datetime="2026-09-05T05:03:07.000Z">Sep 5, 2026</time></p></div><div class="pagination-links print:hidden astro-jgq3vlii" dir="ltr"><a href="/start/quick-start/" rel="prev" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17 11H9.41l3.3-3.29a1.004 1.004 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33 1 1 0 0 0 0 .76 1 1 0 0 0 .21.33l5 5a1.002 1.002 0 0 0 1.639-.325 1 1 0 0 0-.219-1.095L9.41 13H17a1 1 0 0 0 0-2Z"/></svg><span class="astro-jgq3vlii">Previous<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Quick start</span></span></a><a href="/guides/formatter/" rel="next" class="astro-jgq3vlii"><svg aria-hidden="true" class="astro-jgq3vlii astro-n5k4ipy7" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="--sl-icon-size: 1.5rem;"><path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/></svg><span class="astro-jgq3vlii">Next<br class="astro-jgq3vlii"><span class="link-title astro-jgq3vlii">Formatter</span></span></a></div></footer></div></div></main></div></div></div></div></body></html>
+3 -3
View File
@@ -84,9 +84,9 @@ the first workspace folder). External and inline waivers are a union: a
finding either covers is suppressed, and one both cover leaves neither
reported as dead. A missing file or an unparsable directive fails `lucisv
check` with `<file>:<line>: <message>` and exit 2; in an editor the bad line
is dropped and the rest of the file applies — a bad line in a file named by
the editor setting is written once to the lucisv log, one named by
`lucisv.toml` is not (run `lucisv check` to see it). Unused external waivers
is dropped and the rest of the file applies, and the bad line is written once
to the lucisv log whether the file was named by the editor setting or by
`lucisv.toml`. Unused external waivers
are reported under `unused-waiver` at their line of the waiver file, by
`lucisv check` only and only after the whole run.
@@ -30,8 +30,8 @@ style_regex = "[a-z_0-9]+"
| `indent` | integer | `2` | `1..8` | CLI and server |
| `exclude` | string array | `[]` | path patterns | CLI walk and server index |
| `filelist` | string | — | EDA `.f` path | server index |
| `[lint].select` | string array | defaults | rule names or severity classes | CLI |
| `[lint].ignore` | string array | `[]` | rule names or severity classes | CLI |
| `[lint].select` | string array | defaults | rule names or severity classes | CLI and editor |
| `[lint].ignore` | string array | `[]` | rule names or severity classes | CLI and editor |
| `[lint].waivers` | string array | `[]` | external waiver files, resolved against this file's directory (Verible's format; see the linter guide) | CLI and editor |
`[lint.<rule-name>]` tables configure individual rules. The rule registry
@@ -89,13 +89,20 @@ indentation, then editor tab size supplies an indent fallback, then built-in
defaults apply. For regular VS Code format-on-save, use `editor.formatOnSave`;
do not also enable `lucisv.formatOnSave`.
For lint selection, the server currently reads editor settings only. Project
`[lint] select/ignore` lists affect the CLI and are not inherited by the server.
Selection proceeds through defaults → select → severity switches → per-rule
toggles → ignore. Editor rule options overlay project rule options key by key.
Invalid editor options are logged and dropped. Invalid project rule-option
entries are currently dropped by server linting without a per-entry log;
`lucisv check` reports them as configuration errors.
For lint selection, the editor's settings play the role the CLI's flags
play. Selection proceeds through defaults → select → severity switches →
per-rule toggles → ignore. `select` is `lucisv.lint.select` when that
setting is non-empty and the project's `[lint] select` otherwise; `ignore`
is decided the same way and independently. The severity switches and
per-rule toggles are editor-only — a `lucisv.toml` has no such keys — and
apply over whichever selection stands. Editor rule options overlay project
rule options key by key. An entry that cannot be used is dropped and logged
once per configuration file and entry, in the same `<file>:<line>:
<message>` wording `lucisv check` fails with: an invalid editor option, an
invalid `[lint.<rule>]` entry, an unknown rule name in `[lint]
select`/`ignore`, or an unreadable waiver file. `lucisv check` treats each
of these as a configuration error and exits 2; the server keeps linting with
the entry dropped.
## Cache
+6 -4
View File
@@ -621,7 +621,7 @@ update the filing README(s) and this file.
| ~~5~~ | ~~`lucisv check --rules-doc` printing `rules_markdown()`~~ — **delivered 2026-09-02 by macro-word-census (TODO §29.3)**: `lucisv check --rules-doc` prints `rules_markdown()` and exits 0, takes no files, is lint-only; the example binary is gone | lint-rules-2 | ~~crates/lucisv~~ done |
| ~~6~~ | ~~Workspace-wide "does any file mention this name" query — the precondition for the semantic lints defaulting on~~ — **delivered 2026-09-02 by semantic-lints-on**: `FileFacts::words` (one identifier harvest, `vlog_semantic::words`, lifted from the server's candidates) and `WorkspaceIndex::files_mentioning` / `mentioned_outside(name, own_file)`; `FACTS_FORMAT` 12 → 13. The three rules consult a `MentionOracle` and are on by default whenever one exists. | semantic-lints | ~~vlog_semantic (index)~~ done |
| ~~7~~ | ~~`SymbolKind::Interface` (interfaces currently indexed as `Module`; modport/clocking names unbound)~~ — **delivered 2026-09-01 by interface-semantics**: `SymbolKind::{Interface, Modport, Clocking}`, `is_instantiable()` threaded through every Module-exact filter, an interface export rule that treats its signals as its surface, modport/clocking-internal names bound as scope-local references, the modport half of a glued type name bound as `Target::TypeMember`. `program` still indexes as `Module`. Corpus unresolved fell 1 256 → 1 203 | interfaces | ~~vlog_semantic~~ done |
| 8 | Symlink-cycle detection in the shared walk (both front ends exposed; wants its own round — it changes CLI behavior) | lucisv-core-lift | lucisv_core |
| ~~8~~ | ~~Symlink-cycle detection in the shared walk (both front ends exposed; wants its own round — it changes CLI behavior)~~ — **delivered 2026-09-05 by walk-cycles (TODO §43.1):** `Walk` keeps a `visited` set keyed on `(dev, ino)` (canonical path elsewhere); each directory entered once, a link to one already entered skipped, a link to one not yet entered followed once, a dangling directory link skipped (a dangling source-file link is still handed on so the front end's "no such file" survives). Both front ends. | lucisv-core-lift | lucisv_core |
| ~~9~~ | ~~Chasing `InheritedCandidate` through the member tables (in-file and cross-file) + hover for `extends`~~ — **delivered 2026-09-01 by class-member-access**: `resolve::member_in_chain` walks the in-file `extends` chain, `WorkspaceIndex::base_of` + `member_chain` walk it across files (inside `follow_one`, so hover and cross-file references agree), both cycle-guarded; `this.x`/`super.x` misses ride the same loop. `extends` hover/definition on the base name was already answered by overlay-promotion's type-position promotion. Residue filed in TODO §15 round 2: a `base` field on `ReferenceFact` so `this.x` misses get index postings too | class-semantics | ~~vlog_semantic~~ done |
| ~~10~~ | ~~`Fmt::raw_text`'s string-crossing path emits a `Doc::Text` carrying newlines~~ — **delivered 2026-08-26 (`53f2269`)**: both `raw_text` and the parameterized-type `#( … )` now emit `Doc::Inline`, whose printer arm resumes measuring from the text's own last line. directive-split's README (QA round 3 note) still documents it as open and should be struck there too | directive-split QA | ~~vlog_formatter~~ done |
| 11 | Corpus scripts match `parse error:` / `lex error:` / `verification failed:` textually; a structured `--output-format json` for format mode would remove it | corpus-check | crates/lucisv |
@@ -640,9 +640,11 @@ update the filing README(s) and this file.
| ~~24~~ | ~~A **half-typed `#(` parameter override whose value can read as a call** (`sub #(.W(` ⏎ `u0 (.a(x))`) — the greedy expression grammar swallows the next instance's name before any error fires, so the whole instantiation still degrades to an item-level `Error` node instead of getting header recovery's benefit. Found by §32's QA; the fix is a lookahead in the override grammar (an identifier followed by `(` on a later line is the next instance, not a call).~~ — **delivered 2026-09-04 by small-items-3 (TODO §36)** | header-recovery (QA) | vlog_parser |
| ~~25~~ | ~~The parser **refuses** a module-scope `begin … end` and a bare `begin` inside a `generate` region (an `ItemKind::Error`) rather than recovering them as an unnamed generate block, so `module-begin-block` and `v2001-generate-begin` (TODO §35) fire on an error leaf and the rest of the unit is lost to recovery. Wanted: tolerant-mode recovery that keeps the block's items.~~ — **delivered 2026-09-04 by small-items-3 (TODO §36)** | linter-expansion-3 (dev) | vlog_parser |
| 26 | **Same-target atomic writers share a temp path.** `atomic::temp_path` uses canonical target + process ID; parallel workers following distinct symlink spellings can reach that same name, while CLI dedup is lexical. A bounded direct helper probe (100 rounds, two threads, 1 MiB each) returned 100 write errors in 200 calls; no mixed final bytes observed in that probe. Use exclusive per-operation temp creation and coordinate/deduplicate target writes. See repository-analysis.md for limits. | repository audit, 2026-09-04 | lucisv_core / lucisv |
| 27 | **Net-delay comment slot**: parser-skips records a pre-existing refusal for a comment immediately before `#` in a net declaration. The regression cases mark it `#SKIP`; preserve the verifier's rejection until a parser/formatter comment slot handles it. | parser-skips (dev + QA) | vlog_parser / vlog_formatter |
| 28 | **Project lint selection is not consumed by the server.** `enabled_rules` reads `ClientSettings`; `configured` reads project rule options and line length only. `[lint] select/ignore` currently controls CLI runs, while the editor needs `lucisv.lint.select/ignore`. Decide and test a common precedence contract before claiming project-wide parity. | repository audit, 2026-09-04 | lucisv_server |
| ~~26~~ | ~~**Same-target atomic writers share a temp path.** `atomic::temp_path` uses canonical target + process ID; parallel workers following distinct symlink spellings can reach that same name, while CLI dedup is lexical. A bounded direct helper probe (100 rounds, two threads, 1 MiB each) returned 100 write errors in 200 calls; no mixed final bytes observed in that probe. Use exclusive per-operation temp creation and coordinate/deduplicate target writes. See repository-analysis.md for limits.~~ — **closed by §41 (0.43.0):** unique `O_EXCL` temps (`.{name}.{pid}.{n}.lucisv-tmp`), dedup on `fs::canonicalize`; two *processes* remain last-writer-wins by design, stated in `atomic.rs` | repository audit, 2026-09-04 | lucisv_core / lucisv |
| ~~27~~ | ~~**Net-delay comment slot**: parser-skips records a pre-existing refusal for a comment immediately before `#` in a net declaration. The regression cases mark it `#SKIP`; preserve the verifier's rejection until a parser/formatter comment slot handles it.~~ — **delivered 2026-09-05 by walk-cycles (TODO §43.2):** `NetDelay::{before_hash, after_hash}` own the gaps around `#`; the `#SKIP` is retired; the RTL gap fuzzer covers it. The gaps inside `#(1:2:3)` remain §2.9-22's. | parser-skips (dev + QA) | vlog_parser / vlog_formatter |
| ~~28~~ | ~~**Project lint selection is not consumed by the server.** `enabled_rules` reads `ClientSettings`; `configured` reads project rule options and line length only. `[lint] select/ignore` currently controls CLI runs, while the editor needs `lucisv.lint.select/ignore`. Decide and test a common precedence contract before claiming project-wide parity.~~ — **closed by §42 (0.43.0):** `enabled_rules` picks the editor's list when set, else the project's, key by key (the CLI's `pick`); rejected project entries logged once with file:line | repository audit, 2026-09-04 | lucisv_server |
| 29 | An unknown rule name in the **editor's** `lucisv.lint.select`/`ignore` is still dropped silently, while §42 logs the same mistake in a project file (and `lucisv.lint.options` logs its bad entries). Wants the same once-only log through `notification.rs`. | lint-config-contract (QA) | lucisv_server |
| 30 | **An unreadable directory aborts the whole walk.** `Walk::dir` propagates `read_dir`'s error with `?`, so one permission-denied directory anywhere under the start — reachable now that a symlink to an outside directory is followed once (§2.9-8's ruling) — drops every file already found and fails the run. Found by walk-cycles' QA on a link to `/`. Wanted: skip the directory and say so through a warning channel the walk does not have today (the filelist-missing-file precedent), which is also where a dangling source link's warning belongs. | walk-cycles (QA) | lucisv_core / lucisv / lucisv_server |
---
+8
View File
@@ -5,6 +5,14 @@ for you. The extension and its bundled language server share one version
number; the full engineering notes live in the
[project changelog](https://git.luci.ooo/lucio/lucisv/src/branch/master/CHANGELOG.md).
## 0.43.0 — 2026-09-05
- **Project lint settings apply in the editor.** `[lint] select` and
`[lint] ignore` in `lucisv.toml` now govern the editor's diagnostics
unless your own `lucisv.lint.select`/`ignore` overrides them, and a
project entry lucisv cannot use is reported once in the lucisv log.
- Workspaces containing symlink cycles index without hanging.
## 0.42.0 — 2026-09-05
- **Waiver files.** Point `lucisv.lint.waivers` (or `[lint] waivers` in
+7 -1
View File
@@ -30,7 +30,7 @@ Install **lucisv — Verilog/SystemVerilog** from the VS Code Extensions view,
then open a Verilog or SystemVerilog file. There is no separate server or CLI
setup.
The current release is **0.42.0**. Its platform packages include both
The current release is **0.43.0**. Its platform packages include both
`lucisv-server` and the `lucisv` command-line tool:
| Package target | Machines |
@@ -365,6 +365,12 @@ Every nesting color is a proper VS Code theme color:
}
```
## Release 0.43.0 highlights
Version 0.43.0 closes the repository analysis's three findings: atomic
writers that cannot collide, one lint-configuration contract for project
and editor, and directory walks that terminate on symlink cycles.
## Release 0.42.0 highlights
Version 0.42.0 adds external waiver files (Verible's format) and formats
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "lucisv",
"displayName": "lucisv — Verilog/SystemVerilog",
"description": "Fast Verilog/SystemVerilog formatting, linting, navigation, refactoring, semantic highlighting and RTL design intelligence.",
"version": "0.42.0",
"version": "0.43.0",
"publisher": "guoliangchen",
"author": "Guoliang Chen",
"license": "MIT",