Every tracked file that can carry a comment (880 of them) now opens with "Author: Guoliang Chen, a Senior Digital Design Engineer" and closes with "Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com", in the file's own comment syntax. No behaviour change: the diff outside the version bump and changelogs is comment lines only. - tools/stamp_author.py: writes the lines; idempotent, `--check` lists what is missing. Headers go under a shebang and under Markdown front matter. - Left alone: test fixtures, cases and snapshots (byte-exact inputs), JSON and JSONL, logs, images, lockfiles, docs/site/dist (regenerated) and the LICENSE files (already carry the copyright line). - tools/linux_check.sh: --help reads its header from line 3, now that the author line sits under the shebang. - tools/gates.sh green on this tree: 5 545 tests, corpus 814/6 as before. Co-Authored-By: Claude Mythos 5.2 <[email protected]>
index-persistence
Goal
Indexing a large workarea takes perceptible seconds, and until this round
every one of those seconds was paid again from zero on every reopen: the
workspace index lived in memory and nowhere else, so an editor that crashed —
or was simply closed — halfway through its first scan started the same scan
over. This round writes what a scan learned to disk as it learns it: one
record per file, holding exactly the FileFacts that file contributes to the
index, keyed by the FNV-1a hash of the bytes those facts were read from. A
reopened workspace then indexes from records instead of from parses, and a
scan that was interrupted resumes rather than restarts, because a record is
written through the moment its file is parsed. The store lives in the folder
the editor set aside for exactly this (context.storageUri, passed as
initializationOptions.storagePath — the round's one extension.js change),
falls back to this platform's cache directory for every other client, and is
off entirely under lucisv.index.persist: false.
The measured shape, release build, the checked-in 860-file corpus: a whole
rescan goes 322 ms → 179 ms — the parse was a little more than half of it —
and the bar says 860 files indexed, 860 from cache so the user can see it.
Assumptions
- What persists is the per-file record, never the merged index.
FileFactsis whatIndexBuilder::add_fileproduces before anyFileIdexists — the path, the`definetable, the file-scope declarations, the members, the instantiation edges, the inheritance edges. The merged tables and the ids are re-derived by the samefinish/mergeevery build has always ended in, which is what makes the round's central claim structural rather than hopeful:add_facts(decode(encode(facts)))andadd_file(path, src)put the same value in the builder, so a cached index and a parsed index are the same index, byte for byte, ids and disambiguation order included. Pinned directly (an_index_built_from_records_is_the_index_the_parse_would_have_given) and over the whole corpus throughWorkspaceIndex::fingerprint(the_cached_index_is_the_index_a_fresh_scan_would_have_built_over_the_corpus). - Content is the whole key, and no timestamp is trusted — a deviation from
the brief, argued below in the work log. An entry is used for the bytes it
was made from and for nothing else. There is no (size, mtime) fast path: the
brief asked for one, and the honest reason not to have it is that it would
buy nothing here, because the file's text is read on every scan anyway (see
the next point), so the mtime check could only ever save one FNV pass over
bytes already in memory — 6.4 ms of a 179 ms warm scan, measured — in
exchange for making a filesystem timestamp part of the correctness argument.
Both directions are pinned in
the_key_is_the_content_and_only_the_content: a file rewritten with the same bytes (new mtime) still hits, and a file rewritten with different bytes of the same length misses. - The cache skips the parse. It does not skip the read, and that is the
honest ceiling on what it can buy.
Workspace::collect_sourcesreads every in-scope file because two things besides the index are built from that text —Candidates(the completion word table, re-lexed per file) andIncludeGraph(each file's`includeedges) — and neither is cached this round. So a warm scan still costs the read, the lex for words, and the include scan; what it stops costing isparse+analyze, which the measurements below put at a little over half of a rescan. Caching the other two is filed, not done: they are a second and third record format with their own invalidation, and one is worth shipping before three are guessed at. - A hit is verified before it is used, and every failure is silent and
costs work rather than answers. A record whose hash does not match is a
miss; a record whose fields do not match the checksum they were written with
is dropped; a record whose fields do not decode is a miss; a store whose
header is not this exact build's is dropped whole; a directory that cannot
be written in is a cache that writes nothing. Nothing in this round can make
the server answer differently — only faster or slower. That is the same
posture
lucisv_core::cache(the formatter's content-hash store) took, and the same reasoning: a cache that could change an answer is a bug waiting for a user. - The threat model is the same-user disk, and a deliberately forged store is
outside it — the same posture
lucisv_core::cachetakes, with one difference worth stating rather than hiding. QA's finding (2026-08-27) is exactly right about the consequence: that cache's entry is a skip-or-not bit, so poisoning one only wrongly skips a reformat, while this one's fields are served straight into the workspace index, so a poisoned one would serve fabricated definitions, hovers and rename targets for a real file. The ruling is still that this is accepted: anything that can write the cache directory can write the source files the index describes (and the binary that reads them), so the forgery buys an attacker nothing they did not already have, and the only thing that would actually detect it — a keyed MAC — would have to keep its key on the same disk as the data it authenticates, which is theatre rather than defence. So: no defence against a hand-edited store is claimed, and none is implemented. What is implemented, because it is cheap and because the promise should be true against everything that is not a person with a hex editor, is the per-record checksum: every accidental way a written record can change — bit rot, a torn interleaved append, an editor rewriting line endings, a partial write — now drops that record instead of serving it (a_record_whose_facts_do_not_match_their_checksum_is_dropped, and through the whole workspace by fingerprint ina_poisoned_cache_record_is_dropped_and_the_index_is_a_fresh_scans). The accepted residue — a forger who recomputes the checksum is still served — is pinned in the same test, so nobody later mistakes the checksum for a security boundary. - The store is written through per file, and compacted once per whole
scan. One
writeper parsed file, appended, so a process killed mid-scan loses at most the file in flight; then one atomic rewrite (tempfile + rename) when the scan ends, which is the only moment the live set of entries is known. Growth is therefore bounded by the workspace and not by the session: a path saved a thousand times is a thousand appended lines during the session and one line after the next whole rescan, and a record whose file no longer exists is dropped at that rewrite, exactly aslucisv_core::cache::storedrops its own. - …and the rewrite is skipped when it would reproduce the file byte for
byte (2026-09-08, take 5 §P4b (a)).
renderwrites this build's header and then one line per path in path order, so a store this build compacted and nothing has appended to since is already what the next compaction would write over it. Four conditions, all of them properties of whatIndexCache::openread: the header was ours, every line was a record this build could use (none dropped), no path was named twice, the paths arrived ascending — and the session appended nothing since, and no entry's file has gone (renderdrops those). Any one of them failing rewrites exactly as before. This weakens no promise in this README: growth is still one line per path, because a store that grew has appends and therefore compacts; a record whose file is gone is still pruned, because a gone file fails the sweep; and crash safety is untouched, since a session that appended nothing left the file exactly as it found it and there is no half-written state for a rewrite to resolve. The one thing that is deliberately not claimed: an unreadable line inside an otherwise-good store is dropped at load as it always was, and a rewrite is what removes it from disk — that rewrite now happens on the first scan that also appends something rather than necessarily on the next one. It cost 182 ms of a 1.33 s warm start on opentitan, and every one of the six cases above is pinned (index_cache::tests::a_canonical_store_nothing_appended_to_is_not_rewrittenand its five siblings). - A record the store already holds is not appended again (2026-09-08, take
5 §P4b (a)). An open buffer is indexed from its own analysis on every scan
and its record is written through with it, so a warm session would append one
byte-identical duplicate line per open buffer — a line the next load
collapses, at the price of making the store non-canonical and so owing the
compaction above a full rewrite.
IndexCache::recordnow returns early when the entry it is about to write is already there under the same path, the same content hash and the same encoded facts, byte for byte. Anything that differs by a byte is appended exactly as before, which is what keeps "the store says what this session last saw" true. Nothing else changes: the entry map is the same either way, so a hit is the same hit, and a session that appended nothing left the store exactly as it found it. Without this the skip above never fires in a real editor session, measured: opentitan warm,records1 andcompact88 ms on every scan with a buffer open. - A save writes its record through too, on the incremental path, without a
second parse —
WorkspaceIndex::facts_forhands back the recordupdate_filejust made. An hour of saves is an hour of work the next session does not repeat. When the text came from an unsaved buffer the record is written under the buffer's content hash, which the file on disk will simply never match; that is a wasted line, never a wrong answer, and it is the reason the key may not include the file's metadata. - Records for files that leave the scope stay, and
remove_filedeletes nothing. A record is not a file: it can only ever answer for something already on the work list that the scope ladder built, so a session whose scope narrowed has an index that narrowed with it, records or no records (the_cache_never_puts_back_a_file_the_scan_no_longer_visits). Keeping them is what makes reopening a folder that was in scope last week free again, and they are dropped when the file itself is gone. - The cache never widens the scope, never changes which files are walked,
and is not consulted for anything but a file the scan already decided to
index. The scope ladder (
index-scope) and the size cap (indexing-ux) are untouched by this round:collect_sourcesruns first, exactly as before, and the cache is asked only about the list it produced. - One store may hold more than one workspace's files, and that is
harmless. Records are keyed by absolute path, so a store shared between
two workspaces — a rootless VS Code window falling back to the global
storage folder, or a
cachePathdeliberately pointed at one place — simply answers for the union. Nothing collides; the only cost is a store that holds entries a given session never asks about, and compaction drops the ones whose files are gone. - Two servers over one store cannot corrupt each other's answers, and since
2026-08-27 they do not lose each other's records at a cold start either.
Both may append, and the last compaction wins; every record is
independently keyed, independently checksummed and independently verified,
so the worst case is a session whose records another session's rewrite
dropped, which costs re-parsing those files. A store that does not exist yet
is claimed with
File::create_new, so exactly one session creates it and the rest append under the header it wrote — where before, every session that had not read a header truncated the file on its first write, and QA measured four racing cold starters keeping 25 of 100 records. Each record and each header goes out in a singlewrite_allon an append handle, so no line can land inside another. Still no locking, and none is worth taking a dependency for. - Truncating the store is left for exactly one case: a first line this build
cannot read. Those records were already dropped at load, and appending
under a header nobody can read would throw the new ones away at the next
load too. The residue, argued rather than hidden: two sessions cold-starting
on the same store from another version can still both truncate it, and the
first one's early records go with it. That window is one write wide, it
needs two servers first-scanning one workspace in the same instant after an
upgrade, what is lost is a cache nobody could read anyway, and the end of
either scan rewrites the store whole from memory. A zero-length store — a
session killed between its claim and its header — is neither ours nor
foreign, and is finished rather than replaced
(
an_empty_store_is_a_claim_to_finish_rather_than_a_store_to_replace), so a crash in that window costs nothing at all. lucisv.index.persist: falseis off in both directions and takes effect at once. Nothing is read and nothing is written; the setting landing mid-session drops the cache in hand rather than waiting for a rescan, so even a save's write-through stops immediately (turning_persistence_off_mid_session_stops_the_write_through_at_once). Neither cache setting asks for a rescan, because neither changes which files exist — a newcachePathtakes effect at the next one.- A store is per build, not per machine. The header carries the store
format, the record format (
vlog_semantic::FACTS_FORMAT) and lucisv's own version; a new release parses the same bytes into possibly different facts, so its first scan discards the old store and writes a fresh one. This is the same rule the formatter's cache applies for the same reason, one level up: there, another version's entry is dropped; here, the whole file is, because the framing itself may have moved. - Nothing is persisted for a session that has no stable identity. With no
cachePath, nostoragePathand no workspace root or filelist to key an OS cache directory entry on — a single file opened on its own — there is nothing to name a store after, and the index lives in memory exactly as it did before this round.
Handshakes
vlog_parser — one additive constructor, two derives
impl DefineTable {
/// A table from entries that are already known, in source order.
pub fn from_entries(entries: Vec<Define>) -> DefineTable;
}
DefineandDefineTablegainPartialEq/Eq.collect_definesis still the only thing that reads a table out of a file;from_entriesexists because a record restores one that was read a session ago, and the derives exist so the round-trip test can say "every field", rather than comparing renderings of the fields.
vlog_semantic — FileFacts becomes a value you can keep
pub struct FileFacts { /* fields private */ }
impl FileFacts {
pub fn of(path: PathBuf, src: &str) -> FileFacts; // the parse `add_file` does
pub fn encode(&self) -> Option<String>; // one line of fields
pub fn decode(line: &str) -> Option<FileFacts>; // strictly, or nothing
pub fn path(&self) -> &Path;
}
pub fn record_path(record: &str) -> Option<PathBuf>; // the cheap half of decode
pub const FACTS_FORMAT: u32; // bump on any change
impl IndexBuilder {
pub fn add_facts(&mut self, facts: FileFacts); // `add_file` without the parse
}
impl WorkspaceIndex {
pub fn facts_for(&self, path: &Path) -> Option<&FileFacts>;
}
add_fileis nowadd_facts(FileFacts::of(path, src))— one implementation, so the cached path cannot drift from the parsed one.- Since indexed navigation (2026-08-27), the private facts also carry compact
local/external reference records used to rebuild declaration-to-occurrence
postings. That encoding change bumped
FACTS_FORMATfrom 1 to 2; no cache migration is attempted or needed. 2 → 3 (2026-08-28,docs/features/port-detail-spans/README.md): each declaration gained itsdetail_span. 3 → 4 (2026-08-28,docs/features/hover-line-index/README.md): each declaration gained its two line numbers, which is what lets a server printfile:linefor an indexed declaration without reading that file. 4 → 5 (2026-08-29,docs/features/vscode-hierarchy-sidebar/README.md): one bump for three additions — each declaration'sdecl_span; a per-instanceInstanceOccurrencelist on every instantiation edge (the edge itself is still one per statement, so no census moved); and client positions, 0-based lines and UTF-16 columns, on every file-scope declaration and every instance occurrence, which is what lets the design-hierarchy snapshot answer with no file read at all. Members deliberately get none: theUandMgroups of a record are separate, so "units carry positions, members do not" costs a member no field, not even a presence flag — and members outnumber units by two orders of magnitude. Same rule each time, same consequence: the store is discarded whole on the first scan after the upgrade and rewritten — measured at about 175 ms over the 860-file corpus, once.a_store_from_any_previous_facts_format_is_dropped_not_misreadchecks every format this build is not, rather than the one literal number it was pinned at, so each bump inherits the test; its belt-and-braces half (a genuine previous-format record served past the header) is re-derived at each bump —as_a_format_4_recordat format 5. The store grew 68 KB (2.9 %) for the lines at format 4, and a further 212 KB (8.9 %) over the 860-file corpus for all of format 5 — of which the client positions are 1.7 %, measured separately on the same corpus and again on opentitan (1.9 % of a 24.7 MB store). record_pathis public separately because a store keyed by path reads that field out of every record it holds and decodes only the ones it is asked for.facts_foris what lets a save write its record through without parsing the file a second time.- The codec lives in
crates/vlog_semantic/src/facts.rs;FileFactsitself stays declared beside the index it belongs to, withpub(crate)fields.
lucisv_server::index_cache — the store
pub struct IndexCache;
impl IndexCache {
pub fn disabled() -> IndexCache;
pub fn open(dir: Option<PathBuf>) -> IndexCache;
pub fn facts_for(&self, path: &Path, text: &str) -> Option<FileFacts>;
pub fn record(&mut self, facts: &FileFacts, text: &str);
pub fn compact(&mut self);
}
pub fn cache_dir(settings: &ClientSettings, storage: Option<&Path>,
roots: &[PathBuf], filelist: Option<&Path>) -> Option<PathBuf>;
- The content hash is
lucisv_core::cache::content_hash— reused, not copied.lucisv_serveralready depends onlucisv_core(for the walk and for config discovery), so this adds no dependency edge at all, and the alternative — a second FNV-1a in another crate — would be a second thing to keep byte-identical with a store on disk.
lucisv_server::state
Workspacegains the cache and the storage path:Workspace::set_storage_path(Option<PathBuf>), called once before the first build. The cache is re-opened for every whole rescan, because the settings that decide where it lives arrive after startup. Amended 2026-09-08 (take 5 §P4b (b1)): the re-open is deferred to the first file of that rescan that asks the store something, rather than run before the work list's first file exists. The rule itself is unchanged — every whole rescan still resolves the directory afresh and reads the store from it, and both of the reasons for that (a mid-sessioncachePath/persistchange, and a second session's records this one has not seen) hold exactly as written. What changed is that a rescan whose work list is empty asks nothing and therefore reads nothing:Workspace::begin_scanrecords the directory asStoreOpen::DeferredandWorkspace::scan_step(and the save path's write-through) opens it. The deferral is a move, never a drop — a widen behind an empty rescan still finds the store open at its own first file, which is what keeps its cache hits (state::tests::a_scan_with_no_files_neither_reads_the_store_nor_rewrites_itpins both halves).finish_whole_scandoes not compact a store no scan of this session ever opened. A settings change that drops the cache (persist/cachePath) drops the deferral with it, sopersist: falsestill takes effect at once in both directions.IndexEvent::Cached { done, total, path }— the same three numbersParsingcarries, for a file that cost nothing. Every existing consumer of the enum had to grow one arm, which is the compiler making the distinction impossible to forget.rebuild_index_withasks the cache before parsing and writes every miss through;update_onewrites its own record through. Nothing else in the rebuild moved.
lucisv_server::settings
index_persist: bool(default true) fromlucisv.index.persist, andindex_cache_path: Option<String>fromlucisv.index.cachePath— nested underindexlike the other four, so both settings doors carry them with no new code. A wrong-typedpersistleaves the cache on: the direction that silently costs a user work is "off".
lucisv_server::server / main.rs
Server::new/startedtake the storage path;mainreads it out of the rawinitializeparams (initializationOptions.storagePath), the same wayrangesSupportis read and for a related reason — it is not a capability, it is whatever the client's extension put there. A blank value is unset.IndexWatchcounts cached files and logscached: <path>where it logsindexing: <path>;end_indexingnames the count:860 files indexed, 860 from cache, and with a size cap in play860 files indexed, 858 from cache, 2 skipped.
editors/vscode
extension.jsgains one thing —initializationOptions: { storagePath: (context.storageUri || context.globalStorageUri).fsPath }.storageUriis VS Code's own per-workspace folder for server state and is cleaned up when the workspace is forgotten; it isundefinedwhen no workspace is open, and the global one stands in there.package.jsondeclareslucisv.index.persistandlucisv.index.cachePath, both with the honest notes: what the key is, that a stale entry costs a re-parse and can never affect an answer, and that turning it off is exactly the pre-round behaviour.
The store format
One directory, one file, index-cache. A header line, then one line per
record; a .gitignore beside it saying *, the way
lucisv_core::cache marks its own directory.
lucisv-index-cache 2 1 0.10.2
<16 hex content hash> <path> D<n> … U<n> … M<n> … I<n> … S<n> … <16 hex facts checksum>
The header is magic, store format, vlog_semantic::FACTS_FORMAT,
lucisv's version. Any difference and the file is not read at all — and the
first write of the session replaces it rather than appending under a header
nobody can read. (Store format 2, since 2026-08-27: the per-record
checksum below. Format 1's stores are discarded wholesale on the first scan
after an upgrade, which costs one re-parse of the workspace and is what the
version field is for.)
A record is tab-separated fields on one line, in this order: the path, then
five length-prefixed lists — Defines, Units, Members, Instantiations,
Subclasses — and last the checksum. The letter is a marker and the number
after it is the count, so the stream is flat and a misaligned read is a
rejected record rather than a plausible one. Every string field is escaped
(\\, \t, \n, \r), which is what keeps a record on one line when a
macro body holds a tab; every number is decimal; every SymbolKind is its own
word, so a variant inserted into the enum cannot silently become another kind.
TextRanges are written as their two offsets.
The last field is the FNV-1a of everything between the content hash and it — the encoded facts, exactly as written. It is checked before a record is believed, so a record that changed after it was written is dropped rather than served: bit rot, a torn append two servers interleaved, an editor that "helpfully" rewrote the file. It is what makes "never a correctness input" true against every accident rather than only against staleness. It is a plain FNV-1a and not a keyed MAC, which is a threat-model decision and not an oversight — see Assumptions. The facts run to the last tab and no encoded field can contain a raw one, so the split is unambiguous; a record whose checksum field is missing, is not sixteen hex digits, or does not match is not a record.
An example, the whole record for a two-line file (tabs shown as →):
verilog
`define W 8
module m; sub u (); endmodule
2f0a8bd7c1d1f5a1→/w/m.sv→D→1→d→W→-→8→0→11→8→9→U→1→m→module→19→20→M→0→I→1→sub→m→19→20→12→41→22→25→S→0→R→1→e→sub→1→sub→22→25→9b1c04e2a7f3d081
— one define (d for `define, name W, - for "no parameter list",
body 8, span 0..11, name span 8..9), one file-scope unit (m, a module,
name span 19..20), no members, one instantiation edge (of sub, owned by
m whose name is at 19..20 and whose declaration runs 12..41, with the
site's own name span 22..25), no subclasses, and one external reference fact
(e, name sub, one resolution path also named sub, occurrence 22..25),
then the checksum. The example is written at FACTS_FORMAT 2 and is kept
for its shape, not its field count: since then every declaration also
carries its detail span (0 0 when there is none, format 3), its two line
numbers (format 4), its decl_span and — for a file-scope declaration only —
its two client ranges of four numbers each (format 5); and an instantiation
edge carries a length-prefixed list of its individual instances, each a name,
two byte ranges and two client ranges. So a real record today is considerably
wider per declaration than the one above. The framing — one line, tab-separated,
length-prefixed lists, checksum last — is what the example is for and is
unchanged. The record is what lies between the hash field and the
checksum; both hashes above are illustrative.
Any change to what a record holds or how it is written bumps
FACTS_FORMAT — that is the rule, written at the constant, and it is what
lets the reader be as strict as it is.
FACTS_FORMAT 13 (2026-09-02, semantic-lints-on) adds one group, W:
the file's identifier census — every distinct identifier-shaped word its token
stream contains, sorted (vlog_semantic::words::harvest), including the words
inside a macro invocation, a directive line and an attribute, which the lexer
hands over as single tokens. It is written like every other list, marker and
length first, so the framing is untouched. What it costs the store, measured
rather than guessed:
| tree | files | store at format 13 | census bytes | delta |
|---|---|---|---|---|
corpus/ |
860 | 3.67 MiB | 554 620 | +16.9 % |
opentitan hw/ |
3 947 | 41.4 MiB | 5 675 809 | +15.0 % |
What it buys is the other direction. Before it, a scan read a file's facts
from the store and then lexed the file anyway, purely to build the
completion word table (docs/perf/README.md: "of which 325 ms is re-lexing
them for the completion word table — the persistent store holds a file's facts
but not its words, and putting them there is a FACTS_FORMAT change"). Now
the words ride in with the record, and a parse harvests them off the tokens it
already has: −28 % and −31 % over a 667-file scan, in two alternated A/B
pairs on one machine with one line changed. The census is also the table the semantic lint rules ask
"does any other file mention this name", which is why the bump is a
correctness bump and not only a size one: a store written by an older build
would make half the workspace look as though it mentions nothing, and that is
a wrong answer (a signal reported unused because the file that reads it
happened to be cached), not a missing one. See
docs/features/semantic-lints-on/README.md.
FACTS_FORMAT 17 (2026-09-02, macro-word-census) adds one more group,
MW, written after W: the raw half of the same census
(vlog_semantic::words::harvest_raw) — the words a file writes only inside a
macro invocation, a directive line or an attribute, sorted. Two letters
because the single letter M is already the member group; the framing is
untouched, and Reader::tag compares a marker whole, so a two-letter tag is a
tag like any other. It is written beside W rather than carved out of it: the
lint rules' mention guard wants the union, and the rename wants the half
nothing can edit. What it costs, measured the same way:
| tree | records | store at format 17 | MW bytes |
delta |
|---|---|---|---|---|
corpus/ |
860 | 3 971 684 | 123 402 | +3.11 % |
| opentitan | 3 979 | 44 858 329 | 743 873 | +1.66 % |
The bump is a correctness bump for the same reason 13 was: a 0.33.0 store
holds no MW group at all, so a rename over a half-cached workspace would
answer "no file names it in a macro" for exactly the files the store had — and
silence about a macro argument the rename left behind is the failure the new
warning exists to prevent. See docs/features/macro-word-census/README.md.
Why one line per record
Because it is what makes the append log crash-safe with no framing of its own.
A record is written with one write_all (not writeln!, whose formatting
machinery may split a line across two writes — the one thing QA's O_APPEND
reasoning was right to doubt), and a record contains no raw newline, so a
process killed mid-write leaves a final line without its terminator — which
the reader yields and the parser rejects for the same reasons it rejects any
other malformed record, and which cannot carry the checksum of the facts it
was written with in any case. There is nothing to detect and nothing to
repair: the torn record costs one file's parse
(a_torn_final_record_costs_one_file_and_nothing_else).
The store is read as bytes, and each line is decoded as UTF-8 on its own.
That is not fussiness: a cut landing inside a multi-byte character used to
make read_to_string reject the whole buffer, which was indistinguishable
from "no header" and threw away every intact record in the file — QA measured
it at 2 of 534 cut points on a store with one non-ASCII macro body, and any
workspace with non-ASCII comments or string literals has them. Per line, a
torn multi-byte tail costs the torn record and nothing else, which is what
truncating_the_store_at_every_byte_offset_costs_only_the_torn_record now
asserts at every one of 583 cut points: past the last whole record, every
whole record survives.
This is the one place the round deliberately differs from
lucisv_core::cache's posture, which discards a whole store on one malformed
line ("partial trust in a file already caught lying"). Here a malformed last
line is the expected shape of a crash, not evidence of lying, and every record
is independently keyed and independently verified before use — so a bad line
drops that record and no other
(a_corrupt_record_is_dropped_and_the_rest_of_the_store_is_not). A bad
header still discards everything, because the header is the claim that the
rest of the file is ours at all.
The precedence ladder
| rung | where | when |
|---|---|---|
| 1 | lucisv.index.cachePath |
the user said where — absolute, or relative to the first workspace root (the rule lucisv.filelist already uses) |
| 2 | initializationOptions.storagePath |
the editor said where. VS Code's per-workspace storage folder |
| 3 | the OS cache directory, lucisv/index/<key> |
every other client. $XDG_CACHE_HOME or ~/.cache (Unix), ~/Library/Caches (macOS), %LOCALAPPDATA% (Windows), keyed by a hash of the sorted workspace roots — or of the filelist, with no roots |
| 4 | nowhere | lucisv.index.persist: false, or nothing above answered. The index is in memory only, exactly as before this round |
Pinned rung by rung in the_cache_directory_is_the_highest_rung_that_answers,
and through the workspace in
a_configured_cache_path_beats_the_editors_storage_folder.
Measured
corpus/: 860 files, 4.94 MB of Verilog. Both builds, this Mac, min of the
runs the #[ignore]d probe does
(cargo test -p lucisv_server --bin lucisv-server qa_perf_cold_warm -- --ignored --nocapture).
Re-measured after the 2026-08-27 fix round, which added the per-record checksum (one more FNV-1a pass over each record, written and read).
| whole rescan of 860 files | debug | release |
|---|---|---|
| no cache (the pre-round cost) | 1.498 s | 322 ms |
| cold, filling the store | 1.587 s | 340 ms |
| warm, every file from the store | 0.756 s | 179 ms |
| half-warm, one file edited | 0.760 s | 180 ms |
So the parse is a little over half of a rescan, and the cache takes all of it: 2.0× in debug and 1.8× in release. Filling the store costs 6% on the one scan that fills it. The remaining 179 ms is the read, the completion word table's lex and the include scan — none of which this round caches, and all of which are named in Assumptions. The checksum is inside the noise of these numbers: it hashes the record, which is a fifth the size of the source line the record describes, and the store is only touched once per file per scan.
The store is 910 KB for 860 files (895 KB before the checksum: the field costs exactly 17 bytes per record, 15 KB over the corpus) — about 1 KB per file, 18% of the 4.94 MB of source it describes. Growth is one line per file per content, compacted to one line per file at the end of every whole scan, so a session's saves do not accumulate across sessions; a workspace of 10,000 files should expect a store around 11 MB, which is the number to revisit if anyone ever wants compaction to be cleverer than "rewrite it".
Hashing all 4.94 MB is 6.4 ms of that 179 ms (24.4 ms of 756 ms in debug), which is the measurement behind dropping the brief's mtime fast path: the text is read either way, so an mtime match could only ever have saved this.
Status / TODO
FileFactspersisted per file, keyed by content hash + record format + store format + lucisv version- Hand-rolled, versioned, escaped, length-prefixed one-line record format; no new dependency
- Write-through per file as a scan parses it; atomic compaction at the end of a whole scan; a torn final record ignored, never fatal
- A save's record written through on the incremental path, with no second parse
lucisv.index.persist(default on) andlucisv.index.cachePath, both settings doors, both inpackage.jsoninitializationOptions.storagePath, passed by the extension fromcontext.storageUri— the round's oneextension.jschange- The four-rung directory ladder, including the hand-rolled OS cache directory keyed by workspace identity
cached:log lines besideindexing:, cached files counted in the bar,N from cachein the end message- Load-from-cache index == fresh index over the corpus, by fingerprint, plus counts and the completion word table
- 33 new tests (9
vlog_semantic, 10index_cache, 9state, 2server, 2settings, 1 e2e), 1 new#[ignore]d probe - Fix round (2026-08-27), QA finding 1: a per-record checksum of the encoded facts, checked at load, so a record damaged after it was written is dropped rather than served; store format 1 → 2. A deliberately reforged store stays out of the threat model, ruled and written down in Assumptions
- Fix round, QA finding 2: a brand-new store is claimed with
File::create_new, and truncation is left for a header this build cannot read, so four racing cold starters keep 100 of 100 records where they kept 25 - Fix round, QA finding 3: the store is read as bytes and decoded a line at a time, so a cut inside a multi-byte character costs the torn record and no other — zero of 583 cut points now lose a whole record
- Not done, deliberately: no (size, mtime) fast path. It would save 6.4 ms of a 179 ms warm scan, because the file is read anyway, and would put a filesystem timestamp inside the correctness argument. See the work log.
- Not done, deliberately: the completion word table and the include graph are not cached. They are what the remaining 179 ms is, and each is its own record format with its own invalidation. One store shipped and measured beats three guessed at.
- Not done, deliberately: no background compaction, and no size bound. The store is rewritten at the end of every whole scan, which is where the growth math above lands; a scheme that also pruned by age or by size would be guessing at a workspace nobody has reported.
- Not done, deliberately: no locking between two servers over one store. Records are content-keyed, checksummed and independently verified, and a new store is claimed rather than truncated, so a race costs re-parsing at worst, never an answer.
- Not done, filed by QA (Low), still open: an
index-cache.<pid>.tmpleft by a compaction killed between its write and its rename is never swept up (an_orphaned_compaction_tmp_file_is_never_swept_up). Harmless to correctness, one orphan per crash in that window. - Not done, filed by QA (Low), still open:
os_cache_dir's Windows and XDG branches are compiled out of this repo's macOS CI, and the macOS branch is only exercised against the ambientHOME. Making the environment lookups injectable is a testability refactor, not a fix, and belongs with whoever adds a second CI runner. - Filed, not done: the store is not read at all until the first whole rescan of a session, so a session that only ever takes the incremental path (open one file, save it) writes records it never reads. It reads them on the next session's scan, which is the case this round is about.
Work log
2026-09-08 — §61.3: the store open, split into its parts (measured, unchanged)
Nothing in this feature changed. With §61.3 putting the workspace walk
behind the first useful answer, IndexCache::open became the largest thing
left in front of it — 89 ms of a 115 ms warm answer — so the review's "measure
a bounded local-record loading design before proposing a format change" clause
came live. It was measured, against the real 46 486 433-byte OpenTitan store
(3 977 records, page-cached), with a throwaway instrumented build:
part of IndexCache::open |
ms |
|---|---|
read — the whole 46.5 MB |
6.31 |
| line split into 3 977 slices | 14.93 |
| extracting every line's path field (no checksum, no allocation) | 2.27 |
| verifying every record's checksum (FNV-1a over ~45 MB) | 60.99 |
73 % of the open is verifying records the answer will never look at. A bounded local load — paths first, then decode only the neighbourhood's ~124 records — costs about 26 ms and would take the warm first answer to roughly 50. It is bounded, and it needs no format change.
It was not implemented, and the reason is this README's own accounting. The
61 ms is owed either way: the other 3 852 records must be verified before the
scan can hit them, so lazy verification moves cost rather than removing it. What
it changes is Load::canonical — dropped counts the
records the checksum rejects, and a load that has not verified them cannot say
whether the file it holds is the file compact would write. That single flag
is what §P4b's compaction skip rests on, and what makes "the store is
byte-identical across warm sessions" true (28 stores, three hashes, both
binaries, §61.3). It also changes an answer in the attack matrix below: under
lazy verification a corrupt later line for a path would displace a good
earlier one instead of being dropped at load, so
a_corrupt_record_is_dropped_and_the_rest_of_the_store_is_not would need
re-attacking rather than re-running. That is an experiment with its own QA, not
a rider on a latency lane. Filed with these numbers in
docs/features/perf5r-first-answer/README.md.
2026-08-27 — dev agent (a persistent index cache with crash/reopen resume)
- The key is the content and only the content, and that is the round's one
deviation from the brief. The brief asked for
(size, mtime)to skip even the hash, with a hash check on mtime mismatch. I implemented the store first, measured, and dropped the fast path, because the premise it rests on is not true here: a cache hit does not skip reading the file. It cannot —Candidates(the completion word table) andIncludeGraphare built from the same text in the same rescan, and neither is cached this round — so by the time the cache is asked about a file, that file's bytes are already in memory, and an mtime match would save exactly one FNV pass over them: 6.2 ms of a 181 ms warm scan over the corpus, measured by the probe. The price would have been real: a stored(size, mtime)is a claim about a file that the file itself does not carry, and it takes two ways to go wrong that content hashing has none of. It also would have made the save-time write-through unsound as written — a save's text can come from an unsaved buffer, and a record whose hash is the buffer's but whose metadata is the disk file's would be a fast-path hit with the wrong facts. Keyed on content, that same record is simply a line the disk file never matches. The deviation is pinned from both sides inthe_key_is_the_content_and_only_the_content, and the assumption that justifies it (the read is not skipped) is stated in Assumptions rather than buried here. If the word table and the include graph are ever cached too, the read does become skippable and this decision is worth reopening — with the mtime question then paying for something real. - One line per record, because that is the crash-safety mechanism. The brief allowed either tempfile+rename per batch or an append log with a load-time validity check, and asked for the crash-safest shape that stays boring. It is both, and they compose: append one line per parsed file (killing the process loses at most the file in flight), then rewrite atomically at the end of the scan (which bounds growth and drops dead entries). What makes the append half safe with no framing of its own is that a record holds no raw newline — every string field is escaped — so a torn write is a line the reader rejects anyway. No length prefix on the line, no per-line checksum, no repair path.
- A malformed line drops that record, not the store. This is a considered
departure from
lucisv_core::cache, which discards wholesale on one bad line. There, a malformed line is evidence the file is not what it claims; here it is the expected shape of a crash, and the store's own value is that most of it survived. The safety argument is that it costs nothing to be lenient: every record is separately keyed by content and separately verified, so a corrupt record cannot be used, only ignored. The header is the one thing still trusted wholesale, and it is checked exactly. - Strictness is where the safety is, so
decoderefuses everything it does not recognise: a missing field, a number that will not parse, a list marker in the wrong place, aSymbolKindname this version does not write, a count that outruns the line — and a field left over at the end.a_record_that_is_not_exactly_a_record_decodes_to_nothingtruncates a real record at every one of its field boundaries and asserts every prefix is rejected, which is the shape a torn write actually takes. FileFactsbecame public rather than a parallel "cache record" type. The brief warned against storing parse inputs instead; the opposite trap was a second struct mirroring the first, which would need a conversion nobody could prove was total. Making the existing value encodable, withadd_fileredefined asadd_facts(FileFacts::of(...)), means the cached and parsed paths are the same code from the builder's point of view — there is nowhere for them to disagree, and the equivalence test is checking the codec rather than the index.DefineTable::from_entriesis the one thing this round needed fromvlog_parser. ADefineTable's entries are readable and were not writable, and a record has to restore one. It is additive, it is documented as the inverse ofentries(), andcollect_definesremains the only thing that reads a table out of a file.Define/DefineTablealso gainedPartialEq/Eqso the round-trip test can assert every field rather than compare two renderings.- The content hash is reused, not copied.
lucisv_serveralready depends onlucisv_core, solucisv_core::cache::content_hashis oneuseaway — no new edge, and no second FNV-1a to keep byte-identical with a file on disk. (The brief allowed a justified copy; there was nothing to justify.) IndexEvent::Cachedrather than acached: boolonParsing. AParsingevent that did not parse is a lie in the one place a reader looks to find out what a rescan did, and the new variant makes every consumer grow an arm — the compiler asking each of them what it wants to say. The bar ticks identically for both; only the log line and the count differ.- Tests may not write into the developer's cache directory, and two
mechanisms keep them out. In-process tests:
Workspace::cache_dirreturnsNoneunder#[cfg(test)]unless the test named acachePathor astoragePathof its own, so the OS rung is never reached by accident (it is tested directly againstindex_cache::cache_dir). The e2e tests spawn the real binary, where nocfg(test)applies, soserver_command()pointsHOME/XDG_CACHE_HOME/LOCALAPPDATAat a scratch directory for every session. This was not theoretical: the first full run left 104 directories in~/Library/Caches/lucisv/index. - The e2e test is three sessions, not two. Cold, warm, and half-warm with
one file changed between them — the third is the one that proves the resume
is per file rather than all-or-nothing, over the wire, with the real binary
and a real
storagePath. - Files touched:
crates/vlog_parser/src/defines.rs,crates/vlog_semantic/src/{facts.rs (new),workspace.rs,lib.rs},crates/vlog_semantic/tests/workspace.rs,crates/lucisv_server/src/{index_cache.rs (new),state.rs,server.rs,settings.rs,main.rs},crates/lucisv_server/tests/e2e.rs,editors/vscode/extension.js,editors/vscode/package.json,TODO.md,docs/features/{lucisv-server,indexing-ux,incremental-index,index-scope}/README.md, this README. No new dependency, no version bump, nodocs/site/, no commits.
Verification. cargo fmt --all -- --check: clean. cargo clippy --all-targets --workspace: zero warnings. cargo test --workspace: 2286
passed, 0 failed, 9 ignored — measured against a stashed HEAD tree's
2253 passed, 8 ignored in the same session, so 33 new passing tests and
one new #[ignore]d probe, with nothing superseded and nothing renamed. cargo test -p vlog_formatter: 180
passed across its seven binaries, untouched — verify.rs does not appear in
this round's diff. cargo build && node editors/vscode/smoke.js target/debug/lucisv-server: smoke: OK (it passes no storagePath and has
no root, so it takes the no-persistence path unchanged).
node -e JSON.parse(package.json): parses.
The 33 new tests, and what each is for:
| test | pins |
|---|---|
a_records_every_field_survives_the_round_trip (vlog_semantic) |
encode → decode → equal, over a fixture with every field populated, tabs and backslashes included; and re-encoding byte for byte |
an_index_built_from_records_is_the_index_the_parse_would_have_given (vlog_semantic) |
the round's central claim, by fingerprint, over duplicate names and cross-file edges |
a_record_that_is_not_exactly_a_record_decodes_to_nothing (vlog_semantic) |
every truncation point, a trailing field, and ten crafted malformations |
a_degenerate_file_still_makes_a_record (vlog_semantic) |
empty, whitespace, not-Verilog, does-not-lex, comment-only |
a_path_with_a_separator_in_it_is_escaped_like_any_other_string (vlog_semantic) |
a tab, a newline and a backslash in the path |
a_path_that_is_not_utf_8_is_simply_never_cached (vlog_semantic, unix) |
the one path shape with no record at all |
every_symbol_kind_has_a_name_and_only_its_own, every_escape_survives_a_round_trip, an_escape_this_format_does_not_write_is_not_read (vlog_semantic facts) |
the two total matches are inverses and share no name; the escape is a bijection |
a_record_written_in_one_session_is_read_in_the_next (index_cache) |
the store round-trip, and that content and path are both part of the key |
a_record_survives_a_session_that_never_compacted (index_cache) |
the crash case: write-through with no compaction |
a_torn_final_record_costs_one_file_and_nothing_else (index_cache) |
a store cut mid-line, the way a killed process leaves one |
a_store_from_another_version_is_dropped_whole_and_replaced (index_cache) |
the header, and that the first write replaces rather than appends |
a_corrupt_record_is_dropped_and_the_rest_of_the_store_is_not (index_cache) |
seven malformed lines beside a good one |
a_record_whose_facts_no_longer_decode_is_a_miss_not_a_failure (index_cache) |
a well-framed line whose facts are truncated |
compaction_keeps_one_line_per_path_and_drops_the_files_that_are_gone (index_cache) |
the growth bound, last-write-wins, and pruning |
a_disabled_cache_reads_nothing_and_writes_nothing (index_cache) |
persist: false at the store level |
nothing_is_created_until_something_is_recorded (index_cache) |
lazy mkdir, the .gitignore, no leftover temp file |
the_cache_directory_is_the_highest_rung_that_answers (index_cache) |
the four rungs, the relative-path rule, and that the root order is not part of the workspace identity |
a_second_session_over_the_same_store_parses_nothing_it_parsed_before (state) |
the headline: a whole new workspace over the same store parses nothing and builds the same index |
a_half_warm_scan_parses_exactly_what_the_store_cannot_answer_for (state) |
the resume: one changed file and one new file parsed, one cached, and the result equal to a cacheless scan |
the_key_is_the_content_and_only_the_content (state) |
both directions of "no timestamp is trusted" |
the_cache_never_puts_back_a_file_the_scan_no_longer_visits (state) |
the scope is decided before the cache is asked |
persistence_off_reads_nothing_and_writes_nothing (state) |
both directions of the setting, through the workspace |
turning_persistence_off_mid_session_stops_the_write_through_at_once (state) |
the save path stops writing the moment the setting lands |
a_configured_cache_path_beats_the_editors_storage_folder (state) |
rung 1 over rung 2, and the fall-back when it is unset |
a_storage_folder_that_does_not_exist_yet_is_made_on_demand (state) |
what context.storageUri really hands over |
the_cached_index_is_the_index_a_fresh_scan_would_have_built_over_the_corpus (state) |
the paranoid sweep: 860 real files in and out of the store, fingerprint, counts and the completion word table |
qa_perf_cold_warm_and_half_warm_scans (state, #[ignore]) |
the numbers above, the store size, and the cost of the hash |
a_second_session_over_the_same_storage_folder_resumes_from_the_cache (server) |
through the real dispatch: the end message, the cached: lines, the fingerprint, and the same workspace/symbol answer |
a_session_that_was_offered_no_storage_folder_keeps_its_index_in_memory (server) |
what every client but ours does, unchanged |
the_index_cache_is_on_until_a_client_turns_it_off, the_cache_path_is_unset_until_a_client_names_one (settings) |
the defaults, the empty string, five wrong types each; the pull-door test grew both keys |
a_second_session_over_the_same_storage_path_indexes_from_the_cache (e2e) |
the real binary, three sessions over one storagePath: cold, warm, and one file changed |
2026-08-27 — dev agent (fix round: QA's three findings)
Three fixes, all inside index_cache.rs and the tests that pin it. No
handshake moved: FileFacts, its codec and FACTS_FORMAT are untouched — what
changed is the store's framing, which is CACHE_FORMAT's to version.
- Finding 1 (Medium, poisoned records) — the trust question is ruled, and
the accident half is closed anyway. The ruling, written into Assumptions
in full: a store somebody edited on purpose is outside the threat model,
because anything that can write the cache directory can write the source
files (and the binary), and the only thing that would detect a forgery is a
keyed MAC whose key would have to live on the same disk as the data it
authenticates. QA's point that the consequence here is stronger than
lucisv_core::cache's (fields served into the index versus a skip-or-not bit) is recorded with the ruling rather than argued away. What the round does add is a 16-hex FNV-1a of the encoded facts, appended to every record and checked before the record is believed. That is what makes the module's "never a correctness input" promise true against every accident a written record can suffer — bit rot, a torn append two servers interleaved, an editor rewriting line endings, a partial write — rather than only against staleness. It is deliberately not a security boundary, and the test says so out loud:a_record_whose_facts_do_not_match_their_checksum_is_droppedasserts the tampered record is dropped, the honest one beside it still reads, and a reforged one (checksum recomputed) is still served, which is the accepted residue. QA's two tests flipped accordingly — the store-level one renamed from..._is_served_verbatim, and the workspace-levela_poisoned_cache_record_makes_the_fingerprint_diverge_from_a_fresh_scanrenamed toa_poisoned_cache_record_is_dropped_and_the_index_is_a_fresh_scans, where the fingerprint now equals the fresh scan's and the file is reported parsed rather than cached. The checksum goes last on the line because the facts hold no raw tab, sorsplit_oncerecovers it unambiguously and the encoded facts are handed todecodebyte-identical to how they were written.CACHE_FORMAT1 → 2 by the rule at the constant; format 1's stores are discarded whole, whicha_store_from_the_previous_store_format_is_dropped_whole_and_replacedpins with a real format-1 store, header and unchecksummed record and all. - Finding 2 (Medium, first-writer race) —
create_new, and truncation kept for the one case that still deserves it.append's oldelsebranch truncated whenever this instance had not read a header, which is every session's state at its first cold scan, so a second server erased the first's records; QA measured 25 of 100. The store is now claimed withFile::create_new, and the header is written into whatever settled. There are exactly three shapes a session can find, andsettled_headernames them: Ours (append — this is the loser of the race, and the winner's header is as good as its own), Empty (the file one of us just made, caught before its header: write the identical header line and append, so at worst the store carries a duplicate header line, which the reader drops as one more malformed record), Foreign (a whole first line this build cannot read: replace it, because its records were dropped at load and appending under it would lose ours at the next load too).writeln!was also replaced with a singlewrite_allper record and per header, sincewriteln!'s formatting machinery is free to split a line across two writes — the doubt QA raised about the O_APPEND argument, and the thing that makes the "Empty" case's duplicate header a whole line rather than two spliced ones. The count is deterministic, not merely likely: no branch above drops a byte, no session truncates a store another session is appending to, and each line is one write on an append handle. QA's test, renamedconcurrent_first_writers_all_survive_and_none_is_ever_wrong, now asserts 100 of 100 and was run 10 times in a row for 100 every time. The residue, stated honestly: two sessions cold-starting on the same foreign (another version's) store can still both replace it and lose each other's early records. A cousin of the same residue, from QA's fix-round re-check:settled_header's single read could in principle observe a torn read of a concurrent header write and misclassify a store as Foreign, truncating it unwarrantedly — the same one-write window, the same self-healing loss of nothing a current-version reader could use, portable-untestable, accepted alongside. Closing that needs either a lock or a rename-to-claim dance whose failure mode (a writer appending to an unlinked inode) is worse than what it fixes; the window is one write wide, needs an upgrade plus two simultaneous first scans of one workspace, and what is lost is a cache nobody could read. The end of either scan rewrites the store whole from memory regardless. The other windowcreate_newcould have introduced — a zero-byte store from a session killed between the claim and the header — is what the Empty arm exists for, pinned byan_empty_store_is_a_claim_to_finish_rather_than_a_store_to_replace. - Finding 3 (Low, UTF-8 truncation) — bytes in, one line at a time.
openread the store withread_to_string, so a cut landing inside any multi-byte character rejected the whole buffer, whichunwrap_or_defaultthen made indistinguishable from "no header": every intact record thrown away because something later in the file tore mid-character. It now reads bytes, splits them the waystr::lineswould (store_lines, which also strips a\rso the header check is what it always was), and validates each line's UTF-8 on its own — an invalid line is skipped like any other bad record. QA's byte-by-byte truncation loop, renamedtruncating_the_store_at_every_byte_offset_costs_only_the_torn_record, keeps its two original properties and gains the one that was the finding: at every cut past the last whole record, every whole record survives — 0 of 583 cut points cost anything but the record they landed in (it was 2 of 534 before, on a store that is now longer because of the checksum). The test's premise assertion changed with it: it now insists some cut lands mid-character, so the test still proves what it says it proves. - Also:
a_record_whose_facts_no_longer_decode_is_a_miss_not_a_failurenow writes its half-record with a valid checksum, or it would have been rejected one layer earlier and stopped testing the decode path;a_corrupt_record_is_dropped_and_the_rest_of_the_store_is_notgained the two new damage shapes (a record with no checksum field, and one whose checksum does not match) and now also asserts the corrupt record's own path is never served, not merely that the good one survives. - Files touched:
crates/lucisv_server/src/index_cache.rs,crates/lucisv_server/src/state.rs(the one QA test), this README. No new dependency, nounsafe, no#[allow], no version bump, nodocs/site/, no commits. Nothing outsideindex_cache.rschanged behaviour: the store's framing is private to it.
Verification. cargo fmt --all -- --check: clean. cargo clippy --all-targets --workspace: zero warnings. cargo test --workspace: 2297
passed, 0 failed, 9 ignored — QA's tree was 2295, and the two new tests are
a_store_from_the_previous_store_format_is_dropped_whole_and_replaced and
an_empty_store_is_a_claim_to_finish_rather_than_a_store_to_replace. The
three flipped tests were renamed, not added: lucisv_server alone goes 1091 →
1093, so nothing was quietly dropped. cargo test -p vlog_formatter: 180
passed across its seven binaries, untouched — verify.rs is not in this
round's diff. cargo build && node editors/vscode/smoke.js target/debug/lucisv-server: smoke: OK. ~/Library/Caches/lucisv: checked
after the whole run, still absent. The #[ignore]d probe was re-run in both
profiles for the Measured table above, and the four-writer race test was run
ten times in a row: 100 of 100 records every time.
2026-09-08 — dev agent (perf take 5 §P4b: two things the store stops doing)
Two changes, both in this feature's contract, both amended above rather than
only recorded here. Neither touches the record format, the key, the header,
the claim/append protocol, the per-record checksum, the byte-wise load or the
torn-record rule; FACTS_FORMAT and CACHE_FORMAT are untouched.
- A compaction that would reproduce the file is skipped (Assumptions, the
new bullet under the write-through rule). The store
renderwrites is canonical — this build's header, one line per path, path order — soIndexCache::opennow counts what it read (lines read, kept, dropped, duplicated, and whether the paths ascended) andcompactasks whether the rewrite would be the same bytes: loaded canonical, nothing appended since, and no entry's file gone. The existence sweep is onestatper entry, which is a subset of whatrenderalready does per entry, so the check costs a fraction of the rewrite it replaces. On opentitan this is the whole of a warm session's two compactions — 182 ms of a 1.33 s start — both of which were measured writing a byte-identical 44.3 MiB file (§P4a:store_before_kib=store_after_kib= 45 396,records0 and 1). - A write-through the store already holds is not written again
(Assumptions, the new bullet beside the save's write-through). This was not
in the ruling and is reported as a scoped addition, because without it the
skip above never fires in a real session: an open buffer's record is
written through on every scan, so
recordsis never 0 and the store is never canonical. Measured on opentitan before it: warmcompact88.19 ms andcompactions1 on the configured rescan, i.e. the whole of (a) defeated by one duplicate line. After it:records0,repeats1,compactions0,compact10.13 ms — and that 10.13 ms is the skip's own existence sweep over 3 976 entries, against the 90.20 ms rewrite it stands in for. - A rescan opens the store at its first file, not before it (Handshakes,
lucisv_server::state). The re-open rule is unchanged and both of its reasons still hold; only the moment moved. It exists because a session's first scan runs at the default settings, beforeworkspace/configurationcan be asked, and with no buffer open its folder scope — and therefore its work list — is empty: warm, that scan was reading 44.3 MiB and rewriting it for a scan that indexes nothing. The deferral is a move, not a drop, which is the one way this could have gone wrong: the widen adidOpentriggers never opened the store itself (it reads the handlebegin_scanleft), so dropping the open would have silently cost that widen every one of its cache hits. It is pinned from the failing side —state::tests::a_scan_with_no_files_neither_reads_the_store_nor_rewrites_itreportsparsed: ["b.sv"]when the open is dropped instead of deferred.
What was deliberately not done. Reusing the store a previous scan of the
same session already read — the third of §P4a's candidates, worth another
91 ms — was refused by the lead, and this README is the reason: the reopen
guards a mid-session cachePath/persist change and a second session's
compaction replacing the file under an append handle. Nothing here weakens
either.
Tests. Eight new in index_cache.rs (a canonical store is not rewritten,
a record the store already holds is not appended again, and one each for a
duplicated path, an unreadable line, out-of-path-order records, a session that
appended, a file that is gone, and another version's header), three new in
state.rs (the warm rescan leaves the store untouched;
a scan with no files neither reads nor writes it and the widen behind it still
hits; a cold session that indexes nothing creates no store at all), one new
wire test in server/tests/scan_trace.rs (both halves over the real dispatch,
by the trace's own new opens= / compactions= counters). Every pre-existing
test in this feature is untouched and green, the interrupted-store ones
included: a_record_survives_a_session_that_never_compacted,
a_torn_final_record_costs_one_file_and_nothing_else and
truncating_the_store_at_every_byte_offset_costs_only_the_torn_record.
Verified that the six guard tests really guard: with already_compact
widened to "there is a directory", all six fail, as do
compaction_keeps_one_line_per_path_and_drops_the_files_that_are_gone and
nothing_is_created_until_something_is_recorded.
QA log
2026-08-27 — QA agent (attack surfaces on the persistent index cache)
Verdict up front: the poisoned-cache trust boundary does not hold, and
everything else is committable. The module doc's claim — "a performance
artifact and never a correctness input" — is true against corruption and
staleness, which is everything the dev's 33 tests exercise. It is not true
against a store an attacker (or anything else with write access to the cache
directory) can hand-edit: a record is verified only against the file's
content hash, and nothing hashes or otherwise authenticates the facts field
itself. A line with a real file's exact hash and fabricated facts is served
verbatim, and it changes what workspace/symbol, hover, go-to-definition and
rename answer for that file. Filed as Medium severity: same threat model
as lucisv_core::cache (same user, same disk — anyone who can write here can
already edit the source or the binary), but a materially different
consequence, because that cache's entry is a skip-or-not bit and this one's
fields are served straight into the index. Recommend the dev/lead decide
whether this is accepted as within the stated threat model (write access to
the cache dir already implies write access to the workspace) or whether a
record should carry its own integrity check (e.g. hash the encoded facts
too, or HMAC the line) before this ships as "never a correctness input"
without qualification. Not blocking on its own — it does not violate "never
corrupt code" (the cache never touches source files) or idempotency — but the
README's phrasing should either gain a caveat or the gap should be closed.
Gates. cargo fmt --all -- --check: clean, both before and after QA's
additions (one re-run of cargo fmt --all was needed after adding tests, to
match this repo's line-width formatting — no logic changed). cargo clippy --all-targets --workspace: zero warnings, before and after. cargo test --workspace: 1091 passed, 0 failed, 9 ignored in the crate that carries
this round (up from the dev's own 1082 passed — the QA session's 9 new
tests, below), 2295 passed workspace-wide, 0 failed. cargo test -p vlog_formatter: 114 passed, untouched — confirmed verify.rs is not in this
round's diff (git diff 5e4aa7b --stat -- '**/verify.rs' is empty). cargo build && node editors/vscode/smoke.js target/debug/lucisv-server: smoke: OK. ~/Library/Caches/lucisv was checked before, during (mid-session) and
after this entire QA pass with ls: never created. All test-writing paths
used std::env::temp_dir()-based scratch directories, matching the dev's own
TempDir/Tree helpers.
Per attack surface:
-
Adversarial store files — poisoned records. See verdict above. Reproduced directly at the store level (
index_cache::tests::a_record_with_a_valid_hash_but_fabricated_facts_is_served_verbatim, new) and quantified through the equivalence sweep as asked (state::tests::a_poisoned_cache_record_makes_the_fingerprint_diverge_from_a_fresh_scan, new): a record witha.sv's genuine content hash but fabricated facts is a cache hit, and the resultingWorkspaceIndex::fingerprint()differs from a fresh scan's — proving the corpus equivalence test (the_cached_index_is_the_index_a_fresh_scan_would_have_built_over_the_corpus) would have caught this if anything validated a record beyond the file's hash. Nothing does, today.- Escaping attacks: reused and extended
a_corrupt_record_is_dropped_and_the_rest_of_the_store_is_not's shapes by inspection —Reader/Writerincrates/vlog_semantic/src/facts.rssplit strictly on literal\t, so an unescaped raw tab or newline shifts field boundaries rather than being interpreted, anddecode'sinput.done()check (a field left over at the end) plus everyOption-returning accessor rejects the result — verified-clean, no panic path exists (every parse step is?-short-circuited, so an over-long length prefix likeD999999999fails on the very first missing field rather than allocating or looping unboundedly — traced, not additionally tested, since the mechanism is structural: afor _ in 0..n { push(x()?) }loop cannot outrun the fields it reads from). Negative numbers failu32::parse(None, no panic). A path of../../../etc/passwd-shape is just aPathBuf; no filesystem traversal ever happens from a record's path field —record_pathanddecodenever open anything, they only build/compare strings, so this path is inert whether or not the current scan actually asked about it. - Path outside every root: traced, not separately tested —
open()performs a wholesaleHashMapinsert with no root filtering, butrebuild_index_withonly ever callscache.facts_for(path, text)for pathscollect_sources's scope walk already produced, so an out-of-root entry is inert. This is exactly whatthe_cache_never_puts_back_a_file_the_scan_no_longer_visitsalready pins from the other direction (a file leaving scope keeps its record, unused); confirmed the mechanism is symmetric by readingstate.rs:456-490rather than re-testing it. - Duplicate records for one path:
record()-driven duplication (threerecord()calls in one session) was already pinned bycompaction_keeps_one_line_per_path_and_drops_the_files_that_are_gone. Added the raw-file shape — two lines for the same path sitting in the store file directly, the shape a hand-edited or externally concatenated store takes rather than onerecord()produces — confirmed last-line-wins (index_cache::tests::two_raw_lines_for_the_same_path_in_the_store_file_last_one_wins, new). - 100 MB single-line store:
IndexCache::opencallsstd::fs::read_to_string, unbounded — the whole file loads into memory regardless of size, same aslucisv_core::cache::Cache::load's ownread_to_string. Not a regression against this codebase's existing posture, and the store's size is bounded by the workspace's own size (the README's own measurement: ~1 KB/file, so a store large enough to matter implies a workspace already large enough to dominate memory via the index itself). Verified-clean by comparison, not separately load tested — an actual 100 MB write/read round trip was judged not worth the wall-clock time for a bound this codebase already accepts elsewhere. - Header variations: wrong version/format discards all — already
pinned (
a_store_from_another_version_is_dropped_whole_and_replaced). Extra fields: rejected, pinned directly (index_cache::tests::a_header_with_an_extra_trailing_field_is_rejected_like_any_other_mismatch, new) — the check islines.next() == Some(header().as_str()), exact string equality, so there is no forward-compatible "unknown trailing column is ignored" path. Worth knowing if a future format revision ever wants additive header fields; not a defect today.
- Escaping attacks: reused and extended
-
Crash shapes.
- Truncate at every byte offset: implemented exactly as asked
(
index_cache::tests::truncating_the_store_at_every_byte_offset_never_panics_or_serves_wrong_facts, new), over a store built with one file holding a multi-byte UTF-8 character (é/öin a macro body) alongside two plain-ASCII files. No panic at any of 534 cut points, and nothing served was ever wrong — both required properties hold. Finding (Low): a cut landing inside a multi-byte character loses the entire store, not only the torn record.IndexCache::openusesread_to_string, which rejects the whole buffer if its tail is not valid UTF-8; a truncation whose cut point falls inside any multi-byte sequence — anywhere in the file, not only in the record that was mid-write — produces exactly that invalid tail, andunwrap_or_default()then turns the whole read into an empty string, indistinguishable from "no header". The test isolates this from the expected, harmless kind of loss (cuts that simply haven't finished writing a.sv/b.sv/the header yet) by checking specifically for cuts past both good lines that still lose them: 2 of 534 cut points did, both landing inside the record'sé/öbytes. Consequence is bounded to a full re-parse (never a wrong answer, per the property the test actually enforces), but it is a real departure from the stated "a corrupt record drops only that record" granularity for this one tear shape — plausible in practice for any workspace with non-ASCII identifiers, string literals, or comments. Not fixed by QA (a fix — e.g. reading bytes and validating UTF-8 per line rather than for the whole buffer — is a design change belonging to the dev). - Interrupted compaction (temp file left behind): confirmed
never cleaned up
(
index_cache::tests::an_orphaned_compaction_tmp_file_is_never_swept_up, new) —open()only ever reads the exact nameindex-cache, so a strayindex-cache.<pid>.tmpfrom a process killed between the temp-file write and the rename is invisible to it and to every latercompact()(which names its own tmp after its own pid). Harmless to correctness, confirmed inert against a real store in the same test; filed as a minor, slow, unbounded disk leak (one orphan per crash landing in that exact window) — consistent with the already-filed "no background compaction, no size bound" limitation, just a specific mechanism for it. Not fixed by QA (cleaning up stale*.tmpsiblings onopen()is a small, reasonable addition, but it's new behavior, not a typo-class fix). - Disk-full on append: reasoned and tested
(
index_cache::tests::a_write_failure_is_silent_and_never_panics_or_leaves_a_half_written_store, new, Unix-only,#[cfg(unix)]) via a directory with its owner-write bit cleared. Note for whoever reads this test later: a read-only directory does not stop an append to a file that already exists and is itself still writable (directory permissions gate creating/removing entries, not writing through a handle to one that already exists), sorecord()kept succeeding in this setup;compact()'s temp file is a new directory entry and did fail, silently, via the existing.is_ok()check, leaving the standing store intact and readable afterward. No panic either way. This models "cannot create new files" rather than genuineENOSPCon a write to an open fd, which Rust's sandbox does not offer an easy way to simulate; the code path (let _ = writeln!(...)inappend, and the checkedfs::write(...) .is_ok()incompact) is identical for both failure origins by inspection, so the distinction was judged not worth chasing further.
- Truncate at every byte offset: implemented exactly as asked
(
-
Two servers, one store.
- O_APPEND atomicity / merged lines during steady-state appending:
reasoned rather than raced directly —
writeln!(file, "{line}")'s defaultWrite::write_fmtcan issue more than onewrite_allcall per line (one per literal/argument piecefmt::Argumentscarries), so two already-open writers are not guaranteed a single atomicwrite(2)per line the way the README's phrasing might suggest. Even granting an interleave, the field structure means a spliced line either fails to decode (dropped, safe) or — astronomically unlikely — decodes cleanly with a hash field that would have to coincidentally equal some real file's 64-bit FNV-1a hash to be served; not pursued further as a direct race (see below for what QA did race instead, which found a bigger and more tractable gap in the same neighborhood). - Concurrent first writers (cold start) — new finding, Medium:
append()'sheader_okis per-IndexCache-instance state decided atopen()time; every server opening a new store computesheader_ok == falseindependently, andappend()'selsebranch for that case truncates the file before writing a fresh header. Four threads, each its ownIndexCache::openon the same empty directory, each appending 25 long records with no compaction, left 25 of 100 records standing (index_cache::tests::concurrent_first_writers_can_lose_each_others_entries_but_never_serve_a_wrong_one, new) — a later writer's truncate silently erases an earlier writer's already-appended lines, repeatedly, because each writer only truncates once (on its own first write) but does not know another writer already did. Bounded exactly as the README claims — nothing served was ever a mix of two writers' bytes, only sometimes absent — but "no locking … a race costs re-parsing" understates the magnitude: this is not a one-line loss, it can be most of a whole scan's writes, and it is a cold-start-specific shape (steady-state appends to an already-Someheader are not affected the same way) that the write-up does not call out separately from the general no-locking note. The next whole rescan'scompact()repairs it regardless — filed as a documentation gap plus a candidate follow-up (e.g.OpenOptions::new().create_new(true)to detect "someone else already claimed this" instead of always truncating), not fixed by QA. - Compaction racing an append: reasoned, not separately tested — a
renamemid-scan does not invalidate another process's already-open append fd (POSIX: the fd keeps writing to the now-unlinked inode until closed), so a process whose scan is still running when another compacts will lose whatever it appends after that point unless it also reaches its owncompact()before exiting — which every whole rescan unconditionally does (rebuild_index_with's last two lines). Sincecompact()'srender()writes from in-memoryself.entriesrather than re-reading the (possibly now-detached) file, a process that finishes its own scan is self-healing regardless of a mid-scan rename race; the only real loss is a process that crashes during the window, which is no worse than crashing without the race at all. This matches the Assumptions section's own claim ("the worst case is a session whose records another session's rewrite dropped … costs re-parsing, never an answer") exactly — verified-clean by trace, a live two-process test was judged not to add information proportional to its complexity here. - Three e2e sessions are sequential: confirmed by reading
crates/lucisv_server/tests/e2e.rs:4446-4480—a_second_session_over_the_same_storage_path_indexes_from_the_cachecallstalk(&session())three times in program order, andtalkwrites the whole session and reads until the child's stdout closes (the child has already receivedexitand terminated) before the next call starts. No concurrency is exercised on the wire; noting this per the brief's instruction, not as a gap — the concurrent case is what item 3's other three points cover at theindex_cachelevel instead.
- O_APPEND atomicity / merged lines during steady-state appending:
reasoned rather than raced directly —
-
The equivalence sweep: ran
the_cached_index_is_the_index_a_fresh_scan_would_have_built_over_the_corpus(passes, 860 files, corpus present on this machine) and added the negative control described in the brief — see item 1. Both new. -
The
cfg(test)guard.Workspace::cache_dir's test-only early return (state.rs:380-383) is exactly what it claims: it only ever short-circuits when neither acachePathnor astoragePathis set, and every cache test in this crate sets one or the other, so the OS rung is genuinely never reached from an in-process test. Confirmed by reading every call site; not separately tested (testing a negative absence-of-a-branch is what the existing test suite's shape already is).os_cache_dir()'s platform branches — finding (Low): two of three are compiled out of every test run that exists, and the third is exercised only against the ambient environment, never an injected one..gitea/workflows/ci.ymlrunscargo test --workspaceexclusively onruns-on: macos-arm64.os_cache_dir's Windows branch (LOCALAPPDATA) and its "neither macOS nor Windows" branch (XDG_CACHE_HOME, filtered to absolute paths, falling back to~/.cache) are behind#[cfg(windows)]/#[cfg(all(not(macos), not(windows)))]respectively, so on this CI they are not even compiled, let alone tested — this is not something any test in this repository can currently exercise without a second CI runner or cross-compilation. The macOS branch that does compile is called directly inthe_cache_directory_is_the_highest_rung_that_answers(os_cache_dir()atindex_cache.rs:933), but only against whateverHOMEthe test process actually has — no test setsHOMEto a controlled value first, and theHOME-unset-returns-Nonefallback (which is what makes the whole ladder correctly fall through to "no cache" rather than panicking) is never exercised on any platform. Recommend the dev consider a version ofos_cache_dirthat takes its environment lookups as parameters (or a small env-injection test helper), so the Linux/Windows branches can be checked with hand-fed values even when compiled out — a real gap in an otherwise very thoroughly pinned feature, not fixed by QA since it is a testability refactor, not a bug.- e2e env redirection coverage: confirmed complete —
crates/lucisv_server/tests/e2e.rshas exactly twoCommand::newcall sites; one isserver_command()itself (line 77, setsHOME/XDG_CACHE_HOME/LOCALAPPDATAto a scratch sandbox), and every spawn of thelucisv-serverbinary in the file goes throughserver_command()(lines 98 and 2191, bothlet mut child = server_command()...). The thirdCommand::new(line 553) spawns the unrelatedlucisvCLI formatter binary forfix_all_edits_exactly_what_lucisv_check_fix_edits_inside_a_fence, which useslucisv_core::cache's own store (.lucisv_cache, relative to the current directory by default, not the OS cache directory this feature adds) and is out of this round's scope — confirmed it needs no redirection for this feature's sake.
-
Settings/lifecycle: all verified-clean by reading the existing tests plus
settings.rs, no gaps found.persist: falsemid-session stopping both directions:turning_persistence_off_mid_session_stops_the_write_through_at_onceandpersistence_off_reads_nothing_and_writes_nothingboth pass and match the code (set_client_settingsdrops the cache todisabled()the moment either setting changes,state.rs:361-365).cachePathchange taking effect next rescan:a_configured_cache_path_beats_the_editors_storage_folderpins exactly this (switch settings, rescan, store moves)..gitignorecontent:nothing_is_created_until_something_is_recordedasserts the literal"*\n", matchinglucisv_core::cache's own.- Scope-narrowed reopen not resurrecting out-of-scope entries:
the_cache_never_puts_back_a_file_the_scan_no_longer_visitscovers this directly and was re-read line by line; the mechanism (the cache is only ever asked about paths the scope walk already produced) is the same one that makes finding "path outside every root" above inert. - Wrong-typed
persistleaving the cache on, and a badcachePathleaving it unset:the_index_cache_is_on_until_a_client_turns_it_offandthe_cache_path_is_unset_until_a_client_names_oneinsettings.rsboth pass and match the README's stated direction.
-
The no-mtime deviation — save-path soundness. The pinning test (
the_key_is_the_content_and_only_the_content) covers the general claim; added the specific construction the brief asked for — open a buffer whose text disagrees with disk, let the incremental path write its record through, and check the record a fresh session resolves to is keyed on and filled from the buffer's bytes, not disk's (state::tests::a_saved_buffers_record_is_keyed_and_filled_from_the_buffer_not_stale_disk, new). Verified-clean: the store's fresh-session lookup returns the buffer's facts under the buffer's hash, and disk's own current hash does not appear as a key at all — confirming a stored(size, mtime)really would have been unsound here, exactly as argued in the work log. -
CLAUDE.md compliance.
- No
unwrap()/expect()/panic!()in library code: checked every occurrence inindex_cache.rs,facts.rs, and every line this round's diff added tostate.rs,server.rs,settings.rs,main.rs,defines.rs,workspace.rs,lib.rs(git diff 5e4aa7b -- <files> | grep '^+.*\(unwrap\|expect\|panic!\)'). Every hit is inside a#[cfg(test)] mod testsblock (confirmed by line number against each module'smod testsline) — none in a reachable library path. - Public items have one-line doc comments: spot-checked
index_cache.rsandfacts.rsin full — everypubitem is documented, matching the standard the rest of the round holds to. - README sections present exactly once: confirmed by reading the whole file top to bottom — Goal, Assumptions, Handshakes, Status/TODO, Work log, QA log, Review each appear exactly once, in the required order.
- Corpus tests skip-guarded: every corpus-dependent test in this round
(
the_cached_index_is_the_index_a_fresh_scan_would_have_built_over_the_corpus,qa_perf_cold_warm_and_half_warm_scans) opens with theif !corpus.is_dir() { eprintln!(...); return; }guard, matching the pattern already established elsewhere in this file. verify.rsuntouched:git diff 5e4aa7b --stat -- '**/verify.rs' crates/vlog_formatter/**'is empty.- No
#[allow]in either new file (index_cache.rs,facts.rs).
- No
Beyond the list (worst shapes QA reached for on its own): the concurrent-first-writers truncate storm (item 3) and the multi-byte-tear whole-store loss (item 2) were both found by extending the brief's named scenarios rather than being on the list verbatim — they are the two findings beyond the poisoned-cache one that seem worth the dev's attention, in that order of severity. Nothing found reaches a "never corrupt code" or idempotency violation; every finding here is either a performance/DoS-class loss (bounded, self-healing at the next whole rescan) or the one trust question filed first.
Tests added this session (9, all passing, all in
crates/lucisv_server/src/): index_cache.rs —
a_record_with_a_valid_hash_but_fabricated_facts_is_served_verbatim,
truncating_the_store_at_every_byte_offset_never_panics_or_serves_wrong_facts,
concurrent_first_writers_can_lose_each_others_entries_but_never_serve_a_wrong_one,
a_header_with_an_extra_trailing_field_is_rejected_like_any_other_mismatch,
two_raw_lines_for_the_same_path_in_the_store_file_last_one_wins,
an_orphaned_compaction_tmp_file_is_never_swept_up,
a_write_failure_is_silent_and_never_panics_or_leaves_a_half_written_store;
state.rs —
a_poisoned_cache_record_makes_the_fingerprint_diverge_from_a_fresh_scan,
a_saved_buffers_record_is_keyed_and_filled_from_the_buffer_not_stale_disk.
No fixes applied — every finding above is either verified-clean or filed for
the dev/lead, since none of them is a typo-class or missing-assertion-class
fix within QA's remit. cargo fmt --all was run once, after adding these
tests, purely to match this repo's formatting (no behavior change).
Overall verdict: not blocking, but not silently committable as "done"
either. The feature is idempotent, drops no comments, and never corrupts
a source file — the three hard invariants hold. The one finding that
matters is the poisoned-cache trust boundary (severity: Medium, a scoping
question for the lead — is "same disk, same user" an accepted threat model
here the way it is for lucisv_core::cache, given the consequence is
different in kind?). The concurrent-cold-start truncate storm (Medium) and
the multi-byte-tear whole-store loss (Low) are both real but self-healing.
Recommend the lead read finding 1 and decide the threat-model question
before this ships as worded; the rest can land as-is with the two Low/Medium
process gaps filed for a follow-up round.
2026-08-27 — QA agent (fix-round re-verification)
Verdict up front: all three findings are actually fixed, adversarial re-attack found nothing new that rises above what is already accepted and written down, and one bug was caught and fixed in QA's own new test rather than in the product. Committable.
Gates, re-run clean. cargo fmt --all -- --check: clean. cargo clippy --all-targets --workspace -- -D warnings (forced a real rebuild first with
touch on both touched files, since a cached Finished with no visible
warnings is not proof of a clean run): zero warnings. cargo test --workspace: 2300 passed, 0 failed, 9 ignored — the dev's post-fix
2297 plus QA's own 3 new tests below, nothing else moved. cargo test -p vlog_formatter: 180 passed across the same seven binaries (31+1+4+6+2+
22+114), byte-for-byte the count the dev reported — verify.rs untouched.
cargo build && node editors/vscode/smoke.js target/debug/lucisv-server:
smoke: OK. ~/Library/Caches/lucisv: checked with ls before this
session, after cargo test --workspace, after the release perf probe, and
after the final smoke run — never created at any point. git status
confirms the only files this session touched are index_cache.rs (QA's new
tests) and this README.
Finding 1 (checksum) — re-verified, plus one real bug caught in QA's own test.
- The flipped tests (
a_record_whose_facts_do_not_match_their_checksum_is_droppedat the store level,a_poisoned_cache_record_is_dropped_and_the_index_is_a_fresh_scansthrough the workspace) both pass and both read honestly: the store-level test recomputes the checksum vialine()for its "honest" and "reforged" cases rather than reusing a stale one, and its final assertion (served == evil,served != genuine) is exactly the accepted residue, commented as such — not quietly asserted and left unexplained. The workspace-level test recomputes the file's real content hash independently (lucisv_core::cache::content_hash(real_text.as_bytes())) rather than reusing whatever the genuine record already had, which is what makes it a real reproduction of "hash matches, facts don't" and not a tautology. - New adversarial shape 1, checksum field corruption
(
a_corrupted_checksum_field_drops_the_line_and_never_panics, new): odd length, right-length-but-non-hex, and missing entirely, each checked against a good record beside it. Caught a bug in my own first draft —format!("{:015x}", ...)does not truncate a naturally-16-digit hex value (it is a minimum width, not a maximum), so my first "odd length" record accidentally carried the genuine, matching, 16-character checksum and the test failed by asserting a correctly-served record was wrong. Fixed by slicing the real checksum string (&real_checksum[..15]) instead of reformatting the number. Recorded here because it is exactly the class of mistake CLAUDE.md's rule about attack tests is guarding against — an under-verified "corruption" fixture that turns out not to corrupt anything — and because it happened in a fix-round QA test, not in a normal test, it seemed worth naming rather than quietly fixing and moving on. All three shapes now genuinely corrupt the checksum and are dropped, never served, never panicking. - New adversarial shape 2, the checksum's exact byte coverage
(
a_benign_reencoding_with_the_original_checksum_is_still_dropped, new): the brief asked whether an "equivalent-after-decode-but-different-bytes" shape exists. It does, structurally:Reader::numparses withstr::parse::<u32>, which accepts a leading zero ("00"→0), whileWriter::numnever writes one — so a record'sD-count field rewritten from"0"to"00"decodes to the exact sameFileFactsas the original byte-for-byte-different record. Verified the checksum does not treat these as equivalent: keeping the original record's checksum against the re-spelled bytes is rejected, becauseline()'s checksum is computed over and compared against the literal bytesdecodereceives, never over anythingdecodeproduces. This is a genuine structural strength, not a gap — noted per the brief's instruction to record it as such if no exploitable shape exists. (No two-different-inputs encode to the same bytes was found or is plausible: every field is length-prefixed or escaped with no alternate spelling except this one decode-side permissiveness, andencodeitself never emits a leading zero.)
Finding 2 (race) — re-verified, plus real concurrency on the case QA's new shape asked for.
concurrent_first_writers_all_survive_and_none_is_ever_wrongrun 10 times standalone: 100 of 100 every time, no flakes.- New shape, crash-then-two-racers on the
Emptyarm (two_writers_racing_the_empty_arm_leave_a_valid_store, new): a zero-byte store (the crashan_empty_store_is_a_claim_to_finish_rather_ than_a_store_to_replacealready covers with one writer) found by two real threads racingclaim/settled_headerat once, rather than the sequential single-writer construction. Run 15 times standalone with no failure: both writers' records are always readable afterward, and the store is always left with the header present at least once (sometimes duplicated, which is the documented, harmless residue — a duplicate header line the reader drops as one more line that isn't 16 hex digits wide). Matches the work log's description of theEmptyarm exactly. - Read
claim/settled_header/append_lineline by line for the one sub-window the write-up does not name explicitly:settled_headerreads the file with onestd::fs::read, and if that read races a concurrent writer's headerwrite_allsuch that it observes a partial (torn) header — bytes that are neither empty nor a complete matching header line — it falls intoHeader::Foreignand truncates a store that was never actually foreign, just caught mid-write by an unlucky reader. This is a real, additional sub-case of the residue window, not a new class of bug: it requires the OS to hand back a non-atomic partial view of a write well under typical filesystem atomicity thresholds (~50 bytes, the header line), which every other part of this round's crash-safety argument (write_allinstead ofwriteln!, "no line can land inside another") already leans on being atomic in practice. Not reproducible in a portable test — it needs a kernel that actually tears a sub-page write, which nothing in this environment can force — so traced rather than demonstrated, and filed as the same severity as the already-accepted "two cold starts on a foreign store can both replace it" residue: one write wide, self-healing at the next whole-scan compaction, costs a re-parse and never a wrong answer. Worth a one-line mention next to that residue in Assumptions, not a blocker. - The Foreign-both-replace residue: traced against the code and matches the
work log's claim —
replace_with_headeralways writes the exact sameformat!("{}\n", header())bytes regardless of which session calls it, so even an interleaved double-replace converges on a valid single header rather than mixed content, and the next whole rescan'scompact()rewrites the store from memory regardless of what either replace left behind. No code path reads back what a replace overwrote before overwriting it, so nothing a current-version reader could still use is destroyed beyond what was already unreadable.
Finding 3 (truncation) — re-verified, premise checked, not vacuous.
truncating_the_store_at_every_byte_offset_costs_only_the_torn_record
re-run: mid_character_cuts is nonzero every run (2 in this session's runs;
the exact count and the total cut-point count shift slightly run to run
because the temp directory's path — itself part of every record's encoded
path field — differs in length by session, which is expected and doesn't
touch the property under test), and collateral_loss is exactly 0 every
time. The fixture (unicode_text, holding é/ö in a `define body) does
contain genuine multi-byte UTF-8, so the premise assertion is real and not
vacuous — confirmed by reading the fixture, not only by the assertion
passing.
Cross-checks. an_index_built_from_records_is_the_index_the_parse_would_ have_given and the corpus equivalence sweep both still pass. The #[ignore]d
probe reproduces the numbers exactly in debug (910400-byte store, 860 files,
warm ≈ 0.76 s vs. the claimed 0.756 s) and in release (910400 bytes,
warm 183 ms vs. the claimed 179 ms — same order of magnitude, within normal
machine noise). state.rs's renamed poisoned test
(a_poisoned_cache_record_is_dropped_and_the_index_is_a_fresh_scans) keeps
every one of its original premise checks (scanned.parsed == ["a.sv"],
scanned.cached.is_empty()) and adds the fingerprint-equality assertion the
fix requires — nothing was dropped in the rename, only the direction of the
final assertion changed, which is the whole point of the fix.
CLAUDE.md compliance. No unwrap()/expect()/panic!() outside
#[cfg(test)] in index_cache.rs or facts.rs (checked every occurrence,
including QA's own three new tests — all inside mod tests). Every pub
item in both files carries a one-line doc comment. No #[allow], no
unsafe, in either file. README sections (Goal, Assumptions,
Handshakes, Status / TODO, Work log, QA log, Review) each appear
exactly once, in order. FACTS_FORMAT is untouched at 1 — correctly:
nothing about what a record's facts field holds or how encode/decode
read it changed this round, only the store's own framing
(CACHE_FORMAT 1 → 2), which is the constant this round's change actually
belongs to.
Tests added this session (3, all passing, all in
crates/lucisv_server/src/index_cache.rs):
a_corrupted_checksum_field_drops_the_line_and_never_panics,
a_benign_reencoding_with_the_original_checksum_is_still_dropped,
two_writers_racing_the_empty_arm_leave_a_valid_store. cargo fmt --all
was run once after adding them to match this repo's formatting; no logic
changed by it.
Overall verdict: committable. All three original findings are fixed and
hold up against adversarial re-attack, including shapes beyond the ones
named in the brief (checksum-field corruption, the leading-zero
equivalent-bytes shape, and a genuinely concurrent two-writer Empty-arm
race). One sub-window of finding 2's already-accepted residue is a little
wider than written down — a torn read of a header write, not just a torn
write — but it is the same severity, the same self-healing story, and the
same reliance on small-write atomicity the rest of the round already trusts;
worth a documentation line, not a fix. No hard invariant is at risk anywhere
in this round.
Review
2026-08-27 — lead
Reviewed both rounds' diffs, work logs and QA logs; re-ran all gates
myself (2300 workspace tests, 0 failed; the real cache directories
never touched), clean. The main round's design earns its keep in three
places: FileFacts as the persistence unit means the cached and parsed
paths are literally one code path (add_facts), the no-mtime deviation
was measured and sound rather than asserted (the mtime "optimization"
would have been 6 ms and a save-path correctness hole), and the resume
is visible — cached: lines and the "(N from cache)" end message let the
owner watch a half-indexed workarea skip what it already did.
The fix round closed my three rulings exactly. The tampering vector is formally out of threat model — same-user disk, same posture as the formatter's cache — and the pinned reforged-record test is what keeps the per-record checksum from ever being mistaken for a MAC; what the checksum actually buys, everything accidental, is now total (0 of 583 truncation offsets cost more than the torn record; QA's leading-zero-reencoding construction turned up a structural strength). The race fix's 100/100 is structural, and QA's genuinely-concurrent Empty-arm test ran clean 15x. QA's re-check found one cousin residue (a torn header read misclassifying to Foreign) — added to the same Assumptions paragraph as its sibling, accepted for the same reasons. Filed and standing: word-table/include-graph caching (the remaining warm cost), cross-server locking, compaction growth. QA's own self-caught test-construction bug is exactly the epistemic hygiene this workflow is for. Accepted as shipped.