Files
lucisv/docs/features/server-scaling-r10
Guoliang ChenandClaude Mythos 5.2 36733e2c7c Round 10: resumable discovery walk and faster whole rescans (#58, #64)
#58: the discovery walk runs in 512-entry slices with requests drained
between them (lucisv_core ResumableWalk, state/walking.rs); identities are
read in one pass at landing. Proved equal to the one-shot walk.
#64: the 40k rescan timing split is not reproducible; the store is kept
across rescans, compaction streams, candidates are cheaper (-12% on 40k,
answers and store byte-identical).
Files topo #71-#74.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
2026-11-26 19:29:02 -08:00
..

lucisv_core + lucisv_server scaling (Round 10)

Goal

Close docs/topo.md §2.9 rows 58 and 64. #58: the discovery walk at the front of every whole scan held &mut Workspace for its whole length (25–80 ms on OpenTitan, ~390 ms on 40 000 files) and answered nothing meanwhile — the last of the first-colour wait in workspace scope and of a rescan's colour hold. Make it resumable, so the server answers between slices, with an identical-result proof. #64: the 40 000-file rescan after a delete was reported as taking either 12.3 s or 14.5–15.5 s; diagnose that with measurements, write the cause down, fix what the diagnosis supports, and try the candidate speed-ups the handoff lists, keeping only what measures. A performance round: no new features, no client-visible change but timing, and every answer, the discovered file set and the index store byte-identical to trunk (dc54b23).

Assumptions

  • The scope of a sliced walk is fixed when it begins. Its directories, each directory's excludes (lucisv.toml + lucisv.exclude) and the size cap are read once, up front (state/walking.rs begin_walk). A settings change between two slices does not move this scan; it asks for the next one (rescan_wanted), exactly as a settings change between two files always did. The open buffers are not fixed: they are overlaid when the walk lands, so an open, an edit or a close between two slices is seen by this scan.
  • A file created or deleted on disk mid-walk is seen if its directory has not been read yet and not if it has (each directory as it was when it was listed). One window inside a directory: a file deleted after its directory was listed and before its own entry is visited is said as unreadable (a walk warning) and not indexed — the recursive walk has the same window between read_dir and that entry's metadata, only narrower. In every case the watcher event for the change asks for the next scan, which converges (proved: state/tests/walking.rs, server/tests/walking.rs). That warning is the scope's first warning and so can surface as a window/showMessage popup (report_scope), e.g. lucisv: <path>: No such file or directory (os error 2); trunk has the same race, slicing widens it by the drain time (R10-QA2, no code change).
  • Identities are read once, together, when the walk ends (fix round, R10-QA1). Walking::finish stats every walked file back to back after the last slice and carries the result on Found::id; dedup_by_identity, the overlay's dedup and rest_of_scope reuse that one pass instead of trunk's two or three passes. Trunk's window — between a file's walk entry and its post-walk stat, as long as the walk — is kept, widened only by the drain time between slices; the round-1 scheme (identity off each entry's own walk metadata) is withdrawn: entries visited slices apart could see one replaced file as two, and a file-symlink alias was indexed twice. With it goes the earlier claim that the round "closes the window in which a file deleted after being walked kept its path but lost its identity": that window is trunk's again (a deleted file can land in the work list with no identity, as on trunk, and the watcher event's rescan converges). walk::meta_id is removed.
  • The store kept across rescans is the store read again. IndexCache remembers the store file's (length, mtime, inode) whenever its entries, header flag and load counts are exactly what IndexCache::open would read from that file — after a load nothing moved, after a compaction — and forgets it at the first append. A rescan keeps the cache only while the file still has that stamp; another session's append (length), compaction (rename → inode) or anything else that moves the mtime reads it again. The store is content-keyed and never a correctness input, so even a stale kept entry could only change a hit into a miss or back, never an answer.
  • Timing method for every table: release build, the machine otherwise idle (load ≤ 3 before each session, noted in the logs), trunk built from a detached worktree at dc54b23 with its own target dir, binaries run in alternation, N ≥ 5 per cell, min / median / max reported.

Handshakes

  • lucisv_core (new API, additive): walk::ResumableWalk (new, step — visits at most budget entries and returns how many, is_done, error) and DirectoryTracker: PartialEq + Eq. (walk::meta_id from round 1 is removed in the fix round.) The recursive collect_files* walks are untouched; the CLI does not use the new walk.
  • lucisv_server, internal: state::walking (new) owns the sliced walk. Scan gains walking and walking(); neighbourhood_indexed() is false while walking; Workspace::begin_scan may return a scan still walking, which scan_step advances a slice at a time (each step indexes nothing and returns true). server/index.rs scan_once drains between walk slices and decides "interleave or not" after the walk lands, exactly as before (Server::interleaves). discover::Found gains id; overlay_buffers takes the cap; first_scope returns walking::Begun; rest_of_scope takes the walked files. IndexCache::reopen (new) replaces the bare open in open_store; compaction streams (render_to). Candidates::from_words counts without a clone per occurrence.
  • Trace (verbose only): the stages line gains slice_max (the longest discovery hold of the scan, ms) and the counts line gains slices. A rescan that keeps the store reports opens=0.
  • Request to vlog_semantic (not done, out of this round's crates): WorkspaceIndex::absorb is 2.06–2.17 s of a 6.6 s rescan at 40 000 files (32 %), the largest stage left; see the #64 tables.
  • Perf tooling (new): tools/perf/bigtree.py, rescan.py, rescan_diff.py — not yet listed in tools/perf/README.md (outside this round's file list; a docs request for the lead). Any speed-up there is vlog_semantic's lane.

Status / TODO

  • #58 resumable walk in lucisv_core (walk/resumable.rs), proved equal to the recursive walk at every slice size and with varying slice sizes.
  • #58 sliced whole-scope walk and sliced rest-of-scope walk (state/walking.rs), landing identical to trunk's one-shot discovery at every slice size and boundary, with an open / edit / close / settings change / create / delete between slices.
  • #58 server drains between slices; scripted mid-walk bursts settle where the same burst between files does, and where a fresh server starts.
  • #64 reproduce with the existing harness — rebuilt (tools/perf/bigtree.py, tools/perf/rescan.py): not reproduced; see Diagnosis.
  • #64 cache reuse across rescans — kept (−0.7 s at 40k).
  • #64 streaming compaction — kept (−50 ms, −0.47 GB peak RSS at 40k).
  • #64 pre-sized candidates (and no clone per word occurrence) — kept (−60 ms at 40k).
  • #64 absorb — not this round's crate; handshake request above.
  • Fix round: R10-QA1 (identities in one pass at landing; QA test passes unmodified; five replacement cases vs trunk's one-shot), R10-QA3 (scan_step 82 → 49 lines, facts_of_step 44), R10-QA4 (TODO §71 wave-7 walk item ticked; wave-8 40k item left open — the cause was not found, it was not reproducible), R10-QA6 (rescan_diff.py refuses a non-store --storage), R10-QA5 (re-run below), R10-QA2 (Assumptions).
  • lifecycle_r2 debug ceiling — unchanged (nothing here touches the close path; measured headroom recorded below).

Work log

2026-11-26 — dev

#64 first: reproduce. The 40k harness (fast-actions' gen.py, ab41.py, b3.py) lived in a scratch directory and is gone, and bench.py has no rescan phase. Rebuilt as tools/perf/bigtree.py (OpenTitan hw/ copied 10× under c0/…c9/ with every declared unit name prefixed cK_, into a scratch directory; 40 470 files) and tools/perf/rescan.py (one session: startup, then per run delete the previous probe file → didChangeWatchedFiles Deleted, create a new one → Created, which owes a whole rescan; idle waits for the delete's update first, busy sends the create 50 ms later; every rescan's --verbose stage / count / memory lines parsed into the row, RSS sampled every 100 ms). All under tools/guard.sh -m 8 -t 1200.

The table to reproduce is fast-actions' QA table (0.65.10 / lane, 40k, the rescan as the server times it): idle 12.35–12.56 s; busy 12.31–12.32 or 14.58–15.09 s.

Result: the bimodality does not reproduce, on trunk or on 0.65.11. Server-timed whole rescan after a delete, 40 470 files, release, machine idle (load 1.3–3.7), 3 rescans per session (a 4th is killed by the 8 GB guard — see F2):

binary mode N min median max
trunk dc54b23 busy (create 50 ms after the delete) 12 7 422 ms 7 540 ms 7 626 ms
trunk dc54b23 idle (create after the delete's update) 12 7 437 ms 7 527 ms 7 819 ms
0.65.11 cc1e2c8 busy 7 7 337 ms 7 524 ms 7 669 ms
0.65.11 cc1e2c8 idle 8 7 360 ms 7 426 ms 7 566 ms
trunk, 18 yes processes on 18 cores busy 6 9 279 ms 9 756 ms 10 021 ms

Every stage is unimodal too (trunk, 24 rescans): read 817–878, cache_open 672–712, lookup 385–388, decode 1 216–1 269, absorb 2 037–2 307, compact 676–707, candidates 603–635, discovery 363–381 ms. Max/min of the total is ≤ 1.05 on a quiet machine. What the evidence says about the reported numbers:

  • They are 1.6–2.0× today's 7.5 s for the same binary family (0.65.11 is as fast here as trunk), and fast-actions' README says its machine was shared with other lanes' builds. Deliberate CPU contention (18 busy processes) raises the rescan to 9.3–10.0 s but still does not split it into two modes. The cause of 12.3 vs 14.5–15.5 s is outside the code as far as this machine can show — host load / memory state at the time; it cannot be reproduced here, and no fix is made for it.
  • 0.65.11's delete really was slow (its "busy" wall time is 9.7–10.1 s against 7.3–7.7 s for the rescan itself: the create waited behind a ~2.3 s one-file delete); trunk's delete update is 35 ms (Round 2's tombstones). The "busy" bimodality in the old table was therefore read through a 2.3 s handler; that handler is gone.
  • What is real and in the code: peak RSS of a 40k rescan is 6.8–7.9 GB and grows across rescans (F2), which on a shared machine is the kind of state that varies. Streaming compaction below takes 0.5–0.7 GB off that peak.

What the rescan costs (trunk, 40k, median of 12): absorb 2 111 (28 %), decode 1 237, read 870, compact 681, cache_open 676, candidates 617, lookup 386, discovery 373, includes 76 ms. Each candidate in the handoff was measured against the binary before it, alternating sessions, N = 6:

change stage before → after (min–max) rescan before → after (median) peak RSS (median) kept?
#58 sliced walk + identity from the walk's own metadata (identity part withdrawn in the fix round: sort back to ~50 ms at 40k, see below) discovery 370–382 → 277–285 (sort 55→10, cap 50→5) 7 585 → 7 510 ms = yes (#58)
cache reuse across rescans (IndexCache::reopen) cache_open 673–702 → 0.0 7 516 → 6 809 ms = yes
streaming compaction (render_to) compact 677–725 → 628–643 6 809 → 6 753 ms 6.95 → 6.48 GB yes
candidates: reserve + no clone per occurrence candidates 615–632 → 549–583 6 682 → 6 637 ms = yes
absorb 2 041–2 307 ms — — not this round's crate (handshake)

Final, trunk vs this tree (40k, idle, alternated, N = 6 each):

trunk this tree
whole rescan (server) 7 501 / 7 572 / 7 640 ms 6 601 / 6 655 / 6 789 ms (−12 %)
documentSymbol sent 5 ms after the create 1 111 / 1 122 / 1 158 ms 53 / 57 / 96 ms
longest discovery hold ≈ 386 ms (discovery + order, one hold) 33 / 33 / 35 ms (slice_max; the landing slice) — superseded by the fix round: 74 / 74 / 77 ms
peak RSS 6.99 / 7.14 / 7.73 GB 6.28 / 6.44 / 6.55 GB

#58 on OpenTitan-sized trees (min / median / max, N = 6):

trunk this tree
hw/ itself, settings-push rescan: discovery hold 66.5 / 73.1 / 77.7 ms in one piece (+1 ms order) 4.8 / 5.0 / 5.7 ms longest of 24 slices — superseded by the fix round: 11.0 / 11.5 / 11.9 ms
hw/ itself, whole rescan 703 / 722 / 755 ms 616 / 636 / 656 ms
4 047-file copy, documentSymbol 5 ms after a watched create 107 / 109 / 119 ms 5.3 / 5.5 / 6.3 ms
4 047-file copy, longest discovery hold ≈ 37 ms + the store open 68–72 ms before the first drain 3.8 / 3.9 / 4.0 ms (12 slices), store kept — superseded by the fix round: 8.4 / 8.5 / 9.0 ms
4 047-file copy, whole rescan 749 / 760 / 776 ms 653 / 667 / 688 ms

(A settings push holds every request by design — REACH — so the hw/ rows measure the hold from the trace, not a probe; the corpus is never written. The 40k landing slice — sort, cap, overlay, ordering — is the 33 ms; everything before it is ≤ 3 ms slices of 512 entries.)

Identical-result proof (#58).

  • lucisv_core walk/resumable/tests.rs: on trees with nested .gitignore + negation + directory-only rules, an exclude, a symlink cycle, two aliases sorting before and after their target, a dangling source link, empty directories, unreadable directory and ignore file, a file input, a missing input and a pre-filled tracker (the split startup): the event sequence (every found path with its length, every warning, in order), the error and the final tracker equal the recursive walk's — for every slice size from 1 to one past the walk, and for 200 seeds of per-step sizes 1–7.
  • state/tests/walking.rs: the landed scan (work list and order, head, paths, buffered texts, analysed buffers and their words, canonical spellings per identity, incdirs, warnings, skips, split-discovery state) and the watch events equal trunk's one-shot discovery (collect_sources → recursive walk → land_scope) for every slice size 1…N in both the workspace and the folder rung, and the finished index / completion tables / include graph too; an open, an open of an excluded file, an edit, a close and a settings change applied after every slice boundary land what the one-shot discovery lands with the message applied first (settings: not applied — the scope is fixed at the start); a create / delete mid-walk lands exactly the before- or after-tree answer (both occur), with only the vanished file's own warning extra; a split startup's rest walked in slices lands what one call lands.
  • server/tests/walking.rs: through the real process_batch, a rescan with 1-entry slices drains between slices (interleave points > files + 10) and answers a buffer-local request there; open / edit / close / settings / watched create / watched delete scripted at the first, middle and last walk drain settle byte-identical (index, include graph, completion words, buffers) to the same burst at a drain between files (trunk's own interleaving), with settings / create / delete each owing exactly one more scan; and all but the edit settle equal to a fresh server (F1).
  • Existing suites unchanged except two expectations the round moves: interleave.rs cadence test steps past the walk slices of its 514-file tree first; server/tests/scan_trace.rs expects opens=0 for the warm rescan that keeps the widen's read.

Identical-result proof (#64). index_cache/reuse_tests.rs: after a compaction, after a compaction that dropped a gone file, and for a fresh open, the kept cache equals IndexCache::open of the same file (entries, hashes, encoded facts, header flag, load counts) and compacts to nothing; a store another session appended to, compacted and renamed over ours, our own append, another directory and persistence off are all read again; the streamed rewrite is byte-identical to the whole-text render (> 1 MiB store). OpenTitan differential (tools/perf/rescan_diff.py, cold store, startup + 2 rescans, 94 answers: 5 workspace/symbol, the module hierarchy, the outline, definition / hover / references at 8 cursors, each after every scan): trunk and this tree identical, store 50 626 930 bytes, SHA-256 f268de99…81821 both. 40k differential (startup + 1 rescan; trunk was guard-killed at 8.68 GB with 2 rescans, this tree finished 2): 63 answers identical, store 532 809 161 bytes, SHA-256 8589460e…3d6d7 both (this tree's store after 2 rescans: same hash). git -C opentitan status --porcelain empty after every run.

lifecycle_r2:240 debug ceiling (100 ms). Unchanged: the close path (remove_one, vlog_semantic) is not touched and absorb did not get faster in this round. Measured in isolation (--test-threads=1, debug, 3 runs): 8.66 / 8.67 / 8.73 ms per tombstoned close; the ceiling was raised for loaded CI runs, so lowering it needs absorb/remove_file work first.

Findings (not fixed, out of scope or pre-existing):

  • F1 (pre-existing on trunk): an edit arriving mid-scan to a buffer the scan already took leaves the completion word table with the old text's words (index correct). Reproduced on trunk dc54b23 with an edit at the 5th file drain: only mid-scan ["s"], only fresh ["t"]. Same between walk slices with this tree, so the walk test compares against trunk's interleaving and excludes the edit from the fresh-server comparison.
  • F2: on 40k files a server's RSS grows across rescans (3.9 GB settled → 6.8 → 6.9 → 7.5 GB after 3 rescans on trunk; 4k: 0.52 → 1.04 GB over 6); the 8 GB guard killed a 4th rescan (trunk, 0.65.11 twice, and this tree's first cold-store session once). Not diagnosed (allocator retention vs a table that grows); streaming compaction lowers the peak but not the growth.
  • F3: begin_widen (a didOpen into a new folder) still walks in one call; it walks only the added folders. filelist scopes and the rootless flat read are unchanged too.

Tests run (this tree): cargo fmt --all -- --check clean; cargo clippy --workspace --all-targets clean, no new #[allow]; guarded cargo test -p lucisv_core 128 passed, -p lucisv_server 2 236 passed / 53 ignored, -p lucisv_mcp 400 / 3 ignored, -p lucisv 162; with LUCISV_OPENTITAN set (real runs): lucisv_server --test opentitan_references --ignored 2 passed (11.9 s), localized_reindex --ignored 2 passed (36 s); tools/gates.sh --only cross pass.

2026-11-26 — dev, fix round (lead's rulings on the QA log)

R10-QA1. Chose the lead's default: every identity read in one back-to-back pass after the last slice (Walking::finish), reused by the overlay dedup and rest_of_scope, so the window is trunk's (walk length) plus drain time and two walk entries can no longer disagree about one file. No cheaper scheme was attempted: nothing short of reading the identities together gives trunk's answer when an alias and its target are visited slices apart. Proof: QA's state/tests/qa_walking.rs passes unmodified; state/tests/walking_replace.rs (new) — replace the target, replace the alias, retarget the alias, replace the target with a hard link, delete and recreate the directory holding both — applied after every slice boundary (1-entry slices, > 30 boundaries each) lands exactly trunk's one-shot discovery (collect_sources) of the final tree, and no alias is counted twice. a_file_created_or_deleted_mid_walk… now allows the one mixture trunk itself has (a file deleted after it was walked: its path from the old tree, its identity line from the new).

Landing hold, re-measured (release, alternated, min / median / max of slice_max; "round 1" = the identity-from-metadata build):

tree round 1 fix round change trunk (one hold)
OpenTitan hw, settings rescan, N=6 4.9 / 5.1 / 6.5 ms 11.0 / 11.5 / 11.9 ms +6.4 ms 66.5–77.7 ms
4 047-file copy, N=6 3.8 / 3.9 / 4.1 ms 8.4 / 8.5 / 9.0 ms +4.6 ms ≈ 37 ms + 68–72 ms store open
40 470 files, N=3 (guard allows 3) 32.9 / 33.0 / 33.0 ms 73.7 / 74.0 / 76.5 ms +41 ms ≈ 386 ms

The growth is the identity pass (sort stage: 0.8 → 7.4 ms on hw, 9.9 → 50.1 ms at 40k). The landing slice is now the longest hold of the walk at every size; the earlier tables' "longest discovery hold" rows read these numbers instead. Unchanged: buffer-local probe 5 ms after a create, 4k copy 4.7 / 5.0 / 7.5 ms (round 1 4.6 / 5.1 / 9.3), 40k 47 / 51 / 74 ms; whole rescan hw 611 / 627 / 649 ms, 4k 651 / 662 / 683 ms, 40k 6 628 / 6 652 / 6 754 ms (N=3).

R10-QA5. My round-1 localized_reindex --ignored run was a silent skip for the OpenTitan sweep: I set LUCISV_OPENTITAN to the repo root, and that test wants the hw directory. Re-run for real: LUCISV_OPENTITAN=/Users/lucio/repo/opentitan/hw tools/guard.sh -m 8 -t 1200 -- cargo test --release -p lucisv_server --bin lucisv-server localized_reindex -- --ignored --test-threads=1 --nocapture → seed 21: 60 steps over 278 files, 3 whole rescans; seed 22: 60 steps, 2 whole rescans; corpus seeds 11–13: 60 steps over 860 files, 2/2/3 whole rescans; 2 passed in 44.4 s. LUCISV_OPENTITAN=/Users/lucio/repo/opentitan … --test opentitan_references -- --ignored → 2 passed in 12.3 s (aes: 14 references listing the three generated tops; folder scope 11).

Checks. cargo fmt --all -- --check clean; cargo clippy --workspace --all-targets clean; guarded cargo test --all-targets: lucisv_core 129 passed, lucisv_server 2 243 passed / 53 ignored (QA's tests included), lucisv_mcp 400 / 3, lucisv 162; stamp_author.py --check 0, new files' stamps checked by hand; tools/gates.sh --only cross pass. OpenTitan hw differential vs a fresh dc54b23 worktree build: 94 answers identical, store 50 626 930 bytes, SHA-256 f268de99…81821 both. Opentitan porcelain empty; worktree and scratch trees removed.

QA log

2026-11-26 — QA

Verdict: PASS with findings. One Medium finding (R10-QA1) the lead should rule on before merge. No guard kills.

Baseline. cargo fmt --all -- --check clean. cargo clippy --workspace --all-targets clean, including the QA tests. Guarded cargo test -p lucisv_core 128 (+1 QA) passed, -p lucisv_server all green before the QA tests went in, -p lucisv_mcp and -p lucisv green. stamp_author.py --check stamps nothing. I checked the header and footer stamps of every untracked file by hand and all are right; the three new tools/perf/*.py have no shebang, which matches harness.py / lspclient.py. Production lines are all ≤ 600 (rescan.rs 524, discover.rs 515, index_cache.rs 396, walking.rs 153, resumable.rs 171). The diff adds no unwrap/expect/panic!/unsafe/#[allow] to library paths. tools/gates.sh --only cross passes.

Walk equivalence. I read walk/resumable.rs against Walk::dir/entries/push_ignore. The fs calls happen in the same order, rel/ignore push and pop match, read_dir errors are handled the same, and file input, missing input and a pre-entered root behave the same. It always terminates: each step consumes one entry or pops one frame, and budget 0 is treated as 1. I added walk/resumable/tests.rs::qa_edge_budgets_a_symlinked_root_a_negated_dir_and_a_deep_chain_walk_the_same, which covers budget 0 and usize::MAX, a root that is a symlink to a directory, an ignored-then-negated vendor/ with its own nested .gitignore, and a 40-deep chain at every slice size. It passes. Both walks still exist: the recursive one is used by the head walk, the widen and collect_files_below. The core tests compare them on every branch tree, so drift would be caught.

State/server. The state/tests/walking.rs oracle is rebuilt from the recursive walked_files plus the shared overlay_buffers/land_scope. It is not trunk's binary; the trunk binary comparison is rescan_diff.py (below). I added server/tests/qa_walking.rs, all passing:

  • A workspace folder removed at walk drain 1/15/40 ends with no stale files and an index fingerprint identical to a fresh server over the remaining folder.
  • Two watched creates in two different slices cost exactly one more scan, not two, and both files are indexed.
  • A code lens sent mid-walk is held and answered exactly once.
  • A shutdown sent mid-walk is held once and not answered mid-walk. This matches the between-files behaviour of a rescan. I did not drive the exit handshake.

R10-QA1 (Medium, new in this tree; not reproducible on trunk): a file replaced mid-walk breaks symlink-alias dedup.

  • Repro: state/tests/qa_walking.rs::qa_a_file_replaced_mid_walk_keeps_its_symlink_alias_deduplicated (left in, FAILS). Tree is a.sv, b.sv -> a.sv, c.sv, slice 1. After the slice that visits a.sv, a.sv is removed and rewritten with the same bytes and a new inode.
  • Observed work list: ["a.sv","b.sv","c.sv"]. Expected (one-shot discovery on the same tree): ["a.sv","c.sv"].
  • Cause: Found.id comes from each entry's own walk metadata (walking.rs:82), and dedup_by_identity (discover.rs:126) prefers it. Two entries read at different moments can therefore disagree about one file.
  • Trunk stats both paths back to back after the walk, so its window is microseconds. Here the window is any slice drain.
  • Effect: the module is indexed twice under two paths. A watcher event for a.sv classifies as Watched::Held (watched.rs:42), a one-file reindex, so the duplicate lasts until the next whole rescan. That last point is from reading the code, not a server-level run.
  • Trigger: an atomic save or a git checkout of a file that has a file-symlink alias, during a rescan's walk.

Low findings:

  • R10-QA2: deleted-mid-walk warning becomes a popup. The "deleted after listed, before visited" warning (Assumptions, second bullet) is user-visible. report_scope (server/client.rs:239) sends the first scope warning as a window/showMessage popup: lucisv: <path>: No such file or directory (os error 2). Trunk has the same race; slicing widens it by the drain time.
  • R10-QA3: scan_step grows past the function-size guideline. scan_step (state/rescan.rs:412) is now 82 lines (trunk ~76), over CLAUDE.md's "investigate over 80".
  • R10-QA4: TODO.md not ticked. The §71 items at TODO.md:7479 (walk) and :7501 (40k rescan) are still [ ]. CLAUDE.md asks the dev to tick completed items.
  • R10-QA5: the dev's OpenTitan sweep run was most likely a skip. localized_reindex::a_seeded_sweep_over_an_opentitan_sample_holds reads LUCISV_OPENTITAN as the hw directory. With the repo root it prints … not present — skipping and passes (I saw this). With LUCISV_OPENTITAN=/Users/lucio/repo/opentitan/hw it ran for real: seeds 21/22, 278 files, 2–3 whole rescans each, passed, 42 s. The env contract differs from opentitan_references, which wants the root.
  • R10-QA6: rescan_diff.py can delete a mistyped directory. It runs shutil.rmtree(--storage) without any guard. lspclient.py:121 does the same, so the pattern pre-exists.

IndexCache::reopen. No case where a kept cache gives a different answer. Every entry is keyed by the hash of the bytes it was parsed from, so a mismatch between kept and freshly opened can only turn a cache hit into a miss or the reverse. The stamp holds up against the cases I listed:

  • another session's append (length changes);
  • another session's compaction (rename gives a new inode; even when ext4 reuses that inode, the mtime also has to match);
  • an append during open (before and after stamps differ);
  • the store deleted (stamp is None, so the file is re-read);
  • persistence off, or a different directory.

The one gap is an in-place rewrite to the same length with the mtime restored. No lucisv writer does that; cp -p would. index_cache/reuse_tests.rs::qa_an_in_place_same_length_rewrite_with_its_mtime_restored_is_kept_but_only_changes_hits passes and pins it as harmless (the kept hit equals the parse; the fresh read is a miss). There is also a microsecond race in compact_now between the rename and Stamp::of: another session's append there would be in the stamp but not in the entries. That costs a miss only.

Streaming compaction is still temp file plus rename, so it is atomic as before. A failed write leaves the .tmp file, exactly as trunk's fs::write did. entries.retain(exists) now prunes memory too, which can only cost a miss within the same session. The store is byte-identical to trunk: see the differential below.

Candidates. from_words is the same count without the clone; the maps are std HashMap (random order) on both sides. I verified this by reading the code only: rescan_diff.py sends no completion query.

Differential (OpenTitan hw). rescan_diff.py, trunk built in a scratch worktree at dc54b23, cold store, startup plus 2 rescans: 94 answers identical. Store 50 626 930 bytes, SHA-256 f268de99…48581821 from both binaries, matching the dev's.

Timing (release builds, binaries alternated, load 1.1–2.8; min / median / max):

trunk this tree
4 047-file copy, whole rescan, N=12 725 / 751 / 771 ms 624 / 653 / 724 ms
4 047-file copy, documentSymbol 5 ms after the create 111 / 113 / 124 ms 3.6 / 7.4 / 15.1 ms
4 047-file copy, slice_max — 3.9 / 4.3 / 4.7 ms (12 slices)
4 047-file copy, cache_open 68 / 70 / 73 ms 0 (opens=0)
hw settings rescan, N=8 678 / 697 / 715 ms 608 / 637 / 707 ms
hw slice_max — 5.1 / 5.6 / 6.7 ms (24 slices)

The dev's claims reproduce. The probe is a little slower than the 5.3–6.3 ms claimed: the first rescan of each session takes 14–15 ms.

F1 reproduces identically on trunk dc54b23. With an edit at file drain 5 and at drain 1, both trees give only mid-scan ["s"] only fresh ["t"] and an equal index. Mid-walk (slice 1, drain 1 and 3) this tree gives the same result. It is not new and not worse.

F2 (RSS after rescans 1→6, 4k copy, two sessions each):

after rescan 1 after rescan 6 per rescan at the end
trunk 751 / 748 MB 1 058 / 1 048 MB still about +50 MB
this tree 676 / 671 MB 779 / 773 MB plateaus at about +2–5 MB

The kept cache does not make the growth worse; it improves it.

Ignored OpenTitan tests, real runs:

  • opentitan_references --ignored: 2 passed, 13.9 s, with real output (the three generated tops listed).
  • localized_reindex corpus sweep: passed, seeds 11–13, 860 files.
  • localized_reindex OpenTitan sweep: passed as above (with the hw env).
  • ordering_random::random_bursts_long_run: passed, 84 s.

Tests run after the QA tests went in:

  • Full lucisv_server bin suite: 2 131 passed and 1 failed. The failure is R10-QA1 only. Cargo stopped at that target, so the integration tests did not re-run; they passed at baseline.
  • The new reuse_tests QA test passes.

Not verified:

  • The 40k tree (skipped: its size is near the guard limit).
  • The exit half of a mid-walk shutdown.
  • R10-QA1's persistence through a real watcher event (code reading only).
  • Non-unix behaviour beyond cargo check.

Housekeeping. No guard kills. The scratch worktree and copied trees were removed, and git -C opentitan status --porcelain is empty. QA files added to the tree: server/tests/qa_walking.rs, state/tests/qa_walking.rs (failing on purpose, R10-QA1), plus one test each appended to walk/resumable/tests.rs and index_cache/reuse_tests.rs, and mod qa_walking; lines in both tests/mod.rs.

2026-11-26 — QA, re-QA of the fix round

Verdict: PASS. R10-QA1 is fixed. Only one nit is left, listed at the end. No guard kills.

a. Tests.

  • My state/tests/qa_walking.rs::qa_a_file_replaced_mid_walk_keeps_its_symlink_alias_deduplicated still has the setup, the replacement and the assert_eq!(work, want, …) I wrote, and it now passes. The only edit is mine: I changed its header comment from "FAILS" to "failed in round 1, passes now".
  • Guarded cargo test -p lucisv_server --all-targets: green, with 2 134 in the bin target, 106 e2e, the grammar and ifdef tests, and 2 ignored OpenTitan tests.
  • Guarded cargo test -p lucisv_core --all-targets: 129 passed.

b. Mutation check.

  • I put the round-1 scheme back in state/walking.rs: identity taken from each entry's own walk metadata, with finish filling only the missing ones.
  • Under it, walking_replace.rs::a_replacement_between_any_two_slices_lands_trunks_discovery_of_the_final_tree fails ("replace the target after slice 36"), and so do my qa_walking test and my new re-check test ("chain after slice 36").
  • The test stops at its first failing case, so I did not see the other four of the five cases fail one by one.
  • Restored by copying a backup back. cmp against the backup is identical, and SHA-1 is 5658017…eeb before and after. Nothing else was mutated.

c. The single pass.

  • Found::id has one producer, Walking::finish (walking.rs:111). Every other Found is built with id: None and stat'd at dedup time, as on trunk.
  • Overlay dedup and rest_of_scope run in the same call as finish (in walk_a_slice and discover_the_rest), so they use identities read in the same slice. Open buffers' identities are still stat'd at the overlay, back to back as on trunk.
  • No identity read in an earlier slice is reused. A file replaced between trunk's second and third pass cannot give a worse answer here: those passes ran microseconds apart on trunk, and here they collapse into one pass of the same freshness.
  • The loosened create/delete test (walking.rs:311, which lets the ids line come from the other tree): this is exactly the state trunk reaches when a file is deleted between its walk entry and the post-walk stat. It is in the work list with no identity, and dedup_by_identity keeps id-less files.
    • As written, the assertion would also accept any "files from one tree, ids from the other" mix. With one changed file per case, the only reachable mix is the trunk one, so it forgives no real divergence today.
  • tools/gates.sh --only cross passes. It is cargo-cached, but the current sources check.

d. Own attacks. state/tests/qa_walking.rs::qa_recheck_alias_chains_split_aliases_and_outside_targets_land_trunks_discovery passes. It replaces the target after every slice boundary, including the last, for three shapes, and asserts the landing equals trunk's one-shot discovery of the final tree:

  • an alias chain c -> b -> a;
  • two aliases of one target in b/ and z/, visited many slices apart;
  • two aliases of a target outside the workspace root.

It also fails under the mutation in b. A replacement inside the landing slice, between finish and the overlay, cannot be injected without a hook. That window is microseconds, the same as trunk's.

e. Timings and differential.

  • Landing hold, this tree only, N=6, load 2.5–2.9 (min / median / max):
tree whole rescan slice_max sort
hw settings rescan 602 / 619 / 640 ms 9.9 / 10.4 / 11.4 ms 5.6 / 6.1 / 7.1 ms
4k copy 644 / 658 / 666 ms 7.7 / 8.3 / 9.0 ms —

The 4k buffer-local probe was 4.0 / 8.6 / 15.0 ms. The dev's claims (11.5 and 8.5 ms) reproduce.

  • rescan_diff.py on OpenTitan hw, against a fresh dc54b23 scratch worktree build: 94 answers identical. Store 50 626 930 bytes, SHA-256 f268de99…48581821, the same from both binaries.
  • clear_store refuses a directory holding a stray file (the file survives) and a non-directory path. It deletes a real store directory (index-cache, .gitignore, index-cache.<pid>.tmp).
  • rescan.py still empties --storage unguarded through lspclient.py:121. That is pre-existing and not in the brief.

f. Hygiene.

  • fmt, clippy (--workspace --all-targets) and stamp_author.py --check are all clean. walking_replace.rs has both stamps.
  • Production lines: rescan.rs 535, discover.rs 515, walking.rs 155, resumable.rs 172, walk.rs 334.
  • scan_step is 49 lines and facts_of_step 44. The only function over 80 is begin_widen at 125, which is pre-existing.
  • TODO.md:7479 is ticked and :7501 left open.
  • The README withdraws the identity-from-metadata claim in Assumptions, Handshakes and the round-1 table row. meta_id is gone from the code.

Nit: the round-1 timing rows at README lines 198, 205 and 208 still show the round-1 holds (33 / 5.0 / 3.9 ms) with no inline mark. Only the fix-round paragraph says they are superseded.

Not verified: the 40k tree; the other four walking_replace cases failing individually under the mutation; a replacement inside the landing slice.

Housekeeping: the scratch worktree and trees were removed, and git -C opentitan status --porcelain is empty. The tree is as found apart from my QA test additions: the new re-check test and the comment edit in state/tests/qa_walking.rs, plus this entry.

Review

2026-11-26 — lead: accepted after one fix round and a re-QA.

  • Delivered: §2.9 #58 (closed). The discovery walk is sliced, 512 entries at a time, with requests answered between slices. QA's re-measurement agrees with the dev's: longest discovery hold on OpenTitan hw ~10–11 ms against 66–78 ms on trunk; a buffer-local request just after a watched create on the 4 000-file copy ~8 ms against ~113 ms.
  • §2.9 #64 is closed as not reproducible, not as fixed: 39 quiet-machine runs across trunk and 0.65.11 are unimodal, and no cause was found in the code. The rescan is 12 % faster on 40 000 files (store kept, streaming compaction, candidates) with answers and store byte-identical to trunk on OpenTitan hw (94 answers, dev and QA independently) and on 40k (dev only, one rescan).
  • Ruling on R10-QA1: the round-1 shortcut (identity off each walk entry) indexed a replaced file twice through its alias. Identities are read in one pass at landing again; the landing hold roughly doubled for it (hw 5 → 11 ms, 40k 33 → 74 ms) and that price is accepted. QA's mutation check shows the new tests catch the round-1 scheme.
  • Accepted limits: a file deleted between being listed and being visited can now more easily surface as a window/showMessage warning (R10-QA2, trunk's race widened by the drain time); the loosened create/delete assertion is wider than the one mixture trunk produces, harmless with one changed file per case; rescan.py still empties --storage through lspclient.py.
  • Filed, not fixed: #71 (absorb, vlog_semantic), #72 (memory growth across rescans — the 40k fourth rescan hits the 8 GB guard on trunk too), #73 (stale completion words after a mid-scan edit, already on trunk), #74 (three walks still one-call). lifecycle_r2.rs:240 stays at 100 ms.
  • Process: the dev's first OpenTitan sweep of localized_reindex was a silent skip (wrong meaning of LUCISV_OPENTITAN, now noted on #68); QA caught it and both re-ran it for real.
  • Not verified by anyone: Windows behaviour beyond the cross check; the 40k tree by QA; a replacement inside the landing slice itself.