Files
lucioandClaude Fable 5 1029d2f199 Performance wave Lane A: the rename family reads its fan-out
prepareRename answered F2 by reading every in-scope file (1.6-3.0 s on
opentitan, blocking the loop); it now answers from the open buffer and
the index in 139 ns, with a refusal-by-refusal parity table (7
reproduced, 4 deferred to rename, none lost). rename computes over
rename_sources — declarers, reference postings, open buffers, and,
after QA's HIGH finding gated the round, rung 6: files_spelling over
the index's reference facts (resolved or not, FACTS_FORMAT untouched),
restoring the dangling-new-name capture refusal the first five rungs
lost; the old name needs no rung and the argument is written and
pinned, QA's shadowing hunt included. 3.47 s -> 105 ms at a 7-file
fan-out, rung cost 852 us worst-case, byte-parity swept at four real
cursors and 564 offsets, ambiguity escaping to the whole scope.
willRenameFiles rides IncludeGraph::includers(): 249 ms -> 14 ms over
331 includers of 3 976 files. Accepted residue, documented: files
whose only mention of the name is inside opaque macro tokens lose one
warning flavour; the FileFacts macro census is filed as the real fix.

Dev Opus + QA Sonnet (REWORK-gate, fix, SHIP on re-verify) in a
dedicated worktree. Lead-reviewed and merged.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-29 00:11:13 -07:00
..

file-operations

Goal

