An instance-oriented hierarchy view in the Activity Bar — lucisv/moduleHierarchy snapshots (schema 2: uri table, flat ranges, derived ids; 11.6 MB -> 2.3 MB on opentitan) plus lucisv/moduleHierarchyChanged invalidation, gated on the extension's initializationOptions. Format 5 carries decl spans, instance occurrences and client positions for file-scope declarations (+1.7-1.9 % store), so a snapshot reads no files at all: handler 145-167 -> 17-20 ms settled, a save with the sidebar open 366 -> 141 ms. complete is !scanning && !must_wait, pinned. Owner UI rounds: no hover preview, all levels collapsed by default with stable ids across refreshes, and search over a resident flat model (freeze diagnosed: materialized expanded tree x undebounced double fuzzyScore x whole-tree clone per keystroke) — prebuilt lowercased index, bitmask prefilter, top-K counting, 200-row cap with an honest remainder, single-digit ms over a 120k-entry fixture. LineIndex::utf16_position unifies the index's and the wire's position math under a cross-crate agreement test. Implementation: codex. Integration fixes + owner items: Opus dev. QA: lead (measurement pass) + Sonnet (SHIP, independent oracles). Co-Authored-By: Claude Fable 5 <[email protected]>
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:
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
recursiveand does not open again, soA -> B -> Ais 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 matchesline.
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.
- Copy Full Path —
- 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. Novscodedependency, 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 bargaindocs/features/hover-line-index/README.mdstruck forDeclLines. - A client position is 0-based lines and UTF-16 code units, which is what an
LSP
Positioncounts in and not whatLineIndex::line_colreports. 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
Declexactly 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):
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 Decls 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
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
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
{
"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:
rescan_wantedis only ever set whilescanningis true, and is consumed inside the scan loop beforescanninggoes false.must_wait()sets any request aside — held, unanswered — whileanswering_a_rescanorrescan_wantedis set or anything is alreadyheld. A snapshot therefore only ever reaches the flag with all three clear. Socompleteis 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
InstanceOccurrenceon the statement edge, populated through the shared instantiation walk; call hierarchy and code lenses unchanged.Def::decl_span, so a module's whole-construct range needs no reparse.DeclPositionsonDeclLinesfor file-scope declarations, andUtf16Rangeon every instance occurrence — the snapshot's zero-I/O fix.LineIndex::utf16_position, shared by the index and the wire converter.WorkspaceIndex::units_of, so a snapshot does not walk every member.- Record codec: all of the above in
FACTS_FORMAT5, with round-trip and old-format-rejection tests. lucisv/moduleHierarchy+lucisv/moduleHierarchyChanged, gated oninitializationOptions.hierarchyView.- Schema 2: file table, four-number ranges, no ids, no per-instance definition copies — 11.6 MB → 2.3 MB on opentitan.
completetightened toindex_is_complete()and written down.- Client: flat resident model, lazy tree levels, prebuilt search index.
- Owner 2026-08-29: hover source preview removed.
- Owner 2026-08-29: every level collapsed by default.
- Owner 2026-08-29: search runs in memory, debounced, capped, and never re-requests or rebuilds.
cargo fmt/cargo clippy --all-targets/cargo test --workspace, and all four node scripts.- Not done, deliberately:
locate::locationis not rewired ontoDeclPositions.textDocument/definition, references, the lens and both hierarchies still read a file to convert aDef's span to aLocation, 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
Mgroup. - 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 invalidateSnapshot— 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:
buildHierarchymaterialized the entire expanded tree the moment a snapshot arrived.instanceNoderecursed 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.- Every keystroke walked that whole tree.
searchwas posted on the rawinputevent with no debounce; the host ranfilteredHierarchy, which visited every node and calledfuzzyScoretwice per node, each calltoLowerCase()-ing a name — one allocation per node per keystroke. - Every keystroke then shipped the whole tree to the webview.
render()postedroots: model.roots.map(serializeNode)— a deep copy of every node, structured-cloned across the webview boundary — and the webview rebuilt itsnodesmap and re-created DOM for everything visible, with no cap.
The fix, against each of the three.
- Resident and flat.
buildHierarchynow keeps exactly the snapshot — modules and their instances — plus a resolvedtargetIdper 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. - One prebuilt index, scanned once per query.
searchIndexbuilds 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. - Only the rows shown cross the boundary. The host posts a flat
rowsarray — 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 anN 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 declaringmodule 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$leafand\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 wroteleaf u_000 (), leaf u_001 (), …(repeating the module keyword per instance, invalid Verilog), which the parser silently produced zero instances for. Fixed toleaf 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 Utf16Ranges × 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 againstfifoby 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 withtruncated: 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 owntruncatedfield).theBitmaskPrefilterNeverExcludesATrueSubsequenceMatch— an independent, un-bitmaskedisSubsequencechecker (does not callmaskOf) 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 inmaskOf's coarse classification), then assertsfuzzyScoreandsearchHierarchyboth 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 matchescheck (found.truncated === found.total - SEARCH_LIMIT) is real but narrower than it looks:truncatedis defined astotal - rows.length, so the assertion is actually pinningrows.length === SEARCH_LIMITexactly when over the cap, not independently verifyingtotal's own correctness. Not a bug —totalcomes 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 -- --checkclean (aftercargo fmton my own new test code).cargo clippy --all-targets --workspacesilent.cargo test --workspace: 0 failed.lucisv_serverunit tests 1 300 passed / 33 ignored (1 297 + 3 new design_hierarchy tests),e2e63 passed / 2 ignored,vlog_semanticworkspacesuite 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--releasebuild) — 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.)