Files
lucioandClaude Fable 5 e4b1f55c12
ci / checks (push) Failing after 8s
ci / corpus (push) Failing after 5s
Persistent index cache: a half-indexed workarea resumes where it stopped
Owner-requested round. Every parsed file's FileFacts record is written
through to an index-cache store (append per file, atomic compaction at
scan end — a crash loses at most the file in flight), keyed by a
content hash that is the whole key: no mtime fast path, by measured
argument (6 ms of a 181 ms warm scan, and unsound against save-time
write-through). On reopen, hits skip parsing and the resume is
visible — cached: vs indexing: log lines, the bar counting through
hits, and an end message saying how many came from cache. Warm rescan
322 to 179 ms release, 1.5 s to 0.76 s debug; 910 KB store for the
860-file corpus. Location: lucisv.index.cachePath > the extension's
context.storageUri via initializationOptions (the one extension.js
change) > the OS cache dir keyed by workspace identity > nowhere;
lucisv.index.persist (default on) gates both directions immediately.

The cache is a performance artifact, never a correctness input, and
after the fix round that promise is total against everything but
intentional forgery — which the threat model now formally excludes
(same-user disk; a keyed MAC would be theater): a per-record checksum
drops every corrupt-but-parseable line (poisoned and reforged shapes
both pinned so the checksum is never mistaken for a MAC), first-writer
initialization is a create_new claim with structural 100/100 survival,
and a torn multi-byte tail costs exactly the torn record (0 of 583
offsets lose more). Old-format stores discard wholesale. Load==fresh
fingerprint equality swept over the corpus.

45 tests added across the main and fix rounds (dev 33+2, QA 9+3, one
QA test-construction bug self-caught), 2 ignored probes.

docs/features/index-persistence/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-27 16:33:52 -07:00
..

incremental-index

Goal

Until this round any change rebuilt the whole workspace index: a save of one file re-read, re-tokenized, re-parsed and re-analyzed every file in scope, rebuilt the completion tables and rebuilt the include graph. On the checked-in 860-file corpus that is 1.5 s of work, in a debug build, on every didSave. This round makes the common case what it should always have been — when exactly one in-scope file changed, only that file's contribution is replaced — under an invariant strong enough to make the shortcut safe: the index an update produces is the index a whole rebuild would have produced, byte for byte. The same round lands the two edge tables that were filed as Handshakes months apart and always wanted the same shape: who instantiates module M and who extends class C, recorded as the index is built. With them, callHierarchy/incomingCalls, textDocument/codeLens and typeHierarchy/subtypes stop walking the workspace on every request and become lookups — 92 ms → 0.26 ms for a whole file's code lenses, 82 ms → 0.71 ms for subtypes, measured below.

