Owner-requested round. The scope ladder: a filelist still defines the whole project and outranks everything; lucisv.index.scope=workspace restores the walk-the-roots behavior (the same function, not an equal-output one — pinned); the new default walks only the union of folders a buffer has been opened from, each raised lucisv.index.scopeDepth ancestor levels (default 0), clamped at the deepest containing root. Opening a file outside the scope widens it and reindexes through the existing progress/generation machinery; scope grows only along the open axis within a session. Cross-file answers are scope-relative and the docs say so loudly, with the one-line migration in the setting description. The round also closes indexing-ux QA's MEDIUM builder footgun: IndexBuilder::finish now sorts and dedups before assigning FileIds, so no insertion order can reach the result — pinned by a permanent three-order fingerprint test — which makes feeding open files first provably a progress nicety. 151 existing tests swept mechanically (QA sampled 40+ sites: constructor swaps only); lead fixed the one vacuous tail QA found plus two premise/comment hygiene items. 19 tests added. Known deltas documented: a root's .gitignore does not reach a walk starting below it (filed against lucisv_core); rootless depth-0 keeps its flat read; startup index is empty until the first didOpen. docs/features/index-scope/README.md Co-Authored-By: Claude Fable 5 <[email protected]>
607 lines
39 KiB
Markdown
607 lines
39 KiB
Markdown
# index-scope
|
||
|
||
## Goal
|
||
|
||
Open-file-first indexing for a project too big to scan. Until this round the
|
||
server had two answers to "which files exist": a filelist, or **every file
|
||
under every workspace folder** — and on a large codebase the second one costs
|
||
minutes on every save, to answer questions about the handful of folders the
|
||
user is actually in. This round makes the walk follow the *open buffers*
|
||
instead: `lucisv.index.scope` (`"folder"` by default) scopes the index to the
|
||
folders the open files live in, `lucisv.index.scopeDepth` says how far above
|
||
each one to start looking for relative files, and opening a file in a folder
|
||
the scope does not cover widens it and reindexes. A filelist still outranks
|
||
everything — it is the project file — and `"workspace"` restores the old walk
|
||
for anyone who wants it. The same round closes the ordering footgun the
|
||
previous round's QA found in `vlog_semantic::IndexBuilder`, which is what makes
|
||
the second half of the change safe: **the open buffers' files are fed to the
|
||
builder first**, so the progress bar completes the user's own files first, and
|
||
that is provably a reporting decision with no effect on the index.
|
||
|
||
## Assumptions
|
||
|
||
- **The scope ladder is one ladder with a new rung 3.** Highest first:
|
||
(1) a filelist — `lucisv.filelist`, else a `filelist` key in a root's config
|
||
— defines the scope exactly, unchanged and whole-project;
|
||
(2) `lucisv.index.scope: "workspace"` walks every workspace folder, which is
|
||
what every session did before this round;
|
||
(3) the default: the folders the open buffers live in, each raised
|
||
`lucisv.index.scopeDepth` levels, walked. Rung 2 needs a root to mean
|
||
anything, so a rootless session is folder-scoped whatever it says.
|
||
- **This is a behaviour change for every workspace user, and the honest
|
||
statement of it is that cross-file answers are scope-relative.** A symbol in
|
||
a folder the scope has not reached does not exist as far as this server is
|
||
concerned: `textDocument/definition`, `workspace/symbol`, the call and type
|
||
hierarchies, `find_references` and a workspace rename all answer within the
|
||
active scope, exactly as they already did within a filelist's. **The
|
||
migration line is `"lucisv.index.scope": "workspace"`**, which restores the
|
||
old behaviour exactly (pinned by
|
||
`the_workspace_scope_setting_restores_the_walk_of_every_root`).
|
||
- **The scope only ever grows within a session.** It is derived from every
|
||
directory a buffer has been opened *from* (`Workspace::opened_dirs`), not
|
||
from the buffers currently open, so `didClose` narrows nothing and costs no
|
||
rescan. The alternative — recomputing from the open set — would take a
|
||
working answer away at the next unrelated save, which is a worse surprise
|
||
than an index that is slightly larger than the editor's tab bar. It is also
|
||
the cheap choice: no reindex on close, and no reindex-on-close churn while a
|
||
user cycles through files.
|
||
- **`didOpen` rebuilds exactly when it widened the scope.** The rule is one
|
||
comparison of the scope directories across `set_document`, and it replaces
|
||
the old `has_roots()` branch (rootless reindexed, rooted published) with the
|
||
question that branch was really asking. Consequences, both deliberate: a
|
||
rootless session opening a *second* file in an already-scanned directory no
|
||
longer rebuilds (it used to, always), and a session on the filelist or
|
||
workspace rung never rebuilds on `didOpen`, because no open buffer can widen
|
||
those scopes.
|
||
- **The `didOpen` check costs two `scope_dirs()` calls, and each one asks
|
||
`filelist_path()` whether rung 1 is in force.** That is a `Discovery` walk up
|
||
from each root looking for a config — a handful of `exists()` calls, on an
|
||
event that is already about to reanalyze a whole buffer, and orders of
|
||
magnitude cheaper than the rebuild it decides against. Named here because it
|
||
is the one new per-notification cost this round adds.
|
||
- **A workspace folder is a clamp on the folder rung, not a work list.**
|
||
Adding one mid-session changes which files exist only once a buffer in it
|
||
makes it a scope directory; what it does change immediately is how far the
|
||
climb may go (see below). Removing one likewise only loosens the clamp. The
|
||
rescan `didChangeWorkspaceFolders` already triggers is unchanged.
|
||
- **The climb is clamped at the deepest workspace root containing the
|
||
directory** — that is what keeps `scopeDepth: 5` in a two-deep project from
|
||
indexing a home directory. **With no root there is nothing to clamp against
|
||
and the only floor is `/`**: the loop terminates there rather than spinning,
|
||
and the setting means exactly what it says. The rootless default is 0, so
|
||
nobody reaches this without asking for it; it is called out in the setting's
|
||
own description.
|
||
- **The rootless case is unchanged at the default.** A file opened on its own,
|
||
at depth 0, still gets a flat one-level read of its directory — no walk, no
|
||
`.gitignore` —
|
||
(`with_no_workspace_root_the_open_files_own_directory_is_indexed`, untouched
|
||
this round). The moment a rootless session raises `scopeDepth` it has named
|
||
a tree, so the raised directory is walked instead; that is the one place the
|
||
rung's behaviour depends on the depth being non-zero, and it is what stops a
|
||
raise from *losing* the file's own siblings.
|
||
- **One honest filter gap: a root's `.gitignore` does not reach a walk that
|
||
starts below it.** `lucisv_core::walk` reads ignore files from the walk's own
|
||
starting directory downwards, so a rule written at the workspace root is not
|
||
applied when the folder scope starts at `rtl/`. Every `exclude` pattern —
|
||
the config's and the pushed one — is matched against whole paths and is
|
||
unaffected. Pinned both ways in
|
||
`the_folder_scope_honours_every_exclude_and_the_gitignores_below_it`, rather
|
||
than left to be discovered. The fix belongs in `lucisv_core`'s walk (parent
|
||
ignore files, as the `ignore` crate does it) and is filed, not done: it is a
|
||
change to the CLI's walk semantics too, which is not this round's scope.
|
||
- **The startup index is empty, and that is the point.** No buffer is open at
|
||
`initialize`, so the folder scope has no folder yet; the first `didOpen`
|
||
widens it and rebuilds. On a huge project this is the whole saving. It also
|
||
means a client whose settings say `"workspace"` still gets one empty startup
|
||
scan and then a rescan when its settings land — the same one extra rescan
|
||
`lucisv.exclude` and `lucisv.filelist` have always cost, for the same reason
|
||
(neither settings door can deliver before `initialized`).
|
||
- **Open buffers still overlay every rung.** A buffer's text beats disk and a
|
||
buffer outside the scope still contributes itself, exactly as with a
|
||
filelist. Nothing about diagnostics, formatting or any single-file feature
|
||
depends on the scope: the per-buffer analysis is bottom-up and instant, and
|
||
this round does not touch it.
|
||
- **Wrong-typed settings fall back to the *narrow* default**, the same
|
||
direction `maxFileSize` falls back to the cap: a misparse must not silently
|
||
buy a whole-workspace scan. `"scope"` is matched exactly — `"Workspace"` is
|
||
junk — because the enum in `package.json` is what a settings UI offers and
|
||
forgiving it here would make a typo mean different things on different
|
||
clients.
|
||
- **The progress denominator, the cap counts and the output log follow the
|
||
active scope for free.** They all read the same work list
|
||
(`index_order`'s length, known before the first parse), so nothing was
|
||
re-plumbed; verified by `the_bar_names_the_open_file_before_the_rest_of_the_scope`
|
||
and by the e2e transcript, whose startup bar honestly ends `0 files indexed`.
|
||
|
||
## Handshakes
|
||
|
||
### `vlog_semantic` — `IndexBuilder` is order-insensitive
|
||
|
||
The previous round shipped `IndexBuilder` as a dumb accumulator whose ordering
|
||
contract was a doc comment ("feed it `index_order`'s list"), and its QA proved
|
||
that a caller who did not got different `FileId`s and a different winner for a
|
||
name two files declare (indexing-ux README, QA log 2026-08-27, MEDIUM). That is
|
||
closed by construction:
|
||
|
||
```rust
|
||
pub fn add_file(&mut self, path: PathBuf, src: &str); // parses, keeps FileFacts
|
||
pub fn finish(mut self) -> WorkspaceIndex; // sorts by path, dedups, merges
|
||
```
|
||
|
||
- `add_file` parses its file and reads off what it declares into a private
|
||
per-file record (`FileFacts`: the path, the `` `define`` table, the file-scope
|
||
declarations in declaration order, the members in traversal order). **The
|
||
parse still happens in `add_file`**, so a caller reporting progress between
|
||
calls is reporting work that has really been done.
|
||
- `finish` sorts those records by path — `sort_by` is stable, `dedup_by` keeps
|
||
the first of a run, which is exactly `index_order`'s rule — and only then
|
||
hands out `FileId`s and merges the declarations into the `units`/`members`
|
||
tables. No insertion order can reach the result.
|
||
- **`WorkspaceIndex::build` is byte-identical for every existing caller**, and
|
||
the proof is that all 31 pre-existing `vlog_semantic` tests are unchanged and
|
||
green, including `file_ids_follow_the_sorted_paths_whatever_order_they_arrive_in`,
|
||
`a_module_declared_in_two_files_is_ambiguous_in_path_order` and
|
||
`the_incremental_builder_is_what_build_is_made_of`. `build` still calls
|
||
`index_order` first — not for correctness now, but so a duplicate path is not
|
||
parsed twice.
|
||
- **Why this shape and not a type-enforced two-phase API.** The alternative the
|
||
brief allowed was a builder that cannot be misused because the types forbid
|
||
it — an `UnsortedBuilder` that only a `SortedFiles` value can be fed. That is
|
||
a second type, a second constructor and a conversion, to protect an invariant
|
||
that a five-line `sort_by`/`dedup_by` in `finish` removes outright. Making
|
||
the wrong call impossible beats making it a compile error when it costs less.
|
||
The cost is memory: the per-file records for the whole workspace are held
|
||
until `finish`, which is the same data the finished index holds (names,
|
||
spans, kinds), partitioned rather than merged — no `Semantics` and no source
|
||
text is retained.
|
||
- Permanent re-attack: `no_insertion_order_can_change_what_the_builder_produces`
|
||
(the QA pair plus a nested-class/defines fixture, in three orders, compared
|
||
by a full fingerprint of files, ids, disambiguation order, member tables and
|
||
define counts) and `a_path_added_twice_is_one_file_whichever_end_the_duplicate_is_at`.
|
||
- `index_order` stays public and unchanged: the server needs the work list's
|
||
*length* before the first parse for the progress denominator.
|
||
|
||
### `lucisv_server::settings`
|
||
|
||
- Two new fields, `index_scope: IndexScope` (`Folder` | `Workspace`, default
|
||
`Folder`) and `index_scope_depth: u64` (default 0), parsed from
|
||
`lucisv.index.scope` / `lucisv.index.scopeDepth`. Nested under `index` like
|
||
the other two, so both settings doors — push and pull — carry them with no
|
||
new code (`the_index_settings_come_through_the_pull_door_too`).
|
||
- `IndexScope` is public; `state.rs` matches on it.
|
||
|
||
### `lucisv_server::state`
|
||
|
||
- `Workspace::scope_dirs() -> Vec<PathBuf>` is **new and public**: the
|
||
directories the folder scope walks, or empty when the folder rung is not in
|
||
force. `server.rs` compares it across a `didOpen`.
|
||
- `Workspace::set_document` now also records the buffer's directory. It is the
|
||
one place a directory enters the scope.
|
||
- `walked_files` takes the directories to walk instead of reading `self.roots`;
|
||
`sibling_files` is a free function taking the same list.
|
||
- `has_roots()` is `#[cfg(test)]` now — `didOpen` was its only production
|
||
caller.
|
||
- Test-only `open_whole_workspace` / `open_whole_workspace_with` are the
|
||
one-line spelling of "this test wants the pre-round scope", used by the
|
||
dozens of tests across the crate whose subject is a hover or a rename rather
|
||
than the scope.
|
||
|
||
### `lucisv_server::server`
|
||
|
||
- `didOpen` reindexes when `scope_dirs()` moved, else publishes. One rule for
|
||
rootless and rooted; the rebuild rides the existing bar, generation bump,
|
||
code-lens refresh and republish.
|
||
- `Server::started(connection, roots, abilities, ClientSettings)` is the real
|
||
constructor and `Server::new` delegates to it with the defaults. The
|
||
parameter exists for the tests, which is stated where it is written: a test
|
||
whose subject is not the scope starts from the wide scope rather than driving
|
||
a `didChangeConfiguration` and then reasoning about the extra rescan.
|
||
|
||
### `editors/vscode`
|
||
|
||
- Two new `contributes.configuration` properties, both carrying the honesty
|
||
notes: what stops being answered, that the scope grows and never shrinks,
|
||
the migration line, and that a filelist overrides both. No `extension.js`
|
||
change — the whole `lucisv` section including the nested `index` object is
|
||
already synchronized.
|
||
|
||
## Status / TODO
|
||
|
||
- [x] `lucisv.index.scope` (`"folder"` default, `"workspace"` opt-in), both
|
||
settings doors, junk → the narrow default
|
||
- [x] `lucisv.index.scopeDepth` (default 0), clamped at the deepest containing
|
||
workspace root, and at `/` with no root
|
||
- [x] Filelist still outranks both; `scope`/`scopeDepth` ignored on rungs 1–2
|
||
- [x] `didOpen` widens the scope and reindexes; the rootless branch unified
|
||
into the same rule
|
||
- [x] Scope only grows within a session; `didClose` costs no rescan
|
||
- [x] Both settings join the rescan condition; `logFiles` still does not
|
||
- [x] Open buffers' files fed to the builder first; progress reports name them
|
||
first
|
||
- [x] `IndexBuilder` order-insensitive, with the QA attack as a permanent test
|
||
- [x] `package.json` descriptions carry the scope-relative-answers warning and
|
||
the migration line
|
||
- [x] 19 new tests (12 state, 2 server, 1 e2e, 2 vlog_semantic, 2 settings),
|
||
3 existing ones extended, 1 superseded test rewritten; every other test
|
||
in the crate that wanted the whole workspace now says so
|
||
- [ ] **Not done, deliberately:** no `lucisv.toml` key for either setting. They
|
||
are editor-session resource settings — how much of *this machine's* time
|
||
to spend — not project style, the same reason `maxFileSize` has none.
|
||
- [ ] **Not done, deliberately:** no shrink-on-close, no LRU on the scope, no
|
||
time-based eviction. All three are guesses at a problem nobody has
|
||
reported; the escape hatch for a session that grew too wide is to
|
||
restart it or set a filelist.
|
||
- [ ] **Filed, not done:** `lucisv_core::walk` does not read `.gitignore` files
|
||
above its starting directory, so a root-level ignore rule does not apply
|
||
to a folder-scoped walk. Fixing it changes the CLI's walk too.
|
||
- [ ] **Filed, not done:** the folder scope makes the write-path honesty gap
|
||
the previous round's QA found sharper — a workspace rename now rewrites
|
||
only what is in scope, and says nothing about what is not. The follow-up
|
||
task the lead filed for the size cap covers exactly this and should name
|
||
the scope too.
|
||
|
||
## Work log
|
||
|
||
### 2026-08-27 — dev agent (open-file-first indexing, folder-scoped walk)
|
||
|
||
- **The builder was hardened first, because the ordering change depends on
|
||
it.** Feeding the open files first is only free if insertion order provably
|
||
cannot reach the index, so `IndexBuilder` was rewritten to accumulate
|
||
`FileFacts` and sort in `finish` *before* anything in the server was
|
||
reordered. The five-line sort beat the type-enforced two-phase alternative
|
||
on every axis that matters here (one type instead of three, no conversion,
|
||
and the misuse becomes impossible rather than merely uncompilable); the price
|
||
is that the per-file records live until `finish`, which is the index's own
|
||
data partitioned rather than merged. `WorkspaceIndex::add_file`/`add_members`
|
||
became the free `facts_of`/`collect_members` with the same traversal, so the
|
||
merged tables come out in the same order they always did — which is why all
|
||
31 existing tests are byte-identical and green.
|
||
- **The scope ladder went in `source_files`'s rung 3, not beside it.** The
|
||
filelist rung and the walk are untouched; `default_files` now chooses between
|
||
`walked_files(&self.roots)` and `folder_files()`, and `folder_files` is
|
||
`walked_files(&scope_dirs())` with the one rootless exception. That kept the
|
||
exclude/gitignore/cap plumbing literally the same function, which is what
|
||
makes "every filter still applies" a fact rather than a claim.
|
||
- **`opened_dirs`, not `docs`, is what the scope is derived from.** This is the
|
||
close-shrink decision: the scope grows within a session and never narrows.
|
||
Deriving from the open documents would have been one less field, but it makes
|
||
`didClose` silently change what the *next* save indexes, which is a worse
|
||
surprise than a scope that is a few folders wider than the tab bar. It also
|
||
keeps `didClose` free of any rebuild.
|
||
- **`didOpen`'s branch is now one comparison, and it subsumes the rootless
|
||
rule.** `has_roots()` was answering "can an open buffer widen the scope?" by
|
||
proxy; `scope_dirs()` answers it directly and correctly on all three rungs.
|
||
Two deliberate deltas fell out and are documented: a rootless session opening
|
||
a second file in a directory it already read no longer rebuilds, and a
|
||
rootless session with a filelist no longer rebuilds on open either (the
|
||
filelist defines the scope; the buffer is overlaid at the next rebuild
|
||
regardless).
|
||
- **The clamp is the deepest containing root, not the first.** With nested
|
||
workspace folders the tighter floor is the honest one — the user opened both,
|
||
and the inner one is the more specific statement about that file.
|
||
- **The rootless flat read is kept at depth 0 and only at depth 0.** Turning it
|
||
into a walk would have changed the "a file opened on its own" case that has
|
||
its own documented reason to be shallow; leaving it flat at *every* depth
|
||
would have made `scopeDepth: 1` index the parent directory while losing the
|
||
file's own siblings, which is worse than either. So: unchanged at the
|
||
default, walked the moment the user raises the depth, and both halves pinned.
|
||
- **The startup scan indexes nothing now**, because no buffer is open yet. That
|
||
reads as alarming and is exactly the feature: the e2e transcript's first bar
|
||
ends `0 files indexed`, the `didOpen` bar reports the real file, and that
|
||
sequence is asserted on the wire.
|
||
- **The blast radius was 151 tests, and the honest fix was to make each of them
|
||
say what scope it wants.** Every test across the crate whose subject is not
|
||
the scope now calls `Workspace::open_whole_workspace` or `Session::wide`
|
||
instead of the plain form — a mechanical, reviewable change that leaves each
|
||
test exercising exactly what it exercised before, with the scope no longer a
|
||
hidden variable. Four settings pushes inside those tests gained
|
||
`"scope": "workspace"` for the same reason a push replaces every field. The
|
||
new default's own behaviour is covered by the 22 new tests rather than by
|
||
accident.
|
||
- **One test was superseded rather than repaired.**
|
||
`a_rootless_session_gaining_its_first_folder_flips_didopen_from_reindex_to_publish`
|
||
pinned the branch this round deletes; it is replaced by
|
||
`a_didopen_rebuilds_exactly_when_it_widens_the_scope`, same case list, under
|
||
the rule that replaced it, with an explicit `Superseded this round:` note in
|
||
the house style.
|
||
- **Two e2e expectations moved, both of them the model becoming visible on the
|
||
wire:** `indexing_reports_its_progress_over_the_wire` now shows three bars
|
||
(empty startup, the widening `didOpen`, the save) with the honest end
|
||
messages, and `a_save_asks_a_capable_client_to_refresh_its_code_lenses_over_the_wire`
|
||
counts two refreshes because there are now two rescans in its script.
|
||
- **The `.gitignore` gap was found by a failing test I had written to assert
|
||
the opposite**, and is documented and pinned as a delta rather than papered
|
||
over or "fixed" by reaching into `lucisv_core`'s walk, which is the CLI's
|
||
too.
|
||
- Files touched: `crates/vlog_semantic/src/workspace.rs`,
|
||
`crates/vlog_semantic/tests/workspace.rs`,
|
||
`crates/lucisv_server/src/settings.rs`, `crates/lucisv_server/src/state.rs`,
|
||
`crates/lucisv_server/src/server.rs`, `crates/lucisv_server/tests/e2e.rs`,
|
||
the test modules of `completion/hierarchy/file_ops/includes/inlay/hover/lens/
|
||
nav/ports/rename/type_def/type_hierarchy/signature/symbols` (constructor
|
||
swap only), `editors/vscode/package.json`,
|
||
`docs/features/lucisv-server/README.md`,
|
||
`docs/features/indexing-ux/README.md`, this README. No new dependency, no
|
||
version bump, no `CHANGELOG` edit, no `docs/site/`, no commits.
|
||
|
||
**Verification.** `cargo fmt --all -- --check`: clean. `cargo clippy
|
||
--all-targets --workspace`: zero warnings. `cargo test --workspace`: **2217
|
||
passed, 0 failed** (2198 on `HEAD`, measured — 19 new). `cargo test -p vlog_formatter`:
|
||
green, untouched. `cargo build && node editors/vscode/smoke.js
|
||
target/debug/lucisv-server`: `smoke: OK`. `node -e JSON.parse(package.json)`:
|
||
parses.
|
||
|
||
The 19 new tests, the 3 extended and the 1 rewritten, and what each is for:
|
||
|
||
| test | pins |
|
||
|---|---|
|
||
| `no_insertion_order_can_change_what_the_builder_produces` (vlog_semantic) | QA's attack, three orders, full fingerprint — ids, disambiguation winner, member tables, defines |
|
||
| `a_path_added_twice_is_one_file_whichever_end_the_duplicate_is_at` (vlog_semantic) | `index_order`'s dedup rule surviving the move into `finish`, non-adjacent duplicate included |
|
||
| `the_index_scope_is_the_open_folder_until_a_client_asks_for_the_workspace` (settings) | the default, both words, six junk values → the narrow default |
|
||
| `the_scope_depth_is_zero_until_a_client_raises_it` (settings) | the default, no upper bound, six wrong types |
|
||
| `the_index_settings_come_through_the_pull_door_too` (settings) | both new keys through `from_section` as well |
|
||
| `the_default_scope_is_the_open_files_own_folder_and_everything_under_it` (state) | the headline: own folder and subtree, no sibling folder, nothing before a buffer opens |
|
||
| `a_scope_depth_of_one_reaches_the_folder_beside_it` (state) | the `rtl/` + `../include` layout the setting exists for |
|
||
| `the_climb_stops_at_the_workspace_root` (state) | the clamp at depth 99, and the deepest of two nested roots winning |
|
||
| `a_rootless_climb_stops_at_the_filesystem_root` (state) | termination at `/` with no root — on the directories, never walking one |
|
||
| `a_rootless_session_that_raises_the_depth_walks_instead_of_reading_one_level` (state) | the one exception, from the other side |
|
||
| `the_workspace_scope_setting_restores_the_walk_of_every_root` (state) | the migration line, and that the depth is ignored on that rung |
|
||
| `a_filelist_still_defines_the_scope_exactly_whatever_the_folder_rung_would_say` (state) | rung 1 over rung 3, and that no `didOpen` can widen a filelist |
|
||
| `closing_a_file_never_narrows_the_scope` (state) | the close decision |
|
||
| `the_folder_scope_honours_every_exclude_and_the_gitignores_below_it` (state) | both excludes, the in-scope `.gitignore`, **and** the root-`.gitignore` gap, both scopes |
|
||
| `a_folder_added_mid_session_widens_nothing_until_a_file_in_it_is_opened` (state) | folder events × the folder rung |
|
||
| `a_scope_or_a_depth_change_asks_for_a_rescan` (state) | both directions, both settings |
|
||
| `the_open_files_are_indexed_first_and_the_index_cannot_tell` (state) | the event order **and** that the index equals the plain-order one |
|
||
| `a_didopen_rebuilds_exactly_when_it_widens_the_scope` (server) | the unified rule: widens → rebuild, covered → publish only, rootless and rooted |
|
||
| `a_new_index_scope_or_depth_rescans_through_the_real_dispatch` (server) | parser + change test + rescan, end to end through `didChangeConfiguration` |
|
||
| `the_bar_names_the_open_file_before_the_rest_of_the_scope` (server) | `1/3 m_open.sv` first on the wire |
|
||
| `the_folder_scope_widens_when_a_file_in_another_folder_is_opened` (e2e) | the real binary: definition into a sibling folder empty, opening it resolves, and a `"workspace"` client resolves immediately |
|
||
| `indexing_reports_its_progress_over_the_wire` (e2e, updated) | the model on the wire: three bars, `0 files indexed` then `1 file indexed` twice |
|
||
|
||
## QA log
|
||
|
||
### 2026-08-27 — QA agent (gates, attack surfaces, mechanical-sweep audit)
|
||
|
||
**Gates, re-run clean on the untouched working tree.** `cargo fmt --all --
|
||
--check`: clean. `cargo clippy --all-targets --workspace`: zero warnings.
|
||
`cargo test --workspace`: **2217 passed, 0 failed, 5 ignored** (matches the
|
||
dev's count exactly). `cargo test -p vlog_formatter`: 114 passed, untouched.
|
||
`cargo build && node editors/vscode/smoke.js target/debug/lucisv-server`:
|
||
`smoke: OK`. Every temporary probe test below was inserted, run alone, and
|
||
reverted before the final re-run; the final `git diff` of `state.rs`/`server.rs`
|
||
hashes identically to the pre-QA diff, confirming no probe was left behind.
|
||
|
||
**The 151-test mechanical sweep.** Sampled all 14 non-scope test modules
|
||
(`completion`, `file_ops`, `hierarchy`, `hover`, `includes`, `inlay`, `lens`,
|
||
`nav`, `ports`, `rename`, `signature`, `symbols`, `type_def`,
|
||
`type_hierarchy` — every `.open_roots(` call in them, ~40 sites) plus the
|
||
`server.rs`/`state.rs` `Session::wide`/`Workspace::open_whole_workspace`
|
||
call sites: **every one is a pure constructor swap** (`open_roots` →
|
||
`open_whole_workspace`, or `Session::with`/`Session::new` →
|
||
`Session::wide`/`Session::wide_with`, or a `"scope": "workspace"` key added
|
||
to a settings push). No sampled assertion changed beyond that. Verdict:
|
||
**mechanical sweep is genuinely mechanical**, as claimed.
|
||
|
||
**The inverse hunt (tests that should have been swapped but weren't) found
|
||
one real bug and two weakened premises**, all in `state.rs`'s own test
|
||
module, which is the one file that still has bare `.open_roots(` calls
|
||
mixed in with the new scope tests:
|
||
|
||
- **MEDIUM — `a_folder_added_twice_across_two_events_is_absent_after_one_removal`
|
||
(`crates/lucisv_server/src/state.rs:851-876`) no longer tests what it
|
||
says it does.** It calls `ws.open_roots(...)` but never opens any buffer,
|
||
so under the new default (folder scope) `scope_dirs()` is empty for the
|
||
entire test and `"x"` is never indexed — not because of the root
|
||
add/remove/dedup logic under test, but because nothing is ever in scope.
|
||
The final `assert_eq!(indexed(&ws, &["x"]), [])` passes vacuously.
|
||
Confirmed by temporarily inserting a premise check
|
||
(`assert_eq!(indexed(&ws, &["x"]), ["x"])`) right after the first
|
||
`change_roots` add and running the test alone: **it failed**
|
||
(`left: [] right: ["x"]`), proving the premise never held. The
|
||
`change_roots` return-value assertions (`true`/`false`/`true`) are
|
||
unaffected and still test the set-not-multiset behavior correctly — only
|
||
the closing `rebuild_index`/`indexed` pair is vacuous. Fix: either open a
|
||
buffer in `extra`'s directory before checking, or switch to
|
||
`open_whole_workspace` and keep the indexed-content assertion meaningful.
|
||
Not fixed directly — it is a one-line-comment-vs-actual-behavior mismatch
|
||
that the dev should decide the intended fix for (open a buffer, since the
|
||
test's own comment is about indexing, not about scope).
|
||
- **LOW — `an_open_buffer_is_indexed_however_big_the_file_is`
|
||
(`state.rs:1151-1168`)'s "premise: capped on disk" assertion is now true
|
||
regardless of the cap**, because no buffer is open at that point either,
|
||
so folder scope is empty and nothing is indexed for that reason first.
|
||
The test's actual point (the open buffer overrides the cap after
|
||
`set_document`) still holds and is still meaningfully exercised, since
|
||
`set_document` adds the directory to scope before the second
|
||
`rebuild_index`. Not a false pass on the assertion that matters, but the
|
||
premise no longer demonstrates what its comment claims.
|
||
- **LOW — stale rung numbers in comments**, not behavior:
|
||
`without_a_filelist_there_are_no_incdirs_at_all` (`state.rs:1454-1462`)
|
||
says "Rung 2 of the ladder names no include path," and
|
||
`a_broken_filelist_leaves_the_include_graph_without_incdirs`
|
||
(`state.rs:1464-1475`) implies the same fallback. Both are now rung 3
|
||
(folder scope) by default, not rung 2 — the assertions (`None` either way,
|
||
since no filelist means no incdirs regardless of which walk rung ran) are
|
||
unaffected, but the comments should say "rung 2 or 3" or just "the
|
||
fallback."
|
||
|
||
All other `.open_roots(` calls left bare in `state.rs` were individually
|
||
checked and are correct as left: the filelist tests (rung 1 always wins,
|
||
scope-independent), the rootless tests (rung 3 is the only rung with no
|
||
root, unaffected), and `a_folder_change_that_changes_nothing_asks_for_no_rescan`
|
||
/ `a_trailing_slash_in_the_removed_folder_still_matches_the_held_root` (test
|
||
`change_roots`'s bookkeeping only, no indexed-content assertion to weaken).
|
||
|
||
**Scope correctness at the boundaries — all traced and probed, all correct,
|
||
none pinned by a permanent test beyond what's listed below:**
|
||
|
||
- Depth clamping when the open file *is* at the root: `raised()`'s first
|
||
loop iteration compares `out == floor` before descending, so a root-level
|
||
buffer returns immediately at any depth. Covered by
|
||
`the_climb_stops_at_the_workspace_root`.
|
||
- Nested roots, deeper clamps tighter: `max_by_key(|root|
|
||
root.components().count())` — confirmed by the same test's second half.
|
||
- `scopeDepth` past the path depth: terminates at `/` (rootless) or the
|
||
containing root (rooted), confirmed by
|
||
`a_rootless_climb_stops_at_the_filesystem_root` and the depth-99 case in
|
||
`the_climb_stops_at_the_workspace_root`.
|
||
- **A file opened from outside every workspace root, with roots present
|
||
(folder scope still the active rung): no permanent test covers this.**
|
||
Probed with a temporary test (root A open, a buffer opened from an
|
||
unrelated tree B): `scope_dirs()` at depth 0 is just B's own directory,
|
||
and raising `scopeDepth` to 99 climbs all the way to `/` — exactly the
|
||
rootless behavior, because `raised()`'s `floor` is `None` when no root
|
||
contains the directory. **Correct, but untested and not called out in the
|
||
README's Assumptions** as a distinct case from "rootless session."
|
||
Recommend a pinned test plus a sentence in the README.
|
||
- Symlinked folders / case differences on macOS: `opened_dirs` dedups by
|
||
literal `PathBuf` equality (`seen == dir`), not canonicalized — a symlink
|
||
and its target, or `/RTL` vs `/rtl`, are two separate scope directories
|
||
that both get walked. **Not a regression**: the pre-round `sibling_files`
|
||
deduped the same way. Informational only.
|
||
|
||
**The grows-only model's costs.** Opening three folders then closing all
|
||
three: union sticks, verified with a temporary test (three folders opened,
|
||
all three closed, `rebuild_index`, same five packages still indexed) — not
|
||
just the dev's one-of-two-closed case. The pathological end (opening files
|
||
across many folders converges the walk cost back toward the whole-workspace
|
||
walk this round exists to avoid) is **acknowledged only indirectly** — the
|
||
README's "Not done, deliberately" section says there's no shrink/LRU/TTL and
|
||
names "restart or set a filelist" as the escape hatch, but never states the
|
||
asymptotic point plainly. Recommend one sentence owning it, e.g. "a session
|
||
that has opened files in most of the project's folders pays close to the
|
||
whole-workspace walk on every rescan; that is the trade, not a bug."
|
||
|
||
**Builder hardening.** `no_insertion_order_can_change_what_the_builder_produces`
|
||
and `a_path_added_twice_is_one_file_whichever_end_the_duplicate_is_at` both
|
||
pass. Independently re-derived the "first wins" claim from first principles
|
||
rather than trusting the doc comment: wrote a 6-line scratch program
|
||
exercising `Vec::sort_by` + `Vec::dedup_by` with the exact closure shape used
|
||
in `finish` (`sort_by(|a,b| a.path.cmp(&b.path))` then
|
||
`dedup_by(|a,b| a.path == b.path)`) on `[("a",1),("a",2),("b",3)]`; it
|
||
produces `[("a",1),("b",3)]`, confirming `dedup_by` really does keep the
|
||
first of a run in this position (the docs' phrasing invites an off-by-one
|
||
misreading given the reversed-argument-order caveat). `add_file` after
|
||
`finish`: prevented at compile time — `finish(mut self)` consumes the
|
||
builder, so this is Rust's ownership system doing exactly what a type-state
|
||
`SortedFiles` wrapper would do, for free, matching the README's stated
|
||
rationale for not building one. Empty builder `finish()`: sorts/dedups an
|
||
empty `Vec`, loop body never runs, returns `WorkspaceIndex::default()` — no
|
||
panic, consistent with `an_empty_workspace_answers_nothing_and_panics_nowhere`
|
||
already covering `WorkspaceIndex::build([])` through the same path.
|
||
|
||
**Cross-feature interaction sweep — verified clean, and structurally so
|
||
rather than by accident.** `symbols.rs`, `lens.rs`, `type_hierarchy.rs` all
|
||
read from `ws.index()` directly; `rename.rs` reads from `ws.sources()`,
|
||
which is `collect_sources(...).texts`, the exact same `source_files()` ladder
|
||
`rebuild_index` uses. There is one scope-aware code path, not one per
|
||
feature, so "workspace/symbol, codeLens, typeHierarchy and rename all answer
|
||
in-scope only" is a structural fact, not a per-feature promise that could
|
||
drift. `workspace/diagnostic` (`server.rs:988` `workspace_report`) iterates
|
||
`self.workspace.open_uris()` only — confirmed independent of the index
|
||
scope entirely, exactly the "unaffected" claim. The cap composes with scope
|
||
by construction too: `collect_sources` applies `max_file_size` to
|
||
`scope.files`, which is already the scope-filtered list — no special-casing
|
||
needed, none found.
|
||
|
||
**Migration path.** Rather than diff against a `git stash` baseline binary,
|
||
verified the stronger claim algebraically: `default_files()`'s
|
||
`walks_the_workspace()` branch calls `self.walked_files(&self.roots)`, and
|
||
`walked_files(dirs: &[PathBuf])`'s body is byte-identical to the pre-round
|
||
`walked_files(&self)`'s body with `&self.roots` substituted for `dirs` at
|
||
every use — confirmed by re-reading the diff hunk line by line. So
|
||
`scope: "workspace"` is not merely equal in practice to the pre-round
|
||
default, it is the same function called with the same argument, which is a
|
||
stronger guarantee than a fixture comparison could give. `from_section`
|
||
delegates to `from_payload` with zero new code (`settings.rs:208-210`), so
|
||
both settings doors carrying the two new keys is confirmed structurally.
|
||
|
||
**Own-shapes probes (C), all via temporary tests, all reverted:**
|
||
|
||
- Rapid `didOpen` across 10 distinct folders: generation increases by
|
||
exactly 20 (2 per widening open), completes in ~0.02s — no quadratic
|
||
blowup at this scale. `opened_dirs.sort()` runs on every `set_document`
|
||
and `scope_dirs()` sorts+dedups again on every call (twice per `didOpen`),
|
||
which is O(n log n) per open and O(n² log n) over a session — fine at
|
||
realistic folder counts, worth knowing if a future report cites hundreds
|
||
of folders in one session.
|
||
- Lowering `scopeDepth` mid-session (1 → 0) via `set_client_settings`:
|
||
**does narrow the index on the next rebuild**, unlike closing a buffer.
|
||
This is correct and is the right answer (a settings change is a
|
||
deliberate user action, not the same "never take away an answer" case
|
||
`didClose` is), but **no permanent test pins it** and the README's
|
||
Assumptions section states "the scope only ever grows" without
|
||
distinguishing the open/close axis (grows-only) from the settings axis
|
||
(moves either way). Recommend a test plus a clarifying sentence.
|
||
- A filelist appearing mid-session (settings push) while folder scope was
|
||
active: flips the ladder to rung 1 immediately on the next rebuild
|
||
(`folder_scoped()` re-checks `filelist_path()` fresh every call, and
|
||
`set_client_settings`'s rescan condition already includes `filelist`
|
||
changes). Correct, and covered indirectly by the existing rescan test,
|
||
but there is no test that also checks the *index content* actually
|
||
changes to the filelist's files rather than just triggering a rescan —
|
||
probed with a temporary test, passed.
|
||
|
||
**CLAUDE.md compliance.** `verify.rs` untouched (no diff, confirmed by
|
||
`git diff --name-only`). No new `unwrap()`/`expect()`/`panic!` outside
|
||
`#[cfg(test)]` modules in the round's diff (grepped the four core files'
|
||
diffs for all three patterns; every hit is inside `mod tests`). Doc comments
|
||
present on every new public item (`IndexScope`, `ClientSettings::index_scope`
|
||
/`index_scope_depth`, `Workspace::scope_dirs`). `has_roots()` confirmed
|
||
genuinely `#[cfg(test)]`-only — grepped every call site in the crate, all
|
||
seven are inside `#[test]` functions. README sections present exactly once.
|
||
`TODO.md`'s M1 annotation accurately describes the new default and points at
|
||
this feature's README. Corpus tests still skip-guarded (`if !corpus.exists()
|
||
{ return; }` pattern unchanged, only their `open_roots` calls swapped).
|
||
|
||
**One item beyond the brief, informational only:** `editors/vscode/package.json`'s
|
||
`lucisv.index.scope` description says the pre-round behavior is "as lucisv
|
||
did before 0.11" — a forward guess at the next release number. This round
|
||
makes no version bump (confirmed: `Cargo.toml` and `package.json` both still
|
||
say `0.10.2`). Not wrong today, but it is a claim about a future version
|
||
number sitting in a shipped-looking description; worth a quick check by
|
||
whoever cuts the next release that it lands on 0.11 and not, say, 0.10.3 or
|
||
0.12.
|
||
|
||
**Not touched:** `docs/site/` (per instructions), no commit, no push
|
||
attempted (remote noted as flaky).
|
||
|
||
**Verdict: committable as-is**, modulo the dev's call on the one MEDIUM
|
||
finding (the vacuous `a_folder_added_twice_across_two_events_is_absent_after_one_removal`
|
||
assertion — a real but narrow test-coverage gap, not a product bug: nothing
|
||
about `change_roots`'s actual dedup/removal behavior is broken, only that
|
||
one test no longer demonstrates it). The two LOW-MEDIUM missing-permanent-test
|
||
items (out-of-root buffer under folder scope; depth-narrows-on-settings-change)
|
||
and the stale-comment LOW items are follow-up hygiene, not blockers — every
|
||
behavior they probe was independently verified correct by hand in this
|
||
session.
|
||
|
||
## Review
|
||
|
||
### 2026-08-27 — lead
|
||
|
||
Reviewed the diff, the work log and the QA log; re-ran all gates myself
|
||
(2217 workspace tests, 0 failed), clean. The round delivers the owner's
|
||
model exactly and the two structural decisions are right: scope grows
|
||
only along the open axis (recomputing from the open set would take
|
||
working answers away on unrelated saves), and the builder hardening
|
||
makes the open-files-first ordering provably a reporting nicety — QA
|
||
independently re-derived the dedup-keeps-first-copy claim and confirmed
|
||
misuse-after-finish is prevented by ownership, which is the cheapest
|
||
kind of enforcement there is. The migration path being the same
|
||
function rather than an equal-output one is the strongest form of the
|
||
"workspace restores today" promise.
|
||
|
||
Lead actions on QA's findings before commit: the vacuous
|
||
folder-add/remove test now runs whole-workspace scope with a
|
||
present-while-added assertion restored (the MEDIUM); the big-buffer
|
||
cap test's premise is the cap's doing again; the stale rung comments
|
||
and the forward-guessed version string in the setting description are
|
||
corrected. The behaviors QA verified by hand but left unpinned
|
||
(depth-narrowing on a settings change, a mid-session filelist flipping
|
||
the ladder, an outside-root buffer on the folder rung) are accepted on
|
||
that verification and assigned to round 19's brief as permanent-test
|
||
obligations — its dev works in these exact files next. The
|
||
gitignore-below-root delta stays filed against lucisv_core. Accepted
|
||
as shipped.
|