Files
lucioandClaude Fable 5 5e4aa7bd6f Incremental indexing + the edge tables: one file changed, one file merged
Owner-requested round. WorkspaceIndex::update_file/remove_file replace
one file's contribution without reading or parsing anything else;
Server::reindex_one takes the fast path for a didSave of one held file
or a one-file watcher event (33 ms vs 1.5 s on the corpus, 45x), with
everything else — settings, scope, filelist, multi-file events —
keeping the full rebuild, pinned by a trigger-table test. FileIds stay
sorted positions by deliberate deviation: renumbering through the one
merge both finish and update_file end in makes build(W) byte-identical
to build(W minus F).update_file(F) — fingerprint equality, attacked by
QA across long interleaved sequences, disambiguation flips, define
shadowing and the ghost hunt (the affected-keys union reads old and
new records both). The per-file FileFacts the index retains are the
documented memory cost (~1.4 MB on the corpus).

The two oldest filed Handshakes land: instantiation and inheritance
edge tables, built by the byte-for-byte moved census walks, turn
codeLens counts (92 ms to 0.26 ms), incomingCalls and typeHierarchy
subtypes into lookups — census policies pinned unchanged at both the
consumers and now the source. Counts are as of the index, not of
unsaved keystrokes: the freshness delta is documented and pinned from
both sides. Saves no longer raise a progress bar; generation and lens
refresh still ride. Round 18's three inherited scope obligations are
pinned permanent.

36 tests added (dev 27 + QA 9). Left open, filed: wholesale republish,
Candidates re-derivation cost, incremental removal vs include
re-resolution.

docs/features/incremental-index/README.md

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

work-done-progress

Goal

A workspace rescan is the one thing this server does that a user can feel. Server::reindex() is a synchronous full re-walk of the roots — 0.68 s for the 860-file corpus, seconds for a real filelist — and it runs on every save, on every watched-file notification, and whenever lucisv.exclude/lucisv.filelist changes. Until now it happened in total silence: the editor's status bar said nothing, the server simply stopped answering for a while, and a user with a large project had no way to tell a slow index from a hung server. This round wraps every rescan — the startup build included — in server-initiated work-done progress: one window/workDoneProgress/create, one $/progress begin, the scan, one $/progress end naming the file count. Gated on the client's own window.workDoneProgress capability, because the spec forbids creating progress a client never asked for (TODO.md §9b).

Amended (incremental-index, 2026-08-27): a save is no longer a rescan. When a trigger names exactly one file the index already holds — a didSave, a one-file watcher event — only that file's contribution is replaced, in ~33 ms over the corpus, and no bar goes up: the bar exists because a whole scan takes perceptible seconds, and one parse is not something a user can feel. Every whole rescan below is unchanged, and a save of a file the index does not hold is still one of them. The tests that used a save as their rescan trigger now use one that still rescans; see docs/features/incremental-index/README.md.