Renaming a header breaks every `include that reaches it, and until now lucisv watched that happen and said nothing — the editor moved defs.svh, four files went on naming a path that no longer exists, and the only sign was that ctrl-click stopped working. LSP 3.16 has the hook: a client that is about to rename files asks the server first (workspace/willRenameFiles) and applies whatever WorkspaceEdit comes back as part of the same undo step. The include graph already knows exactly which lines point at the moved file — by resolution, not by filename — so this round spends it: an include whose resolved target moves is re-spelled so it still resolves, an include no legal spelling can reach is left exactly as written and named in a warning, and the two after-the-fact notifications (didRenameFiles, didDeleteFiles) nudge the index without waiting for a watcher round-trip.

Assumptions

  • Renames in one batch do not compound. Moves maps a path by the first matching rename (find_map), so a directory rename and an explicit rename of a file inside that directory, sent in one request, apply whichever rule matches first rather than both in sequence (QA log, 2026-08-27). No client observed sends that shape — a directory rename lists the directory alone — and the safety net still refuses any edit whose rewritten include does not resolve, so the failure mode is a skipped edit plus the warning, never a wrong write. Recorded so a future round that wants compounding knows it is changing a documented choice.

  • Resolution decides, never the filename. An include is rewritten only when IncludeGraph::resolve says it reaches the renamed file. Two defs.svh in one workspace are two different files here, and only the one that moves is touched — pinned by an_include_of_a_different_file_with_the_same_name_is_untouched.

  • The rename has not happened yet. willRenameFiles is asked before the move, so the old target is resolved against the filesystem as it stands. The new spelling is resolved against the filesystem the rename will leave behind, which Moves models: everything under old will be under new, a path something moves away from is gone, a path something moves to exists if its source does (so an a→b, b→a swap leaves both files, as it does on disk). No filesystem is touched to answer that — it is a prefix rewrite plus one is_file on the source.

  • A file rename and a folder rename are one operation. LSP sends only the folder's own URI for a folder rename ("when a folder is renamed, only the folder will be included, and not its children"), and a folder is a prefix of the paths inside it — which is exactly what Moves already computes for a file. Handling folders therefore cost this module no machinery at all, which is why they are handled rather than declined: the cost is one filter in the capability and one workspace sweep on a user gesture (54 ms over the 860-file corpus, see Cost), and the case it covers — moving a directory of headers — is the single most include-breaking thing a user can do.

  • The two notifications ask for files only. didRenameFiles/ didDeleteFiles do one thing, reindex, and a folder filter there would buy a full rebuild for every unrelated folder rename in the tree while the file watcher already reports the individual files a folder move touches. So the folder filter is on willRename alone, where it earns its keep.

  • The form is preserved where the new location allows it. The candidate spellings are the suffixes of the new path under each search rung the same form would use — the including file's own directory (skipped for the angled form, as everywhere) and then each +incdir+ — shortest suffix first, with the rung order breaking a tie. An originally absolute include stays absolute. So a same-directory rename keeps the bare filename, and a move into an +incdir+ keeps it bare too.

  • A relative spelling is the last resort, not the first. When no rung's suffix resolves, a quoted include falls back to a path relative to the including file (../headers/defs.svh), which resolves on the own-directory rung every tool has. It is the ugliest spelling in the file, so nothing that goes through an +incdir+ is passed over for it. This is what answers a renamed include directory: the +incdir+ in the filelist is then stale and lucisv does not edit filelists, but the source keeps compiling, which is the better half of a bad situation.

  • An include that still reads correctly is not edited. Before anything is computed, the include as written is re-resolved against the post-rename filesystem; if it still reaches its file, there is no edit and no warning. A header moving between two +incdir+s under the same name, and a rename that carries includer and included together, are both no-ops — a no-op edit is noise in the user's diff.

  • An include the rename strands is left alone and said out loud. The server will not invent a path that resolves to nothing (that would be a guess, and a guess written into the user's file). It also will not stay silent about a line it knows it just broke. So: no edit, and one window/showMessage WARNING naming the file, the line and the include — through report_scope, so forty stranded includes are one popup and forty log lines.

  • Both ends of the edge are watched. The brief's rule was "an include whose resolved target is the renamed file"; the shipped rule adds the mirror case, an include written in a file that moves, because that breaks for exactly the same reason (the own-directory rung moves out from under it) and would otherwise be a silent breakage the feature politely watched happen.

  • Edits are addressed to the file's current URI. A file that is itself being renamed and needs an include rewritten is edited at the URI it has now, while its new content is computed from where it will be. That is what VS Code and every other file-operation participant expect: the edit lands on the document, and the rename carries it.

  • The scope ladder still decides what lucisv can see. The sweep reads Workspace::sources() — the in-scope files, with open buffers overriding disk. An include in a file the filelist does not name is not rewritten, exactly as it is not indexed, not linted and not searched.

  • The capability is static and ungated. ServerCapabilities is built before the client's own capabilities are read, and unlike the file watchers nothing here is server-initiated: a client that cannot send these requests simply never sends them. Gating would buy nothing and cost the capabilities() function a parameter.

The safety net

The WorkspaceEdit this feature produces rewrites the user's source files, which nothing else in the server does unasked. It is fenced three ways, and every candidate spelling passes all three or is discarded (survives):

  1. The edit can only cover the path token. Its range is path_span.start + 1 .. path_span.end - 1 — the bytes between the delimiters. Structurally, no answer this module can compute is able to move the backtick, the quotes, the indentation or a trailing comment; the worst a bug can produce is a wrong path inside a well-formed include line. (the_edit_covers_the_path_token_and_not_one_byte_more.)
  2. It still scans as the include it was. The line the edit would produce is built and re-scanned with includes::scan: exactly one include, target equal to the spelling, same quoted/angled form. A spelling carrying the closing delimiter or a newline dies here.
  3. It still lexes, and it still resolves. The same line is run through vlog_parser::tokenize and must be one TokenKind::Directive and nothing else; and the re-scanned include — what the scanner will actually read back, not what we meant to write — must resolve, through IncludeGraph::resolve_as_if, to exactly the file the rename is moving the old target to. A spelling that would resolve to a different file (a bare name shadowed by a header beside the includer) is refused here, and the longer correct spelling is written instead (a_spelling_that_would_resolve_somewhere_else_is_not_written).

verify.rs is untouched: no normalization was added or broadened, so hard invariant #4 is not in play. The formatter is not involved in this path at all.

Handshakes

Consumed

  • lucisv_server::includes — the whole of the resolution story. Three changes, all additive:
    • IncludeGraph::resolve_as_if(from, include, exists) is new, and resolve is now resolve_as_if(.., &|p| p.is_file()). There is still exactly one copy of the EDA search order; this module needed to ask it about a filesystem that has not happened yet, and a second copy here would have disagreed with the first in the corner cases nobody tests.
    • IncludeGraph::incdirs() — a read-only accessor, so a candidate spelling can be a suffix under a real include path rather than a guess.
    • IncludeGraph::includers() (added 2026-08-28) — a read-only accessor over the edge table's keys, which is what lets the sweep read the files that write a resolving `include instead of every file in scope. The property it stands on is resolve's agreement with the found the edges were built from; it is written out under "The sweep reads the includers, not the workspace", and a change to either half must re-read it. Scope note for the lead: includes.rs is outside the Lane A file list this round was scoped to. The accessor is four lines, purely additive, and there is no second way to ask the graph this question without a second copy of the include scan — flagged rather than smuggled.
    • includes::normalize is now pub (it was private). A renamed path and a resolved include are compared, and they must be folded the same way; a fourth private copy of that loop is the one thing that guarantees they drift. This is the same ./.. folding lucisv_core::filelist::Reader::normalize and lucisv_core::config::Discovery::absolute each have privately — the include-nav README's standing request to extract one lucisv_core::path::normalize and point all of them at it is still open, and this round deliberately did not widen its scope to do it.
  • lucisv_server::watch::watched is now pub (it was private). The notifications filter their paths with exactly the predicate a didChangeWatchedFiles event is filtered with — two copies of "is this a path the index reads" would drift, and the two paths must agree because a client may well send both for one rename.
  • lucisv_server::watch::SOURCE_GLOB is reused verbatim as the file-operation filter's glob, so the watcher and the file operations can never be asked about different sets of files.
  • Workspace::sources() for the sweep, Workspace::includes() for the graph, uri::{path_to_uri, uri_to_path} for the URIs (file-operation params carry String URIs, not parsed ones, so the parse happens in path_of).

