diff --git a/README.md b/README.md index 1eadc48..ca7e647 100644 --- a/README.md +++ b/README.md @@ -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 `:: ` 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.]` option, an unreadable waiver +file or a directive that does not parse — fails `lucisv check` with +`:: ` 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) diff --git a/TODO.md b/TODO.md index bc31f0d..776c5c2 100644 --- a/TODO.md +++ b/TODO.md @@ -4478,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 diff --git a/crates/lucisv_server/src/lint.rs b/crates/lucisv_server/src/lint.rs index 57098b4..29b8106 100644 --- a/crates/lucisv_server/src/lint.rs +++ b/crates/lucisv_server/src/lint.rs @@ -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) { 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 { - let mut paths: Vec = 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 { + 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 { + 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) { (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.` switched off **removes** every rule of /// that class; /// 4. a `lucisv.lint.rules.` 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(); diff --git a/crates/lucisv_server/src/lint/project.rs b/crates/lucisv_server/src/lint/project.rs new file mode 100644 index 0000000..03d7fa4 --- /dev/null +++ b/crates/lucisv_server/src/lint/project.rs @@ -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, + /// `[lint] ignore`: rules dropped from whatever `select` left — unless + /// the editor named some. + pub ignore: Vec, +} + +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) { + 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, +) -> Vec { + 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.]` 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.]` 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 — +/// `:: ` — 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, + /// 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, +} + +impl ConfigProblems { + /// The problems found in this config file. + pub fn new(file: &FileConfig, messages: Vec) -> 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, +} + +/// One config file's memo: the content it was taken under, and what was said. +#[derive(Debug, Default)] +struct Said { + stamp: u64, + messages: BTreeSet, +} + +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 { + 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::>(), + "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::>() + ); + } + + /// §42.2: a `[lint.]` 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()); + } +} diff --git a/crates/lucisv_server/src/server/diagnostics.rs b/crates/lucisv_server/src/server/diagnostics.rs index 1d874fd..9f093dc 100644 --- a/crates/lucisv_server/src/server/diagnostics.rs +++ b/crates/lucisv_server/src/server/diagnostics.rs @@ -94,10 +94,44 @@ impl Server { fn diagnostics_of(&self, uri: &Uri) -> Vec { 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, `:: `, 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 diff --git a/crates/lucisv_server/src/server/mod.rs b/crates/lucisv_server/src/server/mod.rs index 789c421..777cea1 100644 --- a/crates/lucisv_server/src/server/mod.rs +++ b/crates/lucisv_server/src/server/mod.rs @@ -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, + /// 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, 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, diff --git a/crates/lucisv_server/tests/e2e.rs b/crates/lucisv_server/tests/e2e.rs index ddec339..0300c3d 100644 --- a/crates/lucisv_server/tests/e2e.rs +++ b/crates/lucisv_server/tests/e2e.rs @@ -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> { + let mut steps: Vec> = 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 = 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.]` 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 = 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); + } +} diff --git a/docs/features/lint-config-contract/README.md b/docs/features/lint-config-contract/README.md new file mode 100644 index 0000000..4b791b2 --- /dev/null +++ b/docs/features/lint-config-contract/README.md @@ -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.]` 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.` and + `lucisv.lint.rules.` 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.]` 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 `:: `, + 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.` off **removes** that class (editor only); +4. `lucisv.lint.rules.` 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: :: ; 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.]` 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.]` entry and not +per list element: `: [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.]` option, an unreadable waiver +> file or a directive that does not parse — fails `lucisv check` with +> `:: ` 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 `:: +> ` wording `lucisv check` fails with: an invalid editor option, an +> invalid `[lint.]` 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 `:: `, 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.` 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 + (`: [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.]` option (`length = "wide"`): exactly one + `window/logMessage` across five `didChange` passes over the same bad + config; the message's core (`:: rule `` `) 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` 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. diff --git a/docs/features/server-lint/README.md b/docs/features/server-lint/README.md index 04cba9e..dc6105a 100644 --- a/docs/features/server-lint/README.md +++ b/docs/features/server-lint/README.md @@ -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. diff --git a/docs/repository-analysis.md b/docs/repository-analysis.md index 5a5403f..237bf58 100644 --- a/docs/repository-analysis.md +++ b/docs/repository-analysis.md @@ -119,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 `:: `, 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 diff --git a/docs/site/dist/guides/linter/index.html b/docs/site/dist/guides/linter/index.html index 6522c40..148e0e3 100644 --- a/docs/site/dist/guides/linter/index.html +++ b/docs/site/dist/guides/linter/index.html @@ -110,10 +110,10 @@ CLI and the editor), and the editor setting 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 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.

See the complete rule reference.