Assumptions

  • window.workDoneProgress is the gate, and there is no fallback. A client that did not advertise it is sent no create and no $/progress — not a degraded bar, not a showMessage. The spec is explicit that a server may only initiate progress against a client that asked; and a popup per save would be worse than the silence it replaced.
  • begin is sent without waiting for the create's answer. The spec permits it ("the server is allowed to report progress before the create request is answered"), and here it is not merely permitted but necessary: the rescan blocks the single-threaded loop the moment begin_indexing returns, so waiting for the answer would mean the loop never processes it and the bar appears only after the work it describes is over. A client that errors the create is required to ignore the $/progress notifications carrying that token, so the worst case is a client that renders nothing — which is exactly what it rendered before this feature existed.
  • The create's answer is ignored. It goes through Server::response's existing "not in the applying map, fall through" path, the same one the file-watcher (un)registrations use. Nothing is retried and nothing is remembered: the ids are minted from the one shared request_ids counter, so a progress answer can never be mistaken for an applyEdit answer.
  • No percentage, and no intermediate report. Superseded 2026-08-27 by docs/features/indexing-ux/README.md. The original reasoning stands as written and is kept here: Workspace::rebuild_index was one opaque call — it walked the roots, read every file, built the index, the completion tables and the include graph, and returned — so there was no progress to observe, and an invented percentage ("it is probably about half done") would have been a lie the user learned to distrust. The indeterminate bar was the honest shape for a build nobody could see inside. What changed is the premise, not the principle: vlog_semantic now exposes IndexBuilder/index_order, rebuild_index_with drives that loop, and the bar reports n/total file.sv with a percentage that is counted, not guessed. The begin still carries no percentage — the first honest one is the first file's — and the completion tables and include graph, which are still built opaquely after the index, are still outside the count.
  • The end message is the index's own file count, read from WorkspaceIndex::files().len() after the scan. That number was already public and already computed; nothing was plumbed to obtain it. It counts the files the index was built from — in-scope files that read successfully, with open buffers overriding disk — which is what "indexed" means everywhere else in this server.
  • The bar covers the scan, not the republish. end is sent the instant rebuild_index returns, before report_scope's warnings and before the per-buffer republishes that follow. Either order is defensible; this one is pinned by a test (the_bar_is_down_before_the_republish) because the bar names the scan, and the republish is per-open-buffer work the user already pays on every keystroke without a bar.
  • The startup build gets a bar too, and that is legal. Server::new runs after main's initialize_finish, which returns only once the client's initialized notification has arrived — the same fact that makes the existing watcher registration legal there, and it is already stated in that code's comment. So the first index build, which is the slowest of the session, is wrapped like every other. Determined by reading main.rs:59-79 and server.rs's Server::new, not assumed.
  • No cancellation. cancellable: Some(false) is stated rather than left unset: the loop is one thread, a rescan runs to completion, and there is no window/workDoneProgress/cancel handler. A cancel button the user could press and that did nothing would be worse than no button.
  • One bar at a time, in practice. The loop is synchronous, so a rescan cannot overlap another rescan; every begin is followed by its own end before the next begin can be minted. The token counter guarantees uniqueness regardless.

Handshakes

lucisv_server::server

  • ClientAbilities gains work_done_progress: bool, filled by main.rs from InitializeParams.capabilities.window.work_done_progress (absent → false), in the style of the three fields already there. Every existing test that builds ClientAbilities { ..Default::default() } is unaffected.
  • Server gains indexings: u32 — the progress-token counter. It is deliberately not the request-id counter: a token is not a request id, and lucisv-index-3 reads as the fourth rescan rather than as an unrelated ordinal.
  • Two new private methods, begin_indexing() -> Option<ProgressToken> and end_indexing(Option<ProgressToken>), plus a one-line progress() sender. None is the whole of the "this client cannot show a bar" path, so neither caller branches on the ability itself.
  • Server::new is restructured: the Server is built around a Workspace::default() and open_roots is then called through it, so the startup build can sit between a begin_indexing/end_indexing pair. Same work, same order relative to report_scope and register_watchers.
  • Server::response's doc comment now names three things asked of the client rather than two. Its code is unchanged — the create's answer already fell through the applying lookup.

state::Workspace, and every engine crate

Untouched. The file count comes from Workspace::index() and WorkspaceIndex::files(), both of which were already public and already called from this crate. No signature moved, rebuild_index still returns just its scope warnings, and nothing was plumbed for the sake of the end message.

editors/vscode

No extension change. vscode-languageclient advertises window.workDoneProgress itself and renders server-initiated progress in the status bar with no help from extension.js. smoke.js sends capabilities: {}, so it takes the no-progress path and passes untouched — verified by running it.

Status / TODO

  • window.workDoneProgress read into ClientAbilities at initialize
  • begin_indexing/end_indexing around rebuild_index() in reindex()
  • The startup index build wrapped in the same pair (legal: Server::new runs after initialize_finish)
  • A fresh lucisv-index-N token per rescan, never reused
  • end carries the indexed file count, singular and plural
  • A client without the capability is sent zero progress messages
  • The create's answer stays ignored and cannot disturb applyEdit routing
  • Tests: 8 unit (7 in server.rs, 1 in main.rs), 2 e2e over the wire
  • TODO.md §9b checkbox, docs/features/lucisv-server/README.md staleness section
  • Superseded 2026-08-27: the "no percentage, no report" line above. The counting reports, the size cap and the per-file log are docs/features/indexing-ux/README.md; the create/begin/end skeleton, the capability gate, the token scheme and the ordering against the republish are all unchanged by it.
  • Not done, deliberately: no $/progress on anything else. Formatting, a rename across the workspace and callHierarchy/incomingCalls are the other candidates; all three are request-scoped, so they would use the client-supplied workDoneToken rather than a created one, which is a different mechanism with a different gate. Filed here, not built.
  • Not done, deliberately: no window/workDoneProgress/cancel handler. There is nothing in this server to cancel — see Assumptions.

