TODO section 24, coverage_gaps M7 via topo 2.9-6 and 2.9-4. unused-signal, undriven-net and multiply-driven shipped off because a per-file analysis cannot see a signal read or driven from another file's hierarchy. The index now carries a per-file identifier census - FileFacts::words, FACTS_FORMAT 12 -> 13, one harvest lifted from the server's completion candidates and now feeding them back from the store instead of re-lexing every file at startup (scan -28 percent) - and the linter gains a MentionOracle: unused-signal and undriven-net say nothing when the name is mentioned in any other indexed file, the false-negative-safe direction; multiply-driven shares the gate but never reads it. The three are on wherever an oracle exists (the editor always, the CLI when it walks a project) and off for a single file or stdin. With them, the missing off switch: [lint] select/ignore in lucisv.toml with CLI flags winning key by key, and lucisv.lint.select/ignore in the editor. QA's finding, reworked: the census dropped macro invocations whole, so a signal named only inside `uvm_info(..., dut.sig) was not silenced; the harvest now splits macro, directive and attribute words, skipping double-quoted runs so a "%d" cannot silence a signal named d project-wide, with workspace-defined macro names filtered out of the completion table at the reader. Store +16.9 percent corpus / +15.0 percent opentitan, measured. Corpus unused-signal 52 -> 44 and undriven-net 3 -> 0 with every silencing hand-checked, nothing added; opentitan - lint-clean under its own tools - 14 findings, all classified true against the whole repo. Also: the docs-site rules page gains the empty-item row it lacked. docs/features/semantic-lints-on/README.md. Co-Authored-By: Claude Fable 5 <[email protected]>
1024 lines
58 KiB
Markdown
1024 lines
58 KiB
Markdown
# completion-core
|
||
|
||
M5 of the refactoring plan (`docs/features/refactor/README.md`): **general
|
||
completion** — keywords and project-wide identifiers merged into M4's
|
||
module-hinting response — plus the **0.3.0 version bump**.
|
||
|
||
## Goal
|
||
|
||
Make `textDocument/completion` answer the question a user actually asks while
|
||
typing, instead of only the one M4 could answer. One response, five tiers,
|
||
sorted best-first: the instantiation skeleton where one belongs, then the
|
||
declarations visible at the cursor, then what the project declares, then every
|
||
reserved word the lexer knows, then every identifier used anywhere in the
|
||
project. A name appears once, claimed by its best tier. Nothing is offered
|
||
inside a comment or a string, and — the other half of the same promise — a name
|
||
that appears *only* inside a comment or a string is never a candidate, because
|
||
the word list is harvested from the token stream, where comments are trivia and
|
||
a string is one token. The scope of "the project" is M1's ladder, unchanged, so
|
||
a file the filelist leaves out contributes nothing.
|
||
|
||
Completion fires on every keystroke, which is the whole design constraint: no
|
||
tier may walk the workspace. The two project-wide tables are built beside the
|
||
workspace index, from the same file list, and are replaced with it.
|
||
|
||
## Assumptions
|
||
|
||
- **The lexer's reserved-word list is the keyword list.** `vlog_parser::token`
|
||
now generates `KEYWORDS` (a `&[&str]`) and `is_keyword` from one
|
||
`keywords![...]` macro invocation, so a word cannot be one without being the
|
||
other. The list is unchanged — 181 words, comments and all — and the parser
|
||
suite is green, so lexing behaviour is untouched. Offering a word the parser
|
||
does not reserve, or failing to offer one it does, would both be lies; the
|
||
macro makes both unrepresentable.
|
||
- **A comment is never code and a string is never code.** The harvest takes
|
||
`Ident` and `SystemIdent` tokens only. Comments never reach the token stream
|
||
at all (the lexer detaches them as trivia), and a string literal is one
|
||
`String` token, so neither can contribute a candidate — this is a property of
|
||
the lexer, not a filter that could be forgotten. Two `Ident` shapes are
|
||
dropped on purpose: a macro usage (`` `WIDTH ``, whose text is the whole
|
||
invocation, argument list included — the macro *names* have their own table)
|
||
and an escaped identifier (`\my-port`, which needs a terminating space that a
|
||
plain word item cannot promise).
|
||
- **A buffer that does not lex gets no completions at all.** With no token
|
||
stream there is no way to tell a comment from code, and the commonest way to
|
||
break the lexer while typing is to open a string or a block comment and keep
|
||
going. Declining is the safe half of that trade, and the buffer lexes again as
|
||
soon as the quote or the `*/` is typed. Deliberate: the alternative is
|
||
offering a completion list *inside* the unterminated string.
|
||
- **The index's freshness is the tables' freshness.** The index rebuilds on
|
||
`initialize` and on `didSave`, so the project-wide tables do too. An unsaved
|
||
edit in *another* buffer is therefore not in the word table until it is
|
||
saved — exactly the rule the index has always had (`lucisv-server`'s
|
||
invalidation notes). The buffer being typed in is the exception, and needs no
|
||
rebuild: its own token stream is already computed on every change, so its
|
||
words are harvested per request and an unsaved name is a candidate
|
||
immediately.
|
||
- **The harvest is `vlog_semantic::words::harvest`, not this crate's.**
|
||
Amended 2026-09-02 by `semantic-lints-on`: `candidates::words_in` and
|
||
`words_of_tokens` are now one-line wrappers over it, and the same census
|
||
rides in each file's `FileFacts` (`FACTS_FORMAT` 13). Two consequences.
|
||
The rules for what counts as a word are stated once: `Ident`/`SystemIdent`
|
||
tokens, plus — since the round's second pass — the identifiers **inside** a
|
||
macro invocation, a directive line and an attribute, which the lexer hands
|
||
over as single tokens carrying their whole text. So `` `CHECK(u_dut.sig) ``
|
||
offers `sig`, which it did not before; a quoted run inside such a token is
|
||
stepped over (it is a value), and an escaped identifier is still dropped
|
||
whole (inserting one needs a terminating space a plain word cannot promise).
|
||
Comments and string literals stay unreachable by construction. The semantic
|
||
lint rules ask the *same* table "does any other file mention this name", so a
|
||
completion list and a lint finding can never disagree about what a file
|
||
contains.
|
||
|
||
**One subtraction, at the reader rather than the harvest.** A name the
|
||
workspace `` `define``s is in the census — it is a word the file writes down
|
||
— but `Candidates::words_scan` does not offer it, because the macro tier
|
||
already does and does so **by prefix only**, which is this feature's own
|
||
fuzzy ruling (`the_keyword_template_macro_and_module_tiers_did_not_go_fuzzy`
|
||
pins it). Without the skip, splitting `` `define CLK_OSC_EN_Q 1 `` into
|
||
words would have made a macro name reachable by subsequence through a side
|
||
door, and would have offered it bare where the code needs a backtick. Pinned
|
||
by `macro_argument_words_are_offered_and_macro_names_are_left_to_their_own_tier`.
|
||
Note the coupling this creates:
|
||
`a_fuzzy_scan_finds_exactly_what_brute_force_subsequence_finds` compares the
|
||
fuzzy scan against a brute-force sweep of the whole table, and that
|
||
equivalence now holds only for a table whose fixture declares no macros —
|
||
which its does not. And a scan no longer lexes a file to build this table: a cache hit
|
||
brings the words with the record, a parse harvests them from tokens it
|
||
already has, which is TODO §10's deferred item and −28 % to −31 % over a
|
||
667-file scan. The one thing that did move is order: `harvest` returns its words
|
||
sorted rather than in `HashSet` order. Nothing depended on the old order —
|
||
`Candidates` sorts everything it holds — but it is a change, and it is what
|
||
lets a record round-trip byte for byte.
|
||
- **A macro name is written with a backtick where it is used and without one
|
||
where it is defined or tested.** See *The backtick ruling* below.
|
||
- **`sortText` is a nudge, not a guarantee.** VS Code scores its own fuzzy match
|
||
first and uses `sortText` to break ties; a client that sorts purely on
|
||
`sortText` gets the tier order exactly. Both are correct behaviour, and the
|
||
tests assert what the server sends rather than what any client draws.
|
||
- **The response is capped at 512 items** (`LIMIT`), the module tier separately
|
||
at 64 (`MODULE_LIMIT`, M4's, unchanged). Justification under *The cap*.
|
||
|
||
## Handshakes
|
||
|
||
- **Widened in `vlog_parser`** — the only change outside `lucisv_server`.
|
||
`token.rs`'s keyword table became a `keywords![...]` macro invocation that
|
||
generates both `pub const KEYWORDS: &[&str]` and `pub fn is_keyword`;
|
||
`lib.rs` re-exports `KEYWORDS`. `is_keyword` is still a `matches!` over
|
||
literals, so the lexer's hot path is byte-for-byte the same code it was.
|
||
No word was added, removed or reordered.
|
||
- **Consumes `vlog_semantic`**: `Semantics::scopes`/`scope`/`symbol` for the
|
||
visible-declarations tier, `WorkspaceIndex::workspace_symbols`/`path`/
|
||
`files`/`defines` (all once per index build, never per request) for the
|
||
project-declares tier. Read-only; nothing new is asked of it.
|
||
`SymbolKind` → `CompletionItemKind` is a new mapping in `completion.rs`
|
||
mirroring the choices `symbols::lsp_kind` already makes for the outline in
|
||
the other enum.
|
||
- **Consumes `vlog_parser`**: `tokenize` for the word harvest, `KEYWORDS` for
|
||
the keyword tier, `defines::DefineKind` to keep `` `undef`` entries out of the
|
||
macro table.
|
||
- **Consumes `vlog_refactor`** — `instantiation_plan`, `render_with` —
|
||
through the planning half (`plan_for`), which since 2026-08-30 serves only
|
||
`inline.rs`'s ghost; `module_tier` itself reads no files. The
|
||
`module_definition` consumption ended with round 2 of inline-instantiation:
|
||
the file is chosen by `completion::nearest_definition` (most shared leading
|
||
path components with the asking buffer, then shallowest, then
|
||
lexicographic), which never refuses on multiplicity the way
|
||
`module_definition` deliberately does. Nothing in `vlog_refactor` was
|
||
touched, then or since.
|
||
- **Stopped consuming `vlog_refactor::module_names` (2026-08-28).** That
|
||
function is `WorkspaceIndex::workspace_symbols("")` filtered to modules, and
|
||
`workspace_symbols` builds and sorts a record per declaration in the whole
|
||
workspace — 43 140 of them in opentitan, on *every keystroke*.
|
||
`Candidates::modules` is the same list, built once beside the index and
|
||
filtered per request, and
|
||
`candidates::tests::the_module_table_answers_exactly_what_module_names_answers`
|
||
asserts the two agree — set *and* order — at eleven queries.
|
||
`vlog_refactor::module_names` is unchanged and still has its own callers;
|
||
only tier 0 stopped asking it. **Note for whoever changes it**: the two are
|
||
now pinned against each other by that test, so a change to `module_names`'s
|
||
match rule or ordering breaks the build rather than silently diverging.
|
||
- **Reads `WorkspaceIndex::units`'s `Def::name_span` directly (2026-08-28)**,
|
||
to anchor the header slice (`module_header`). Treated as advisory, never as
|
||
truth: the byte range is checked against the text actually read, and a
|
||
mismatch — a file edited on disk since the last scan — declines the slice
|
||
and parses the whole file, exactly as before.
|
||
- **Duplicated deliberately, not shared**: `vlog_refactor::ports::visible_in`
|
||
answers "is this *one* name visible here" and is `pub(crate)` to that crate;
|
||
`completion::visible_symbols` answers "what is visible here". They share the
|
||
innermost-scope idea and nothing else, and lifting one to fit both would have
|
||
meant widening another crate's API for a second caller that wants a different
|
||
answer. Recorded so the lead can overrule it cheaply.
|
||
- **Promises `lucisv_server`'s own callers**: `completions` never panics, and
|
||
always returns items whose `textEdit` replaces exactly the typed word (plus
|
||
the backtick, in the macro case).
|
||
- ~~"never returns a module item whose text differs from what M4 returned"~~ —
|
||
**superseded 2026-08-30** by the owner's two-level ruling. A tier-0 item now
|
||
inserts the module's **name**; the instantiation is ghost text served by
|
||
`inline.rs`, planned once, for the one module the user has spelled out. The
|
||
byte-for-byte skeleton pins moved with it. See
|
||
`docs/features/inline-instantiation/README.md`.
|
||
- **Provides `at_instantiation_site` (new, 2026-08-30, `pub(crate)`)** — tier
|
||
0's own position gate, lifted out of `completions` so `inline.rs` asks the
|
||
identical question rather than growing a second answer to it. `plan_for` and
|
||
`snippet_hole` became `pub(crate)` for the same caller; `module_header`
|
||
already was. Nothing about what any of the three computes changed.
|
||
- **`editors/vscode` needs no change.** No new setting, no new capability: the
|
||
completion provider was already advertised, and `snippetSupport` is read the
|
||
same way.
|
||
|
||
## The tiers
|
||
|
||
`sortText` is `<tier digit><name>`, so the client sorts tier-first and
|
||
alphabetically within a tier.
|
||
|
||
| Tier | What | `CompletionItemKind` | Where it comes from |
|
||
|---|---|---|---|
|
||
| `0` | Module **names** (instantiation candidates) | `MODULE` | `Candidates::modules`, module-item position only |
|
||
| `1` | Declarations the scope chain at the cursor binds | the declaration's own kind | this file's `Semantics` |
|
||
| `2` | Packages, package members, typedefs, classes, modules, `` `define`` names | the declaration's own kind, `CONSTANT` for a macro | `WorkspaceIndex`, tabled at build time |
|
||
| `3` | Statement / item / declaration templates | `SNIPPET` | `templates.rs`, gated by position |
|
||
| `4` | Every reserved word | `KEYWORD` | `vlog_parser::KEYWORDS` |
|
||
| `5` | Every identifier used anywhere in the project | `TEXT` | token harvest, tabled at build time |
|
||
|
||
Two responses are **exclusive** and contain none of the six: the backtick
|
||
response (`` `WI| ``, macro names only — *The backtick ruling* below) and,
|
||
since 2026-09-02, the **member** response after a `.` or a `::` (the members
|
||
of what stands before it, `sortText` digit `0`, nothing else at all). Neither
|
||
is a tier; each is the whole answer to a different question, and the tier
|
||
table above is what a *plain identifier* gets. See
|
||
`docs/features/member-completion/README.md`.
|
||
|
||
Tier 0 is first because at module-item position a module name is what the user
|
||
is reaching for — and, since 2026-08-30, a *name* is all it inserts: the
|
||
instantiation follows as ghost text once the name is spelled exactly and a
|
||
space typed after it (`docs/features/inline-instantiation/README.md`). For a
|
||
module declared in more than one file, the item's detail names the copy the
|
||
ghost will read (`nearest_definition`'s pick for this buffer). It is still the only tier
|
||
that is *position*-gated at all: M4's gate (nothing but whitespace before the word on its line, plus
|
||
`pairs::analyze`'s scope chain) is unchanged and still declines inside a
|
||
procedural block, a function, a class, a connection list and an expression.
|
||
Every other tier ignores position entirely — a name is a name wherever it is
|
||
written — which is why M4's "nothing is offered here" tests became "no
|
||
*skeleton* is offered here".
|
||
|
||
**Amended 2026-09-02.** That last sentence is still true of the tiers and no
|
||
longer true of the *response*. Two byte sequences immediately before the typed
|
||
run — a `` ` `` and, now, a `.` or a `::` — make the answer something other
|
||
than the six tiers: they say what kind of name may be written here at all, and
|
||
the response becomes only that kind. The difference from tier 0's gate is
|
||
worth stating, because it is the difference between withholding items and
|
||
replacing the answer: tier 0 declining leaves the other five to answer, where
|
||
a separator leaves nothing else to say. An unreadable or unresolvable head
|
||
after a separator therefore answers **nothing** rather than falling back to
|
||
the six tiers — which, until 2026-09-02, is exactly what the cursor after a
|
||
dot got: the whole-index dump, 512 items of everything.
|
||
See `docs/features/member-completion/README.md`.
|
||
|
||
Tier 5 deliberately includes names that are **not** visible at the cursor. That
|
||
is the point of it: it is the rope / VS Code word-completion tier, and a name
|
||
used three files away is a better guess than nothing. It is last, and it is
|
||
`TEXT`, so it never pretends to be a resolved symbol.
|
||
|
||
Dedup is by label, first tier wins. A name that is both a local declaration and
|
||
a word used elsewhere in the project is offered once, in tier 1, with its real
|
||
kind and its declaration line as detail.
|
||
|
||
### Amendment, 2026-08-30 — how a tier *matches*
|
||
|
||
Tier ordering, `sortText`, dedup, the caps and the position gates are all
|
||
unchanged. What changed is the comparison three of the tiers make, and only
|
||
from the third typed character up:
|
||
|
||
| Tier | Matched by, ≥3 characters typed | Was |
|
||
|---|---|---|
|
||
| `0` module names | substring | substring — unchanged |
|
||
| `1` declarations in scope | **subsequence** | prefix |
|
||
| `2` index names | **subsequence** | prefix |
|
||
| `2` `` `define`` names | prefix — unchanged | prefix |
|
||
| `3` templates | prefix — unchanged | prefix |
|
||
| `4` keywords | prefix — unchanged | prefix |
|
||
| `5` project words | **subsequence** | prefix |
|
||
| the backtick response | prefix — unchanged | prefix |
|
||
|
||
**Below three characters every tier matches exactly as it did before**, item
|
||
for item. The one thing that had to change there is `isIncomplete`: a 1- or
|
||
2-character response now always sets it, because VS Code re-asks the server
|
||
only when the last answer said so, and a complete 2-character answer would
|
||
swallow the third keystroke — the one that turns subsequence matching on.
|
||
|
||
Within a tier the fuzzy hits are ordered prefix-first, then by a boundary /
|
||
contiguity / gap score, then by name; that order is the order of the `items`
|
||
array, and decides which items survive the cap. `sortText` is still
|
||
`<tier digit><name>` and still means the tier order and nothing else.
|
||
|
||
Rules, scoring, the `isIncomplete` argument and the measurements are in
|
||
`docs/features/fuzzy-completion/README.md`. The prefix API this file describes
|
||
(`Candidates::units`/`words`/`macros`/`modules`/`has_module`) is untouched and
|
||
still answers exactly what it answered.
|
||
|
||
## The backtick ruling
|
||
|
||
`` `define`` names are the one candidate whose spelling depends on where the
|
||
cursor is, so the rule is stated rather than implied:
|
||
|
||
- **The cursor follows a backtick** (`` `WI| ``) — the response is *only* macro
|
||
names, because nothing else may follow a backtick. Each item is labelled and
|
||
inserted as `` `NAME ``, and the replaced range starts at the backtick the
|
||
user already typed, so it is never doubled.
|
||
- **The cursor does not follow one** (`WI|`) — macro names are offered
|
||
alongside everything else, bare, and **no backtick is invented**. Inserting
|
||
punctuation the user did not type is how a completion list loses trust, and
|
||
bare is the correct text at exactly the places a macro name is written without
|
||
a backtick: `` `ifdef NAME ``, `` `ifndef NAME ``, `` `undef NAME ``,
|
||
`` `define NAME ``.
|
||
|
||
Both spellings are tested. `` `undef`` entries are not offered: lucisv does not
|
||
preprocess and cannot say where a name stopped being defined, so a table that
|
||
listed them would be pretending to know.
|
||
|
||
## The cap
|
||
|
||
512 items per response, `isIncomplete` when it truncates. The arithmetic: an
|
||
*empty* prefix is the worst case, and 64 modules + 181 keywords + whatever one
|
||
scope binds still leaves room for the word tier to appear at all, which a
|
||
64-item cap (M4's) would not — the list would have ended inside the keywords.
|
||
512 small items is a payload of a few tens of kilobytes, and the tiers fill in
|
||
order, so what a truncation drops is the least useful end.
|
||
|
||
The module tier keeps its own 64, because it is the one tier that costs
|
||
*parsing*: one parse of one defining file per item. Every other tier is a binary
|
||
search into a sorted table.
|
||
|
||
Truncation is cheap by construction: each tier asks `Items::full()` before
|
||
building an item and breaks out of its loop when the answer is yes, so a full
|
||
response never formats a `detail` string nobody will read. Skipping that check
|
||
cost 8.5 ms on the corpus's empty-prefix request; with it, 212 µs.
|
||
|
||
## Performance
|
||
|
||
Measured on the 860-file corpus (4.94 MB of source: picorv32, ibex,
|
||
common_cells, OpenTitan), release build, aarch64-apple-darwin. The permanent
|
||
regression guard is
|
||
`completion::tests::a_keystroke_over_the_whole_corpus_stays_in_budget`, which
|
||
skips when `corpus/` is not checked out and asserts a deliberately loose 150 ms
|
||
per request — it is there to catch an order of magnitude, not to pin a number.
|
||
|
||
**Build (once per index rebuild: `initialize`, `didSave`, a settings change):**
|
||
|
||
| Step | Time |
|
||
|---|---|
|
||
| `WorkspaceIndex::build` (pre-existing) | 165 ms |
|
||
| `Candidates::build` — the new tables | **94 ms** (word harvest alone: 88 ms) |
|
||
| whole `open_roots`: walk + read + index + tables | 344 ms |
|
||
|
||
The new tables therefore add ~57 % to what the index build already cost, and
|
||
~27 % to the whole rebuild. The word harvest is one extra `tokenize` pass over
|
||
the same sources the index reads; it is not shared with the index's own lex
|
||
because `WorkspaceIndex::build` does its lexing privately, and asking it to hand
|
||
back token streams would be a new cross-crate contract for one caller.
|
||
|
||
Deduplicating *during* the harvest rather than after it matters more than the
|
||
lexing does: the corpus holds ~900 k identifier tokens and 16 750 distinct
|
||
identifiers, and copying every token only to sort the copies away cost 197 ms
|
||
against the 88 ms it costs now.
|
||
|
||
**Tables and memory:**
|
||
|
||
| Table | Entries | Heap |
|
||
|---|---|---|
|
||
| index names (units + members) | 7 728 | |
|
||
| `` `define`` names | 361 | |
|
||
| project words | 16 750 | |
|
||
| all three | | **~1.4 MiB** |
|
||
|
||
**Per request (what a keystroke costs):**
|
||
|
||
| Case | Worst of ten, release | Worst of ten, debug |
|
||
|---|---|---|
|
||
| typed prefix, mid-expression | **298 µs** | 1.3 ms |
|
||
| empty prefix (explicit invoke — every tier matches, the cap does the work) | **212 µs** | 1.1 ms |
|
||
|
||
A prefix lookup itself is ~76 ns (1 000 lookups in 76 µs): the tables are
|
||
sorted case-insensitively, so a match is a `partition_point` and then a
|
||
`take_while` over one contiguous run. Nothing allocates a lowercase copy —
|
||
`lower_cmp` compares byte iterators.
|
||
|
||
The one request that was *not* microseconds was a module-item position, which
|
||
parsed up to 64 defining files. Two rounds took that apart: the header slice
|
||
below (2026-08-28) and, finally, the two-level split (2026-08-30) that stopped
|
||
the popup planning anything at all. Tier 0 is now a scan of a table like every
|
||
other tier.
|
||
|
||
### The module tier, 2026-08-28
|
||
|
||
That last paragraph was the whole bill. `performance.md` §6d measured
|
||
completion at **34–66 ms per keystroke** against opentitan, worst at 0–4 typed
|
||
characters, and typing an eleven-character identifier at **201 ms** of blocked
|
||
single-threaded loop. The probe
|
||
(`perf::completing_one_keystroke_at_a_time`) runs the same request with the
|
||
cursor at module-item position and inside an expression, where tier 0 is gated
|
||
off:
|
||
|
||
| generated corpus, 4 000 files | at an item | in an expression |
|
||
|---|---:|---:|
|
||
| empty prefix, before | 53.2 ms | 0.19 ms |
|
||
| empty prefix, after | **3.17 ms** | 0.19 ms |
|
||
|
||
Every other tier put together is 0.19 ms and always was. Two changes, neither
|
||
of which may alter an item:
|
||
|
||
1. **`module_header` — parse the header, not the file.** A plan reads a
|
||
module's parameter list and port list and nothing else, and both are in the
|
||
header; the body was being parsed to reach them. The slice is the file's
|
||
text up to the `;` that ends the header, **kept byte for byte** so every
|
||
span the plan reads still points where it did, with an `endmodule` written
|
||
in place of the body. It is anchored on the index's `Def::name_span`
|
||
(checked against the text, so a file edited under the index declines rather
|
||
than slices at a stale offset) and the end is found by lexing a bounded
|
||
window and walking a **whitelist**: `static`/`automatic`, `import …;`,
|
||
`#(…)`, `(…)`, `;`. Anything else answers "no slice" and the whole file is
|
||
parsed exactly as before — `module aes import aes_pkg::*; #(…) (…);` writes
|
||
three semicolons and only the last ends the header, which is why this is a
|
||
whitelist and not a search for the first `;`.
|
||
2. **`Candidates::modules` — table the module names.** See Handshakes.
|
||
|
||
Two guards keep the answer identical, and both are load-bearing rather than
|
||
decoration:
|
||
|
||
- **A non-ANSI port list writes its directions in the module *body***
|
||
(`module m (a); input wire [7:0] a;`), which is the part the slice drops. A
|
||
plan whose ports have neither a direction nor a type is the signature of
|
||
that, and `plan_for` re-plans from the whole file when it sees one.
|
||
`a_non_ansi_port_list_is_planned_from_the_whole_file` asserts both halves —
|
||
that the header alone really does lose them, and that the guard really does
|
||
get them back.
|
||
- **A slice that fails to plan is re-planned whole**, so the list can only
|
||
ever lose an item where it would have lost it anyway.
|
||
|
||
`the_header_slice_plans_exactly_what_the_whole_file_plans` is the argument, not
|
||
the prose: fifteen header shapes — imports, two imports, no ports, an empty
|
||
port list, non-ANSI with and without body declarations, a comment inside the
|
||
header, a lifetime qualifier, a directive between the name and the port list, a
|
||
directive *inside* the port list, an escaped module and port name, a second
|
||
module before and after the one being planned, and a header wider than the
|
||
first window rung — each planned both ways and compared field by field.
|
||
|
||
`HEADER_WINDOWS` is a ladder because the lex is the whole cost of the slice and
|
||
it is linear in what it is handed. The rungs are measured, not guessed: over
|
||
opentitan's 344 RTL modules 59% of headers end inside 256 bytes and 90% inside
|
||
2 KB, and the largest is 6.6 KB — so a top rung of 16 KB, because a rung that
|
||
is too small is not a wrong answer but a 2–4 ms whole-file parse. The full
|
||
before/after, including the four `aes_control*` modules that found this, is in
|
||
`docs/perf/README.md`, *Before / after — round 7*.
|
||
|
||
Against the real checkout, over the wire: **63–66 ms → 13.1–15.0 ms** at the
|
||
empty prefix, and typing `aes_reg_top` **200.9 ms → 64.5 ms**. What was left
|
||
was 64 real header parses, and the two ways down from there — memoizing the
|
||
plan, or `completionItem/resolve` — both changed something that round was not
|
||
allowed to change.
|
||
|
||
### The module tier, 2026-08-30
|
||
|
||
The owner took the third way: **stop planning on the popup path entirely.**
|
||
Tier 0 answers with module *names*, and the instantiation is offered as ghost
|
||
text once the user has typed a name exactly — one plan, for one module, at the
|
||
moment they have said which one they mean. The 64 remaining header parses are
|
||
gone with it, and `module_header`/`plan_for` live on unchanged as the ghost's
|
||
planner. See `docs/features/inline-instantiation/README.md`; the numbers on
|
||
opentitan are QA's to record there.
|
||
|
||
## Version 0.3.0
|
||
|
||
Every place `tools/RELEASING.md` says the version lives, plus the install
|
||
examples it does not:
|
||
|
||
- [x] `Cargo.toml` `[workspace.package] version` → `0.3.0` (all eight crates
|
||
inherit it via `version.workspace = true`)
|
||
- [x] `Cargo.lock` regenerated by `cargo check --workspace` — eight entries
|
||
- [x] `editors/vscode/package.json` `"version"`
|
||
- [x] `editors/vscode/package-lock.json` `"version"` in **both** places (top
|
||
level and `packages[""]`)
|
||
- [x] `README.md` — the `code --install-extension dist/lucisv-0.3.0.vsix` example
|
||
- [x] `editors/vscode/README.md` — both install examples
|
||
- [x] `tools/RELEASING.md` — the `dist/` listing, the install commands, the
|
||
`git tag v0.3.0` example and the appendix's publish commands
|
||
- [x] `CHANGELOG.md` — a `0.3.0 — 2026-08-24` section in the existing voice:
|
||
one paragraph per area (filelists, rename, ports, module hinting,
|
||
completion, editors), each linking to its feature README
|
||
- [x] Verified: `target/debug/lucisv --version` → `lucisv 0.3.0`. Nothing
|
||
hard-codes a version string in Rust; `lucisv --version` and the server's
|
||
`serverInfo.version` both read `env!("CARGO_PKG_VERSION")`.
|
||
- [x] Verified: `node editors/vscode/smoke.js target/debug/lucisv-server` →
|
||
`smoke: OK`
|
||
|
||
Deliberately **not** touched: the `0.2.0` section of `CHANGELOG.md`,
|
||
`docs/features/release-prep/README.md` and `TODO.md`'s release entry — those
|
||
record what happened at 0.2.0 and are not install instructions. The literal
|
||
`0.2.0` strings in `lucisv_core/src/cache.rs`'s and `lucisv/tests/cli.rs`'s
|
||
corrupt-cache fixtures are deliberately malformed lines whose version field is
|
||
incidental; they exercise the parser, not the version.
|
||
|
||
## Status / TODO
|
||
|
||
- [x] `KEYWORDS` factored out of the lexer's table without changing lexing
|
||
- [x] `candidates.rs`: the two project-wide tables, built with the index
|
||
- [x] Tier 1 — visible declarations, with kinds and declaration lines
|
||
- [x] Tier 2 — index names and `` `define`` names, with the backtick ruling
|
||
- [x] Tier 3 — keywords
|
||
- [x] Tier 4 — token-harvested project words, current buffer overlaid live
|
||
- [x] Comment/string gate, both directions
|
||
- [x] Dedup across tiers, `sortText` tier ordering, prefix filter, cap +
|
||
`isIncomplete`
|
||
- [x] Every M4 completion test green, module skeletons byte-identical
|
||
- [x] e2e stdio round trip for the new tiers
|
||
- [x] Corpus performance measured and guarded
|
||
- [x] Version 0.3.0 across the workspace, the extension and the docs
|
||
- [x] `cargo fmt --all -- --check`, `cargo clippy --all-targets`,
|
||
`cargo test --workspace` all clean; `smoke.js` OK
|
||
- [x] **Performance wave, Lane B (2026-08-28):** completion 34–66 ms per
|
||
keystroke → 13–15 ms worst case on opentitan and 3.2 ms on the
|
||
same-sized generated corpus, with the items pinned identical. Tier 0
|
||
parses the header instead of the whole declaring file
|
||
(`module_header` / `plan_for`), and the module-name list is a table
|
||
built with the index (`Candidates::modules`) instead of a
|
||
whole-symbol-table sort per keystroke.
|
||
|
||
## Work log
|
||
|
||
- **2026-08-28 (dev, performance wave Lane B)** — the module tier.
|
||
|
||
Profiled first, as the brief asked, with an `#[ignore]`d house probe rather
|
||
than a guess: `perf::completing_one_keystroke_at_a_time` measures the whole
|
||
request at nine prefixes with tier 0 on and off. The answer was that
|
||
**everything except tier 0 costs 0.19 ms at every prefix**, so
|
||
`performance.md`'s hypothesis — "scanning/filtering the candidate set, and
|
||
the broader the prefix the more of the 3 976-file symbol table is walked" —
|
||
was half right: the symbol-table walk was real but it was
|
||
`vlog_refactor::module_names`'s, inside tier 0, not the word or index tiers'.
|
||
|
||
What changed is in *The module tier, 2026-08-28* above, with the identity
|
||
argument and the fifteen-shape test that carries it. Two decisions worth
|
||
naming:
|
||
|
||
- **No cache.** The obvious fix is to memoize the plan per module. It was not
|
||
taken: `Candidates` is rebuilt at `didSave`, and tier 0 reads
|
||
`ws.text_of`, which sees an *unsaved* buffer — so a cache there would go
|
||
stale exactly where `another_open_buffer_overlays_disk_once_the_index_is_rebuilt`
|
||
says it must not. Slicing needed no new invalidation rule at all, and it
|
||
makes the cold request fast rather than only the repeat.
|
||
- **The whitelist is a whitelist.** `header_end` refuses every shape it does
|
||
not recognise instead of scanning for the first `;`. `module aes import
|
||
aes_pkg::*; #(…) (…);` is the case that makes the difference, and it is
|
||
what most of opentitan's `aes*` modules are written as: a first-`;` scan
|
||
would have silently reported them as having no ports.
|
||
|
||
Deviations from the brief: none on this item. The measurement is on
|
||
`docs/perf/README.md` rather than here, because that is where this
|
||
repository keeps before/after numbers; this section keeps the argument.
|
||
|
||
- **2026-08-24 (dev)** — implemented.
|
||
|
||
**Keyword list.** `vlog_parser/src/token.rs`'s `is_keyword` was a 181-arm
|
||
`matches!`. Rather than write a second copy of the list, the whole thing is
|
||
now one `keywords![...]` invocation of a local `macro_rules!` that expands to
|
||
both `pub const KEYWORDS` and `pub fn is_keyword` — so `is_keyword` is still a
|
||
`matches!` over literals (no linear scan on the lexer's hot path) and the two
|
||
cannot drift. The explanatory comments inside the list survived the move. Two
|
||
tests added in `token.rs`; the parser suite (185 → 187 lib tests, all four
|
||
targets) is green.
|
||
|
||
**Tables (`crates/lucisv_server/src/candidates.rs`, new).** `Candidates` holds
|
||
three sorted vectors — index names, macro names, project words — built in
|
||
`Workspace::rebuild_index` from the same `collect_sources()` list the index
|
||
gets. That is what makes the scope ladder and the open-buffer-beats-disk rule
|
||
apply to completion for free, with no second walk. Lookup is
|
||
`partition_point` on a case-insensitive comparator, returning a slice.
|
||
|
||
**Tiers (`completion.rs`).** `completions` grew a gate
|
||
(`in_comment_or_string`, plus "no tokens, no answer") and five tier functions
|
||
feeding one `Items` builder that owns dedup, the cap and `isIncomplete`.
|
||
M4's `completions` body is now `module_tier`, unchanged except that it is
|
||
conditional instead of an early return, and its item gained a `sortText`.
|
||
`typed_word` grew two fields: `backtick` (was the run preceded by one) and
|
||
`at_line_start` (M4's second gate, now used only by tier 0).
|
||
|
||
**Decisions worth flagging to the lead:**
|
||
1. **M4's "nothing is offered" tests had to change meaning.** Nine of them
|
||
asserted `completions(...).is_none()` at positions where general
|
||
completion is exactly what a user wants (mid-expression, inside an
|
||
`always` block, inside a function). They are now "no *skeleton* is
|
||
offered here", checked on `sortText`'s tier digit; the skeleton text and
|
||
the module gate are untouched, and the e2e assertions changed the same
|
||
way. This is the one place the milestone genuinely broadens behaviour
|
||
M4 shipped, and it is what the M5 brief asked for — recorded so it is
|
||
reviewed rather than assumed.
|
||
2. **The cap went 64 → 512** for the response as a whole, with the module
|
||
tier keeping 64. Arithmetic under *The cap*.
|
||
3. **The backtick ruling** — only macros after a backtick, bare macro names
|
||
without one, no backtick ever invented. Under *The backtick ruling*.
|
||
4. **`SystemIdent` tokens (`$display`, `$clog2`) are harvested as words.**
|
||
They are identifiers used in the project and `$` is already an
|
||
identifier character as far as the typed-word scan is concerned, so
|
||
`$clo|` completes. Cheap, and it is what "identifiers used anywhere in
|
||
the project" says.
|
||
5. **A buffer that does not lex is declined outright** rather than answered
|
||
without a comment/string gate.
|
||
|
||
**Performance work.** Two measured fixes, both from the corpus harness rather
|
||
than from guessing: deduplicating the word harvest during collection (197 ms
|
||
→ 88 ms) and checking `Items::full()` before building an item (8.5 ms → 212 µs
|
||
on the empty-prefix request). Numbers under *Performance*.
|
||
|
||
**Version bump** per `tools/RELEASING.md`, checklist above, plus a
|
||
`CHANGELOG.md` 0.3.0 section covering M1–M5.
|
||
|
||
**Suite**: 1 232 → 1 262 workspace tests, all green; `cargo fmt --all --
|
||
--check` and `cargo clippy --all-targets` clean; `node
|
||
editors/vscode/smoke.js target/debug/lucisv-server` → `smoke: OK`.
|
||
|
||
## QA log
|
||
|
||
**2026-08-24 — QA agent.**
|
||
|
||
### Gates
|
||
|
||
- `cargo fmt --all -- --check` — clean.
|
||
- `cargo clippy --all-targets` — clean, zero warnings, workspace-wide.
|
||
- `cargo test --workspace` — green, **1262** tests (summed the per-crate
|
||
`test result` lines myself rather than trusting the printed total) —
|
||
matches the Work log's `1232 → 1262` claim exactly.
|
||
- `node editors/vscode/smoke.js target/debug/lucisv-server` — `smoke: OK`.
|
||
- `cargo build -p lucisv` then `target/debug/lucisv --version` → `lucisv 0.3.0`.
|
||
|
||
All gates: **pass, claims confirmed.**
|
||
|
||
### Priority 1 — the keyword-table refactor (`vlog_parser::token`)
|
||
|
||
Not eyeballed: extracted both word lists programmatically (regex over
|
||
`is_keyword`'s old `matches!` arms vs. the new `keywords![...]` invocation)
|
||
and diffed the two lists as Python sets and as ordered lists.
|
||
|
||
- Old list: 181 words, no duplicates. New list: 181 words, no duplicates.
|
||
- `old_set == new_set` → **True**. `old_words == new_words` (order too) →
|
||
**True**. Nothing added, dropped, reordered or typo'd.
|
||
- Read the macro expansion by hand: `matches!(s, $($word)|*)` expands to
|
||
exactly the same `matches!(s, "module" | "macromodule" | ...)` chain the
|
||
old hand-written function was — confirmed textually, not just by claim —
|
||
so the lexer's hot path really is byte-for-byte the same generated code.
|
||
- `crates/vlog_parser/src/lib.rs`'s diff is the expected one-line
|
||
`pub use token::KEYWORDS;`.
|
||
|
||
**Confirmed exactly as claimed.**
|
||
|
||
### Priority 2 — the nine repurposed M4 tests + the module-skeleton gate
|
||
|
||
Counted precisely rather than trusting "nine": `grep -c '.is_none()'` in the
|
||
old (`git show HEAD:.../completion.rs`) test module gives **8** call sites
|
||
across 6 functions (one of them a 4-case loop), plus **1** more in
|
||
`e2e.rs`'s `completion_and_signature_help_round_trip_over_the_wire` (the
|
||
`assert!(inside["result"].is_null())` at the always_comb position) — **9
|
||
total**, matching the claim exactly once both files are counted together.
|
||
|
||
Diffed the gate itself: `at_module_item`, `enclosing_scopes`,
|
||
`is_procedural`, `balanced`, and the `ITEM_SCOPES`/`NOT_ITEM_SCOPES`/
|
||
`PROCEDURAL`/`STATEMENT_END` constants are **byte-identical** between
|
||
`git show HEAD:crates/lucisv_server/src/completion.rs` and the working tree —
|
||
only a doc comment above `completions` changed (`"module completions"` →
|
||
`"completions"`). The gate that decides *where* a skeleton may appear was
|
||
not touched.
|
||
|
||
Confirmed each of the 9 sites was repurposed consistently: the 8 unit-test
|
||
sites now assert `skeletons(&items).is_empty()` (module-tier-only, read off
|
||
`sortText`'s digit) rather than `completions(...).is_none()`, and the
|
||
e2e site now asserts no item has a `sortText` starting with `'0'` while the
|
||
general tiers *do* answer (`items.iter().any(|i| sortText doesn't start
|
||
with '0')`) — i.e. it went from "nothing at all" to "everything except a
|
||
skeleton", which is exactly the milestone's stated broadening.
|
||
|
||
**Confirmed exactly as claimed.**
|
||
|
||
### Attacks — comment/string exclusion
|
||
|
||
All of the following pass exactly as the feature promises (verified by
|
||
reading `in_comment_or_string`/`in_comment` and running the dev's own
|
||
tests, which cover every case listed in the brief):
|
||
|
||
- Identifier only in a comment, or only in a string → not a candidate
|
||
(`a_name_that_only_a_comment_or_a_string_holds_is_never_a_candidate`,
|
||
and independently in `candidates.rs`'s
|
||
`words_come_from_tokens_so_comments_and_strings_contribute_nothing`).
|
||
- Cursor inside a `//` comment, a `/* */` comment, and a string literal →
|
||
no response (`nothing_is_offered_inside_a_comment_or_a_string`, all four
|
||
sub-cases).
|
||
- Cursor immediately after a block comment's `*/` on the same line → code
|
||
again, completions answer (`the_byte_after_a_block_comment_is_code_again`).
|
||
- An unterminated block comment mid-file → `doc.tokens.is_empty()`, decline
|
||
outright (`a_buffer_that_does_not_lex_is_declined_rather_than_guessed_at`).
|
||
- Identifier in a string in an **unsaved** buffer overlay: structurally
|
||
guaranteed rather than merely tested — `word_tier`'s live scan of
|
||
`doc.tokens` filters to `Ident | SystemIdent` (`completion.rs:250-254`),
|
||
the same `TokenKind` gate `candidates.rs::is_word` uses for the
|
||
persisted table, so a string's contents can never surface as an `Ident`
|
||
token regardless of whether the buffer is saved.
|
||
|
||
No findings here.
|
||
|
||
### Attacks — the backtick
|
||
|
||
- `` `de<cursor> `` completes defines with the range including the
|
||
backtick, no doubling — dev's own
|
||
`a_backtick_offers_macro_names_and_only_macro_names` pins the exact
|
||
replaced range; re-verified by hand.
|
||
- Backtick with nothing typed after it (`` `<cursor> ``, no macros defined)
|
||
→ 0 items (probed). With macros defined → all of them, sorted
|
||
(probed: `` `<cursor> `` against `ALPHA`/`BETA` → `["`ALPHA", "`BETA"]`).
|
||
- Backtick inside a comment → `None` (probed: the comment gate in
|
||
`completions` runs before the backtick branch is ever reached, so this
|
||
is structural, not incidental).
|
||
- **Directive keywords (`ifdef`, `endif`, `undef`, `include`, `timescale`,
|
||
…) get no completion help anywhere — LOW, not filed as blocking.**
|
||
Probed: `` `ifd<cursor> `` (typing toward `` `ifdef ``) → `None`.
|
||
Mechanism: `` `ifdef FOO `` lexes as one `TokenKind::Directive` token
|
||
(`vlog_parser/src/token.rs`), so `ifdef`/`endif`/etc. are never `Ident`
|
||
tokens (can't reach the word tier) and are deliberately absent from
|
||
`KEYWORDS` (the lexer's directive handling is a separate mechanism from
|
||
its keyword table, unchanged by this milestone). Typing a backtick then
|
||
a directive name routes into the backtick branch's macro-only answer,
|
||
which correctly finds no macro named `ifd*` and returns nothing. This
|
||
isn't a regression — there was no completion at all before M5 — and it
|
||
isn't inside this milestone's stated scope (keywords + project
|
||
identifiers), but it's a real, common gap (`` `ifdef `` is about as
|
||
frequent as any keyword) that the README's *Assumptions* and *The
|
||
backtick ruling* sections don't mention at all. Worth a line in the
|
||
README disclosing it, or a follow-up milestone; not blocking M5.
|
||
|
||
### Attacks — tiers, dedup, case
|
||
|
||
- A name that is both a local declaration and a project word: offered
|
||
**once**, tier 1, real kind — dev's own
|
||
`a_name_that_is_both_in_scope_and_a_project_word_is_offered_once`;
|
||
re-derived independently with a `Data`/`data` pair (see below).
|
||
- Module name at item position → skeleton (tier 0); at expression
|
||
position → offered as a plain tier-2 index item, `CompletionItemKind::
|
||
MODULE`, `PlainText`, no snippet (probed directly: `sub` at
|
||
`assign x = su|` comes back as tier `'2sub'`, not a skeleton). Correct —
|
||
matches "a name is a name wherever it is written" for every tier but 0.
|
||
- Case-insensitive **prefix** vs. case-sensitive **identity**: probed with
|
||
`logic data;` (local) and a project file declaring `logic Data;`
|
||
elsewhere. Typing `dat` (prefix, case-insensitive) surfaces **both**
|
||
`data` and `Data` as separate items — the prefix match doesn't collapse
|
||
them, and dedup (label-keyed) correctly treats them as different SV
|
||
identifiers. Exactly as required.
|
||
- The cap keeps the **best** tiers, not an arbitrary cut: probed a
|
||
workspace where tier 2 alone (600 `localparam`s in one package) exceeds
|
||
`LIMIT` on an empty prefix — response is exactly 512 items, all from
|
||
tier 2 (`has_word_tier: false`), `isIncomplete: true`. Consistent with
|
||
the tiers being filled in strict order and each one's `Items::full()`
|
||
guard stopping it immediately; not re-derived from scratch since the
|
||
dev's own `a_full_response_is_truncated_and_says_it_is_incomplete` and
|
||
the corpus test's "empty prefix fills the response to exactly LIMIT"
|
||
already pin the same mechanism.
|
||
- Empty prefix at item position: 187 items total, 2 module skeletons
|
||
(`sub`, and — see next finding — `top` itself).
|
||
|
||
**LOW, informational, not blocking — a module can offer itself as a
|
||
self-instantiation skeleton.** Probed: cursor at item position inside
|
||
`module top` with nothing typed → tier-0 skeletons offered are `["sub",
|
||
"top"]`. `module_tier` calls `vlog_refactor::module_names(ws.index(), "")`
|
||
unfiltered by the enclosing module, and that function is M4's, unchanged
|
||
(confirmed: `module_tier`'s body is untouched by this milestone). Not a
|
||
new bug — an M4-era gap in `vlog_refactor::module_names` — but M5 makes it
|
||
far easier to hit in practice: an explicit empty-prefix invoke
|
||
(VS Code's Ctrl+Space) at item position is a completion this milestone
|
||
specifically added support for (see *The cap*'s "empty prefix" arithmetic),
|
||
and it now surfaces "instantiate `top` inside `top`" as a real, clickable
|
||
suggestion. Filing against `vlog_refactor::module_names`/`instantiate.rs`,
|
||
not against this milestone's own code, since nothing in `completion.rs` or
|
||
`candidates.rs` introduced it.
|
||
|
||
### Attacks — scope ladder, invalidation, cap arithmetic
|
||
|
||
- 2-file + filelist fixture: dev's own
|
||
`a_file_outside_the_filelist_contributes_no_words` builds exactly this
|
||
(`files.f` listing only `listed.sv`) and confirms `word_unlisted` never
|
||
appears. Read the mechanism independently: `Candidates::build` is fed
|
||
the same `sources` list `rebuild_index` already restricted by the
|
||
filelist, so this is structural, not per-tier filtering.
|
||
- Which event updates candidates: confirmed by reading `server.rs` —
|
||
`reindex()` (which calls `Workspace::rebuild_index`, which rebuilds
|
||
`Candidates`) is called from `DidSaveTextDocument`, from `DidOpen` only
|
||
when there is no workspace root, and from `open_roots` at `initialize`.
|
||
`DidChangeTextDocument` does **not** call it. This matches the README's
|
||
"rebuilds on `initialize` and `didSave`" claim exactly — not "on every
|
||
edit". The buffer being typed in is still live because `word_tier`
|
||
separately re-scans `doc.tokens` (recomputed per `didChange`) on every
|
||
request, independent of the table. Probed the negative case the dev's
|
||
own test doesn't cover: edited *another* buffer without calling
|
||
`rebuild_index()` — the new word (`ov_in_buffer`) is correctly absent
|
||
(only the current buffer's own half-typed `ov` shows up, from the live
|
||
per-request scan). The dev's
|
||
`another_open_buffer_overlays_disk_once_the_index_is_rebuilt` shows the
|
||
positive half (present *after* `rebuild_index()`); together they pin
|
||
the exact rule stated in the README.
|
||
- Cap arithmetic isn't quadratic: ran the corpus budget test in release
|
||
(below). Separately probed a worst-case shape the corpus doesn't
|
||
naturally produce — sparse scope/index/keyword tiers (so `word_tier`'s
|
||
own `items.full()` guard does *not* short-circuit) against an
|
||
artificially huge word table (30 003 distinct identifiers, one file) —
|
||
512 items, `isIncomplete: true`, in **1.66 ms** (release build). Not
|
||
quadratic (n log n from the sort, bounded well under any budget this
|
||
test would need to guard), and not a finding: `word_tier` does collect
|
||
and sort the *whole* prefix-matched slice before applying the cap
|
||
rather than stopping at remaining capacity, which is a real but minor
|
||
inefficiency (the guard only short-circuits the *whole tier*, not a
|
||
partial one) — worth knowing about, not worth blocking on at these
|
||
numbers.
|
||
|
||
### Version 0.3.0
|
||
|
||
- `grep -rn "0.2.0"` over the whole tree (excluding `target/`): every hit
|
||
is one the dev's README lists as deliberately untouched — `CHANGELOG.md`'s
|
||
`0.2.0` history section, `TODO.md`'s release-prep line,
|
||
`docs/features/release-prep/README.md`'s own history, and the
|
||
malformed-cache-line fixtures in `lucisv_core/src/cache.rs` and
|
||
`lucisv/tests/cli.rs`. No stray `0.2.0` anywhere else.
|
||
- `cargo metadata` — all eight workspace crates report `0.3.0`.
|
||
`editors/vscode/package.json` and **both** places in
|
||
`package-lock.json` (top level and `packages[""]`) — `0.3.0`.
|
||
`Cargo.toml`'s `[workspace.package] version` — `0.3.0`.
|
||
`target/debug/lucisv --version` → `lucisv 0.3.0`.
|
||
- `CHANGELOG.md`'s `0.3.0` section: read against what actually shipped
|
||
(filelists, rename, ports, module hinting, completion, editors) —
|
||
accurate, no overclaiming; the completion paragraph's "860 real-world
|
||
files answer a request in about 300 µs" matches the measured number
|
||
below almost exactly.
|
||
|
||
**Confirmed exactly as claimed.**
|
||
|
||
### Performance
|
||
|
||
Re-ran `a_keystroke_over_the_whole_corpus_stays_in_budget` in `--release`
|
||
against the checked-out `corpus/` (860 files):
|
||
|
||
```
|
||
corpus: 860 files, 16750 words, 7728 index names;
|
||
index+tables built in 344.538ms;
|
||
worst request 296.917µs typed / 222.625µs empty
|
||
```
|
||
|
||
Matches the README's table almost exactly (298 µs / 212 µs claimed vs.
|
||
297 µs / 223 µs measured here — within normal run-to-run noise on a
|
||
loaded machine) and the file/word/index counts match exactly (860 / 16 750
|
||
/ 7 728). **Confirmed, not overclaimed.**
|
||
|
||
### e2e — real server binary over stdio
|
||
|
||
Ran the dev's own `crates/lucisv_server/tests/e2e.rs` tests as part of the
|
||
full-suite gate (both pass). Independently drove `target/debug/lucisv-server`
|
||
over stdio by hand (a small Python LSP client, not committed anywhere) for
|
||
the one case the dev's own e2e test doesn't explicitly assert on:
|
||
|
||
- **Keyword completion over the wire** — `initialize` → `didOpen` with
|
||
`assign x = alw` → `textDocument/completion` at the cursor. Real
|
||
response: 5 items, keyword items `always`/`always_comb`/`always_ff`/
|
||
`always_latch`, each with `"kind": 14` (LSP `Keyword`), `"sortText":
|
||
"3always"` etc., and a `textEdit.range` matching exactly the typed
|
||
`alw`. Confirms the keyword tier works correctly end-to-end.
|
||
- Project-word completion from another file, and inside-comment decline:
|
||
already covered by the dev's own
|
||
`keyword_and_project_completion_round_trip_over_the_wire`, which I
|
||
re-ran in isolation (`cargo test -p lucisv_server --test e2e
|
||
keyword_and_project_completion -- --nocapture`) — passes standalone.
|
||
|
||
**LOW, informational — the Status/TODO line "e2e stdio round trip for the
|
||
new tiers" (plural) is slightly optimistic.** `e2e.rs` asserts scope
|
||
(tier 1), index/macro (tier 2), word (tier 4), and the comment decline
|
||
over the wire, but never asserts a keyword-tier (tier 3) item by label or
|
||
`kind` — only that no item's `sortText` starts with `'0'`. The keyword
|
||
tier itself is thoroughly unit-tested
|
||
(`every_keyword_the_lexer_knows_is_offered`,
|
||
`the_keyword_tier_is_exactly_the_lexers_list`) and, per the probe above,
|
||
does work correctly over the wire — this is a documentation-accuracy /
|
||
test-coverage nit, not a functional gap. Not fixed (adding the assertion
|
||
is a one-line addition to the dev's existing e2e test, left for the dev
|
||
or a follow-up rather than touching test files outside a small,
|
||
unambiguous fix).
|
||
|
||
### Cleanup
|
||
|
||
All probing was done with temporary `qa_probe_*` `#[test]` functions added
|
||
to `crates/lucisv_server/src/completion.rs`'s existing `tests` module, run
|
||
with `--nocapture`, then fully reverted. Verified clean:
|
||
`grep -rn qa_probe crates/` — zero hits; `git diff --stat` for this file
|
||
matches the pre-QA baseline exactly (898 changed lines, same as
|
||
`git status` showed before QA started); final `cargo fmt --all -- --check`
|
||
+ `cargo clippy --all-targets` + `cargo test --workspace` (1262 passed)
|
||
re-run clean after cleanup.
|
||
|
||
### Verdict
|
||
|
||
**Ship.** Both priority items (the keyword-list refactor and the nine
|
||
repurposed tests) are verified programmatically, not by eyeballing, and
|
||
hold up exactly as claimed. Every other claim in the Work log — the three
|
||
sorted tables, the five tiers, the backtick ruling, the cap arithmetic,
|
||
the performance numbers, the version bump — checked out under direct
|
||
attack. Three LOW/informational findings, none blocking:
|
||
|
||
1. Preprocessor directive names (`` `ifdef ``, `` `endif ``, …) get no
|
||
completion assistance anywhere — a real, common gap, undisclosed in
|
||
the README, but out of this milestone's stated scope
|
||
(`vlog_parser::token`'s directive handling, untouched by M5).
|
||
2. A module can offer itself as a self-instantiation skeleton at an
|
||
empty-prefix, item-position completion — pre-existing to
|
||
`vlog_refactor::module_names` (M4), newly easy to trigger via M5's
|
||
empty-prefix support.
|
||
3. The e2e suite's "new tiers" coverage doesn't explicitly assert the
|
||
keyword tier by label/kind over the wire, though it works correctly
|
||
(independently verified by hand against the real binary).
|
||
|
||
No fixes applied to feature code — nothing found rose to "small,
|
||
unambiguous" (typo/missing assertion) territory; all three are judgment
|
||
calls for the dev/lead. No commits, no edits to `TODO.md` or the umbrella
|
||
`docs/features/refactor/README.md`.
|
||
|
||
### 2026-08-28 — QA agent (performance wave Lane B: the module tier)
|
||
|
||
Verdict: **the fix holds. No corruption found, one pre-existing parser gap
|
||
surfaced (filed below, not fixed here — out of this feature's touched
|
||
files).**
|
||
|
||
**What I attacked.** The whitelist walk in `header_end`, the guard in
|
||
`plan_for`, and `Candidates::modules`'s parity with
|
||
`vlog_refactor::module_names`, per the adversarial list in the round brief:
|
||
header-slice mis-slicing, stale-span handling, and the module-table's set
|
||
*and* order against hostile queries.
|
||
|
||
**Header-slice attacks — all safe, one gap in the dev's own test found and
|
||
fixed.** Extended `SHAPES` in `completion.rs` (in
|
||
`the_header_slice_plans_exactly_what_the_whole_file_plans`) with: a single
|
||
`import a::*, b::*;` declaration (comma-chained packages, one statement —
|
||
`skip_to_semicolon` must not stop at the first `::`), a parameter default
|
||
whose string literal contains a literal `;` and `)` (`"a;b)c"`), CRLF line
|
||
endings through the whole header, a genuine attribute instance right after
|
||
the module name, and one inside the port list on a single port. All five
|
||
plan identically sliced vs. whole-file; the two attribute shapes exposed
|
||
something worth recording (next paragraph). Added
|
||
`the_attack_shapes_actually_slice_rather_than_passing_the_pin_vacuously`
|
||
(`completion.rs`) asserting the first three actually invoke the slice path
|
||
(`module_header(..).is_some()`) rather than passing the comparison
|
||
vacuously by both sides falling back to the whole file — a real risk with
|
||
this style of pinned-equality test, since a shape the whitelist declines
|
||
passes the assertion for free.
|
||
|
||
**Finding (LOW, not a regression this round introduced) — `completion.rs`,
|
||
`module_header`, and transitively `vlog_semantic`/`vlog_parser`: a module
|
||
with an attribute instance (`(* ... *)`) anywhere near its header is not
|
||
indexed as a `Module` unit at all.** `WorkspaceIndex::units("attributed")`
|
||
and `..("port_attributed")` both come back empty for
|
||
`module attributed (* some_attr *) #(...) (...);` and
|
||
`module port_attributed (input logic clk, (* keep *) output logic q);`.
|
||
`module_header` correctly declines at its very first line (`let [def] =
|
||
index.units(module)...else { return None }`, `completion.rs:99-103`) —
|
||
this is the documented whole-file fallback working exactly as designed,
|
||
not a slicing bug — but it means completion's module tier, which sources
|
||
its candidate names from the same index, never offers such a module as a
|
||
completion candidate in the first place, attribute-based header or not.
|
||
This predates 2026-08-28 (the index-level gap is not something tier 0's
|
||
change touches), so it is filed rather than fixed: out of Lane B's stated
|
||
files (`vlog_semantic`/`vlog_parser` are not touched-file scope for this
|
||
round). Reproduction: `cargo test -p lucisv_server -- completion::tests::
|
||
a_module_with_an_attribute_near_its_header_is_not_indexed_at_all`, a new
|
||
permanent regression pinning the current (gap) behavior so a future fix to
|
||
the indexer is *noticed* here rather than silently changing what
|
||
`module_header` sees.
|
||
This also means the dev's own `noisy` shape's doc comment ("a comment and
|
||
an attribute inside the header") was inaccurate — it has two comments and
|
||
no attribute; I did not edit that comment since fixing it is a one-line
|
||
call for the dev, and the actual behavior is now separately pinned above.
|
||
|
||
**Stale-span attack**: `a_stale_index_span_declines_to_slice_rather_than_
|
||
slicing_the_wrong_bytes` (dev's own test) re-verified by hand — re-ran with
|
||
`cargo test -p lucisv_server -- completion::tests::a_stale_index_span` in
|
||
isolation, passes. No addition needed; the test already does the right
|
||
thing (name-span-vs-text mismatch declines).
|
||
|
||
**`Candidates::modules` parity**: `contains_ignore_case` (`candidates.rs`)
|
||
and `contains_ignore_ascii_case` (`vlog_semantic::workspace`) are
|
||
byte-identical implementations, and both `Candidates::modules` and
|
||
`vlog_refactor::module_names` ultimately filter the same
|
||
`workspace_symbols`-sorted, `container.is_none() && kind == Module` slice
|
||
with the same predicate — so parity is structural, not incidental, and
|
||
holds for any name content (case-different names, escaped identifiers,
|
||
duplicate names across files) without needing per-shape tests. Traced by
|
||
hand rather than by adding more cases to the dev's own
|
||
`the_module_table_answers_exactly_what_module_names_answers` (which
|
||
already covers duplicates-across-files and query-case-differences); no
|
||
counter-example found.
|
||
|
||
**Numbers reproduced** (release build, this machine, M1 Max):
|
||
- `perf::completing_one_keystroke_at_a_time`: empty prefix at item position
|
||
**3.28 ms** (dev's claim: 3.17 ms — within machine noise), expression
|
||
position 190 µs unchanged. Whole-file plan 2.68 ms vs. header-alone
|
||
16.3 µs for one skeleton off the 1214-line generated file — matches the
|
||
claimed order of magnitude.
|
||
- `LUCISV_PERF_CORPUS=/Users/guoliangchen/repo/opentitan cargo test
|
||
--release -p lucisv_server perf::completing_over_a_real_project`: empty
|
||
prefix **11.6 ms** (dev's claim against the real wire protocol: 13.1–15.0
|
||
ms; this is the in-process `completions()` call without LSP round-trip
|
||
overhead, so a bit faster is expected, same order of magnitude). Zero
|
||
modules fell back to whole-file parsing across every prefix tested
|
||
(`parsed whole: []`), confirming the slice fires in practice on real RTL,
|
||
not just in the synthetic corpus.
|
||
- Live end-to-end confirmation against the real opentitan checkout with
|
||
this worktree's release binary (`node`-free, via a copy of the
|
||
scratchpad's `lspclient.py`/`bench.py` pointed at
|
||
`target/release/lucisv-server`): completion itself was not re-measured
|
||
over the wire (out of scope to re-run the whole battery), but see the
|
||
references-nav QA log below for the documentHighlight leg of the same
|
||
session, which used the identical harness.
|
||
|
||
**Gates**: `cargo fmt --check`, `cargo clippy --all-targets`, `cargo test
|
||
--workspace` (1261 passed, up from 1259 with my additions), `node
|
||
editors/vscode/smoke.js target/release/lucisv-server` — all clean, run
|
||
against the worktree with my additional tests included.
|
||
|
||
No fixes applied beyond the two new permanent regression tests (attack
|
||
shapes actually slicing; the attribute-indexing gap pinned). No commits.
|
||
|
||
## Review
|
||
|
||
**2026-08-28 — lead, performance-wave Lane B.** Reviewed after QA's
|
||
SHIP; gates re-run on the worktree (fmt clean, clippy silent, 2495
|
||
workspace tests green). The header-slice design is right because of
|
||
what it refuses: a whitelist walk that re-plans from the whole file on
|
||
anything it does not positively recognize — including the non-ANSI
|
||
signature — is the honest shape, and QA's seven added attack shapes
|
||
plus the field-by-field plan-equality pin make the "items byte
|
||
identical" claim tested rather than asserted. The stale-span decline
|
||
and the Candidates::modules order-and-set parity are correctly pinned.
|
||
QA's LOW (attribute-instance modules not indexed as units — a
|
||
pre-existing parser/semantic gap the guard already declines safely) is
|
||
accepted as filed with its regression pin; it belongs to a parser
|
||
round, not this one. The residual opentitan cost is real header
|
||
parses, with the plan-cache and completionItem/resolve options filed
|
||
where the numbers are. Accepted.
|
||
|
||
**2026-08-24 — lead.** Reviewed after QA's ship verdict — the first
|
||
milestone through with no rework round; gates run independently (1262
|
||
tests, 0 failures, clippy silent). The keyword-table refactor was verified
|
||
set- and order-identical programmatically, the five-tier/sortText design is
|
||
the boring right shape, and 212–298 µs per keystroke over the 860-file
|
||
corpus with a budget test guarding it is exactly the performance story
|
||
wanted. The nine repurposed M4 tests are a genuine, intended broadening
|
||
(general completion where skeletons were rightly refused), with the
|
||
skeleton gate itself byte-identical. Dev's backtick ruling (never invent
|
||
punctuation) and decline-on-unlexable-buffer are accepted as argued.
|
||
QA's three LOW findings, ruled: (1) no completion help on preprocessor
|
||
directive words — accepted gap, now named in the umbrella backlog;
|
||
(2) self-instantiation skeletons — pre-existing M4 nit, backlog;
|
||
(3) e2e keyword-tier assertion — nice-to-have, not required. QA's
|
||
transparency note about a briefly clobbered-and-restored working file is
|
||
appreciated; the independent gate run confirms the tree. Accepted; M5 and
|
||
the 0.3.0 bump are checked off in the umbrella plan and TODO.md §8.
|