Merge the design-hierarchy sidebar (codex + integration round)
Co-Authored-By: Claude Fable 5 <[email protected]> # Conflicts: # crates/lucisv_server/src/main.rs
This commit is contained in:
commit
8cdc1b3375
30 files changed
+3883
-86
No files matched your search
@@ -96,7 +96,15 @@ promised:
|
||||
- **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. A *parallel table* keyed by declaration was the
|
||||
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
|
||||
|
||||
@@ -221,13 +221,28 @@ impl WorkspaceIndex {
|
||||
`detail_span`. **3 → 4** (2026-08-28,
|
||||
`docs/features/hover-line-index/README.md`): each declaration gained its two
|
||||
*line numbers*, which is what lets a server print `file:line` for an indexed
|
||||
declaration without reading that file. Same rule each time, same
|
||||
declaration without reading that file. **4 → 5** (2026-08-29,
|
||||
`docs/features/vscode-hierarchy-sidebar/README.md`): one bump for three
|
||||
additions — each declaration's `decl_span`; a per-instance
|
||||
`InstanceOccurrence` list on every instantiation edge (the edge itself is
|
||||
still one per *statement*, so no census moved); and **client positions**,
|
||||
0-based lines and UTF-16 columns, on every file-scope declaration and every
|
||||
instance occurrence, which is what lets the design-hierarchy snapshot answer
|
||||
with no file read at all. Members deliberately get none: the `U` and `M`
|
||||
groups of a record are separate, so "units carry positions, members do not"
|
||||
costs a member no field, not even a presence flag — and members outnumber
|
||||
units by two orders of magnitude. Same rule each time, same
|
||||
consequence: the store is discarded whole on the first scan after the
|
||||
upgrade and rewritten — measured at about 175 ms over the 860-file corpus,
|
||||
once. `a_store_from_any_previous_facts_format_is_dropped_not_misread` now
|
||||
once. `a_store_from_any_previous_facts_format_is_dropped_not_misread`
|
||||
checks **every** format this build is not, rather than the one literal
|
||||
number it was pinned at, so the next bump inherits the test.
|
||||
The store grew 68 KB (2.9 %) for the lines.
|
||||
number it was pinned at, so each bump inherits the test; its
|
||||
belt-and-braces half (a genuine previous-format record served past the
|
||||
header) is re-derived at each bump — `as_a_format_4_record` at format 5.
|
||||
The store grew 68 KB (2.9 %) for the lines at format 4, and a further
|
||||
212 KB (8.9 %) over the 860-file corpus for all of format 5 — of which the
|
||||
client positions are 1.7 %, measured separately on the same corpus and again
|
||||
on opentitan (1.9 % of a 24.7 MB store).
|
||||
- `record_path` is public separately because a store keyed by path reads that
|
||||
field out of every record it holds and decodes only the ones it is asked
|
||||
for.
|
||||
@@ -363,9 +378,12 @@ site's own name span `22..25`), no subclasses, and one external reference fact
|
||||
(`e`, name `sub`, one resolution path also named `sub`, occurrence `22..25`),
|
||||
then the checksum. **The example is written at `FACTS_FORMAT` 2 and is kept
|
||||
for its shape, not its field count**: since then every declaration also
|
||||
carries its detail span (`0 0` when there is none, format 3) and its two line
|
||||
numbers (format 4), so a real record today has four more numbers per
|
||||
declaration than the one above. The framing — one line, tab-separated,
|
||||
carries its detail span (`0 0` when there is none, format 3), its two line
|
||||
numbers (format 4), its `decl_span` and — for a file-scope declaration only —
|
||||
its two client ranges of four numbers each (format 5); and an instantiation
|
||||
edge carries a length-prefixed list of its individual instances, each a name,
|
||||
two byte ranges and two client ranges. So a real record today is considerably
|
||||
wider per declaration than the one above. The framing — one line, tab-separated,
|
||||
length-prefixed lists, checksum last — is what the example is for and is
|
||||
unchanged. The record is what lies between the hash field and the
|
||||
checksum; both hashes above are illustrative.
|
||||
|
||||
@@ -0,0 +1,806 @@
|
||||
# vscode-hierarchy-sidebar
|
||||
|
||||
## Goal
|
||||
|
||||
Give the lucisv VS Code extension its own Activity Bar container with a
|
||||
**Hierarchy** view: a persistent fuzzy-search field above an alphabetical,
|
||||
folder-like module-instance tree. LSP call hierarchy deliberately groups a
|
||||
module's calls by target module *type*; this view needs the other reading of the
|
||||
same facts — every individual instance name, its source range, and every
|
||||
declaration its type may name — so the server answers a custom
|
||||
`lucisv/moduleHierarchy` snapshot and notifies `lucisv/moduleHierarchyChanged`
|
||||
whenever the installed index changes. The snapshot is **flat**: the client picks
|
||||
roots and opens paths, which keeps recursion out of the protocol and lets one
|
||||
answer serve both rendering and search. This is a textual design hierarchy, not
|
||||
an elaborator: generate loops appear once as written, both preprocessor arms may
|
||||
appear, parameters are not evaluated, and instance arrays are not expanded into
|
||||
numeric elements.
|
||||
|
||||
For a design such as:
|
||||
|
||||
```systemverilog
|
||||
module TB;
|
||||
top dut ();
|
||||
endmodule
|
||||
|
||||
module top;
|
||||
block inst1 ();
|
||||
endmodule
|
||||
|
||||
module block;
|
||||
leaf inst2 ();
|
||||
endmodule
|
||||
```
|
||||
|
||||
the view begins collapsed at `TB` and opens, one level at a time, to
|
||||
`TB` → `dut (top)` → `inst1 (block)` → `inst2 (leaf)`. The root label is a
|
||||
module name; every child label leads with the instance name and includes its
|
||||
module type, so both names are visible and both are searchable.
|
||||
|
||||
### Product behaviour (codex's specification, amended where noted)
|
||||
|
||||
**Tree and roots.**
|
||||
|
||||
- Show every uniquely declared module reachable from a root through instance
|
||||
edges. Roots are modules with no resolved parent, sorted case-insensitively;
|
||||
children are sorted by instance name, then module name, then source URI and
|
||||
position for a deterministic tie-break.
|
||||
- Show an unresolved instantiated type as a non-expandable warning row.
|
||||
Navigation to the instance still works; "Show Definition" explains that no
|
||||
definition is indexed.
|
||||
- Keep an ambiguous type visible as a non-expandable warning row. "Show
|
||||
Definition" offers a Quick Pick of candidates instead of guessing.
|
||||
- After the ordinary zero-parent roots, add any declaration a root never
|
||||
reaches because it sits in a recursive strongly connected component. Those
|
||||
fallback roots are marked, and the repeated edge inside them is marked
|
||||
`recursive` and does not open again, so `A -> B -> A` is visible without an
|
||||
infinite tree.
|
||||
- Two declarations of one module name in different files are distinct
|
||||
definitions, identified by URI and position.
|
||||
- The view reflects exactly the server's current index scope.
|
||||
- **Amended, owner 2026-08-29: every level starts collapsed.** Nothing expands
|
||||
on the view's behalf, on open or on refresh; the one exception is the ancestor
|
||||
chain of a bookmarked row, which the user asked for by bookmarking.
|
||||
|
||||
**Search.**
|
||||
|
||||
- A real text input stays fixed above the tree — not a toolbar command, not an
|
||||
InputBox.
|
||||
- Matching is case-insensitive against exactly two fields, module name and
|
||||
instance name. Never paths, filenames, directories, preview text, ports or
|
||||
connection expressions.
|
||||
- The scorer is a deterministic fuzzy subsequence with exact, prefix,
|
||||
word-boundary and consecutive-character bonuses; an instance-name score wins a
|
||||
tie against a module-name score by one.
|
||||
- **Amended, owner 2026-08-29: a query renders a ranked, capped result list
|
||||
rather than a filtered tree.** A flat model has no one path per instance, so a
|
||||
match is one row that names the module writing it. The tree is not torn down
|
||||
while searching, and clearing the query restores it — same rows open, no
|
||||
snapshot re-request. Results cap at 200 with an `N more matches` line.
|
||||
|
||||
**Navigation, context menu and bookmark.**
|
||||
|
||||
- Clicking an instance selects its instance-name range at the instantiation;
|
||||
clicking a root module selects its module declaration.
|
||||
- The context menu is reachable with the mouse and with Shift+F10 / the Menu
|
||||
key, and rows carry ARIA tree roles, levels, expanded state and labels:
|
||||
- **Copy Full Path** — `TB.dut.inst1.inst2`; the root segment is the root
|
||||
module name and every later segment an instance name. *Tree rows only.*
|
||||
- **Show Definition** — opens the instantiated module's declaration and
|
||||
selects its name; a Quick Pick when ambiguous, a concise warning when
|
||||
unresolved.
|
||||
- **Show Instance** — the normal instance click's destination.
|
||||
- **Highlight / Bookmark** — one workspace-scoped bookmarked path, painted
|
||||
with a yellow theme token, ancestors expanded and the row revealed. The
|
||||
logical full path is persisted in `workspaceState`, re-resolved after every
|
||||
refresh, and dropped with an explanation if it stops existing or stops being
|
||||
unique. *Tree rows only.*
|
||||
- **Open on the Right** — the module definition in `ViewColumn.Beside`, pinned
|
||||
as a non-preview editor.
|
||||
- **Removed, owner 2026-08-29: the five-line hover source preview.** See the
|
||||
work log; it was the feature's last consumer of file text.
|
||||
|
||||
### UI architecture
|
||||
|
||||
One contributed `WebviewView`, not a `TreeDataProvider`: VS Code's native tree
|
||||
API gives excellent rows and context menus but no persistent text input inside
|
||||
the view, and a webview is the only stable API at the extension's VS Code floor
|
||||
(`^1.82.0`) that satisfies the literal search-bar layout. `package.json`
|
||||
contributes a `lucisv` Activity Bar container with a monochrome SVG icon, the
|
||||
`lucisv.hierarchy` webview view, `onView:lucisv.hierarchy` activation, and
|
||||
refresh / clear-bookmark commands.
|
||||
|
||||
`extension.js` stays the lifecycle owner; the feature lives in focused CommonJS
|
||||
modules:
|
||||
|
||||
- `hierarchyModel.js` — response validation, the flat resident model, root
|
||||
choice, lazy tree rows, cycle guards, full paths, sorting and the search
|
||||
index. No `vscode` dependency, so plain Node tests cover it exhaustively.
|
||||
- `hierarchyView.js` — the provider: server requests, the model, the expansion
|
||||
set, navigation, clipboard, persistence and command dispatch.
|
||||
- `media/hierarchy.js` / `hierarchy.css` — rendering, the search box, disclosure,
|
||||
the accessible context menu and the message bridge.
|
||||
- `images/hierarchy.svg` — the theme-neutral Activity Bar icon.
|
||||
|
||||
The webview uses a nonce-based CSP, `localResourceRoots`, `asWebviewUri`, HTML
|
||||
escaping and a fixed allow-list of message types. Rows carry opaque ids and the
|
||||
extension resolves an id against its current model; no source text, filesystem
|
||||
path or executable command ever comes back from DOM data. All colours are VS
|
||||
Code theme variables, with a high-contrast border fallback for the bookmark row.
|
||||
|
||||
### Explicit non-goals for the first delivery
|
||||
|
||||
- Full SystemVerilog elaboration, parameter evaluation, preprocessor branch
|
||||
selection, generate-loop expansion, or simulator-specific library binding.
|
||||
- Searching ports, signals, files, source text, or full hierarchy paths.
|
||||
- Multiple simultaneous bookmarks, bookmark sync across machines, drag-and-drop,
|
||||
hierarchy editing, or changing the selected top from the view.
|
||||
- Replacing the standard LSP call hierarchy; this sidebar is an
|
||||
instance-oriented companion to it.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- **A recorded position is a fact about the same snapshot the span is.** A
|
||||
declaration's byte span and its client position (`vlog_semantic::DeclPositions`)
|
||||
are read off one text in one pass, so a range and a span can never name
|
||||
different generations of a file. Where a file changed on disk with nothing
|
||||
telling the server, both are stale together — the same bargain
|
||||
`docs/features/hover-line-index/README.md` struck for `DeclLines`.
|
||||
- **A client position is 0-based lines and UTF-16 code units**, which is what an
|
||||
LSP `Position` counts in and *not* what `LineIndex::line_col` reports. Both
|
||||
the index and the wire converter go through one function,
|
||||
`vlog_parser::LineIndex::utf16_position`, so they cannot answer differently.
|
||||
- **Only file-scope declarations carry client positions.** A member is a `Decl`
|
||||
exactly as a unit is, and there are two orders of magnitude more of them; see
|
||||
Handshakes for the measurement that decided it.
|
||||
- **A module type resolves to the modules of that name in the same snapshot.**
|
||||
The server no longer repeats those declarations on every instance; the client
|
||||
looks them up in its own module table, which is the identical set.
|
||||
- **The tree is a reading of the index's scope.** If `lucisv.index.scope`, a
|
||||
filelist, excludes or the large-file policy keeps a file out, it is out of the
|
||||
hierarchy too.
|
||||
- **A row id is stable while its declaration does not move.** Ids are composed
|
||||
from a URI and the declaration's own start position, so the user's expansion
|
||||
state survives a refresh, a rescan and a restart.
|
||||
|
||||
## Handshakes
|
||||
|
||||
### `vlog_semantic` — `FACTS_FORMAT` 4 → 5, and what it now carries
|
||||
|
||||
One bump, three additions, all folded into the same number (this branch minted
|
||||
5; nothing here mints a 6):
|
||||
|
||||
```rust
|
||||
pub struct Def {
|
||||
pub file: FileId,
|
||||
pub name_span: TextRange,
|
||||
pub decl_span: TextRange, // new in 5
|
||||
pub kind: SymbolKind,
|
||||
pub detail_span: Option<TextRange>,
|
||||
pub lines: DeclLines,
|
||||
}
|
||||
|
||||
pub struct DeclLines {
|
||||
pub name: u32,
|
||||
pub detail: Option<u32>,
|
||||
pub positions: Option<DeclPositions>, // new in 5 — Some for a unit
|
||||
}
|
||||
|
||||
/// 0-based line, UTF-16 code units — what a client counts in.
|
||||
pub struct Utf16Pos { pub line: u32, pub character: u32 }
|
||||
pub struct Utf16Range { pub start: Utf16Pos, pub end: Utf16Pos }
|
||||
pub struct DeclPositions { pub name: Utf16Range, pub decl: Utf16Range }
|
||||
|
||||
pub struct InstantiationEdge {
|
||||
pub file: FileId,
|
||||
pub owner: DeclSite,
|
||||
pub site_span: TextRange,
|
||||
pub instances: Vec<InstanceOccurrence>, // new in 5
|
||||
}
|
||||
|
||||
pub struct InstanceOccurrence {
|
||||
pub name: String,
|
||||
pub name_span: TextRange,
|
||||
pub span: TextRange,
|
||||
pub name_positions: Utf16Range, // new in 5
|
||||
pub positions: Utf16Range, // new in 5
|
||||
}
|
||||
|
||||
// Two added parameters, because a record now carries client positions:
|
||||
impl FileFacts {
|
||||
pub fn from_analysis(path, tree, defines, sem, src: &str, lines: &LineIndex) -> FileFacts;
|
||||
}
|
||||
pub const FACTS_FORMAT: u32 = 5; // was 4
|
||||
```
|
||||
|
||||
`callHierarchy/incomingCalls`, outgoing calls and code-lens counts still read
|
||||
the statement-level edge and its `site_span`, so `sub u1 (), u2 ();` remains
|
||||
**one** call site there. The sidebar alone flattens `instances` into two rows.
|
||||
There is no second instantiation census to drift from the first: `instances` is
|
||||
populated from the same `instantiations::sites` walk the call hierarchy reads.
|
||||
|
||||
**The carrier extends by gaining a field, exactly as `hover-line-index`
|
||||
predicted.** `DeclLines` was documented as "a column, or a rendered preview, is
|
||||
another field written beside these two"; `DeclPositions` is the first of those
|
||||
fields, written in `Writer::decl`'s group and read in `Reader`'s, with the
|
||||
format bump any record change owes.
|
||||
|
||||
**Why only file-scope declarations carry positions.** Members — ports,
|
||||
parameters, class fields — are `Decl`s exactly as units are, and on opentitan
|
||||
there are 1 544 modules against hundreds of thousands of members. Giving every
|
||||
declaration eight more numbers would have cost, by measurement of the record
|
||||
shape, several megabytes on a 24.6 MB store to serve a caller that does not
|
||||
exist. The units and the members are written in two separate groups of a record
|
||||
(`U` and `M`), so "units carry positions, members do not" costs a member **no
|
||||
field at all** — not even a presence flag. The day a member wants them, it is
|
||||
the same eight fields in the other group plus a bump.
|
||||
|
||||
### `vlog_semantic` — `WorkspaceIndex::units_of`
|
||||
|
||||
```rust
|
||||
pub fn units_of(&self, kind: SymbolKind) -> impl Iterator<Item = (&str, &Def)>;
|
||||
```
|
||||
|
||||
The cheap half of `workspace_symbols("")` for a caller that wants units and
|
||||
never members: it walks the unit table alone and sorts nothing, where
|
||||
`workspace_symbols("")` walks every member of every unit and sorts the lot.
|
||||
Measured on opentitan: **15 ms per call**, on every snapshot, gone.
|
||||
|
||||
### `vlog_parser` — `LineIndex::utf16_position`
|
||||
|
||||
```rust
|
||||
pub fn utf16_position(&self, text: &str, offset: u32) -> (u32, u32);
|
||||
```
|
||||
|
||||
The byte-offset → (0-based line, UTF-16 column) conversion, moved down beside
|
||||
the table it reads so that **two callers cannot disagree**: the semantic index
|
||||
recording a declaration's position while a file is scanned, and
|
||||
`lucisv_server::convert::Positions::position` converting a span for the wire.
|
||||
`Positions::position` is now a two-line wrapper over it and its whole existing
|
||||
test suite passed unmodified. Pinned across the crate boundary by
|
||||
`design_hierarchy::tests::an_indexed_position_is_the_position_the_wire_converter_would_have_given`.
|
||||
|
||||
### `lucisv_server::state` — `Document::facts`
|
||||
|
||||
`FileFacts::from_analysis` grew a `src: &str` parameter, because a client
|
||||
position cannot be read off a line table alone. Its one real caller
|
||||
(`Document::facts`) already holds that text; the change is a straight
|
||||
substitution.
|
||||
|
||||
### The wire — `lucisv/moduleHierarchy`, schema 2
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaVersion": 2,
|
||||
"revision": 42,
|
||||
"complete": true,
|
||||
"files": ["file:///w/top.sv", "file:///w/fifo.sv"],
|
||||
"modules": [
|
||||
{
|
||||
"moduleName": "top",
|
||||
"definition": { "file": 0, "range": [0,0,12,9], "selectionRange": [0,7,0,10] },
|
||||
"instances": [
|
||||
{ "instanceName": "u_fifo", "moduleName": "fifo",
|
||||
"site": { "file": 0, "range": [3,2,3,20], "selectionRange": [3,7,3,13] } }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
A range is `[startLine, startCharacter, endLine, endCharacter]` — an LSP
|
||||
`Range` with its four field names left off. `range` covers the whole construct,
|
||||
`selectionRange` its name, exactly the call-hierarchy contract. Modules and
|
||||
instances are sorted on the server for deterministic protocol tests and sorted
|
||||
again defensively in the client.
|
||||
|
||||
Four things left the wire deliberately, and the client rebuilds all four in
|
||||
`hierarchyModel.js`'s `validateSnapshot` — see the work log for why:
|
||||
|
||||
| gone from the wire | rebuilt as |
|
||||
|---|---|
|
||||
| a `uri` on every location | an index into `files` |
|
||||
| `{ start: { line, character }, end: … }` | four numbers |
|
||||
| an `id` on every row | `` `${uri}#${line}:${character}` `` of its selection range |
|
||||
| `definitions` copied onto every instance | the modules of that name, from the client's own table |
|
||||
|
||||
`lucisv/moduleHierarchyChanged { "revision": n }` still rides beside the
|
||||
server's existing code-lens refresh point, so every index-mutation path is
|
||||
covered once, and is still gated on `initializationOptions.hierarchyView` so no
|
||||
other LSP client sees unsolicited traffic. A `-32601` from an older binary
|
||||
renders a compatibility message and leaves every other extension feature
|
||||
working.
|
||||
|
||||
### `complete` — what it promises, and the window it has to be honest about
|
||||
|
||||
`complete` is `Server::index_is_complete()`, which is `!scanning &&
|
||||
!must_wait()`. Both clauses, not just `scanning`: `!scanning` alone answers "is
|
||||
a scan running *this instant*", and a snapshot taken between a finished scan and
|
||||
a rescan already asked for would call a stale index complete.
|
||||
|
||||
Today that window is unreachable, for two independent reasons, and the second
|
||||
clause is written down anyway so the flag's honesty does not depend on either:
|
||||
|
||||
1. `rescan_wanted` is only ever **set while `scanning` is true**, and is
|
||||
consumed inside the scan loop before `scanning` goes false.
|
||||
2. `must_wait()` sets any request aside — held, unanswered — while
|
||||
`answering_a_rescan` or `rescan_wanted` is set or anything is already
|
||||
`held`. A snapshot therefore only ever *reaches* the flag with all three
|
||||
clear. So `complete` is false exactly during the startup scan, which is the
|
||||
one scan nothing asked for.
|
||||
|
||||
Pinned by `server::tests::a_snapshot_is_never_answered_complete_while_a_rescan_is_owed`,
|
||||
which asserts both halves: the flag is false with a rescan owed, and the request
|
||||
is held rather than answered off the stale index.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] `InstanceOccurrence` on the statement edge, populated through the shared
|
||||
instantiation walk; call hierarchy and code lenses unchanged.
|
||||
- [x] `Def::decl_span`, so a module's whole-construct range needs no reparse.
|
||||
- [x] `DeclPositions` on `DeclLines` for file-scope declarations, and
|
||||
`Utf16Range` on every instance occurrence — the snapshot's zero-I/O fix.
|
||||
- [x] `LineIndex::utf16_position`, shared by the index and the wire converter.
|
||||
- [x] `WorkspaceIndex::units_of`, so a snapshot does not walk every member.
|
||||
- [x] Record codec: all of the above in `FACTS_FORMAT` 5, with round-trip and
|
||||
old-format-rejection tests.
|
||||
- [x] `lucisv/moduleHierarchy` + `lucisv/moduleHierarchyChanged`, gated on
|
||||
`initializationOptions.hierarchyView`.
|
||||
- [x] Schema 2: file table, four-number ranges, no ids, no per-instance
|
||||
definition copies — 11.6 MB → 2.3 MB on opentitan.
|
||||
- [x] `complete` tightened to `index_is_complete()` and written down.
|
||||
- [x] Client: flat resident model, lazy tree levels, prebuilt search index.
|
||||
- [x] Owner 2026-08-29: hover source preview removed.
|
||||
- [x] Owner 2026-08-29: every level collapsed by default.
|
||||
- [x] Owner 2026-08-29: search runs in memory, debounced, capped, and never
|
||||
re-requests or rebuilds.
|
||||
- [x] `cargo fmt` / `cargo clippy --all-targets` / `cargo test --workspace`, and
|
||||
all four node scripts.
|
||||
- [ ] **Not done, deliberately: `locate::location` is not rewired onto
|
||||
`DeclPositions`.** `textDocument/definition`, references, the lens and
|
||||
both hierarchies still read a file to convert a `Def`'s span to a
|
||||
`Location`, and every unit's range is now in the index for free. It is a
|
||||
real second consumer and a real saving, and it is a different change to a
|
||||
different feature's file — filed, not smuggled in.
|
||||
- [ ] **Not done: members carry no client positions.** See Handshakes for the
|
||||
cost that decided it; a port-oriented caller would add them to the `M`
|
||||
group.
|
||||
- [ ] Manual extension-host acceptance: themes, keyboard-only navigation, zoom,
|
||||
screen-reader labels, an empty workspace, an old server binary, and both
|
||||
universal and platform VSIX builds.
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-08-29 — codex (implementer of the feature)
|
||||
|
||||
The feature itself — the plan, the semantic facts, the custom request and
|
||||
notification, the webview shell, navigation, the context menu, the bookmark, the
|
||||
`FACTS_FORMAT` 4 → 5 bump and the committed node tests — was designed and built
|
||||
by **codex** in this worktree on branch `codex/vscode-hierarchy-sidebar-plan`
|
||||
from base commit `40094c4`. Everything below is a fix round on top of that work;
|
||||
the shape of the feature, the flat-snapshot decision, the one-edge-per-statement
|
||||
decision and the client module split are codex's and are unchanged.
|
||||
|
||||
### 2026-08-29 — dev (snapshot cost, `complete`, and three owner items)
|
||||
|
||||
**The lead's finding, reproduced first.** `snapshot()` read **every**
|
||||
module-declaring file and built a `LineIndex` over each, per request, and the
|
||||
client re-pulls on every index change. Over stdio against
|
||||
`/Users/guoliangchen/repo/opentitan` (3 979 SV files, workspace scope, warm
|
||||
store, `--release`, `--verbose` so the server times its own handler):
|
||||
|
||||
| | before | after |
|
||||
|---|---:|---:|
|
||||
| `lucisv/moduleHierarchy`, server-side handler, first | 197 ms | **34 ms** |
|
||||
| — settled (the number that blocks the queue) | 145–167 ms | **17–20 ms** |
|
||||
| — end to end over stdio, settled | 265–325 ms | **39–44 ms** |
|
||||
| a `textDocument/definition` pipelined behind a snapshot | 263 ms | **41 ms** |
|
||||
| a `didSave` plus the snapshot the client re-pulls | 366 ms | **141 ms** |
|
||||
| the response itself | 11 559 498 B | **2 335 749 B** |
|
||||
|
||||
The requirement was ≤ ~20 ms warm; the settled handler is 17–20 ms, and no
|
||||
snapshot reads a file at any point.
|
||||
|
||||
**(a), not (b), and the measurement says why.** Option (b) — a per-file
|
||||
snapshot-fragment cache — would have made a *save* cheap and left the first
|
||||
snapshot of every session paying the whole read (5.0 s cold on the lead's
|
||||
measurement), and every rescan would have emptied it again. Option (a) makes
|
||||
**every** snapshot zero-I/O, cold and warm alike, permanently. It is also the
|
||||
cheaper thing to own: no cache, no invalidation points to keep in step with
|
||||
`FileView`'s. So (a), and (b) was not needed.
|
||||
|
||||
**But (a) alone did not reach the target, and the measurement said so.**
|
||||
With the reads gone the handler was still 92–130 ms. Instrumented, it split
|
||||
three ways: `workspace_symbols("")` 15 ms, building the answer 9 ms, and
|
||||
**~75 ms of JSON for an 11.6 MB response**. The I/O was never the whole bill.
|
||||
So two more things had to happen, and both are named in the numbers above:
|
||||
|
||||
- `WorkspaceIndex::units_of` — the snapshot wanted 1 544 modules and was being
|
||||
handed every declaration in the workspace, sorted.
|
||||
- **Schema 2.** A `file:///…` URI was written 15 432 times, a range was four
|
||||
nested objects with eight field names, every row carried an id built from that
|
||||
same URI, and every instance carried a full copy of the declarations its type
|
||||
resolves to. All four are redundant with something the client already has, and
|
||||
the client rebuilds all four in `validateSnapshot` — so the *model* every
|
||||
other line of client code reads is byte-for-byte the shape codex designed.
|
||||
11.6 MB → 2.3 MB. This is the one place the brief's "keep codex's wire shape"
|
||||
was overridden, and the measurement is the reason: at 11.6 MB the ≤20 ms
|
||||
requirement is arithmetically out of reach.
|
||||
|
||||
**Store growth, measured both ways.** The client positions are the part this
|
||||
round added:
|
||||
|
||||
| store | codex's format 5 | this round | delta |
|
||||
|---|---:|---:|---:|
|
||||
| 820-file corpus, workspace scope | 2 519 198 B | 2 561 773 B | **+42 575 B, +1.69 %** |
|
||||
| opentitan, 3 979 files | 24 663 087 B | 25 122 252 B | **+459 165 B, +1.86 %** |
|
||||
|
||||
And against `master`'s format 4 for the whole of format 5 (codex's `decl_span`
|
||||
plus occurrences, plus this round's positions), on the in-tree 860-file corpus
|
||||
probe: **2 380 790 B → 2 593 082 B, +212 292 B / +8.9 %**. Scan times over that
|
||||
corpus are inside their own noise (351 ms cacheless / 377 cold / 205 warm,
|
||||
against the 350 / 374 / 200 the previous round recorded). This is what the
|
||||
units-only decision bought: giving every declaration its positions would have
|
||||
put the growth two orders of magnitude higher on the member count alone.
|
||||
|
||||
**One conversion function, not two.** The dangerous part of carrying positions
|
||||
in the index is that the index's answer and the wire's could drift — a UTF-16
|
||||
column is exactly the kind of thing two implementations get differently on a
|
||||
CRLF line or a surrogate pair. So the conversion moved down into
|
||||
`vlog_parser::LineIndex::utf16_position` and `convert::Positions::position`
|
||||
became a wrapper over it; `convert`'s existing test suite passed unmodified,
|
||||
and a cross-crate test now requires the index's recorded ranges to equal the
|
||||
wire converter's over CRLF, two-, three- and four-byte characters, a name on a
|
||||
last line with no trailing newline, and two instances in one statement.
|
||||
|
||||
**`complete`, tightened and written down** — both, because the brief allowed
|
||||
either. `index_is_complete()` is `!scanning && !must_wait()`; the second clause
|
||||
is unreachable today for two independent reasons (`rescan_wanted` is only set
|
||||
while `scanning`, and `must_wait` holds any request owed a rescan), both spelled
|
||||
out in Handshakes and pinned by a test that asserts the flag *and* the holding.
|
||||
|
||||
**The v4-store discard path covers format 5, confirmed.**
|
||||
`index_cache`'s `a_store_from_any_previous_facts_format_is_dropped_not_misread`
|
||||
loops `1..FACTS_FORMAT`, so it already discards a format-4 store by the header —
|
||||
it was rewritten away from a pinned literal in the `hover-line-index` round for
|
||||
exactly this. Its belt-and-braces half, though, had gone stale: its stripper
|
||||
produced a record that was neither format 3 nor 4, so the test passed for the
|
||||
wrong reason. Rewritten as `as_a_format_4_record`, which removes all three of
|
||||
format 5's additions and yields the record format 4 genuinely wrote (verified by
|
||||
hand against the encoded fixture); `decode` still returns `None`.
|
||||
`vlog_semantic`'s two generalized strippers were corrected for the new field
|
||||
widths in the same way.
|
||||
|
||||
#### Owner item 1 (2026-08-29) — the hover source preview is gone
|
||||
|
||||
Removed entirely: `HierarchyView.preview`, the `hover` message, the
|
||||
`schedulePreview`/`showPreview`/`hidePreview` triplet and the `mouseenter`/
|
||||
`mouseleave` listeners in the webview, the `#preview` element and its CSS. It
|
||||
was **the last consumer of file text in the whole feature**: with it gone the
|
||||
extension host opens a document only when the user navigates to one, and the
|
||||
snapshot's zero-I/O property is now the whole story rather than half of it. The
|
||||
view test asserts positively that a `hover` message posts nothing back and that
|
||||
the popover is gone from the markup, so the code cannot quietly return.
|
||||
|
||||
#### Owner item 2 (2026-08-29) — every level collapsed by default
|
||||
|
||||
The webview used to expand every root whenever nothing was expanded; that is
|
||||
gone. This is a `WebviewView`, not a `TreeDataProvider`, so the equivalent of
|
||||
`collapsibleState: Collapsed` is that the host's `expanded` set starts empty and
|
||||
only a user `toggle` adds to it. Two expansions survive, and both are the user's
|
||||
own act rather than a default: the ancestor chain of a **bookmarked** row (the
|
||||
feature's stated contract — bookmarking reveals) and, while a query is active,
|
||||
nothing at all, because search now renders a flat list instead of a filtered
|
||||
tree.
|
||||
|
||||
**Expansion state across a refresh — verified.** A row id is
|
||||
`root:<uri>#<line>:<character>` for a module and `<parent id>><uri>#<line>:<character>`
|
||||
per level below, composed in the client from the location itself. It does not
|
||||
depend on array order, on a `FileId`, or on byte offsets, so a rescan that adds
|
||||
or removes files elsewhere leaves every unaffected row's id identical and the
|
||||
open rows stay open. Pinned by
|
||||
`hierarchyModel_test.js::rowIdsSurviveARefresh`, which reverses the module order
|
||||
in a second snapshot and requires the same ids and the same opened rows.
|
||||
|
||||
#### Owner item 3 (2026-08-29) — the search freeze, diagnosed and fixed
|
||||
|
||||
**The mechanism, named.** It was not a per-keystroke server request, and it was
|
||||
not unbounded rendering alone. It was three things compounding, all synchronous
|
||||
on the extension host and then again on the webview thread:
|
||||
|
||||
1. **`buildHierarchy` materialized the entire expanded tree** the moment a
|
||||
snapshot arrived. `instanceNode` recursed into its target module's instances,
|
||||
so a module instantiated in ten places duplicated its whole subtree ten
|
||||
times. On a real design that is combinatorial in depth — opentitan's 1 544
|
||||
modules and 13 888 instances expand to far more nodes than there are
|
||||
instances.
|
||||
2. **Every keystroke walked that whole tree.** `search` was posted on the raw
|
||||
`input` event with **no debounce**; the host ran `filteredHierarchy`, which
|
||||
visited every node and called `fuzzyScore` twice per node, each call
|
||||
`toLowerCase()`-ing a name — one allocation per node per keystroke.
|
||||
3. **Every keystroke then shipped the whole tree to the webview.**
|
||||
`render()` posted `roots: model.roots.map(serializeNode)` — a deep copy of
|
||||
every node, structured-cloned across the webview boundary — and the webview
|
||||
rebuilt its `nodes` map and re-created DOM for everything visible, with no
|
||||
cap.
|
||||
|
||||
**The fix, against each of the three.**
|
||||
|
||||
1. *Resident and flat.* `buildHierarchy` now keeps exactly the snapshot —
|
||||
modules and their instances — plus a resolved `targetId` per instance and a
|
||||
reachability pass over the **module** graph (one visit per module) to pick
|
||||
roots. A tree row is built only when its parent is open: `treeRows(model,
|
||||
expanded)` walks roots and descends only into expanded ids. A collapsed tree
|
||||
over 100 000 instances is one row per root and costs **0.02 ms**.
|
||||
2. *One prebuilt index, scanned once per query.* `searchIndex` builds one entry
|
||||
per module and per instance at snapshot time, each carrying its two names
|
||||
**already lowercased** and two character bit sets. A query lowercases and
|
||||
splits itself once, then makes one pass: an entry whose bits do not cover the
|
||||
query's cannot contain the query's characters and is never scored at all.
|
||||
The top rows are found by **counting hits per score and walking down from the
|
||||
top** rather than sorting — a one-letter query matches nearly every name, and
|
||||
sorting 100 000 hits to show 200 of them was most of a frame by itself. Ties
|
||||
break by index order, which is modules alphabetically and then instances
|
||||
alphabetically, so the answer is deterministic without comparing any strings.
|
||||
Input is debounced 60 ms in the webview.
|
||||
3. *Only the rows shown cross the boundary.* The host posts a flat `rows` array
|
||||
— the open part of the tree, or one capped page of results — never a tree.
|
||||
The webview keeps two containers and a query swaps which is shown, so
|
||||
searching never tears the tree down and clearing the search puts back exactly
|
||||
the rows that were open, with no snapshot re-request. Results are capped at
|
||||
200 with an `N more matches — narrow the search.` line.
|
||||
|
||||
**Before and after, on the generated fixture the node suite now carries**
|
||||
(20 000 modules × 5 instances = 120 000 search entries, ~6× opentitan):
|
||||
|
||||
| | before | after |
|
||||
|---|---:|---:|
|
||||
| build the model from a snapshot | did not finish — the expanded tree is unbounded | 183 ms, once per revision |
|
||||
| the collapsed tree's rows | (whole tree) | 0.02 ms |
|
||||
| `u` (matches all 100 000 instances) | — | 3.0 ms |
|
||||
| `u_inst` | — | 4.4 ms |
|
||||
| `u_inst_1` (73 756 matches) | — | 8.2 ms |
|
||||
| `mod_999` (444 matches) | — | 5.6 ms |
|
||||
| `zzz` (no match) | — | 0.8 ms |
|
||||
|
||||
The owner asked for "microsecond level". Per entry that is what an array scan
|
||||
gives — 3.0 ms over 120 000 entries is **25 ns each**; per *query* the honest
|
||||
equivalent at that size is single-digit milliseconds, which is what the table
|
||||
shows and what `searchOverAHugeHierarchyStaysInsideItsBudget` asserts. The
|
||||
assertion itself is 60 ms, an order of magnitude of headroom, so a busy machine
|
||||
cannot make a test that is about orders of magnitude flake.
|
||||
|
||||
**One behaviour changed as a consequence, and it is worth naming.** Codex's plan
|
||||
had search *filter the tree*, keeping each match plus its ancestor chain. A flat
|
||||
model has no one path per instance — an instance reached through three different
|
||||
parents is one row, not three — so search now renders a ranked, capped result
|
||||
list, each row saying which module writes it, and clicking navigates. The two
|
||||
context actions that need a path (Copy Full Path, Highlight/Bookmark) stay
|
||||
tree-only and say so when invoked from a result; Show Definition, Show Instance
|
||||
and Open on the Right work from either. This is the shape the owner's
|
||||
"cap rendered results with a N more… affordance" asks for.
|
||||
|
||||
**Files touched.** `crates/vlog_parser/src/line_index.rs`,
|
||||
`crates/vlog_semantic/src/{workspace.rs,facts.rs,lib.rs}`,
|
||||
`crates/vlog_semantic/tests/workspace.rs`,
|
||||
`crates/lucisv_server/src/{design_hierarchy.rs,convert.rs,server.rs,state.rs,index_cache.rs}`,
|
||||
`editors/vscode/{hierarchyModel.js,hierarchyView.js,hierarchyModel_test.js,hierarchyView_test.js,smoke.js,README.md,CHANGELOG.md}`,
|
||||
`editors/vscode/media/{hierarchy.js,hierarchy.css}`, this README,
|
||||
`docs/features/{workspace-index,index-persistence,hover-line-index}/README.md`,
|
||||
`TOPO.md`, `TODO.md`. No new dependency, no `unsafe`, no `#[allow]`, no
|
||||
`FACTS_FORMAT` 6, no version bump, no commits.
|
||||
|
||||
**Tests added.**
|
||||
|
||||
| test | where | pins |
|
||||
|---|---|---|
|
||||
| `a_file_scope_declaration_carries_its_client_ranges` | `vlog_semantic/tests/workspace.rs` | the extension: a unit's name and decl ranges, 0-based and UTF-16 |
|
||||
| `client_ranges_count_utf16_units_not_bytes` | same | a four- and a two-byte character ahead of a name shift the client column away from the byte column |
|
||||
| `every_instance_occurrence_carries_its_client_ranges` | same | both ranges on both instances of one statement |
|
||||
| `a_member_carries_lines_but_no_client_ranges` | same | the units-only decision, stated as a property |
|
||||
| `utf16_positions_are_zero_based_and_count_code_units` | `vlog_parser/src/line_index.rs` | surrogate pairs, mid-character flooring, clamping past the end |
|
||||
| `a_crlf_is_not_part_of_its_lines_utf16_content` | same | the `\r` rule the wire converter has always had |
|
||||
| `an_indexed_position_is_the_position_the_wire_converter_would_have_given` | `lucisv_server/src/design_hierarchy.rs` | **the round's central safety property**, across the crate boundary, over five awkward shapes |
|
||||
| `a_snapshot_reads_no_files_at_all` | same | the round's central claim: delete every source file, get a byte-identical snapshot |
|
||||
| `every_file_is_named_once_and_a_range_is_four_numbers` | same | the file table and the compact range, by counting URI occurrences in the serialized answer |
|
||||
| `positions_are_zero_based_utf16_even_through_multibyte_text` | same | end to end, through the snapshot |
|
||||
| `a_snapshot_is_never_answered_complete_while_a_rescan_is_owed` | `lucisv_server/src/server.rs` | the flag is false with a rescan owed, *and* the request is held rather than answered |
|
||||
| `rootsAreAlphabeticalAndEverythingStartsCollapsed` | `hierarchyModel_test.js` | owner item 2 |
|
||||
| `openingOneLevelAtATimeWalksTheDesign` | same | lazy levels build the right rows in the right order |
|
||||
| `rowIdsSurviveARefresh` | same | expansion state across a rescan, by reversing module order |
|
||||
| `bookmarksResolveByPathWithoutATableOfEveryPath` | same | the bookmark walks down instead of consulting a table of every path |
|
||||
| `searchScansTheFlatIndexAndKeepsAncestorContext` | same | one row per instance, names only, and what a result navigates to |
|
||||
| `theNarrowWireIsRebuiltIntoTheWideModel` | same | schema 2 → the model codex's client code reads |
|
||||
| `searchOverAHugeHierarchyStaysInsideItsBudget` | same | owner item 3's budget, on a generated 120 000-entry fixture |
|
||||
| the view suite's collapsed/lazy/search/no-preview assertions | `hierarchyView_test.js` | owner items 1–3 through the real provider |
|
||||
|
||||
**Gates.** `cargo fmt --all -- --check` clean. `cargo clippy --all-targets
|
||||
--workspace` silent. `cargo test --workspace` green, 0 failed —
|
||||
`lucisv_server` unit tests 1 297 passed / 33 ignored, its `e2e` suite 63 passed
|
||||
/ 2 ignored, `vlog_semantic`'s `workspace` suite 77 passed. All four node
|
||||
scripts OK: `hierarchyModel_test.js`, `hierarchyView_test.js`,
|
||||
`restart_test.js` (44 checks), `smoke.js`.
|
||||
|
||||
## QA log
|
||||
|
||||
### 2026-08-29 — QA (adversarial pass on the dev round)
|
||||
|
||||
**Scope note first.** `git diff master` over-reports this round's footprint:
|
||||
`master` has advanced two commits past this branch's own base (`40094c4`,
|
||||
`37560ca` and a `--stdio` hotfix), so a plain diff against `master` makes it
|
||||
look like `server.rs`/`state.rs` dropped
|
||||
`a_widen_that_subsumes_the_old_scope_reads_only_the_files_it_adds` and its
|
||||
doc comment. They did not — that test was added by `37560ca`, a commit this
|
||||
branch never had. `git diff HEAD` (this branch's own tip) is the correct
|
||||
diff and shows only this round's real changes; verified with
|
||||
`git merge-base HEAD master` = `40094c4`.
|
||||
|
||||
**Verdict: SHIP.** No corruption, no idempotency break, no widened
|
||||
`verify.rs` forgiveness, nothing dropped silently. One real finding, low
|
||||
severity, everything else confirmed by hand or by new regression tests.
|
||||
|
||||
**1. Position agreement (adversarial extension) — confirmed, no divergence.**
|
||||
Extended `an_indexed_position_is_the_position_the_wire_converter_would_have_given`
|
||||
(`crates/lucisv_server/src/design_hierarchy.rs:344`) with two more hostile
|
||||
shapes: CRLF and bare LF mixed in one file, and an instance on the same
|
||||
source line as its module header. Both agree with `convert::Positions`
|
||||
exactly, as every other shape already did. Raised the fixture's own
|
||||
`checked >= 11` premise to `>= 16` to keep counting honest against the two
|
||||
new sources. `cargo test -p lucisv_server design_hierarchy::` — 8/8 pass.
|
||||
|
||||
**2. Schema-2 fidelity on a hostile workspace — confirmed, no bug; coverage
|
||||
was missing and is now filled.** The client-side rebuild
|
||||
(`theNarrowWireIsRebuiltIntoTheWideModel`,
|
||||
`editors/vscode/hierarchyModel_test.js:204`) is a real check against a
|
||||
hand-built wire fixture, not a self-reference — it does not call the server
|
||||
or reuse `buildHierarchy`'s own output as its oracle. But nothing on the
|
||||
*server* side had ever produced a wire snapshot from duplicate module
|
||||
names, an escaped identifier, or a module with many instances of another —
|
||||
exactly the hostile shapes the charter named. Added three tests to
|
||||
`design_hierarchy.rs`:
|
||||
- `duplicate_module_names_across_files_stay_two_distinct_rows` — two files
|
||||
each declaring `module dup`; the wire keeps two separate rows keyed by
|
||||
`(file, definition range)`, each with only its own file's instances.
|
||||
- `an_escaped_identifier_names_a_module_and_an_instance` — `\weird$leaf ` and
|
||||
`\u$inst ` (space-terminated, space not part of the name) round-trip
|
||||
through the wire unmangled.
|
||||
- `one_hundred_instances_of_one_module_are_one_hundred_sorted_rows` — caught
|
||||
a bug in my *own* first draft, not the feature's: the fixture generator
|
||||
wrote `leaf u_000 (), leaf u_001 (), …` (repeating the module keyword per
|
||||
instance, invalid Verilog), which the parser silently produced zero
|
||||
instances for. Fixed to `leaf u_000 (), u_001 (), …, u_099 ();` (one
|
||||
module, 100 comma-separated instances); all 100 came back as sorted,
|
||||
individual rows. Filed here as a QA-harness bug, not a feature bug — the
|
||||
server encoder was never wrong.
|
||||
|
||||
**3. Format-5 discipline — confirmed by hand.** Walked the `as_a_format_4_record`
|
||||
field-stripper (`crates/lucisv_server/src/index_cache.rs:600`) against the
|
||||
actual encoder field order in `facts.rs` by counting fields myself: a unit's
|
||||
group is `name, kind, name_span×2, decl_span×2, detail_span×2, lines×2` (10
|
||||
fields) then `positions` (2 `Utf16Range`s × 4 = 8 fields) = 18, and an
|
||||
instantiation's occurrence is `name, name_span×2, span×2, name_positions×4,
|
||||
positions×4` = 13 fields behind its own count field. The two `drain` calls
|
||||
remove exactly those, in descending index order so neither shifts the
|
||||
other's target before it runs — `as_a_format_4_record` really does yield
|
||||
what format 4 wrote, not a fabricated shape that merely fails to decode for
|
||||
some other reason. `cargo test` confirms `a_format_4_record_without_instance_occurrences_is_rejected`
|
||||
and the belt-and-braces assertion both still pass.
|
||||
|
||||
**4. Search honesty — confirmed by hand, previously untested at this
|
||||
precision; two regression tests added to `hierarchyModel_test.js`.**
|
||||
- `topKSearchMatchesWhatAFullSortWouldChoose` — five instances of one
|
||||
module scored against `fifo` by the documented rule (exact/prefix/
|
||||
substring/subsequence tiers, arithmetic shown in the test's own comment);
|
||||
asserts the counting cutoff's capped-at-3 answer is `["fifo", "fifo_ctrl",
|
||||
"ffifo"]` in that order with `truncated: 2`, and that an uncapped call
|
||||
returns all five in the same relative order. This is the "same top
|
||||
results a full sort would give" check the charter asked for; nothing like
|
||||
it existed before (the 120k-entry budget test only measures speed and a
|
||||
cap that is tautologically consistent with its own `truncated` field).
|
||||
- `theBitmaskPrefilterNeverExcludesATrueSubsequenceMatch` — an independent,
|
||||
un-bitmasked `isSubsequence` checker (does not call `maskOf`) confirms six
|
||||
adversarial (haystack, needle) pairs really are subsequence matches,
|
||||
including escaped-identifier-shaped names with `$`, `.` and `[]` (all of
|
||||
which fold onto the same "other" bit in `maskOf`'s coarse classification),
|
||||
then asserts `fuzzyScore` and `searchHierarchy` both find them too. By
|
||||
construction (every character sets some bit, and the "other" bucket can
|
||||
only make the prefilter more permissive, never less) this class of bug is
|
||||
not reachable, but it was previously asserted nowhere.
|
||||
- The existing 120k-entry fixture's `N more matches` check
|
||||
(`found.truncated === found.total - SEARCH_LIMIT`) is real but narrower
|
||||
than it looks: `truncated` is *defined* as `total - rows.length`, so the
|
||||
assertion is actually pinning `rows.length === SEARCH_LIMIT` exactly when
|
||||
over the cap, not independently verifying `total`'s own correctness. Not a
|
||||
bug — `total` comes from the same counting pass the charter already asked
|
||||
me to hand-verify above — but worth recording so a future reader does not
|
||||
mistake it for a hand-checked "right N".
|
||||
|
||||
**5. Complete/held semantics — confirmed as documented, not independently
|
||||
re-driven through the widen machinery.**
|
||||
`a_snapshot_is_never_answered_complete_while_a_rescan_is_owed`
|
||||
(`server.rs:5523`) sets `rescan_wanted = true` directly rather than
|
||||
triggering a real scope widen, but `rescan_wanted` is exactly, and only, the
|
||||
flag every real widen path sets (`server.rs:1833,1870,1927`, all three
|
||||
verified by inspection) before `must_wait` holds the request — so the test
|
||||
exercises the true mechanism, not a stand-in for it. Did not add a
|
||||
heavier end-to-end "trigger a real widen, then race a snapshot against it"
|
||||
test; diminishing returns against the direct flag test already there.
|
||||
|
||||
**6. Perf reproduction — independently reproduced on
|
||||
`/Users/guoliangchen/repo/opentitan`, matches the claimed numbers closely.**
|
||||
Built `--release`, drove a hand-rolled LSP client over stdio (workspace
|
||||
scope pulled via `workspace/configuration`, `--verbose` for server-side
|
||||
handler timing), no test dependency. Settled:
|
||||
- 1 544 modules (README claims 1 544 — exact match).
|
||||
- Snapshot 2 335 713 B (README: 2 335 749 B on its own run — 36 B apart,
|
||||
consistent with ordinary opentitan corpus drift between runs).
|
||||
- Server-reported handler time settled at 16.3–17.98 ms across two runs
|
||||
(README: 17–20 ms — inside range, in fact slightly faster).
|
||||
- Client round trip over stdio settled at 29.9–36.7 ms (README's "end to
|
||||
end… settled" is 39–44 ms; this machine is somewhat faster end to end,
|
||||
same order of magnitude, same conclusion: no file is read per snapshot).
|
||||
- First request after the real workspace-scope index landed (the
|
||||
cold/rescan-blocked one) took 1.2–3.1 s across two runs — consistent with
|
||||
"a request pipelined behind a rescan waits for the rescan," not a
|
||||
regression, since the round only claims the *settled* number.
|
||||
Did not separately reproduce the `didSave`-plus-re-pull ~141 ms figure
|
||||
(would need a second harness pass simulating an editor save); the settled
|
||||
snapshot and rescan-blocked numbers above exercise the same code paths that
|
||||
number is built from.
|
||||
|
||||
**7. Full gates — all green, including new tests.**
|
||||
- `cargo fmt --all -- --check` clean (after `cargo fmt` on my own new test
|
||||
code).
|
||||
- `cargo clippy --all-targets --workspace` silent.
|
||||
- `cargo test --workspace`: 0 failed. `lucisv_server` unit tests
|
||||
1 300 passed / 33 ignored (1 297 + 3 new design_hierarchy tests), `e2e`
|
||||
63 passed / 2 ignored, `vlog_semantic` `workspace` suite 77 passed —
|
||||
matching the work log's counts plus my additions.
|
||||
- `hierarchyModel_test.js`, `hierarchyView_test.js`, `restart_test.js`
|
||||
(44 checks), `smoke.js` (against a `--release` build) — all OK.
|
||||
|
||||
**Tests added this pass.**
|
||||
|
||||
| test | where | pins |
|
||||
|---|---|---|
|
||||
| two new sources in `an_indexed_position_is_the_position_the_wire_converter_would_have_given` | `design_hierarchy.rs` | CRLF+LF mixed in one file; instance on the module header's own line |
|
||||
| `duplicate_module_names_across_files_stay_two_distinct_rows` | same | two `module dup` declarations stay two wire rows, never merged |
|
||||
| `an_escaped_identifier_names_a_module_and_an_instance` | same | `\weird$leaf `/`\u$inst ` round-trip the wire unmangled |
|
||||
| `one_hundred_instances_of_one_module_are_one_hundred_sorted_rows` | same | 100 instances of one statement are 100 sorted rows |
|
||||
| `topKSearchMatchesWhatAFullSortWouldChoose` | `hierarchyModel_test.js` | the counting cutoff picks the same top-K a full sort would, checked by hand |
|
||||
| `theBitmaskPrefilterNeverExcludesATrueSubsequenceMatch` | same | an independent, un-bitmasked subsequence check against escaped-identifier-shaped names |
|
||||
|
||||
**Findings.**
|
||||
|
||||
| severity | finding |
|
||||
|---|---|
|
||||
| low (harness/process, not code) | `git diff master` on this worktree conflates two unrelated upstream commits with this round's own changes; use `git diff HEAD` (`merge-base HEAD master` = `40094c4`, this branch's own base) — flagged so the lead doesn't review a phantom deletion of `a_widen_that_subsumes_the_old_scope_reads_only_the_files_it_adds`. |
|
||||
| informational | The 120k-entry `N more matches` assertion is tautologically tied to its own `total`/`rows.length` definitions rather than an independent oracle; not wrong, now supplemented by a hand-checked small fixture (finding 4 above). |
|
||||
| informational | `complete`/`must_wait` is pinned via a direct flag set rather than a live-triggered widen; the flag is the real mechanism's own signal, so this is a documentation note, not a gap requiring more test weight. |
|
||||
|
||||
No masked-corruption risk, no `verify.rs` change, no `unsafe`, no new
|
||||
dependency, no `FACTS_FORMAT` 6, no commits made.
|
||||
|
||||
## Review
|
||||
|
||||
**2026-08-29 — lead.** Reviewed across the whole arc: codex's
|
||||
implementation (externally contributed; UI architecture and the
|
||||
flat-snapshot/client-tree split were right from the start), the lead's
|
||||
own QA pass that measured the 5 s / 300 ms-per-save snapshot cost, the
|
||||
fix round (index-carried positions folded into the format 5 codex was
|
||||
already minting — one bump, not two; schema 2 forced by arithmetic,
|
||||
with codex's client model rebuilt byte-for-byte behind validateSnapshot),
|
||||
the owner's three UI rulings (preview removed, collapsed by default,
|
||||
resident-model search with the freeze diagnosed three ways), and QA's
|
||||
SHIP with independent oracles added where the round's own tests were
|
||||
self-consistent. Gates re-run by the lead on the worktree. The wire
|
||||
break from codex's schema 1 is accepted: no shipped client ever spoke
|
||||
it, and the model layer preserves the contract where code actually
|
||||
reads it. Search-as-ranked-list instead of filtered tree is accepted
|
||||
as the necessary consequence of the flat model the owner asked for,
|
||||
with the tree-only actions honestly labeled. The --stdio hotfix is
|
||||
mirrored here and merges clean with master's. Accepted; merged by the
|
||||
lead. Credit: codex (implementation), Opus dev (integration fixes),
|
||||
Sonnet QA, the owner's live UI feedback.
|
||||
|
||||
_(reserved for the lead.)_
|
||||
@@ -41,13 +41,24 @@ impl WorkspaceIndex {
|
||||
fn fingerprint(&self) -> String; // 2026-08-27
|
||||
fn find_define(&self, name: &str) -> Vec<(FileId, &Define)>;
|
||||
fn workspace_symbols(&self, query: &str) -> Vec<WorkspaceSymbol<'_>>;
|
||||
fn units_of(&self, SymbolKind) -> impl Iterator<Item = (&str, &Def)>; // 2026-08-29
|
||||
fn counts(&self) -> IndexCounts;
|
||||
}
|
||||
|
||||
struct Def { file: FileId, name_span: TextRange, kind: SymbolKind,
|
||||
struct Def { file: FileId, name_span: TextRange, decl_span: TextRange, // 2026-08-29, hierarchy sidebar
|
||||
kind: SymbolKind,
|
||||
detail_span: Option<TextRange>, // 2026-08-28, port-detail-spans
|
||||
lines: DeclLines } // 2026-08-28, hover-line-index
|
||||
struct DeclLines { name: u32, detail: Option<u32> } // 1-based source lines
|
||||
struct DeclLines { name: u32, detail: Option<u32>, // 1-based source lines
|
||||
positions: Option<DeclPositions> } // 2026-08-29, hierarchy sidebar
|
||||
// Where a *file-scope* declaration sits as a client counts positions, so an
|
||||
// editor can be pointed at a module in a closed file with no read at all.
|
||||
// `None` for a member: members outnumber units by two orders of magnitude and
|
||||
// nothing wants theirs, and the record's `U` and `M` groups are separate, so a
|
||||
// member spends no field on the absence.
|
||||
struct DeclPositions { name: Utf16Range, decl: Utf16Range }
|
||||
struct Utf16Range { start: Utf16Pos, end: Utf16Pos }
|
||||
struct Utf16Pos { line: u32, character: u32 } // 0-based line, UTF-16 units
|
||||
struct WorkspaceSymbol<'a> { name: &'a str, container: Option<&'a str>, def: &'a Def }
|
||||
struct IndexCounts { files, modules, packages, typedefs, members, defines }
|
||||
|
||||
|
||||
Reference in new issue
Block a user