Work log

2026-08-26 — dev agent, §9b

  • Read the code before deciding about the startup build, as the brief asked. main.rs calls connection.initialize_finish(...) on line 74 and Server::new(...) on line 76, and initialize_finish returns only after the client's initialized notification has been received and consumed. So the startup build happens at a moment when server-initiated requests are legal — the existing register_watchers() call in Server::new already relies on exactly that, and says so in a comment. Verdict: wrapped. It is the slowest rescan of the session and the one most worth a bar.
  • The one structural change is in Server::new: the struct is now built first and open_roots called through it, because begin_indexing needs &mut self. Nothing else about that function moved — report_scope still runs on the warnings open_roots returned, and register_watchers still runs last.
  • Option<ProgressToken> is the ability check. begin_indexing returns None for a client that cannot show a bar and end_indexing returns on None, so neither reindex nor Server::new mentions the capability. That also makes "a bar that went up came down" structural rather than a discipline: there is exactly one value that ends it and exactly one place it is produced.
  • Tokens are strings, lucisv-index-N, off their own counter. A number token would collide conceptually with the lucisv-N request ids in a log, and the string says what the bar is for. The counter starts at the startup build, so lucisv-index-0 is always the first index and the first save is always lucisv-index-1 — pinned by tests at both the unit and the wire level.
  • The end message reads WorkspaceIndex::files().len(), which was already public and already reachable through Workspace::index(). The brief's fallback ("end with no message if no count is cheaply available") was not needed; nothing was plumbed. The singular case has its own assertion, because "1 files indexed" is the kind of thing that ships.
  • report_scope still shows its popup after the bar comes down. A filelist warning and a progress bar are unrelated; sequencing them the other way would have meant holding the bar up across a modal in some clients.
  • Files touched: crates/lucisv_server/src/server.rs, crates/lucisv_server/src/main.rs, crates/lucisv_server/tests/e2e.rs, TODO.md, docs/features/lucisv-server/README.md, this README. No engine crate, no editors/, no new dependency, no version bump.

Verification. cargo fmt --all -- --check: clean. cargo clippy --all-targets: zero warnings. cargo test --workspace: 1812 passed, 0 failed (1802 on HEAD, measured — 7 new unit tests in server.rs, 1 in main.rs, 2 new e2e sessions). cargo build && node editors/vscode/smoke.js target/debug/lucisv-server: OK, exit 0. No commits.

The ten tests, and what each is for:

test pins
the_startup_index_build_runs_under_the_first_bar the startup determination above, as observable traffic
a_whole_rescan_puts_a_bar_up_and_takes_it_down_again (was a_save_puts_a_bar_up_and_takes_it_down_again, 2026-08-27) create → begin → end, one token, on a trigger that still rescans
the_bar_says_how_many_files_were_indexed the end message, plural and singular
the_bar_is_down_before_the_republish the documented ordering against publishDiagnostics
a_client_that_did_not_ask_for_a_bar_is_sent_no_progress_at_all zero messages of any kind, at startup and on save
every_rescan_path_gets_its_own_bar_and_its_own_token the watched-file and config-change paths, three distinct tokens, no leaked begin, no report
a_progress_create_answer_is_ignored_and_never_disturbs_an_apply_edit an Ok and an Err create answer arriving between an applyEdit push and its answer; the refusal still reported exactly once
work_done_progress_support_is_read_from_the_clients_own_capabilities (main.rs) absent/false/true, and no panic on InitializeParams::default()
indexing_reports_its_progress_over_the_wire + a_client_that_never_asked_for_progress_is_sent_none_over_the_wire (e2e) the whole sequence against the real binary, both gate states, including title, cancellable: false and the absence of percentage

QA log

2026-08-26 — QA agent, §9b

Gates re-run, on the working tree as handed off (commit 00c03ec + uncommitted): cargo fmt --all -- --check clean. cargo clippy --all-targets --workspace zero warnings. cargo test --workspace: 1812 passed, 0 failed — matches the dev log exactly. cargo build && node editors/vscode/smoke.js target/debug/lucisv-server: smoke: OK. After the four tests added below: 1816 passed, 0 failed, gates re-checked and still clean.