- \ No newline at end of file + \ No newline at end of file diff --git a/docs/site/dist/pagefind/fragment/en_12205bd.pf_fragment b/docs/site/dist/pagefind/fragment/en_12205bd.pf_fragment deleted file mode 100644 index 19b52eb..0000000 Binary files a/docs/site/dist/pagefind/fragment/en_12205bd.pf_fragment and /dev/null differ diff --git a/docs/site/dist/pagefind/fragment/en_209bfcf.pf_fragment b/docs/site/dist/pagefind/fragment/en_209bfcf.pf_fragment new file mode 100644 index 0000000..8786643 Binary files /dev/null and b/docs/site/dist/pagefind/fragment/en_209bfcf.pf_fragment differ diff --git a/docs/site/dist/pagefind/fragment/en_c0f23d2.pf_fragment b/docs/site/dist/pagefind/fragment/en_c0f23d2.pf_fragment new file mode 100644 index 0000000..896ae11 Binary files /dev/null and b/docs/site/dist/pagefind/fragment/en_c0f23d2.pf_fragment differ diff --git a/docs/site/dist/pagefind/fragment/en_df926cc.pf_fragment b/docs/site/dist/pagefind/fragment/en_df926cc.pf_fragment deleted file mode 100644 index 6e4b7d5..0000000 Binary files a/docs/site/dist/pagefind/fragment/en_df926cc.pf_fragment and /dev/null differ diff --git a/docs/site/dist/pagefind/index/en_179e478.pf_index b/docs/site/dist/pagefind/index/en_179e478.pf_index new file mode 100644 index 0000000..2ff02dd Binary files /dev/null and b/docs/site/dist/pagefind/index/en_179e478.pf_index differ diff --git a/docs/site/dist/pagefind/index/en_49be357.pf_index b/docs/site/dist/pagefind/index/en_49be357.pf_index new file mode 100644 index 0000000..f4c3dda Binary files /dev/null and b/docs/site/dist/pagefind/index/en_49be357.pf_index differ diff --git a/docs/site/dist/pagefind/index/en_83a706f.pf_index b/docs/site/dist/pagefind/index/en_83a706f.pf_index deleted file mode 100644 index 9c89f9c..0000000 Binary files a/docs/site/dist/pagefind/index/en_83a706f.pf_index and /dev/null differ diff --git a/docs/site/dist/pagefind/index/en_acaf82d.pf_index b/docs/site/dist/pagefind/index/en_acaf82d.pf_index deleted file mode 100644 index 76c0a7f..0000000 Binary files a/docs/site/dist/pagefind/index/en_acaf82d.pf_index and /dev/null differ diff --git a/docs/site/dist/pagefind/pagefind-entry.json b/docs/site/dist/pagefind/pagefind-entry.json index 7427d23..f7f86d4 100644 --- a/docs/site/dist/pagefind/pagefind-entry.json +++ b/docs/site/dist/pagefind/pagefind-entry.json @@ -1 +1 @@ -{"version":"1.5.2","languages":{"en":{"hash":"en_a31252bf8c","wasm":"en","page_count":12}},"include_characters":["_","‿","⁀","⁔","︳","︴","﹍","﹎","﹏","_"]} \ No newline at end of file +{"version":"1.5.2","languages":{"en":{"hash":"en_e88e94fa5c","wasm":"en","page_count":12}},"include_characters":["_","‿","⁀","⁔","︳","︴","﹍","﹎","﹏","_"]} \ No newline at end of file diff --git a/docs/site/dist/pagefind/pagefind.en_a31252bf8c.pf_meta b/docs/site/dist/pagefind/pagefind.en_a31252bf8c.pf_meta deleted file mode 100644 index f67cc6d..0000000 Binary files a/docs/site/dist/pagefind/pagefind.en_a31252bf8c.pf_meta and /dev/null differ diff --git a/docs/site/dist/pagefind/pagefind.en_e88e94fa5c.pf_meta b/docs/site/dist/pagefind/pagefind.en_e88e94fa5c.pf_meta new file mode 100644 index 0000000..45c3109 Binary files /dev/null and b/docs/site/dist/pagefind/pagefind.en_e88e94fa5c.pf_meta differ diff --git a/docs/site/dist/reference/cli/index.html b/docs/site/dist/reference/cli/index.html index d78b833..f1d4d6d 100644 --- a/docs/site/dist/reference/cli/index.html +++ b/docs/site/dist/reference/cli/index.html @@ -271,4 +271,4 @@

An error outranks “would change.” Every file involved in an error is left untouched.

- \ No newline at end of file + \ No newline at end of file diff --git a/docs/site/dist/start/configuration/index.html b/docs/site/dist/start/configuration/index.html index 3e3afa5..a89dc02 100644 --- a/docs/site/dist/start/configuration/index.html +++ b/docs/site/dist/start/configuration/index.html @@ -120,14 +120,14 @@ string array defaults rule names or severity classes -CLI +CLI and editor [lint].ignore string array [] rule names or severity classes -CLI +CLI and editor [lint].waivers @@ -285,13 +285,18 @@ not enable a rule that is off by default.

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.

Successful “already formatted” verdicts are cached under .lucisv_cache/. Entries are keyed by file, content hash, line length, indentation, and lucisv version. Files that would change or fail are never cached. Use --no-cache to disable reads and writes or --cache-dir to relocate the store.

- \ No newline at end of file + \ No newline at end of file diff --git a/docs/site/src/content/docs/guides/linter.md b/docs/site/src/content/docs/guides/linter.md index 41ba97c..aead090 100644 --- a/docs/site/src/content/docs/guides/linter.md +++ b/docs/site/src/content/docs/guides/linter.md @@ -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 `:: ` 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. diff --git a/docs/site/src/content/docs/start/configuration.md b/docs/site/src/content/docs/start/configuration.md index 0f9abbf..90cdc68 100644 --- a/docs/site/src/content/docs/start/configuration.md +++ b/docs/site/src/content/docs/start/configuration.md @@ -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.]` 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 `:: +` wording `lucisv check` fails with: an invalid editor option, an +invalid `[lint.]` 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 diff --git a/docs/topo.md b/docs/topo.md index 0add63a..86bb5ae 100644 --- a/docs/topo.md +++ b/docs/topo.md @@ -642,7 +642,8 @@ update the filing README(s) and this file. | ~~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. | 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 | +| ~~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 | ---