Format cache: uvm-utils-indent joins the key (§59, topo 34) — Entry carries the option, the store line has it as a fourth field, a 0.49.0 store is rebuilt not trusted; CLI regression both toggle directions
ci / checks (push) Successful in 1m15s
ci / corpus (push) Successful in 34s

This commit is contained in:
lucio committed 2026-09-07 04:31:26 -05:00
1 parent d8d1791c1c
commit c37b13de31
9 files changed
+512 -63

No files matched your search

+5 -7
View File
@@ -86,8 +86,8 @@ run over an unchanged tree skips them: the summary says `N files from cache`,
and on one core the corpus check goes from 396 ms to 51 ms (2.3× at the default
thread count, where parallelism has already taken the easy win).
An entry is keyed on **(content hash, `line-length`, `indent`, lucisv version)**
per file, and only ever records the *already formatted* verdict — a file that
An entry is keyed on **(content hash, `line-length`, `indent`,
`uvm-utils-indent`, lucisv version)** per file, and only ever records the *already formatted* verdict — a file that
would be reformatted, or that failed, is re-checked on every run. The store is one
text file in `.lucisv_cache/` (self-ignoring, like cargo's `target/`); deleting
it, or a corrupted one, costs one slow run and nothing else. `--no-cache`
@@ -96,11 +96,9 @@ default is relative to the current directory). Content hashing is 64-bit
FNV-1a and a lookup never crosses files; `docs/features/format-cache/README.md`
states the collision posture, the semantics table and the concurrency story.
In v0.49.0, the new `uvm-utils-indent` option is missing from this key.
After changing that option, use `--no-cache` or remove `.lucisv_cache/` (or
your custom cache directory); otherwise a cached clean verdict can hide a
formatting change. The reproduction and required fix are recorded in
[topology handshake 34](docs/topo.md).
(In v0.49.0 only, `uvm-utils-indent` was missing from this key, so a cached
clean verdict survived a toggle of the option — fixed in 0.50.0; a 0.49.0
store is simply rebuilt.)
### Ignore files
+4 -4
View File
@@ -5653,9 +5653,9 @@ amended: the key now names the option).
- README: the `--no-cache` workaround paragraph in `README.md` and the
topo row 34 struck at merge (lead).
- [ ] `Entry`/`entry_for`/store codec, tests
- [ ] CLI regression, both toggle directions
- [ ] format-cache README work log + Handshakes
- [ ] QA: attack the key (another option, another version, a store line
- [x] `Entry`/`entry_for`/store codec, tests
- [x] CLI regression, both toggle directions
- [x] format-cache README work log + Handshakes
- [x] QA: attack the key (another option, another version, a store line
with four fields); confirm the audit's probe passes on the fix and
fails on 0.49.0
+6 -1
View File
@@ -333,7 +333,12 @@ fn process_file(file: &Path, config: &Config, opts: &Options, cache: &Cache) ->
/// the key, not the config file that produced them, so identical settings
/// from different `lucisv.toml` files share entries.
fn entry_for(content: u64, config: &Config) -> Entry {
Entry { content, line_length: config.max_width, indent: config.indent_width }
Entry {
content,
line_length: config.max_width,
indent: config.indent_width,
uvm_utils_indent: config.uvm_utils_indent,
}
}
/// Builds rayon's global pool. Worker stacks are sized for the parser's
+68 -5
View File
@@ -1267,16 +1267,18 @@ impl TempDir {
}
}
/// One hand-written cache line, for the tests that forge entries.
/// One hand-written cache line, for the tests that forge entries. The
/// fields are the store's, in order; `uvm` is `[format] uvm-utils-indent`.
fn cache_line(
path: &str,
content: &str,
line_length: usize,
indent: usize,
uvm: bool,
version: &str,
) -> String {
let hash = lucisv_core::cache::content_hash(content.as_bytes());
format!("{hash:016x}\t{line_length}\t{indent}\t{version}\t{path}\n")
format!("{hash:016x}\t{line_length}\t{indent}\t{uvm}\t{version}\t{path}\n")
}
#[test]
@@ -1363,7 +1365,8 @@ fn a_hit_skips_the_work_entirely() {
let out = run_raw(&["--check", &path, "--cache-dir", &cache]);
assert_eq!(code(&out), 2, "without an entry this file is an error");
std::fs::write(dir.cache_file(), cache_line(&path, UNPARSEABLE, 100, 2, VERSION)).unwrap();
std::fs::write(dir.cache_file(), cache_line(&path, UNPARSEABLE, 100, 2, false, VERSION))
.unwrap();
let out = run_raw(&["--check", &path, "--cache-dir", &cache]);
assert_eq!(code(&out), 0, "a hit does no work at all: {}", stderr(&out));
assert!(stderr(&out).contains("1 file from cache"), "{}", stderr(&out));
@@ -1388,6 +1391,65 @@ fn a_config_file_change_invalidates_the_entry_too() {
assert!(stderr(&out).contains("1 file from cache"), "{}", stderr(&out));
}
/// A UVM class whose layout depends on `[format] uvm-utils-indent`: with the
/// option on, the `` `uvm_field_* `` macro gains a level. Written here as the
/// formatter leaves it with the option *off*.
const UVM_CLASS: &str = "class c extends uvm_object;\n `uvm_object_utils_begin(c)\n \
`uvm_field_int(a, UVM_DEFAULT)\n `uvm_object_utils_end\nendclass\n";
#[test]
fn changing_uvm_utils_indent_invalidates_the_entry() {
let dir = TempDir::new("cache-uvm");
dir.write("lucisv.toml", "[format]\nuvm-utils-indent = false\n");
let path = dir.write("a.sv", UVM_CLASS);
let cache = dir.cache();
// Clean with the option off, and that verdict is cached.
assert_eq!(code(&run_raw(&[&path, "--cache-dir", &cache])), 0);
let flat = dir.read("a.sv");
let out = run_raw(&["--check", &path, "--cache-dir", &cache]);
assert_eq!(code(&out), 0, "{}", stderr(&out));
assert!(stderr(&out).contains("1 file from cache"), "{}", stderr(&out));
// Turning the option on must not hit the entry the option-off run left.
dir.write("lucisv.toml", "[format]\nuvm-utils-indent = true\n");
let out = run_raw(&["--check", &path, "--cache-dir", &cache]);
assert_eq!(code(&out), 1, "uvm-utils-indent is part of the key: {}", stderr(&out));
assert!(stdout(&out).contains("would reformat:"), "{}", stdout(&out));
// Format under the option on, cache *that*, then flip back off.
assert_eq!(code(&run_raw(&[&path, "--cache-dir", &cache])), 0);
assert_ne!(dir.read("a.sv"), flat, "the option really does change the output");
let out = run_raw(&["--check", &path, "--cache-dir", &cache]);
assert_eq!(code(&out), 0, "{}", stderr(&out));
assert!(stderr(&out).contains("1 file from cache"), "{}", stderr(&out));
dir.write("lucisv.toml", "[format]\nuvm-utils-indent = false\n");
let out = run_raw(&["--check", &path, "--cache-dir", &cache]);
assert_eq!(code(&out), 1, "and the other direction too: {}", stderr(&out));
assert!(stdout(&out).contains("would reformat:"), "{}", stdout(&out));
}
#[test]
fn a_store_written_before_the_option_joined_the_key_is_rebuilt() {
let dir = TempDir::new("cache-oldshape");
let path = dir.write("a.sv", FORMATTED);
let cache = dir.cache();
std::fs::create_dir_all(dir.path.join("cache-dir")).unwrap();
// The five-field line lucisv wrote before `uvm-utils-indent` was in the
// key. Not corruption: the line is dropped on its own and the run
// rebuilds the store in the current shape.
let hash = lucisv_core::cache::content_hash(FORMATTED.as_bytes());
std::fs::write(dir.cache_file(), format!("{hash:016x}\t100\t2\t{VERSION}\t{path}\n")).unwrap();
let out = run_raw(&["--check", &path, "--cache-dir", &cache]);
assert_eq!(code(&out), 0, "an older store is never an error: {}", stderr(&out));
assert!(!stderr(&out).contains("from cache"), "{}", stderr(&out));
let out = run_raw(&["--check", &path, "--cache-dir", &cache]);
assert!(stderr(&out).contains("1 file from cache"), "the store was rebuilt: {}", stderr(&out));
}
#[test]
fn an_entry_from_another_lucisv_version_is_ignored() {
let dir = TempDir::new("cache-version");
@@ -1397,13 +1459,14 @@ fn an_entry_from_another_lucisv_version_is_ignored() {
// A forged entry claiming this unformatted file is clean. With this
// version's stamp it is believed…
std::fs::write(dir.cache_file(), cache_line(&path, UNFORMATTED, 100, 2, VERSION)).unwrap();
std::fs::write(dir.cache_file(), cache_line(&path, UNFORMATTED, 100, 2, false, VERSION))
.unwrap();
let out = run_raw(&["--check", &path, "--cache-dir", &cache]);
assert_eq!(code(&out), 0, "the forged entry proves entries are really read");
assert!(stderr(&out).contains("1 file from cache"), "{}", stderr(&out));
// …and with any other version's stamp it is not.
std::fs::write(dir.cache_file(), cache_line(&path, UNFORMATTED, 100, 2, "0.0.0-other"))
std::fs::write(dir.cache_file(), cache_line(&path, UNFORMATTED, 100, 2, false, "0.0.0-other"))
.unwrap();
let out = run_raw(&["--check", &path, "--cache-dir", &cache]);
assert_eq!(code(&out), 1, "another version's entry must not be trusted: {}", stderr(&out));
+94 -19
View File
@@ -32,6 +32,9 @@ pub struct Entry {
pub line_length: usize,
/// The `indent` that verdict was reached under.
pub indent: usize,
/// The `[format] uvm-utils-indent` that verdict was reached under: it
/// changes the output of a UVM class, so it is part of the key.
pub uvm_utils_indent: bool,
}
/// The cache for one run: loaded once at startup, written once at exit.
@@ -104,8 +107,8 @@ impl Cache {
let entry = &self.entries[path];
let _ = writeln!(
text,
"{:016x}\t{}\t{}\t{VERSION}\t{path}",
entry.content, entry.line_length, entry.indent
"{:016x}\t{}\t{}\t{}\t{VERSION}\t{path}",
entry.content, entry.line_length, entry.indent, entry.uvm_utils_indent
);
}
text
@@ -137,25 +140,49 @@ fn key(path: &Path) -> Option<&str> {
Some(text)
}
/// The `(content, line-length, indent)` prefix every store line has ever
/// begun with, or `None` when those three fields are not what lucisv writes.
fn prefix(content: &str, line_length: &str, indent: &str) -> Option<(u64, usize, usize)> {
Some((u64::from_str_radix(content, 16).ok()?, line_length.parse().ok()?, indent.parse().ok()?))
}
/// Parses the store. `None` means "this file is not something lucisv wrote"
/// — one malformed line discards the whole cache, because partial trust in
/// a file already caught lying is not worth the branch. Entries from
/// another lucisv version are dropped individually; that is staleness, not
/// corruption.
/// another lucisv version, and lines written in an older field layout, are
/// dropped individually; that is staleness, not corruption.
fn parse(text: &str) -> Option<HashMap<String, Entry>> {
let mut entries = HashMap::new();
for line in text.lines() {
let mut fields = line.splitn(5, '\t');
let content = u64::from_str_radix(fields.next()?, 16).ok()?;
let line_length = fields.next()?.parse().ok()?;
let indent = fields.next()?.parse().ok()?;
let version = fields.next()?;
let path = fields.next()?;
if path.is_empty() {
return None;
}
if version == VERSION {
entries.insert(path.to_string(), Entry { content, line_length, indent });
let fields: Vec<&str> = line.splitn(6, '\t').collect();
match fields[..] {
[content, line_length, indent, uvm, version, path] => {
let (content, line_length, indent) = prefix(content, line_length, indent)?;
let uvm_utils_indent = uvm.parse().ok()?;
if path.is_empty() {
return None;
}
if version == VERSION {
entries.insert(
path.to_string(),
Entry { content, line_length, indent, uvm_utils_indent },
);
}
}
// A store written before `uvm-utils-indent` joined the key: a
// well-formed line of that older shape says nothing about the
// option, so it is dropped individually, exactly like another
// version's entry. (The version field alone already makes such
// a store miss; the codec stays self-describing anyway.)
// Anything else on five fields is corruption and discards the
// file like any other malformed line.
[content, line_length, indent, _version, path] => {
prefix(content, line_length, indent)?;
if path.is_empty() {
return None;
}
}
_ => return None,
}
}
Some(entries)
@@ -201,7 +228,7 @@ mod tests {
}
fn entry(content: u64) -> Entry {
Entry { content, line_length: 100, indent: 2 }
Entry { content, line_length: 100, indent: 2, uvm_utils_indent: false }
}
#[test]
@@ -234,9 +261,53 @@ mod tests {
assert!(!reloaded.is_clean(&file, entry(0xbeef)));
assert!(!reloaded.is_clean(&file, Entry { line_length: 80, ..entry(0xdead) }));
assert!(!reloaded.is_clean(&file, Entry { indent: 4, ..entry(0xdead) }));
assert!(!reloaded.is_clean(&file, Entry { uvm_utils_indent: true, ..entry(0xdead) }));
assert!(!reloaded.is_clean(Path::new("other.sv"), entry(0xdead)));
}
#[test]
fn uvm_utils_indent_alone_is_a_different_entry() {
let on = Entry { uvm_utils_indent: true, ..entry(0xdead) };
assert_ne!(entry(0xdead), on, "the option is part of equality");
// …and it survives the round trip through the store, on its own.
let dir = TempDir::new("uvm");
let file = dir.file("a.sv");
let mut cache = Cache::load(&dir.path);
cache.record(&file, on);
cache.store();
assert!(dir.cache_text().contains("\t100\t2\ttrue\t"), "{}", dir.cache_text());
let reloaded = Cache::load(&dir.path);
assert!(reloaded.is_clean(&file, on));
assert!(!reloaded.is_clean(&file, entry(0xdead)), "the option must invalidate the entry");
}
#[test]
fn a_line_without_the_option_is_dropped_but_not_fatal() {
// The five-field shape lucisv wrote before `uvm-utils-indent` joined
// the key: stale, like another version's entry, never corruption.
let dir = TempDir::new("oldshape");
let old = dir.file("old.sv");
let mine = dir.file("mine.sv");
let text = format!(
"{:016x}\t100\t2\t{VERSION}\t{}\n{:016x}\t100\t2\tfalse\t{VERSION}\t{}\n",
1,
old.to_string_lossy(),
2,
mine.to_string_lossy()
);
std::fs::write(dir.path.join(FILE), text).unwrap();
let cache = Cache::load(&dir.path);
assert!(!cache.is_clean(&old, entry(1)), "a line without the option must not be trusted");
assert!(cache.is_clean(&mine, entry(2)), "and it does not discard the rest of the file");
// And it is not carried forward.
cache.store();
assert!(!dir.cache_text().contains("old.sv"), "{}", dir.cache_text());
}
#[test]
fn the_file_is_sorted_and_carries_the_version() {
let dir = TempDir::new("format");
@@ -254,7 +325,7 @@ mod tests {
assert!(lines[1].ends_with("b.sv"), "sorted by path: {text}");
assert_eq!(
lines[0],
format!("{:016x}\t100\t2\t{VERSION}\t{}", 1, a.to_string_lossy()),
format!("{:016x}\t100\t2\tfalse\t{VERSION}\t{}", 1, a.to_string_lossy()),
"{text}"
);
}
@@ -277,12 +348,15 @@ mod tests {
"0000000000000001\twide\t2\t0.2.0\t/a.sv\n",
"0000000000000001\t100\t2\t0.2.0\n",
"0000000000000001\t100\t2\t0.2.0\t\n",
"0000000000000001\t100\t2\tyes\t0.2.0\t/a.sv\n",
"0000000000000001\t100\t2\tfalse\t0.2.0\t\n",
"\0\0\0\n",
] {
let dir = TempDir::new("corrupt");
let file = dir.file("a.sv");
// A good line first: a bad one anywhere discards all of them.
let good = format!("{:016x}\t100\t2\t{VERSION}\t{}\n", 1, file.to_string_lossy());
let good =
format!("{:016x}\t100\t2\tfalse\t{VERSION}\t{}\n", 1, file.to_string_lossy());
std::fs::write(dir.path.join(FILE), format!("{good}{corrupt}")).unwrap();
let cache = Cache::load(&dir.path);
assert!(!cache.is_clean(&file, entry(1)), "should have been discarded: {corrupt:?}");
@@ -295,7 +369,8 @@ mod tests {
let old = dir.file("old.sv");
let mine = dir.file("mine.sv");
let text = format!(
"{:016x}\t100\t2\t0.0.0-not-this-one\t{}\n{:016x}\t100\t2\t{VERSION}\t{}\n",
"{:016x}\t100\t2\tfalse\t0.0.0-not-this-one\t{}\n\
{:016x}\t100\t2\tfalse\t{VERSION}\t{}\n",
1,
old.to_string_lossy(),
2,
+1 -1
View File
@@ -20,7 +20,7 @@ L3 grammar forms, L6 real `randsequence` nodes, L9 ANSI conversion and L10
optional UVM indentation are delivered, as annotated below. DPI-export name
binding (handshake 31), generate-block hierarchy and cross-file macro expansion
remain gaps. Refactor handshakes 32–33 and the newly reproduced UVM-option
cache omission (34) are detailed in the current repository analysis. These
cache omission (34, fixed in 0.50.0 by TODO §59) are detailed in the current repository analysis. These
status updates do not replace the original survey with a new corpus sweep.
What lucisv 0.21.0 does not yet handle, ranked by severity, from two
+327 -21
View File
@@ -23,12 +23,17 @@ what they would have been anyway (modulo one extra summary segment).
assumption parallel-files already relies on. If that ever stops being
true (a formatter that reads the file's *name*, or another file), this
cache silently goes wrong and the assumption must be revisited here.
- **`line-length` and `indent` are the whole config surface.** They are
the only two things `lucisv_core::config::FileConfig` can put into
`vlog_formatter::Config`. The key stores the *resolved values*, not the
config file's path or mtime — so moving a `lucisv.toml` around, or
switching from a file to an equivalent `--line-length` flag, correctly
does **not** invalidate anything, while a real value change does.
- **The key covers every `FileConfig` field that reaches the formatter.**
Today that is `line-length`, `indent` and `[format] uvm-utils-indent` —
everything `lucisv_core::config::FileConfig` can put into
`vlog_formatter::Config` (see `lucisv/src/args.rs::config_with`). Any
future setting that changes formatted output must join `Entry` and the
store line in the same change; a setting left out is a stale clean
verdict, which is exactly the bug TODO §59 fixed. The key stores the
*resolved values*, not the config file's path or mtime — so moving a
`lucisv.toml` around, or switching from a file to an equivalent
`--line-length` flag, correctly does **not** invalidate anything, while
a real value change does.
`exclude` is not part of the key: it changes *which* files are visited,
never how one is formatted.
- **The version string is the workspace version** (`env!("CARGO_PKG_VERSION")`
@@ -56,8 +61,8 @@ what they would have been anyway (modulo one extra summary segment).
### The key
Per file: **(content hash, line-length, indent, lucisv version)**, keyed on
the file path.
Per file: **(content hash, line-length, indent, uvm-utils-indent, lucisv
version)**, keyed on the file path.
- **Content hash: hand-rolled FNV-1a, 64-bit**, over the file's bytes
(`cache::content_hash`). Two reasons it is not
@@ -111,7 +116,7 @@ the hash of **the bytes that were written** goes in.
| Situation | Cache read | Cache write | Reported as |
|---|---|---|---|
| Hit (hash + line-length + indent + version all match) | skip all work | entry kept | `left unchanged`, plus `N files from cache` |
| Hit (hash + line-length + indent + uvm-utils-indent + version all match) | skip all work | entry kept | `left unchanged`, plus `N files from cache` |
| Miss, file is already formatted | — | record `hash(src)` | `left unchanged` |
| Miss, file rewritten in place (write succeeded) | — | record `hash(output)` | `reformatted` |
| Miss, `--check`/`--diff` says it would reformat | — | **nothing** | `would be reformatted`, exit 1 |
@@ -140,7 +145,7 @@ One text file, `<cache-dir>/cache`, one line per path, tab-separated,
hand-rolled in the style of the corpus TSV:
```
<content-hash, 16 hex digits>\t<line-length>\t<indent>\t<version>\t<path>
<content-hash, 16 hex digits>\t<line-length>\t<indent>\t<uvm-utils-indent, `true`/`false`>\t<version>\t<path>
```
The path is last because it is the only field that can contain
@@ -153,7 +158,7 @@ third-party dependency between them (`rayon`, in `lucisv`). `serde` exists
in the workspace only because `lucisv_server` needs it for LSP wire
messages — `lucisv`/`lucisv_core` do not depend on it, and taking it here
would put a proc-macro build step into the CLI's dependency graph to
encode five fields. Five fields on a line need no schema; CLAUDE.md's
encode six fields. Six fields on a line need no schema; CLAUDE.md's
"standard library first" says so.
Loading, corruption and staleness:
@@ -168,6 +173,15 @@ Loading, corruption and staleness:
silently (that is not corruption, just another lucisv's entry). It is not
carried forward on write, so alternating between two lucisv versions
rebuilds the cache each time.
- **A well-formed line in an older field layout is dropped the same way.**
A five-field line is the shape lucisv wrote before `uvm-utils-indent`
joined the key: it says nothing about the option, so it is skipped
individually rather than trusted or treated as corruption. (The version
field alone already makes a 0.49.0 store miss at 0.50.0; the tolerance
is what keeps the codec self-describing when the two ever come apart —
a hand-written store, a downgrade.) A five-field line that is *not*
well formed in that older shape is corruption like any other, and
discards the file.
- **Writing is atomic**: the new text goes to `<cache-dir>/cache.<pid>.tmp`
and is `rename`d over `cache`. A reader therefore sees the old file or
the new one, never a half-written one.
@@ -256,12 +270,19 @@ the only writer of an entry is the code path that just observed
- **Consumes `docs/features/config-discovery/README.md`'s promise** that
the cache key "must include the resolved per-file settings … not just
file content + lucisv version". Done, with the *values*
(`Config::max_width`, `Config::indent_width`) rather than the config
file's identity, so two trees governed by different `lucisv.toml` files
that happen to say the same thing share entries correctly.
- **Consumes `vlog_formatter::Config`** read-only, for its two fields.
Nothing in `vlog_parser` / `vlog_formatter` / `vlog_linter` was
touched.
(`Config::max_width`, `Config::indent_width`,
`Config::uvm_utils_indent`) rather than the config file's identity, so
two trees governed by different `lucisv.toml` files that happen to say
the same thing share entries correctly.
- **Consumes `vlog_formatter::Config`** read-only, for every field
`args.rs::config_with` can set from a `lucisv.toml`. **The contract this
crate owes back (TODO §59, 2026-09-07):** a new formatter setting that
changes output is a change to `cache::Entry`, to
`lucisv/src/main.rs::entry_for` and to the store line, in the same
commit — otherwise a warm cache serves the old setting's verdict.
`Config::uvm_utils_indent` was added in 0.49.0 without that and is the
reason this line exists. Nothing in `vlog_parser` / `vlog_formatter` /
`vlog_linter` was touched.
- **Where the module lives: `lucisv_core::cache`,** next to `config` and
`walk`. `lucisv_core` is by its own doc comment "the parts of lucisv that
decide *which* files are processed and *with what settings*", and "this
@@ -269,8 +290,9 @@ the only writer of an entry is the code path that just observed
It also keeps the door open for `lucisv_server`: a language server that
wanted to avoid re-formatting an unedited buffer on save would want the
same predicate, and would otherwise have to duplicate the file format.
Nothing in the module is CLI-specific — it takes paths, `u64`s and two
`usize`s and has no opinion about arguments or reporting.
Nothing in the module is CLI-specific — it takes paths and the bare
scalars of the key (a `u64`, two `usize`s and a `bool`) and has no
opinion about arguments or reporting.
- **Promises to whoever changes the formatter's output** (alignment
inference, `--lines`, any style change): **bump the workspace version**,
or every user with a warm cache keeps their old formatting on files
@@ -289,7 +311,10 @@ the only writer of an entry is the code path that just observed
(`load` / `disabled` / `is_clean` / `record` / `store`).
- [x] Hand-rolled tab-separated store, sorted by path, atomic
temp+rename write, self-ignoring `.gitignore` in the cache dir.
- [x] Corrupt / unreadable / wrong-version entries ignored, never fatal.
- [x] Corrupt / unreadable / wrong-version entries ignored, never fatal;
so is a line in the pre-`uvm-utils-indent` five-field shape.
- [x] `[format] uvm-utils-indent` in `Entry`, in `entry_for` and as the
store's fourth field (TODO §59).
- [x] `--no-cache` and `--cache-dir <PATH>` in `args.rs` and `--help`,
accepted (and inert) for `lucisv check`.
- [x] Lookup at the top of `process_file`; entries collected through the
@@ -303,7 +328,8 @@ the only writer of an entry is the code path that just observed
content change invalidates, indent change invalidates, wrong
version ignored, `--no-cache`, corrupt file tolerated, `--check`
exit codes, `--threads` determinism with a warm cache, default
cache dir is cwd-relative and self-ignoring).
cache dir is cwd-relative and self-ignoring, `uvm-utils-indent`
invalidates in both directions, an older store is rebuilt).
- [x] Root `.gitignore` entry, `README.md` Cache section, `TODO.md` §3
box.
- [x] `cargo fmt`, `cargo clippy --all-targets`, `cargo test`.
@@ -438,6 +464,75 @@ their work lands.
- No `Cargo.toml` / `Cargo.lock` change: no new dependency, and
`lucisv_core` still has an empty `[dependencies]`.
### 2026-09-07 — dev agent (TODO §59: `uvm-utils-indent` joins the key)
The owner's audit (topo §2.9 row 34, and the "Confirmed cache omission"
paragraph of `docs/repository-analysis.md`) found the key stale against
0.49.0's `[format] uvm-utils-indent`. `args.rs::config_with` sets
`Config::uvm_utils_indent`, the formatter indents `` `uvm_field_* ``
under it, but `Entry` and `entry_for` still named only content,
line-length and indent — so a clean `--check` cached with the option off
kept exiting 0 after the option was turned on, while `--no-cache
--check` exited 1. Reproduced first, on the fixture from the audit.
**The fix, four lines of real change.** `Entry` gains
`uvm_utils_indent: bool` (equality is derived, so the key follows for
free); `lucisv/src/main.rs::entry_for` fills it from the same `Config`
the formatter is handed; `render` writes it as the store's fourth field,
`true`/`false`, after `indent` and before the version.
**Why `true`/`false` and not `0`/`1`.** The parser's style is one
`.parse()` per field; `bool: FromStr` accepts exactly `true`/`false`, so
the round trip is `{}` out and `.parse().ok()?` back, with no mapping
either way and no new failure mode. A numeric encoding would have needed
a hand-written `"0" => false` match for no gain.
**The five-field tolerance.** `parse` now matches on the field slice:
six fields is the current shape; five fields *that are well formed in
the old shape* (hex content, numeric line-length and indent, non-empty
path) is a store written before the option joined the key, and is
dropped individually exactly like another version's entry; anything else
still discards the whole file, because partial trust in a file caught
lying is still not worth the branch. The precision matters — a blanket
"wrong field count → skip the line" would have quietly forgiven
`not-hex\t100\t2\t0.2.0\t/a.sv`, which the corruption tests require to be
fatal. The version field alone already makes a 0.49.0 store miss at
0.50.0, so this tolerance buys nothing today; it is there so the codec
stays self-describing when the two come apart (a hand-written store, a
downgrade).
**Tests.** `cache.rs`:
`uvm_utils_indent_alone_is_a_different_entry` (equality differs on the
option alone; the line round-trips carrying it),
`a_line_without_the_option_is_dropped_but_not_fatal` (an old-shape line
next to a current one: the old one is not trusted, the current one
survives, and the old one is not carried forward), plus the option's
column added to `entries_round_trip_through_the_file`,
`the_file_is_sorted_and_carries_the_version`,
`another_versions_entry_is_dropped_but_not_fatal` and two new
six-field corruption cases (a non-boolean option, an empty path).
`crates/lucisv/tests/cli.rs`:
`changing_uvm_utils_indent_invalidates_the_entry` — the audit's own
probe through the real binary, in both directions (clean under `false`,
cached, flip to `true` → exit 1; format under `true`, cached, flip back
to `false` → exit 1) — and
`a_store_written_before_the_option_joined_the_key_is_rebuilt`. The CLI
regression was checked against the bug: with `entry_for` pinned to
`false` it fails with "1 file from cache" at exit 0, which is exactly
the audit's step 2.
**Note for the lead.** `README.md`'s key sentence (line ~89, which still
lists four fields) and its `--no-cache` workaround paragraph (lines
~99-103, "In v0.49.0, the new `uvm-utils-indent` option is missing from
this key") are now stale, as is `docs/topo.md` row 34, and
`docs/repository-analysis.md`'s "Confirmed cache omission" paragraph
describes a fixed bug. Per the brief this lane did not touch those three
files; they are the lead's to strike at merge.
**Gates:** `cargo fmt` clean, `cargo clippy --all-targets` silent,
`cargo test -p lucisv_core` / `-p lucisv` / `--workspace` green, all
through `tools/guard.sh -m 8 -t 1800`.
## QA log
### 2026-08-19 — QA agent
@@ -595,8 +690,219 @@ apply, but the same spirit (attack the exact class of thing that could
silently corrupt trust) was applied here to the cache's own trust
boundary instead.
### 2026-09-07 — QA agent (TODO §59: `uvm-utils-indent` joins the key)
Read CLAUDE.md, TODO §59, this README's amended Handshakes and the
2026-09-07 dev entry above, then `git diff` for `cache.rs`, `main.rs`,
`cli.rs`. The workspace built clean on trunk this time (no concurrent
lane mid-landing), so all gates ran directly, no scratchpad rsync
needed.
**Gates.**
- `cargo fmt -- --check`: clean.
- `tools/guard.sh -m 8 -t 1800 -- cargo clippy --all-targets`: silent.
Re-ran scoped with `-p lucisv_core -p lucisv --all-targets --
-D warnings` after a touch to force recompilation (not just a cached
"Finished"): still silent.
- `tools/guard.sh -m 8 -t 1800 -- cargo test -p lucisv_core -p lucisv`:
**36** (`lucisv` unit) + **107** (`cli.rs`) + **102** (`lucisv_core`
unit) = 245, all green. (The dev's log counts pre-date this run; §59
added 2 `cache.rs` unit tests, 2 `cli.rs` tests, and touched shared
corruption-vector tests in place, so the totals climbed from the
2026-08-19 136 baseline.) Confirmed
`a_store_written_before_the_option_joined_the_key_is_rebuilt` and
`changing_uvm_utils_indent_invalidates_the_entry` both present and
passing.
- `cargo build --release -p lucisv`: clean, used for every probe below
as `target/release/lucisv`.
**Step 2 — the audit's probe, by hand, `--cache-dir` in a scratch dir**
(fixture: the UVM class from the brief, `[format]
uvm-utils-indent = false` first).
- Fixed binary: format under `false` → `--check` exits 0, `1 file from
cache`. Flip to `true` → `--check` exits **1**, `would reformat:
c.sv`. Correct.
- 0.49.0 baseline (`~/.cache/lucisv-baselines/lucisv-0.49.0`): same
sequence — format under `false`, cache hit, flip to `true` →
`--check` exits **0**, `1 file from cache` (the bug, reproduced
exactly), while `--check --no-cache` on the same binary correctly
says `would reformat` / exit 1 — confirming the option really does
change output and only the cache is stale.
- Other direction on the fixed binary: format under `true` (file is
reformatted, output differs from the `false` rendering — confirmed
`assert_ne!`-style by hand), cache hit under `true`, flip to `false`
→ exits **1**. Correct.
**Step 3 — attacking the key.**
- (a) Entry recorded under `true`, then run under `false` with the
same content: `--check` reports `would reformat`, no `from cache` —
miss, as required.
- (b) Option set via a `lucisv.toml` in a **parent** directory (file
under `sub/`, config in the parent, config discovery finds it):
formatted clean under `false`, cache hit; flipped the *parent*
config to `true` → `--check` exits 1, `would reformat`. The key
follows the resolved value regardless of which directory in the
chain set it, as the Assumptions section claims.
- (c) A store written by the real 0.49.0 binary (five fields) read by
the fixed binary: not an error, `1 file left unchanged` **without**
"from cache" (the old-shape line is dropped individually, not
trusted), and the store is six fields after this run. The next
`--check` is then `1 file from cache` in the new shape. Matches the
five-field-tolerance branch exactly.
- (d) A store written by the fixed binary (six fields) read by the
real 0.49.0 binary: read `crates/lucisv_core/src/cache.rs` at
`v0.49.0` (`git show v0.49.0:...`) — its parser is
`line.splitn(5, '\t')`. Against a six-field line this splits on only
the first 4 tabs, so 0.49.0's "version" slot actually receives the
*uvm* field's text (`"false"`/`"true"`) and its "path" slot receives
everything after that, `"<real-version>\t<real-path>"` (with the
join tab folded in raw). Since that captured "version" text is never
equal to 0.49.0's own `VERSION` constant, the `if version == VERSION`
check fails and the line is silently **not inserted** — the same
code path 0.49.0 already uses for "another version's entry," not an
error return. No `path.is_empty()` trip either (path is nonempty).
Verified empirically: 0.49.0 read the six-field store, did not
crash, reported plain `1 file left unchanged` (no "from cache" — a
real re-verify, not a false hit, and correct anyway since the file
is genuinely clean), and rewrote the store back to its own five-field
shape on exit. No false hit, no crash, confirmed both by code
reading and by running it.
- (e) Six-field line with `uvm` = `"1"`: `bool::from_str` only accepts
the literal strings `true`/`false`, so `.parse().ok()?` fails and
`parse()` returns `None` → whole store discarded. Verified: seeded a
store with one genuine clean entry plus this line, `--check` on the
genuine file no longer says "from cache" (it re-verified). The
`"yes"` case is already the unit test
`a_corrupt_file_is_ignored_wholesale`'s `"...\tyes\t0.2.0\t/a.sv\n"`
vector — read it, it exercises the same `.parse().ok()?` branch as
`"1"` does (both are non-`true`/`false` strings; no reason for one to
behave differently from the other, and this run confirms `"1"`
directly since the brief calls it out by name). Five-field line with
non-hex content (`"nothex\t100\t2\t0.49.0\tc.sv"`): `prefix()`'s
`u64::from_str_radix(content, 16)` fails first, `?` short-circuits
before the shape is even fully validated → `None` → discarded.
Verified by hand: seeded that single bad line, `--check` did not
trust it (no "from cache"), file re-verified clean on its own
merits.
- (f) Two files, one old-shape (five-field, `a.sv`) and one new-shape
(six-field, `b.sv`) line in the same store: `--check a.sv b.sv`
reports `2 files left unchanged, 1 file from cache` — exactly one
hit (`b.sv`), `a.sv` silently rebuilt, neither line poisoned the
other. Matches `a_line_without_the_option_is_dropped_but_not_fatal`.
Also checked, prompted by the TODO item's own wording ("a store line
with four fields"): a genuine four-field line (`hash\t100\t2\t0.49.0`,
no `uvm`/no path) matches neither the six- nor the five-field pattern
in `parse`'s `match`, falls to `_ => return None`, and **discards the
whole store** — including a separately-present, otherwise-good
six-field entry for another file. Verified: seeded a good entry for
`realfile.sv` plus a bogus four-field line, and the previously-good
entry was no longer served ("from cache" absent) on the next
`--check`. This is the fourth malformed-line shape (three, five,
seven+ fields all land here too, by the same `_` arm) and behaves like
every other corruption case — correct, and consistent with "guilty
until proven innocent" for a change that *could* have silently
widened forgiveness but provably didn't.
**Step 4 — path shapes that could confound the parser.** Read `parse`
and `splitn(6, '\t')`. The path field is always the **last** slot
(index 5) of an at-most-6-way split, so no matter what the path
contains, it receives everything left after the fifth tab is
consumed — it cannot be mistaken for field 4 (`uvm`) and cannot cause
a `true`/`false` field to be mis-identified as a path or vice versa:
- **Path literally `"true"`**: line
`42b10c60d1dbc11a\t100\t2\tfalse\t0.49.0\ttrue` parses to
`uvm_utils_indent = false`, `path = "true"` — positionally
unambiguous. Verified with a real file named `true` in a scratch
dir: formats, caches, hits on the next `--check`.
- **Path containing an embedded tab**: `key()` (used both to look up
and to record) rejects any path containing `\t` or `\n` outright, so
**lucisv itself can never write such a line** — this class is only
reachable via a hand-forged/corrupted store. Reasoned from
`splitn(6, '\t')`: a forged line
`deadbeefdeadbeef\t100\t2\ttrue\t0.49.0\ta\tb.sv` (6 tabs, one more
than the 5 the split consumes) parses with `path = "a\tb.sv"` intact
— the sixth-and-final split field folds the extra tab in, so it
round-trips as one field rather than desyncing the columns. Since
`key()` can never *produce* a tab-containing lookup key for a real
file, this forged entry can never be hit by any real run; verified
by seeding exactly this line plus a real file, confirming no crash
and no false hit, and that the forged line (path does not exist on
disk) is silently pruned by `render()`'s existence check on the next
write.
**Step 5 — README cross-check.** Handshakes' "Consumes
`vlog_formatter::Config`" paragraph states the obligation on the next
formatter setting explicitly, naming `Entry`, `entry_for` and "the
store line" together, in the same commit — matches CLAUDE.md's rule 4
posture (widen the safety-adjacent surface only with the accompanying
proof). The Storage section's line grammar
(`<hash>\t<line-length>\t<indent>\t<uvm-utils-indent>\t<version>\t<path>`)
matches `render()`'s `writeln!` argument order exactly
(content, line_length, indent, uvm_utils_indent, VERSION, path).
**Step 6 — size.** `cache.rs`: 191 lines before `mod tests` (118
non-blank/non-comment) — nowhere near the 300–600 target.
`lucisv/src/main.rs`: 568 lines before `mod tests` — the `entry_for`
change added 4 lines and did not push it toward a threshold. No file
touched by this diff is newly over any CLAUDE.md size line.
**One non-blocking observation for the lead.** Step 3(c)/(d) used
today's actual pairing — the release-tagged `lucisv-0.49.0` baseline
against this uncommitted fix's local build, which *also* self-reports
`CARGO_PKG_VERSION = "0.49.0"` because the workspace version has not
been bumped for this change. That means in exactly the scenario just
tested, the **shape-based** (five- vs six-field) tolerance is what
kept the cross-binary read safe — the *version* field could not have,
since both binaries carry the identical string. This slightly
sharpens (not contradicts, once you know which pairing was meant) the
dev's work-log claim that the five-field tolerance "buys nothing
today" — that claim is true only *after* whatever release actually
ships this fix bumps `Cargo.toml`'s version per the existing
release-commit pattern (`git log` shows each `Release X.Y.Z` commit
does this), which is a lead/release-time step, not something this
diff needed to do itself. Recorded so the version bump isn't skipped
at merge — no code change needed here, the fallback already covers
the pre-bump window correctly, as demonstrated above.
**Verdict: PASS.** No corruption, no crash, no false hit, no
mis-parse in any attacked case; both directions of the audit's own
probe reproduce the bug on 0.49.0 and are fixed on the new binary;
the five-field tolerance is precise (old-shape-well-formed lines drop
individually, anything else on five fields is fatal like any other
malformed line, confirmed with `"nothex"` content); a four-field line
(the TODO item's own wording) discards the whole store as corruption,
confirmed by direct repro; no file crossed a CLAUDE.md size threshold.
Ticking the §59 QA line in `TODO.md`.
## Review
**2026-09-07 (lead, §59).** Accepted. Read the diff (`Entry`, the store
line, `parse`'s two arms, `entry_for`, the six cache tests, the two CLI
regressions) and both logs.
- The key now covers every `FileConfig` field that reaches the formatter,
and the Handshakes say so as an obligation on whoever adds the next one.
That is the actual fix; the codec change is its consequence.
- The five-field arm is deliberately *conditional* (well-formed old shape
only), so the existing "one malformed line discards the store" posture
is unchanged — the corruption tests still bite on a non-hex content,
a `yes` option, an empty path. Right call; a blanket field-count skip
would have been a forgiveness with no attack test behind it.
- QA's cross-version check is the one that matters: a 0.49.0 store is
dropped individually and rebuilt; a 0.50.0 store read by 0.49.0 lands
the option text in 0.49.0's version slot and is skipped as another
version's entry. Neither direction can produce a false hit.
- QA's note on the version bump is taken: the release chain bumps
`CARGO_PKG_VERSION` to 0.50.0 before the tag, so the version field
invalidates a 0.49.0 store on its own and the shape arm is belt and
braces.
- Docs applied at merge: README.md's key sentence and the workaround
paragraph replaced by a one-line history note; topo row 34 struck;
repository-analysis and coverage_gaps annotated as fixed.
**2026-08-19 — lead. Verdict: accepted and committed. Warm runs are
2-4× faster in parallel and up to 7.7× single-threaded, bought without
touching a single correctness property.**
+6 -4
View File
@@ -108,7 +108,7 @@ unchanged.
## Remaining limits and open work
**Confirmed cache omission (topology handshake 34).** The CLI applies the new
**Cache omission (topology handshake 34, fixed in 0.50.0).** The CLI applies the new
`Config::uvm_utils_indent` field, but `lucisv/src/main.rs::entry_for` and
`lucisv_core::cache::Entry` omit it from cache equality and serialization.
A private-cache probe using the archived CLI and this class reproduced:
@@ -125,9 +125,11 @@ endclass
2. Change only the option to `true`, `--check`: exit **0**, one cache hit.
3. Same config, `--no-cache --check`: exit **1**, would reformat.
Use `--no-cache` or remove the format cache after changing this option. A fix
needs the setting in the cache key and a regression for both toggle directions.
This documentation refresh records the issue without changing Rust behavior.
**Fixed 2026-09-07 (TODO §59, ships in 0.50.0):** the option is in the key
and in the store line, a 0.49.0 store is rebuilt rather than trusted, and the
probe above is a CLI regression test in both toggle directions
(`changing_uvm_utils_indent_invalidates_the_entry`). The paragraph is kept as
the record of the finding.
**Refactor limits:** inline-module requires a separate-file source module and
simple named connections. It refuses wildcards, positional/expression or
+1 -1
View File
@@ -690,7 +690,7 @@ update the filing README(s) and this file.
| 31 | **DPI-export name binding remains open.** Package re-export resolution closed §2.9-16, but the name in a DPI export is still not a semantic reference. Keep this separate from the delivered package-member traversal. | dpi-export request (b); package-reexports | vlog_semantic |
| 32 | **The refactoring verifier does not catch a same-file relocation of a never-dropped piece written as two well-formed edits** (delete here, insert there): `verify_move` computes `after` by applying the edits, so `positions_match`'s reconstruction cannot diverge from it and equation 3 of the ledger is unreachable through any real caller. No planner produces the shape today. Wanted: an independent `after` (the client's applied text, or a second reconstruction) and a test that isolates equation 3. Found by extract-module's QA re-attack. | extract-inline-module (QA) | vlog_refactor |
| 33 | **`module_sources`' fan-out has no rung for a file that reaches an instance through an intermediate module it does not itself instantiate** (a bench naming `wrap.u_S.x` where `wrap` instantiates `S`): inline-module's hierarchical-reference refusal sees only the handed files, so such a reference is missed. Wanted: a transitive-instantiators rung (§49's hierarchical surface knows the path) in `module_sources` for the refactorings that must see every hierarchical use. Found by §53.2's QA. | extract-inline-module (QA) | lucisv_server / vlog_refactor |
| 34 | **The format cache omits `Config::uvm_utils_indent`.** CLI `args.rs::config_with` applies the key, but `main.rs::entry_for` and core `cache::Entry` serialize/compare only content, line length and indent (plus the store version). On one UVM class: cache a clean verdict with the option false, change only the option to true, then cached `--check` exits 0 while `--no-cache --check` exits 1. Wanted: key/equality/codec coverage for the option and a regression for both toggle directions. Until fixed, use `--no-cache` or delete the format cache after toggling. See repository-analysis.md for the bounded reproduction. | repository audit, 2026-09-07 | lucisv_core / lucisv |
| ~~34~~ | ~~**The format cache omits `Config::uvm_utils_indent`.** CLI `args.rs::config_with` applies the key, but `main.rs::entry_for` and core `cache::Entry` serialize/compare only content, line length and indent (plus the store version). On one UVM class: cache a clean verdict with the option false, change only the option to true, then cached `--check` exits 0 while `--no-cache --check` exits 1. Wanted: key/equality/codec coverage for the option and a regression for both toggle directions. Until fixed, use `--no-cache` or delete the format cache after toggling. See repository-analysis.md for the bounded reproduction.~~ — **fixed 2026-09-07 (TODO §59, 0.50.0):** `Entry` carries `uvm_utils_indent`, `entry_for` fills it, the store line has it as a fourth field; a well-formed five-field (0.49.0) line is dropped individually like another version's entry; the audit's probe is `changing_uvm_utils_indent_invalidates_the_entry` in `lucisv/tests/cli.rs`, both directions. | repository audit, 2026-09-07 | lucisv_core / lucisv |
---