Per attack surface (lead's numbering):

  1. Server::new restructuring — verified clean, structurally rather than just empirically. Workspace::default() then open_roots(roots) is the same value undergoing the same two operations in the same order whether the mutation happens on a local binding before it moves into the Server literal (old, server.rs pre-00c03ec-diff) or on &mut self.workspace after it is already a field (new) — a move is bitwise and Rust invokes no Drop/observer between them, so there is no field open_roots could leave stale that the old order would have filled: every field of Workspace (docs, roots, index, candidates, includes, client) gets the identical value either way. Every other Server field's initializer (connection, config_warnings, abilities, watchers, registrations, request_ids, applying, generation, tokens, token_results, and the new indexings: 0) is inert and side-effect-free, so field-initializer order carries no risk. report_scope still receives open_roots's warnings (server.rs:109-111); register_watchers still runs last (server.rs:116). Gap found and fixed: the ordering the lead flagged as the actual risk — whether register_watchers's request lands before or after the startup bar comes down — was not observable in any existing test, because every dev test using watching_progress() (work_done_progress: true) leaves file_watching at its Default::default() of false, so register_watchers is a no-op in all of them; conversely every test that turns file_watching on (Session::new(_, true)) leaves work_done_progress off. No test ever ran both abilities together. Added the_startup_watcher_registration_arrives_after_the_indexing_bar_comes_down (server.rs, in mod tests, right after a_progress_create_answer_is_ignored_and_never_disturbs_an_apply_edit), which turns both abilities on and pins the wire order create, begin, end, register.

  2. Protocol conformance — verified clean. The e2e test indexing_reports_its_progress_over_the_wire decodes the actual JSON (not the Rust struct) off the real binary and asserts, in one ordered Vec: create precedes begin for the same token, for both the startup rescan (lucisv-index-0) and the save-triggered one (lucisv-index-1) — i.e., create-before-begin holds across consecutive rescans, not just once. The token is read with .as_str().expect("a string token"), which fails the test if the wire ever sends a JSON number instead — so the string-typed-token requirement is pinned, not assumed. title, cancellable: false (explicit false, not absent), and the absence of percentage are asserted off the decoded begin; the end's message is asserted off the decoded end. No gap.

  3. Pairing is structural — verified clean. Read reindex() (server.rs:887-897) and Server::new (server.rs:140-169): in both, nothing sits between begin_indexing() and end_indexing() but a call that returns a plain Vec<String> (rebuild_index/open_roots), never a Result — there is no ? and no early-return expression available to write between them even by accident. end_indexing is therefore unconditionally reached in every existing and reachable call site. Multiple rapid reindexes: the server is single-threaded and reindex() is fully synchronous (begin, scan, end, all before the call returns), so two rescans provably cannot interleave regardless of how close together their triggers arrive — confirmed observably by every_rescan_path_gets_its_own_bar_and_its_own_token, which fires a save, a watched-file change and a config change back-to-back and gets three strictly-paired, strictly-increasing tokens. No gap.

  4. Capability gating — mostly verified clean, one gap fixed. Startup and save, both gated correctly, per a_client_that_did_not_ask_for_a_bar_is_ sent_no_progress_at_all. window: {} and window: { workDoneProgress: false } are both covered by work_done_progress_support_is_read_from_the_clients_own_capabilities (main.rs) via saying(None) and saying(Some(false)) respectively — ClientCapabilities::default()'s window field is itself None, and saying(None) still wraps a Some(WindowClientCapabilities{ .. }), which is exactly the window: {} shape; neither panics on InitializeParams::default(). Gap found and fixed: the watched-file and lucisv.exclude/filelist reindex triggers were never driven with the capability off — only proven off by reading that they share reindex()'s single begin_indexing call with the save path. Added a_client_without_the_bar_gets_none_on_the_watcher_or_config_paths_either (server.rs), which drives both and asserts session.progress() empty after each.

  5. Response routing under interleaving — one direction existing, the reverse was missing; fixed. The dev's a_progress_create_answer_is_ignored_and_never_disturbs_an_apply_edit answers the create (Ok then, for the same id, Err) while the applyEdit is still outstanding, then answers the edit — this is a real interleaving (create resolved first), and both answer shapes are exercised. The reverse ordering the lead asked for — applyEdit resolved first, then a late create answer — was not present. Added a_late_create_answer_after_the_apply_edit_already_answered_is_ignored_too (server.rs): answers the edit as accepted, confirms nothing is shown, then feeds a late Response::new_ok for the create's id and confirms it is still silently dropped. This same test doubles as "a create answer arriving for a token the server already Ended": by the time the edit is answered, the watched-file reindex that minted the create has already run its begin/end pair synchronously (per point 3), so the create answer that follows is necessarily late-for-an-ended-bar. It is ignored cleanly because response() keys off RequestId, never off ProgressToken — the two are different namespaces and request_ids never repeats, so there is no representable state where a create's id could collide with anything a still-outstanding request cares about. No further scenario to test here.

  6. End-message count — verified clean, one gap fixed. end_indexing reads self.workspace.index().files().len() (server.rs:192), which is the index's own file list, computed by rebuild_index immediately before end_indexing runs — not open-buffer count, not scope-file count before filtering. Singular/plural pinned by the_bar_says_how_many_files_were_ indexed ("2 files indexed" / "1 file indexed", explicitly asserting "not 1 files"). Gap found and fixed: no test drove a rootless workspace with zero open buffers through startup. Traced default_files() → sibling_files() (state.rs:308-328) for that case: no roots and no docs means no directories to walk, so the index is empty and files == 0; the plural branch (files == 1 is false for 0) correctly renders "s". Added a_rootless_workspace_with_no_open_files_says_zero_at_startup_without_ crashing (server.rs), asserting "0 files indexed" and, by not panicking, non-crashing. Confirmed passing.

  7. CLAUDE.md compliance — verified clean. Grepped every non-#[cfg(test)] line of server.rs and main.rs (i.e., everything before their mod tests) for unwrap(, expect(, panic!(: zero hits. Every new item (ClientAbilities::work_done_progress, Server::indexings, INDEXING_TITLE, begin_indexing, end_indexing, progress, work_done_progress_support) carries a doc comment. This README's seven required sections (Goal, Assumptions, Handshakes, Status / TODO, Work log, QA log, Review) each appear exactly once (grep -n "^## "). TODO.md's §9b item text is untouched — only its checkbox flipped to [x] and an indented → note appended below, per the existing convention elsewhere in that file.

Beyond the list. One thing noted for the record, not a defect in this diff: Workspace::collect_sources (state.rs, untouched by this round) folds in every open buffer's path unconditionally, even one outside the walked scope, so in principle an open buffer for a file the workspace walk would not have found could nudge the "N file(s) indexed" count up by one beyond what a disk-only scan would report. This is pre-existing behavior this feature did not introduce and does not change (state.rs has no diff against 00c03ec), so it is not filed as a finding against this round — just flagged in case a future change to the end message's wording ever needs it.

Fixes made (all additive; no dev code changed): four new tests in crates/lucisv_server/src/server.rs's mod tests, inserted after a_progress_create_answer_is_ignored_and_never_disturbs_an_apply_edit: a_late_create_answer_after_the_apply_edit_already_answered_is_ignored_too, the_startup_watcher_registration_arrives_after_the_indexing_bar_comes_down, a_client_without_the_bar_gets_none_on_the_watcher_or_config_paths_either, a_rootless_workspace_with_no_open_files_says_zero_at_startup_without_ crashing. All four pass; full workspace suite is green at 1816; cargo fmt and cargo clippy --all-targets stay clean.

Verdict: committable as-is. No corruption risk, no idempotency risk (this feature touches only the LSP transport, never formatted output), no dropped comments, no widened verify.rs forgiveness (that file has no diff in this round). The one structurally risky change — Server::new's construction order — is provably equivalent to the old order and now has its previously-unpinned watcher-vs-bar ordering under test. No dev follow-up required.

Review

2026-08-26 — lead

Reviewed the diff, the work log and the QA log; re-ran all gates myself (1816 workspace tests, 0 failed), clean. The Option<ProgressToken>-as- capability-gate design is the kind of structural guarantee this repo prefers over discipline: neither caller can put a bar up for a client that cannot show one, and nothing between begin and end can return early — I read the two call sites and confirm QA's finding that the pairing is unconditional. The startup-build determination was done the right way (read from initialize_finish's contract and the existing register_watchers comment, not guessed), and the restructured Server::new is provably equivalent — same value, same two operations, different borrow spelling — with the previously-unpinned watcher-after-bar ordering now under test thanks to QA. Honesty calls all correct: no invented percentage, cancellable: false because nothing here can cancel, and the end message costing nothing because the index already knew its file count. QA's four gap-closing tests (both interleaving directions, capability-off on all trigger paths, the rootless zero-count startup) complete the surface. Accepted as shipped.