The three top findings of the LSP 3.18 audit (TODO.md §9), one round of dev (Opus) + QA (Sonnet) + lead review: - executeCommand now pushes its WorkspaceEdit as workspace/applyEdit and reads the client's verdict; the old return-the-edit behavior stays as the documented fallback for clients without the capability. This fixes the three port commands doing nothing in stock clients — the returned edit was dropped by vscode-languageclient and Neovim alike. docs/features/apply-edit/README.md - textDocument/diagnostic + workspace/diagnostic (LSP 3.17), served from the same parse+lint pass the push model publishes, with resultId / unchanged caching on one generation counter; a pulling client is pushed nothing, a pushing client is unchanged. QA's exhaustive input trace found no stale-unchanged path. docs/features/pull-diagnostics/README.md - textDocument/selectionRange: chains from token spans, the tolerant parse's item/statement spans and the scope-pair matcher, filtered to strict nesting; the invariant swept over all 860 corpus files (6,880 positions, held everywhere). docs/features/selection-range/README.md 43 tests added across unit/e2e (server 557 -> 594+ unit, 29 -> 32 e2e); fmt/clippy/test/smoke all clean, re-verified independently by QA and by the lead. Co-Authored-By: Claude Fable 5 <[email protected]>
apply-edit
Goal
Make the three port commands actually edit something in a stock editor.
workspace/executeCommand used to answer with the WorkspaceEdit that
ports::execute computed, as the request's result. The protocol defines no
such thing: an executeCommand result is any | null, and a client applies
what a server pushes at it with workspace/applyEdit.
vscode-languageclient (which editors/vscode/extension.js uses unmodified)
drops the result on the floor, and so does Neovim's built-in client — so
lucisv.addPort, lucisv.removePort and lucisv.propagatePorts invoked as
commands did nothing at all in every stock client. (The code-action path was
never affected: a code action carries its edit inline.) This round pushes the
edit, answers null, and reads the one client response the server can no
longer ignore.
Assumptions
workspace.applyEditis the gate. A client that advertised it gets the push and anullresult. A client that did not gets exactly the old behavior — the edit as the result — because for that one it is the only thing that could ever work, and a silent no-op is worse than a non-standard answer that some caller may yet read. Both VS Code and Neovim advertise it;editors/vscode/smoke.jssendscapabilities: {}and so takes the fallback, which is why it still passes untouched.- The push goes out before the command's own response. The loop sends a
request's response when the handler returns, and the handler sends the
applyEditrequest during it. The protocol allows a server to make a request at any time, and a client that waited for the command result before applying the edit would deadlock against any server that does this — VS Code and Neovim both apply immediately. Stated here because it is the ordering a reader would otherwise wonder about. - A refusal is worth a popup.
ApplyWorkspaceEditResponse.applied: falsemeans the user ran a command, watched nothing happen, and has no other way to find out why. It is shown as an ERROR naming the command, plus the client's ownfailureReasonwhen it sent one. Success says nothing. - A response that does not parse is a refusal. Nothing was seen to be applied, so the honest thing is to say so rather than assume the best.
- Watcher (un)registration answers stay ignored. Their ids are never in
the pending map, so they fall straight through the new handler — including
an error response, which is what a client that refuses to watch sends. The
behavior
docs/features/file-watching/README.mddocuments is unchanged. - No retry, no timeout. A client that never answers leaves one entry in the pending map for the life of the session; three port commands per session is not a leak worth a timer, and the server has no timers by design.
- The
report_scope(warnings)behavior is unchanged — the engine's warnings are still surfaced exactly as before, whichever delivery path the edit takes.
Handshakes
lucisv_server::server
ClientAbilitiesgainsapply_edit: booland derivesDefault, so a test can name only the ability it cares about.main.rsfills it fromInitializeParams.capabilities.workspace.apply_edit.Servergainsapplying: HashMap<RequestId, String>— the outstandingworkspace/applyEditrequests, each remembering the command that asked.Server::send_requestnow returns theRequestIdit sent on. The watcher registration ignores it, exactly as it ignores the answer.run'sMessage::Response(_) => {}becomesself.response(response).ExecuteCommandgoes through the newServer::deliver.
ports
ports::execute's signature is unchanged; only the doc comment's claim that
"the server does not push workspace/applyEdit" is now false, and is
rewritten. No engine behavior changed.
editors/vscode
No extension change. vscode-languageclient applies workspace/applyEdit
requests itself; extension.js has no custom executeCommand handling and
needs none. Verified by reading, not assumed.
Status / TODO
workspace.applyEditread intoClientAbilitiesat initializeServer::deliver: push the edit with alabel, answernullServer::response: match answers to outstanding requests, report a refusal as an ERROR naming the command- Return-the-edit fallback kept for a client that cannot apply
- Tests: pushed-and-null, fallback-returns-the-edit, refusal reported, success silent, duplicate/unknown answer ignored, watcher answer still ignored
- Not done, deliberately: no
$/progressor timeout on an unansweredapplyEdit— see Assumptions. - Not done, deliberately:
WorkspaceEditstill carries plainchanges(nodocumentChanges, no snippet edits). That is TODO §9c's item, and it would improveaddPortcursor placement.
Work log
2026-08-26 — dev agent, §9a
deliveris a method onServer, not a free function, because it has to both send a request and remember its id; splitting it would have meant returning a request for the caller to send, which is a shape with one user.send_requestreturning the id was the smallest change that let the applyEdit path record it. The two watcher call sites ignore the value; aRequestIdis not#[must_use], so this stays silent.- The pending map is keyed by
RequestId, not by command, so two commands in flight cannot be confused and a duplicate answer to a spent id does nothing. Pinned byan_edit_the_editor_applied_is_said_nothing_about's second half. - The
labelislucisv: <command>— it is what an editor shows on its undo stack, so it names the thing the user would want to undo. - Files touched:
crates/lucisv_server/src/server.rs,crates/lucisv_server/src/main.rs,crates/lucisv_server/tests/e2e.rs, andports.rs's stale doc comment (it claimed the server does not pushworkspace/applyEdit).editors/vscode/extension.jswas read and deliberately left alone.
Verification. cargo fmt, cargo clippy --all-targets (zero warnings),
cargo test --workspace, node editors/vscode/smoke.js — all clean. 5 new
unit tests in server.rs (plus the watcher-answer guard), 1 in main.rs, and
one e2e session (a_command_pushes_its_edit_to_a_client_that_can_apply_one)
that pushes the edit at a real binary and answers it as an editor would.
QA log
2026-08-26 — QA agent, §9a
Re-ran the dev's verification, clean. cargo fmt --all -- --check,
cargo clippy --all-targets --workspace (zero warnings, forced a rebuild by
touching the changed files first so the check was not answered from a stale
cache), cargo test --workspace (3 full runs, no failures), node editors/vscode/smoke.js target/debug/lucisv-server (exit 0) — all reproduced
independently.
Read the diff against the README's claims, file:line references against the working tree as it stood before this QA pass:
server.rs'sExecuteCommandhandler (around what is now line 304) callsself.report_scope(warnings)unconditionally in theOkarm, beforeself.deliver(...)branches on the ability — confirmed both the push and the fallback path surface engine warnings identically.- RequestId collision, checked and ruled out.
applyingand the watcher (un)registration ids are both minted by the samesend_request, whose counter (self.request_ids) is a single monotonically increasingu32shared across every call site — two ids can never collide, so a watcher answer can never land inapplyingand vice versa. This is structural, not incidental: there is exactly one counter to break for a collision to become possible. ports.rs's doc comment rewrite matches the new behavior; no engine behavior changed there, confirmed by readingexecute's body (untouched except the comment).
Attacked the response-routing path (server.rs::response, the
ApplyWorkspaceEditResponse deserialization). The existing tests covered
Ok(applied: true), Ok(applied: false, failureReason), a duplicate answer,
and a watcher answer — but not the two cases the doc comment explicitly
claims to handle: a response payload that is Ok JSON but does not
deserialize as ApplyWorkspaceEditResponse at all, and a JSON-RPC-level
Err response (a client that rejects the request outright rather than
answering it). Added both as tests in server.rs:
a_malformed_apply_edit_answer_is_reported_as_a_refusal— answers with{"notApplied": "whatever"}(noappliedfield, which is required with no default inlsp_types::ApplyWorkspaceEditResponse); asserts one ERROR naming the command, not a panic and not silence.a_response_with_a_jsonrpc_error_is_reported_too— usesResponse::new_errdirectly; asserts theerror.messagereaches the shown text.
Both pass. Confirms the "a response that does not parse is a refusal" assumption is real code, not just a comment.
Found and fixed one self-inflicted test bug while adding the above: the
first draft of a_malformed_apply_edit_answer_is_reported_as_a_refusal named
its tree propagating("malformed", ...), which collides with the existing
Tree::new("malformed") in
a_malformed_watched_files_notification_is_dropped — both resolve to the
same std::env::temp_dir() path (keyed only by pid + name), so running the
suite in parallel raced the two tests' filesystem setup and made
ports::execute fail to find sub.sv (server.rs, originally around line
1417 in this session's numbering). Not a server bug — a QA-test-authoring
bug. Renamed to "malformedapplyedit"; reran the full lucisv_server suite
three times back to back with no failures. Worth a general note for future
dev/QA agents: Tree::new's temp path is name-keyed, not test-keyed, so a
tree name must be checked for uniqueness across the whole crate, not just
the tests being added.
Capability reading: apply_edit_support reads
params.capabilities.workspace.as_ref().and_then(|w| w.apply_edit) —
verified this cannot panic on InitializeParams::default() or any partial
capability object; already covered by
apply_edit_support_is_read_from_the_clients_own_capabilities, re-ran it
directly.
CLAUDE.md compliance: grepped the new/changed lines in server.rs,
main.rs, ports.rs for .unwrap(), .expect(), panic! outside
#[cfg(test)] — none found. Public items added (ClientAbilities::apply_edit)
carry doc comments. README has all seven required sections; TODO.md's
checkbox is checked with the item text unchanged and a → pointer added.
Verdict: no blocking findings. The two new attack tests and the tree-name-collision fix are the only changes made to this feature's code.
Review
2026-08-26 — lead
Reviewed the diff, the work log and the QA log; re-ran fmt/clippy/the full
workspace suite/smoke.js myself, all clean. The design is right: the gate is
the client's own workspace.apply_edit capability, the fallback is exactly
the old behavior for exactly the clients the old behavior could serve, and
the pending-map keyed by the one shared id counter makes response routing
collision-free by construction (QA verified the same). The deliver
doc comment's deadlock note is a good catch worth keeping. The no-timeout
decision is accepted: three commands per session cannot leak meaningfully,
and the server has no timers by design. ports.rs's previously-false doc
comment is now true. Accepted as shipped.