The hand-patched diagnostic build becomes a feature: --verbose gates the timing lines (request answered / notification handled / HELD behind a rescan / scan and widen lifecycle / flush / reindex_one, the exact wordings of the two diagnostic builds) as LOG messages into the client's output channel; without the flag not one line is sent and the cost is one branch, measured unmeasurable against HEAD. Unknown args exit 2 with usage before the transport opens. The extension gains lucisv.verbose (default off) and its first restart-on-settings machinery: restart.js, one serialized chain reconciling to the last toggle, no client transition outside it — activation and deactivate included — after QA twice caught the alternatives (a mid-start toggle silently rejoining the stale start; deactivate's out-of-chain stop orphaning a spawn). Headless node harness restart_test.js, 44 checks, five mutations caught. Spawn contract amended everywhere it is written: no args required, --verbose optional. Co-Authored-By: Claude Fable 5 <[email protected]>
verbose-timing
Goal
lucisv-server --verbose makes the server say how long every operation took,
as timing: lines in the client's own log channel. It is the diagnostic build
the lead produced twice by hand-patching, made permanent and opt-in: the same
lines, the same wording, now shipped behind one flag instead of a rebuild. The
question it answers is the one a user asks when the editor feels slow — was
that request slow, or was it never started? — and the two lines that answer it
are <method> answered in X ms and <method> HELD behind a rescan. Off is the
shipped state and costs one branch per timed site: no clock read, no
format!, no notification. VS Code turns it on with lucisv.verbose, which
restarts the server because the flag is a spawn argument.
What it prints
Every line is one window/logMessage at MessageType::LOG, prefixed
timing: — the same channel and the same message type the per-file index log
(lucisv.index.logFiles) already uses, so a client that shows one shows both
and grep timing: separates them. Durations are milliseconds to two decimals,
from one helper (ms), so a 60 µs hover reads as 0.06 ms rather than 0 ms.
| line | where | says |
|---|---|---|
timing: <method> answered in X ms |
Server::request |
One request, handler only — the flush it triggers, the analysis, the answer |
timing: <method> handled in X ms |
Server::notification |
One notification, including any rescan it caused |
timing: <method> HELD behind a rescan (answering=…, wanted=…, already held=N) |
Server::process_batch |
The request did not start: the order contract made it wait. The three fields are must_wait's three clauses, so the line names which one held it |
timing: scan started: N file(s)[, interleaved] |
Server::scan_once |
The work list's size, and whether the scan will answer messages between its files (total > INTERLEAVE_ABOVE) |
timing: scan finished: N file(s) (S skipped, C from cache) in X ms |
Server::scan_once |
The same counts the progress bar's closing message carries, with the time |
timing: widen started: N folder(s) added: <paths> |
Server::reindex_widened |
Which folders a didOpen added to the scope, by name |
timing: widen finished: N file(s) (S skipped, C from cache) in X ms |
Server::reindex_widened |
What that cost |
timing: flush of N dirty buffer(s) took X ms |
Server::flush_dirty |
The debounced reparse a typing burst was coalesced into |
timing: reindex_one(<path>) took X ms |
Server::reindex_one |
The one-file incremental index update a save takes |
Three absences are deliberate:
shutdownis never timed.Connection::handle_shutdownanswers it in the loop, ahead of the dispatch, so it never reaches the timed wrapper. Nothing measurable happens there and routing the handshake through the wrapper to get a line would be worse than not having one.- A scan a
shutdowninterrupted prints nofinishedline, and areindex_onethat declined (the file was not in the index) prints nothing either: the first must not speak to a client that has gone, and the second did no work — its caller is about to rebuild the whole index, and that times itself. - A cancelled request prints no
answered inline.process_batchresolves$/cancelRequestbeforeServer::request(the timing wrapper) is ever called — a cancelled id is answered from the cancelled set directly — so the handler never ran and there is nothing to have timed. Pinned bya_flood_of_requests_and_cancels_under_verbose_times_only_what_ran_and_corrupts_nothingintests/e2e.rs(QA, 2026-08-29).
Ordering: the line comes before the response
A request's timing line is sent before the response it describes. The dispatch
is Server::request, and the response is sent by its caller
(process_batch), so a wrapper around the dispatch can only speak first. That
was chosen over threading the start time out to the caller because it keeps the
measurement to exactly the handler, with none of the transport in it, and it
keeps the shape the two diagnostic builds already had.
Nothing keys off the order. A window/logMessage carries no id; a client pairs
a response with its request by id, whatever arrived in between. The one real
consequence — that in verbose mode a response is preceded by one extra small
write — is the cost of the flag and is why it is off by default. The e2e test
the_flag_times_every_request_and_notification_and_says_so_in_the_log_channel
pins the order, so a future change to it is a deliberate one.
The restart: one chain, reconciled to the last toggle
--verbose is a spawn argument, so lucisv.verbose can only take effect by
starting a new process. That makes the extension's restart the one piece of
this feature with a concurrency problem, and editors/vscode/restart.js is
the whole of the answer to it.
The rule: there is exactly one chain of transitions, no transition exists outside it, and it always reconciles to the last arguments anybody asked for.
- Every toggle writes what it wants into
desiredArgssynchronously and queues a reconcile onto the same promise (chain = chain.then(reconcile)). Nothing else starts or stops the client — the activation spawn is the first link of that chain too, which is the part that matters: a start is in flight for as long as the first workspace scan takes, and that is exactly when a user reaches for the setting. - A reconcile that finds the running arguments already equal to the desired
ones does nothing. That is what collapses a burst of toggles —
on,off,on— into at most one restart, landing on the last one. - Otherwise:
stop()(awaited, and a rejection is tolerated — a client that is not running cannot be stopped, and because this is on the chain, nobody else is stopping it), write the arguments intoserverOptions.args(the client re-reads that object at everystart()),start()(awaited), then repaint. - A
start()that rejects records "nothing is running", so the next toggle retries whatever it asks for, and is reported through the same handler activation failures use rather than swallowed by an anonymouscatch {}. The chain survives it. - Teardown is a link of the chain too.
deactivate()callsrestarter.dispose()and awaits it; it never touchesclient.stop()itself.dispose()shuts the door —want()becomes a silent no-op, and any reconcile already queued returns without doing anything — and then puts one final stop on the same chain, which is what the returned promise resolves after. Idempotent, and a dispose before anything was spawned stops nothing.
That last bullet is the second half of the same invariant, and it was learned
the same way. deactivate() used to await a snapshot of the chain and then
stop the client itself. A lucisv.verbose event landing in the same tick
mutated the live chain and queued a whole reconcile — stop, then spawn —
as a sibling of that stop, with nothing left to await the new process: QA
reproduced stop, stop, start(--verbose) against the shipped module (finding
3, 2026-08-29). When the whole window closes that server dies with its parent's
stdin, but an extension disable or an extension-host-only restart leaves the
host alive and the process orphaned. Two guards close it, and both are wanted:
the one in want() keeps the chain from growing after teardown, and the one
inside reconcile() catches the toggle that got into the queue first — the
chain only promises that a queued reconcile runs after dispose() was called,
not that it was never queued.
Why it has to be a chain rather than a guard: vscode-languageclient 9's
start() returns the in-flight start whenever one exists (client.js:642),
and its stop() rejects while the client is still Starting
(client.js:960). A restart that just calls stop() then start() therefore
stops nothing, rejoins the start that was already running with the old
arguments, and reports success — the user believes the toggle worked while
the server has never heard of it. That was QA finding 1 (2026-08-29), and the
chain removes the precondition for it: no transition ever begins while another
is in flight, so there is no in-flight start to rejoin.
restart.js knows nothing about VS Code — it takes a client-like object with
start()/stop(). That is what lets editors/vscode/restart_test.js
(node restart_test.js, plain node, no dependencies, run like smoke.js
beside it) drive this logic against a scripted fake, rather than
re-implementing the language client's state machine and testing the copy.
Why the in-loop send cannot deadlock
Every timing line goes out through Server::notify, the same fire-and-forget
path the diagnostics push, the scope warnings and the per-file index log have
always used, on the same thread, holding no lock (this server has none — it is
one thread and lsp-server's two I/O threads).
lsp-server 0.10.0's stdio transport makes the writer channel bounded(0), so
a send waits for the writer thread to take the message. That thread does
exactly one thing — write the message to stdout and hand it to a dropper thread
— and never sends anything back into the loop, so there is no cycle to close.
If it has exited, the receiver is dropped and the send returns Err, which
notify_on discards: a client that has gone is nobody to report to. The only
way a send can wait is a client that has stopped reading its own stdout, and
that already blocks every diagnostic and every one of the hundreds of per-file
log lines a scan sends — verbose adds volume there, not a new hazard.
Ordering is likewise unchanged: one channel, one writer thread, FIFO. A timing line sent before a response is written before it, and the two can never interleave.
Assumptions
- The client shows
MessageType::LOG.vscode-languageclient9 appends it verbatim to the extension's output channel (itsLogMessageNotificationhandler falls through tooutputChannel.appendLine), which is where the index log already lands. A client that drops LOG messages sees nothing — the same deallucisv.index.logFileshas always had. - A user who turns this on accepts the volume. A busy session logs a line per keystroke (the flush) and per request. That is stated in the setting's description rather than rate-limited: a sampled diagnostic is a lying one.
- Two decimals of a millisecond is enough resolution. The fastest thing timed here is a cursor answer at ~0.05 ms; nanoseconds would be noise from the clock read itself.
- Nobody parses these lines. They are for a person reading a channel. Nothing in the repo greps them except this feature's own tests.
Handshakes
Amends editors/vscode ◀──▶ lucisv_server (TOPO.md §1.2). The spawn
contract said "binary named lucisv-server, no args, no env, LSP over stdio,
…". It now reads, in that row:
The extension passes exactly
[]by default or['--verbose']whenlucisv.verboseis true; the server accepts only that spelling (repeats are idempotent) and refuses any other argument with exit 2. Changing that setting restarts the server because it is a process argument, not an LSP setting. […]smoke.jsstill drives the default no-argument contract headlessly;tests/e2e.rspins both spawns.
Both halves of that are load-bearing and both are pinned:
- The no-argument spawn is unchanged, which is what
smoke.jsdrives (its spawn untouched this round, still passing) and whatwithout_the_flag_not_one_timing_line_is_ever_sentproves stays silent. - An argument the server does not take is refused, not ignored. Today's
server ignores
std::env::argsentirely, solucisv-server --verboswould have started a perfectly normal server that logged nothing, and the user would have had no way to tell that from a broken feature. Exit 2 matches the CLI's own "an error occurred" code and itserror: unknown option: …wording. There is deliberately no-v,--helpor--version: one spelling, and the version lives on thelucisvCLI, which is wheretools/release.shreads it (TOPO.md §1.2,tools/handshake).
Consumed from editors/vscode: the lucisv.verbose setting, whose
false default and the server's "no argument means off" are pinned against
each other by the_extension_ships_the_flag_off_which_is_what_no_argument_means
in main.rs, reading package.json — the same manifest-vs-shipped-defaults
check settings.rs makes for scopeDepth and maxFileSize.
Promised to nobody else. The lines are not a wire format: no client parses
them, and lucisv.verbose is not a server setting — the server never reads
it out of the lucisv section it is pushed (it is spawn-time or nothing), so
settings.rs is untouched by this round.
Status / TODO
--verboseparsed inmain.rs; unknown arguments exit 2 with a usage line on stderr; the flag threaded toServeras onebool.Server::request/Server::notificationare timing wrappers aroundanswer_request/handle_notification.- The
HELDline, naming whichmust_waitclause held the request. - Scan, widen, flush and
reindex_onelifecycle lines. timer/timed/timing/ms, so verbose-off is one branch per site and nothing else.- Verbose-off cost measured against HEAD (see the work log).
lucisv.verboseinpackage.json, passed in the spawn args, and a restart when it changes.- That restart is one serialized chain reconciling to the last toggle
(
editors/vscode/restart.js), with the activation spawn as its first link — QA finding 1, reworked 2026-08-29. - And teardown is a link of the same chain:
deactivate()awaitsrestarter.dispose(), which shuts the door (inwantand in a queuedreconcile) before its final stop, so no toggle can spawn an orphan on the way out — QA finding 3, reworked 2026-08-29. node editors/vscode/restart_test.js: eleven cases over that chain against a scripted fake client, mutation-checked five ways.- e2e: the flag times things, the absence of it times nothing, a held request says so, an unknown argument exits 2.
- e2e: a cancelled request is timed for exactly what ran, and nothing is reordered under a flood (QA, 2026-08-29).
smoke.jsunchanged in behaviour and still passing.- Contract amended in TOPO.md,
lucisv-server,editor-settings, both editor READMEs. - Not done, deliberately: no
--verboseon thelucisvCLI (it formats files; there is no session to time), no log file, no rate limit, no per-category filter. If the volume turns out to be the problem, the next round is a filter, not a sampler. - Known, not this round's to fix: after a start that failed,
vscode-languageclient9 never clears its_onStart, so a laterstart()re-joins the rejected promise — the chain's retry asks correctly and the library declines, and a window reload is still needed to recover from a badlucisv.serverPath. Pre-existing (QA, 2026-08-29); the retry is the right shape either way and costs nothing.
Work log
2026-08-29 — dev agent (rework 2, after QA finding 3, MEDIUM)
QA's re-verification closed finding 1 (their two mutations were caught by the
shipped test) and found one more transition outside the chain: deactivate()
itself. It awaited restarter.settled() — a snapshot of the chain — and then
called client.stop() beside it, so a want() landing in the same tick queued
a full reconcile, spawn included, that nothing was left to await. Their trace
against the shipped module: stop, stop, start(["--verbose"]). Self-healing
when the window closes (the child's stdin dies with the parent), an orphan when
the extension host outlives the module — a disable, or a host-only restart.
Fixed to the lead's ruling, ten lines:
restart.jsgainsdisposedanddispose(). The flag is set synchronously and checked in two places: the top ofwant()(nothing new is accepted, and the chain does not even grow —wanthands back the teardown promise) and the top ofreconcile()(whatever was already queued does nothing). The second is the load-bearing one: a toggle can beatdisposeinto the queue by a tick, and the chain only guarantees it runs afterwards.dispose()then chains onestopForGoodonto the samechainand returns that link, so awaiting it means "the server is stopped", not "the stop was queued". It stops nothing when nothing was spawned (the real client rejects a stop of a client that never ran), tolerates a rejected stop (teardown — nobody can act on it), and is idempotent, with every caller's promise resolving after the one real stop.extension.js'sdeactivate()is nowreturn restarter ? restarter.dispose() : undefinedand no longer namesclient.stop()at all. With that,grep '\.start(\|\.stop('overextension.jsfinds no client transition outside the restarter, which is the invariant the module header claims — QA checked that grep last pass and it is now true.
restart_test.js grows four cases (11 total, 44 checks): QA's exact repro (a
want() in the same tick as dispose() spawns nothing, and a later toggle
adds no link at all); a reconcile queued before dispose() becoming a no-op;
dispose() resolving only after the final stop, twice-in-one-tick included;
and a dispose before anything was spawned stopping nothing. Mutation-checked to
five now, each caught and each file restored byte-identical: dropping the
disposed check in reconcile (the half the ruling named), dropping it in
want, returning from dispose before its stop finishes, hanging that stop
beside the chain instead of on it, and stopping a client that was never
started.
Also took QA's LOW comment nit in
aFailedStartIsReportedAndTheChainStaysUsable: the comment said the retry is
"what a user who fixed their serverPath does", which reads as though the
retry works against the real client. It does not — _onStart is never cleared
after a failed start — so the comment now says what the test actually pins:
restart.js keeps asking, and whether the ask can succeed is the known
library limitation recorded in Status / TODO.
No crates/ change in this iteration; the server side is untouched by both
reworks.
2026-08-29 — dev agent (rework after QA finding 1, HIGH)
QA found the restart could silently lose a toggle: with a start() in
flight, stop() rejects (swallowed), start() rejoins the in-flight start
with the old arguments, the extension repaints, and nothing anywhere says the
setting did not take. Their trace of the vendored client
(client.js:642-653, 960-965, 988-992) is in the QA log; their repro
harness re-implemented that state machine and was rightly not committed.
Fixed to the lead's ruling — serialize, and reconcile to the last desired
state. New module editors/vscode/restart.js (~90 lines, no VS Code
dependency, shipped) holding createRestarter({ client, serverOptions, onStarted, onStartFailed }):
desiredArgsis written synchronously by everywant(args);runningArgsis what the live process was actually spawned with (nullwhen none is).- One
chain;want()andstart()both dochain = chain.then(reconcile).catch(onStartFailed).activatenow spawns throughrestarter.start()instead of callingclient.start()directly — that is what closes the finding, since the activation start was the in-flight start being rejoined. reconcile()returns immediately whensameArgs(runningArgs, desiredArgs)(so a burst collapses to one restart), else stops (tolerating a rejection), writesserverOptions.args, starts, repaints. A rejectedstart()setsrunningArgs = nulland rethrows, so the failure is reported and the next toggle retries.sameArgs(null, anything)is false,nullincluded, which is what makes that retry possible.onStartFailedisreportStartFailureinextension.js, now shared with activation: one line into the client's own output channel (no popup — the client already reports the spawn failure itself, and activation never opened one), wrapped in case there is no channel to write to.deactivate()now waits for the chain before stopping, for the same reason the toggles do.
The test seam and the test. restart.js takes a client-like object, so
editors/vscode/restart_test.js drives our rule against a fake whose
start()/stop() the test settles by hand — no re-implementation of the
library's state machine, which is what made QA's harness uncommittable. Plain
node, no dependencies, node editors/vscode/restart_test.js, exit 0/1, the
same invocation style as smoke.js beside it; documented in README.md
("Checking the server without an editor") and in tools/RELEASING.md's
.vscodeignore bullet. Seven cases, 28 checks:
- activation spawns once with the settings' arguments;
- the finding: a toggle during the in-flight activation start spawns
nothing while that start is running, then restarts onto
--verboseonce it finishes (andserverOptions.argsis what the second start reads); on→off→onduring an in-flight start costs one restart, landing on the last toggle;- asking for what is already running restarts nothing;
- a rejected
start()is reported once, records nothing as running, and the chain still retries the next toggle; - a rejected
stop()does not cost the start that was asked for; sameArgscompares by value and treatsnullas "nothing running".
Deliberately mutation-checked, because a green test proves nothing on its own:
removing the chaining fails case 2 ("nothing else may spawn while it is"),
keeping runningArgs after a failed start fails case 5, and reconciling to
the old arguments instead of the desired ones fails case 2's landing
assertion. A watchdog timer fails the run rather than letting node exit 0 in
silence if a promise never settles — which it did during development, and is
a trap worth keeping shut. .vscodeignore excludes restart_test.js (and
still smoke.js); restart.js itself must ship, which RELEASING.md now
says out loud with the unzip check.
QA's own LOW (a cancelled request gets no timing line, documented as the third
deliberate absence and pinned by
a_flood_of_requests_and_cancels_under_verbose_times_only_what_ran_and_corrupts_nothing)
is kept as they left it. The server side is unchanged by this rework.
2026-08-29 — dev agent
Server. verbose_flag in main.rs walks std::env::args().skip(1):
every argument must be --verbose (repeats are fine — they say the same thing
twice), and the first one that is not is returned and reported. main refuses
before Connection::stdio() is built: answering LSP anyway would hide the
mistake for a whole session. The flag becomes Server { verbose: bool }
(Server::new and the test seam Server::started each take one more
argument).
request and notification became timing wrappers; the old bodies are
answer_request and handle_notification, unchanged. Each wrapper's first
statement is let Some(started) = self.timer() else { return … }, so
verbose-off is a field read and a branch — no Instant::now, no method clone,
no format!. The other five sites use the same timer() plus timed(started, |took| …), whose closure is never called when the timer is None; the two
"started" lines (scan, widen) are under if started.is_some().
Decisions worth naming:
- The line precedes the response — argued in full above, and pinned by a test rather than left to a reader.
scan started: N file(s) …— the brief's ellipsis is resolved to, interleavedwhen the scan is overINTERLEAVE_ABOVEand to nothing otherwise. It is one word, it is decided at exactly that point, and it is the second half of theHELDanswer: a scan that does not interleave answers nothing at all until it is done.- One duration format for every line. The brief wrote
X.XX msfor requests andX msfor the lifecycle lines; both go throughms()and read asX.XX ms. Two formats would have been a difference with no meaning. - Counts are pluralized (
1 file,0 files) rather than printing a literalfile(s), which is whatend_indexingnext door already does. shutdownis not timed, because it never reaches the dispatch — found by an assertion that expected it to be there, now inverted and commented.
Extension. serverArgs() reads lucisv.verbose (=== true, so nothing
but a real boolean turns it on) and is called once at activation for
serverOptions.args, and again by every toggle. This extension had no
restart-on-settings path before; lucisv.serverPath still needs a window
reload, which this round deliberately did not change.
(The first cut of the restart — a straight-line
stop()/write-args/start() guarded by comparing the new arguments with
serverOptions.args — lost a toggle that arrived while a start() was in
flight. It was rewritten as the reconcile chain below after QA finding 1;
see the rework entry.)
The decorations are repainted after each successful start, because they went with the old connection.
Tests. Four e2e cases, and talk_with(args, session) so a test can spawn
with arguments (talk is now its no-argument case, which is the contract
smoke.js drives):
the_flag_times_every_request_and_notification_and_says_so_in_the_log_channel— one session that opens a buffer, types in it, asks two questions, saves, and shuts down: it produces every kind of line butHELD, and each is asserted by its exact prefix. It also pins the line-before-response order.without_the_flag_not_one_timing_line_is_ever_sent— the same session over the shipped spawn: zerotiming:lines, and the answers still arrive (a server that failed to start would also be quiet).a_request_queued_behind_a_rescan_says_it_was_held— 100 generated files in a filelist make the startup scan interleave; the session's settings push is drained mid-scan and asks for a rebuild, so theworkspace/symbolbehind it is held, says so, and is answered afterwards.an_argument_the_server_does_not_take_is_refused_rather_than_ignored—--verbosexits 2, names the option, prints the usage line, and puts nothing on stdout.
Plus the_extension_ships_the_flag_off_which_is_what_no_argument_means and
three verbose_flag unit tests in main.rs.
Docs. The contract is amended in five places, because five documents state
it: TOPO.md §1.2's spawn-contract row (see the note at the end of this entry),
lucisv-server's README (a new "Starting it: the argument contract" table, and
its Handshakes section, which said the binary promised nobody anything and now
names the argument contract), editor-settings' README (the two settings in
the lucisv section that are not wire settings, and why one of them
restarts the server), editors/vscode/README.md's settings table, and
editors/nvim/README.md (a worked example, including the fact that Neovim
writes window/logMessage at info level and drops it at the default WARN
log level). TODO.md has no item this completes — the backlog never asked for
instrumentation — so it is untouched.
smoke.js is unchanged in behaviour: the only edit is the comment above the
spawn, which claimed the extension passes no arguments and now says it passes
none by default. It still spawns with [] and still passes.
The verbose-off cost, measured against HEAD. The claim is that a server
built with this round and started without the flag is indistinguishable from
the one at HEAD. Both are release builds of the same tree — HEAD's binary was
built and copied aside before the first edit — and each was driven through the
same scripted session: one 400-line buffer, 2,000 textDocument/hover
requests, client-observed round trips on a monotonic clock
(time.perf_counter), five runs of each binary, strictly alternating, on an
M1 Max.
| binary | each run's median, sorted | median of those |
|---|---|---|
HEAD 46e7b31…, no args |
0.0265 0.0268 0.0268 0.0274 0.0283 | 0.0268 ms |
this round 21da327…, no args |
0.0261 0.0262 0.0271 0.0280 0.0510 | 0.0271 ms |
this round, --verbose (3 runs) |
0.0413 0.0451 0.0454 | 0.0451 ms |
The off path is unmeasurable: the two no-argument binaries are 0.3 µs
apart — about 1 %, against a 1.8 µs spread between runs of the same binary —
and the new one is the faster of the pair in three of the five pairings, which
is the shape of noise rather than of a cost. That is what one predictable
branch on a bool field buys you: nothing this instrument can see. (The
italicized 0.0510 is the very first run after the binary was copied into place,
with the file cache cold and the machine still busy from the build; it is left
in the table rather than dropped, and the median is why it does not matter.)
Turning the flag on costs 14–18 µs per request, which is the extra
window/logMessage written before the response. That is half again as long as
a null hover like this probe's, and about 1 % of the 1.35 ms a real cold hover
over opentitan takes (performance.md §2). It is a real cost, which is why the
shipped state is off — but it is nowhere near large enough to change what the
lines it buys are measuring.
The probe is
…/scratchpad/verbose_cost.py <binary> [--verbose]; it needs no fixture but
its own temp buffer, so it can be re-run against any two builds.
Note on TOPO.md. The spawn-contract row this round amends was rewritten in
topo.md from outside this work while it was in progress (the file is
TOPO.md/topo.md, one file on a case-insensitive filesystem; its mtime moved
mid-round, and the whole document was re-dated to 2026-08-29 for several
rounds at once). The amendment already there states exactly what was built —
[] or ['--verbose'], every other argument refused with exit 2, the restart
on the setting, smoke.js still driving the default spawn — so it was left
alone rather than written twice. Nothing else in the tree was touched from
outside; git diff --stat at the end of this round is this round's files plus
that one document.
QA log
2026-08-29 — QA agent
Adversarial pass over the round described in the work log above. Verified by
reading: crates/lucisv_server/src/main.rs, server.rs (the whole diff,
line by line), editors/vscode/extension.js (the whole diff, and its
existing code around client), editors/vscode/node_modules/vscode-languageclient
9.0.1's lib/common/client.js (the real start()/stop()/shutdown() state
machine this round's restart relies on), topo.md, and every touched doc.
Verified by test: gates below, plus one new permanent regression test and
a standalone headless harness (not committed — see finding 1).
Finding 1 — HIGH — restartForVerbose silently drops the toggle if it is
called while a start() is already in flight. editors/vscode/extension.js:284-304.
vscode-languageclient 9.0.1's BaseLanguageClient.start() (client.js:642-653)
returns the existing _onStart promise whenever one is set, regardless of
whether the client is Starting or Running — it only throws when the state
is Stopping. _onStart is set the moment the first start() call begins
and is cleared only by a stop that actually reaches cleanUp()
(client.js:988-992). Consequently, a client.stop() issued while the state
is Starting hits shutdown()'s "Client is not running and can't be stopped" branch (client.js:960-965) and rejects — which
restartForVerbose's try/catch swallows exactly as it swallows "nothing to
stop" — and the subsequent await client.start() then just joins the
original, already-in-flight start, which captured the old args before
the toggle ever wrote the new ones into serverOptions.args. The function
then reaches repaintVisible() with no exception, no rejected promise, no
message anywhere — from the user's point of view the toggle "worked."
This is exactly the scenario the brief names ("toggle while the server is
mid-scan"): a large workspace's startup scan keeps initialize() — and
therefore start() — in flight for a while, and any lucisv.verbose toggle
during that window is lost. It also fires on a second toggle arriving before
a previous restart's own start() has resolved, i.e. it is not limited to
the very first activation.
Repro (headless, no real VS Code — see "what could not be tested" below):
mock vscode and replace vscode-languageclient/node's LanguageClient
with a fake whose stop()/start() reproduce the state transitions read
above (join-if-in-flight, throw-if-not-Running/Stopping); activate() a
context, flip the fake lucisv.verbose setting and fire
onDidChangeConfiguration once, 5ms into a 30ms fake startup start()
(modeling a slow initial scan), then let everything settle. Observed:
spawn attempt #1 args=[]
running with args=[]
setting at end: verbose=true
Only one spawn ever happens, its args are the stale [], and the setting
is left reading true while the running server has no --verbose — with
no error surfaced anywhere. The harness (harness.js, plus three other
scenarios that confirm rapid on→off→on does converge correctly once the
client is already Running, and that toggling after a genuine
StartFailed is at least non-throwing) lives at
…/scratchpad/restart-harness/harness.js in this QA session and was not
copied into the repo: it reimplements the vendored library's state machine
from the source cited above rather than driving the real one, so it is
strong enough to pin this extension's own guard/ordering logic but not a
substitute for an in-VS-Code integration test. Formalizing it (or a
real-vscode-languageclient, fake-vscode version of it) as a permanent
check is a design decision for the dev/lead, not something QA should decide
unilaterally.
Not filed as a fix because the right shape (retry-after-settle? track a "desired args" and reconcile once any in-flight transition finishes? a queue?) is itself a design call — flagging for dev/lead per "you verify, you don't redesign."
Finding 2 — LOW, fixed directly — cancel/timing interaction was
unspecified. The brief's adversarial charter asked explicitly: "cancel a
request and check the timing line story... check the dev documented it." It
was not documented anywhere, and no test exercised --verbose together with
the cancel path. By reading server.rs:479 (cancelled requests are
answered from the cancelled set inside process_batch, before
self.request(request) is ever called): a cancelled request gets no
answered in timing line, since the timed wrapper never runs. This is a
reasonable, already-consistent-with-the-rest-of-the-feature choice (matching
the reindex_one-declined and shutdown-during-scan absences the dev already
listed), so I documented it in the feature README's "Two absences are
deliberate" section (now three) and added a permanent regression test,
a_flood_of_requests_and_cancels_under_verbose_times_only_what_ran_and_corrupts_nothing
in crates/lucisv_server/tests/e2e.rs, which re-runs the existing
a_flood_of_requests_and_cancels_is_answered_exactly_once_each flood with
--verbose and additionally asserts: every id still answered exactly once
(protocol-integrity check under load with the timing notify sharing the
writer channel — no reordering or corruption observed), and the count of
timing: textDocument/formatting answered in lines equals exactly the
number of requests that were not served from the cancelled set (never one
more, for a cancelled id; never one fewer, for a real one).
Everything else checked and found sound:
- Silence when off:
without_the_flag_not_one_timing_line_is_ever_sentcovers every instrumented path in one session (request, notification, scan, widen, flush, reindex_one); confirmed passing.verbose_flag's exit-2 path and the flag's idempotency under repeats are unit-tested inmain.rsand pass. - HELD line correctness:
server.rs:459callssay_heldbefore the request is spliced intoself.held, soself.held.len()at that point is exactly "already held" as documented — confirmed by reading the ordering inprocess_batch. - Ordering: the request's
timing:line precedes its response by construction (requestsends the notify, then returns to the caller which sends the response) — confirmed by reading and pinned by the dev's ownline_at < response_atassertion inthe_flag_times_every_request_and_notification_and_says_so_in_the_log_channel. Confirmed no deadlock risk:notify/timinggo through the same fire-and-forgetbounded(0)writer-thread channel every other notification already uses; nothing in the loop holds a lock across it. didOpenbuffer survives a restart (brief: "verify, don't assume"): readvscode-languageclient'stextSynchronization.js:38-53(DidOpenTextDocumentFeature.registerwalksvscode.workspace.textDocumentsand resendsdidOpenfor every one matching the selector) andclient.js:1005-1007(cleanUp(), run by every successfulstop(), clears_syncedDocuments) — so a freshstart()'sinitialize()always re-syncs every currently-open buffer to the new server process. Verified by reading the real vendored library; not exercised in a live VS Code window (not available in this environment).- Decorations repaint after restart:
restartForVerbosecallsrepaintVisible()after a successfulstart()— confirmed by reading; not exercised in a live window. StartFailedtoggle does not throw:shutdown()'s "not running" branch andstart()'s Stopping-only throw mean a toggle issued after a failed start is caught by the existingtry/catchs and returns quietly. It also does not retry the spawn in that state (_onStartis never cleared by a failed start, so a laterstart()just re-joins the same rejected promise) — this looks like a pre-existing limitation ofvscode-languageclientitself rather than something this round introduced, but it means "fix the badserverPathand toggle verbose to recover" will not work; a window reload is still required, same as it was forlucisv.serverPathbefore this round. Not filing as a new finding since the brief only asked whetherrestartForVerboseexplodes (it does not) — noting it here so it isn't lost.- Off-path cost: re-ran
…/scratchpad/verbose_cost.py— built a fresh release binary of this round's tree and, separately, one from a cleangit worktreeatHEAD(pre-round). Off-path medians over 3×2000 hovers: HEAD ≈0.0292–0.0341 ms, this round (no args) ≈0.0262–0.0316 ms — well inside the run-to-run spread of a single binary, confirming "unmeasurable."--verbosemedians ≈0.0440–0.0449 ms, a ~12 µs delta consistent with the dev's reported 14–18 µs. Independently reproduced, not just re-read. - Contract coherence:
topo.md's §1.2 spawn-contract row, its new verbose-timing handshake row (§2.7), thelucisv-serverREADME's new argument table,editor-settings' README,editors/vscode/README.md's settings table, andpackage.json'smarkdownDescriptionall state the same contract ([]/['--verbose'], exit 2 on anything else, restart on change). No mismatch found;topo.md's pre-existing edit (noted in the work log as done outside this round) matches what was actually built. smoke.js: diff is comment-only; still spawns[]; ran it directly (node smoke.js <built-binary-path>) — passes.- nvim doc's
WARN-level gotcha: plausible and consistent with Neovim's documented default log level (WARN) and its historical mapping of LSPMessageType.LogtoINFOinwindow/logMessage, but I do not have a Neovim binary in this sandbox to execute against, so this is recorded as read-only-verified-from-memory, not executed — worth a real Neovim smoke check before anyone treats it as pinned.
Gates, all green:
cargo fmt --check— clean (after formatting the test I added).cargo clippy --all-targets --all-features— clean, no warnings.cargo test --workspace --release— every crate green, including the 4 new e2e cases, the 4 newmain.rsunit tests, and my added e2e case (63 passed inlucisv_server, up from 62; 2 pre-existing perf tests remain#[ignore]d as designed).node editors/vscode/smoke.js <release binary>— OK (needed an explicit path; there is nolucisv-serveron this sandbox'sPATH, unrelated to this round).
Verdict: REWORK (one finding, severity HIGH; everything else SHIP-clean). Finding 1 is a genuine silent-failure in brand-new restart machinery, exactly in the adversarial charter's target zone ("a restart that loses state") — recommend the dev address it (likely: track the last-desired args and reconcile once whatever transition is in flight settles, retrying rather than assuming one attempt suffices) and add a regression check for it before shipping the extension-side half of this round. The server-side half (the actual timing instrumentation, the flag parsing, the protocol-safety properties) is solid: every adversarial angle in the charter came back clean or was closed with a new permanent test this pass.
2026-08-29 — QA agent (re-verification of the rework)
Focused pass over editors/vscode/restart.js (new), restart_test.js (new),
the rewritten extension.js, .vscodeignore and tools/RELEASING.md. Not a
full re-run of the earlier charter — the server side is untouched by this
rework (confirmed: crates/ diff stat unchanged since the first pass) and was
not re-audited.
1. Every entry point into client.start()/client.stop(), and whether
desiredArgs is ever read non-synchronously. grep -n "\.start(\|\.stop(" extension.js finds exactly two live call sites outside comments:
restarter.start() (extension.js:260, the activation spawn, now the first
link of the chain) and a direct client.stop() in deactivate()
(extension.js:270). Inside restart.js, client.start()/client.stop()
are called from exactly one place, reconcile(), which only ever runs
serialized on chain — so within restart.js there is no second entry point,
confirming the module's own claim. serverArgs() (extension.js:289) is a
plain synchronous read of vscode.workspace.getConfiguration, called at
exactly two sites (extension.js:157, 241), both of which pass its result
straight into want()/the initial serverOptions.args with no await
between the read and the write — no non-synchronous read of desired arguments
anywhere. However — see finding 3 below — deactivate()'s client.stop()
is a transition that happens outside the chain, which is exactly the kind
of second entry point the module's own header comment (restart.js:18-20)
says must not exist ("Nothing else starts or stops the client"). It is
guarded by waiting for settled() first, but that guard has a gap.
2. My own mutation pass (two mutations, not the dev's three), against
restart_test.js, restored after each:
- Dropped the
.catch(onStartFailed)inqueue()(restart.js:97,chain = chain.then(reconcile).catch(onStartFailed)→chain = chain.then(reconcile)), so a failed start poisons the chain instead of leaving it usable. Caught immediately:restart: FAIL — Error: spawn ENOENT(the unhandled rejection propagates out ofmain()), at the very next test that hits a failure. Restored, confirmed byte-identical to the pre-mutation file (diffclean) andrestart_test.jsgreen again (28/28). - Made
sameArgstreatnull/nullas equal (restart.js:29-32, addedif (a === null && b === null) return true;before the existing checks). Caught immediately by the direct unit case:restart: FAIL — not even against another nothing — a failed start must retry. Restored and re-verified green.
Both mutations were caught by the shipped test without needing a third or fourth attempt — the suite has good discrimination on the two properties the brief specifically flagged as easy to get wrong.
3. Fake-client honesty, against my earlier reading of the real
BaseLanguageClient:
- The fake's
start()/stop()are simpler than the real state machine (no "return the in-flight promise" join behavior, noStarting/Stoppingstate at all) — but this is not dishonesty, it's the point:restart.js's whole fix is that it never callsclient.start()/client.stop()concurrently with itself, so the real library's join/reject-while-Starting behavior (client.js:642-653,960-965) is now dead code fromrestart.js's point of view, and a fake that doesn't model it is testing the right surface.aStopThatRejectsDoesNotStopTheRestartexplicitly covers the one real behavior that still matters (astop()can reject), which is the only piece of the real state machinerestart.jsstill has to tolerate. - One real gap, LOW:
aFailedStartIsReportedAndTheChainStaysUsable's fake lets a secondstart()call succeed oncefailNextStartis consumed, and its comment reads "...which is what a user who fixed theirserverPathdoes" — read on its own, that suggests fixing the path and toggling again brings the server up. Against the real library it does not: perclient.js:651-653,_onStartis never cleared by a failed start, so a real secondclient.start()call returns the same rejected promise without attempting a new spawn at all, regardless of whether the underlying problem was fixed — which is exactly the "known, not this round's to fix" item the README already states two sections above (lines 219-224). The test's own assertions are still accurate (they check thatrestart.jsasks again, not that the ask succeeds), so this is a comment-clarity nit, not a wrong assertion — worth a one-line tweak ("...which is whatrestart.jsretries regardless of whether the real client can act on it — see the known limitation above") but not a regression or a blocker. - The known-not-ours limitation itself: confirmed the README states it
plainly (lines 219-224) and that the code degrades to exactly that,
not worse —
reconcile()'s catch setsrunningArgs = nulland rethrows unconditionally on anystart()rejection, real or fake, so a realStartFailedrejoin is reported once per toggle (never silently dropped) and every subsequent toggle keeps asking, forever, which is the documented "asks correctly, library declines" shape.
4. Toggle-while-deactivating — read, then confirmed by executing the real
restart.js: yes, a want() landing after deactivate() has read
settled() can spawn a process nothing will subsequently stop.
deactivate() is:
return restarter ? restarter.settled().then(() => client.stop()) : client.stop();
settled() returns whatever chain currently is — a snapshot, not a live
reference — and deactivate's own client.stop() is attached as a .then
sibling on that snapshot, not enqueued through want()/reconcile. So
deactivate never marks the restarter as done, and nothing stops a want()
call (a stray didChangeConfiguration for lucisv.verbose, arriving from a
settings-sync apply or a user toggling right as the window closes) from
calling queue(), which mutates the live chain variable and queues a
perfectly normal reconcile() — stop, then start a new process — as a
second sibling off the same snapshot.
Reproduced directly against the shipped editors/vscode/restart.js (fake
client, no reimplementation of the library — script available on request,
not committed):
start([])
onStarted
--- activation settled, deactivate begins ---
stop()
stop()
start(["--verbose"])
onStarted
deactivate()'s own client.stop() resolves first (it was attached first),
but the want() fired in the same tick still runs its full reconcile()
afterward — including a fresh client.start() — with nothing left to await
it: deactivate() already returned a promise that resolved after the first
stop(), so whatever waits on deactivate() (VS Code's extension host) has
no way to know a second spawn is happening. In the common case (whole window
closing) the new child's stdin pipe dies with the parent process and
lucisv-server's own loop exits on that EOF, so this self-heals; the bad
case is an extension disable, or an extension-host-only restart, where the
host process outlives the module unload — there the new process has no
remaining handle anywhere in the extension and is a genuine orphan. This is
the round's own target sin ("a restart that loses... servers"), reachable
only through this specific race, in code the rework just wrote.
Verdict on item 4: confirmed real, not ruled out. Filed as a new finding
rather than fixed directly, since the right shape is a design call (a
disposed flag that makes want() a no-op after deactivate starts; or
routing deactivate's stop through the same chain, e.g.
chain = chain.then(() => client.stop()) before returning it, so a want()
racing it queues after the stop instead of beside it) — QA verifies, it
doesn't redesign.
Finding 3 — MEDIUM — deactivate() is a transition outside the chain and
can race a concurrent want() into spawning an orphaned server process.
editors/vscode/extension.js:264-271. See reproduction above. Requires a
lucisv.verbose configuration-change event to land in the same microtask
turn as (or after) deactivate() reading restarter.settled() — a narrow
window, and self-healing in the ordinary whole-window-close path — but
confirmed reachable by direct execution against the shipped module, and it
is exactly the failure class ("loses servers") the brief's top-level charter
named. Recommend closing before shipping, given how cheap the fix looks
(routing deactivate's stop through the chain, or a disposed-flag guard on
want), but it does not block on its own the way finding 1 did — the
common-case teardown path is not at risk.
Gates, all green (re-run in full since a prior pass, given the file
changes span both sides): cargo fmt --check, cargo clippy --all-targets --all-features, cargo test --workspace --release (unchanged pass counts
from the first QA pass — the rework did not touch crates/), node editors/vscode/smoke.js <release binary>, node editors/vscode/restart_test.js (28/28).
Verdict: SHIP with one open item (MEDIUM). Finding 1 (HIGH, the silent
lost-toggle) is closed: the chain construction is sound, the fix targets the
actual root cause (the activation spawn now being the chain's first link),
and both my own mutations plus the dev's own three were caught by
restart_test.js. Finding 2 (LOW, cancel/timing) remains closed from the
first pass. The new finding 3 (MEDIUM, the deactivate race) is real but
narrow, self-healing in the common teardown path, and does not reopen finding
1 — it is a defensible ship-with-a-followup rather than a hold, but the lead
should decide whether a same-round fix (small, per the two options above) is
warranted before release given how directly it falls under this round's own
charter.
Review
2026-08-29 — lead. Reviewed across the full loop: dev, QA REWORK (HIGH: a toggle mid-start silently rejoined the stale start), rework 1, QA re-verify (SHIP plus a new MEDIUM: deactivate's stop outside the chain could orphan a server), rework 2, and the lead's own gate run (fmt clean, clippy silent, 2540 workspace tests, smoke OK, restart harness 44/44). The server half was clean from the first pass: exact diagnostic-build wordings kept, off-path cost measured unmeasurable against HEAD by dev and QA independently, ordering and no-deadlock arguments written rather than assumed, and the cancelled-request absence made deliberate. The extension half is where the loop earned its keep twice — both findings came from reading the pinned library's real state machine, and the final shape is the right invariant stated the right way: one chain, no transition outside it, reconciled to the last toggle, with dispose() closing the door on both entry points. The committed headless harness with five mutation checks is exactly how extension-side machinery should be tested in a repo whose CI has no VS Code; QA's fake-client honesty check and the plainly-documented library limitation (_onStart never clears after StartFailed — reload still required) keep it honest. The spawn-contract amendment is consistent across topo.md, both server docs, both editor READMEs and the manifest. Accepted; committed by the lead.
(reserved for the lead)