run() now reads in bursts: one blocking receive plus everything already
queued behind it, processed strictly in arrival order. A request whose
$/cancelRequest sits in the same burst is answered RequestCancelled
(-32800) without being dispatched; cancels naming anything else — an
already-answered request, one never received, a server-initiated id —
are dropped on the spot, so cancellation holds no state that can leak
or misfire. shutdown is honoured before the cancel set is consulted,
and a didChange queued ahead of a request is still applied first.
The enabling change: lsp-server 0.10's stdio transport uses rendezvous
channels, so a client's backlog never queues on connection.receiver —
it sits invisible in the OS pipe (dev measured 0/5 cancels honoured
under the original drain design). A single forwarder thread moves
messages onto an unbounded queue, stopping at shutdown because
handle_shutdown reads the following exit off the connection itself.
First thread in this server; QA re-derived the hand-off from the
vendored lsp-server source and found no steal or deadlock window.
15 tests added (dev 11 + QA 4), covering the full cancel matrix (both
id types, double cancel, orphan drop with id-reuse proof, malformed
params), the forwarder against a real Connection, and an e2e flood of
20 requests with cancels asserting schedule-independent properties —
green across twelve consecutive runs. Completes TODO.md §9b.
docs/features/cancel-request/README.md
Co-Authored-By: Claude Fable 5 <[email protected]>