Promised

  • lucisv_server::file_ops:
    pub fn file_operations() -> WorkspaceFileOperationsServerCapabilities;
    pub struct Rewrite { pub edit: Option<WorkspaceEdit>, pub warnings: Vec<String> }
    pub fn will_rename(ws: &Workspace, files: &[FileRename]) -> Rewrite;
    pub fn renamed(files: &[FileRename]) -> Vec<PathBuf>;
    pub fn deleted(files: &[FileDelete]) -> Vec<PathBuf>;
    pub fn touches_scope(paths: &[PathBuf], filelist: Option<&Path>) -> bool;
    
    Rewrite::edit is None when there is nothing to do, and the handler answers that as the protocol's null rather than as an empty edit.
  • Server::reindex_for(paths) — the notification half, one reindex() when the paths touch the index's scope. Deliberately not deduplicated against the watcher: a client is free to send both a didRenameFiles and a didChangeWatchedFiles for one rename, and the second rebuild is a pure re-read of the tree. It costs one scan and one diagnostics generation, never a different answer.
  • main.rs advertises workspace.fileOperations; report_scope's doc now says it serves these warnings too.

Not touched

No other crate. No new dependency. No version bump. verify.rs, the formatter and the linter are not on this path at all.

Cost

willRenameFiles sweeps the workspace once per request. Measured 2026-08-27 on the checked-in 860-file corpus, --release:

files read (sources()) 860
one rename, whole sweep ~54 ms
the index rebuild a save already pays ~320 ms

Most of it is the file read sources() does — the same read callHierarchy/incomingCalls (56 ms) and typeHierarchy/subtypes (55 ms) pay, and for the same reason. A text.contains("include")prefilter keeps the resolver off the ~86% of files that include nothing. Pinned by an#[ignore]d probe (cargo test --release -p lucisv_server --bin lucisv-server file_ops::tests::perf -- --ignored --nocapture), the same shape as includes.rs`'s: it prints and asserts nothing but the corpus's presence.

The sweep reads the includers, not the workspace (2026-08-28)

The prefilter above still cost a read of every file to run. On OpenTitan (3 976 files) that is 249 ms of sources() per gesture, and the server advertises willRename with a ** folder filter, so renaming any folder in the explorer paid it.

The include graph already holds the answer. IncludeGraph's edge table is built as scan(text).filter_map(|include| self.found(Some(path), include)) over every in-scope file, and resolve is exactly found followed by the index's own spelling of the result — so resolve answers Some for an include if and only if found did. Therefore:

A file with no entry in the edge table writes no `include this workspace can resolve, so every iteration of will_rename's inner loop over it hits let Some(old) = graph.resolve(…) else { continue }. It can produce neither an edit nor a warning, and reading it is reading the workspace to answer "nothing".

Workspace::include_sources is that set — IncludeGraph::includers() — plus every open buffer, because the graph is rebuilt on save and an `include typed and not yet saved is in the buffer and in no edge (an_unsaved_include_is_still_rewritten). The one-directional property is asserted directly over a hostile tree rather than argued (nothing_skipped_has_an_include_to_rewrite: every in-scope file the sweep skips is checked to have no resolving include, and the tree is asserted to actually exercise the skip).

Measured, --release:

before after
synthetic 506 files, 1 of them including anything reading the scope 16.1 ms reading the includers 18.9 µs; whole answer 35.4 µs
OpenTitan, 3 976 files, 331 of them includers sources() 249 ms whole answer 14.1 ms

Same staleness premise the rename family adopted the same day (docs/features/refactor-rename/README.md): the graph is the server's authority on who includes what, a file changed on disk with nothing telling this server is a file the sweep does not read, and open buffers are the exemption.

The notifications cost one reindex() each, which is the cost a save has.

