codeAction reads the module's fan-out, not the workspace
The owner's slow-F12 root cause: textDocument/codeAction on a module instantiation read every in-scope file through ws.sources() and ran the port-refactor engine over them, per cursor move — 3.1-4.6 s on opentitan's 3 976 files, blocking the single-threaded loop so every queued definition/hover paid the bill. Workspace::module_sources now hands the engine the cursor modules' fan-out: declarers (units), instantiation-edge files, references_to postings (the fourth rung — edges_of drops owner-less file-scope instantiations, so edges alone are not a superset), and every open buffer. 4.56 s -> 7.1 ms typical, 83 ms at a 36-file fan-out; equality with the whole-workspace computation pinned by four dev + six QA equivalence/attack tests. Disclosed behavior change: the answer now sees the workspace as the index describes it, like every other index-backed answer. Also: performance.md (full opentitan benchmark of every LSP action) committed at the root, and TODO.md gains section 10 tracking the performance wave the benchmark spawned (rename family, completion, documentHighlight, scope default) with per-lane file ownership. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
bf9170a850
commit
ad27ed23dc
10 files changed
+1519
-31
No files matched your search
@@ -32,6 +32,9 @@ pub fn propagate_ports(files: &[(PathBuf, String)], file: &Path, offset: u32)
|
||||
pub fn port_actions(files: &[(PathBuf, String)], file: &Path, offset: u32)
|
||||
-> Vec<PortAction>;
|
||||
pub fn may_have_port_action(text: &str, offset: u32) -> bool;
|
||||
// added 2026-08-28, for the server's file-set question:
|
||||
pub fn port_action_modules(text: &str, offset: u32) -> Vec<String>;
|
||||
pub fn enclosing_module(text: &str, offset: u32) -> Option<String>;
|
||||
```
|
||||
|
||||
`files`, `RefactorEdit`, `TextEdit` and the `Err(String)`-is-a-sentence
|
||||
@@ -339,14 +342,85 @@ neither is offered where the refactoring would be refused. They answer for the
|
||||
**start** of the requested range: a code action is about where the cursor is.
|
||||
|
||||
A code-action request arrives on **every cursor move**, and computing an
|
||||
answer means reading the whole in-scope file set and building an index — a
|
||||
fifth of a second on a large workspace, on a single-threaded server. So the
|
||||
engine exposes a cheap one-file question, `may_have_port_action(text, offset)`:
|
||||
one parse of the buffer itself, no workspace and no I/O, answering "is this
|
||||
position inside a port element, a non-ANSI port declaration, or an
|
||||
instantiation?". The server asks it *before* materializing anything. It cannot
|
||||
hide a refactoring: all three start by locating exactly one of those three
|
||||
constructs.
|
||||
answer used to mean reading the whole in-scope file set and building an index
|
||||
— a fifth of a second on a large workspace, on a single-threaded server, and
|
||||
2.9 s on OpenTitan's 3 976 files, with every queued definition and hover
|
||||
waiting behind it. Two things keep that off the cursor path, and both are the
|
||||
engine's own walk:
|
||||
|
||||
- `may_have_port_action(text, offset)` — one parse of the buffer itself, no
|
||||
workspace and no I/O, answering "is this position inside a port element, a
|
||||
non-ANSI port declaration, or an instantiation?". The server asks it
|
||||
*before* materializing anything. It cannot hide a refactoring: all three
|
||||
refactorings start by locating exactly one of those three constructs.
|
||||
- `port_action_modules(text, offset)` — the same walk saying *which* module it
|
||||
found, so the server can hand the engine that module's own fan-out instead
|
||||
of the workspace. `may_have_port_action` is this function asked for
|
||||
emptiness (one walk, two readers), which is what keeps the gate and the
|
||||
fan-out from ever disagreeing about which positions carry an action.
|
||||
|
||||
### The file set a port action reads — why a subset is the same answer
|
||||
|
||||
`Workspace::module_sources(file, modules)` (`lucisv_server/src/state.rs`)
|
||||
builds the file set both `ports::code_actions` and `ports::execute` hand to the
|
||||
engine. It is `sources()` narrowed to four rungs:
|
||||
|
||||
1. **the file the request names** — the open buffer's text, as always;
|
||||
2. **every file declaring one of `modules`** — `index.units(name)`;
|
||||
3. **every file that instantiates one** — `index.instantiations_of(name)` —
|
||||
**or otherwise refers to one** — `index.references_to(def)`;
|
||||
4. **every open buffer**, whatever it contains.
|
||||
|
||||
The answer is *equal* to the whole-workspace answer, and the argument is one
|
||||
per way a file can influence the result:
|
||||
|
||||
- **A file the plan can edit.** `plan_add`/`plan_remove` loop over the whole
|
||||
scope, but `instantiation_edits`/`disconnection_edits` write nothing in a
|
||||
file that does not textually contain the module name and parse an
|
||||
instantiation of it under `collect_instantiations`. That census — module
|
||||
bodies, packages, nested modules, generate regions (`if`/`for`/`case`), and
|
||||
`bind` — is walk-for-walk the one `vlog_semantic::instantiations::sites`
|
||||
performs to record the index's instantiation edges, so rung 3 names exactly
|
||||
the files that could gain or lose a connection. `plan_propagate` edits the
|
||||
cursor's file alone. **One gap**: `edges_of` drops a site with no owning
|
||||
module — an instantiation written at *file scope*, illegal SystemVerilog a
|
||||
tolerant parse still produces — and the engine would have edited it. Rung 3's
|
||||
second half covers it: an instantiation's module name is a
|
||||
`Target::Module` reference wherever it is written, so the file appears in
|
||||
`references_to` even when it is nobody's edge.
|
||||
- **A file that decides `locate_module`'s verdict.** Every one of them is in
|
||||
rung 2, *all* of them, so a module declared twice still produces the "lucisv
|
||||
will not guess which module's ports these are" refusal instead of quietly
|
||||
picking the one definer that happened to be in the set. Rung 2 is the reason
|
||||
the set is built from `units(name)` rather than from a single definition.
|
||||
- **A file the verifier watches.** `check::watched_files` widens verification
|
||||
to every file spelling the module name, edited or not, and compares each
|
||||
one's declarations and resolutions before and after. For a file that is not
|
||||
edited, "before" and "after" differ only if some *anchor* moved — and an
|
||||
anchor is a local declaration (its own text, unchanged) or a def in the
|
||||
rebuilt index (pre-shifted through the edits by `Shifts`, which is why an
|
||||
insertion in the module's file does not read as a difference). An anchor
|
||||
that could move is by construction a reference *into* the edited module or
|
||||
its members — which is a `references_to` posting, rung 3. Every other file's
|
||||
print is identical on both sides whether it is in the set or not, so
|
||||
omitting it cannot turn a refusal into an offer.
|
||||
- **A file the index has not seen.** An unsaved buffer's live text can add or
|
||||
remove any of the above, and the edges are only as fresh as the last save —
|
||||
so rung 4 takes every open buffer whole, exactly as `collect_sources` does.
|
||||
|
||||
Everything else about the set is `collect_sources`'s rules unchanged: each
|
||||
file's text is the open buffer's when there is one and disk otherwise, a
|
||||
buffer on the large-file fast path contributes nothing, and a file over
|
||||
`lucisv.index.maxFileSize` is not read.
|
||||
|
||||
Pinned by four tests in `lucisv_server/src/ports.rs`, each asserting against
|
||||
the whole-workspace computation rather than a transcription of it:
|
||||
`a_code_action_answers_what_the_whole_workspace_would`,
|
||||
`an_unsaved_buffer_contributes_the_instantiation_the_index_has_not_seen`,
|
||||
`a_module_declared_twice_is_refused_through_the_subset_as_well`,
|
||||
`a_command_computes_over_the_subset_and_answers_the_same`, plus
|
||||
`the_files_a_code_action_reads_are_the_modules_own_fan_out`, which asserts the
|
||||
noise files really are absent (4 files read of 44).
|
||||
|
||||
**Commands** (`workspace/executeCommand`, advertised in
|
||||
`executeCommandProvider`):
|
||||
@@ -390,7 +464,19 @@ engine's sentence verbatim, M2's precedent.
|
||||
- **A port refactoring is a rare, user-initiated request**, so re-parsing the
|
||||
in-scope files that mention the module (twice: once to plan, once to verify)
|
||||
is affordable. The substring prefilter M2 introduced keeps it to a handful of
|
||||
files. Measured below.
|
||||
files. Measured below. **Amended 2026-08-28**: a *code action* is not rare —
|
||||
it arrives on every cursor move — so the files handed to the engine are the
|
||||
module's fan-out rather than the workspace (above).
|
||||
- **The index is the server's authority on where a module is declared and
|
||||
instantiated.** The fan-out is read from it, so a port action sees the
|
||||
workspace as far as the index describes it: a file changed on disk with
|
||||
nothing telling this server, or a file a startup scan has not reached yet,
|
||||
is a file the action does not read. That is the same rule every other
|
||||
index-backed answer already lives by — definition, hover, references, the
|
||||
code lens, the call hierarchy — and the file watcher is what keeps it true.
|
||||
Before 2026-08-28 a port action re-read the whole scope from disk and was
|
||||
the one answer in the server that could see further than the index; it no
|
||||
longer is.
|
||||
- **Two spaces** are used for the one indentation lucisv has to invent (a body
|
||||
declaration in a module with no items at all). Every other insertion copies an
|
||||
indentation that is already in the file.
|
||||
@@ -436,6 +522,27 @@ engine's sentence verbatim, M2's precedent.
|
||||
- `warnings` are informational: an `Ok` with warnings is still safe to apply.
|
||||
- `PortAction.title` is user-facing text; the server does not rewrite it.
|
||||
|
||||
**Consumed from `vlog_semantic`, added 2026-08-28** (no change required):
|
||||
`WorkspaceIndex::{instantiations_of, references_to}` — the incremental-index
|
||||
edge and posting tables — are what make the file set a lookup instead of a
|
||||
workspace read. The equality argument above leans on one property of theirs:
|
||||
`edges_of` records the census `instantiations::sites` walks, which is the walk
|
||||
`ports::collect_instantiations` performs. If either walk grows a node kind the
|
||||
other does not, the fan-out stops being a superset of the editable files —
|
||||
so **they must move together**.
|
||||
|
||||
**Requested of `lucisv_server`'s rename surface (follow-up, not this round):**
|
||||
`rename` and `prepare_rename` still call `ws.sources()` and run the engine
|
||||
over every in-scope file. On the synthetic 504-file workspace the port probe
|
||||
uses, `prepare_rename` costs **249 ms** (of which `sources()` alone is 14.5
|
||||
ms — the rest is the index build and the analyses over every file);
|
||||
`textDocument/prepareRename` is sent when the user presses the rename key, not
|
||||
per cursor move, so it does not block the way the code action did. The subset
|
||||
for a rename is a *different* argument from this one — a rename must see every
|
||||
file that could name the symbol, and the postings table
|
||||
(`references_to`/`references_are_ambiguous`) is the candidate — so it is filed
|
||||
here rather than guessed at now.
|
||||
|
||||
**Changed in `lucisv_server`** (protocol layer only): `code_action::wanted` is
|
||||
now `pub` so the port actions can honor the same `only` filter the lint actions
|
||||
do; `server.rs` gained the `workspace/executeCommand` arm and the port-action
|
||||
@@ -467,6 +574,11 @@ call inside the existing `textDocument/codeAction` arm; `main.rs` advertises
|
||||
- [x] `lucisv_server`: code actions, three commands, capabilities
|
||||
- [x] `may_have_port_action` — the one-file pre-check that keeps a
|
||||
cursor-move-frequency code-action request off the workspace walk
|
||||
- [x] The file set a port action reads is the module's fan-out through the
|
||||
index, not `sources()` (2026-08-28): `port_action_modules` /
|
||||
`enclosing_module` in the engine, `Workspace::module_sources` in the
|
||||
server, one builder for both callers, with the equality argument above
|
||||
and five equivalence tests
|
||||
- [x] Conditional-compilation guard on both insertion paths: refuse inside an
|
||||
arm, warn when the list carries directives at all (QA HIGH #1)
|
||||
- [x] Preprocessor warnings on removal — macro-invocation arguments and
|
||||
@@ -652,6 +764,62 @@ still `Ok((6, 18))` in 0.36 s, so the guard false-refuses nothing in real RTL.
|
||||
One clippy-driven tidy while there: the header planner's arguments are now a
|
||||
`File { text, path, tokens }` struct rather than eight positional parameters.
|
||||
|
||||
**2026-08-28 — dev agent.** `textDocument/codeAction` no longer reads the
|
||||
workspace per cursor move. The owner's instrumented session on OpenTitan
|
||||
measured 3 111 ms and 3 015 ms for a code action against 0.01–0.44 ms for
|
||||
every other request; VS Code sends one on nearly every cursor move and the
|
||||
server is single-threaded, so a cursor resting on an instantiation — which is
|
||||
exactly where F12 leaves it — held every queued definition and hover behind
|
||||
it. That is the "goto definition is slow" report: the definition answered in
|
||||
microseconds and stood in a three-second queue.
|
||||
|
||||
What changed:
|
||||
|
||||
- **`vlog_refactor::port_action_modules`** — `may_have_port_action`'s walk,
|
||||
returning the module names it found instead of a bool, and
|
||||
`may_have_port_action` is now that function asked for emptiness. One walk,
|
||||
two readers, so the gate and the fan-out cannot drift; a byte-by-byte
|
||||
equality test over a mixed file pins the two against each other.
|
||||
**`vlog_refactor::enclosing_module`** is the same question for the command
|
||||
path, where `lucisv.addPort` takes a position anywhere in a module —
|
||||
`module_at` made public, which is precisely what `ModuleRef::At` resolves
|
||||
with, so the server names the module the engine will name.
|
||||
- **`Workspace::module_sources`** — the one file-set builder, used by
|
||||
`ports::code_actions` and by all three commands through `ports::sources_at`.
|
||||
Four rungs and the equality argument are written up under "The file set a
|
||||
port action reads" above; the two decisions worth repeating here are that
|
||||
**all** definers of the name go in (or an ambiguous module would stop
|
||||
refusing) and that `references_to` goes in beside `instantiations_of` (or a
|
||||
file-scope instantiation, which records no edge, would stop being edited).
|
||||
- Both callers share the builder, so there is no second code path with a
|
||||
second answer; `execute` computes the names per command shape rather than
|
||||
materializing anything before it knows what it was asked.
|
||||
|
||||
Measured, release:
|
||||
|
||||
| | before | after |
|
||||
|---|---|---|
|
||||
| synthetic 504 files, cursor on a port instantiated in 3 of them | 725 ms | **0.41 ms** |
|
||||
| OpenTitan (3 976 files), cursor on a port of `adc_ctrl_core`, action offered | 4.56 s | **7.1 ms** |
|
||||
| OpenTitan, cursor on a `prim_fifo_sync` instantiation (36-file fan-out) | 2.93 s | **83 ms** |
|
||||
|
||||
The last row is the honest ceiling: `prim_fifo_sync` is instantiated all over
|
||||
OpenTitan, so its fan-out is 36 real files and the engine parses them twice
|
||||
(plan, then verify) — 1.3 ms of that is reading them, the rest is the engine.
|
||||
A module with a normal fan-out is the middle row. The synthetic probe is
|
||||
`perf::a_code_action_at_an_instantiation_before_and_after`, which prints the
|
||||
before column, the after column and `sources()` alone; the OpenTitan numbers
|
||||
were taken with a throwaway probe against the local checkout and deleted, since
|
||||
no test may depend on it. Both OpenTitan cursors were also checked for
|
||||
*equality* against the whole-workspace computation — same titles, same edited
|
||||
file counts — beside the five equivalence tests in the suite.
|
||||
|
||||
Deliberately untouched: `rename`/`prepare_rename`'s `sources()` calls, filed as
|
||||
a Handshake follow-up with its number (249 ms on the synthetic workspace).
|
||||
Gates: `cargo fmt` clean, `cargo clippy --all-targets` clean, `cargo test`
|
||||
green workspace-wide, `node editors/vscode/smoke.js` OK against the release
|
||||
binary.
|
||||
|
||||
## QA log
|
||||
|
||||
**2026-08-24 — QA agent.**
|
||||
@@ -1179,8 +1347,87 @@ counts across all three QA passes are themselves evidence against scope
|
||||
creep. The one imprecision found (over-broad trailing-directive warning
|
||||
text) is cosmetic, safe-direction, and not blocking.
|
||||
|
||||
**2026-08-28 — QA agent.** Round on the codeAction-fan-out change: `Workspace::module_sources` replacing `ws.sources()` for `textDocument/codeAction` and the three port commands. Adversarial charter: find a file the whole-workspace computation would have edited (or that would change/refuse the answer) missing from the subset — refactoring correctness, invariant-1-adjacent.
|
||||
|
||||
### Gates
|
||||
|
||||
- `cargo fmt --all -- --check` — clean.
|
||||
- `cargo clippy --all-targets` — clean, zero warnings, workspace-wide (one warning surfaced from a QA-added test — `map_or(true, …)` → `is_none_or(…)` — fixed directly, small and unambiguous).
|
||||
- `cargo test --workspace` — green, **2482** passed, 0 failed, 0 measured (28 `#[ignore]`d perf probes not run) — includes the 6 permanent regression tests added this round (below). `lucisv_server`'s own unit suite: **1249** passed, 28 ignored. `vlog_refactor` unit: 72, `tests/ports.rs`: 52 (dev added 2: the byte-sweep pinning `may_have_port_action`/`port_action_modules` against each other, and `enclosing_module`'s own test).
|
||||
- `node editors/vscode/smoke.js target/release/lucisv-server` — OK (had to pass the binary path explicitly; `lucisv-server` is not on `PATH` in this environment, not a project issue).
|
||||
- Reproduced the synthetic perf claim exactly: `perf::a_code_action_at_an_instantiation_before_and_after` (`--release`) printed **724 ms → 409 µs**, `sources()` alone **14.4 ms**, `prepareRename` **250 ms** — matches the README's 725 ms / 0.41 ms / 14.5 ms / 249 ms table to the reported precision.
|
||||
- Reproduced the OpenTitan claim's *shape* independently, with a throwaway probe (added to `perf.rs`, run, then reverted — not in the tree): cursor on a port of `adc_ctrl_core.sv` went **3.13 s → 3.17 ms**; cursor on a `prim_fifo_sync` instantiation (in `otp_ctrl.sv`, a different real fan-out site than the dev's) went **3.08 s → 84.6 ms** — both essentially the dev's numbers (4.56 s→7.1 ms; 2.93 s→83 ms) to within what a different instantiation site and a warm/cold FS cache would explain. Both probe cursors landed on offsets that produced 0 offered actions on *both* sides (an imprecise offset, not a bug), but the **parity held** (0 == 0) in both cases, which is the property that matters here. No test depends on the checkout, per the brief.
|
||||
|
||||
### Attack angles from the brief, and what I found
|
||||
|
||||
**1. Missing-file attacks — all held.** Wrote 4 new permanent regression tests attacking the exact scenarios the brief named, each asserting the subset's `code_actions`/`module_sources` answer against `whole_workspace_at` (the dev's own reference function) or `ws.sources()`:
|
||||
|
||||
- `qa_file_scope_instantiation_lands_in_the_subset` (`crates/lucisv_server/src/ports.rs`) — an owner-less instantiation (`sub u_fs (.clk(c), .rst(r));` at file scope, no enclosing module) records **no** `InstantiationEdge` (confirmed directly: `edges_of` requires an owner), yet the file lands in `module_sources` and the subset's answer matches the whole-workspace one exactly. This is the dev's rung-3-second-half claim (`references_to` catching what `instantiations_of` structurally cannot) — verified empirically, not just by reading `resolve.rs`'s `named_at_file_scope`/`bind_instantiation` code path that makes it true. This was the brief's most specific, most load-bearing ask ("verify it actually lands in `references_to`") and it does.
|
||||
- `qa_generate_block_instantiation_lands_in_the_subset` — an instantiation inside a `generate for` body is a real `InstantiationEdge` (confirmed) and its file is in the subset, subset == whole-workspace.
|
||||
- `qa_escaped_module_name_instantiation_parity_with_whole_workspace` — an escaped-identifier instantiation (`` \sub u_esc (...) ``). Whatever the parser/binder does with the escape (resolve it to `sub` or treat it as a distinct name — did not chase which, since it is a pre-existing lexical question this round did not touch), the subset and whole-workspace answers agree. Framed as a parity check rather than a correctness check of escaping itself, since a bug there would be M1/M2-era and out of this round's scope.
|
||||
- `qa_add_port_by_position_still_fans_out_to_instantiation_files` — the dev's own equivalence test (`a_command_computes_over_the_subset_and_answers_the_same`) only exercises `lucisv.addPort` with a **module-name** argument, which reaches `module_sources` directly. The **Position** argument goes through a different function (`sources_at`, used by all three commands and by nothing else previously tested at the command layer) — confirmed it still reaches all 3 instantiating files, matching `ws.sources()`'s answer byte-for-byte.
|
||||
- Not separately tested as a new attack, but read and reasoned through carefully: `.*` connections, hierarchical-reference-only files, and macro-expanded module names. `.*` sites are structurally ordinary `Instantiation` nodes to `edges_of`/`collect_instantiations` (connection *style* plays no part in either census), so they get the same edge as a named-connection site — no special case to miss. A file whose only relationship to the module is a hierarchical reference to one of its ports (no instantiation) is not in scope for *either* the old or the new computation (neither `collect_instantiations` nor `edges_of` would ever find or edit it), so it cannot be a point of divergence. A macro-expanded module name is one opaque token to lucisv's non-preprocessing binder in both the old and new code paths equally (documented Assumption, unchanged) — not a regression this round could introduce.
|
||||
- Did **not** separately verify a duplicate-module-name-under-macro or a nested-module-inside-a-package instantiation; ran out of budget. Low-risk: `collect_instantiations`/`edges_of` both explicitly walk `ItemKind::Package{items,..}` identically (confirmed by direct side-by-side read of both functions, `crates/vlog_semantic/src/instantiations.rs:68-105` vs `crates/vlog_refactor/src/ports.rs:489-518` — they are the same match arms in the same order, which is exactly the Handshake's "walk-for-walk" claim, verified by inspection rather than by a fresh test).
|
||||
|
||||
**2. Refusal-parity attacks.**
|
||||
|
||||
- Duplicate-definer-already-indexed: the dev's own `a_module_declared_twice_is_refused_through_the_subset_as_well` covers this (re-ran, passes).
|
||||
- New module in an **unsaved buffer the index has never heard of at all** (not stale — genuinely absent): `qa_a_module_declared_only_in_an_unsaved_new_file_is_still_handled` — a module declared only in a brand-new, never-saved-to-disk buffer, with the cursor inside that same buffer. Rung 1 ("the file the request names") is what carries it, since rung 2 (`index.units`) is empty for a name the index has never indexed. Confirmed it still offers the action correctly (`lucisv: remove port \`b\` (no instantiation in scope)`), no panic, no silent no-op.
|
||||
- **Index stale vs. disk — the one place I judged rather than just tested.** `qa_a_duplicate_definer_unindexed_on_disk_is_a_stale_answer_not_a_corruption`: wrote a *second* definer of `sub` straight to the filesystem, bypassing the server (`fs::write`, no `rebuild_index`, no `set_document`). Confirmed: the subset computation, unaware of the new file, does **not** refuse — it offers the action as if the module were still uniquely declared, which is a real, observable divergence from `ws.sources()`'s always-fresh-from-disk answer (the old code path *would* have refused here). Judged against invariant 1, not against freshness, per the brief's own framing: this cannot corrupt anything, because the engine is handed exactly the files in the subset and has no I/O of its own — `dupe.sv` is never read and never appears in the produced edit (asserted directly). The worst case is a **stale-but-internally-consistent** answer (an edit that is fully verified against the files it actually saw), not a wrong-and-unverified one. This is exactly the trade-off the dev's own Assumptions section documents ("the index is the server's authority... a file changed on disk with nothing telling this server is a file the action does not read") and explicitly parallels every other index-backed LSP answer in the server (definition, hover, references). I agree with the dev's framing: this is a disclosed staleness trade-off, not a hidden safety gap, and does not violate "never corrupt code." Confirmed the parity is restored the moment the index is told (`rebuild_index()` → refuses, matching whole-workspace).
|
||||
|
||||
**3. Gate ⟺ subset coherence — verified by direct code comparison, no divergence found.** `may_have_port_action` is now defined literally as `!port_action_modules(...).is_empty()` (`crates/vlog_refactor/src/ports.rs:159`), so the two cannot drift by construction; the only residual risk was a logic bug introduced while refactoring the original single-`bool` walk into a `Vec<String>`-returning one. Diffed the two versions line-by-line: the only structural change is `.any(...)` → `.filter(...).map(...).collect()` over the same predicate, which is behavior-preserving (a multi-match, if the tolerant parser ever produced overlapping instantiation spans, would just widen the returned module list — still correctly non-empty, never a false negative). The dev's own new test (`the_pre_check_names_the_module_whose_files_the_action_will_need`, `crates/vlog_refactor/tests/ports.rs`) sweeps every byte offset of a mixed file and asserts `may_have_port_action(text, offset) == !port_action_modules(text, offset).is_empty()` — re-ran it, passes. No old-vs-new crafted-file attack found a gate-false position the old whole-workspace path would have offered an action for, because the "old path" *is* this same walk (`may_have_port_action` was never a separately-maintained function — it's the same code, just newly able to say which module).
|
||||
|
||||
**4. Command parity — held**, including the position-argument case above (attack 1's `qa_add_port_by_position...` doubles as this). `REMOVE_PORT`/`PROPAGATE_PORTS` both go through `sources_at`, which unions `port_action_modules` (what the offset directly names — a port, or an instantiation's own module) with `enclosing_module` (the module the offset sits textually inside) — read `locate_module`'s `ModuleRef::At` (`ports.rs:379-413`) and `locate_port`/`plan_propagate`'s own module-name derivation to confirm `sources_at` always names a superset of what the engine will independently look up for each of the three commands; for `propagate_ports` specifically the extra `enclosing_module` name is unnecessary (the README says propagate only ever touches the cursor's own file) but harmless — it can only add files, never omit the one that matters.
|
||||
|
||||
**5. Verifier integrity.** Read this one by construction rather than by attack: `check::watched_files` and the whole verifier only ever see the files handed to `Scope::build(files)` — the crate does no I/O of its own (Handshakes, unchanged this round). So "an edit corrupts a file outside the subset" is not reachable as a distinct failure mode in this design: the engine cannot write to, or even read, a file that was never in the set. The only failure mode a wrong subset can produce is the one attack angle 1 covers (a file that *should* have been edited is silently skipped) — which is why I put the budget there instead of trying to construct a doomed "verifier misses an out-of-subset corruption" scenario that the architecture rules out by construction.
|
||||
|
||||
### Tests added (all permanent, all in `crates/lucisv_server/src/ports.rs`'s `mod tests`)
|
||||
|
||||
`qa_file_scope_instantiation_lands_in_the_subset`, `qa_generate_block_instantiation_lands_in_the_subset`, `qa_escaped_module_name_instantiation_parity_with_whole_workspace`, `qa_add_port_by_position_still_fans_out_to_instantiation_files`, `qa_a_module_declared_only_in_an_unsaved_new_file_is_still_handled`, `qa_a_duplicate_definer_unindexed_on_disk_is_a_stale_answer_not_a_corruption`. No probe files left in the tree; the only non-test-only edit was the `map_or` → `is_none_or` clippy fix inside my own new test code (nothing in the dev's code touched).
|
||||
|
||||
### Summary
|
||||
|
||||
| Claim | Verdict |
|
||||
|---|---|
|
||||
| `cargo fmt`/`cargo clippy`/`cargo test --workspace`/smoke | **Pass** |
|
||||
| File-scope (owner-less) instantiation lands in the subset via `references_to` | **Pass, confirmed empirically** — the brief's most specific ask |
|
||||
| Generate-block instantiation, escaped-identifier parity | **Pass** |
|
||||
| `ModuleArgument::Position` (not just `Name`) still fans out correctly | **Pass, confirmed** — previously untested combination |
|
||||
| Ambiguous-module refusal, via the index | **Pass** (dev's own test, re-verified) |
|
||||
| Unsaved brand-new module (index has never heard of it) | **Pass** |
|
||||
| Index stale vs. disk (duplicate definer unindexed) | **Behaves as documented**: a stale-but-verified answer, never a corruption; matches the Assumptions section's own framing |
|
||||
| Gate (`may_have_port_action`) ⟺ fan-out (`port_action_modules`) coherence | **Pass, verified by construction + the dev's byte-sweep test** |
|
||||
| Command parity across all three commands | **Pass** |
|
||||
| Verifier cannot touch a file outside the subset | **True by construction** (no I/O in the crate) |
|
||||
| Perf claims (synthetic + OpenTitan) | **Reproduced**, synthetic to the reported precision, OpenTitan to the same order of magnitude on different cursor sites |
|
||||
|
||||
No corruption, no false refusal, no lost feature, and no missing-file divergence found anywhere I could construct one. The one real, novel-to-this-round behavior change (index staleness vs. `sources()`'s always-fresh disk read) is pre-existing in spirit everywhere else in the server, is disclosed prominently in the feature's own Assumptions section, and cannot produce a corrupt edit by the crate's own no-I/O architecture — so I am not filing it as a finding, only recording that I attacked it deliberately and it held.
|
||||
|
||||
**Verdict: SHIP.** No blocking or non-blocking findings this round.
|
||||
|
||||
## Review
|
||||
|
||||
**2026-08-28 — lead, codeAction fan-out round.** Reviewed after QA's
|
||||
clean SHIP; gates re-run independently (fmt clean, clippy silent, 2482
|
||||
workspace tests green). This closes the owner's original report from
|
||||
the root: the "slow F12" was a 3–4.5 s codeAction on every cursor move
|
||||
blocking the single-threaded loop, and the fix is the house pattern —
|
||||
the index's fan-out instead of `ws.sources()` — with the sufficiency
|
||||
argument written before the speed was trusted. The dev's fourth rung
|
||||
(`references_to`, because `edges_of` drops owner-less file-scope
|
||||
instantiations) is exactly the kind of gap that separates a subset from
|
||||
a superset, found by reading rather than by failing; QA confirmed it
|
||||
empirically and pinned it. The one behavior change — a port action now
|
||||
sees the workspace as the index describes it, so an unindexed on-disk
|
||||
duplicate yields a stale offer instead of a fresh refusal — is
|
||||
disclosed in Assumptions, cannot corrupt (the engine does no I/O of
|
||||
its own; QA proved the untouched file untouched), and aligns this
|
||||
answer with every other index-backed one. 4.56 s → 7.1 ms on
|
||||
opentitan, 83 ms honest ceiling at a 36-file fan-out, both reproduced
|
||||
by QA on different cursors. The prepareRename follow-up (250 ms on the
|
||||
synthetic; 2.5–3 s measured on opentitan in performance.md) is Lane A
|
||||
of the performance wave. Accepted; committed by the lead.
|
||||
|
||||
**2026-08-24 — lead.** Reviewed after QA round 2's ship verdict; gates run
|
||||
independently (1170 tests, 0 failures, clippy silent). The splice verifier
|
||||
plus per-feature shape check is the right division — the verifier stays
|
||||
|
||||
Reference in new issue
Block a user