TODO §56 (docs/features/dut-hierarchy), the owner's request of 2026-09-06.
Client-only, over the flat `lucisv/moduleHierarchy` snapshot the server
already sends. `hierarchySections.js`: per starred DUT, in starred
order, the DUT's forward subtree (the DUT at the top) and an upward tree
from the DUT through every module that instantiates it (labelled `via
<instance>`, cycles cut with one `recursive` row), then one section for
every module in no DUT's subtree or ancestor closure, re-rooted where
its only parents are DUT ancestors (the review ruling — a monitor beside
the DUT under the same bench stays on screen); a module both below one
DUT and above another appears in both DUT sections; a starred name the
index lacks keeps its sections with a "not in the index" row. Star and
unstar from the webview row menu (the pane is a WebviewView, so the
menu is the renderer's, driven by a `menuTable()` per render), the
`lucisv.hierarchy.{starDut,unstarDut,clearDuts}` commands and title
actions, persistence in `workspaceState` in starred order, and the
`lucisv.hierarchy.duts` setting whose entries show locked. With nothing
starred the pane is byte-identical to before (pinned).
opentitan `hw/ip` (847 modules): `aes` → 3 sections with `tb` in its
parents and 5 modules under `aes_tb` re-rooted into others; `aes` +
`hmac` → 5 sections; every module reachable in both configurations; QA's
200-trial fuzz found no overlap and no gap. `extract_test.js` added to
`.vscodeignore`.
(Committed after the 0.48.0 version commit: the release chain broke at a
test-output grep and cut the tag one commit early; the tag is moved here.)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
663 lines
39 KiB
Markdown
663 lines
39 KiB
Markdown
# dut-hierarchy
|
||
|
||
## Goal
|
||
|
||
A design holds hundreds of modules and one — or a few — that matter: the DUT,
|
||
usually with a testbench above it. The hierarchy pane treats every module the
|
||
same, so the module the user actually works on is buried among roots that are
|
||
alphabetically ahead of it and its DV bench is a root of its own. This feature
|
||
lets the user **star a module as DUT** from the pane's context menu and splits
|
||
the pane into sections: per starred DUT, **the DUT with its children** (its
|
||
forward instance subtree, the DUT at the very top) and **the DUT's parents** (an
|
||
upward tree from the DUT through every module that instantiates it,
|
||
transitively — typically the DV), then one **all other modules** section. One
|
||
DUT gives three sections, two DUTs five. Unstar from the same menu. Everything
|
||
is composed in the extension over the snapshot the server already sends
|
||
(`lucisv/moduleHierarchy`: `files`, `modules`, `instances`, flat) — the server
|
||
changes nothing in this round.
|
||
|
||
## Assumptions
|
||
|
||
- **The pane is a `WebviewView`, not a `TreeDataProvider`.** That was decided in
|
||
`docs/features/vscode-hierarchy-sidebar` (a webview is the only API at the
|
||
extension's VS Code floor with a persistent search input inside the view).
|
||
Consequences for this feature are in Handshakes: there is no `viewItem`
|
||
context key and no `view/item/context` menu; the row menu is the pane's own
|
||
HTML menu, driven by a per-row `contextValue` the host computes.
|
||
- The reverse edge "module → modules that instantiate it" is exactly the
|
||
forward edge read backwards: an instance contributes an edge only when its
|
||
type resolves to exactly one declaration (`instance.targetId`), which is the
|
||
same rule the forward tree uses. An unresolved or ambiguous type contributes
|
||
no upward edge, so an ambiguous DUT name has an empty parents tree — the same
|
||
answer the forward view gives for ambiguity.
|
||
- Two declarations of one module name are two modules. A starred *name* that
|
||
several declarations carry is resolved to the first in the model's
|
||
deterministic order and the section is marked `ambiguous`; the other
|
||
declarations keep their ordinary place in the pane.
|
||
- **`others` is additive** (the lead's ruling, 2026-09-05, replacing the
|
||
question this bullet used to ask). The owner's spec is "any dangling module
|
||
that is not a child of the DUT would be put in a different section", so
|
||
`others` holds **every module that is in no DUT's forward subtree and in no
|
||
DUT's ancestor closure** — not `model.roots` minus that set. Its roots are the
|
||
members of that set with no parent left inside it: a monitor the DV bench
|
||
instantiates beside the DUT is not a child of the DUT, and with the bench
|
||
excluded it has no parent on screen, so it is re-rooted at the top of
|
||
`others`. A module that still has an ordinary parent stays under it and is not
|
||
re-rooted, so nothing is shown twice. An `others` root's forward subtree is
|
||
the plain, unfiltered one: a module that is also below a DUT is still shown
|
||
under its parent here, exactly as before. A DUT itself can never appear in
|
||
`others` — everything that instantiates it is in its ancestor closure and is
|
||
therefore excluded.
|
||
- Starring is an explicit user act, so it may expand rows on the user's behalf:
|
||
the two new sections and the DUT row inside each open once, when the DUT list
|
||
changes. This is the second exception to the owner's 2026-08-29 rule that
|
||
nothing expands by itself (the first is a bookmark's ancestor chain).
|
||
- **A bookmark is painted wherever its own path is on screen**, and a path is
|
||
what is stored — not an instance. Bookmarking inside a DUT section stores the
|
||
DUT-relative path (`aes.u_ctrl`) and is painted there; bookmarking under a
|
||
root stores the full path and is painted there. The two are different paths
|
||
to one instantiation, so a bookmark made in one place is not painted in the
|
||
other, and a bookmark whose path runs through an excluded module
|
||
(`tb.u_dut.…` while `dut` is starred) is not painted at all until the DUT is
|
||
unstarred — the module it names may well still be on screen, but not at that
|
||
path. Nothing is ever *lost*: the model
|
||
still resolves the path, so `refresh()` never drops it. Tested in
|
||
`hierarchySections_test.js::aBookmarkIsPaintedWhereverItsPathIsShown`.
|
||
- The `lucisv.hierarchy.duts` setting is a workspace-level list a team checks
|
||
in. Its entries cannot be unstarred from the pane, because the pane cannot
|
||
edit a checked-in file on the user's behalf; the menu says so.
|
||
|
||
## Handshakes
|
||
|
||
### `hierarchyModel.js` — three additive changes, no behaviour change
|
||
|
||
Consumed: `buildHierarchy`'s flat model (`modules`, `byId`, `roots`, per-instance
|
||
`targetId`), `childrenOf`, `treeRows`, `idForPath`, `searchHierarchy`.
|
||
|
||
Promised/changed by this feature (all additive, the plain pane byte-identical):
|
||
|
||
- `rootNode` is now exported. `hierarchySections.js` builds a section's root
|
||
from it and re-ids it with the section prefix; every descendant id is derived
|
||
from the parent id, so one prefix moves a whole subtree into its section.
|
||
- `treeRows`' rows and `searchRow`'s rows carry `moduleName` (for a tree
|
||
instance row, the instantiated type — the same string the label shows in
|
||
parentheses). It is what lets the star/unstar decision be a pure function of a
|
||
row.
|
||
- `bookmarkChain` keeps its roots-first walk and, **only when that finds
|
||
nothing**, retries over every module. A row inside a DUT section has a
|
||
DUT-relative full path (`aes.u_ctrl`), and without the retry bookmarking such
|
||
a row would store a path that can never be re-resolved. Every path that
|
||
resolved before resolves to the same chain.
|
||
|
||
### `hierarchyView.js` ← `hierarchySections.js`
|
||
|
||
- `sections(model, duts)` → the section list (below).
|
||
- `sectionRows(model, sections, expanded, bookmarkPath)` → `{ rows, nodes }` in
|
||
exactly the shape `treeRows` returns, with the section header at depth 0 and
|
||
everything under it shifted one level.
|
||
- `decorate(rows, duts, locked)` → the same rows with a `contextValue`
|
||
(`module`, `module.dut`, `module.dut.locked`, `instance`, …) and, for a locked
|
||
DUT, a `title` tooltip.
|
||
- `menuTable()` → `contextValue` → the menu items that row offers. Sent once per
|
||
render; the webview renders `payload.menus[row.contextValue]` and has no rule
|
||
of its own.
|
||
- `sectionPrefixes(duts)` → the id prefixes, so the bookmark's ancestor
|
||
expansion reaches the copy of the chain inside each section.
|
||
- `defaultOpenIds(sections)` / `OTHERS_ID` → what a star opens once, and the
|
||
one section it closes.
|
||
|
||
### `media/hierarchy.js` (the renderer)
|
||
|
||
- Builds the row menu from `payload.menus[row.contextValue]` instead of a fixed
|
||
list, and opens it for any row whose `contextValue` has items (module rows
|
||
included — previously only instances had a menu).
|
||
- Renders `row.icon` when the host sends one (section and notice rows) and
|
||
`row.title` as the row tooltip.
|
||
|
||
### The server — nothing
|
||
|
||
No request, notification or schema change. The upward tree is one pass over the
|
||
snapshot already sent.
|
||
|
||
### Requested of the lead (docs this lane may not edit)
|
||
|
||
See "Docs to apply at merge (lead)".
|
||
|
||
## Status / TODO
|
||
|
||
- [x] 56.1 model: reverse map, `sections()`, others-exclusion, cycle cut
|
||
(`editors/vscode/hierarchySections.js`)
|
||
- [x] 56.2 view: section nodes, icons, context values, persistence, setting
|
||
union (`editors/vscode/hierarchyView.js`, `media/hierarchy.js`)
|
||
- [x] 56.3 commands, menus, `package.json`, tests, acceptance checklist row
|
||
- [x] Gates: `node --test editors/vscode/*_test.js`; server smoke; the vsix
|
||
package step; the plain view pinned unchanged
|
||
- [x] A real opentitan snapshot through `sections()` with `aes`, then
|
||
`aes` + `hmac`
|
||
- [x] Rework (lead's ruling): `others` is additive — every module outside every
|
||
DUT, re-rooted where the exclusion took its parents
|
||
(`editors/vscode/hierarchySections.js`, `hierarchySections_test.js`)
|
||
- [x] Hygiene: `extract_test.js` in `.vscodeignore`
|
||
- [ ] Docs the lead applies: `README.md`, `docs/site/` editors page
|
||
- [ ] QA
|
||
|
||
## Work log
|
||
|
||
### 2026-09-05 — dev (the whole of §56)
|
||
|
||
**Shipped.**
|
||
|
||
- `editors/vscode/hierarchySections.js` (new, 284 production lines): the reverse
|
||
index, `sections()`, the upward tree, `sectionRows()`, `decorate()` and
|
||
`menuTable()`.
|
||
- `editors/vscode/hierarchySections_test.js` (new): every shape §56 lists.
|
||
- `editors/vscode/hierarchyModel.js`: `rootNode` exported, `moduleName` on
|
||
tree/search rows, `bookmarkChain`'s all-modules retry.
|
||
- `editors/vscode/hierarchyView.js`: the DUT list (workspaceState + setting),
|
||
the three commands, section rendering, the seeded default expansion, the
|
||
menu table in the render payload.
|
||
- `editors/vscode/media/hierarchy.js`, `media/hierarchy.css`: a menu built from
|
||
the payload, section/notice icons, row tooltips.
|
||
- `editors/vscode/package.json`: three commands, three more `view/title`
|
||
entries, the `lucisv.hierarchy.duts` setting.
|
||
- `editors/vscode/.vscodeignore`: the new test file is not shipped.
|
||
- `editors/vscode/README.md`, `docs/manual-acceptance.md`: the user-facing text.
|
||
|
||
**The section algorithm.** `sections(model, duts)` walks the starred list in
|
||
order. For each name it emits `{ kind: 'dut', name, root }` — `rootNode` for the
|
||
named module, re-ided `dut:<name>/root:<id>`, so the subtree under it is exactly
|
||
the one the plain pane shows — and `{ kind: 'parents', name, root }`, whose root
|
||
is the same module as an *upward* node (`parents:<name>/up:<id>`) and whose
|
||
children come from the reverse index: one child per (module, instance) pair with
|
||
`instance.targetId === node.moduleId`, labelled with the instantiating module
|
||
and `via <instance name>`. The walk carries a `seen` set down the path, so a
|
||
cycle (`a` instantiates `b` instantiates `a`) closes with one row marked
|
||
`recursive` that does not open again — the same shape the forward tree uses.
|
||
Both trees are lazy: children are built when a row is opened, never before.
|
||
|
||
While walking, the DUT's forward subtree and its full ancestor closure are
|
||
collected into one `excluded` set of module ids. `{ kind: 'others', roots }` is
|
||
`model.roots` filtered by that set. Two consequences, both intended and tested:
|
||
|
||
- **Both below and above.** A module below DUT1 and above DUT2 is in both DUT
|
||
sections (it is reached by two different walks, with two different id
|
||
prefixes, and opens independently in each) and is excluded from `others`.
|
||
- **The excluded-root cost.** `others` loses a root that is an ancestor of a
|
||
DUT, and with it anything only reachable through that root. See Assumptions.
|
||
|
||
A starred name the snapshot does not hold keeps both of its sections; each shows
|
||
a single non-expandable notice row, so the section count stays `2 × DUTs + 1`
|
||
whatever the index says.
|
||
|
||
**Persistence and the setting.** The starred list lives in `workspaceState`
|
||
under `lucisv.hierarchy.duts`, an array of names in the order starred, written
|
||
on every star/unstar/clear and read (and sanitized — non-strings and blanks
|
||
dropped) in the constructor. The `lucisv.hierarchy.duts` *setting* (string
|
||
array, `window` scope — the pane is workspace-wide, not per file) is read on
|
||
every render and on
|
||
`onDidChangeConfiguration`. The effective list is the union, **setting entries
|
||
first in setting order, then starred entries the setting does not already
|
||
name**; setting entries are "locked": starring one again is a no-op, unstarring
|
||
one is refused with the reason, and their rows carry the locked `contextValue`
|
||
whose menu holds one disabled item whose tooltip says where the DUT comes from.
|
||
`lucisv.hierarchy.clearDuts` empties the starred list only, and says so when the
|
||
setting still names DUTs.
|
||
|
||
**Deviation from the plan, and why.** §56.3 asks for `view/item/context` entries
|
||
gated on `viewItem`. The pane is a `WebviewView`; VS Code has no `viewItem`
|
||
context key for it and would never show such a menu, so contributing one would
|
||
be dead configuration. The intent — "the menu shows Unstar DUT on a starred
|
||
module and Star as DUT on any other" — is delivered by the pane's own HTML menu:
|
||
the host stamps every row with a `contextValue` and ships one `menuTable()` per
|
||
render, and the renderer shows exactly the items that table names. The three
|
||
commands are contributed and work from the palette (each takes an optional
|
||
module name, and prompts with a Quick Pick when invoked without one), and
|
||
`view/title` carries "Clear DUTs" and the existing entries. The `when` clauses
|
||
that do exist (`view == lucisv.hierarchy`) and the whole `contextValue` → menu
|
||
table are asserted in `hierarchySections_test.js`.
|
||
|
||
**Second deviation.** The plan's "others" is exclusive (see Assumptions); the
|
||
owner's sentence "all other modules" could be read as additive, which would
|
||
re-root a DV bench's monitor when its bench is excluded. The plan won; the lead
|
||
should rule if the manual pass finds it surprising on opentitan. On `hw/ip` the
|
||
whole cost of the exclusion is three roots out of 295, all of them benches, so
|
||
it reads as intended there. *(Superseded the same day: the lead ruled for the
|
||
additive reading — see the rework entry below. Everything above describes what
|
||
the first round shipped, `others` included.)*
|
||
|
||
**Two corrections made while reviewing my own code, both with the reasoning
|
||
written next to them.** (1) `treeOrSections` records the "already seeded" key
|
||
even when the DUT list is empty, so starring the same module again after a
|
||
"Clear DUTs" seeds its sections again instead of trusting a stale key; it is
|
||
only weakly observable (the expansion set keeps the ids), so the test asserts
|
||
the re-starred sections are open rather than the key itself. (2)
|
||
`collectSubtree` walks with its own visited set rather than the shared
|
||
exclusion set: a module already excluded as DUT1's *ancestor* would otherwise
|
||
stop DUT2's downward walk at it, leaving that walk short. With today's root
|
||
choice the difference cannot change `others.roots` (nothing below a module is a
|
||
root), so it is a defensive correction with no test of its own — said here
|
||
rather than left silent.
|
||
|
||
**Files touched outside the plan's expected set.** Three, all consequences of
|
||
the two above: `editors/vscode/media/hierarchy.js` and `media/hierarchy.css`
|
||
(the pane's renderer is where a webview's row menu lives, so the star/unstar
|
||
items had to be built there), and `editors/vscode/.vscodeignore` (the new test
|
||
file must not ship). Noted while there and **not** fixed, because it is not
|
||
this feature's: `extract_test.js` is missing from `.vscodeignore` and is
|
||
therefore packaged into the .vsix — a one-line hygiene fix for whoever owns
|
||
that file next.
|
||
|
||
**Not done.** Nothing in the plan is unfinished. Two things a later round could
|
||
take further, both written down rather than smuggled in: the additive reading
|
||
of `others` above, and a bookmark that follows an instantiation rather than a
|
||
path (see Assumptions).
|
||
|
||
**Opentitan, real snapshot** (release server over `hw/ip`, `index.scope` pushed
|
||
to `workspace`, scratch `storagePath`, read-only — `git status --porcelain` on
|
||
the checkout showed the same three pre-existing modified files before and
|
||
after). 835 files, 847 modules, 295 roots, `complete: true`.
|
||
|
||
| starred | sections | DUT section | parents section | others |
|
||
|---|---|---|---|---|
|
||
| — | 1 | — | — | 295 roots |
|
||
| `aes` | **3** | `aes`, 5 direct children, 577 rows fully open | `aes` → `aes_tb`, `aes_wrap`, **`tb`**; `aes_wrap` → `aes_wrap_tb` (5 rows) | 292 roots |
|
||
| `aes`, `hmac` | **5** | + `hmac`, 11 direct children, 302 rows | + `hmac` → `tb` (2 rows) | 291 roots |
|
||
|
||
The DV bench is in `aes`'s parents section, which is the point of the feature.
|
||
The three roots `aes` drops from `others` are `aes_tb`, `aes_wrap_tb` and `tb`
|
||
— exactly its transitive ancestors; `hmac` drops the *other* declaration named
|
||
`tb` (two files declare one, and they are two modules). `sections()` over the
|
||
whole of `hw/ip` costs 2.85 ms the first time (it builds the reverse index) and
|
||
0.15 ms after.
|
||
|
||
**Gates.** `tools/guard.sh -- node --test editors/vscode/*_test.js`: 5 files,
|
||
all pass. `cargo build --release -p lucisv_server` + `tools/guard.sh -- node
|
||
editors/vscode/smoke.js target/release/lucisv-server`: OK. `npx @vscode/vsce
|
||
package` into the scratchpad: OK (the contributions validate).
|
||
|
||
### 2026-09-05 — dev (rework: `others` is additive)
|
||
|
||
The lead ruled on the question the first round left open (Assumptions, now
|
||
rewritten): the owner's "any dangling module that is not a child of the DUT
|
||
would be put in a different section" is additive, so a monitor beside the DUT
|
||
under the same bench belongs in `others`, and the exclusive formula that put it
|
||
in *no* section was wrong. Only `others` changed — the two DUT sections, the id
|
||
scheme, the memoized reverse index and the seeded expansion are untouched.
|
||
|
||
**The algorithm.** `othersRoots(model, excluded)` replaces
|
||
`model.roots.filter(…)`. The set is every module not in `excluded` (unchanged:
|
||
each DUT's forward subtree plus its ancestor closure); its roots are the members
|
||
with no parent left in the set, emitted in three passes over one shared
|
||
`covered` set:
|
||
|
||
1. `model.roots` minus the excluded — today's answer, and with nothing starred
|
||
it is still the whole answer, byte-identical to `model.roots`. Each one marks
|
||
its forward subtree covered.
|
||
2. Every remaining module that is neither excluded nor covered and has no
|
||
parent in the set: re-rooted. This is the monitor whose bench is in the
|
||
DUT's parents section.
|
||
3. Whatever is still uncovered is inside a recursive component no root enters —
|
||
the model's own fallback rule, and marked `recursive` the way the model
|
||
marks it.
|
||
|
||
Roots come out in the model's order (alphabetically, then the fallbacks), which
|
||
is exactly how `buildHierarchy` orders `model.roots`, so the section does not
|
||
grow an odd tail. Coverage is what prevents duplicates: a module reachable from
|
||
one excluded and one ordinary parent is covered by the ordinary parent's walk in
|
||
pass 1 and is never re-rooted. It cannot be duplicated the long way round
|
||
either, and that is a property of the exclusion rather than of the pass order: a
|
||
path from one module of the set to another can never leave the set, because a
|
||
module above an ancestor of the DUT is itself an ancestor, and a module below
|
||
the DUT's subtree is itself in it — both excluded. So a pass-2 candidate is
|
||
reachable from no other root in the section. A root's forward subtree is still the plain,
|
||
unfiltered one — a module that is also below a DUT is shown under its parent
|
||
here as before, and a *DUT* can never turn up in it, because everything that
|
||
instantiates a DUT is in that DUT's ancestor closure. Coverage skips a module it
|
||
has already descended through, so the whole pass is one walk over the graph.
|
||
|
||
**Tests** (`hierarchySections_test.js`, 16 → 21). A `graph({ module: [types] })`
|
||
helper builds the small snapshots. New: the monitor beside the DUT (`bench →
|
||
{dut, monitor}` — `monitor` is a root of `others`, `bench` is in the parents
|
||
section, and every module in the snapshot is asserted to be on screen
|
||
somewhere); a module under **two** excluded benches (re-rooted once, not twice);
|
||
a module with one excluded and one ordinary parent (shown once, under the
|
||
ordinary parent); two DUTs whose benches nest (`bench → {dut1, sub_bench}`,
|
||
`sub_bench → {dut2, monitor}` — five sections, `monitor` re-rooted); and a cycle
|
||
reachable only through an excluded bench (pass 3 — opened at a `recursive`
|
||
root). The existing exclusion test keeps its name's meaning but is renamed
|
||
`othersHoldsEveryModuleOutsideEveryDut`: starring `leaf2` now re-roots `leaf1`
|
||
and `leaf3`, which it used to hide. `thePlainViewIsUntouched` is unchanged and
|
||
green.
|
||
|
||
**Opentitan, re-derived** (release server over `hw/ip`, `index.scope` pushed to
|
||
`workspace`, scratch `storagePath`; `git status --porcelain` on the checkout
|
||
showed the same three pre-existing modified files before and after). 835 files,
|
||
847 modules, 295 roots, `complete: true`.
|
||
|
||
| starred | others before | others after | re-rooted |
|
||
|---|---|---|---|
|
||
| — | 295 | 295 | — |
|
||
| `aes` | 292 | **297** | `aes_tb_c_dpi`, `aes_tb_reqs`, `tlul_adapter_tb_reqs`, `tlul_delayer`, `vh_regs` |
|
||
| `aes`, `hmac` | 291 | **297** | the five above + `hmac_if` |
|
||
|
||
All five are instantiated only by `aes_tb` (`hw/ip/aes/pre_dv/aes_tb/rtl/`),
|
||
which is one of `aes`'s excluded ancestors; `hmac_if` is instantiated only by
|
||
`hmac`'s `tb`. Every one of them was in no section at all before this rework.
|
||
No root the old formula kept was lost, and a walk over the new `others` roots
|
||
plus the DUT sections reaches every one of the 847 modules — nothing is off
|
||
screen with `aes` or with `aes` + `hmac` starred.
|
||
|
||
**Cost.** `sections(model, ['aes'])` over the whole of `hw/ip`: 1.9 ms → 3.5 ms
|
||
on the first call (both dominated by building the reverse index) and 0.03 ms →
|
||
0.33 ms on later ones — one extra walk over 847 modules per render of a starred
|
||
pane. With nothing starred the pane never calls `sections()` at all
|
||
(`treeOrSections` returns `treeRows`), so the plain view pays nothing.
|
||
|
||
**Also fixed here** (the hygiene item the first round found and left):
|
||
`extract_test.js` is now in `editors/vscode/.vscodeignore`, so no `*_test.js`
|
||
ships in the .vsix — confirmed against the packaged file list.
|
||
|
||
**Gates.** `tools/guard.sh -- node --test editors/vscode/*_test.js`: 5 files, 5
|
||
pass, 0 fail. `npx @vscode/vsce package` into the scratchpad: OK, 338 files.
|
||
|
||
## QA log
|
||
|
||
### 2026-09-06 — QA (Sonnet 5)
|
||
|
||
**Scope.** Read the plan (TODO §56), the dev's account (this README, both
|
||
work-log entries), and the diffs of every file it lists. Attacked the model
|
||
and view with scratch tests (removed afterwards, none of the lane's files
|
||
touched besides this log and the TODO checkbox), re-derived the opentitan
|
||
numbers against the real, read-only checkout, and ran every gate.
|
||
|
||
**1. Sections — attacked on the existing fixtures, `graph()`, and new scratch
|
||
graphs (`/private/tmp/.../scratchpad/attack_sections.js`, removed).** All of
|
||
the following hold, matching the algorithm's own description and this
|
||
README's Assumptions:
|
||
|
||
- Zero/one/two DUTs: `2n+1` sections, order = starred order (pinned by the
|
||
dev's `oneDutIsThreeSectionsAndTwoAreFive`).
|
||
- A DUT that is a root: its parents section holds only the DUT row, no
|
||
children (`parents.root.hasChildren === false`) — verified with a fresh
|
||
`dut → leaf` graph.
|
||
- A DUT that is a leaf: its DUT section is the DUT alone
|
||
(`dut.root.hasChildren === false`) — verified with `bench → dut`.
|
||
- A DUT instantiated twice by one parent: the parents tree shows the parent
|
||
**twice**, one row per instance, each with its own `via <instance>` label
|
||
and its own row id — a 2-way explore tree, as the plan asked. Verified with
|
||
`bench → [[dut,u_dut_a],[dut,u_dut_b]]`.
|
||
- A module instantiated by two benches, itself instantiating the DUT: the
|
||
upward tree branches at that node (two children under `mid`). Verified.
|
||
- A parent chain of depth 6: the upward walk climbs all six levels,
|
||
`depth` incrementing by one per hop. Verified.
|
||
- Two DUTs where DUT2 is inside DUT1's subtree (`dut1 → dut2 → leaf`): DUT2
|
||
appears both under DUT1's forward tree (unfiltered — `dutSection`'s root is
|
||
always the plain subtree) and as its own two sections; DUT1 appears in
|
||
DUT2's parents tree. Five sections, all present and correctly shaped.
|
||
Verified, and the mirror (starring DUT2 before DUT1) changes only section
|
||
*order*, never content.
|
||
- The same module starred twice: `sections()` itself performs **no dedup** —
|
||
`sections(model, ['dut','dut'])` yields 5 sections (two DUT×2 pairs plus
|
||
others). Dedup is the caller's job: `hierarchyView.js`'s `moduleNames()`
|
||
wraps every stored/configured list in a `Set` before it ever reaches
|
||
`sections()`, and this is exercised in the dev's own `hierarchyView_test.js`
|
||
(`configuredDuts = ['top', '']`, the blank and any repeat dropped). Pinning
|
||
this contract here so a future caller of `sections()` that skips
|
||
`moduleNames()` doesn't get a silent surprise (see LOW finding below).
|
||
- A starred name absent from the snapshot: both its sections keep a single
|
||
non-expandable "not in the index" notice row; section count stays `2n+1`
|
||
(dev's `aStarredNameTheSnapshotLacksKeepsItsSections`, re-run, green).
|
||
- A starred name matching two declarations: `ambiguous: true` on both
|
||
sections, header says "ambiguous", the **first** declaration in the model's
|
||
order is what is shown (dev's `twoDeclarationsOfOneNameAreMarkedAmbiguous`).
|
||
Went one step further than the existing test: confirmed the Assumptions
|
||
claim that "an ambiguous DUT name has an empty parents tree" actually holds
|
||
— with two declarations of `dut`, `tb`'s instance of `dut` becomes
|
||
itself ambiguous (`instance.definitions.length === 2`), so `targetId` is
|
||
unset and the reverse index carries no edge to either declaration;
|
||
`parents.root.hasChildren` is `false`. This isn't special-cased code, it
|
||
falls out of `parentIndex` using `instance.targetId` — correct and matches
|
||
the forward view's own ambiguity answer, as documented.
|
||
- A cycle through the DUT itself (`a → b → a`, starred `a`): both the forward
|
||
walk and the upward walk terminate at one `recursive`-marked row that does
|
||
not reopen (dev's `theParentsWalkCutsACycle`); re-verified.
|
||
- **Others is additive and complete.** Re-ran the dev's own reasoning as a
|
||
fuzz test: a seeded-random 40-module DAG (0.15 edge probability, i < j only
|
||
so it's acyclic — plus deliberately keeping a couple of exact-duplicate
|
||
edges to also exercise the twice-instantiated case), 200 random DUT
|
||
selections (1–3 DUTs each). For every trial: every one of the 40 modules is
|
||
on screen in some section, and no module is both an `others` root and a
|
||
member of any starred DUT's forward subtree. 200/200 trials passed with no
|
||
failures.
|
||
- No module appears in `others` *and* in a DUT subtree: covered by the fuzz
|
||
test above (assertion is exactly this) and by the dev's own
|
||
`othersHoldsEveryModuleOutsideEveryDut`/`aModuleUnderAnExcludedBenchIsReRootedInOthers`.
|
||
- A module both below DUT1 and above DUT2: dev's
|
||
`aModuleBothBelowOneDutAndAboveAnotherIsInBothSections` — two rows, two ids,
|
||
neither in `others`; re-run, green.
|
||
- Re-rooted module ordering: `othersRoots` emits in `model.roots`' own order
|
||
(alphabetical, then fallbacks) — confirmed by reading `othersRoots` and by
|
||
the passing `aModuleUnderTwoExcludedBenchesIsReRootedOnce` /
|
||
`aCycleReachableOnlyThroughAnExcludedBenchStillHasARoot` tests (recursive
|
||
fallback root correctly marked).
|
||
- A module with one excluded and one ordinary parent: shown once, under the
|
||
ordinary parent, never re-rooted (dev's
|
||
`aModuleWithOneOrdinaryParentIsNotReRooted`; re-run, green).
|
||
- **The plain view is byte-identical to `model.roots` with no DUT.** Read
|
||
`thePlainViewIsUntouched`: it is a real deep-equality check over every
|
||
visible field (`id, kind, label, detail, depth, hasChildren, expanded,
|
||
warning, bookmarked`) between `decorate(treeRows(...).rows, [], [])` and
|
||
`treeRows(...).rows` directly — not a placeholder. Also confirmed
|
||
structurally: `treeOrSections()` in `hierarchyView.js` calls `treeRows`
|
||
directly and never calls `sections()` at all when `duts.length === 0`, so
|
||
the plain pane pays zero extra cost, exactly as claimed.
|
||
|
||
**2. View/persistence.** Read and re-ran `hierarchyView_test.js`'s DUT block
|
||
(lines ~199–330): the fake-`workspaceState` round trip (star, "reload" via a
|
||
second `HierarchyView` over the same `state` map, order kept, `7` and `''`
|
||
dropped by `moduleNames`'s sanitizer); the setting union (setting entries
|
||
first, locked, unstar refused with the exact reason string, re-star a
|
||
no-op with an information message); `onDidChangeConfiguration` re-render
|
||
(`configurationChanged({...})` reshapes the section list); `clearDuts` clears
|
||
stars only (locked setting DUT's section survives, with a message naming it);
|
||
the seeded expansion opens the two new sections and the DUT row at depth 1 in
|
||
each, `others` stays closed, and — the dev's own "two corrections" note —
|
||
re-starring the same module after a `clearDuts` reseeds (`seededFor` keeps
|
||
recording even at `duts.length === 0`). All green as shipped.
|
||
|
||
Added one attack of my own the plan explicitly asked for and the existing
|
||
tests don't cover directly: **collapsing a DUT section survives an unrelated
|
||
snapshot refresh.** Built a second fake-`vscode` harness
|
||
(`attack_sections.js`, removed after the run) that stars a DUT, collapses its
|
||
section via a `toggle` message, then fires the `lucisv/moduleHierarchyChanged`
|
||
notification handler with the *same* starred list and waits out the refresh
|
||
debounce. The section stayed collapsed. This is exactly what
|
||
`seedExpansion`'s `if (this.seededFor === key) return;` guard promises (`key`
|
||
is unchanged when the DUT list doesn't change), and it held.
|
||
|
||
**Search inside sections and reveal-on-open — read, not just tested, because
|
||
the plan's phrasing assumed more than the feature does.** `render()` in
|
||
`hierarchyView.js` sends search results (`searchHierarchy`) as a **flat** list
|
||
whenever the query box is non-empty, entirely independent of which sections
|
||
are open or which DUTs are starred — this is pre-existing behaviour from
|
||
`vscode-hierarchy-sidebar`, unchanged by §56. A search hit still gets a
|
||
correct `contextValue` via `decorate(found.rows, duts, locked)`, so
|
||
star/unstar works from a search result, but there is no per-section grouping
|
||
of search results to "resolve into" — search was never section-shaped, before
|
||
or after this feature, and nothing in the README's Handshakes claims
|
||
otherwise ("the existing search... behaviour work[s] inside every section"
|
||
means it keeps working, not that it becomes section-aware). Not a defect.
|
||
Likewise, **no "reveal a file's module when it is opened" feature exists
|
||
anywhere in this codebase** — grepped `editors/vscode` for
|
||
`onDidOpenTextDocument`/`activeTextEditor`/`revealOnOpen` and found nothing,
|
||
in this feature or the sidebar it builds on. The QA brief's "reveal-on-open of
|
||
a file whose module is only in a parents section" item does not correspond to
|
||
an implemented or claimed capability; the only reveal behaviour that exists is
|
||
bookmark-driven (`setBookmark` expands the bookmarked row's ancestors), which
|
||
*is* implemented per-section (`sectionPrefixes`) and is covered by
|
||
`aBookmarkIsPaintedWhereverItsPathIsShown` — re-run, green, and its claims
|
||
(DUT-relative path painted inside the section, ordinary path painted at the
|
||
root, a path through an excluded module painted nowhere but never dropped)
|
||
all hold on inspection of `isBookmarked`/`bookmarkChain`'s retry.
|
||
|
||
**Bookmark painting inside a DUT section.** Matches the README exactly: a
|
||
bookmark is a stored *path*, painted wherever that exact path resolves to an
|
||
id on screen (`isBookmarked` matches the bookmark id or `.../<id>` suffix per
|
||
section prefix). Re-verified `bookmarkChain`'s all-modules retry does not
|
||
change any *previously resolving* path's id (the retry only changes which
|
||
node search order finds a match through; `rootNode(model, module, false)`'s
|
||
`false` for `fallback` affects only `detail`/`warning` display fields on a
|
||
node that is never rendered — the chain is an array of ids, and `rootNode`'s
|
||
`id` field does not depend on `fallback`). No crash, no incorrect painting in
|
||
any of the model/view tests or the scratch attacks.
|
||
|
||
**3. Menus/commands.**
|
||
|
||
- `menuTable()` per render: read and re-verified against
|
||
`contextValuesAndMenusSayWhatEachRowOffers` — a starred row → `[UNSTAR]`, an
|
||
ordinary row → `[STAR]` (or `INSTANCE_ACTIONS + STAR/UNSTAR` for an
|
||
instance), a locked row → one disabled item with the setting-naming
|
||
tooltip. Every `contextValue` `decorate()` can produce has a menu entry
|
||
(asserted by the same test's closing loop) — no row can silently offer
|
||
nothing.
|
||
- The three commands exist in `package.json`'s `contributes.commands`
|
||
(`starDut`, `unstarDut`, `clearDuts`) and in `view/title` gated
|
||
`"when": "view == lucisv.hierarchy"` — confirmed by reading `package.json`
|
||
directly and by the dev's `packageJsonContributesTheCommandsMenusAndSetting`
|
||
test, both green.
|
||
- Ran every command through the extension's registered handler with the
|
||
dev's fake `vscode` (`commands.get(...)`), with and without a module name:
|
||
`starDut('top')` (named) and `starDut()` (Quick Pick, `picked` captures the
|
||
candidate list — confirmed sorted, deduped, and scoped correctly: "every
|
||
module name" for starring, "only what this workspace starred" for
|
||
unstarring). Both paths work; re-run, green.
|
||
- The `lucisv.hierarchy.duts` setting's `contributes.configuration` entry:
|
||
`type: "array"`, `items.type: "string"`, `scope: "window"`,
|
||
`default: []`, with a `markdownDescription` naming both the checked-in and
|
||
starred routes and the lock — read directly in `package.json` and pinned by
|
||
the dev's test.
|
||
- `.vscodeignore` excludes every `*_test.js`: listed all five
|
||
(`extract_test.js`, `hierarchyModel_test.js`, `hierarchySections_test.js`,
|
||
`hierarchyView_test.js`, `restart_test.js`) against the file and confirmed
|
||
none of them, nor any other `*_test.js`, appears in `npx @vscode/vsce
|
||
package`'s file listing (§5 below).
|
||
|
||
**4. Opentitan (read-only, scratch index store).** Re-derived the dev's table
|
||
independently, with my own hand-rolled LSP client
|
||
(`/private/tmp/.../scratchpad/opentitan_client.js`, removed after the run) —
|
||
`initializationOptions.storagePath` under the scratchpad,
|
||
`lucisv.index.scope: "workspace"` pushed via `workspace/didChangeConfiguration`,
|
||
`rootUri`/`workspaceFolders` pointed at `hw/ip`, polling
|
||
`lucisv/moduleHierarchy` until `complete: true`.
|
||
|
||
| starred | sections | others roots | direct parents |
|
||
|---|---|---|---|
|
||
| — | 1 | 295 | — |
|
||
| `aes` | 3 | 297 | `aes_tb`, `aes_wrap`, `tb` |
|
||
| `aes`, `hmac` | 5 | 297 | `aes`: same three; `hmac`: `tb` |
|
||
|
||
835 files, 847 modules, 295 roots, `complete: true` — matches the dev's
|
||
numbers exactly. The five re-rooted names the dev called out
|
||
(`aes_tb_c_dpi`, `aes_tb_reqs`, `tlul_adapter_tb_reqs`, `tlul_delayer`,
|
||
`vh_regs`) are present in the `others` list for `aes`; `hmac_if` joins them
|
||
only once `hmac` is also starred — matches. Verified independently (not just
|
||
by trusting the label) that opentitan really does declare 31 separate modules
|
||
named `tb` across `hw/ip` (`grep -rl '^module tb\b'`), so `aes`'s `tb` and
|
||
`hmac`'s `tb` genuinely are two different modules, as the dev's note claims.
|
||
`sections(['aes'])`: 4.2 ms cold, 0.6 ms warm (my machine/session, not a
|
||
controlled comparison against the dev's 2.85 ms/0.15 ms, but the same order of
|
||
magnitude and the same qualitative shape — most of the cost is the one-time
|
||
reverse-index build). **Full-reachability check**: walked the module graph
|
||
directly (not the rendered tree, to stay linear over 847 nodes) from every
|
||
DUT's forward+ancestor closure plus every `others` root's forward subtree —
|
||
**847 of 847 modules reachable** for both `['aes']` and `['aes','hmac']`. No
|
||
module is off screen in either configuration.
|
||
|
||
`git -C /Users/guoliangchen/repo/opentitan status --porcelain` before and
|
||
after this session's use: unchanged, exactly the three pre-existing modified
|
||
files (`hw/ip/aes/dv/tb/tb.sv`, `hw/top_darjeeling/ip/ast/rtl/ast.sv`,
|
||
`hw/top_earlgrey/ip/ast/rtl/ast.sv`).
|
||
|
||
**5. Gates.**
|
||
|
||
- `tools/guard.sh -- node --test editors/vscode/*_test.js`: 5 files, 5 pass, 0
|
||
fail (`extract_test.js`, `hierarchyModel_test.js`,
|
||
`hierarchySections_test.js`, `hierarchyView_test.js`, `restart_test.js`).
|
||
- `tools/guard.sh -m 8 -t 900 -- cargo build --release -p lucisv_server`:
|
||
already up to date (0.02 s, no crate source changed by this lane — verified
|
||
`git status --porcelain -- crates/` is empty), binary present.
|
||
- `tools/guard.sh -- node editors/vscode/smoke.js target/release/lucisv-server`:
|
||
OK, 20 messages, includes a passing `lucisv/moduleHierarchy` round trip.
|
||
- `npx @vscode/vsce package` into the scratchpad: OK, 338 files, 3.1 MB, no
|
||
`*_test.js` in the listing; guard not required (not a test/fuzzer/sweep, and
|
||
it finished in a few seconds well under any memory concern, consistent with
|
||
how the dev logged the same step).
|
||
- No guard kill on any run.
|
||
|
||
**Findings.**
|
||
|
||
- LOW — `sections(model, duts)` performs no de-duplication of its own `duts`
|
||
argument (confirmed by direct test: two identical names cost two identical
|
||
section pairs). Today's only caller (`hierarchyView.js`'s `treeOrSections`)
|
||
always passes `this.duts()`, which is already deduped through
|
||
`moduleNames()`'s `Set`, so this is not reachable from the shipped extension
|
||
today. Worth a one-line doc comment on `sections()` saying the caller owns
|
||
dedup, so a future caller (a test, a second view) doesn't get a surprise
|
||
five-section render from `['aes','aes']`. Not blocking.
|
||
- LOW — the QA brief's "search inside every section" and "reveal-on-open of a
|
||
file" items don't correspond to implemented behaviour: search has always
|
||
been flat/section-independent (pre-existing, unchanged by §56), and no
|
||
file-open reveal feature exists in this extension at all (verified by grep
|
||
across `editors/vscode` for `onDidOpenTextDocument`/`activeTextEditor`/
|
||
`revealOnOpen`). Recorded here so the brief isn't silently treated as
|
||
satisfied; nothing to fix in the dev's code — the feature never promised
|
||
either shape.
|
||
- No MEDIUM or HIGH findings. Every shape in TODO §56, the model's own
|
||
Assumptions, and the rework's stated invariants held under direct testing,
|
||
fuzzing (200 random DUT selections over a random 40-module DAG), and a real
|
||
847-module snapshot.
|
||
|
||
**Verdict: PASS.** No rework needed. The two LOW items above are hygiene notes
|
||
for a later round, not conditions on this one.
|
||
|
||
## Review
|
||
|
||
**2026-09-06 — lead.** Accepted after one ruling; ships in 0.48.0. This is
|
||
the owner's request built as asked — star from the row menu, the DUT with
|
||
its children at the very top, its parents as an upward tree, all other
|
||
modules in one collapsible section, two sections per DUT plus one — and
|
||
built where it belongs, in the extension over the snapshot the server
|
||
already sends, with no server change. The one deviation (a webview row
|
||
menu rather than `view/item/context`, because the pane is a `WebviewView`)
|
||
delivers the intent exactly. The ruling: the first version's "others"
|
||
dropped any module reachable only through a DUT's ancestors — a monitor
|
||
beside the DUT under the same bench — which the owner's "any dangling
|
||
module not a child of the DUT" does not allow; the rework re-roots them,
|
||
and on opentitan that put five real modules under `aes_tb` back on screen,
|
||
with a walk over every section reaching all 847 modules in both
|
||
configurations and QA's 200-trial fuzz finding no overlap and no gap. The
|
||
setting-with-lock for a team's checked-in DUTs is a good addition. QA's
|
||
LOWs (a doc comment on `sections()`'s de-dup contract; two brief items
|
||
that name no shipped capability) need nothing.
|
||
|
||
## Docs to apply at merge (lead)
|
||
|
||
`docs/topo.md`: one new node, `dut-hierarchy`, with a single inbound edge from
|
||
`vscode-hierarchy-sidebar` (it consumes that feature's model and renderer and
|
||
adds nothing the server sees). No edge to any Rust crate — the server is
|
||
untouched by this round.
|
||
|
||
For `README.md`'s VS Code section and the site's editors page:
|
||
|
||
> **DUT-centred hierarchy.** Right-click a module in the Hierarchy pane and
|
||
> choose **Star as DUT**. The pane splits into sections: the DUT with its
|
||
> children, the DUT's parents (an upward tree through everything that
|
||
> instantiates it — usually the testbench), and every module in neither —
|
||
> including whatever the bench held beside the DUT, which that last section
|
||
> re-roots rather than hide. Star a
|
||
> second DUT and you get five sections. Unstar from the same menu, or clear
|
||
> every DUT from the pane's title bar. Starred DUTs are remembered per
|
||
> workspace; a team can also check them in with
|
||
> `"lucisv.hierarchy.duts": ["aes", "hmac"]`, and DUTs that come from the
|
||
> setting are shown locked.
|