Status / TODO

  • crates/lucisv_server/src/file_ops.rs: the capability shape, the sweep, the candidate spellings, the three safety checks, the post-rename filesystem model, the notification filters.
  • workspace/willRenameFiles dispatched in server.rs, answering WorkspaceEdit | null and reporting stranded includes through report_scope.
  • workspace/didRenameFiles + workspace/didDeleteFiles dispatched, one reindex() per notification that touches scope.
  • workspace.fileOperations advertised in main.rs — source-file filters for all three, plus a folder filter on willRename.
  • IncludeGraph::resolve_as_if / incdirs() / pub normalize, so there is still one search order and one path folding.
  • watch::watched made public, so the notifications and the watcher share one scope test.
  • The sweep reads the include graph's includers plus the open buffers rather than sources() (2026-08-28): IncludeGraph::includers, Workspace::include_sources, the one-directional property asserted over a hostile tree, and a before/after probe.
  • Tests: 24 in file_ops.rs, 7 in server.rs (dispatch, warning volume, reindex, watcher-double, unopened file, null), 1 in main.rs (the capability on the wire), 1 e2e session (real binary, edit decoded, applied, rename performed, include re-resolving).
  • cargo fmt, cargo clippy --all-targets, cargo test --workspace, node editors/vscode/smoke.js.
  • Not done, deliberately: willCreateFiles/didCreateFiles. A file that has just been created has nothing pointing at it to rewrite, and the watcher indexes it.
  • Not done, deliberately: willDeleteFiles. Refusing a delete the user asked for, or editing the includes of a file that is about to stop existing, is not this server's business; didDeleteFiles reindexes and the include simply stops resolving, which is the truth.
  • Not done, deliberately: the filelist is never rewritten. Renaming a file the .f names, or the directory an +incdir+ names, leaves the filelist stale — lucisv warns about a filelist naming a file that is gone on the very next rebuild, and fixing it is the user's call. Editing a project's build manifest from a rename gesture is a much bigger promise than this feature makes.
  • Not done, deliberately: an include in a file the scope ladder excludes is not rewritten. Same rule as everywhere else in the server.
  • Not done, deliberately: no documentChanges/renameFile operations in the answer — plain changes, as textDocument/rename returns. The client is doing the renaming; the server has only text to contribute.

Work log

2026-08-27 — dev agent, file operations (TODO.md §9c)

Built in the order the brief lists: the resolution extension first, then the sweep, then the dispatch, then the tests. Decisions worth recording:

  • resolve_as_if rather than a second resolver. The one thing this module needs that includes.rs did not have is "where would this include land if the filesystem looked like that". Writing that here would have been a second copy of the EDA rung order, three weeks after the include-nav round concluded that two scanners meant "documentLink and the graph disagreeing in exactly the corner cases nobody tests". So resolve grew an existence predicate and became a one-line call into the general form. No behaviour change: the ordinary path passes |p| p.is_file(), which is the expression it had inline.
  • Folder renames are handled, not declined — the brief left the choice to the code, and the code made it easy: Moves maps a path by prefix, and a file is just a prefix with no children. The whole folder story is one extra filter in the capability. Two tests pin it (a folder of headers moving, and an +incdir+ directory moving).
  • The rule grew a mirror half, deliberately. The brief scoped this to includes whose target is renamed. Writing the tests turned up the twin: an include breaks just as thoroughly when the file it is written in moves, because the own-directory rung goes with it — and that case would have been silent, with no edit and no warning. It is the same machinery (target = moves.after(old).unwrap_or(old), and the includer resolved from where it will be), so it shipped. a_file_that_moves_away_from_its_own_headers_is_re_spelled_too.
  • Two of the first tests were wrong, and the code was right. Both asserted an edit where the correct answer is no edit: a header moving into an +incdir+ under the same name, and a batch carrying includer and included into one new directory, both leave the line already reading correctly. That is what added the explicit "does it still resolve as written?" guard at the top of the loop — without it, the candidate ranking would have rewritten a perfectly good "../inc/defs.svh" into a bare "defs.svh" during an unrelated in-place rename, which is a diff the user did not ask for.
  • One real bug, found by a failing test, not by review. Moves::is_file compared paths lexically while the resolver hands it un-folded candidates like rtl/../inc/defs.svh — Path::is_file follows the .. itself, a prefix comparison does not. Every ..-relative candidate silently failed to verify, which showed up as "no spelling reaches it" on the two tests that need the relative fallback. is_file now folds first, through includes::normalize — the same fold the resolver's own result goes through, which is why that function is now pub rather than copied.
  • A renamed +incdir+ directory re-spells relatively rather than warning. The first draft warned, on the grounds that only the filelist can really fix it. The relative fallback resolves in every tool through the rung every tool has, so the source keeps compiling; the stale +incdir+ is a filelist problem lucisv already reports on the next rebuild. Pinned, with the trade-off written into the test.
  • report_scope reused rather than a second warning path. "Log all, show the first" is exactly the volume control this needs — a rename can strand forty includes as easily as a filelist can name forty missing files. Its doc comment now says so; no code moved.

