textDocument/prepareTypeHierarchy + typeHierarchy/supertypes/subtypes for SystemVerilog classes. Supertypes is one computed offset into the existing resolution machinery — the overlay promotion made cross-file bare class names answerable, and the offset is the LAST byte of the extends name span so pkg::base lands in the tail's reference, never the package's. Subtypes is a workspace census on the callers_of_each pattern (one sources() pass, prefilter, deterministic sort), matching the base name as written — 0 of the corpus's 270 extends clauses are qualified, and the asymmetry with supertypes is documented and pinned from both directions, including the same-name/different-file consequence. Ambiguous bases answer every declaration, like definition. Modules stay on callHierarchy by scope ruling. lsp-types 0.97 has no server-side typeHierarchyProvider field, so initialize_value() inserts the one key into the serialized result — QA's strip-and-compare test proves every other key survives with identical values. QA also traced the parser to show the degenerate extends spans the code guards against cannot be constructed, corrected two README figures the lead applied (the 309 extends count did not reproduce; 270 does), and pinned the generate-block walk gap as a scoped choice. Interface classes stay blocked on the parser, pinned. 45 tests added (dev 33 + QA 12), including the real ibex UVM chain and a 10-deep expansion. The inheritance-edge index want is filed beside the instantiation-edge Handshake as one future round. docs/features/type-hierarchy/README.md Co-Authored-By: Claude Fable 5 <[email protected]>
1018 lines
74 KiB
Markdown
1018 lines
74 KiB
Markdown
# lucisv-server
|
||
|
||
## Goal
|
||
|
||
`crates/lucisv_server` is the analog of ruff's `ruff_server`: one binary,
|
||
`lucisv-server`, that speaks LSP over stdio and serves both VS Code and
|
||
Vim/Neovim with no editor-specific logic below the protocol layer (TODO.md
|
||
§6). Every engine it needs already exists — the tolerant parser, the span and
|
||
line-index utilities, the `` `define`` table, `vlog_semantic` and the
|
||
workspace index — so this crate owns **only the protocol layer**: message
|
||
loop, document state, position arithmetic, and one small handler per
|
||
capability. It deliberately contains no analysis of its own; anything that
|
||
looks like language knowledge in here is a bug or a `Handshake` request.
|
||
|
||
## Capabilities as shipped
|
||
|
||
| LSP request | Engine it consumes | Notes |
|
||
|---|---|---|
|
||
| `textDocument/formatting` | `vlog_formatter::format_source` | One whole-document `TextEdit`, and only when the text actually changed |
|
||
| `textDocument/rangeFormatting` | `vlog_formatter::format_range` | Same edit shape; the LSP `Range`'s *lines* become the engine's `--lines` (round 18) |
|
||
| `textDocument/onTypeFormatting` | `vlog_formatter::format_range` (for `;`); the token stream (for `\n`) | Two triggers, and only two. `;` range-formats the statement it ended, through the *same* engine `rangeFormatting` runs, over the `;`'s own line. `\n` re-indents the line it opened from block nesting — new logic outside the verified engine, so its edit can structurally only replace that one line's leading whitespace with spaces, and a corpus-wide agreement test forbids it from ever disagreeing with the printer. **Never speaks**: a refusal is `[]` with no `showMessage`, and a broken `lucisv.toml` is not reported here either (the dedup is re-armed by the `didChange` every keystroke produces). Advertised unconditionally — the client's own `editor.formatOnType` is the opt-in. See `docs/features/on-type-formatting/README.md` |
|
||
| `textDocument/willSaveWaitUntil` | `vlog_formatter::format_source` | Format-on-save, protocol-native, for the editors that have no format-on-save of their own. **Off unless `lucisv.formatOnSave` is pushed**, and the decline is `null` — a capable client asks before every save, and a client with its own format-on-save would otherwise format twice. When on it is `textDocument/formatting` with a different trigger: the same engine, the same all-or-nothing edit, and the settings ladder minus its `tabSize` rung (the request carries no `FormattingOptions`). See `docs/features/will-save-wait-until/README.md` |
|
||
| `textDocument/publishDiagnostics` | `vlog_parser::parse_source_tolerant` | Pushed on `didOpen`/`didChange`/`didSave`, once per notification — **only for a client that does not pull**. See `docs/features/pull-diagnostics/README.md` |
|
||
| `textDocument/didChange` | `sync::apply_changes` | Incremental sync: the ranges are applied in order to the buffer the server holds, then one `set_document` + one `publish`. A rangeless change still replaces the whole buffer, so a full-sync client is unaffected. See `docs/features/incremental-sync/README.md` |
|
||
| `textDocument/diagnostic`, `workspace/diagnostic` | the same parse+lint pass | The 3.17 pull model, served to a client that advertised `textDocument.diagnostic` — which is then pushed nothing at all. `resultId` is one generation counter, bumped by a buffer change and by an index rebuild; the workspace report covers the **open buffers**. Same feature README |
|
||
| `textDocument/selectionRange` | `Document.tokens`, AST spans, `pairs::analyze` | Expand-selection: one strictly nesting chain per requested position, token → statement → block → item → file. No expression step. See `docs/features/selection-range/README.md` |
|
||
| `textDocument/semanticTokens/full` | `vlog_parser::tokenize` + `Semantics` | Delta-encoded, split at line boundaries. Stamped with a `resultId` since 2026-08-26, so a delta can name it |
|
||
| `textDocument/semanticTokens/range` | the same classification pass | The visible lines only, for the first paint of a large file. A **self-contained** answer: the tokens overlapping the range, kept whole, re-encoded from the start of the document. No `resultId` — a partial view is not what a delta is computed against. See `docs/features/semantic-tokens-delta/README.md` |
|
||
| `textDocument/semanticTokens/full/delta` | the same classification pass | What changed since the answer the client names: one edit replacing everything between the common prefix and the common suffix (the suffix capped so the two cannot overlap — identical lines of Verilog encode identically, which is exactly the trap). An id the server does not hold, including one from before a `didClose`, is answered in full. Same feature README |
|
||
| `textDocument/hover` | `DefineTable`, `Semantics`, `WorkspaceIndex`, `includes::IncludeGraph`, `expand` | Macro body, or declaration kind + snippet. A macro this file does not define is answered from the workspace: the definition it **reaches through its `` `include``s** when exactly one is reachable, and every candidate otherwise. A macro card also shows what the hovered use **expands to in one step** — the body with this call's arguments substituted — when that says more than the body already does; a nested `` `INNER`` is left as written, an argument count that does not match expands nothing, and several candidates expand nothing. See `docs/features/macro-expansion/README.md` |
|
||
| `textDocument/definition` | `includes::IncludeGraph`, then `Semantics`, then `ExternalResolutions` | A cursor on an `` `include`` line jumps to the resolved file's first byte; otherwise the in-file symbol table, then the workspace overlay, whose `Ambiguous` answer returns every location. See `docs/features/include-nav/README.md` |
|
||
| `textDocument/typeDefinition` | `type_def`, then `nav::definition` | The same jump one token to the left: from a name to where its **type** is declared — a `typedef`, an `interface`, a `class`, or the module an instance name stands for. The tree says which declaration a position is in and where its type name is written; the answer is then `definition` of *that* name, so cross-file resolution, ambiguity and position conversion are all the ones F12 already uses. One hop on an alias chain, an empty list for a built-in. See `docs/features/type-definition/README.md` |
|
||
| `textDocument/linkedEditingRange` | `linked`, over `Document.tree` | SV's closing labels, edited as one name: the cursor on either half of `module m ... endmodule : m` (and of `endfunction`/`endtask`/`endclass`/`endpackage`/`endinterface`/`endclocking`, a named `begin`/`fork`, a generate block, and the prefix-labelled `b : begin ... end : b`) answers **both** ranges plus the SV `wordPattern`. The pair comes off one AST node — `name_span` with `end_label_span` — never off a text match, so four identical names at two nesting levels still pair syntactically. Two `null`s on purpose: a closer with **no** label (nothing to co-edit, and this never offers to create one) and a **mismatched** one (the spec requires identical text; linking would silently rewrite broken code). Escaped identifiers are excluded. See `docs/features/linked-editing/README.md` |
|
||
| `textDocument/documentLink` | `includes::IncludeGraph` | One link per **resolvable** `` `include``, covering the quoted path, target already resolved (`resolveProvider: false`). Search order: the including file's own directory, then each `+incdir+` of the configured filelist in order; the `<angled>` form skips the first rung. An include nothing answers to gets no link and no error. Same feature README |
|
||
| `textDocument/references` | `vlog_refactor::find_references`, else `Semantics::references_of` | Cross-file when the symbol is one the workspace index holds (a module, a package, an exported member, a port); in-file for everything else, which is what keeps a local `wire` off the workspace walk. See `docs/features/references-nav/README.md` |
|
||
| `textDocument/documentHighlight` | `pairs::analyze`, else `Semantics::references_of` | A scope keyword highlights its own closer; anything else highlights the symbol's occurrences in this file. Kind is always `Text`; neither answer means `null`, so the editor keeps its word highlighting. Same feature README |
|
||
| `textDocument/foldingRange` | `pairs::analyze` + comment trivia | One `Region` per matched scope pair, folded through the line *before* the closer so `end`/`endmodule` stays visible, plus one `Comment` per multi-line block comment. An unmatched opener folds nothing. Same feature README |
|
||
| `textDocument/documentSymbol` | `Semantics::document_symbols` | Hierarchical |
|
||
| `textDocument/prepareRename` | `vlog_refactor::prepare_rename` | Declines with the engine's own sentence (`RequestFailed`), so the box never opens on a rename that would fail |
|
||
| `textDocument/rename` | `vlog_refactor::rename` | Cross-file `WorkspaceEdit` (`changes`); warnings go out on `window/logMessage`; refusals are `RequestFailed`. See `docs/features/refactor-rename/README.md` |
|
||
| `textDocument/completion` | `vlog_refactor::instantiation_plan` | Module hinting: one item per indexed module, inserting the whole instantiation skeleton as a snippet (plain text for a client that did not advertise `snippetSupport`). Capped at 64 items, `isIncomplete` when truncated; declines every position that is not module-item. See `docs/features/refactor-instantiate/README.md` |
|
||
| `textDocument/signatureHelp` | `vlog_refactor::instantiation_plan` | The instantiated module's ports (or, inside `#( ... )`, its parameters) with the active one highlighted — by name for a named list, by position for an ordered one. Triggers: `(` and `,`. Same feature README |
|
||
| `textDocument/inlayHint` | `vlog_refactor::instantiation_plan` | Ghost port names on an **ordered** connection list (`u1 (clk, rst_n)`) and parameter names on ordered `#( ... )` overrides, read from the instantiated module's declaration. Range-scoped; named lists, `.*`, omitted positions, connections past the last port, gate primitives and modules the index cannot resolve get nothing at all — a hint is decoration and never guesses. No `resolveProvider`. See `docs/features/inlay-hints/README.md` |
|
||
| `textDocument/prepareCallHierarchy` | `instantiations::{sites,declarations}`, `WorkspaceIndex::units` | The module under the cursor as a hierarchy node (`SymbolKind::Module`), from its own declaration or from any instantiation of it. Every other position answers `null`; an ambiguous name returns every declaration, as `definition` does. See `docs/features/hierarchy/README.md` |
|
||
| `callHierarchy/incomingCalls` | `instantiations::sites` over `Workspace::sources` | "Who instantiates X": one call per **instantiating module**, `fromRanges` naming every site inside it. Walks the in-scope files — the index holds no instantiation edges — skipping any file whose text does not contain the name (56 ms over the 860-file corpus). Since 2026-08-26 this is `hierarchy::callers_of_each` with a one-name batch; the batched form is what `textDocument/codeLens` counts from, so there is exactly one census. Same feature README |
|
||
| `callHierarchy/outgoingCalls` | `instantiations::sites`, `WorkspaceIndex::units` | "What X instantiates": one call per **distinct instantiated module**, `fromRanges` naming its sites. A target the index does not hold, or holds twice, is skipped silently. Same feature README |
|
||
| `textDocument/prepareTypeHierarchy` | the class walk over `Document.tree`, then `ExternalResolutions::definition_of` | The **class** under the cursor as a type hierarchy node (`SymbolKind::Class`), from its own declaration or from any use of its name (an `extends` base, a property's type, a method local's type). Every other position answers `null`; a name two files declare returns both, as `definition` does. Advertised by hand — `lsp-types` 0.97's `ServerCapabilities` has no `typeHierarchyProvider` field. See `docs/features/type-hierarchy/README.md` |
|
||
| `typeHierarchy/supertypes` | `ClassDecl::extends` + `ExternalResolutions::definition_of` | "What X extends": its base class, resolved by the same two layers F12 uses — in-file first, then the workspace overlay — asked at the **last byte** of the extends name, which is the tail of `pkg::base` and the whole of a bare `base`. A parameterized base resolves by its bare name; a base the workspace does not index (every UVM chain top) yields **no** item rather than a guess. Same feature README |
|
||
| `typeHierarchy/subtypes` | the class walk over `Workspace::sources` | "Who extends X": every class in scope whose `extends` names it, sorted by file then position. Walks the in-scope files — the index holds no inheritance edges — skipping any file whose text does not contain the name (55 ms over the 860-file corpus, 53 ms of it file I/O). A **qualified** base is not matched by a bare name, the `callHierarchy` precedent; 0 of the corpus's 270 `extends` clauses are qualified. Same feature README |
|
||
| `textDocument/codeLens` | `instantiations::declarations` + `hierarchy::callers_of_each` | **"N instantiations"** above every module and interface declaration in the buffer, on the declaration's own name span. N is the number of instantiation *sites* across the workspace — the same population `callHierarchy/incomingCalls` reports, from the same walk asked about every module in the file at once, so the two can never disagree. `resolveProvider: false`: every lens is complete. Clicking runs `lucisv.showInstantiations`; a module with **no** instantiations gets a display-only lens (empty `command`) instead of a click that leads nowhere. Unopened buffer → `null`; a declaration with no name span gets no lens. See `docs/features/code-lens/README.md` |
|
||
| `workspace/executeCommand` → `lucisv.showInstantiations` | `hierarchy::callers_of_each` | The code lens's own jump: `["module-name"]` in, every site as a `Location` out — one per site, file-then-position order. For a client that advertised `window.showDocument`, the server also pushes a `window/showDocument` for the **first** site, which is what makes the click navigate; LSP has no server-initiated peek-references, and this repo's extension declares no client-side command. A name with no sites answers `[]`; a missing or empty name is `RequestFailed`. Same feature README |
|
||
| `workspace/codeLens/refresh` | — | Server-**initiated**, once per workspace rescan, straight after the indexing bar comes down: a rescan can change any count on screen. Only for a client that advertised `workspace.codeLens.refreshSupport`; never at startup, where no buffer holds lenses. Same feature README |
|
||
| `workspace/symbol` | `WorkspaceIndex::workspace_symbols` | Capped at 256 hits |
|
||
| `workspace/didChangeWatchedFiles` | `Workspace::rebuild_index` | Registered dynamically after the handshake, for a client that advertised it. One rebuild per *notification*, however many files it names. See `docs/features/file-watching/README.md` |
|
||
| `window/workDoneProgress/create` + `$/progress` | — | Server-**initiated**: one indeterminate bar per workspace rescan, titled "Indexing Verilog workspace", ending with the indexed file count. Only for a client that advertised `window.workDoneProgress`. See `docs/features/work-done-progress/README.md` |
|
||
| `$/cancelRequest` | — | Best-effort, and honoured exactly when the cancel reaches the loop in the same burst as the request it names: that request is answered `RequestCancelled` (-32800) instead of computed. A cancel for anything else is dropped where it is read, `shutdown` is never cancellable, and nothing already running is interrupted. See `docs/features/cancel-request/README.md` |
|
||
|
||
Deferred, deliberately, and named in Status/TODO below: ~~range formatting
|
||
(waits on TODO.md §2 `--lines`)~~ **delivered by range-formatting (round 18):
|
||
`documentRangeFormattingProvider` is advertised and the handler converts the
|
||
UTF-16 `Range` to 1-based lines — see
|
||
`docs/features/range-formatting/README.md`**, ~~lint diagnostics (waits on `vlog_linter`)~~
|
||
**delivered by server-lint (round 13): lint findings publish as warnings in the
|
||
same notification as the parse errors, and `textDocument/codeAction` offers
|
||
their Safe fixes — see `docs/features/server-lint/README.md`**,
|
||
~~rename~~ **delivered by refactor-rename (M2 of the refactoring plan):
|
||
`textDocument/prepareRename` + `textDocument/rename`, edits computed in the new
|
||
`vlog_refactor` crate — see `docs/features/refactor-rename/README.md`**,
|
||
~~completion / signature help~~ **delivered by refactor-instantiate (M4 of the
|
||
refactoring plan): `completionProvider` expands a module name at item position
|
||
into a full instantiation skeleton and `signatureHelpProvider` names the ports
|
||
inside a connection list — see
|
||
`docs/features/refactor-instantiate/README.md`**, ~~and cross-file
|
||
references~~ **delivered by references-nav (M7): `textDocument/references`
|
||
now routes through the same collection a rename runs, so what lucisv lists and
|
||
what lucisv would edit are one answer — see
|
||
`docs/features/references-nav/README.md`, which also brought
|
||
`documentHighlight` for symbols and `foldingRange`.**
|
||
(`lucisv.toml` discovery and `.gitignore`-aware indexing, deferred when this
|
||
was written, were delivered by lucisv-core-lift the same day — lead note.)
|
||
|
||
## Dependencies, and the justification CLAUDE.md asks for
|
||
|
||
Four direct dependencies, all exact-pinned in the root `[workspace.dependencies]`:
|
||
|
||
| crate | version | why it is not std, and not hand-rolled |
|
||
|---|---|---|
|
||
| `lsp-server` | `=0.10.0` | rust-analyzer's own transport: stdio framing, the `Content-Length` header dance, the initialize/shutdown/exit state machine. Synchronous — a `crossbeam-channel` pair and two I/O threads, **no `tokio`**. This is the whole reason it was picked over `tower-lsp`, which drags an async runtime into a program whose work is CPU-bound and single-file. |
|
||
| `lsp-types` | `=0.97.0` | The protocol's data model — several hundred structs whose field names and `serde` attributes are the wire format. Hand-writing them is hand-rolling JSON by another name, which the brief forbids and which would rot at every spec revision. |
|
||
| `serde` | `=1.0.229` | Only for the `DeserializeOwned` bound on the one generic request-decoding helper. Arrives transitively via `lsp-types` regardless. |
|
||
| `serde_json` | `=1.0.140` | `Value` is `lsp-server`'s params/result type; `from_value`/`to_value` are the only JSON this crate touches. Arrives transitively regardless. |
|
||
|
||
**Transitive audit**, measured on this workspace's own lock file (diffing
|
||
`Cargo.lock` against `HEAD`, so the number is what the repo actually gained,
|
||
not what a standalone crate would):
|
||
|
||
**18 new packages.** `bitflags`, `crossbeam-channel`, `fluent-uri`, `itoa`,
|
||
`log`, `lsp-server`, `lsp-types`, `memchr`, `proc-macro2`, `quote`, `ryu`,
|
||
`serde`, `serde_core`, `serde_derive`, `serde_json`, `serde_repr`, `syn`,
|
||
`unicode-ident`. **Twelve of the eighteen are the `serde`/JSON stack** and its
|
||
proc-macro toolchain (`serde*`, `proc-macro2`, `quote`, `syn`,
|
||
`unicode-ident`, `itoa`, `ryu`, `memchr`) — a cost any JSON handling at all
|
||
would have paid. The other six are the protocol proper: `lsp-server`,
|
||
`lsp-types`, `crossbeam-channel`, `fluent-uri`, `bitflags`, `log`.
|
||
`crossbeam-utils` was already in the lock via
|
||
`rayon` and is shared, not added. Exactly one `syn` is resolved (3.0.3) —
|
||
worth checking, because `lsp-types`' `serde_repr` and `serde_derive` can
|
||
easily land on different major versions and double the proc-macro build.
|
||
|
||
**Build scripts: five** — `proc-macro2`, `quote`, `serde`, `serde_core`,
|
||
`serde_json`. All five were read. Every one is a toolchain probe: four shell
|
||
out to `rustc --version` and all five emit only `cargo:rustc-cfg` /
|
||
`cargo:rustc-check-cfg` lines. None compiles native code, links a system
|
||
library, or touches the network. No `cc`, no `bindgen`, no vendored C.
|
||
|
||
**Versions considered and rejected.** `lsp-types` `0.94.x` models a URI as
|
||
`url::Url`, which would give us `Url::from_file_path` for free but costs the
|
||
`url` → `idna` → `unicode-bidi`/`unicode-normalization`/`tinyvec` subtree —
|
||
five extra packages to avoid writing the ~40 lines in `src/uri.rs`. `0.97.0`
|
||
uses `fluent-uri` (one package, one shared `bitflags`) and gives us a `Uri`
|
||
with `FromStr` and `as_str()`, so path↔URI conversion is ours. That trade —
|
||
five packages against forty tested lines — went the way CLAUDE.md's "standard
|
||
library first" points. The cost is recorded honestly: `fluent-uri` 0.1.4 is a
|
||
zero-copy parser with ~144 `unsafe` occurrences. CLAUDE.md's no-`unsafe` rule
|
||
governs our code, and this crate has none.
|
||
|
||
## The byte ↔ UTF-16 conversion (`src/convert.rs`)
|
||
|
||
**This is the classic LSP bug, so it is the one piece of this crate with a
|
||
design section.** Everything below the protocol speaks **UTF-8 byte offsets**
|
||
(`TextRange`, `LineIndex`, every span the engines produce). LSP `Position`
|
||
speaks **UTF-16 code units** within a line. The two agree only on ASCII, which
|
||
is exactly why the bug survives to production: it is invisible until a comment
|
||
contains `é` or an emoji.
|
||
|
||
`Positions<'a> { text: &'a str, index: &'a LineIndex }` is built per request
|
||
from the document's own text and line table — it borrows, so there is no
|
||
cached copy to invalidate.
|
||
|
||
**Byte offset → `Position`:**
|
||
|
||
1. `LineIndex::line_col(offset)` gives the 1-based line; LSP wants 0-based.
|
||
2. The character is `text[line_start..offset]` measured in UTF-16 code units
|
||
(`chars().map(char::len_utf16).sum()`), **not** in bytes and **not** in
|
||
`char`s.
|
||
3. `offset` is floored to a UTF-8 character boundary first. An offset landing
|
||
inside a multi-byte character cannot slice; clamping down is the only
|
||
answer that neither panics nor invents a position.
|
||
4. A trailing `\r` in that slice is dropped. `LineIndex` deliberately treats
|
||
`\r` as an ordinary byte of its line (`docs/features/spans/README.md`), but
|
||
LSP line content excludes the whole `\r\n` terminator, so a span ending at
|
||
the `\n` of a CRLF line would otherwise report one character too many.
|
||
|
||
**`Position` → byte offset:** walk the line's characters from its start,
|
||
accumulating UTF-16 units, and stop when the accumulated count reaches the
|
||
requested character. Consequences, both deliberate:
|
||
|
||
- A character that lands **inside a surrogate pair** (an astral character
|
||
counts 2; the client asks for the midpoint) resolves to the offset *after*
|
||
that character. There is no byte there to point at; rounding forward keeps
|
||
the result a valid char boundary.
|
||
- A character past the end of its line clamps to the line's end (`\r`
|
||
excluded), never wrapping onto the next line — the same clamping rule
|
||
`LineIndex::offset` already documents for byte columns.
|
||
- A line past the end of the file clamps to the file's length.
|
||
|
||
**The one place the round-trip is not the identity, found by the test that
|
||
tried to assert it was.** Both bytes of a `\r\n` are "the end of this line's
|
||
content", and LSP has a single position for that, so `position(\r)` and
|
||
`position(\n)` are equal and the `\n` cannot round-trip back to itself. The
|
||
alternative — letting the `\r` count as a character — would report a position
|
||
one past the line content the client believes it has, which every client then
|
||
clamps anyway. The collapse is the correct behavior, so it is pinned by a test
|
||
of its own (`a_crlf_terminator_is_the_one_place_the_round_trip_collapses`)
|
||
rather than papered over, and the exhaustive round-trip test skips exactly
|
||
that one byte class.
|
||
|
||
**An empty span is not a drawable range.** A diagnostic whose span is empty —
|
||
which is every lex error, since the lexer reports the point it gave up —
|
||
would underline nothing. `diagnostic_range` widens an empty span to the whole
|
||
line it sits on, and, when *that* line is empty, to the line before it. The
|
||
second rule is not hypothetical: an unterminated block comment is reported at
|
||
end-of-file, and a file ending in a newline has an empty last line, so without
|
||
the fallback the single most common lex error draws nothing at all. Found by
|
||
the handler test, not predicted.
|
||
|
||
The server advertises `position_encoding: utf-16`, the protocol default, so
|
||
the conversion is always on. Negotiating UTF-8 with capable clients would make
|
||
this module a no-op for them; it is not worth a second code path until
|
||
somebody measures the cost.
|
||
|
||
Tested in `convert.rs`'s own unit tests (14 of them): pure ASCII, 2-byte (`é`)
|
||
and 3-byte (`✓`) characters, an astral emoji (`🎉`, one `char`, two UTF-16
|
||
units, four UTF-8 bytes), a position landing *inside* a surrogate pair, an
|
||
offset landing inside a multi-byte character, CRLF line ends, out-of-range
|
||
positions in both directions, the empty document, and a full round-trip over
|
||
every character boundary of a document mixing all of those.
|
||
|
||
## State and staleness
|
||
|
||
Single-threaded request loop — `lsp-server`'s model. Two I/O threads (its
|
||
own) read and write stdio; this crate's loop handles one message to completion,
|
||
and sends the response before looking at the next. No shared mutable state, no
|
||
locks, and nothing already running is ever interrupted. Verilog files are small
|
||
and every handler is milliseconds; the complexity of a worker pool buys nothing
|
||
yet.
|
||
|
||
**Since 2026-08-26 the loop reads in bursts** rather than strictly one message
|
||
at a time: it blocks for the next message, takes everything already queued
|
||
behind it without blocking, and then handles that whole burst **in arrival
|
||
order** — a `didChange` ahead of a completion is applied before the completion
|
||
is answered, exactly as before. The one thing the burst adds is
|
||
`$/cancelRequest`: a request the same burst also carries a cancel for is
|
||
answered `RequestCancelled` (-32800) instead of being computed, which is the
|
||
only moment a one-thread server can honour a cancel at all. A cancel that
|
||
names no request in its burst is dropped where it is read (the request was
|
||
answered in an earlier burst, or never existed), so cancellation costs no
|
||
state; `shutdown` is handled before any cancel is consulted and so can never
|
||
be cancelled. Because `lsp-server`'s transport uses zero-capacity rendezvous
|
||
channels — a client's backlog sits in the OS pipe, not on
|
||
`connection.receiver` — the loop first forwards incoming messages onto an
|
||
unbounded queue of its own on one small thread, which stops at `shutdown` so
|
||
`handle_shutdown` keeps its own read of the `exit` that follows. Rules,
|
||
reasoning and the measurements: `docs/features/cancel-request/README.md`.
|
||
|
||
**Two layers, invalidated by different events** — exactly the split
|
||
`docs/features/workspace-index/README.md` designed for:
|
||
|
||
| layer | rebuilt when | cost |
|
||
|---|---|---|
|
||
| a document's `Semantics` + tokens + diagnostics | every `didOpen`/`didChange` — **once per notification**, however many ranges it carried | one file, full recompute |
|
||
| the `WorkspaceIndex` | `initialize`, every `didSave`, every `workspace/didChangeWatchedFiles`, and a changed `lucisv.exclude`/`lucisv.filelist` | full re-scan of the roots |
|
||
| the `` `include`` graph | with the `WorkspaceIndex`, from the same file list | a line scan per file (~6ms over the 860-file corpus). An open buffer's *own* includes are re-resolved on every request instead, so a line just typed is clickable before the next save |
|
||
|
||
**Per-file recompute on every keystroke** is the strategy TODO.md §6 states
|
||
("per-file recompute is fine at Verilog file sizes"); salsa is explicitly
|
||
deferred there. Incremental *sync* did not change that: the wire now carries
|
||
ranges, but a `didChange` still throws the whole `Document` away and builds a
|
||
new one — one reparse per notification, which is also the one generation bump
|
||
the pull-diagnostics `resultId` depends on.
|
||
|
||
**Open buffers override disk** in every index rebuild: the roots are walked,
|
||
each file read, and then every open document with a path replaces the disk
|
||
copy (adding itself if it exists only in the editor). So the index never
|
||
disagrees with a buffer the user is looking at.
|
||
|
||
**The staleness window, stated plainly.** The index is rebuilt on save, not on
|
||
change. Between editing file A and saving it, file B's cross-file answers
|
||
(`definition` into A, `workspace/symbol` hits in A, hover falling back to A's
|
||
defines) reflect A **as it was at its last save** — except for A's own buffer,
|
||
which the override above keeps current. Rebuilding on every keystroke would
|
||
re-parse the whole workspace per character; rebuilding on save is the cheapest
|
||
point where the answer is expected to change anyway. Measured cost of a
|
||
rebuild: 0.68 s for the 860-file corpus (the workspace index's own baseline),
|
||
plus the file reads.
|
||
|
||
**Every rescan is visible since 2026-08-26**, for a client that advertised
|
||
`window.workDoneProgress`: the startup build and all three `reindex()` triggers
|
||
are wrapped in one `window/workDoneProgress/create` plus a `$/progress`
|
||
begin/end pair on a fresh `lucisv-index-N` token, so a multi-second index on a
|
||
big filelist reads as work rather than as a hang. The `begin` does not wait for
|
||
the create's answer (the rescan blocks the loop immediately after), the answer
|
||
is ignored on the same path the watcher registrations' is, there is no
|
||
percentage and no intermediate report — the rescan is one opaque call — and the
|
||
`end` names the indexed file count. A client that did not advertise the
|
||
capability is sent nothing at all, which the spec requires. Rules and the
|
||
startup-legality argument: `docs/features/work-done-progress/README.md`.
|
||
|
||
**Changes made outside the editor close on the next notification, not on the
|
||
next save** (M9, `docs/features/file-watching/README.md`). The server registers
|
||
`workspace/didChangeWatchedFiles` for `**/*.{v,vh,sv,svh}` and for the
|
||
configured filelist's own path, so a `git pull`, a checkout, a generated file
|
||
or an externally edited `.f` rebuilds the index straight away — one rebuild per
|
||
notification, however many files that notification names. **The window that
|
||
remains, honestly:** a client that did not advertise
|
||
`workspace.didChangeWatchedFiles.dynamicRegistration` cannot be registered
|
||
(the protocol has no static form of the capability) and keeps the save-only
|
||
model above; nested `-f` filelists are not watched, only the root one;
|
||
`lucisv.toml` is not watched either (it is re-read on every rebuild, so the next
|
||
rebuild from any cause picks it up); and there is no time-based debouncing, so
|
||
a burst arriving as several separate notifications costs one rebuild each.
|
||
|
||
**Definition targets in other files need that file's text** to turn a
|
||
`TextRange` into a `Range`, and the index deliberately keeps no file contents.
|
||
The server resolves a target by taking the **open buffer's text if that path
|
||
is open, else reading the file from disk** — the same precedence the index
|
||
rebuild uses, so a location can never be computed against text the index did
|
||
not see.
|
||
|
||
## Assumptions
|
||
|
||
- ~~**Full-text document sync only.**~~ **Superseded (incremental-sync, round
|
||
2026-08-26).** The server advertises `TextDocumentSyncKind::INCREMENTAL`
|
||
inside a `TextDocumentSyncOptions` (`openClose: true`,
|
||
`save.includeText: false` — the same values a bare `Kind` resolved to
|
||
client-side, so only `change` moved). A `didChange` now carries ranges, and
|
||
`sync::apply_changes` applies them in order to the buffer the server holds:
|
||
each range is positioned against what the previous ones left, a change with
|
||
no range still replaces the whole document, and every out-of-range or
|
||
backwards position clamps rather than panicking. The server is now the only
|
||
holder of the buffer text, which is what makes that function's rules worth
|
||
reading in full: `docs/features/incremental-sync/README.md`.
|
||
- **Every document URI is a `file:` URI.** `untitled:` buffers are accepted
|
||
and served for everything single-file (diagnostics, tokens, formatting,
|
||
symbols), but they have no path, so they never enter the workspace index.
|
||
- **Percent-encoding, not a URI library, converts paths.** `src/uri.rs`
|
||
encodes everything outside the unreserved set plus `/`, and decodes `%XX`.
|
||
Non-UTF-8 paths are rejected rather than guessed at. The Windows
|
||
drive-letter rule (`file:///C:/x` → `C:\x`) is written and compiled but
|
||
**untested on Windows** — it is behind `cfg!(windows)` so it cannot misfire
|
||
on a POSIX path legitimately named `/C:`.
|
||
- **The workspace walk is plain.** `initialize`'s `workspace_folders` (falling
|
||
back to `root_uri`) are walked recursively for `*.v`/`*.sv`/`*.vh`/`*.svh`.
|
||
~~`.gitignore` and `--exclude` are **not** honored~~ **Superseded by
|
||
lucisv-core-lift (lead note): the scan now uses the lifted `lucisv_core` walk —
|
||
`.gitignore` always on, workspace-root config excludes applied. The old
|
||
64-directory depth cap is gone for CLI parity (symlink-cycle exposure now
|
||
shared with the CLI, filed as a follow-up in that feature's README).**
|
||
- **A file that does not lex has no tokens.** The lexer is all-or-nothing
|
||
(`docs/features/error-recovery/README.md`), so `semanticTokens` returns an
|
||
empty set and hover's macro lookup finds nothing for such a buffer. The
|
||
tolerant parser still yields one file-wide diagnostic, which is what the
|
||
user needs to see anyway.
|
||
- **A broken *header* distorts the tree**, as error-recovery's Assumptions
|
||
warn: the module body re-parses at file scope and an orphaned `endmodule`
|
||
becomes a second error item. Symbols and diagnostics in that state are
|
||
oddly-placed but never wrong about their spans. This is the documented
|
||
shape, not a bug in this crate.
|
||
- ~~**`lucisv.toml` is not discovered.**~~ **Superseded by lucisv-core-lift
|
||
(lead note): discovery now runs per formatting request via `lucisv_core`,
|
||
with precedence config > client tabSize > built-in default, and a broken
|
||
config warns once and formats with defaults. See
|
||
`docs/features/lucisv-core-lift/README.md`.**
|
||
|
||
## Handshakes
|
||
|
||
**Consumed from `vlog_parser`:** `tokenize`, `parse_source_tolerant`,
|
||
`ParseDiagnostic { message, line, col, span }`, `TextRange`, `LineIndex`
|
||
(`line_col` / `offset` / `line_range` / `line_count`), `token::{Token,
|
||
TokenKind, Comment}` including the `leading`/`trailing` trivia and their
|
||
spans, and `defines::{collect_defines, Define, DefineTable}`.
|
||
|
||
**Consumed from `vlog_semantic`:** `analyze`, `Semantics::{symbol_at,
|
||
reference_at, references_of, document_symbols, symbol, symbols, references,
|
||
reference_id_at, scope}`, `Symbol { name, kind, name_span, decl_span, scope,
|
||
child_scope }`, `Scope::owner`, `SymbolKind`, `Resolution`, `DocumentSymbol`,
|
||
and the workspace layer — `WorkspaceIndex::{build, path, units, member,
|
||
find_define, workspace_symbols}`, `resolve_external`,
|
||
`ExternalResolutions::{definition_of, get}`, `ExternalTarget::best`,
|
||
`Definition`, `Def`.
|
||
|
||
**Consumed from `vlog_refactor`:** `prepare_rename`, `rename`,
|
||
`instantiation_plan` and friends, the port refactorings, and — since
|
||
references-nav (M7) — `find_references(files, file, offset,
|
||
include_declaration) -> Result<Vec<(PathBuf, TextRange)>, String>`, which is
|
||
the cross-file half of `textDocument/references`. Every one of them takes the
|
||
same `Workspace::sources()` file set.
|
||
|
||
**Consumed from `vlog_formatter`:** `format_source(&str, &Config) ->
|
||
Result<String, FormatError>` and `Config { max_width, indent_width }`.
|
||
|
||
**Promised to nobody yet.** This crate is a leaf: it has no library target and
|
||
nothing depends on it. The editor packaging round (TODO.md §6) will consume
|
||
the binary's name and its stdio contract, nothing else.
|
||
|
||
**Requested of other modules** — none of these block this round, and none was
|
||
done here:
|
||
|
||
1. **DELIVERED** by `docs/features/lucisv-core-lift/README.md` (round 12):
|
||
`config.rs` now lives in `crates/lucisv_core`, and formatting discovers
|
||
`lucisv.toml` anchored at the document's own path. **`crates/lucisv`: make
|
||
config discovery reusable.** `lucisv.toml` search,
|
||
parsing and precedence live in `crates/lucisv/src/config.rs`, inside a binary
|
||
crate, so the server cannot call it. The LSP needs exactly the same
|
||
answer the CLI gives for the same file, and duplicating the search rule is
|
||
how the two silently diverge. The ask: lift `config.rs` into a small
|
||
library (its own crate, or a `lib.rs` beside `main.rs`) with a
|
||
`discover(path) -> Config`-shaped entry point. Until then the server
|
||
formats with defaults, which is wrong for any project that sets
|
||
`line-length`.
|
||
2. **DELIVERED** by `docs/features/lucisv-core-lift/README.md` (round 12):
|
||
`walk.rs` now lives in `crates/lucisv_core`, and the index scan uses it, so
|
||
the index skips what the CLI skips. **`crates/lucisv`: make the ignore-aware
|
||
walk reusable.** Same shape of
|
||
problem for `walk.rs` (`.gitignore` + `--exclude`). The server's plain walk
|
||
will index generated netlists a `lucisv` run would skip.
|
||
3. **`vlog_parser`: token-kind detail the lexer folds away.** Two spellings
|
||
are indistinguishable in `TokenKind` today and are therefore classified
|
||
coarsely by `semanticTokens` rather than reached for privately: an operator
|
||
and a bracket are both `Symbol` (this crate emits neither, see the mapping
|
||
table), and a macro *usage* is a `TokenKind::Ident` whose text starts with
|
||
a backtick, distinguished by the existing public `Token::is_macro()` —
|
||
which is enough, so this is a note, not a request.
|
||
4. **`vlog_semantic`: nothing.** The queries needed for all six navigation
|
||
capabilities existed exactly as documented. *(One request has since been
|
||
filed by type-definition: an unqualified name nothing in the file binds is
|
||
reported `NotFound` rather than as an external candidate, so the workspace
|
||
overlay never sees it — which is how an `interface` type is written. Stated
|
||
in full, with the fenced workaround it stands in for, in
|
||
`docs/features/type-definition/README.md`.)*
|
||
|
||
## The `semanticTokens` mapping
|
||
|
||
Legend advertised, in index order:
|
||
|
||
`0 namespace`, `1 class`, `2 type`, `3 enumMember`, `4 parameter`,
|
||
`5 variable`, `6 property`, `7 function`, `8 macro`, `9 keyword`,
|
||
`10 comment`, `11 string`, `12 number`, `13 decorator`.
|
||
Modifiers: `0 declaration`.
|
||
|
||
| source | token type |
|
||
|---|---|
|
||
| `TokenKind::Keyword` | `keyword` |
|
||
| `TokenKind::Number` | `number` |
|
||
| `TokenKind::String` | `string` |
|
||
| `TokenKind::Directive` (`` `define``, `` `ifdef``, `` `include``) | `macro` |
|
||
| `TokenKind::Ident` where `Token::is_macro()` (`` `NAME ``) | `macro` |
|
||
| `TokenKind::SystemIdent` (`$display`) | `function` |
|
||
| `TokenKind::Attribute` (`(* ... *)`) | `decorator` |
|
||
| `Comment` trivia (leading and trailing, incl. on the EOF token) | `comment` |
|
||
| `TokenKind::Symbol` | **not emitted** |
|
||
| `TokenKind::Ident`, otherwise | from `Semantics`, below |
|
||
|
||
A plain identifier is looked up in the file's `Semantics` at its start offset:
|
||
a declaration (`symbol_at`) gets its symbol's type **plus the `declaration`
|
||
modifier**; a use (`reference_at`) that resolved in-file gets the resolved
|
||
symbol's type; anything else — an external candidate, a not-found name, a name
|
||
a macro would have produced — falls back to `variable`.
|
||
|
||
`SymbolKind` → type: `Module`→`class`, `Package`→`namespace`,
|
||
`Typedef`→`type`, `EnumVariant`→`enumMember`, `Param`/`TfArg`→`parameter`,
|
||
`Function`/`Task`→`function`, `StructMember`→`property`, and
|
||
`Port`/`Net`/`Var`/`Genvar`/`Instance`/`Block`→`variable`.
|
||
|
||
Two rules that are easy to get wrong and are tested:
|
||
|
||
- **Punctuation is not emitted.** Every editor already colors brackets from
|
||
its TextMate grammar, and emitting one token per `;` roughly triples the
|
||
payload for no visible gain.
|
||
- **No token ever spans a line break.** The spec requires it, and Verilog has
|
||
three multi-line token shapes that would violate it — a block comment, a
|
||
continued `` `define``, and a multi-line macro invocation. Every span is
|
||
split at `\n` before encoding, and the pieces are sorted by (line, start)
|
||
before the delta encoding runs. Single-line tokens are also what lets the
|
||
`range` filter reason about overlap without looking at the text at all.
|
||
|
||
Since 2026-08-26 that classification feeds three requests, not one: the pass
|
||
produces an intermediate **absolute** form (line, column, length, type,
|
||
modifiers), `range` filters it, and one pure encoder delta-encodes whatever is
|
||
left — from the start of the document in every case, so a range answer stands
|
||
on its own. The `resultId` bookkeeping that makes `full/delta` possible lives
|
||
in `server.rs` (one counter, one remembered answer per open buffer, dropped on
|
||
`didClose`), because `tokens.rs` owns no state. Rules, the prefix/suffix
|
||
overlap trap and the round-trip property:
|
||
`docs/features/semantic-tokens-delta/README.md`.
|
||
|
||
## Hover, and the order it tries things
|
||
|
||
1. **A macro usage** (`` `NAME `` / `` `NAME(...) ``, and the name inside a
|
||
`` `ifdef``-style directive is *not* included): the file's own
|
||
`DefineTable::latest` wins, rendered as the joined body plus the
|
||
definition's own source lines. If this file does not define it,
|
||
`WorkspaceIndex::find_define` supplies every workspace definition, each
|
||
with its file and line — and since M10 the **`` `include`` graph gets to
|
||
narrow that list**: when the file reaches exactly one of the candidates
|
||
through its includes (transitively, cycles included), that one is shown
|
||
alone. When it reaches none of them, or more than one, every candidate is
|
||
listed as before — the index still models no order of its own
|
||
(`docs/features/workspace-index/README.md`), and the graph is only allowed
|
||
to speak where its answer is unambiguous
|
||
(`docs/features/include-nav/README.md`).
|
||
2. **A reference** resolved in-file: the symbol's kind, its name, and the
|
||
source lines its `decl_span` covers.
|
||
3. **A reference** answered only by the workspace overlay: the kind and name,
|
||
plus each target's file and line.
|
||
4. **A declaration** the cursor is sitting on: its own kind, name and
|
||
snippet.
|
||
|
||
The snippet is `decl_span` widened to whole lines, so a declaration reads as
|
||
it was written rather than starting mid-line.
|
||
|
||
**A macro card has a second half since M14 (0.5.0).** Under the definition it
|
||
shows what the hovered *use* expands to in one step — the body with this call's
|
||
arguments substituted for the parameters — fenced identically, with a footnote
|
||
when a nested macro use survives the step and another when a long body was cut
|
||
at 2000 characters. It is offered only where it says something the definition
|
||
does not: never for a plain object-like macro (whose expansion *is* the body
|
||
printed above), never when the argument count disagrees with the parameter
|
||
list, and never when the lookup above listed several candidates, because the
|
||
expansion must always be of the definition the card is showing. The rules and
|
||
the non-goals (no nested expansion, no stringification, no preprocessing) are
|
||
in `docs/features/macro-expansion/README.md`; `crate::expand` holds the code
|
||
and takes no part in lookup.
|
||
|
||
**The fence tag is a contract now (0.4.1).** Every code block this server puts
|
||
in markdown — both hover snippets and the completion templates' documentation
|
||
panel — opens ```` ```systemverilog ````, unconditionally, `.v` buffers
|
||
included. Since 0.4.1 the VS Code extension contributes a TextMate grammar
|
||
registered for exactly that language id, and that grammar is the *only* thing
|
||
that colours a hover card: semantic tokens cannot reach markdown, and VS Code
|
||
resolves a fence's info string against the language registry rather than
|
||
against the hovered document. Changing the tag, or fencing a new surface with a
|
||
different one, silently returns every card to flat grey. The three call sites
|
||
pin the exact fenced string in their own tests; the registration is pinned by
|
||
`crates/lucisv_server/tests/grammar.rs`, which also holds the extension's keyword
|
||
list to `vlog_parser::KEYWORDS`. Rationale and inventory:
|
||
`docs/features/editor-packaging/README.md`.
|
||
|
||
## Status / TODO
|
||
|
||
- [x] Crate skeleton compiling **before** the root `members` entry (the
|
||
ordering lesson from the previous round).
|
||
- [x] `src/convert.rs`: byte ↔ UTF-16 `Position`, `TextRange` ↔ `Range`.
|
||
- [x] `src/uri.rs`: `file:` URI ↔ path, percent-encoded.
|
||
- [x] `src/state.rs`: `Document` (text, line index, tokens, diagnostics,
|
||
`Semantics`, `DefineTable`, overlay), workspace walk, index rebuild.
|
||
- [x] `textDocument/formatting`.
|
||
- [x] Diagnostics on `didOpen`/`didChange`/`didSave`.
|
||
- [x] `textDocument/semanticTokens/full`, joined by `/range` and `/full/delta`
|
||
(2026-08-26) — one tokenizer and one encoder behind all three, plus a
|
||
per-buffer `resultId` dropped on `didClose`.
|
||
`docs/features/semantic-tokens-delta/README.md`.
|
||
- [x] `textDocument/hover`.
|
||
- [x] `textDocument/definition`.
|
||
- [x] `textDocument/typeDefinition` — delivered by **type-definition**
|
||
(2026-08-26, TODO.md §9c): the type half of go-to-definition, computed
|
||
by redirecting the position to the type name the declaration writes and
|
||
answering with `nav::definition` from there. No engine change.
|
||
`docs/features/type-definition/README.md`.
|
||
- [x] `textDocument/linkedEditingRange` — delivered by **linked-editing**
|
||
(2026-08-26, TODO.md §9c): a closing label and the header name it
|
||
repeats, answered as one linked pair off the AST node that holds both
|
||
spans. No engine change; the two refusals (no label, mismatched label)
|
||
are stated in `docs/features/linked-editing/README.md`.
|
||
- [x] `textDocument/references`.
|
||
- [x] `textDocument/documentSymbol` + `workspace/symbol`.
|
||
- [x] Unit tests for the position conversion, including surrogate pairs.
|
||
- [x] Handler-level tests against constructed state, no process spawned.
|
||
- [x] One end-to-end smoke test that spawns the built binary and speaks
|
||
framed JSON-RPC.
|
||
- [x] TODO.md §6 `lucisv_server` checkbox, annotated with what shipped.
|
||
- [x] ~~**Not done, deliberately:** `rangeFormatting`. It reuses TODO.md §2's
|
||
`--lines`, which does not exist yet; advertising the capability before
|
||
the engine does is how an editor learns to distrust a server.~~
|
||
Delivered by **range-formatting** (round 18): `--lines` exists, so the
|
||
capability is advertised and `format::range_formatting` serves it on the
|
||
same all-or-nothing contract as the whole-document request.
|
||
`docs/features/range-formatting/README.md`.
|
||
- [x] ~~**Not done:** lint diagnostics.~~ Delivered by **server-lint**
|
||
(round 13): the publisher gained the second source — in
|
||
the *same* notification, since LSP replaces rather than merges — plus
|
||
`textDocument/codeAction` for the Safe fixes.
|
||
`docs/features/server-lint/README.md`.
|
||
- [x] ~~**Not done:** completion, rename, signature help (TODO.md §6's "then"
|
||
list).~~ Rename delivered by **refactor-rename** (M2); completion and
|
||
signature help delivered by **refactor-instantiate** (M4), both served
|
||
from `vlog_refactor::instantiation_plan` so Vim gets the same answers.
|
||
`docs/features/refactor-instantiate/README.md`.
|
||
- [x] ~~**Not done:** cross-file references. `references_of` is per-file, and
|
||
answering across the workspace means resolving every other file's
|
||
references *into* this one — an inverted index the workspace layer does
|
||
not build. It is a real feature, not a small addition.~~ Delivered by
|
||
**references-nav** (M7). The inverted index was never built: M2's rename
|
||
already resolves every *other* file's references and asks whether each
|
||
one lands on this declaration, so the answer came from sharing that walk
|
||
(`vlog_refactor::find_references`) rather than from new machinery. The
|
||
same round added `documentHighlight` for symbols and `foldingRange`.
|
||
`docs/features/references-nav/README.md`.
|
||
- [x] ~~**Not done:**~~ `lucisv.toml` discovery, `.gitignore`-aware indexing —
|
||
delivered by lucisv-core-lift (both Handshakes below marked DELIVERED).
|
||
- [x] `textDocument/inlayHint` — delivered by **inlay-hints** (M8): port and
|
||
parameter names on ordered connection lists, off the same
|
||
`instantiation_plan` completion and signature help read.
|
||
`docs/features/inlay-hints/README.md`.
|
||
- [x] `textDocument/documentLink` — delivered by **include-nav** (M10),
|
||
together with the include case of `textDocument/definition` and hover's
|
||
include-graph precedence for `` `define``.
|
||
`docs/features/include-nav/README.md`.
|
||
- [x] `callHierarchy` (all three requests) — delivered by **hierarchy** (M11):
|
||
the module hierarchy both directions, modules as the nodes and
|
||
instantiations as the calls, off a walk shared with the inlay hints.
|
||
`docs/features/hierarchy/README.md`.
|
||
- [x] `typeHierarchy` (all three requests) — delivered by **type-hierarchy**
|
||
(2026-08-26, TODO.md §9c): the class `extends` tree both directions,
|
||
classes as the nodes. The capability is inserted into the serialized
|
||
`initialize` result because `lsp-types` 0.97 has no field for it.
|
||
`docs/features/type-hierarchy/README.md`.
|
||
- [x] Single-step macro expansion on a hover card (`src/expand.rs`, M14) —
|
||
`docs/features/macro-expansion/README.md`.
|
||
- [x] `$/cancelRequest` — delivered by **cancel-request** (2026-08-26,
|
||
completing TODO.md §9b): the loop reads in bursts and answers a queued
|
||
request whose cancel is in the same burst with `RequestCancelled`,
|
||
order across the burst unchanged. `docs/features/cancel-request/README.md`.
|
||
- [ ] **Not done:** editor packaging (the VS Code extension and the
|
||
`lspconfig` snippet are their own TODO.md §6 item).
|
||
|
||
## Work log
|
||
|
||
### 2026-08-26 — dev agent (type-hierarchy, TODO.md §9c)
|
||
|
||
- **One new capability, one new module, nothing else moved.** The three
|
||
`typeHierarchy` requests are served from
|
||
`crates/lucisv_server/src/type_hierarchy.rs`; `server.rs` gained three
|
||
dispatch arms. No engine change — `vlog_semantic` and `vlog_parser` are
|
||
untouched, and `hierarchy.rs`/`instantiations.rs` were not opened.
|
||
- **The capability is written by hand.** `lsp-types` 0.97 models type hierarchy
|
||
on the *client* side only: `ServerCapabilities` has no
|
||
`type_hierarchy_provider` field. `main.rs`'s new `initialize_value` serializes
|
||
the `InitializeResult` and inserts `"typeHierarchyProvider": true` into the
|
||
capabilities object — the same JSON a field would have produced — because a
|
||
capability a client cannot see is a feature that is never requested.
|
||
`experimental` was not used: different key, and no client reads it for this.
|
||
- **Classes, not modules.** The lead's scope decision, argued in the feature
|
||
README: an instantiation is a containment edge and `extends` is an
|
||
inheritance edge, so the module hierarchy stays on `callHierarchy` where it
|
||
shipped, and this request serves one node kind well.
|
||
- **`supertypes` is `definition_of` at a computed offset**, not a new lookup.
|
||
`extends Base` is already a reference, and the overlay-promotion round already
|
||
made a bare cross-file class name reachable through it, so the only new idea
|
||
is *which* offset to ask about: the last byte of the extends name span, which
|
||
is the tail of `pkg::base` and the whole of a bare `base`. That gets in-file
|
||
bases, cross-file bases, package-qualified bases and parameterized bases from
|
||
one line, and can never disagree with F12 on the same token.
|
||
- **`subtypes` is `callers_of_each`'s census in another key**: one
|
||
`sources()` pass, a substring prefilter before any parse, a deterministic
|
||
sort. 55 ms over the 860-file corpus, 53 ms of it file I/O — the same shape
|
||
`incomingCalls` measured, and the same backlog item (an edge table in
|
||
`WorkspaceIndex`, now filed for inheritance edges beside the instantiation
|
||
ones).
|
||
- **What the class model lacked:** interface classes. `vlog_parser` rejects
|
||
`interface class` outright, so `implements` can never resolve and no item can
|
||
carry `SymbolKind::Interface`; both facts are pinned by tests named to force a
|
||
future parser round past them. Full details, assumptions, cost table and the
|
||
ambiguity argument: `docs/features/type-hierarchy/README.md`.
|
||
|
||
### 2026-08-25 — dev agent (M14 macro-expansion, 0.5.0)
|
||
|
||
- **No new capability, one new module, one card grew a section.**
|
||
`crates/lucisv_server/src/expand.rs` turns a macro-use token plus the `Define`
|
||
the card already chose into an "expands to" block; `hover.rs`'s private
|
||
`define_text` takes the call text as a fourth argument and appends the
|
||
section when there is one. `server.rs`, `state.rs`, the capability list and
|
||
every engine crate are untouched.
|
||
- **`expand` is deliberately blind to lookup.** It never sees the workspace,
|
||
the index or the include graph — `hover.rs` decides *which* definition is on
|
||
the card (M10's narrowing) and hands it over, so the expansion can never
|
||
disagree with the definition printed above it. Where hover lists several
|
||
candidates it passes no call text, and nothing is expanded.
|
||
- **The fence contract of 0.4.1 extends to the new block**: ```` ```systemverilog ````,
|
||
pinned by the e2e round trip, which now asserts a whole macro hover card byte
|
||
for byte rather than by `contains`.
|
||
- All eighteen pre-existing hover tests pass with no assertion changed.
|
||
`cargo test -p lucisv_server`: **528 passed, 0 failed** (498 unit + 27 e2e +
|
||
3 grammar), up 27. Rules and non-goals:
|
||
`docs/features/macro-expansion/README.md`.
|
||
|
||
### 2026-08-25 — dev agent (M11 hierarchy)
|
||
|
||
- **One new capability, two new modules, one lifted walk.**
|
||
`callHierarchyProvider` is advertised as a plain `true` — the three requests
|
||
are either all served or none are — `server.rs` gained three dispatch arms,
|
||
and `crates/lucisv_server/src/hierarchy.rs` holds the answers. No engine
|
||
change: `WorkspaceIndex` is read exactly as before.
|
||
- **The instantiation walk is now shared.**
|
||
`crates/lucisv_server/src/instantiations.rs` holds the walk that used to be
|
||
private to `inlay.rs`, with the innermost enclosing module declaration
|
||
threaded through it. `inlay.rs` calls it and ignores the owner; its 34 tests
|
||
were left untouched as the evidence that the factoring changed nothing.
|
||
Hierarchy uses the owner for both directions — it is what makes an incoming
|
||
call name the *calling module* rather than a span, and what stops a
|
||
neighbouring module's instantiations from being claimed as this module's.
|
||
- **The index holds no instantiation edges**, so "who instantiates X" is a
|
||
walk of the in-scope files rather than a lookup. It is nonetheless 4×
|
||
cheaper than `textDocument/references` on the same corpus (56 ms against
|
||
218 ms), because a file that does not contain the module's name cannot
|
||
instantiate it and is skipped before it is parsed. An edge table in
|
||
`WorkspaceIndex` is recorded as backlog in the feature README, not built.
|
||
- **Ambiguity is answered two ways on purpose**: `prepare` returns every
|
||
declaration (the protocol takes a list and the user is there to choose),
|
||
`outgoingCalls` skips silently (a tree node has nobody to ask, and a wrong
|
||
node is unfalsifiable to the reader).
|
||
- Nothing else moved: `state.rs`, `nav.rs`, `vlog_semantic`, `vlog_refactor`
|
||
and `editors/` are untouched, and there is no version bump. Full details,
|
||
assumptions and numbers: `docs/features/hierarchy/README.md`.
|
||
|
||
### 2026-08-24 — dev agent (M8 inlay-hints)
|
||
|
||
- **One new capability, one new module, nothing else moved.**
|
||
`inlayHintProvider` is advertised as `InlayHintOptions` with no
|
||
`resolveProvider` (every hint is returned complete), `server.rs` gained one
|
||
dispatch arm, and `crates/lucisv_server/src/inlay.rs` holds the whole answer.
|
||
No engine change: `vlog_refactor::module_definition` +
|
||
`instantiation_plan` were already public for M4, and this feature reads only
|
||
the port/parameter **names** out of the plan.
|
||
- **The one architectural difference from `signature.rs`, stated here because
|
||
the two look like they should share code**: signature help reads the token
|
||
stream because it answers about a half-typed list; inlay hints read
|
||
`doc.tree`, because a hint decorates text that parses and the tree already
|
||
knows which lists are ordered, where each expression starts, and which
|
||
positions were omitted. Sharing a comma counter between them would have made
|
||
the hint answer worse, not the code smaller.
|
||
- **Cost measured before the design was fixed**, not after: 0.005 ms over a
|
||
1916-line corpus file, 12.2 ms for a 40-line screen showing forty *distinct*
|
||
ordered instantiations, 30.8 ms for a hundred of them at once. Plans are
|
||
cached for the length of one request and not across requests; the number
|
||
that would justify a cross-request cache, and the staleness it would bring,
|
||
are written up in the feature README's *Cost* section.
|
||
- **Nothing in `state.rs` was touched**, so the workspace is still immutable
|
||
through every read handler. `editors/vscode` needs no change either — the
|
||
language client picks the feature up from the advertised capability — and
|
||
`smoke.js` was deliberately left alone (its capability list belongs to
|
||
editor-packaging); it still passes against the release binary.
|
||
- **Results.** `cargo test --workspace`: **1358 passed, 0 failed** (1330
|
||
before — 26 unit tests in `inlay.rs`, one capability test in `main.rs`, one
|
||
e2e stdio round trip). `cargo clippy --all-targets`: silent.
|
||
`cargo fmt --all -- --check`: clean. No new dependencies, no version bump
|
||
(0.5.0 belongs to M14), no commits.
|
||
|
||
### 2026-08-24 — dev agent (0.4.1, fence audit only)
|
||
|
||
Owned by `docs/features/editor-packaging/README.md`; noted here because it
|
||
turned one of this crate's output details into a cross-module contract.
|
||
|
||
- **No behaviour changed in this crate.** Every markdown surface it emits was
|
||
audited for unfenced code: `hover.rs:89` and `hover.rs:131` and
|
||
`completion.rs:423` already carried ```` ```systemverilog ```` and were left
|
||
exactly as they are; `completion.rs:615` (the M4 instantiation documentation)
|
||
is a bullet list whose port signatures are *inline* code spans, which markdown
|
||
cannot tag and which a fence would restructure, so it was left alone; and
|
||
`signature.rs:85` emits prose in `Documentation::String` with a `label` the
|
||
client renders itself, so neither is markdown at all.
|
||
- **Three test assertions were added** — one per code-carrying surface —
|
||
pinning the exact fenced string rather than just the payload, because the tag
|
||
is what the extension's new TextMate grammar keys off. See the section "The
|
||
fence tag is a contract now" above.
|
||
|
||
### 2026-08-19 — dev agent
|
||
|
||
- Read `CLAUDE.md`, `README.md`, TODO.md §6 in full, and the Handshakes/API
|
||
sections of `spans`, `error-recovery`, `define-table`, `vlog-semantic` and
|
||
`workspace-index` before writing anything. Every query this crate needed
|
||
existed already; **no change was required in any engine crate**, which is
|
||
the outcome the two-layer design in `workspace-index` was aiming for.
|
||
- **Took the ordering lesson literally.** `crates/lucisv_server/` was created
|
||
with a `Cargo.toml` and a `fn main() {}` and *built* before the root
|
||
`members` entry was added, then the entry, then a build, then the
|
||
dependencies, then a build. A members line pointing at nothing breaks the
|
||
workspace for every other agent in the tree; this cost four extra builds and
|
||
was worth it.
|
||
- **Dependency choice measured, not assumed.** Resolved the tree in a scratch
|
||
crate first: `lsp-types` 0.97 (`fluent-uri`) against 0.94 (`url`). 0.94
|
||
would have handed us `Url::from_file_path`; it also costs `idna`,
|
||
`unicode-bidi`, `unicode-normalization`, `tinyvec` and `percent-encoding`.
|
||
Chose 0.97 and wrote `src/uri.rs` (~40 lines, 6 tests) instead. Also
|
||
confirmed the workspace resolves exactly one `syn`, which the scratch crate
|
||
had *not* — worth re-measuring in place rather than trusting the sandbox.
|
||
- **`serde` is a direct dependency for exactly one reason** and it is stated
|
||
at the manifest line: the `DeserializeOwned` bound on `decode`. Without it
|
||
the request dispatcher becomes eight copies of the same four lines. It
|
||
arrives transitively anyway, so this costs nothing but honesty.
|
||
- **Wrote the UTF-16 conversion first, and its tests before the handlers.**
|
||
This is the bug the brief called out, and two of its rules were established
|
||
by failing tests rather than by design: the CRLF round-trip collapse and the
|
||
empty-diagnostic-range fallback (both written up in the conversion section
|
||
above). In both cases my first *test expectation* was wrong and the code was
|
||
right, which is the good direction for that to happen — but it means the
|
||
behavior is now pinned by a test that understands why, instead of by one
|
||
that happened to pass.
|
||
- **`semanticTokens` line-splitting was designed in, not discovered.** The
|
||
spec forbids a token spanning a line break and Verilog has three shapes that
|
||
would (block comment, continued `` `define``, multi-line macro call). All
|
||
three have a test. Punctuation is deliberately not emitted — every editor
|
||
colours brackets from its own grammar and emitting `;` roughly triples the
|
||
payload.
|
||
- **Formatting failures go to `showMessage`, not to diagnostics**, and the
|
||
reason is in a comment at the call site: the diagnostic list belongs to the
|
||
parse pass and is cleared on the next keystroke, which would silently erase
|
||
the explanation for a format the user explicitly asked for. The handler
|
||
returns an empty edit list in that case — never a partial edit, per CLAUDE.md
|
||
invariant #1.
|
||
- **Definition/hover into other files read that file's text on demand**, with
|
||
open-buffer-beats-disk precedence, because the index deliberately keeps no
|
||
file contents. Holding the whole workspace in memory to avoid a
|
||
microsecond-scale file read would double what a server already spends on
|
||
buffers.
|
||
- **Three warnings were fixed by deleting code, not by allowing it**: an
|
||
unused `Uri` import, a `text_range` helper with no consumer (it would be
|
||
range formatting's, which is deferred), and a `tree` field on `Document`
|
||
that nothing read once `Semantics` was built. The two `#[allow(deprecated)]`
|
||
that remain are on `DocumentSymbol.deprecated` / `SymbolInformation.
|
||
deprecated` / `InitializeParams.root_uri` — protocol fields deprecated by
|
||
the spec that are still non-optional struct fields — and each carries the
|
||
comment CLAUDE.md requires.
|
||
- **The e2e test writes the whole session before reading a byte.** Interleaving
|
||
writes and reads against a subprocess is how a smoke test turns into an
|
||
intermittent hang; the session is under 4 KB, well inside a pipe buffer, and
|
||
the server exits on `exit` so stdout closes and the read terminates on its
|
||
own. No timeouts, no reader thread, and it cannot deadlock.
|
||
- Did not touch `vlog_parser`, `vlog_formatter`, `vlog_semantic`,
|
||
`vlog_linter` or `crates/lucisv`. Did not run `git commit`/`git push`.
|
||
- **Concurrency note:** another agent's `vlog_linter` round is live in the same
|
||
tree and added its own `members` line to the root `Cargo.toml` mid-round;
|
||
left alone, as expected. Something in that round also ran `cargo fmt --all`
|
||
across the tree, which reflowed a few of this crate's lines — harmless, and
|
||
the final `cargo fmt --all --check` is clean.
|
||
|
||
**Results.** `cargo test -p lucisv_server`: **76 passed, 0 failed** (75 unit +
|
||
1 e2e; counts trued up by the lead per the QA log — the workspace total
|
||
below also moved as the concurrent linter round landed). `cargo test
|
||
--workspace`: **494+ passed, 0 failed**. `cargo clippy
|
||
--workspace --all-targets`: silent, 0 warnings. `cargo fmt --all --check`:
|
||
clean. Files added: `crates/lucisv_server/{Cargo.toml,src/{main,server,state,
|
||
convert,uri,locate,diagnostics,format,tokens,hover,nav,symbols}.rs,
|
||
tests/e2e.rs}`, this README. Files edited: root `Cargo.toml` (one `members`
|
||
entry, four `[workspace.dependencies]` lines — additive only), `TODO.md`
|
||
(§6 checkbox).
|
||
|
||
## QA log
|
||
|
||
### 2026-08-19 — QA agent
|
||
|
||
Scope: `-p lucisv_server` only. Did not touch `vlog_linter`, `crates/lucisv`, or
|
||
`docs/features/linter-core` (a concurrent QA round owns those). No source was
|
||
edited; this entry is the only write.
|
||
|
||
**Gates.** `cargo fmt -p lucisv_server -- --check`: clean. `cargo clippy -p
|
||
lucisv_server --all-targets`: 0 warnings. `cargo test -p lucisv_server`: **76
|
||
passed, 0 failed (75 unit + 1 e2e)** — stable across two runs. `cargo test
|
||
--workspace`: green (503 passed at the instant measured; the concurrent
|
||
`vlog_linter` round is landing tests live in the same tree, so this number
|
||
moves independently of anything here — `-p lucisv_server`'s own 76 is the
|
||
number that matters for this feature and is not moving).
|
||
|
||
**Dependency audit, independently reproduced.** `git diff HEAD -- Cargo.lock`
|
||
adds exactly the 18 named packages, plus two *local* workspace crates
|
||
(`lucisv_server` itself and `vlog_linter`, the concurrent round — not part of
|
||
the transitive count). Exactly one `syn` resolves, `3.0.3`. Exact-pin lines
|
||
in root `Cargo.toml` confirmed: `lsp-server = "=0.10.0"`, `lsp-types =
|
||
"=0.97.0"`, `serde = "=1.0.229"`, `serde_json = "=1.0.140"`. Read all five
|
||
build scripts in full (not spot-read): `proc-macro2-1.0.107`,
|
||
`quote-1.0.47`, `serde-1.0.229`, `serde_core-1.0.229`, `serde_json-1.0.140`
|
||
(paths under `~/.cargo/registry/src/…`, resolved via `cargo metadata`).
|
||
Every one only shells out to `rustc --version` and emits
|
||
`cargo:rustc-cfg`/`cargo:rustc-check-cfg` lines (`proc-macro2`'s also
|
||
compiles a tiny local probe file through `rustc` to detect a stable-API
|
||
cutoff — still no network, no linking, no `cc`/`bindgen`). Confirms the
|
||
README's claim exactly.
|
||
|
||
**No `unwrap`/`expect`/`panic!`/`unsafe` outside `#[cfg(test)]`.** Checked
|
||
every line match against each file's `mod tests` boundary in all 12
|
||
`src/*.rs` files — zero hits above the boundary. Three `#[allow(deprecated)]`
|
||
found (`main.rs:98`, `symbols.rs:78`, `symbols.rs:103`), each with an
|
||
explanatory comment.
|
||
|
||
**Real-binary end-to-end session, driven directly over stdio** (own
|
||
hand-rolled Python framing client extending the `tests/e2e.rs` pattern, not
|
||
reusing it — scripts left in the scratchpad, not the repo). Scratch project:
|
||
`A.sv` (`` `include``s `defs.vh`, `import P::K`, instantiates `B`), `B.sv`,
|
||
`pkg.sv` (`package P; localparam K = 4;`), `defs.vh` (`` `define WIDTH 8``).
|
||
All PASS:
|
||
|
||
- Capabilities JSON on `initialize`: every shipped capability present
|
||
(`documentFormattingProvider`, `definitionProvider`, `referencesProvider`,
|
||
`hoverProvider`, `documentSymbolProvider`, `workspaceSymbolProvider`,
|
||
`semanticTokensProvider` with the 14-type/1-modifier legend,
|
||
`positionEncoding: "utf-16"`, `textDocumentSync: 1` i.e. Full). Deferred
|
||
capabilities (`documentRangeFormattingProvider`, `completionProvider`,
|
||
`renameProvider`, `signatureHelpProvider`) absent from the JSON, not just
|
||
falsy. *(All four have since shipped — range-formatting, refactor-rename and
|
||
refactor-instantiate — and `tests/e2e.rs` now asserts their presence
|
||
instead; this entry records the state at the time of that QA pass.)*
|
||
- `definition` on `B u_b` → `B.sv` at the correct declaration span.
|
||
- `hover` on `` `WIDTH`` → macro body `` `define WIDTH 8``; `hover` on `K`
|
||
(reached via `import P::K`) → `**parameter** — declared in pkg.sv:2`.
|
||
- `didChange` introducing `localparam int ;` → two diagnostics, non-empty
|
||
sane ranges (`severity: 1`, `source: "lucisv"`).
|
||
- `didChange` reverting the fix → **diagnostics array published empty** —
|
||
the classic forgotten-clear case, verified actually clearing.
|
||
- `textDocument/formatting` on the unformatted file → one edit whose
|
||
`newText` is **byte-for-byte identical** to `target/debug/lucisv --stdout`
|
||
on the same source.
|
||
- `textDocument/formatting` on the already-formatted output → `result: []`.
|
||
- `semanticTokens/full` on `B.sv` → decoded the delta stream by hand (12
|
||
tokens), spot-checked against the source; correct.
|
||
- `documentSymbol` on `A.sv` → module `A` nests 5 children (`clk`, `out`,
|
||
the `u_b` instance, `WIDTH2`, `K2`).
|
||
- `workspace/symbol` substring `"WIDTH2"` → 1 correctly located hit.
|
||
- Renamed `B`→`B2` in `B.sv`, `didChange` + `didSave` → `definition` from
|
||
`A`'s still-open buffer (referencing the old name `B`) now resolves to
|
||
`[]`. Staleness model confirmed: the index only rebuilds on save, and did.
|
||
- `shutdown`/`exit` → clean ack, exit code 0.
|
||
|
||
**Position torture.** All PASS. `initialize` with **no** `workspaceFolders`
|
||
and **no** `rootUri` → succeeds (single-file mode works). A file with an
|
||
emoji (`🎉`) in a `//` comment on the line before a module declaration:
|
||
`hover` and `documentSymbol.selectionRange` on the module name land at the
|
||
correct UTF-16 column on the following (pure-ASCII) line. `hover` at the
|
||
character offset landing *inside* the emoji's own surrogate pair (comment
|
||
line itself) → graceful `null`, no crash. A CRLF file with a `wire ;` parse
|
||
error → diagnostic range end character is `8`, matching the 8-char line
|
||
content, not bleeding into the `\r`. `hover`/`definition` at
|
||
character-past-end-of-line, line-past-end-of-file, and both-past-end → all
|
||
six combinations return graceful `null`/`[]`, no protocol error, no crash;
|
||
server process survived and later exited cleanly (code 0). `textDocumentSync`
|
||
confirmed `1` (Full) in the capabilities JSON, so the "stale/overlapping
|
||
`didChange`" scenario is moot as documented. *(That last sentence records the
|
||
state at the time of this QA pass only: sync became incremental on
|
||
2026-08-26, and the clamping that keeps a desynced `didChange` harmless is
|
||
specified and tested in `docs/features/incremental-sync/README.md`.)*
|
||
|
||
**Robustness.** All PASS. Malformed `Content-Length: notanumber` header, and
|
||
a well-framed-but-garbage JSON body → in both cases the process does **not**
|
||
panic (no `panicked at` in stderr); `lsp-server`'s own transport reports
|
||
`ProtocolError("disconnected channel", true)` and the process exits (code
|
||
1) — "exits cleanly" per the acceptance criterion. Every capability request
|
||
(`hover`, `definition`, `references`, `documentSymbol`,
|
||
`semanticTokens/full`, `formatting`) against a URI that was never opened →
|
||
graceful `null`/`[]`, never a protocol error. A `file:` URI built from a
|
||
path with spaces, `&`, `#`, and a non-ASCII directory component
|
||
(`münchen`) → round-trips correctly through `didOpen`/`publishDiagnostics`
|
||
and `documentSymbol` (probing `src/uri.rs` through the real binary, not just
|
||
its own unit tests).
|
||
|
||
**Index scale.** PASS, and a QA-tooling note worth recording. Pointed
|
||
`initialize` at `corpus/` (860 files, read-only, untouched). A full session
|
||
— `initialize` + `workspace/symbol("")` + `workspace/symbol("clk")` +
|
||
`workspace/symbol("uart_core")` + `shutdown`/`exit` — completes in **0.79 s**
|
||
wall time (`/usr/bin/time -l`: 29.5 MB max RSS). The 256 cap is honored
|
||
exactly: `""` (matches everything, per `vlog_semantic`'s own doc comment)
|
||
and `"clk"` (a common substring almost certainly matching far more than 256
|
||
declarations across a real 860-file corpus) both return exactly 256 hits;
|
||
`"uart_core"` returns the correct single hit.
|
||
|
||
*Tooling note, not a lucisv_server defect:* an earlier attempt at this same
|
||
check, using a persistent bidirectional-threaded Python client (a reader
|
||
thread continuously draining stdout while the main thread issues requests —
|
||
the natural way to extend the e2e pattern for an interactive multi-request
|
||
session), appeared to hang indefinitely specifically on `workspace/symbol
|
||
("clk")` against the real corpus — confirmed *not* CPU-bound via `sample`
|
||
(macOS) on the server process: all four of its threads (main loop, reader,
|
||
writer, message-dropper) sat blocked on `recv()`/`read()` the entire time,
|
||
CPU time flat at 0.76 s across a 3-minute wait. Root-caused by replacing the
|
||
persistent client with a write-the-whole-session-then-read-all-of-stdout
|
||
script (`subprocess.run(..., input=session)`) — the exact pattern
|
||
`tests/e2e.rs` itself uses, with the exact rationale given in its own
|
||
top-of-file comment ("interleaving writes and reads against a subprocess is
|
||
how a smoke test turns into an intermittent hang"). That version returned
|
||
the correct, capped, sub-second result every time. I did not chase the
|
||
harness bug further since the server's correctness is independently proven;
|
||
flagging it so nobody mistakes the interactive-client hang for a server
|
||
issue if they re-run a similar probe.
|
||
|
||
**CLAUDE.md / TODO.md compliance.** README has all seven required sections.
|
||
TODO.md §6's `lucisv_server` checkbox (`TODO.md:330`) is checked and its
|
||
shipped/not-shipped annotation matches the README's Capabilities table and
|
||
Status/TODO checklist exactly — no over-claiming. Both filed Handshakes
|
||
(`config.rs` and `walk.rs` lifting requests, README.md:370-371) are
|
||
recorded; confirmed independently that `crates/lucisv` is `[[bin]]`-only (no
|
||
`[lib]` target in its `Cargo.toml`), so the Handshake's premise — that
|
||
`lucisv_server` genuinely cannot call into them today — holds.
|
||
|
||
**Minor, non-blocking:** the Work log's "Results" paragraph
|
||
(README.md:447-448) says "75 passed, 0 failed (74 unit + 1 e2e)" and "493
|
||
passed" workspace-wide. Current actual counts are 76 (75 unit + 1 e2e) and
|
||
503 workspace-wide (the latter net of concurrent work). The `-p lucisv_server`
|
||
count is off by exactly one unit test from what's written — likely a test
|
||
added after that paragraph was written. Not fixed here since it's prose in
|
||
another agent's Work log entry, not a code or test defect; flagging so the
|
||
dev agent can true it up.
|
||
|
||
**Summary: no BLOCKING findings.** No panic, no dropped/never-cleared
|
||
diagnostic, no position off-by-one, on ASCII or non-ASCII content, in any
|
||
scenario tried. All five claims verified against the real binary, not just
|
||
its own unit tests.
|
||
|
||
## Review
|
||
|
||
**2026-08-19 — lead. Verdict: accepted; commits jointly with linter-core
|
||
(round 11). The owner's LSP requirement is now a running binary.**
|
||
|
||
What earned it:
|
||
|
||
1. **Protocol layer only.** Not one engine crate was modified — the
|
||
ten rounds of foundations were sufficient exactly as documented,
|
||
which is the strongest validation the feature-README discipline has
|
||
produced. Where the CLI's config/gitignore behavior couldn't be
|
||
reached (they live in the lucisv binary), the dev filed Handshakes
|
||
instead of duplicating logic — those two lifts are round-12 work.
|
||
2. **Honest capability advertising**: deferred features are absent
|
||
from the initialize result, so no editor is lied to. rangeFormatting
|
||
waits on §2 `--lines`; lint diagnostics wait on wiring vlog_linter
|
||
in — both natural follow-ups.
|
||
3. **The two test-produced findings** (CRLF's one-position collapse
|
||
pinned rather than papered over; empty EOF diagnostic spans widened
|
||
to drawable lines) are the UTF-16/position class of bug that ruins
|
||
language servers, caught before any editor saw them. QA's
|
||
position-torture (emoji, surrogates, six past-end combinations) and
|
||
robustness runs (malformed frames, unopened URIs, percent-encoded
|
||
paths) all came back clean, and the diagnostics-actually-clear case
|
||
was verified through a real stdio session.
|
||
4. **Dependency discipline held under the biggest temptation**: 4
|
||
exact-pinned direct deps, 18 packages, all 5 build scripts read.
|
||
The lsp-types 0.97-over-0.94 choice traded ~40 tested URI lines for
|
||
5 fewer packages — the right direction.
|
||
5. Index scale: 860 files in 0.79s / 29.5MB through a real session.
|
||
Per-file recompute with didSave index rebuild is the documented,
|
||
deliberately boring staleness model; salsa stays deferred until it
|
||
hurts.
|
||
|
||
Lead fix on acceptance: the stale test counts in the work log trued up
|
||
per QA. QA's harness-hang investigation (profiled the server before
|
||
blaming it; found its own threading at fault; matched the e2e test's
|
||
own documented write-then-read pattern) is preserved in the QA log as
|
||
the reference for anyone scripting against the server.
|
||
|
||
Round 12: editor packaging (VS Code extension + Neovim lspconfig) and
|
||
the config/walk library lifts, closing TODO §6.
|