TODO §71.7. Three server bugs, all older than this series. - A caret just past an identifier's last letter resolved the NEXT character (spans are end-exclusive): references, definition, hover and highlight came back empty where VS Code considers the caret on the word — the owner's 'not found, then works after clicking back'. lucisv_server/src/caret.rs; nine position-to-symbol requests use it through Server::symbol_offset; the References view opens a row with the caret at the name's start. - process_batch held requests during a scan but applied notifications at once, so a didChange could overtake an older one still queued; with incremental sync that corrupted the server's copy of the buffer until the file was reopened. Rule now: no notification overtakes an older unapplied notification (Server::must_hold, the 'behind' count for the burst a scan is nested in). Cancels wait whenever anything is held; responses never. - answer_what_is_waiting acted on a didOpen it had queued but not applied, re-holding the same batch at every file of the startup scan (~300-400 s on OpenTitan). Scan state now changes only where a message is applied; a held batch is handed back at most once per applied didOpen. An attempt to also drop excluded buffers from the index on close cost 190 ms per open of an outside file and was reverted after QA measured it. Dev (two rounds), QA (two rounds, own ordering driver: 9 118 bursts, no wrong text) and lead review: docs/features/scan-ordering/README.md. TODO.md files what stays open. Version bump (Cargo.toml, Cargo.lock, editors/vscode/package.json and both package-lock.json spots); notes in CHANGELOG.md (## 0.65.8) and editors/vscode/CHANGELOG.md. Gates: tools/gates.sh PASS on this tree including cross; lucisv_server 2030/0. Co-Authored-By: Claude Mythos 5.2 <[email protected]>
58 KiB
scan-ordering
Goal
The owner's report: "Sometimes when I find references on a port/signal, it
shows not found. But if I click somewhere else and then click back to the same
word, the find reference suddenly works again." The investigation (TODO §71.7)
found the cause and two worse bugs beside it. A1: a caret just past a
name's last letter — where a double-click, a click on the right half of the
last letter, or a row of lucisv's own References view leaves it — asked the
server about the next character, and every "symbol under the cursor" request
answered nothing there. B: while a whole rescan answered messages, a
didChange drained mid-scan was applied ahead of an older didChange still
waiting, so under incremental sync the server's copy of a buffer silently
diverged from the editor's until the file was reopened. C: a burst
[request, didOpen] during the startup scan re-held the request at every
file, and the scan took ~300 s instead of ~1.7 s on OpenTitan. This round makes
a caret touching a name's right edge mean that name, establishes "no
notification overtakes an older notification" as the loop's rule, and makes
"only applied messages change a scan's state" true. P1, P2 and P3 are
documented, not changed (P2 was fixed in the first round and reverted in the
fix round for its cost, QA-1).
Assumptions
- VS Code's word rule is the one to match.
getWordAtText(src/vs/editor/common/core/wordHelper.ts) accepts a word whose end equals the caret, so VS Code titles a references search, highlights the word and shows "No references found" for the name before a caret that touches it on the right. Its default word pattern splits on.,(,[,`and$, so inu_a|.sigthe word isu_aand inu_a.|sigit issig; the rule here agrees ([caret::symbol_offset]). - A name byte is ASCII alphanumeric,
_or$(IEEE 1800-2017 §5.6). A macro after its backtick and a system task are covered by the same set; an escaped identifier (\a+b) is handled by its terminating whitespace. A number or keyword just before the caret is a "name" too: harmless for the requests that resolve nothing there, and right fordocumentHighlight's keyword pairs (begin|now highlights itsend, as VS Code's own word highlight already did). vscode.openputs the caret at a range's end. Verified in VS Code's source (extHostTypeConverters.tsconvertsselectionwithRange.from, losing aSelection's direction;codeEditorWidget.ts'ssetSelection(IRange)makes the range's end the position). VS Code's own references view passesrange.with({ end: range.start })and go to definitionRange.collapseToStart(range); lucisv's view now does the same.- What is ordered (fix round, narrowed from "every client message"):
every notification other than
$/cancelRequest— the only messages that change what the server holds — is applied in the order sent, across documents (adidCloseof one file and adidOpenof another stay in order). A request is answered after every notification sent before it (must_wait, unchanged), but may be answered after a newer notification has been applied, when it was held and nothing older than that notification was: it is then answered against newer state, exactly as every request answered late on base was. Exempt altogether: responses (they answer a request the server made;take_the_answer_out_of_heldrelies on that) and the navigation requests the empty-answer rule set aside (deferred, re-asked at a later publish). A cancel waits whenever anything is held, so one naming a held request is honoured at replay; one naming a request in the unapplied tail of the burst a scan is nested in is dropped and the request computed, as on base. - Why narrowing is sound. Buffer text, open/closed state, settings,
folders and watcher effects are changed only by non-cancel notifications.
Such a notification is applied only when no older one is unapplied in
heldor in an enclosing burst's tail ([Server::behind]),heldis replayed in order, and nothing else defers a notification — so the sequence of state changes is the client's. The broad rule's only extra effect was to keep a notification from overtaking a held request, which changes no state and cost the startup its firstdidOpen(QA-3). Checked by the randomized test, f6.py, QA's seeds and hand scenarios (Work log). - Memory while holding is bounded by the scan's length times the client's
rate. Requests were already held this way; a
didChangeunder incremental sync (what lucisv advertises) is a few hundred bytes. A full-sync client flooding whole-buffer changes during a long rescan holds one copy per change until the scan ends — the same order as thedirtytext it would otherwise have kept, times the number of changes. Not coalesced: coalescing two held changes is only sound when nothing between them reads the buffer, which is the analysis this round avoids. - P1 (directory-only watcher events) is a registration question, not a handler one — see Handshakes; nothing arrives today for the case that matters.
Handshakes
Consumed: Scan::neighbourhood_indexed and open_next (unchanged),
sync::apply_changes_at (unchanged). No state/ file is touched after the
fix round (in particular not incremental.rs's holds_another_spelling_of).
Promised to the rest of the server (changed, read this):
process_batchholds notifications too (Server::must_hold, mod.rs). A non-cancel notification is held when an older one is still unapplied: inheld, or in the tail of a burst whose message started the scan now draining (Server::behind, a count of those tails' non-cancel notifications, kept byprocess_batch). A cancel is held when anything is held. A request's rule ismust_wait, unchanged. A response is never held.batch::changes_statenames the messages that are ordered. Anything that adds a new caller ofprocess_batchinherits the rule for free; anything that applies a client message without going throughprocess_batchbreaks it. For lane 71.3 (viewport highlighting), rebasing onto this: theprocess_batchdiff is thebehindbookkeeping (anunappliedcounter), themust_holdcall in place ofmust_wait() && Request, acancel_deferredbefore holding, and the splice moved intoServer::hold(which keepsprocess_batchunder 80 lines). Nothing else in the loop moved.- A
didOpenchanges a scan's order where it is applied. ThedidOpenarm setshead_owedandopened_mid_scanwhenscanning;answer_what_is_waitingreadsopened_mid_scanafter the batch.batch.rs'sopened_inis gone — nothing may read a batch'sdidOpens again. - Position → symbol requests resolve through
Server::symbol_offset(dispatch.rs), which isServer::offsetplus [caret::symbol_offset]. A new request about the name under the cursor should use it; one with a boundary rule of its own keepsoffset. The table is below. - Test-only:
server/probe.rsscripts bursts into a scan's interleave points and counts hand-backs; it is#[cfg(test)]and thread-local, and the one production line is#[cfg(test)]too.
Requests to other modules / the lead (not done here):
- P1 needs a second watcher registration. VS Code coalesces the deletes
under a deleted folder into one event for the folder
(
src/vs/platform/files/common/watcher.ts,EventCoalescer: "remove all DELETE events up to the root folder that got deleted";vscode.d.ts: "file events from deleting a folder may not include events for the contained files"), andextHostFileSystemEventService.tsthen drops the folder event because its path does not match**/*.{v,vh,sv,svh}. So afterrm -rf diror agit checkoutthat removes a directory, the server receives nothing — no handler change can fix it. Created files are not coalesced:mkdir d && cp x.svh d/or a checkout that adds a directory arrives as per-file creates, which the server already handles; a directory moved in arrives as one folder event, dropped the same way. The fix is a second watcher,**/*withkind: Create | Delete, plus a handler that expands a folder path to the held files under it (delete) or a rescan (create). That changes the registration every client receives and the traffic it sends (every create/delete outsidefiles.watcherExclude), which is a decision for the lead, so it is filed rather than done. QA's syntheticr2attack.py dir-create/held-dir-deletestill diverge (unchanged). - P3 (symlinked files held under one spelling or both) is unchanged: the
rule "one file, one spelling, whatever is open" needs the walk
(
discover.rs'sAliased), the overlay and the one-file path changed together. Not small; filed. - P2 (reverted, known, pre-existing — 0.65.6 behaviour). An excluded or
unlisted buffer the index took in (a whole scan takes every open buffer;
the one-file path of a save or watcher event takes it too, QA F4 of
localized-reindex) stays in the index afterdidClose, where a fresh server would not hold it:oracle/r2attack.py excluded-close, "closed" and "saved then closed", 20 answers differ. The first round fixed it by taking an unheld buffer in ondidOpenand forgetting it ondidClose; each is a one-file add/remove, which shifts file ids and rebuilds the completion tables and include naming — ~190 ms per open and ~225 ms per close on full OpenTitan, 2 000 outside files opened and closed 806 s vs 0.7 s (qa717/drv/lat717.py,p2perf.py, QA-1). Reverted. A fix must make the removal cheap (a tombstone the next scan or publish folds in, say) — it is an index-layer change, filed. - QA-2 (known, pre-existing): an unheld buffer opened while a scan runs is
not taken in by that scan, and nothing takes it in when the scan ends;
opened before the scan it is held.
qa717/drv/race717.py BIN <OpenTitan copy> 0.5: an excluded file opened 0.5 s into the startup scan is still unheld after settle, base and new alike. The same final state answers differently depending on when the buffer was opened; QA'sQA_FRESH_SAVEexists to hide exactly this on the fresh side. - QA-7a (known, pre-existing): closing an unsaved in-scope buffer whose
text a rescan took into the index leaves that text in the index after
the close; a fresh server holds the disk text.
qa717/drv/closeidx.py BIN rescan:qd_bufsurvives the close, the fresh server holdsqd_disk. Identical on base. Same root as P2: a close does not touch the index. - Notes for the lead's backlog (QA, not this lane): QA-6 — the
lucisv_mcptestqa_m3::qa_lucisv_check_over_the_same_tree_while_the_server_formats(crates/lucisv_mcp/tests/qa_m3.rs:687) hung to the guard's 600 s limit once in QA's gate run (passed on the retry), also seen in the 0.65.5 release gate log. QA-7b —rand_run.pyfull OpenTitan seed 301 ×100 diverges at step 100 (13 answers,top_earlgrey/ip/ast/rtl/usb_osc.sv) identically on base. QA-7c — renaming a port of a module defined twice (top_englishbreakfast/ip/ast/rtl/adc.sv:81rst_adc_ni) gives an edit or a refusal at random across fresh servers, base too (qa717/drv/dup.py). - lucisv_mcp answers by name, not by caret position, so A1 does not apply to it.
Every position-taking request and its boundary rule (A1)
| request | what the position names | rule now |
|---|---|---|
textDocument/hover |
the name under the cursor | shifted (symbol_offset) |
textDocument/definition |
the name | shifted |
textDocument/typeDefinition |
the name whose type is wanted | shifted |
textDocument/references |
the name | shifted — the owner's bug |
textDocument/documentHighlight |
the name, or a scope keyword of a pair | shifted |
textDocument/prepareRename, textDocument/rename |
the name | shifted |
textDocument/prepareCallHierarchy |
the module under the cursor | shifted (already answered for the whole instantiation, so it changes nothing there) |
textDocument/prepareTypeHierarchy |
the class | shifted (already answered for the whole declaration) |
textDocument/linkedEditingRange |
a closing label being typed | as sent — linked.rs's covers is already end-inclusive (offset <= span.end), which typing at a label's end needs |
textDocument/signatureHelp |
the call the caret is in | as sent — before ( and after it are different answers on purpose |
textDocument/completion, textDocument/inlineCompletion |
the insertion point | as sent — "just past a name" is where the text goes |
textDocument/onTypeFormatting |
the character just typed | as sent |
textDocument/selectionRange |
where expansion starts | as sent — VS Code merges its own word ranges in |
textDocument/codeAction (port refactorings, organize imports) |
range.start as the cursor, resolved to the instantiation or import around it |
as sent — the item's span contains a name's end |
textDocument/codeAction (extract, inline module) |
a range | as sent |
workspace/executeCommand (port commands, lens) |
positions the server itself issued | as sent |
inlayHint, semanticTokens/range, foldingRange, documentLink, documentSymbol, lucisv/scopePairs, the hierarchy snapshot |
a range or the whole document | no caret |
Status / TODO
- Reproduce A1, B, C on
58d3db3with the investigation's drivers; record - A1:
caret::symbol_offset,Server::symbol_offset, nine requests - A1: the References view puts the caret at the identifier's start
- B:
Server::must_hold+Server::behind - C:
opened_mid_scan, set where adidOpenis applied;opened_ingone - P2: fixed in round 1, reverted in the fix round (QA-1); documented
- Fix round: rule narrowed to notification-over-notification (QA-3);
process_batchsplit (Server::hold); QA-4 measured; QA-5 wording - P1: filed (Handshakes) — needs a registration decision
- P3: filed (Handshakes)
- Regression tests (fail on
58d3db3+ the probe, pass now) - Randomized ordering test, fast and
#[ignore]d long - QA's seeds and hand scenarios against the binary
- Timings
- fmt, clippy
--all-targets -D warnings, guardedlucisv_server(fix round: 1 920 unit + 106 integration, 44 + 3 ignored),vlog_semantic435,lucisv_mcp384,node --test editors/vscode/*_test.js37; ignored release runs (both re-index sweeps, the 300-seed ordering run) pass - full
tools/gates.sh: PASS, every step (corpus 814/6, the same six known failures;lucisv_server2 032/0)
Not verified here (no VS Code on this machine): double-click a port name and run Find All References — results, not "No references found"; F12 and hover with the caret just after a name; a row of lucisv's References view opens with the caret at the name's start, and Shift+F12 from there finds the same list; F2 with the caret just after a name opens the rename box.
Work log
2026-11-19 — dev agent
Base is 58d3db3 (release 0.65.6). Drivers are the investigation's
(scratchpad/inv717/drv), QA's oracle (scratchpad/qa711/oracle) and the Q1
driver (scratchpad/qa713/drv/livelock2.py), copied to scratchpad/dev717/
with the guard pointed at this worktree; every tree they touch is a scratch
copy, every index store is under dev717/st.
Reproduced on base, then fixed (same drivers, release binaries):
58d3db3 |
now | |
|---|---|---|
A1 refpos.py uart_core.sv tx, caret just past the name (col 27) |
refs 0, def 0, highlight null, hover null | refs 3, def 1, highlight 2, hover yes (= col 25) |
| A1 one column further right (col 28) | 0 / 0 / null / null | 0 / 0 / null / null (unchanged) |
B f6.py held, full sync |
server holds v2, client v3 | v3 |
B f6.py tail, full / incremental |
v2 / v3 lost ({qa_v2_mod} only) |
v3 / both, in place |
B f6.py held, incremental |
right by luck (the two inserts commute) | right |
C livelock2.py hover, cold full OpenTitan |
hover and tokens answered at 318.6 s, scan ended 318.6 s | hover 0.68 s, tokens(B) 0.76 s, scan ends 1.70 s (median of 3; 4th run, delta variant: 0.67 / 0.76 / 1.70 s) |
A1. caret.rs is the rule (23 production lines): one byte left when the
caret's byte is not a name byte and the byte before is, or when the caret sits
on the whitespace that ends an escaped identifier. Applied after the UTF-16 →
byte conversion, so a multi-byte character before the name changes nothing.
Server::symbol_offset in dispatch.rs uses it for the nine requests in the
table. Decided against shifting inside the feature modules (nav.rs etc.):
one place, one rule, and the requests with their own boundary rule are visibly
the ones still calling offset. The References view's rows now open with a
collapsed selection at the identifier's start — vscode.open cannot carry a
backwards Selection, so "select the name, caret at its start" is not
expressible through it, and the start is where VS Code's own view and go to
definition put the caret.
B. Server::must_hold is the rule, Server::behind the bookkeeping. The
prototype held every notification while a rescan a message asked for was
running (answering_a_rescan). That is a superset of what is needed and it
cost something real: a watcher event arriving during a rescan was then
applied after it, one scan each, instead of coalescing into one more scan.
behind is exact: process_batch sets it, for the message it is handling, to
"how many older messages are unapplied in the bursts around me", so a scan's
drain holds a notification only if something older really is waiting. Pinned
by a_rescans_trigger_alone_in_its_burst_still_lets_newer_changes_apply_at_once
(two bars: the rescan, and one more for both watcher events). Cancels follow
the same rule, so a cancel arriving after its held request now waits with it
and is honoured when the batch is replayed (before, it was dropped and the
request computed); a cancel naming a deferred request is still honoured where
it lands.
Answers to the brief's questions:
- Must didClose/didSave/watched/config keep order? Yes, all of them: the
rule is about the stream, not the method. A
didSaveheld behind a held request is applied after it — as the cheap one-file update, where before it was folded into a whole rescan. - Other documents? Same stream, same rule —
didClose(a)thendidOpen(b)(a rename) cannot cross.a_reopen_behind_a_held_close…pins the one- document form, the randomized test the cross-document one. - Starvation? The scan drains exactly as before (the drain still reads, it
only holds). Progress is the scan's and unaffected.
shutdownwas already held behind a rescan a message asked for and still is: measured withdev717/drv/exitmid.py(see Timings).exitis read byhandle_shutdownoff the connection, never queued. - Memory? Under Assumptions.
- One exemption, kept: a navigation request the empty-answer rule
deferred (
Server::deferred, startup scan only) is re-asked at the next publish, and adidChangeapplied in between moves the text under its position. That is the perf5r-publication design, not a reordering of applied messages; the worst it gives is a stale or empty navigation answer, never a buffer change. Not changed.
C. As the prototype: the didOpen arm sets head_owed and
opened_mid_scan when a scan is running; answer_what_is_waiting clears the
flag before the batch and takes it after. Bound: a held batch is handed
back only when !answering && !rescan_wanted && !head_owed; handling it
re-holds something only behind a didOpen it applied (each message is
applied once) or a rescan it asked for (one per scan), so hand-backs ≤
applied didOpens + scans + 1 — the randomized test asserts exactly that
inequality every round, and base breaks it at seed 1, round 0 (37 hand-backs
for 2 didOpens and 1 scan).
P2. The index now holds every open buffer (a didOpen that moves no scope
takes an unheld buffer in through update_one_file, the path F4 already
used) and forgets a closed one that scope_could_take says no scan would
hold. Both halves were needed: closing alone fixed r2attack.py excluded-close "closed" and "saved then closed" and broke "reopened". Mid-scan
the open half does nothing (as before) and the close half asks for one more
scan. One existing test changed fixture, not assertion:
sync::closing_a_dirty_buffer… opened two files that were not on disk, which
now costs an index change on close; the files are written to disk so the test
asks what it always asked.
P1, P3: not changed — see Handshakes for what VS Code actually sends and why the fix is a registration decision.
Tests (new files; each failing test was run against 58d3db3 plus only the
probe hook, in scratchpad/dev717/basecopy):
| test | 58d3db3 |
|---|---|
scan_ordering::a_change_drained_mid_rescan_waits_behind_an_older_change_held_with_a_request |
FAIL (holds v2) |
scan_ordering::incremental_changes_held_mid_rescan_are_applied_in_the_order_they_were_sent |
FAIL (second insert one line off) |
scan_ordering::a_change_drained_mid_rescan_waits_behind_the_rest_of_the_burst_that_started_it |
FAIL (holds v2) |
scan_ordering::a_reopen_behind_a_held_close_leaves_the_buffer_open_with_its_new_text |
FAIL (buffer closed) |
scan_ordering::a_request_ahead_of_a_didopen_mid_startup_is_answered_and_the_drain_runs_once |
FAIL (answered after the bar) |
scan_ordering::a_request_behind_a_didopen_mid_startup_still_waits_for_the_buffer_it_names |
pass (kept behaviour) |
scan_ordering::a_rescans_trigger_alone_in_its_burst_still_lets_newer_changes_apply_at_once |
pass (kept behaviour) |
caret_boundary::every_symbol_request_answers_the_same_just_past_a_name_as_at_its_start |
FAIL (references []) |
caret_boundary::a_caret_after_a_dot_is_on_the_member_and_before_it_on_the_instance |
FAIL |
caret_boundary::the_column_past_a_name_is_counted_in_utf16_after_non_ascii_text |
FAIL |
outside_buffers::an_excluded_buffer_is_held_while_open_and_forgotten_when_closed |
FAIL |
outside_buffers::a_buffer_not_on_disk_is_held_while_open_and_forgotten_when_closed |
FAIL |
outside_buffers::closing_a_buffer_the_scope_takes_leaves_the_index_alone |
pass (kept behaviour) |
ordering_random::random_bursts_keep_every_buffer_and_answer_every_request_once |
FAIL (C bound, seed 1 round 0; with that check disabled, B: seed 1 round 5, a.sv lost an edit) |
caret::tests (7, the rule itself) |
— (new module) |
Randomized test (ordering_random.rs): a seeded xorshift client with three
documents sends bursts of 1–4 messages — full and incremental didChanges
(insert or delete a line, ranges in the client's own current text),
didOpen/didClose, $/cancelRequest for a random earlier id, hover /
definition / documentSymbol / workspace/symbol, and watcher create/delete
events; 70 % of rounds put a rescan trigger at a random place in the round's
first burst, and 0–6 more bursts land at the scan's interleave points through
the probe. The startup scan gets 1–5 scripted bursts too (that is where C
lives). After every round: the server's open buffers are the client's and
their text is byte-equal; hand-backs ≤ didOpens + scans + 1. At the end:
every request answered exactly once, and documentSymbol of every open buffer
plus the created packages equal a fresh server's on the same disk and
buffers. Normal suite: seeds 1–12 × 10 rounds, ≥ 200 bursts must land
mid-scan (300 do), 0.8 s debug. #[ignore]d long run: seeds 100–399 × 40
rounds, ≥ 10 000 mid-scan bursts, 32 s in release — passes.
QA's oracle against this binary (logs scratchpad/dev717/logs/), none
with QA_REPAIR (the "re-send buffers before each check" workaround):
| run | 58d3db3 / QA |
now |
|---|---|---|
rand_run.py corpus, push, seed 7 × 200 (every 25) |
divergent at step 200 (F6) | 8 checks, 0 divergent |
rand_run2.py OpenTitan sample, seed 42 × 500 (every 25), QA_FRESH_SAVE=1 as in QA's run |
step 350 divergent (F6) | 20 checks, 0 divergent |
rand_run.py full OpenTitan hw, seed 21 × 50 (every 50) |
309 answers differ | 0 differ |
small.py, workspace + folder scope, pull and push |
— | 94 + 94 ok; only NEGCTL-silent diverges (both scopes), as it must |
outside.py, pull and push |
— | 14/14 and 14/14 ok (re-run on the final binary too) |
r2attack.py (all cases) |
directory-create, held-directory-deleted (P1), excluded-open-close closed / saved-then-closed (P2) diverge |
only the two P1 cases diverge |
Seed 42 run without QA_FRESH_SAVE diverged at step 50 on an excluded
buffer (qa_excl/qa_x0.sv) the incremental server now holds while it is open
and the fresh side does not — the fresh server's documented startup race (a
buffer opened while its startup scan takes its work list is not taken in),
which is what QA_FRESH_SAVE exists to remove; with it, 0 divergent over 500
steps.
Re-index lane sweeps (release, --ignored a_seeded_sweep): corpus 3
seeds and OpenTitan sample 2 seeds, both pass.
Timings (release, full OpenTitan hw 4 061 files, workspace scope; the
machine is shared with another lane):
58d3db3 |
now | |
|---|---|---|
| startup scan, cold (median of 3) | 2 104 ms | 2 077 ms |
| startup scan, warm (median of 3) | 1 124 ms | 1 124 ms |
perf.py, median of 5, save → reindex_one line: uart_tx comment / uart_tx signal / prim_flop signal / prim_flop top / uart_reg_pkg member / prim_assert / prim_mubi member / prim_mubi top / tlul_pkg top / new uvm_object / new `define / clk_rst_if top |
0.04 / 8.2 / 8.1 / 67.3 / 22.8 / 3.5 / 97.9 / 98.8 / 85.4 / 13.4 / 9.5 / 28.6 | 0.04 / 8.6 / 8.4 / 67.1 / 23.5 / 3.4 / 106.5 / 103.2 / 84.3 / 10.5 / 14.6 / 30.0 |
| watcher echo, every row | 0.03–0.35 ms | 0.02–0.33 ms |
C: [hover, didOpen(B), tokens(B)] in a cold startup (livelock2.py) |
318.6 s | 1.70 s scan, hover 0.68 s |
didClose of a held file (P2's scope check), median of 3: prim_assert (174-file dir) / top_earlgrey / uart_core / dv_base_env |
0.02 / 0.16 / 0.13 / 0.02 ms | 1.22 / 0.41 / 0.27 / 0.22 ms |
didOpen of the same four |
0.21 / 1.64 / 1.28 / 0.31 ms | 0.20 / 1.57 / 1.15 / 0.28 ms |
shutdown sent mid-rescan, behind a held hover and change (exitmid.py) |
answered 0.75 s, exit 0.92 s later | answered 0.76 s, exit 0.87 s later |
The save rows move by noise either way except prim_mubi_pkg (+5–9 ms of
~100) and the new `define (+5 ms), both single-digit and in rows whose
work this round does not touch (nothing here runs on a save); a didClose
now pays the scope walk of its directory, about a millisecond at worst.
Test hook: server/probe.rs (#[cfg(test)], thread-local) — the
transport cannot be timed against a scan's files, so a test scripts what
arrives at each interleave point. One #[cfg(test)] line in
answer_what_is_waiting.
Files (production lines, non-blank non-comment, before mod tests; base
in parentheses): server/mod.rs 203 (186), server/dispatch.rs 491 (486),
server/index.rs 292 (265), server/notification.rs 252 (244),
server/batch.rs 74 (opened_in removed), server/startup.rs 173 (+2),
state/watched.rs 95 (+3), state/incremental.rs 145 (+4), new
caret.rs 23, new server/probe.rs 46 (test-only); main.rs +1;
editors/vscode/referencesView.js +5. Tests: server/tests/{scan_ordering, caret_boundary,ordering_random,outside_buffers}.rs new, tests/mod.rs
+4 module lines, tests/sync.rs fixture, referencesView_test.js one
assertion.
2026-11-19 — dev agent: fix round (QA-1 … QA-5, the size note)
QA-1 — P2 reverted. take_in_if_unheld, forget_if_outside,
Workspace::holds_outside_the_scope and Workspace::forget_file are gone;
state/watched.rs, state/incremental.rs and server/tests/sync.rs are
byte-identical to 58d3db3 again (the sync fixture change is undone —
without P2 it is not needed), server/tests/outside_buffers.rs is deleted.
Making open/close of an unheld file cost < 1 ms is not reachable at the
server layer: adding or removing one file shifts ids and rebuilds the
completion tables and the include naming (QA's sample), so it is filed as
an index-layer change (Handshakes, with QA-2 and QA-7a). QA's drivers,
full OpenTitan, before the other lane's load test started:
lat717.py (median of 5), didOpen / didClose |
58d3db3 |
round 1 (QA) | now |
|---|---|---|---|
| held files | 0.83–2.72 / 0.11–0.27 ms | 0.47–1.74 / 0.39–1.02 ms | 0.80–3.43 / 0.11–0.29 ms |
| outside the root | 0.57–0.59 / 0.08–0.10 ms | 185–189 / 222–230 ms | 0.54–0.56 / 0.06–0.08 ms |
| excluded | 0.55–0.59 / 0.07 ms | 188–190 / 222–225 ms | 0.44–0.81 / 0.07–0.08 ms |
| outside / excluded, 200 buffers open | 0.47–0.60 / 0.07–0.08 ms | 201–228 / 258–279 ms | 0.52–0.58 / 0.06–0.08 ms |
p2perf.py: 2 000 outside files opened and closed |
0.7 s | 806 s | 0.7 s |
p2perf.py: didClose with ~200 open, in-scope / outside (median) |
0.13 / 0.09 ms | — | 0.11 / 0.09 ms |
QA-3 — the rule narrowed to "no notification overtakes an older
notification" (must_hold; the soundness argument is under Assumptions).
Chosen over a staging-only patch because it is the rule B actually needs and
the broad rule bought no state the client could see; the staging case then
needs nothing special. live717.py staging, first hover with a request ahead
of the first didOpen: 58d3db3 0.111–0.133 s, round 1 0.151–0.160 s, now
0.116–0.125 s (3 × 3 runs). Cancels: one waits whenever anything is held
(so a late cancel of a held request is still honoured); changes_state
excludes them from what makes a notification wait. New test
a_change_behind_only_a_held_request_applies_at_once_and_a_late_cancel_waits_with_it
pins both halves. Every earlier test, the randomized one (fast and the
#[ignore]d 300-seed run) and f6.py's six variants pass unchanged.
QA-4 — documented, not changed. QA's c717.py (cold full OpenTitan, 16–18
bursts [request, didOpen×1–3] in the first 0.2 s) on the narrowed rule:
scan ends 3.74–4.17 s (5 seeds), answers 0.02–4.17 s, median 1.40–1.68 s; QA
measured 2.8–4.2 s on round 1, the same 26 opens without requests 1.66–1.89 s.
Each request behind an applied didOpen is held until the work list
re-ordered round that buffer has indexed its neighbourhood, and the hand-back
then forces a publish (a merge over the index so far) so the answer can see
it — one per burst here. Coalescing hand-backs would mean answering a later
burst's requests before its neighbourhood is in, which is the §P4b []
the head rule exists to prevent; cheaper publishes are the index layer's.
So the cost stays: bounded (≤ one forced publish per applied didOpen),
seconds, against ~400 s on base.
QA-5 — the changelog now names what is ordered: edits, opens, closes, saves and the other notifications (not responses, not deferred navigation requests).
Size. process_batch 95 → 69 lines: the splice into held is
Server::hold, and answering one request (cancelled / deferred / computed)
is Server::answer_from_batch. No behaviour moved.
Fix-round checks against this binary (dev717/logs3, none with
QA_REPAIR). Another lane ran an 18-busy-loop load test on this machine from
about 11:00 into the oracle runs, so the latency numbers below that window are
not comparable and were re-taken after it eased.
| run | result |
|---|---|
refpos.py (A1) |
col 27 = col 25 (refs 3, def 1, highlight 2, hover), col 28 nothing — unchanged |
f6.py held / tail / control, full and incremental |
all six: server holds v3, incremental inserts in place |
livelock2.py hover (C), after the load eased |
hover 0.66–0.90 s, tokens(B) 0.74–0.99 s, scan ends 1.67–2.15 s (3 runs) |
q1min.py |
answered 0.96 s, one progress cycle |
| corpus push 7 × 200 | 8 checks, 0 divergent |
OpenTitan sample 42 × 500 (QA_FRESH_SAVE=1) |
20 checks, 0 divergent |
| full OpenTitan 21 × 50 | 0 divergent |
new: corpus push 111 × 300 (rand_run2.py) |
12 checks, 0 divergent |
new: OpenTitan sample 211 × 300 (QA_FRESH_SAVE=1) |
12 checks, 0 divergent |
small.py pull and push, both scopes |
94 + 94 ok; only NEGCTL-silent diverges, as it must |
outside.py pull and push |
14/14 and 14/14 |
r2attack.py |
P1's two cases and P2's two (excluded-open-close closed / saved then closed) diverge — 58d3db3's set, as the revert intends |
full tools/gates.sh |
PASS every step; lucisv_server 2 030/0, corpus 814/6 |
Production lines now (as before, base in brackets): server/mod.rs 215
(186), server/index.rs 267 (265), server/notification.rs 248 (244),
server/batch.rs 77 (opened_in removed, changes_state added),
server/dispatch.rs 491 (486), server/startup.rs +2, caret.rs 23,
server/probe.rs 46 (test-only); state/ untouched.
Changelog paragraph (for the lead)
Find All References, Go to Definition, hover, highlight and rename now work with the cursor just after a name. A double-click, a click on the right half of the last letter, or a click on a row of lucisv's References view leaves the cursor there, and the server used to look at the character after the name — so VS Code said "No references found" until you clicked away and back. The References view now also puts the cursor at the start of the name it opens. An edit typed while the workspace was re-indexing could be applied out of order, leaving the server's copy of the file different from the editor's until it was closed and reopened; edits, opens, closes, saves and the other notifications the editor sends are now applied in the order it sent them. A file opened while the first index of a session was being built could make that index take minutes instead of seconds on a large workspace (about 300 s instead of 2 s on OpenTitan); fixed.
QA log
2026-11-19 — QA agent (Opus 5.5)
Verdict: PASS WITH FINDINGS. No lost, duplicated or reordered message, no
deadlock, no wrong buffer text and no wrong rename found in anything below. One
High finding (QA-1, a P2 cost: opening or closing a file the index does not
hold now blocks the loop ~0.2 s on OpenTitan) should be fixed before release;
the rest are Low/Info or pre-existing. Everything ran against release binaries
built here (qa717/bin/new from this worktree, qa717/bin/base from
git archive 58d3db3, own CARGO_TARGET_DIRs). All drivers and logs are in
scratchpad/qa717/{drv,oracle,logs}; every tree was a scratch copy, every
index store under qa717/st; ~/.cache/lucisv-opentitan-full git status --short empty and nothing under either cache newer than this QA's start.
Baseline. tools/gates.sh (full, logs qa717/gates/): PASS — fmt,
clippy -D warnings, build, every suite (lucisv_server 2 032/0,
vlog_semantic 435/0, lucisv_mcp 384/0), docs, corpus 814/6, node 37/0.
One guard kill — see QA-6. Ignored release runs (--ignored ordering_random sweep_over_the_corpus sweep_over_an_opentitan, guarded, trees from scratch
copies): 3/3 pass. Counts vs 58d3db3: lucisv_server unit 1 901 + 43 ignored →
1 922 + 44 (+14 server tests, +1 ignored long run, +7 caret unit); integration
106/3 unchanged; no pre-existing test removed or edited except sync.rs.
The changed fixture: with the base fixture on the new code the test fails
generation 6 != 5 — P2's take-in/forget of two not-on-disk buffers is an extra
index change and republish. Writing the files to disk keeps the test's subject
(the closed buffer's dirty text is never analyzed, the other one flushes) and
every assertion's meaning; accepted. New tests on base: grafted
probe.rs + its one #[cfg(test)] call + the four test files onto the
58d3db3 archive: exactly the 11 the README lists fail, the 3 "kept behaviour"
tests pass. probe is #[cfg(test)] at server/mod.rs:60 and
server/index.rs:522, no other reference. Sizes: every touched file under 600;
process_batch is 95 lines (78 on base), mostly comment — over the 80 line
"investigate" mark (Info).
B/C code read. must_hold, behind, process_batch,
answer_what_is_waiting, waiting_for_this_scan, run's replay,
take_the_answer_out_of_held and the staging loops: every message put in
held is taken out by run (loop top) or by the startup scan's drain; held
non-empty never outlives a scan, and nothing waits on a client response except
staging's bounded waits (the only recv_timeouts). behind is restored on
every exit of process_batch that the caller reads. No path found where a
message is applied twice or dropped.
B — ordering, own stdio driver (drv/ord717.py, independent of the probe):
4 synthetic documents in 4 folders, seeded bursts of 1–5 messages written in
one write() — incremental single- and multi-change and full didChanges,
didOpen (disk or new text), save-then-didClose, didSave (±text),
documentSymbol / hover / definition / references / semanticTokens / highlight /
workspace/symbol, $/cancelRequest of a recent id, watcher create/delete of
package files, an unknown notification, a malformed didChange — while scans
run: the startup scan, workspace-folder add/remove, a pushed and an empty
(workspace/configuration pull) config change, a save of an unheld file,
watcher creates. Checked: every documentSymbol answer equals the client's
text at the moment the request was sent (the order contract, exact
names/lines/columns); after each settle every buffer's text, open/closed state
and the watcher/save effects; every id answered exactly once; a final battery
(documentSymbol, semantic tokens, hover/references/definition at both ends of
every name, workspace/symbol, push diagnostics) equal to a fresh server's.
Runs: corpus seeds 1–3 ×30 and 10–17 ×60 (workspace), 20–23 ×60 (folder); full
OpenTitan seeds 30–32 ×40 (workspace), 40–41 ×40 (folder): ≈ 8 700 bursts,
≈ 27 000 messages, 85 % of bursts sent while a scan was running, ≈ 4 500
at-send-time checks — 0 ordering/text/state failures, 0 duplicate or missing
responses. Fresh oracle: equal in every run once the driver saved dirty
buffers before comparing (the 6 seeds that had differed, re-run, and the 5 that
never had); the 12 runs that differed before that correction differed only in
workspace/symbol for module names typed but not yet saved — the documented
index staleness of unsaved text, not this lane. The same driver on base fails at once (seed 1: 22 failures,
both scopes — stale documentSymbol answers, a buffer one edit behind).
(Two driver corrections were needed, both my model: duplicate wire names
collapse in documentSymbol; and unsaved buffer text reaches the index only at a
scan or save, so the final oracle saves dirty buffers first. A third thing the
driver found is pre-existing — QA-7.)
Liveness / latency (drv/live717.py, full OpenTitan, whole rescans of
~0.6–1.8 s; base vs new):
| case | 58d3db3 |
now |
|---|---|---|
| hover held mid-rescan, then its cancel: cancel → answer | 0.55–0.59 s, honoured 4/5 (once computed) | 0.58–0.62 s, honoured 5/5 |
| shutdown behind a held hover + change mid-rescan: answer / exit | 0.65 s / 0.86 s; hover answered first | 0.66 s / 0.94 s; hover answered first |
exit alone mid-rescan with a held queue |
exits 0.8–1.6 s | exits 1.0–1.6 s |
server's workspace/configuration (+ progress create, lens refresh) held by the client, answered mid-burst while notifications are held |
no deadlock, final text right | no deadlock, final text right |
20 000 incremental didChanges flooded behind a held request across rescans |
settle 23 s, RSS peak 686 MB, text wrong | settle 27 s, RSS peak 679 MB, text right |
| VS Code-like typing (change + tokens + highlight per key, 30 ms) through 5 rescans | scans 1.5–1.85 s, text wrong at the end | scans 1.6–1.86 s, text right |
request before the first didOpen during staging: first hover |
0.11–0.13 s | 0.15–0.18 s (QA-3) |
(The shutdown case exits with rc 1 in 2 of 3 runs on both binaries — pre-existing, Info.)
C bound (drv/c717.py: cold startup on full OpenTitan, 26 didOpens in
13–14 bursts [request, didOpen×1–3] every 2–10 ms): base — every answer at
406.9 s, scan ends 406.9 s. Now — scan ends 2.8–4.2 s (5 seeds), answers
0.03–4.15 s, no duplicate. Same 26 opens with no requests between them: scan
1.66–1.89 s; plain cold startup 1.65 s. So C is fixed and bounded, but see QA-4.
A1 sweep (drv/a1sweep.py): 200 corpus files × 25 tokens and 150 OpenTitan
files × 20 tokens (identifiers, keywords, macros, system tasks, numbers), all
nine requests: 69 030 token×request pairs; end == start == middle on the new
server in every one; new == base at the start in all but 6 (all in
OpenTitan's duplicated top_*/ip/ast modules — rename there is
nondeterministic on base too: 4 edit / 4 refused in 8 fresh base servers; QA-7);
one column right of the name (40 158 cases) new == base in every one.
Edges (drv/a1edge.py, drv/a1rename.py): \foo /\a+b (on the ending
space: the name; after it: nothing), $bits(a|), `FOO|, `BAR|(b),
8'hFF| / 8'hF|F / 12| (nothing — no hFF/FF signal resolved),
begin|/end|, u_a|.b/u_a.|b/u_a.b|, pkg|::x/pkg:|:x/pkg::|x/pkg::x|,
a|+b, x|[i], x[i|], f|(a), f(a|), end of line, endmodule : d| at EOF
with and without newline, empty file, column 0, CRLF, tabs, non-ASCII and an
astral character before the name, ifdef-out region: end-of-name == start
everywhere. Comments, strings and a `define body: nothing at start and end.
Rename/prepareRename at the end-of-name caret: placeholder and range are the
whole name and the applied edit is byte-identical to the one from the start in
all nine shapes — never the neighbour. A position past the end of a line now
resolves the line's last name (VS Code never sends one; Info). Request table:
every arm in dispatch.rs that reads a position is either one of the nine or in
the "as sent" rows (linked editing, signature help, completion, inline
completion, on-type, selection range, the two code-action uses of
range.start, executeCommand); declaration/implementation/moniker are not
served; nothing missed.
P2 (drv/p2.py: excluded / outside-the-root / not-on-disk buffer ×
open-close, open, close-reopen, save-close, change-close, open-mid-scan-close,
close-mid-scan, open+close in one burst; fresh server with the same buffers
opened before its scan): workspace scope 24/24 equal (base 12/24). Folder
scope: the outside-the-root file stays held after close — the opened file's
folder widened the scope, which never shrinks; base does the same in an
isolated tree, by design. 2 000 distinct outside files opened and closed: RSS
695 → 718 MB, none left in the index — but see QA-1 for the time it took.
QA_FRESH_SAVE — see QA-2.
Re-index oracle on this binary (QA 71.1's scripts, no QA_REPAIR):
small.py pull and push, both scopes: only NEGCTL-silent diverges, as it must;
outside.py 14/14 both. Previously failing seeds: corpus push 7 ×200 — 8 checks,
0 divergent; full OpenTitan 21 ×50 — 0 differ; OpenTitan sample 42 ×500 with
QA_FRESH_SAVE — 20 checks, 0 divergent (without it: divergent at step 50, the
QA-2 race). New seeds: corpus 101–103 ×500 and push/folder 104 ×500 — 0 divergent;
OpenTitan sample 201–203 ×500 — 0 divergent with QA_FRESH_SAVE, divergent at
step 150–200 without (every diff an excluded qa_excl buffer, QA-2); full
OpenTitan 301 ×100 — 13 answers differ at step 100, identically on base
(QA-7).
References view. VS Code's TextEditorOpenOptions.from converts
selection with Range.from and codeEditorWidget.setSelection(IRange) makes
the range's end the position — so base put the caret just past the name, the
A1 spot; a collapsed range at range.start puts it at the name's start, where
Shift+F12 works on a base server as well as this one (VS Code's own references
view uses range.with({ end: range.start })). Cost: the row no longer
selects the identifier. The test asserts the new collapsed range. The P1
analysis checks out against watcher.ts (coalesce: deletes under a deleted
parent dropped) and extHostFileSystemEventService.ts (each event filtered by
the registered glob). The extension sets no wordPattern, so VS Code's default
word rule is the one in play.
Timings (release, full OpenTitan, workspace scope, medians of 5, machine
shared with this QA's own runs): cold startup 1 667 → 1 681 ms, warm 747 → 747
ms. Open/close (drv/lat717.py, didOpen → its publish, didClose → its clearing
publish):
| file | 58d3db3 open / close |
now open / close |
|---|---|---|
| held (prim_assert, top_earlgrey, uart_core, dv_base_env) | 0.46–1.83 / 0.07–0.18 ms | 0.47–1.74 / 0.39–1.02 ms |
| outside the root, 0 other buffers | 0.33–0.36 / 0.06–0.07 ms | 185–189 / 222–230 ms |
| excluded, 0 other buffers | 0.34–0.37 / 0.06–0.07 ms | 188–190 / 222–225 ms |
| outside / excluded, 200 buffers open | 0.31–0.38 / 0.05–0.07 ms | 201–228 / 258–279 ms |
Saves (QA 71.1's perf.py, 5 reps, save → reindex_one line, base / now):
uart_tx comment 0.05 / 0.04, uart_tx signal 5.4 / 4.2, prim_flop signal 4.4 /
4.3, prim_flop top 49.6 / 48.8, uart_reg_pkg member 12.9 / 12.1, prim_assert
1.4 / 1.5, prim_mubi member 93.5 / 91.2, prim_mubi top 90.3 / 85.1, tlul_pkg top
69.9 / 67.1, new uvm_object 4.8 / 4.1, new `define 6.9 / 6.2, clk_rst_if
top 16.6 / 26.2 ms; echoes 0.03–0.28 ms both. Unchanged within noise except
clk_rst_if, the one row that moved (the dev measured it 28.6 / 30.0, so most
likely noise; nothing in this lane runs on a save).
Findings
- QA-1 (High, performance, P2).
server/index.rs:212-224(take_in_if_unheld) and:189-202(forget_if_outside), called fromnotification.rs:109and:285. Taking an unheld buffer in ondidOpenand forgetting it ondidCloseeach run a one-file index update plus lens refresh, hierarchy bump andrepublish_all, synchronously on the message loop. On full OpenTitan that is ~190 ms per open and ~225 ms per close (table above; ×500–3 000 vs base), with nothing else open; 2 000 outside files opened and closed took 806 s vs 0.7 s (drv/p2perf.py). Asampleof the server meanwhile sits inCandidates::unit_tables/merge_words/take_index_tables,IncludeGraph::refresh_naming_all,dependents::note,WorkspaceIndex::push_records. Every keystroke, hover and completion queued behind such an open/close waits for it. Repro:python3 -I drv/lat717.py BIN <OpenTitan copy> 5. The README's timing rows measured only held files. Correctness of P2 is fine; its cost is not. - QA-2 (Low, P2 gap; on the
QA_FRESH_SAVEquestion). A buffer the index does not hold that is opened while a scan is running is not taken in, and nothing takes it in when that scan ends (take_in_if_unheldreturns atscan_owed()):drv/race717.py BIN <OpenTitan copy> 0.5— an excluded file opened 0.5 s into the startup scan is still unheld after settle, base and new alike; opened before the scan it is held. So "the index holds every open buffer" (Handshakes 4) is true only for buffers opened outside a scan, and the same final state answers differently depending on when the buffer was opened. The dev's argument is sound as far as it goes — the divergenceQA_FRESH_SAVEremoves is the fresh server losing this race, not the incremental one getting anything wrong — but it is a real, user-visible nondeterminism of the server (pre-existing in kind), andQA_FRESH_SAVEhides it. Suggest taking in open unheld buffers when a scan finishes, or documenting the limit in Handshakes 4 rather than only in the code comment. - QA-3 (Low, startup).
startup.rs:283-296(await_opening_file): a request that arrives before the firstdidOpenduring staging is held (staging), and thedidOpenbehind it is now held too (must_hold:heldnon-empty), so the "wait for the first buffer" loop never sees it, waits its full 25 ms bound, and the startup scan does not lead with the user's folder. Measured first hover 0.15–0.18 s vs 0.11–0.13 s (live717.py staging). Harmless to correctness; not mentioned in the README. - QA-4 (Low, C cost). The C bound holds (≤ one hand-back per applied
didOpen+ 1), but each hand-back forces apublish_scan: 26 opens interleaved with requests stretch the cold OpenTitan startup scan from 1.65–1.9 s to 2.8–4.2 s, and in 2 of 5 seeds a request is answered only at the scan's end (3.7–4.2 s). Five minutes → four seconds, so this is a note, not a blocker; the README's 1.70 s figure is for the 3-messagelivelock2burst. - QA-5 (Info, docs). The changelog's "every message is now handled in the order it was sent" overstates it: responses and deferred navigation requests are exempt (both explained in the Work log). Suggest "every edit".
- QA-6 (Info, pre-existing, outside this lane).
tools/gates.sh:suite:lucisv_mcpwas KILLED by the guard at 600 s and passed on the retry; the hung test wasqa_m3::qa_lucisv_check_over_the_same_tree_while_the_server_formats(crates/lucisv_mcp/tests/qa_m3.rs:687).lucisv_mcpdoes not depend onlucisv_server, and the 0.65.5 release gates log shows the same KILLED → retried. Not filed anywhere inTODO.md; reporting as CLAUDE.md asks. - QA-7 (pre-existing, outside this lane — file for the backlog). (a)
Closing an unsaved in-scope buffer whose text a rescan took into the
index leaves that text in the index after the close (
drv/closeidx.py BIN rescan:qd_bufsurvives the close, a fresh server holdsqd_disk) — identical on base; P2 covers excluded/unlisted files only. (b)rand_run.pyfull OpenTitan seed 301 ×100: 13 answers differ at step 100 (pull diagnostics, references, incoming calls intop_earlgrey/ip/ast/rtl/usb_osc.sv) — byte-identical divergence on base. (c) Rename of a port of a module defined twice in OpenTitan (top_englishbreakfast/ip/ast/rtl/adc.sv:81rst_adc_ni) is edit-or-refuse at random across fresh servers, base and new (drv/dup.py). All three involve state this lane did not touch.
Fixed myself: nothing. Not verified (no VS Code here): the four items
under Status; that VS Code itself never sends a request ahead of its first
didOpen during staging (QA-3's trigger).
2026-11-19 — QA agent (Opus 5.5), round 2 (f1d4492 on dbb2349)
Verdict: PASS WITH FINDINGS (one Info-level note on the narrowed rule,
pre-existing in kind; nothing new). Binaries: qa717/bin2/new (this tree),
qa717/bin2/base (git archive dbb2349), qa717/bin2/r1 (round 1's binary,
for comparison). Caches untouched as in round 1.
Baseline. Full tools/gates.sh (logs qa717/gates2/): PASS every step
including cross; lucisv_server 2 030/0 (dbb2349: 1 901 + 106 + 4 = 2 011 →
1 920 + 106 + 4, +19 and +1 ignored), vlog_semantic 435, lucisv_mcp 384 (no
guard kill this time), corpus 814/6, node 37. Ignored release runs 3/3 pass.
P2's revert is a clean one: no state/ file and no sync.rs in
git diff dbb2349. caret.rs, dispatch.rs, referencesView.js and
caret_boundary.rs are byte-identical to round 1.
What the narrowed rule promises, stated as checked (must_hold,
server/mod.rs): (i) after settle every open buffer's text, and which buffers
are open, equal the client's; (ii) non-cancel notifications are applied in the
order sent, across documents — a notification is applied only when no older one
is in held or in an enclosing burst's unapplied tail; (iii) every request is
answered exactly once; (iv) a request is answered against the state after every
notification sent before it, and possibly after some sent after it — so its
answer reflects some client state between sending and answering, never one the
client did not have (each didChange is applied whole, in one handler call).
Ordering driver (drv/ord3.py: round 1's driver with check (iv) — every
documentSymbol answer must equal the expected symbols of the client's state at
send or of some later state the client had sent before the answer arrived, each
state recorded per message): corpus seeds 510–519 ×60 (workspace), 520–523 ×60
(folder); full OpenTitan 530–533 ×40 (workspace), 540–541 ×40 (folder);
incremental single/multi-change and full-sync changes, scans in flight as in
round 1. 20 runs, 9 118 bursts (≈ 87 % mid-scan), 28 663 messages, 4 693
state checks: 0 failures, 0 duplicate or missing responses, every fresh oracle
equal; 13 answers reflected a later state than at send, each one a state the
client had. The same check fails at once on dbb2349 (seed 501: answers
matching no client state, a buffer an edit behind). An earlier run of my
coarser ord2.py (states recorded per burst, not per message) flagged one
answer (seed 514) that matched no burst-final state; with per-message states the
same seed ran clean three times — a driver limitation, recorded.
Harm hunt (drv/harm2.py, GAP=0.2, full OpenTitan, index not persisted so
the rescan really interleaves; a request sent against v1 is held, then a
didChange to v2 that inserts a line above it is applied mid-scan):
| request held, then v2 applied | dbb2349 |
round 1 | now |
|---|---|---|---|
rename of beta at its v1 position |
answered on v2: renames alpha (the name now at that position); edit consistent with v2 |
answered on v1; applied to the client's v2 it corrupts (logic qqa;, alpqq) |
as dbb2349 |
| hover / definition / references | about alpha, v2 ranges |
about beta, v1 ranges |
as dbb2349 |
| formatting | edits for v2, applied to v2 = v2's own formatting | same | same |
hover held, then didClose applied |
null |
answered from the open buffer | null |
documentSymbol(A) held, then didClose A + didOpen A2 |
null |
from A | null |
documentSymbol(B) sent before didOpen B |
B's buffer | null |
B's buffer |
[documentSymbol, change v2] in one burst, then v3 |
answered on v3 (B) | v1 | v1 |
So the narrowing restores dbb2349's late-request behaviour exactly — no harm
that base did not already have — and keeps B fixed (last row). Rename edits are
unversioned (changes map; extract.rs:185 sends version: None), so a client
cannot reject a stale one by version; VS Code drops a rename or format result
when the buffer changed while it waited (its editor-state cancellation), so the
practical exposure is a client without that guard. QA-8 (Info, pre-existing):
a held position-taking request can resolve a different symbol when a newer
edit moved the text under its position — identical on dbb2349. Round 1's
strict rule had the opposite trade (right symbol, ranges for text the client no
longer had).
Liveness (live717.py, dbb2349 / now): cancel of a held request mid-rescan
answered 0.58–0.62 / 0.55–0.60 s, honoured 5/5 / 5/5; shutdown behind a held
hover + change answered 0.70 / 0.70 s, hover first, exit < 1 s (rc 1 in 2 of 3
on both, as round 1); exit alone 0.8–1.6 s on both; server→client requests
held by the client and answered mid-burst: no deadlock, final text right on
both; 20 000-change flood (now): settle 27.7 s, RSS peak 680 MB, text right;
typing through 5 rescans: scans 1.67–1.90 / 1.69–1.93 s, text wrong on
dbb2349, right now; staging (QA-3): first hover 0.13–0.15 / 0.13–0.14 s —
fixed (round 1 was 0.15–0.18 s).
C (c717.py, 26 opens in 13–14 [request, didOpen×1–3] bursts, cold full
OpenTitan): scan ends 2.59–3.32 s, answers 0.02–3.32 s (5 seeds), 0 duplicates;
round 1 2.8–4.2 s; dbb2349-class base 407 s; plain cold startup 1.51 s
(dbb2349 1.51 s, now 1.53 s; warm 0.71 / 0.70 s). QA-4 as documented.
P2 revert confirmed. lat717.py: outside/excluded didOpen 0.41–0.72 ms,
didClose 0.07–0.12 ms (dbb2349 0.37–0.79 / 0.06–0.13 ms); held files as base.
p2perf.py: 2 000 outside open+close 0.6 s (dbb2349 0.7 s), RSS flat.
r2attack.py: the same four divergent cases on both binaries
(directory-create, held-directory-deleted, excluded-open-close closed and
saved-then-closed); outside.py 14/14 equal on both, push and pull.
A1 (code byte-identical): sample sweep 60 corpus files × 15 tokens, 7 830
token×request pairs — end = start = middle everywhere, start and end+1 = base
everywhere; a1edge.py all end = start; a1rename.py 9/9 identical.
Oracle (no repair workaround): small.py push and pull — only
NEGCTL-silent diverges (both scopes); corpus push seed 7 ×200 — 0 divergent;
full OpenTitan 21 ×50 — 0; OpenTitan sample 42 ×500 (QA_FRESH_SAVE) — 0.
New: corpus seed 601 ×500 — 10 checks, 0 divergent; OpenTitan sample 602 ×500
(QA_FRESH_SAVE, for QA-2's race) — 10 checks, 0 divergent.
Findings this round: QA-8 above (Info, pre-existing). Round 1's QA-1 and
QA-3 are fixed, QA-4 documented, QA-5 reworded; QA-2, QA-6, QA-7 stand as
written (pre-existing, outside this lane). Fixed myself: nothing. Not
verified: a real VS Code (the Status items, and whether VS Code's editor-state
cancellation really sends $/cancelRequest for a held rename).
Review
Lead, 2026-11-19. Accepted for 0.65.8, after two QA rounds.
- The owner asked whether it was VS Code or the server. It was the server,
and it was not a race: an end-exclusive span met a caret VS Code considers
to be on the word. The investigation's deterministic reproduction
(
refpos.py, column 27) settled that before any code was written, and ruled out the things I would have guessed first — cancellation, deferred answers, caching. - B and C were found by other lanes' QA and are worse than the reported bug: one corrupts the server's copy of a buffer, the other turns a 2 s startup into minutes. Both come from treating queued messages as applied. I kept them in this lane because they live in the same loop.
- I asked for P2 "only if small"; the dev's attempt cost 190 ms per open of an outside file and QA caught it (806 s for 2 000 files). Reverted. The right fix is in the index layer and is filed.
- The ordering rule was narrowed in the fix round from "no message overtakes an older message" to "no notification overtakes an older notification". That changes the invariant, so I sent it back to QA instead of accepting the dev's own run. QA's harm table is what decides it: under the narrow rule a held request behaves exactly as on 0.65.7; under the broad rule a held rename was answered on the old text and would have corrupted the client's newer one. Narrow is both faster and safer.
- Not verified: a real VS Code, in particular whether it drops a rename or format result when the buffer changed while the request was held (QA-8 rests on that for its "Info" grade).