Files touched outside this feature's own module, all of them the wiring the brief asked for: includes.rs (resolve_as_if, incdirs(), normalize made public — no behaviour change), watch.rs (watched made public), main.rs (the module, the workspace.fileOperations capability, one test), server.rs (the request arm, the two notification arms, reindex_for, one doc sentence on report_scope, seven tests), tests/e2e.rs (one session and one apply_edits helper).

Verification. cargo fmt --all -- --check clean; cargo clippy --all-targets silent; cargo test --workspace green — 2105 passing, 5 ignored, 33 of them new (24 file_ops, 7 server, 1 main, 1 e2e session) plus the ignored perf probe. node editors/vscode/smoke.js target/debug/lucisv-server → OK, 9 messages, unchanged from bf17ddd (checked against the stashed tree, not assumed — the new capability is static JSON and adds no message). Perf measured as above. No new dependency, no version bump, no other crate touched.

2026-08-28 — dev agent (performance wave, Lane A). The sweep stops reading the workspace. performance.md §6e flagged file_ops.rs:120's ws.sources() as the same shape as the rename family's, unmeasured; it is 249 ms of file reading per gesture on OpenTitan, and the server advertises willRename with a ** folder filter, so renaming any folder in the explorer paid it to learn that 3 645 of 3 976 files write no `include that resolves.

The include graph already holds that fact. IncludeGraph::includers() — four lines, the edge table's keys — is the new accessor, Workspace::include_sources is the set (includers plus every open buffer, because the graph is rebuilt on save and an unsaved `include is in neither raw nor edges), and will_rename's loop is otherwise untouched. The argument is one sentence long and is written up under "The sweep reads the includers, not the workspace": resolve is found plus a re-spelling, and raw is built from found, so a file with no edge has no include resolve answers — every iteration of the inner loop over it hits its first continue.