Assumptions

  • The equivalence invariant is the round. For any workspace W and any file F in it: build(W) and build(W \ F).update_file(F) are the same index — same FileIds, same disambiguation order, same unit and member tables, same edge tables, same per-file `define tables. Not "equivalent where anything looks", equal: WorkspaceIndex::fingerprint() renders every observable and the two fingerprints are compared directly. The same holds for remove_file, and for the two composed into a rename.
  • A FileId is a position in the path-sorted file list and nothing else, which is what it has always been. The brief allowed interning ids per path and retiring them, so that an insert or a remove would not renumber. That was considered and not done, and the reason is the invariant above. Interned ids differ between "a whole build" and "a build minus F, then F added back" — F would take the next free id rather than its sorted-position one — so the two histories could only be equivalent, never equal, and equality would have to be re-established observable by observable in every consumer that reads the numeral. Three do: find_define returns its hits in FileId order, candidates.rs iterates 0..files().len(), and the crate's own tests compare files(). Renumbering keeps the strongest statement available — the same index — and costs one merge pass over records already in memory, no file read and no file re-parsed. Disambiguation was already order-derived and still is: a name's declarations are pushed in one loop over the path-sorted per-file records, so the order is the path order, and the ids happen to agree with it because they are that same position. Nothing reads a FileId numeral to decide an order.
  • Ids do not survive an add or a remove, and nothing in the tree holds one across an update. The only place a FileId is stored is a Def inside a buffer's ExternalResolutions, and update_one refreshes every open buffer's overlay exactly as rebuild_index does. The server is single threaded and no update can interleave with a request.
  • The index keeps every file's contribution unmerged. FileFacts — the path, the define table, the file-scope declarations, the members, the instantiation edges and the inheritance edges — used to live only until IndexBuilder::finish and now lives in the index. (Since index-persistence, 2026-08-27 it also lives on disk: FileFacts is public, encodable and decodable, and a record put back through IndexBuilder::add_facts gives the index the file's parse would have.) That is what makes the restricted re-merge possible, and it is the round's honest memory cost: the same names and spans the merged tables hold, held once more, per file. No Semantics and no source text is retained, exactly as before.
  • The cheap path is "a file the index already holds", and everything else is a whole rebuild. A file appearing changes what other files' `includes resolve to, and answering that needs a walk; a file the index does not hold is also how a brand-new file gets in at all. So the gate is one membership test, and it is stated as such rather than guessed at per trigger.
  • A save carries no progress bar any more, and that is the visible protocol delta. The bar exists because a whole scan takes perceptible seconds; one file is one parse. No bar, no per-file log line, and no scope warnings — the last because warnings come from resolving the scope, and the scope was not re-resolved. Everything else a rebuild does after the scan still happens: the generation bump, the code-lens refresh, and a republish of every open buffer.
  • The republish stays wholesale. Every open buffer's diagnostics are computed against the index, so any of them may have moved; narrowing to "the buffers that could have changed" needs a cross-file dependency graph this server does not have. Filed, not guessed at.
  • The census is now as of the index, which is as of its last build or update. This is a real behaviour change and it is the one the round argues hardest for. hierarchy::callers_of_each and type_hierarchy::subtypes used to walk Workspace::sources() per request, which folds open buffers over disk — so a keystroke in another buffer moved a code-lens count before anything rebuilt. They read the index's edge tables now, and an index is only ever as of its last build or update. Both of those fold every open buffer in, so a save (or any rescan trigger) makes the edit count; a keystroke alone does not. In exchange the lens, the call hierarchy and every other index-shaped answer are consistent with each other by construction, and the census costs a lookup instead of a workspace walk. Pinned from both sides in an_edited_buffers_instantiation_counts_from_the_moment_the_index_sees_it and an_edited_buffers_extends_counts_from_the_moment_the_index_sees_it.
  • The census policies did not move, and could not have: the tables are built by the very walks the request handlers used to run. One Instantiation node is one site however many instances it declares; a generate for body is one site, not the elaborated four; both arms of an `ifdef are sites; matching is by the name as written; an instantiation at file scope is not an edge, because nothing calls it; a gate primitive names no module. Every one of lens.rs's QA tests passes unchanged, and the same policies are now pinned at the source of the numbers as well (the_instantiation_table_records_the_census_the_hierarchy_counts).
  • An edge's spans are as of the index; the ranges are as of the text now. Turning a recorded byte span into a line/character range needs the file's text, which is read fresh (open buffer beating disk, as always). For a buffer edited since the last update the two disagree — the same staleness item_in_file has carried since the hierarchy shipped, on the same files, for the same reason.
  • The include graph's one incremental limit is stated rather than papered over. IncludeGraph::update_file re-scans the changed file's own edges and re-learns the known-file and folded-spelling tables from the index's list; it does not re-resolve any other file's edges. For the case the server uses it in — one file's text changed, the file set did not — there is nothing stale at all. When the update is a removal, another file's `include of the removed file keeps its edge until the next whole rebuild. Named here because it is the only thing in this round that is not exactly a rebuild.
  • The completion word table is exact, and pays for it in memory. Candidates keeps a per-file word list and a per-word file count, so one file's words can be given back without re-lexing the other 859. Over the corpus that is ~40k Strings of per-file lists (QA measured 39,673 — the work log's original ~170k estimate was 4.3x high; ~1.38 MB) on top of the ~17k distinct words — single-digit megabytes, for the difference between "the word table is correct" and "the word table drifts until something rebuilds".

Handshakes

vlog_semantic — the index gains an incremental API and two edge tables

impl WorkspaceIndex {
    /// Insert or replace one file. Gives the index a whole build would have.
    pub fn update_file(&mut self, path: PathBuf, src: &str);
    /// Drop one file, reporting whether it was there.
    pub fn remove_file(&mut self, path: &Path) -> bool;
    /// Every observable, rendered — the equivalence witness.
    pub fn fingerprint(&self) -> String;

    pub fn instantiations_of(&self, name: &str) -> &[InstantiationEdge];
    pub fn subclasses_of(&self, name: &str) -> &[InheritanceEdge];
    pub fn instantiations(&self) -> impl Iterator<Item = (&str, &[InstantiationEdge])>;
    pub fn subclasses(&self) -> impl Iterator<Item = (&str, &[InheritanceEdge])>;
}

pub struct DeclSite { pub name: String, pub name_span: TextRange, pub span: TextRange }
pub struct InstantiationEdge { pub file: FileId, pub owner: DeclSite, pub site_span: TextRange }
pub struct InheritanceEdge { pub file: FileId, pub subclass: DeclSite }
  • InstantiationEdge carries the owner's whole DeclSite rather than just its name span, because that is what a CallHierarchyItem is: name is the item's name, name_span its selectionRange, span its range. The code-lens README's proposed shape asked for "(file, instantiating-module name span, instance site span)"; the extra two fields are what stopped callers_of_each needing to re-parse the file to find them.
  • IndexCounts gains instantiations and inheritances. Additive; every field is still public and every existing read still compiles.
  • Two modules were lifted into this crate, because the index now records what they find and a second copy of either walk would be free to drift from the one the request handlers use:
    • vlog_semantic::instantiations — moved verbatim from lucisv_server::instantiations. hierarchy.rs, lens.rs and inlay.rs import it from here now; its own tests moved with it.
    • vlog_semantic::classes — the class-declaration walk that was private to lucisv_server::type_hierarchy, plus extends_name. type_hierarchy.rs uses it and no longer has a copy.
  • IndexBuilder is unchanged in shape and still sorts in finish; finish is now merge(None) over the sorted records, which is the same loop update_file runs restricted to the affected keys. That is the equivalence proof: there is exactly one place any table's order is decided.

