Every tracked file that can carry a comment (880 of them) now opens with "Author: Guoliang Chen, a Senior Digital Design Engineer" and closes with "Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com", in the file's own comment syntax. No behaviour change: the diff outside the version bump and changelogs is comment lines only. - tools/stamp_author.py: writes the lines; idempotent, `--check` lists what is missing. Headers go under a shebang and under Markdown front matter. - Left alone: test fixtures, cases and snapshots (byte-exact inputs), JSON and JSONL, logs, images, lockfiles, docs/site/dist (regenerated) and the LICENSE files (already carry the copyright line). - tools/linux_check.sh: --help reads its header from line 3, now that the author line sits under the shebang. - tools/gates.sh green on this tree: 5 545 tests, corpus 814/6 as before. Co-Authored-By: Claude Mythos 5.2 <[email protected]>
556 lines
32 KiB
Markdown
556 lines
32 KiB
Markdown
<!-- Author: Guoliang Chen, a Senior Digital Design Engineer -->
|
||
|
||
# hover-line-index
|
||
|
||
## Goal
|
||
|
||
The owner's report (2026-08-28): hovering a module instantiation is slow, and
|
||
hovering one of its ports — to see the port's own declaration — is slow on the
|
||
**first** try. Both land on the same code: a hover whose target is declared in
|
||
a *closed* file read that whole file and built a whole `LineIndex` over it, for
|
||
two things at once — the heading's `file:line`, and the fenced snippet of the
|
||
declaration. On a netlist-adjacent file that read is milliseconds, and nothing
|
||
was kept, so the *next* hover into the same file paid it again. The owner's
|
||
design, which this round implements: put each declared name's **line number**
|
||
into the index itself, where it costs a `u32` per declaration and is computed
|
||
once when the file is scanned. The heading then costs no file access at all,
|
||
and only the snippet still wants text — served from a small bounded cache of
|
||
closed files' text in `Workspace`, so the first touch pays one read and no
|
||
touch after it pays anything.
|
||
|
||
The shape of what that buys, measured below: a hover into a 12 MB closed file
|
||
goes **6.2 ms → 0.9 µs on the second hover** and stays 6.2 ms on the first;
|
||
the steady-state cross-file hover on a 10 000-line file goes **157 µs →
|
||
13 µs**. The round also *measured the other suspect* and did not fix it — see
|
||
Handshakes.
|
||
|
||
## Assumptions
|
||
|
||
- **A line is a fact about the same snapshot the span is.** `Def::name_span`
|
||
and `Def::lines.name` are read off one text in one pass, so a heading and a
|
||
snippet can never name different generations of a file. Where the file has
|
||
changed on disk with nothing telling the server, both are stale together,
|
||
which is strictly better than the previous shape — a stale *offset* looked
|
||
up in *fresh* text, whose line was arbitrary.
|
||
- **Lines are 1-based, and are exactly what `LineIndex::line_col` reports.**
|
||
That is what `locate::line_number` returned before, so the same headings come
|
||
out.
|
||
- **`FileFacts::from_analysis`'s caller has a line index already.** It is a
|
||
server holding an open buffer's finished `Document`, which carries one. So
|
||
the extra parameter costs the caller nothing, and `FileFacts::of` builds its
|
||
own — one pass over the source's newlines, about 1 % of the parse it sits
|
||
beside (`docs/perf/README.md`: `LineIndex::new` 115 µs against
|
||
`parse_tolerant` 14.3 ms at 10 000 lines).
|
||
- **The view cache is a cache and never a correctness input.** Every entry can
|
||
be dropped at any moment with no change to any answer; a *stale* entry can
|
||
only ever make a snippet disappear, never make it wrong, because
|
||
`hover::spells_exactly` still checks the text at the span against the hovered
|
||
name before anything is shown. That guard is unchanged and is still the last
|
||
line of defence.
|
||
- **Only closed files are cached.** `Workspace::file_view` returns `None` for a
|
||
path an open buffer speaks for: that buffer's `Document` already holds its
|
||
text and line index, and a second copy here would be a second opinion.
|
||
- **The index is still text-free.** A line number is not text, exactly as a
|
||
span is not text (`docs/features/workspace-index/README.md`'s promise, and
|
||
the same reading `port-detail-spans` took for `detail_span`).
|
||
|
||
## Handshakes
|
||
|
||
### `vlog_semantic` — `DeclLines`, and the carrier's extension story
|
||
|
||
```rust
|
||
/// Where a declaration sits in its file, counted in lines.
|
||
pub struct DeclLines {
|
||
pub name: u32, // 1-based line of the declared name
|
||
pub detail: Option<u32>, // 1-based line the detail span starts on
|
||
}
|
||
|
||
pub struct Def {
|
||
pub file: FileId,
|
||
pub name_span: TextRange,
|
||
pub kind: SymbolKind,
|
||
pub detail_span: Option<TextRange>,
|
||
pub lines: DeclLines, // new
|
||
}
|
||
|
||
// One added parameter, because a record now carries lines:
|
||
impl FileFacts {
|
||
pub fn from_analysis(path, tree, defines, sem, lines: &LineIndex) -> FileFacts;
|
||
}
|
||
pub const FACTS_FORMAT: u32 = 4; // was 3
|
||
```
|
||
|
||
**The carrier is one value per declaration, and it extends by gaining a
|
||
field.** That is the owner's explicit ask ("keep the implementation flexible so
|
||
we might even cache the port location") answered structurally rather than
|
||
promised:
|
||
|
||
- **Ports already ride it.** A module's ports and parameters are indexed as
|
||
*members*, and a member is a `Decl` exactly as a unit is — so
|
||
`index.member("sub", "addr").lines.name` is that port's line, recorded in the
|
||
same pass, with no extra table, no extra pass and no extra decision about
|
||
"small projects". The owner's optional second step was already paid for by
|
||
the first.
|
||
- **A split port's two lines ride it too.** A non-ANSI port is named in the
|
||
header and finished in the body (`detail_span`,
|
||
`docs/features/port-detail-spans/README.md`), and `DeclLines::detail` is that
|
||
body's line — the second position datum, already present, in the same value.
|
||
- **A third one is a field.** A column, a rendered preview, an end line: add it
|
||
to `DeclLines`, write it in `Writer::decl`, read it in `Reader::decl`, bump
|
||
`FACTS_FORMAT`. Nothing else moves, because nothing else knows how many
|
||
fields a `DeclLines` has. **Taken, 2026-08-29**, and it went exactly that
|
||
way: `docs/features/vscode-hierarchy-sidebar/README.md` added
|
||
`positions: Option<DeclPositions>` — the declared name's and the whole
|
||
declaration's ranges in the units a client counts in — for `FACTS_FORMAT`
|
||
4 → 5, so a design-hierarchy snapshot needs no file text at all. The one
|
||
amendment that round made to the story above: those positions ride
|
||
**file-scope declarations only**, because members outnumber units by two
|
||
orders of magnitude and the record's `U` and `M` groups are separate, so
|
||
the absence costs a member nothing. A member still carries its lines. A *parallel table* keyed by declaration was the
|
||
alternative and was rejected: it would have to be kept in step with `Decl`
|
||
through every merge, every incremental update and every record round-trip,
|
||
and there is no second consumer to justify the indirection
|
||
(`CLAUDE.md`, "Simplicity first").
|
||
|
||
### `vlog_semantic` — `FACTS_FORMAT` 3 → 4, justified
|
||
|
||
A record's per-declaration group grew two fields. The rule written at the
|
||
constant is that **any** change to what a record holds bumps the format, and
|
||
the reason it is a whole-store discard rather than a migration is
|
||
`docs/features/index-persistence/README.md`'s: a reader that guessed at an
|
||
older layout would read last month's field order as this month's. Concretely,
|
||
a format-3 record read as a format-4 one would shift every field after the
|
||
first declaration by two — which is why the format field in the store's header
|
||
catches it first, and why `decode` rejects it even if something served it past
|
||
the header (both pinned, see Tests). The cost is one re-parse of the workspace
|
||
on the first scan after upgrading; the corpus measurement below says that is
|
||
about 175 ms.
|
||
|
||
### `vlog_semantic` — fingerprint
|
||
|
||
`WorkspaceIndex::fingerprint`'s `sym` line now carries `line=` and `detail=`.
|
||
That is what makes the house witness — incremental index == fresh build —
|
||
cover the new field rather than ignore it; every existing equivalence test
|
||
(`update_file`, `update_facts`, `add_facts` from records, the corpus sweep)
|
||
now compares lines as well as spans, and all of them stayed green unmodified.
|
||
|
||
### `lucisv_server::state` — the closed-file view cache
|
||
|
||
```rust
|
||
pub struct FileView { pub path: PathBuf, pub text: String, pub lines: LineIndex }
|
||
impl Workspace {
|
||
pub fn file_view(&self, path: &Path) -> Option<Rc<FileView>>;
|
||
}
|
||
```
|
||
|
||
Bounded by **four entries** and **8 MiB of text**, newest first, oldest
|
||
evicted. Two bounds because they answer two questions: how many files one
|
||
answer can name (a card names one or two; a references list walks a handful
|
||
before moving on), and how much memory a netlist-shaped file may cost. The
|
||
newest entry is kept whatever it weighs — one file can exceed the whole byte
|
||
budget on its own, and a cache that refused to hold it would be useless for
|
||
exactly the file it exists for — so a huge file simply evicts everything else.
|
||
|
||
**Every invalidation point, in full.** A view is dropped when:
|
||
|
||
| event | what is dropped | why |
|
||
|---|---|---|
|
||
| `set_document(uri, text)` — `didOpen`, `didChange`, a text-carrying `didSave` | that path's view | the buffer becomes the authority, and the held disk copy may predate the edits it carries |
|
||
| `close_document(uri)` | that path's view | disk is the authority again, and the view predates every save that buffer made |
|
||
| `update_one(path)` | that path's view | re-indexing one file *is* the claim its bytes moved |
|
||
| `rebuild_index_with(..)` | **all** views | a rescan says nothing about which file moved |
|
||
|
||
Those four are every path in the server that can change what a file holds:
|
||
`server.rs` reaches the first two directly from the sync notifications, and the
|
||
last two through `reindex_one` / `reindex`, which is where a save, a watched
|
||
file change, a client file operation and a settings change all land.
|
||
|
||
What survives all four is a file changed on disk with nothing telling this
|
||
server — and there the *index* is stale by the same event, which is precisely
|
||
what `spells_exactly` exists for.
|
||
|
||
### `lucisv_server::locate` — the sweep
|
||
|
||
`locate::line_number` and `locate::location` were the only two functions that
|
||
read a whole file to answer a position question, and `line_number`'s only
|
||
callers were `hover.rs`'s two. Both now take an open buffer's own line index
|
||
when there is one and the shared view otherwise; neither reads a file directly
|
||
any more. `location`'s open-buffer arm also stops cloning the whole buffer text
|
||
(`text_of` returns a `String`) on the way to a range. Mechanical, no behaviour
|
||
change: `location` is what `textDocument/definition`, references, the lens and
|
||
the hierarchies build their `Location`s from, and a references list over one
|
||
file now reads that file once instead of once per site.
|
||
|
||
An indexed declaration's line no longer goes through `line_number` at all —
|
||
`Def::lines` is the answer. What is left for it is the spans the index records
|
||
no line for, which today is a `` `define``'s (the macro hover card's
|
||
`defined in file:line`). Those ride the shared view, so a second macro hover
|
||
into one file is free; giving `Define` its own line would mean a field in
|
||
`vlog_parser`'s `Define` and is filed rather than done — it buys the first
|
||
touch of one card and costs a second crate a field.
|
||
|
||
### Suspect 2 — **reported, not fixed here; DELIVERED 2026-08-28** by `docs/features/scan-interleave/README.md`
|
||
|
||
The brief named a second suspect and asked for it to be measured and filed
|
||
rather than redesigned. It is real, and on the owner's own complaint it is by
|
||
far the larger of the two:
|
||
|
||
`Server::new` runs the whole startup scan **before** `run()`'s message loop
|
||
takes its first message. `main.rs` answers `initialize` (through
|
||
`initialize_finish`, which also consumes `initialized`) and only then builds
|
||
the `Server` — so everything a client sends the instant the handshake is done
|
||
sits in the OS pipe until the scan is over. Measured over a 200-file, 1 000-
|
||
line-each workspace with a filelist (so the startup scan really indexes it):
|
||
|
||
| the first hover of a session | cold store | warm store |
|
||
|---|---:|---:|
|
||
| issued the moment `initialized` was sent | **780 ms** | **287 ms** |
|
||
| the same hover once the scan is done | 64 µs | 61 µs |
|
||
|
||
Four orders of magnitude, and this round does not touch it: fixing it means
|
||
answering requests during the scan (or scanning on another thread), which is a
|
||
change to request scheduling and to what an answer *means* while the index is
|
||
half-built. `docs/features/index-persistence`'s store already takes it from
|
||
780 ms to 287 ms; the rest is the read, the completion word table's lex and
|
||
the include scan, which that feature's README already names as uncached.
|
||
**Request to whoever owns the message loop next:** this is where "the first
|
||
hover is really slow" mostly lives, and the probe that measures it is
|
||
`e2e::a_hover_issued_during_the_initial_scan_waits_for_it`.
|
||
|
||
**DELIVERED, 2026-08-28.** `docs/features/scan-interleave/README.md` took the
|
||
scan apart into per-file steps and drains the message queue between them, so a
|
||
startup scan long enough to be worth it answers requests while it runs. The
|
||
same probe, flipped and renamed
|
||
(`e2e::a_hover_issued_during_the_initial_scan_is_answered_during_it`), now
|
||
reports **15.5 ms cold / 12.8 ms warm** where the table above says 780 / 287 —
|
||
and the scan's own total moved by under a percent. The request is closed; what
|
||
that round did *not* do (the files are still read eagerly, a rescan still makes
|
||
requests wait) is filed in its own Status/TODO with numbers.
|
||
|
||
## Measured
|
||
|
||
Machine and method are `docs/perf/README.md`'s: Apple M1 Max, macOS 27.0,
|
||
`--release`, `#[ignore]`d probes, `--test-threads=1`, means where the numbers
|
||
are small enough to need one. Every figure below was taken on 2026-08-28,
|
||
before and after, in the same session.
|
||
|
||
### Suspect 1 — the per-hover read
|
||
|
||
| what | before | after |
|
||
|---|---:|---:|
|
||
| hover on an **instantiation** into a 12 MB closed file, first touch | 6.47 ms | 6.23 ms |
|
||
| — the same hover again | 5.75 ms | **0.95 µs** |
|
||
| hover on a **port** into the same file, first touch | 5.85 ms | 5.92 ms |
|
||
| — the same hover again | 5.71 ms | **0.99 µs** |
|
||
| hover into a 31.7 MB closed file, first touch (QA's own probe) | 17.0 ms | 16.8 ms |
|
||
| — the same hover again | 17.0 ms | **4.4 µs** |
|
||
| cross-file hover, 1 000-line target, mean of 20 | 39.8 µs | **4.7 µs** |
|
||
| cross-file hover, 10 000-line target, mean of 20 | 157 µs | **12.9 µs** |
|
||
| — one read + `LineIndex` of that file, for comparison | 149 µs | 158 µs |
|
||
|
||
Read the table as two claims. **The first touch is unchanged**, and it should
|
||
be: the snippet genuinely wants that file's text, and reading it is what the
|
||
6.2 ms is. **Every touch after it is free**, which is the shape the owner's
|
||
"slow on the FIRST try" report describes — and the heading half is free even
|
||
on the first touch, which is why a card with no snippet (an unreadable file, a
|
||
guard miss) now costs nothing at all.
|
||
|
||
### The price paid for it
|
||
|
||
| | before | after |
|
||
|---|---:|---:|
|
||
| whole 860-file corpus scan, no cache | 338 ms | 343 ms |
|
||
| — cold, filling the store | 372 ms | 374 ms |
|
||
| — warm, every file from the store | 197 ms | 200 ms |
|
||
| the store, 860 files | 2 312 802 B | 2 380 790 B |
|
||
|
||
The scan times are inside their own run-to-run noise: the added work is one
|
||
`LineIndex::new` per parsed file, which the flush breakdown puts at under 1 %
|
||
of that file's parse. The store grows **68 KB over 860 files — 2.9 %**, which
|
||
is the two decimal numbers per declaration over roughly 13 000 declarations,
|
||
and is the owner's "a few KB for 20 000 modules" measured on real source.
|
||
|
||
## Status / TODO
|
||
|
||
- [x] Measure both suspects before touching anything; both recorded above.
|
||
- [x] `DeclLines` on `Decl` and on `Def`, computed in `facts_from_analysis`
|
||
from the file's own `LineIndex`.
|
||
- [x] `FileFacts::from_analysis` takes the line index; `FileFacts::of` builds
|
||
one.
|
||
- [x] Record codec: two fields per declaration, `FACTS_FORMAT` 3 → 4, with the
|
||
justification above.
|
||
- [x] `WorkspaceIndex::fingerprint` carries the lines, so incremental == fresh
|
||
covers them.
|
||
- [x] `Workspace::file_view` — bounded, LRU, four named invalidation points.
|
||
- [x] `hover.rs`: heading from `Def::lines`, snippet from the shared view; the
|
||
per-request `disk_view` memo is gone, subsumed.
|
||
- [x] `locate.rs` swept onto the buffer's index / the shared view.
|
||
- [x] Tests (11 new, listed in the work log) and two new `#[ignore]`d probes.
|
||
- [x] `cargo fmt` / `cargo clippy --all-targets` / `cargo test --workspace`.
|
||
- [ ] **Not done, deliberately: `` `define``s get no indexed line.** A
|
||
`Define` is `vlog_parser`'s, and giving it a line means a field in
|
||
another crate's public type plus its own record fields, to save the
|
||
*first* macro hover into one file and nothing after it. The shared view
|
||
already covers the repeat.
|
||
- [ ] **Not done, deliberately: the other `text_of` callers are untouched.**
|
||
`rename`, `ports`, `hierarchy`, `type_hierarchy`, `completion`,
|
||
`signature`, `inlay` and `nav` read whole files because they want whole
|
||
files, not a line — the sweep was for the position-only readers. Routing
|
||
them through the view cache would mean `text_of` handing out an `Rc`
|
||
instead of a `String`, which is a different change with a different
|
||
argument.
|
||
- [x] **Reported, not fixed *here*: the first request of a session waits out
|
||
the startup scan.** Numbers and the filed request are in Handshakes;
|
||
**delivered 2026-08-28** by `docs/features/scan-interleave/README.md`
|
||
(780 ms → 15.5 ms cold, 287 ms → 12.8 ms warm).
|
||
|
||
## Work log
|
||
|
||
### 2026-08-28 — dev
|
||
|
||
**Measured first, both suspects, before a line of the fix was written.** Two
|
||
new probes were needed and are part of the round:
|
||
`perf::hovering_into_a_big_closed_file_first_touch_and_repeat` (an
|
||
instantiation and a port, into a 12 MB file, first touch and repeat separately
|
||
— the existing probes all reported means, which hide exactly the first/repeat
|
||
split the owner's report is about) and
|
||
`e2e::a_hover_issued_during_the_initial_scan_waits_for_it` (over the wire,
|
||
against the real binary, two whole sessions so the persistent store is cold in
|
||
one and warm in the other). The second answered the brief's question about
|
||
suspect 2 with a number four orders of magnitude larger than suspect 1's, which
|
||
is worth saying plainly even though this round could not act on it.
|
||
|
||
**The carrier: a struct, not a bare `u32`.** `DeclLines { name, detail }`
|
||
rather than `line: u32` on `Decl`, because the *second* datum already exists —
|
||
a split port's body line — and because the owner asked for room for more. The
|
||
alternative shapes were both worse: a bare `u32` would have needed a second
|
||
field the day `detail` was wanted (and `detail` was wanted on day one), and a
|
||
parallel table keyed by declaration would have to be kept in step with `Decl`
|
||
through the merge, the incremental update and the record round-trip, for no
|
||
consumer that exists. `Option<u32>` for `detail` rather than a `0` sentinel in
|
||
the *type*, even though the *record* writes `0` for `None`: the record's
|
||
sentinel is a framing decision (the stream stays flat, exactly as
|
||
`detail_span`'s `0 0` already does) and the type's is an API decision, and
|
||
those two should not be forced to be the same thing.
|
||
|
||
**`from_analysis` grew a parameter rather than growing a `&str`.** It could
|
||
have taken `src: &str` and built its own index, but its one real caller —
|
||
`Document::facts` — already holds a `LineIndex` over exactly that text, and
|
||
handing it over is both cheaper and more honest about what the function needs.
|
||
The test helper `as_a_server_analyzes` grew a fourth return value for the same
|
||
reason.
|
||
|
||
**`FACTS_FORMAT` 3 → 4, not 2 → 3 as the brief said.** The brief was written
|
||
against a tree where `port-detail-spans` had not yet been counted; the constant
|
||
was already at 3 when this round started. Same rule, next number.
|
||
|
||
**The heading now comes from the index on the disk path, and that is a small
|
||
behaviour change in one corner.** Before, a closed file that could not be read
|
||
produced a bare `` `sub.sv` `` heading with no line; now it produces
|
||
`` `sub.sv:2` ``, because the line no longer depends on the file being
|
||
readable. That is more information and not less, it is the line the index
|
||
recorded from the text it indexed, and it is pinned by
|
||
`a_closed_files_heading_line_comes_from_the_index_and_not_from_a_read` — which
|
||
deletes the file and requires the heading to survive. Every other card is
|
||
byte-identical: the full suite passed unmodified before a single new test was
|
||
added, including the stale-span, guard, CRLF, cap and ambiguity tests.
|
||
|
||
**The live path was deliberately left alone.** An open buffer's heading still
|
||
comes from that buffer's own line index and *not* from `Def::lines`, because
|
||
the buffer may hold unsaved edits the index has not seen — the same reason
|
||
`declaration_snippet` matches a `Def` to a live symbol logically instead of
|
||
reading at the indexed span (`docs/features/hover-declarations/README.md`).
|
||
Zero I/O either way, so there is nothing to win by unifying them and a
|
||
correctness property to lose.
|
||
|
||
**`disk_view` is gone, subsumed.** Its whole job — one read per file per hover
|
||
— is now the view cache's, which does the same thing per *session* instead of
|
||
per request. The per-request memo would have been a second cache in front of
|
||
the first.
|
||
|
||
**Files touched.** `crates/vlog_semantic/src/{workspace.rs,facts.rs,lib.rs}`,
|
||
`crates/vlog_semantic/tests/workspace.rs`,
|
||
`crates/lucisv_server/src/{state.rs,locate.rs,hover.rs,index_cache.rs,perf.rs}`,
|
||
`crates/lucisv_server/tests/e2e.rs`, this README,
|
||
`docs/features/{hover-declarations,workspace-index,index-persistence}/README.md`,
|
||
`docs/perf/README.md`, `TODO.md`. No new dependency, no `unsafe`, no
|
||
`#[allow]`, no version bump, no commits.
|
||
|
||
**Tests added.**
|
||
|
||
| test | where | pins |
|
||
|---|---|---|
|
||
| `every_declared_names_line_is_recorded_when_the_file_is_indexed` | `vlog_semantic/tests/workspace.rs` | line 1, a middle line, the last line with no trailing newline, and a member's line — each checked against the source line's own text |
|
||
| `crlf_and_multibyte_text_do_not_shift_a_declarations_line` | same | `\r\n` line endings, and three- and four-byte characters ahead of the declaration |
|
||
| `a_split_ports_two_lines_ride_the_same_carrier` | same | the extension story: a non-ANSI port's header line *and* body line, and an ANSI port's `None` |
|
||
| `a_declarations_lines_survive_the_record_round_trip` | same | encode → decode → equal, and through `IndexBuilder` to a `Def` |
|
||
| `a_store_from_any_previous_facts_format_is_dropped_not_misread` | `lucisv_server/src/index_cache.rs` | **rewritten**: every format `1..FACTS_FORMAT` is discarded by the header, *and* a genuine format-3 record (today's minus the two line fields) fails `decode` even served past the header. Was pinned at the literal `2` and would have gone on testing 2 forever |
|
||
| `a_closed_files_text_is_read_once_and_then_reused` | `lucisv_server/src/state.rs` | the cache exists: the file is rewritten behind the server's back and the second view is the first |
|
||
| `a_file_an_open_buffer_speaks_for_has_no_view_of_its_own` | same | closed files only |
|
||
| `every_way_a_files_text_can_move_drops_its_view` | same | all four invalidation points, each by the same warm-change-event-check experiment |
|
||
| `the_view_cache_holds_a_handful_of_files_and_a_bounded_amount_of_text` | same | both bounds, LRU order, and that a file over the whole byte budget is still cached and evicts the rest |
|
||
| `a_closed_files_heading_line_comes_from_the_index_and_not_from_a_read` | `lucisv_server/src/hover.rs` | the round's central claim: the file is deleted and the heading still names its line, snippet correctly dropped |
|
||
| `a_second_hover_into_one_closed_file_reads_nothing` | same | the snippet's read is shared: the file is rewritten and the second card is the first |
|
||
|
||
Two `#[ignore]`d probes added (`perf::hovering_into_a_big_closed_file_first_touch_and_repeat`,
|
||
`e2e::a_hover_issued_during_the_initial_scan_waits_for_it`); one existing probe
|
||
(`hovering_into_a_large_closed_file_reads_it_once`) grew a second timing so it
|
||
reports the repeat beside the first touch.
|
||
|
||
**Gates.** `cargo fmt --all -- --check` clean. `cargo clippy --all-targets
|
||
--workspace` silent. `cargo test --workspace` green, 0 failed. The counts, by
|
||
binary: `lucisv_server`'s unit tests **1 210 passed / 24 ignored** (+6 passing,
|
||
+1 `#[ignore]`d probe), its `e2e` suite **56 passed / 2 ignored** (+1
|
||
`#[ignore]`d probe), `vlog_semantic`'s `workspace` suite **66 passed** (+4).
|
||
One test was renamed rather than added
|
||
(`a_store_from_the_previous_facts_format_is_dropped_not_misread` →
|
||
`a_store_from_any_previous_facts_format_is_dropped_not_misread`), so nothing
|
||
was quietly dropped.
|
||
|
||
## QA log
|
||
|
||
### 2026-08-28 — QA
|
||
|
||
Verdict: **SHIP.** No correctness bug found in the round's own code — every
|
||
finding below is a test-coverage gap, closed in this pass with permanent
|
||
regression tests. All seven charter items checked; details follow.
|
||
|
||
**1. Heading staleness — reproduced, and the documented window holds.**
|
||
Constructed the exact attack: index `sub.sv` from its original text, then
|
||
rewrite it on disk (`addr` moved from line 2 to line 6, and the byte offset
|
||
the index still holds for it now lands inside a comment) with no `didSave`, no
|
||
watcher event and no `update_one`/`rebuild_index` call — before any hover has
|
||
ever read the file, so the view cache is empty and the read the snippet does
|
||
is genuinely against the *new* bytes. Result: the heading still shows
|
||
`sub.sv:2` (the index's last-scanned line, not the file's true current one),
|
||
and the snippet is dropped by `spells_exactly` rather than showing whatever
|
||
now sits at that byte range — no wrong line and no wrong snippet, matching the
|
||
README's Assumptions ("both are stale together") exactly. Pinned:
|
||
`hover::tests::an_unreindexed_disk_edit_leaves_a_stale_heading_and_no_wrong_snippet`
|
||
(`crates/lucisv_server/src/hover.rs`). The docs (this README's Assumptions
|
||
section, and `Workspace::file_view`'s doc comment at
|
||
`crates/lucisv_server/src/state.rs:1043`) already state this honestly — no
|
||
doc fix needed.
|
||
|
||
**2. `DeclLines` correctness — dev's tests already cover the awkward
|
||
offsets** (line 1, the last line with no trailing newline, CRLF, multi-byte
|
||
text ahead of the declaration, a split port's two lines, an ANSI port's
|
||
`None`) and check each recorded line against the source line's own text, not
|
||
just against a hand-computed expectation. No drift found; ran unmodified.
|
||
|
||
**3. View-cache attacks — three untested-but-correct paths, now covered.**
|
||
The cache's own logic (`trim_views`, `cached_view`,
|
||
`crates/lucisv_server/src/state.rs:349` and `:1061`) was already right by
|
||
inspection and by trace, but three of the charter's named attacks had no
|
||
regression test, meaning a future refactor could break any of them silently:
|
||
- *Recency, not insertion order.* `cached_view`'s `rotate_right` had no test
|
||
at all. Added
|
||
`state::tests::re_hovering_the_oldest_cached_file_saves_it_from_eviction`:
|
||
fills the cache, re-touches the oldest entry, adds a fifth file, and
|
||
requires the just-touched file to survive while the untouched one is what
|
||
falls off instead.
|
||
- *`update_one` selectivity.* Every existing invalidation test warms one
|
||
file's view at a time, so a hypothetical `update_one` that widened to
|
||
`views.clear()` would still pass all of them. Added
|
||
`state::tests::updating_one_file_leaves_another_files_cached_view_alone`.
|
||
- *A second oversized file.* The existing bound test caches exactly one
|
||
file over the byte budget; it never tries a second one. Added
|
||
`state::tests::a_second_oversized_file_evicts_the_first_rather_than_growing_beside_it`,
|
||
confirming the cache stays at one entry (the newest) rather than
|
||
accumulating unbounded huge files.
|
||
All three pass against the round's code unmodified — genuine coverage gaps,
|
||
not bugs.
|
||
|
||
**4. Format bump — the single-decl test's premise checked, and generalized.**
|
||
`index_cache`'s `a_store_from_any_previous_facts_format_is_dropped_not_misread`
|
||
genuinely constructs a format-3 record (verified by hand: `strip_the_line_
|
||
fields` removes exactly the two trailing fields of the one declaration `M`
|
||
has, and the record that results is what format 3 actually wrote — not merely
|
||
a v3 header over v4 bytes). That fixture has only one declaration, so it could
|
||
not have caught a field-shift that landed on a *second* declaration's fields
|
||
rather than on a tag literal. Added
|
||
`vlog_semantic::tests::workspace::a_format_3_record_with_two_declarations_is_
|
||
rejected_not_misread`, generalizing the stripper to N declarations (both units
|
||
and members) and covering a two-unit file and a mixed unit+split-port-member
|
||
file. Both decode to `None`, confirming the structural reason this is safe in
|
||
general: a field-shift by exactly one declaration's two line-fields always
|
||
lands either on a tag literal (`"M"`, `"I"`, …) or on the next declaration's
|
||
`name`/`kind` string fields, and a Verilog identifier can never parse as
|
||
`u32`, so `Reader::num` fails and `decode` returns `None` rather than building
|
||
a `Decl` out of someone else's fields. No misread constructed; the
|
||
"guilty until proven innocent" bar is met.
|
||
|
||
**5. Equivalence — confirmed, not just claimed.** `cargo test --workspace`
|
||
green with 0 failures both before and after this pass's additions (dev's
|
||
counts: `lucisv_server` 1210 passed/24 ignored, `vlog_semantic` `workspace` 66
|
||
passed — both unmodified by this pass except for the new tests below). Read
|
||
the `hover.rs` and `locate.rs` diffs directly: the live-buffer branch is
|
||
untouched, `location()`'s open-buffer arm is a straight substitution
|
||
(`doc.positions()` for the old `Positions::new(&text, &index)` built from a
|
||
clone of the same text), and the disk branch is the only place behavior can
|
||
differ — which is exactly the one documented corner (an unreadable closed
|
||
file now shows its indexed line). No other behavior change found.
|
||
|
||
**6. Numbers reproduced**, `--release`, this machine, this session:
|
||
- `perf::hovering_into_a_big_closed_file_first_touch_and_repeat`: first
|
||
touch 5.75 ms (instantiation) / 5.65 ms (port), repeat 1.35 µs / 1.89 µs —
|
||
same order as the README's 6.23 ms / 0.95 µs and 5.92 ms / 0.99 µs; run-
|
||
to-run noise, not drift.
|
||
- `state::tests::qa_perf_cold_warm_and_half_warm_scans` (860-file corpus):
|
||
store size **2 380 790 bytes** — an exact match to the README's "after"
|
||
figure, confirming the +68 KB / 2.9 % growth claim against the real
|
||
corpus rather than trusting the doc's arithmetic. Scan times (325 / 350 /
|
||
186 ms) were in the same band as the README's (343 / 374 / 200 ms);
|
||
machine noise, no regression.
|
||
- `e2e::a_hover_issued_during_the_initial_scan_waits_for_it`: 748.7 ms cold
|
||
/ 274.0 ms warm for the first hover issued the moment `initialized` is
|
||
sent, vs. 26.3 µs / 40.2 µs once the scan is done — the same four-orders-
|
||
of-magnitude gap the README reports (780 / 287 ms vs. 64 / 61 µs). The
|
||
test genuinely exercises the wait (it asserts the answer resolves
|
||
correctly across files, and the two timings are taken across the real
|
||
wire protocol against the shipped binary) — the Handshake in this
|
||
README's "Suspect 2" section is accurate and not overstated.
|
||
|
||
**7. Full gates**, run after adding the tests above:
|
||
- `cargo fmt --all -- --check`: clean (after formatting the new tests —
|
||
two blocks needed `cargo fmt`'s wrapping, applied).
|
||
- `cargo clippy --all-targets --workspace`: clean, no warnings.
|
||
- `cargo test --workspace`: green. `lucisv_server` unit tests **1214
|
||
passed** (dev's 1210 + this pass's 4), `vlog_semantic` `workspace` suite
|
||
**67 passed** (dev's 66 + this pass's 1). 0 failed anywhere in the
|
||
workspace, including doctests.
|
||
- `node editors/vscode/smoke.js ./target/debug/lucisv-server`: `smoke: OK`.
|
||
|
||
**Tests added this pass** (5, all permanent regressions, all green):
|
||
`hover::tests::an_unreindexed_disk_edit_leaves_a_stale_heading_and_no_wrong_snippet`,
|
||
`state::tests::re_hovering_the_oldest_cached_file_saves_it_from_eviction`,
|
||
`state::tests::updating_one_file_leaves_another_files_cached_view_alone`,
|
||
`state::tests::a_second_oversized_file_evicts_the_first_rather_than_growing_beside_it`
|
||
(all `crates/lucisv_server/src/`), and
|
||
`vlog_semantic::tests::workspace::a_format_3_record_with_two_declarations_is_rejected_not_misread`
|
||
(`crates/vlog_semantic/tests/workspace.rs`).
|
||
|
||
## Review
|
||
|
||
**2026-08-28 — lead.** Reviewed after QA's SHIP; gates re-run
|
||
independently (fmt clean, clippy silent, 2440 workspace tests green).
|
||
This round is the owner's design implemented at the right altitude:
|
||
`DeclLines` as a field on the carrier the index already had — not a
|
||
parallel table — so ports got their lines for free through the member
|
||
entries and the extension story is "add a field, bump the format",
|
||
exactly the flexibility the owner asked for. The +68 KB store growth
|
||
on the 860-file corpus scales to the owner's 20 000-module thought
|
||
experiment at the few-tens-of-KB order they predicted. The `FileView`
|
||
cache is honest about its one unwatchable staleness case and leans on
|
||
`spells_exactly` correctly (a stale view omits, never lies); QA's
|
||
staleness repro pins the heading/snippet pair going stale *together*.
|
||
The dev's rewrite of the format-discard test from a pinned literal to
|
||
all-previous-formats is the kind of fix that outlives the round.
|
||
Suspect 2 — the first request of a session waiting 287–780 ms behind
|
||
the startup scan — is confirmed genuine by dev and QA independently
|
||
and is the dominant remainder of the owner's "slow on first try";
|
||
correctly filed as a Handshake, next round's work. Accepted; committed
|
||
by the lead.
|
||
|
||
<!-- Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com -->
|