Rather than argue that by inspection alone it is asserted over a hostile tree: nothing_skipped_has_an_include_to_rewrite walks every in-scope file the sweep skips and checks each of its `includes resolves to nothing, and asserts the tree exercises the skip at all. Two behaviour tests beside it — the_narrowed_sweep_reads_the_includers_and_answers_the_same (24 files, 1 includer, 2 with dangling includes) and an_unsaved_include_is_still_rewritten.

Measured, --release: synthetic 506 files, reading the scope 16.1 ms → reading the includers 18.9 µs, whole answer 35.4 µs (perf::a_will_rename_before_and_after). OpenTitan, 3 976 files with 331 includers: sources() 249 ms → whole answer 14.1 ms (throwaway probe against the local checkout, deleted; no test depends on it).

One scope deviation, flagged not smuggled: includes.rs is outside the file list this lane was scoped to, and the accessor was added there anyway. The alternative was a second copy of the include scan inside state.rs, which is the one thing this module's Handshakes section already says must not happen. Recorded in Handshakes above and in the round's report.

Gates: cargo fmt --all -- --check clean, cargo clippy --all-targets clean, cargo test --workspace green, node editors/vscode/smoke.js OK.

QA log

2026-08-27 — QA agent, file operations (TODO.md §9c)

Re-ran every gate, then attacked the list the lead handed down. One real bug found and fixed (small, unambiguous, in-scope — fixed directly per the workflow rules rather than kicked back to dev); everything else the dev claimed held up, including the single highest-risk detail.

Verdict up front: the pre-rename-URI semantics are correct. will_rename keys every edit off the path Workspace::sources() handed it — which is always the file's current (pre-rename) location, including for the mirror case where the edited file is itself one of the files being renamed. Read the code to confirm, then pinned it at the wire level, which the dev's own e2e session did not cover (it only exercised "another file's edit," not "the moving file's own edit"): added a_moving_includer_s_own_edit_is_addressed_to_its_old_uri_on_the_wire to crates/lucisv_server/tests/e2e.rs — a real willRenameFiles round trip where the renamed file is also the includer needing the edit, asserting the WorkspaceEdit's changes map is keyed by the old URI and does not contain the new one. Passes.

Gates. cargo fmt --all -- --check clean. cargo clippy --all-targets --workspace silent (one warning surfaced in a QA-added test — clippy::for_kv_map on for (_, edits) in &map — fixed to .values(), noted below). cargo test --workspace: 2114 passed, 0 failed, 5 ignored (2105 baseline + 1 e2e test + 8 new file_ops QA tests). Two full runs of cargo test -p lucisv_server file_ops:: diffed byte-for-byte except for parallel test-execution order — no flakiness. node editors/vscode/smoke.js target/debug/lucisv-server → OK, 9 messages.

Finding 1 (MEDIUM, fixed) — candidate_spellings silently fails when the includer's own path isn't already ./..-folded. crates/lucisv_server/src/file_ops.rs, candidate_spellings (now around line 293) and relative_spelling. target (the rename's destination) always reaches candidate_spellings normalized — both graph.resolve and Moves::after fold ./.. before returning. includer did not: it comes straight from Workspace::sources(), which inherits whatever self.roots was given at open_roots, unnormalized. target.strip_prefix(dir) and relative_spelling's common-prefix walk are pure path-component algebra run before anything touches the filesystem, and Path's components compare a literal ParentDir (..) as different from the directory it resolves to — so when includer's directory carries an unfolded .. and target doesn't, every rung silently fails to match, even the trivial "keep it bare" spelling for a same-directory rename. The include then gets a spurious "no include path reaches it" warning instead of the one-word edit it should get. Caught by the corpus-scale probe (below), not by any of the dev's or my hand-written unit tests — every Tree-based test in this feature builds ws.open_roots(vec![tree.path.clone()]) from an already-clean std::env::temp_dir()-based path, so the bug had no way to show up there. resolve/resolve_as_if's own existence checks (Path::is_file, Moves::is_file) were never affected — both fold .. themselves before deciding, which is exactly why only this one pure-path step needed the fix. Fixed with one line, normalizing includer at the top of candidate_spellings before anything derives from it; comment explains why, inline. Real-world exposure: narrow but not zero — workspace_roots in main.rs never normalizes a client's rootUri/workspace_folders URI either, so any workspace root a client hands over with an unresolved ./.. segment (unusual, but not forbidden by the URI grammar) would have hit this on every single same-directory rename, the most common case there is. Pinned by the corpus probe test itself (below), which fails without the fix and passes with it — no separate minimal regression test added, since the probe already exercises the exact shape that triggers it and a synthetic Tree-based one would have to manufacture a dirty root on purpose, which is what the probe already is.

Attack surfaces, in the order asked for:

  1. Wrong-edit hunts at the resolution boundary — verified clean. Added a_shadow_between_an_own_dir_file_and_an_incdir_file_is_never_crossed: two defs.svh, one reached only via the includer's own directory and one only via an +incdir+, so a name-matching implementation would cross them. Renaming either one touches only the file that resolves to it, in both directions. resolve_as_if's delegation from resolve is the same inlined closure resolve used before (&|path| path.is_file()) — no include-nav test needed updating, and the full suite confirms documentLink/definition/hover behavior is unchanged.
  2. The three checks, adversarially — verified clean, one gap closed. (a) the_edit_range_is_exact_with_tab_indentation_and_a_block_comment: tabs for indentation, a /* block */ trailing comment instead of the dev's // line comment, byte range decoded and checked against the raw text — exact. (b) a_rename_target_whose_name_contains_the_quote_delimiter_is_refused_not_written: POSIX allows " in a filename (confirmed creatable on this filesystem), and with no other candidate spelling available the module is forced to either refuse or write a corrupting line — it refuses, warns, and the source file on disk is provably untouched. Also a_rename_to_a_name_with_a_space_or_non_ascii_text_is_written_correctly: space and non-ASCII (défs.svh) are legal inside quotes and both rewrite cleanly — the "total, correct" half of the same question. (c) the dev's a_spelling_that_would_resolve_somewhere_else_is_not_written is a genuine shadow: rtl/defs.svh pre-exists beside the includer, the bare candidate for the renamed inc/old.svh → inc/defs.svh would resolve to the wrong file via the own-directory rung, and the longer ../inc/defs.svh is written instead — read through by hand and confirmed live by the suite.
  3. The mirror case (includer moves) — verified clean, see the verdict above. Moves's own-dir-move handling and the pre-rename URI addressing are both correct.
  4. Directory renames by prefix — verified clean. a_directory_rename_does_not_claim_a_sibling_with_a_shared_string_prefix: rtl → rtl2 with a rtl_extra/ sibling holding its own decoy header, both referenced relatively from outside their own directories (so the test actually forces an edit rather than landing on the includer-and- included-move-together no-op). rtl_extra's file is never touched, and Moves's mapped/strip_prefix is checked directly too: Path::strip_prefix is component-wise, not string-wise, so rtl_extra was never at risk from this angle. Nested batch: a_directory_rename_and_a_file_rename_inside_it_do_not_compound — characterized, not "fixed": Moves::after uses find_map, so a directory rename and an explicit rename of a file inside it (a batch shape a spec-compliant client should not send, per LSP's "only the folder's own URI" rule, but nothing stops one from doing it) do not compound; whichever entry is listed first in params.files wins for any path under that directory, and the other is silently shadowed. Not corruption — whatever spelling gets written is still checked against whichever model Moves produced — but it is order-dependent in a way nothing documents. Recommendation for dev, not fixed here (out of QA's remit to redesign): either note this explicitly in the Assumptions section as an accepted ambiguity, or have Moves::announced detect a file entry nested under a directory entry in the same batch and drop the redundant one with a warning. Low priority — real clients don't appear to construct this shape.
  5. Batch semantics — verified clean. a_batch_where_both_the_includer_and_the_included_move_needs_both_moves_modeled: includer moves two directories deep, included file moves to an unrelated directory, in one batch. Chose depths that make "only one move modeled" produce a textually different, wrong answer both ways (dropping the includer's move is one .. short; dropping the included file's move points at the old directory) — the actual answer is neither, confirming Moves truly models both simultaneously rather than one overwriting the other. The dev's own a_batch_that_carries_includer_and_included_together_writes_nothing is a real instance of this too (a no-op requires both moves to be seen together), just not one that discriminates between hypotheses on its own.
  6. didRename/didDelete — verified clean. Read reindex_for and the dispatch arms; the dev's own tests already cover in-scope → one reindex, out-of-scope → none, and the watcher-double case, and pass. Generation bumps once per reindex() call, so a client sending both didRenameFiles and a watcher event for the same move bumps it twice — documented as intentional ("a pure re-read of the tree"), matches a_rename_notification_rebuilds_the_index's own assertion, no pull-diagnostics correctness issue (content converges, resultId just changes an extra time).
  7. Capability shape on the wire — verified clean. main.rs's the_file_operations_reach_the_wire_under_workspace and file_ops.rs's the_capability_names_the_operations_this_server_answers pin the exact JSON; folder filter present only on willRename, absent on both notifications, confirmed. Case sensitivity: the glob match is entirely the client's job (VS Code decides whether TOP.SV matches **/*.{v,vh,sv,svh} before it ever sends the request) — nothing in this server's code path is involved, so there is nothing here to fix or test; noting it per the brief's "don't over-engineer."
  8. CLAUDE.md compliance — verified clean. No unwrap()/expect()/ panic! outside #[cfg(test)] in any of file_ops.rs, server.rs, main.rs, watch.rs, includes.rs (checked with a diff-scoped grep). Every public item has a one-line doc comment. This README's sections each appear exactly once. TODO.md's §9c item text is unchanged; only its checkbox flipped and a delivery summary was appended below it, per the "leave the item text intact" rule. verify.rs does not appear in the diff at all.

Beyond the list — corpus-scale probe. prim_assert.sv (a single real file in corpus/ibex/vendor/lowrisc_ip/ip/prim/rtl/) is included, own- directory rung, by 87 sibling files in that same directory — real fan-out, not a synthetic tree. Added a_real_corpus_header_with_wide_fan_out_is_swept_correctly_and_deterministically: sweeps the whole corpus with will_rename twice (identical file/warning counts both times), then independently re-derives, for every produced edit, whether the written spelling resolves to the new location once the modeled rename has happened (built the check from resolve_as_if + Moves::announced directly, deliberately not by calling back into survives, so it is a genuine second opinion) — and confirms every touched file's directory is the one real directory that includes this header, nothing else. This is the test that caught Finding 1: it failed outright before the fix (no edit was produced for any of the 87 files — every one came back as a false "unreachable" warning) and passes cleanly after.

Test tally added this round: 8 in file_ops.rs (qa_2026_08_27_attacks, nested under mod tests), 1 in tests/e2e.rs. cargo test --workspace: 2114 passed (was 2105 before this QA round; +1 e2e +8 file_ops, net of the 9 new tests exactly).

Verdict: not committable as-is until Finding 1's fix is included — which it now is, applied directly in this same working tree (small, unambiguous, in-scope per the workflow rules). With the fix in place and all eight attack surfaces plus the corpus probe green, this is committable. Item 4's nested-batch ordering is a documentation/robustness suggestion for the dev, not a blocker — no corruption path exists even in that shape, thanks to the safety net doing its job independently of what Moves models.

2026-08-28 — QA agent (performance wave, Lane A). Verified the round that moves will_rename's sweep off ws.sources() onto Workspace::include_sources() (the include graph's includers(), plus open buffers). Worked alongside the rename-family QA pass in the same worktree; see docs/features/refactor-rename/README.md's QA log for the shared gate run.

Gates

cargo fmt, cargo clippy --all-targets, cargo test --workspace (0 failures workspace-wide) and node editors/vscode/smoke.js all pass — see the refactor-rename QA entry for the exact run, which covered this round's diff in the same pass. file_ops::tests::perf::one_rename_sweeps_the_whole_corpus_in_milliseconds and includes::tests::perf::building_the_graph_over_the_whole_corpus_is_milliseconds fail in this worktree because corpus/ is not checked out here; confirmed pre-existing (unchanged by this diff, present at HEAD before it) and unrelated.

Attacks

The safety-net argument this narrowing rests on ("a file with no entry in the edge table writes no `include this workspace can resolve") is mechanical and did not need attacking on its own terms — nothing_skipped_ has_an_include_to_rewrite already asserts it directly over whatever tree a test builds. What was worth attacking is whether includers() narrows in every file that matters, not just the ones the dev's own tree happened to build:

  • An include chain, a.svh -> b.svh, with a third file c.sv -> a.svh never spelling b.svh at all. Renaming b.svh must narrow to a.svh (its direct includer) and rewrite only it; c.sv must not be mistaken for a candidate even though it transitively depends on the moved file through a.svh. Added an_include_chain_narrows_to_the_direct_includer_of_the_moved_file — passes: will_rename only ever rewrites a direct include of the moved file, which is exactly what includers() (a flat key set, not a reachability walk) bounds.
  • A case-mismatched include spelling — `include "DEFS.svh" written against a real defs.svh on disk, which macOS's default case-insensitive filesystem (confirmed case-insensitive on this machine) resolves silently. IncludeGraph::found/found_as_if key raw by the includer's own path, not the target's spelling, so the case mismatch does not stop the includer from landing in includers(). Added a_case_mismatched_include_spelling_still_narrows_in_and_rewrites — passes, narrows in and rewrites correctly.
  • Unsaved includer, and the property test's own coverage — re-read an_unsaved_include_is_still_rewritten and nothing_skipped_has_an_include_to_rewrite; both hold and both are exercised (assert!(skipped > 0, ...) in the property test actually forces the tree to have skippable files, so the property is not vacuously true).

No divergence found: every file will_rename would have read under the old ws.sources() sweep and actually needed (an includer of something that resolves) is still read under include_sources(), and no file that used to be read-and-skipped is now silently mis-included either. The includes.rs scope deviation the dev flagged (a four-line, purely additive accessor, outside Lane A's stated file list) is accepted as argued — the only alternative was a second copy of the include scan, which the feature's own Handshakes section already forbids.

Summary

Claim Verdict
Gates Pass
includers() narrows in every file that can produce an edit or a warning Holds under an include-chain attack and a case-mismatched-spelling attack, beyond the dev's own tree
Scope deviation (includes.rs::includers) Accepted, correctly flagged, minimal

Verdict: ship. No findings against this round's diff. (The rename family's own residue finding, which needs the lead's ruling, is filed in docs/features/refactor-rename/README.md and does not touch this feature.)

Review

2026-08-29 — lead, performance-wave Lane A (willRenameFiles). The includers() narrowing is the same discipline as the rename fan-out applied to the include graph, QA's chain/case-spelling/unsaved attacks all pinned, and the property test ("nothing skipped has an include to rewrite") is the right shape of guarantee. Accepted; merged by the lead.

2026-08-27 — lead

Reviewed the diff, the work log and the QA log; re-ran all gates myself (2114 workspace tests, 0 failed), clean. For a feature that writes user files, the shape is right: resolution-not-name matching, a three-check safety net that refuses rather than guesses, and the mirror case the brief missed shipped with the same machinery rather than a special case. The two dev deviations are both accepted as argued — the moving includer's own-dir rung genuinely breaks, and re-spelling under a renamed +incdir+ beats warning about a filelist this server rightly does not edit.

The round's two QA results are exactly why the corpus probe belongs in every write-path charter: the unnormalized-includer bug made the most common rename shape (same directory) silently fail into a warning, and no hand-written fixture caught it — 87 real includers of a real ibex header did. And the pre-rename-URI wire test QA added covers the one detail that would have failed invisibly in real editors (a client drops an edit addressed to the post-rename uri). I applied QA's recommendation as an Assumptions entry: batch renames do not compound, recorded as a documented choice with the safety net bounding the failure mode at a skipped edit plus a warning. Accepted as shipped.