lucisv_server::state

  • Workspace::update_one(&mut self, path: &Path) -> bool — the incremental rescan for one file. false means "not a file this index holds; rebuild". It patches all four pieces of state a rebuild produces (index, completion tables, include graph, every open buffer's overlay) and is documented piece by piece at the function. Amended (index-persistence, 2026-08-27): it also writes the file's new record through to the on-disk index cache, using WorkspaceIndex::facts_for to take back the record the update just made rather than parsing anything twice. An hour of saves is an hour of work the next session does not repeat.
  • Workspace::update_one_checked is the #[cfg(test)] paranoid form: it runs the update, then rebuilds the whole workspace and asserts the two agree on the index's fingerprint and on the completion word table.

lucisv_server::candidates / includes

  • Candidates::update_file(index, path, text) / remove_file(index, path) and IncludeGraph::update_file(path, text, known) / remove_file(path, known). Both are the incremental forms of their build, and both are exact for the case update_one uses them in.

lucisv_server::watch

  • watch::one_scope_file(changes, filelist) -> Option<PathBuf> — the one file a watcher notification named, when it named exactly one and that one is not the filelist. The gate on the fast path for the watcher trigger.

lucisv_server::server

  • reindex_one(&mut self, path) -> bool, taken by didSave and by a one-file didChangeWatchedFiles, falling through to reindex() when it declines.

The fast-path trigger table

trigger path bar
didSave naming one file the index holds incremental none
didSave naming a file the index does not hold (a new file) whole rebuild yes
didChangeWatchedFiles naming one held source file incremental none
didChangeWatchedFiles naming two or more files (a checkout) whole rebuild yes
didChangeWatchedFiles naming the filelist whole rebuild yes
didChangeConfiguration moving exclude/filelist/maxFileSize/index.scope/index.scopeDepth whole rebuild yes
didOpen that widened the scope whole rebuild yes
didChangeWorkspaceFolders that moved the root set whole rebuild yes
didRenameFiles / didDeleteFiles whole rebuild yes

Pinned by the_fast_path_is_taken_for_one_held_file_and_for_nothing_else (rows 1–5 and the settings row) and by the tests the earlier rounds left on the remaining rows.

Derived state, and how each piece is patched

state what it reads on an incremental update
WorkspaceIndex.files / facts the file set one record replaced, inserted or removed
units, members every file's declarations the keys this file declared before or declares now, re-merged from the records in path order
instantiations, subclasses every file's edges same, keyed by instantiated module / base class
defines this file only replaced with the record
Candidates::units / macros the index alone re-derived from the (already updated) index
Candidates::words every file's tokens this file's words given back and its new ones taken, by per-word file count
IncludeGraph::edges this file's `includes re-scanned for this file; other files' left standing (see Assumptions)
IncludeGraph::known / folded the file set re-learned from index.files()
every open buffer's ExternalResolutions the index refreshed, as after a rebuild
the persistent index cache this file's new record written through, from the record update_file just made — no second parse (docs/features/index-persistence/README.md, 2026-08-27)
the diagnostics generation — bumped
the client's code lenses the index refresh requested

An add or a remove takes the whole merge rather than the restricted one, because every id after the change moves; it is still one pass over records in memory, with no file read and no file re-parsed.

Measured

Debug build, this Mac, the checked-in 860-file corpus, printed by the #[ignore]d probes (cargo test -p lucisv_server -- --ignored --nocapture).

before after
textDocument/codeLens, a three-module file 92 ms (one workspace walk, then a parse of every file mentioning a name) 0.26 ms
typeHierarchy/subtypes, core_ibex_base_test 82 ms (same shape) 0.71 ms
rescan after one file changed 1.50 s (whole rebuild) 33 ms (45×)

The "before" column for the two requests is measured in the same probe as the "after": Workspace::sources() is still there and still costs what it always did, so the row is one walk of the corpus against the lookup that replaced it, in the same process on the same run. The reindex row is the whole rebuild and the one-file update measured back to back over the same workspace.

The 33 ms is dominated by two things that are not the file: re-deriving the completion units/macros tables from the index (a workspace_symbols("") over ~12k members, sorted) and the merge pass over every file's records. Both are O(index), not O(files read), and neither parses anything. Making them O(change) is possible and was not done: 45× is the win that was asked for, and the next 3× is a bigger change to Candidates than this round should carry.

Status / TODO

  • WorkspaceIndex::update_file / remove_file, exact-equality equivalence with a whole build, pinned from six directions
  • WorkspaceIndex::fingerprint as the one equivalence witness, used by both crates' tests
  • Instantiation and inheritance edge tables, built by the walks the request handlers used to run
  • hierarchy::callers_of_each is a lookup; its sources() walk deleted
  • lens.rs counts through it unchanged; type_hierarchy::subtypes is a lookup
  • The census policies pinned at the source of the numbers as well as at the lens
  • Workspace::update_one patching index, completion tables, include graph and every open buffer's overlay
  • Server::reindex_one: no bar, no log, no scope warnings; generation bumped, lenses refreshed, every open buffer republished
  • The fast-path trigger table, pinned row by row
  • The paranoid corpus sweep: every mutation checked against a whole rebuild
  • The three inherited obligations from index-scope's Review
  • Not done, deliberately: no narrowing of the republish. A lint reads the index, so any open buffer's diagnostics may have moved; narrowing correctly needs a dependency graph this server does not have, and narrowing incorrectly is a stale red squiggle.
  • Not done, deliberately: no incremental path for a file appearing or vanishing without the index already holding it. It is a rebuild, it is rare, and the include graph's cross-file resolution is what makes it one.
  • Not done, deliberately: the index is not updated on didChange. A keystroke would cost a second parse and a second analysis of the buffer on top of the one Document::new already does, per keystroke, to make a count in another file fresher than the file on disk.
  • Filed, not done: Candidates::units/macros are re-derived whole on every incremental update. They are index-derived and correct; they are also most of the 33 ms.
  • Filed, not done: an incremental update cannot re-resolve another file's `include when a file is removed. See Assumptions.

Work log

2026-08-27 — dev agent (incremental single-file updates, the edge tables)

  • The FileId decision was the first one and it went against the brief, with the invariant as the argument. The brief asked for interned, retired ids so that an insert would not renumber. Interning makes ids stable but makes the two histories the round has to compare merely equivalent, and the brief's own acceptance test says to make the equivalence exact if anything observable reads the numeral — three things do. Renumbering keeps FileId meaning exactly what it has always meant (a position in the path-sorted list), makes the comparison a string equality on a fingerprint, and costs one merge pass over in-memory records. The stability interning would have bought is worth nothing here: the only FileIds that outlive a call are the ones in each buffer's overlay, and those are refreshed by the update itself.
  • The merge is the equivalence proof, not a test of it. IndexBuilder::finish and WorkspaceIndex::update_file both end in one function, merge, which loops over the path-sorted per-file records pushing what it meets. merge(None) rebuilds every table; merge(Some(affected)) clears and refills only the keys the changed file could have moved. Same loop, same order, so a restricted merge and a whole one cannot disagree — there is nowhere for them to disagree. That is why the round could afford to keep the per-file records rather than invent a patching scheme with its own ordering rules.
  • The affected set is coarse on purpose. members is keyed by unit and the affected set names units, not (unit, member) pairs: rebuilding one whole package's member sub-table is a handful of entries, and a finer key would be a second ordering rule to keep honest.
  • Two walks were lifted into vlog_semantic rather than copied. The instantiation census is what lens.rs's QA tests pin, so a second copy of that walk inside the index would have been licence for the numbers to drift. instantiations.rs moved whole (its tests with it) and type_hierarchy's private class walk became classes.rs. Both moves are mechanical; the census policies are now a property of one function each.
  • The unsaved-buffer census delta is the round's one behaviour loss and it is argued rather than hidden. Two tests pinned "a just-typed instantiation in another buffer counts": they were the walk's own freshness, not a policy, and they cannot survive a table built at index time. Both are rewritten in the house style under // Superseded this round: to pin the new rule from both sides — the buffer alone moves nothing, and the update moves it. The three alternatives were considered and rejected in the README's Assumptions: a per-keystroke index update (a second parse and analysis per keystroke), an edges-only per-keystroke update (breaks the equivalence invariant outright — edges from the buffer, declarations from disk, an index equal to no build at all), and a live overlay of dirty buffers over the table (needs dirty tracking the server does not do).
  • Eight progress tests changed, all for the same one reason and none of them weakened. A save is the trigger those tests reached for when they needed a rescan, and a save is exactly what stops being one. Each now uses a trigger that really does rescan — two files in one watcher event, or a settings change — and keeps its own subject (the bar goes up and comes down, the bar is down before the republish, the refresh rides after it, three outstanding requests answer by id). a_save_puts_a_bar_up_and_takes_it_down_again was renamed to name the trigger it now uses, and the property it used to carry — that a save reports itself — is replaced by a_one_file_save_costs_no_bar_and_no_log_line, which is the new rule.
  • One lens test's assertion was superseded, and its replacement is stronger. code_lenses_for_a_whole_file_cost_about_one_workspace_walk asserted whole_file < one_name * 2 — "the batch is one walk, not one per module". There is no walk; both sides are microseconds dominated by one file read each, so the ratio pins noise. It now asserts what the round actually bought: a whole file's lenses cost less than a tenth of one workspace walk, measured in the same loop.
  • The e2e progress transcript lost a bar, which is the model becoming visible on the wire again: startup (empty scope, 0 files indexed), the widening didOpen (1 file indexed), and then a save that reports nothing because it is one parse.
  • The three inherited obligations are pinned as permanent tests, in state.rs beside the scope tests they belong with: lowering scopeDepth narrows the index on the next rescan (the settings axis moves both ways, unlike the open axis); a filelist appearing mid-session flips the ladder to rung 1 and changes what is indexed, with the open buffer still overlaid; and a buffer opened outside every root rides the folder rung like a rootless one, its own directory at depth 0 and / at depth 99.
  • Files touched: crates/vlog_semantic/src/workspace.rs, crates/vlog_semantic/src/lib.rs, crates/vlog_semantic/src/instantiations.rs (moved in), crates/vlog_semantic/src/classes.rs (new), crates/vlog_semantic/tests/workspace.rs, crates/lucisv_server/src/{state,server,hierarchy,lens,type_hierarchy,inlay,candidates,includes,watch,main}.rs, crates/lucisv_server/tests/e2e.rs, TODO.md, docs/features/{code-lens,type-hierarchy,hierarchy,workspace-index,lucisv-server,indexing-ux,work-done-progress,file-watching}/README.md, this README. No new dependency, no version bump, no docs/site/, no commits.

Verification. cargo fmt --all -- --check: clean. cargo clippy --all-targets --workspace: zero warnings. cargo test --workspace: 2244 passed, 0 failed, 8 ignored — measured against a clean HEAD worktree's 2217 passed, 5 ignored, so 27 new passing tests and 3 new #[ignore]d probes, with 2 superseded in place and 1 renamed. cargo test -p vlog_formatter: 180 passed across its seven binaries (114 of them verification.rs), untouched — verify.rs never appears in this round's diff. cargo build && node editors/vscode/smoke.js target/debug/lucisv-server: smoke: OK.

The 30 new tests, and what each is for:

test pins
adding_a_file_gives_the_index_a_whole_build_would_have (vlog_semantic) the hard direction: the new file sorts first, so every later id and every table naming one moves
replacing_a_file_touches_only_what_that_file_said (vlog_semantic) the restricted merge: the other file's edge survives, the replaced file's does not
removing_a_file_gives_the_index_a_whole_build_would_have (vlog_semantic) removal, renumbering down, edges going with the file, removing twice
removing_a_file_moves_the_disambiguation_winner (vlog_semantic) the sharpest derived answer: the file that won a duplicate name is the file that goes
a_file_that_redefines_a_name_another_file_declares_lands_in_path_order (vlog_semantic) insertion into a table that already holds the other file's copy, both directions
a_rename_is_a_remove_and_an_add_and_lands_where_a_build_would_put_it (vlog_semantic) the rename-shaped sequence
an_update_survives_every_degenerate_file_there_is (vlog_semantic) empty, whitespace, not-Verilog, does-not-lex, comment-only; and an empty index
a_full_build_and_a_build_minus_one_plus_that_one_are_the_same_index (vlog_semantic) the headline invariant, over a six-file fixture, with every file taken out and put back
the_instantiation_table_records_the_census_the_hierarchy_counts (vlog_semantic) every census policy at the source of the numbers, plus the spans a hierarchy item is built from
the_inheritance_table_records_every_class_that_names_a_base (vlog_semantic) file order, a parameterized base, a class in a package, a class in a module, the counts
the_edge_tables_are_empty_for_a_workspace_with_no_edges (vlog_semantic) the degenerate lookups, and a default index
only_a_file_the_index_already_holds_takes_the_incremental_path (state) the gate, from four sides, including a file that becomes held
one_files_edit_reaches_every_table_the_index_answers_from (state) declaration, instantiation edge, inheritance edge, completion word, include edge — all five in one update
a_file_the_cap_or_the_disk_takes_away_leaves_the_index (state) removal through update_one: deleted on disk, and grown past the cap
an_open_buffer_beats_disk_on_the_incremental_path_too (state) collect_sources's precedence, for one file
the_incremental_update_agrees_with_a_whole_rebuild_over_the_real_corpus (state) the paranoid sweep: 172 real files, 6 mutated five ways, every one checked against a whole rebuild
lowering_the_scope_depth_narrows_the_index_on_the_next_rescan (state) inherited obligation (a)
a_filelist_appearing_mid_session_flips_the_ladder_to_rung_one (state) inherited obligation (b), on the index's content and not just the rescan
a_buffer_opened_outside_every_root_rides_the_folder_rung_like_a_rootless_one (state) inherited obligation (c), at depth 0 and at depth 99
qa_perf_one_file_against_the_whole_rebuild (state, #[ignore]) the 45×
the_fast_path_is_taken_for_one_held_file_and_for_nothing_else (server) the trigger table, five rows
a_one_file_save_still_bumps_the_generation_and_refreshes_the_lenses (server) what the fast path keeps
a_one_file_save_costs_no_bar_and_no_log_line (server) what it drops
a_one_file_save_answers_from_the_file_it_saved (server) the edit reaches the index and the rest of the workspace is untouched
a_whole_rescan_puts_a_bar_up_and_takes_it_down_again (server, renamed) the bar's own rule, on a trigger that still rescans
qa_perf_lens_lookup_against_the_walk_it_replaced (lens, #[ignore]) 0.26 ms against 92 ms
qa_perf_subtypes_lookup_against_the_walk_it_replaced (type_hierarchy, #[ignore]) 0.71 ms against 82 ms
a_save_of_one_file_updates_the_index_over_the_wire (e2e) the real binary: the save moves the definition answer, and the untouched file answers exactly what it did
a_class_is_found_wherever_it_may_be_written, a_parameterized_base_names_the_bare_class, a_declarations_extent_contains_its_own_name (vlog_semantic classes) the lifted walk, in its new home

Two tests were superseded in place and are named in the work log above: an_unsaved_instantiation_is_a_caller_before_it_is_saved and an_unsaved_extends_is_a_subtype_before_it_is_saved, both replaced by the …counts_from_the_moment_the_index_sees_it form; and code_lenses_for_a_whole_file_cost_about_one_workspace_walk was renamed and given the stronger assertion.

QA log

2026-08-27 — QA agent (equivalence attack pass)

Verdict up front: committable as-is. No production-code defect found under any constructed attack. One documentation-accuracy finding (LOW, non-blocking) in the Assumptions section's memory estimate. Nine new tests added, all passing, none exposing a bug — they pin behavior that was correct but unverified against the specific adversarial shapes below.

Gates, re-run from a clean state (before adding anything): cargo fmt --all -- --check clean. cargo clippy --all-targets --workspace zero warnings. cargo test --workspace: 2244 passed, 0 failed, 8 ignored — matches the dev's own count exactly. cargo test -p vlog_formatter: 180 passed across seven binaries (114 verification.rs) — verify.rs does not appear anywhere in git diff 7266b13 (git diff --name-only | grep verify: empty). cargo build && node editors/vscode/smoke.js target/debug/lucisv-server: smoke: OK. After adding the tests below, cargo test --workspace: 2253 passed, 0 failed, 8 ignored (2244 + 9 new), fmt and clippy still clean.

1. The ghost hunt and the affected-keys verdict — verified clean. WorkspaceIndex::update_file's Ok(at) arm computes affected as Affected::of(&self.facts[at]) (the old record's names) then affected.add(&facts) (the new record's names) — a union of both sides, read directly at crates/vlog_semantic/src/workspace.rs:311-315. That is the side that matters: a name only the old record declared is still in the cleared set even though the new record no longer supplies it, so merge's self.units.remove(name) followed by a full re-scan of every file's current facts (not just the changed one, workspace.rs:422-460) leaves nothing behind for it — no stale one-entry Vec survives. Constructed the exact ghost explicitly: a_name_only_one_file_declared_leaves_no_ghost_when_that_file_stops_declaring_it (vlog_semantic tests/workspace.rs) — a file that is the sole declarer of solo stops declaring it; units("solo") comes back empty and the fingerprint matches a fresh build. Passes. The same union covers edge-table keys too: Affected::add extends modules from facts.instantiations and bases from facts.subclasses (workspace.rs:487-489), so a file that stops instantiating M shrinks M's table the same way — already covered by the dev's own replacing_a_file_touches_only_what_that_file_said, re-verified here by re-running it and by the new sequence test below.

2. Byte-identical histories, adversarially — six new tests, all pass (crates/vlog_semantic/tests/workspace.rs):

  • a_long_interleaved_sequence_matches_a_fresh_build_at_every_step — update A, update B, remove A, re-add A, update B again, fingerprint-checked after every step (not just at the end, which would miss a bug that only shows two steps later).
  • a_name_only_one_file_declared_leaves_no_ghost_when_that_file_stops_declaring_it — the ghost hunt above.
  • adding_a_new_file_that_duplicates_an_existing_name_lands_by_path_order_either_direction — the dev's own duplicate-name test only attacks the restricted-merge (Ok(at)) arm; this attacks the whole-merge (Err(at), brand-new file) arm, both sort directions.
  • find_define_answers_in_current_file_id_order_after_cross_file_updates — `define/ `undef shadowing across files, then a renumbering add, then the answer re-checked in the new id order.
  • updating_a_file_to_empty_text_differs_from_removing_it — confirmed different, deliberately: update_file(path, "") keeps the file's FileId slot (still a file, contributing nothing); remove_file drops the slot and renumbers everything after it. Not pinned anywhere else in the round's own tests, so pinned here.
  • same_named_files_in_different_directories_updated_alternately_stay_correct — two files named defs.sv in different directories, updated A then B then A again, fingerprint-checked at each step (identity is the path, binary_search_by compares PathBufs, never the filename alone).

3. The moved walks — verbatim, confirmed byte-for-byte. diff of crates/lucisv_server/src/instantiations.rs (at 7266b13) against crates/vlog_semantic/src/instantiations.rs: the only changes are added doc comments (the "Lifted from..." note and two new one-line field docs); every line of code, every test, is identical. classes.rs is new but its three functions (declarations, collect, extends_name) are line-for-line identical to the private walk type_hierarchy.rs used to carry (compared directly against git show 7266b13:crates/lucisv_server/src/type_hierarchy.rs lines 141-274). hierarchy::callers_of_each and type_hierarchy::subtypes were rewritten (not moved) to read the new edge tables instead of walking Workspace::sources(); read both in full. The file-grouping subtypes and callers_in rely on ("edges arrive in file order, so one file's are consecutive") holds by construction: merge always fully clears and rebuilds an affected key's whole vector by iterating self.facts in ascending FileId order (never appends to a partial vector across separate merges), so the grouping invariant cannot be violated by any sequence of incremental updates, not just the initial build. Re-ran lens.rs's QA policy tests and the_instantiation_table_records_the_census_the_hierarchy_counts / the_inheritance_table_records_every_class_that_names_a_base — unchanged, passing. git diff --stat on hierarchy.rs/type_hierarchy.rs/lens.rs test bodies: exactly the two superseded freshness tests (an_unsaved_instantiation_is_a_caller_before_it_is_saved → an_edited_buffers_instantiation_counts_from_the_moment_the_index_sees_it, and the extends equivalent) plus the renamed/strengthened lens ratio test (code_lenses_for_a_whole_file_cost_about_one_workspace_walk → ..._a_fraction_of_a_workspace_walk) and one doc-comment-only touch on qa_perf_worst_case_common_word_module_name (no logic change). Each supersession keeps the original point per house style: both rewritten tests assert the buffer alone does not move the count and then that ws.update_one(path) does — the same "unsaved edit is visible" property the old tests pinned, restated for a table that is index-fresh rather than per-request-fresh.

4. Candidates::words exact bookkeeping — two new tests, both pass (crates/lucisv_server/src/candidates.rs): a_shared_word_dropped_from_one_file_is_still_offered_by_the_other and updating_the_same_file_twice_in_a_row_never_double_counts_or_goes_negative. Read set_words (candidates.rs:78-99): it removes the previous call's words for this path before counting the new ones, so calling it twice in a row for the same path decrements based on the first call's own words, never double-decrements, and never underflows.

5. The freshness delta's edges — verified against the code, not just the docs. hover::narrowed_to_the_include_graph (hover.rs:84-105) is the concrete case: candidates come from find_define, which only ever enumerates files the index currently holds, while reachable comes from includes::reachable_from, whose first hop is resolved live off the buffer's own current text (includes.rs:344-350, "resolved against the buffer's current text rather than looked up in the graph") — buffer-fresh — before walking the rest of the graph via the index-fresh IncludeGraph::edges. The docs (code-lens, hierarchy, type-hierarchy READMEs, and this feature's own Assumptions) consistently say which surfaces are index-fresh (lens counts, incomingCalls, subtypes) versus buffer-fresh (an include's own first hop, go-to-definition, document links) — no surface was found mismarked.

6. Fast-path discipline.

  • Two saves in one batch: added two_saves_of_different_held_files_in_one_batch_are_two_incremental_updates (server.rs). process_batch handles one message at a time (for message in batch, server.rs:316), so two didSaves in one burst are two independent incremental updates, not coalesced and not a full rebuild — confirmed: no progress bar, both files' edits land, generation bumps by 4 (2 saves × 2 bumps each — set_document bumps once for the buffer's own new text, reindex_one bumps once more for the fast path; these are orthogonal and both fire per save, which the test now pins explicitly since it was not obvious from the docs alone).
  • Generation bump / lens refresh / resultId: reindex_one bumps generation exactly once and calls refresh_code_lenses() exactly once (server.rs:1365-1374), pinned by the dev's own a_one_file_save_still_bumps_the_generation_and_refreshes_the_lenses. result_id() is self.generation.to_string() (server.rs:1024-1025), so a fast-path update does move a pull-diagnostics client's resultId — no new test needed, it follows directly from the generation bump. No-bar/no-log: pinned by a_one_file_save_costs_no_bar_and_no_log_line, re-run, passing.
  • A save during another operation: the server is single-threaded and process_batch runs to completion before the next receive, so there is no interleaving to attack — matches the dev's own note.
  • A file whose path is held but which is the filelist: not reachable in practice — a filelist is a .f/similar file, never a .sv/.v/.svh source, so it is never a member of self.index.files() and Workspace::update_one's gate (state.rs:36) returns false for it regardless of the watcher-side one_scope_file exclusion (watch.rs:27-38) — the two gates agree by construction rather than by coincidence, so no separate test was added for this shape.

7. The include-graph gap — severity-checked, confirmed LOW/harmless (dangling, not wrong). Traced every consumer of IncludeGraph::edges: only reachable/reachable_from read it (document_links/definition resolve live off disk via resolved(), never consulting self.edges). After a file B is removed, another file A's stale forward-edge to B can make reachable(A) include B's now-dangling path — but B has no FileId in the index any more, so hover::narrowed_to_the_include_graph's filter (ws.index().path(*file).is_some_and(|p| reachable.contains(p))) can never match a candidate against that ghost path, because no surviving file's current path can equal a path the index no longer assigns to anyone. The answer is a superset that can only ever be harmlessly too permissive, never one that manufactures a wrong single-file narrowing. It self-heals the moment A itself is next incrementally updated (IncludeGraph::update_file re-resolves A's own edges fresh off disk). No test added — this is a reachability argument about aliasing that a unit test would have to special-case anyway; recorded here for the record instead.

8. Perf and memory claims — spot-reproduced, one discrepancy found. Reproduced all three timing claims on this machine, same corpus, debug build: qa_perf_one_file_against_the_whole_rebuild: 1.517 s → 33.8 ms (45×, matches the README's 1.50 s → 33 ms exactly). qa_perf_lens_lookup_against_the_walk_it_replaced: 67.1 ms → 0.297 ms (README: 92 ms → 0.26 ms — same order of magnitude, machine variance accounts for the rest). qa_perf_subtypes_lookup_against_the_walk_it_replaced: 66.9 ms → 0.720 ms (README: 82 ms → 0.71 ms — very close). All three: verified clean.

Finding (LOW, documentation accuracy, non-blocking). The Assumptions section's memory estimate for Candidates::per_file — "Over the corpus that is ~170k Strings of per-file lists on top of the ~17k distinct words — single-digit megabytes" — was checked against the real corpus with a scratch probe (Candidates::build over all 860 corpus files, then per_file.values().map(Vec::len).sum() and a byte estimate from String::capacity(); probe not kept, reproducible in one line from a REPL-ish test). Measured: 16,750 distinct words (matches the "~17k" half of the claim) but 39,673 per-file word entries — about 4.3× lower than the claimed "~170k" — and ~1.38 MB of per-file String storage, itself well under "single-digit megabytes." The conclusion ("single-digit megabytes," i.e. the design is memory-cheap enough) is not undermined — if anything the real number is more favorable than claimed — but the specific "~170k" figure in the Assumptions section does not match reality and is not pinned by any test in the round. Not blocking; worth a one-line correction next time this README is touched.

9. CLAUDE.md compliance. No unwrap()/expect()/panic! in library code in any touched file, checked by grepping each file up to its own #[cfg(test)] module (workspace.rs, instantiations.rs, classes.rs, state.rs, candidates.rs, includes.rs, server.rs, watch.rs, hierarchy.rs, type_hierarchy.rs, lens.rs) — zero matches in all eleven. No unsafe anywhere in the diff. This README has all seven required sections, each exactly once (plus three extra ones the format allows: the fast-path trigger table, the derived-state table, Measured). verify.rs does not appear in the diff at all. Every corpus-dependent test checked is skip-guarded (if !corpus.is_dir() { ...; return; }). TODO.md's completed items are struck through with the original text kept and a note appended, matching the project's existing convention for closing an item without deleting it. docs/site/ diff is empty — untouched, as required. Spot-checked the struck Handshakes in code-lens and hierarchy READMEs against the actual code (instantiations_of/subclasses_of signatures, the lifted vlog_semantic::instantiations/classes modules) — accurate.

Fixes made: none to production code — every constructed attack passed. Tests added (9, all passing): the six vlog_semantic tests and two candidates.rs tests listed above, plus two_saves_of_different_held_files_in_one_batch_are_two_incremental_updates in server.rs.

Review

2026-08-27 — lead

Reviewed the diff, the work log and the QA log; re-ran all gates myself (2253 workspace tests, 0 failed), clean. The round's deviation was better than my brief: keeping FileIds as sorted positions and paying one in-memory merge per update buys byte-identical histories — the strongest equivalence there is — where my interned-ids design would have bought mere observational equivalence plus three consumers to audit forever. The structural argument (finish and update_file ending in the one merge over path-sorted records) is the same one-implementation discipline this codebase now uses everywhere, and QA's ghost hunt confirmed the affected-keys union reads both the old and new records, which is the single place the design could have silently rotted. The moved census walks are byte-for-byte verbatim, the policy numbers stand, and the freshness delta — counts as of the index, not of unsaved keystrokes — is the right trade, pinned from both sides.

The measured wins close two of the audit's oldest filed Handshakes with a 350x lens speedup and a 45x one-file rescan, on top of the scope round's narrowing — together these are the large-workarea story the owner asked for. QA's nine adversarial tests (the long sequences, define shadowing across renumbering, burst double-saves) are permanent. I corrected the one LOW finding (the per-file word-list estimate, 4.3x high; the conclusion stood). The three filed leftovers (wholesale republish, Candidates re-derivation cost, the include removal edge) are honest and none blocks. Accepted as shipped.