Round 3 of the census (mcp_analysis.md): with feedback-1/2 the whole-design question is one call and 15 % cheaper than plain file tools (47/47 in 9 calls); the small edits stay 4–19 % dearer; the cross-file rename is complete every time; a 71-instance hierarchy question costs a third of the tool calls but the same tokens because every unit_interface answer carried a 30-line template. Verdict: helpful, not a toy — no wrong answer in 20 runs, one-call whole-design answers, completeness on cross-file edits, verified writes — with a fixed catalogue tax and verbose answers as the cost. Feedback-3 (crates/lucisv_mcp/src/tools/{interface,hierarchy}.rs): `unit_interface` renders the template only with `template: true` (−40 % bytes), `hierarchy` renders `#(…)` only with `overrides: true` (−55…66 %), `ports (N):`/`parameters (N):` headers; QA proved the opt-in output byte-identical to the previous binary over every fixture and the opentitan clone. Docs: the Agents guide's tool table regenerated from the binary and the site rebuilt; CHANGELOG 0.57.0 section and the extension notes drafted for the closing release; TODO-MCP's M6 items closed; docs/mcp/census-runs.txt holds the raw run log. Gates through tools/guard.sh: fmt, clippy, workspace 4 953 passed.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
mcp-navigation
TODO-MCP.md M2 — the navigation, diagnostics and resource half of
lucisv-mcp: tools definition, references, hierarchy, diagnostics,
defines, and the lucisv:// resources. Design: docs/mcp/PLAN.md §4.2,
§4.3 and §4.5. The transport and Project they run on are
docs/features/mcp-transport; the rendering contract is
docs/features/mcp-read-tools's.
Goal
Let an agent ask the questions it otherwise answers by grepping and reading
whole files — where is this declared, who uses it, what instantiates what,
what does lucisv check say about this file, what does this macro expand
from — and get a compact, root-relative answer in one call. Every answer is
a composition of existing library queries (vlog_semantic's index and
overlay, vlog_refactor::find_references, vlog_linter's run); no language
knowledge lives in the MCP crate. The same answers the read tools give are
also addressable as lucisv:// resources for a host that attaches context
instead of calling tools.
Assumptions
- One selector for
definitionandreferences(tools/select.rs):file+line+col(1-based, byte column — the crate's one column unit; a column past the line's end is refused naming the line's length, one past the last byte is the end and allowed); orfile+line+name— the first token on that line spellingname(an identifier, or a macro use when written`NAME), so a comment or a string never stands in for the code; a name found only inside a macro call's argument text is refused ("inside a macro argument, which lucisv does not resolve; givecolon a plain use"); orfile+name— the name's one declaration in that file; else, when the file declares none, its uses, provided they all resolve to one declaration (uses naming different declarations are refused listing a line per target, "sigon line 2 → leaf.sv:1, line 6 → other.sv:1; addline"); else its first macro use; a name declared twice in the file is refused listing the lines; or a barenamewith an optionalunit, looked up in the index.unitwithfileis refused (two selectors at once);line/colwithoutfileis refused. definitionis the language server's ladder (nav.rs::at_position): an`includeline → the named file beside the including file only (no include-directory ladder: the MCP has no+incdirconfiguration to honour, and a miss says so); a macro use → the file's own last`definewhen it has one, else every indexed definition (the include graph is not modelled, so none is picked); then the file's symbol table, then the workspace overlay (resolve_externalcomputed per call against the current index — never cached, because the index moves under an unchanged file). A local declaration answers its completing declaration first (a non-ANSI port's body line), then its name, then every redeclaration the binder folded into it (Semantics::duplicates, sooutput y; wire y;lists the port and the net — the "both a port and an internal net" case), one site per line. By name: the unit declarations, the connection-surface members (workspace_symbolsfiltered to the exact name), and the hierarchical-only members (hierarchical_declarations); withunit,member_in(unit, name, Surface::Hierarchical);`NAME(or a name nothing else declares) answers the macro definitions. The by-name form reports what the index records — a redeclaration inside a unit is visible only through the position form, which has the file's own table. Ambiguity is always a list.- Every indexed span is re-checked against the bytes before it is
printed (
tools/source.rs::checked_site): the site is shown only when the file still spells the name there, so a stale index omits a site, never mislocates one (thespells_exactlyrule ofdocs/features/references-hierarchical-surface). One read per file per call (source::Texts). referenceshands the engine the whole indexed file set, always (lead's ruling on QA finding 1, replacing the M2 narrowing rule): every indexed file plus the selected one, read from disk at call time (nav.rs::all_files). A use resolves through files that never spell its name —u_a.u_b.signeeds the file declaringu_b,e.s.countneeds the class declarings— so no narrowing by the name's census is sound, and a narrowed set also turned an unresolvable use into the false refusal "declared outside the files lucisv indexes". Measured cost (release, whole opentitan checkout, 3 944 files, after the index exists; each call re-reads and re-parses the set):entropy_masking_req1.62 s,state_qfromentropy_src_main_sm.sv1.89–1.92 s, theaesinstantiation intb.sv1.70 s,clk_ifromprim_fifo_sync.sv2.55 s (83 hits); peak RSS of the session ~0.98 GB. Handshake MCP-7 is the way down. The engine's refusals are said as ours: prefixed "lucisv cannot follow this position: ", and the rename wording they share withrenamereplaced (nav.rs::engine_refusal). A macro use — by position or by a bare name that only a`definedeclares — is refused with a pointer todefines(the engine follows declarations, not macros).hierarchyis the textual instance census (WorkspaceIndex:: instantiations(), the edges the editor's hierarchy view and call hierarchy read):generateand`ifdefbranches all appear; an instantiation at file scope (abind) is not an edge, so a bound module is a "top". Down:instance : module #(overrides), a module instantiated N times under one parent listed N times; a module the index does not hold is marked(not indexed); a module declared more than once is marked(declared N times)and not expanded (which declaration an instance means is the elaborator's choice); a module already on the path is marked(recursive)and not expanded (a self-instantiatinggeneratetree terminates at once);depthdefaults to 3 and the schema accepts 1..=20 (Ty::Range, soinputSchemacarriesmaximum: 20and 21 is refused namingdepth); the walk stops at 50 000 nodes and says so. Up:parent.instance #(overrides) file:lineper instantiation ofroot, recursively. Withoutroot, down starts at every module nothing instantiates (a module that only instantiates itself is therefore not a default root; name it).- Override slicing: the text between the instantiated module's name at
the site (
InstantiationEdge::site_span) and the statement's first instance name (edge.instances[0].name_span— the#(...)belongs to the whole statement), read from the file now, comments dropped (source::without_comments, strings kept), whitespace collapsed, kept only when it starts with#and the file still spells the module name at the site. The text line caps it at 200 characters with…(opentitan'searlgrey_pd_maininstance carries hundreds of overrides);structuredContent.nodes[].overridescarries all of it.leaf #(.W(2)) u_a (), u_b ();shows#(.W(2))on both instances. - Structured
hierarchyis a flat, pageable node list in tree order, each{depth, instance, module, parent, file, line, overrides, note}(moduleis always the instantiated module;parentis set in theupdirection) — a nested tree cannot be paged withlimit/offset, and the depth field reconstructs it. diagnosticsanswers whatlucisv check .— the whole-tree run, CI's run — reports (lead's ruling on QA finding 5): the cross-file rules (unknown-port,unused-signal, …) always run, also when onefileis asked for, so one file's answer is that file's share of the whole-tree run, notlucisv check <file>(which, holding one file, runs none of them). The tool description says so. The config ladder islucisv check's, per file:Discovery::for_filefinds thelucisv.tomlgoverning it; its[lint] selectis the base set unless therulesargument is given (which replaces it, like--select);[lint] ignorethen removes; the run isselect_rules(select, ignore, workspace = true);[lint.<rule>]options go throughRuleOptions::set_raw(a bad one is refused namingfile:line, as the CLI fails);[lint] waiversfiles are read withExternalWaivers::readand applied bylint_with; the line length and tab width areline-length/indentelse the formatter's defaults (100, 2).severityfilters the findings afterwards. The workspace rules' cross-file questions are answered by the project index (Mentions, the server'sIndexMentions): one file asksmentioned_outsidedirectly; the whole-project form builds a word → (file count, first file) census once per call fromFileFacts::words, because the per-question walk over 3 944 records would cost minutes. Parse errors come first as ruleparse-error, severityerror, from the tolerant parse the file's analysis already holds; the JSON array uses the CLI's field names (filename,rule,severity,message,location{line,column},end_location,range{start,end},fix) withfilenameroot-relative. Missing-closer warnings are not offered: they are the language server'spairs::missing_end_diagnostics, not a library API, and the tolerant tree's diagnostics alone do not carry them. The whole-project form lints every indexed file (1.9 s on opentitan, 2 100 findings) and returns the firstlimit(default 500 since feedback-2) with the total. Unused external waivers: the whole-project form, being a complete run, reports each[lint] waiversdirective that suppressed nothing as anunused-waiverfinding against the waiver file (ExternalWaivers::unusedover the usage every file'slint_withreturned, per config; the severity the linter stamps, as the CLI does), whenunused-waiveris among the run's rules. The single-file form cannot know — a directive may fire in a file it did not lint — and reports none.defines:file→ that file's table as on disk (its`undefs included);name→ every indexed definition of it (find_define); neither → every indexed`define, paged. Each rowlinedefine NAME(params) body, the body one-lined and cut at 200 characters (UVM macro bodies run to hundreds of lines). **One-step expansion withargsis not offered**: the server'sexpand.rs` is ~260 production lines of argument splitting, default parameters, string/escape handling and token pasting — not the ~60 lines the lane allowed, and a second copy of it is exactly the duplication CLAUDE.md forbids. See Handshakes.- Resources (
src/resources.rs):lucisv://overview(text/plain,project_overview's text, walking first as the tool does) andlucisv://rules(text/markdown,vlog_linter::rules_markdown(), no index needed) inresources/list;lucisv://unit/{name}(unit_interface's text) andlucisv://file/{path}/outline(outline's text,pathroot-relative,%XXdecoded) inresources/templates/list. A read runs the read tool's own handler, so the two can never disagree. Any other URI, and one naming nothing (an unknown unit, a path outside the roots), is JSON-RPC-32002"resource not found: ()"; a missinguriis-32602.initializealready declaredresources: {}; nosubscribe/listChangedis offered. - A boolean argument type (
tools::Ty::Bool) was added to the registry forinclude_declaration; it validates like the others (true or falsein the refusal). Analysisnow keeps the tokens and the`definetable (project/analysis.rs): the lint context and the macro lookups need the tokens the parse consumed, so they are cloned once before the parse.
Handshakes
Consumed (public APIs only; no library crate was modified):
vlog_semantic:Semantics::{symbols_named, symbol, symbol_at, reference_at, reference_id_at, references, duplicates, scope},resolve_external,ExternalResolutions::{definition_of, get},ExternalTarget::best,WorkspaceIndex::{units, member_in, workspace_symbols, hierarchical_declarations, files_mentioning, files_naming_in_macros, mentioned_outside, find_define, defines, instantiations, instantiations_of, instantiable_units, members_of, facts_for, file_id, files, path},FileFacts::words,PackageExports::exports.vlog_parser:defines::{collect_defines, DefineTable, Define, DefineKind},token::{Token, TokenKind},LineIndex::{offset, line_range, line_col}.vlog_refactor::find_references.vlog_linter:LintContext::{from_parse, with_semantics, with_options, with_line_length, with_tab_width, with_oracle},lint_with,select_rules,RuleOptions::set_raw,ExternalWaivers::{read, absorb},MentionOracle,ModuleInterface,rules_markdown.lucisv_core::config::{Discovery::for_file, FileConfig};vlog_formatter::Config::default(the line-length and indent defaults).
Requests (none blocking):
-
MCP-7 →
vlog_refactor: afind_referencesvariant taking&dyn KnownFacts(asrename_traced_withdoes), so a caller holding a currentFileFactsrecord per text — M6's cache, or the MCP's own index — can skip re-parsing the whole set. Until then everyreferencescall parses all 3 944 opentitan files (~1.6–2.6 s release): the price of a correct answer (QA finding 1). -
MCP-5 →
vlog_parser(candidate): lift the server'sexpand.rs(single_step,has_macro_use,CAP) intovlog_parser::definesas a pure move, sodefinescan offer the one-step expansion the plan lists and hover keeps its own. Until thendefinesanswers the table only. -
MCP-6 →
lucisv_server(informational, a candidate finding): on opentitan,textDocument/referencesat theaesinstantiation and its.clk_iconnection inhw/ip/aes/dv/tb/tb.svanswers 11 and 9 locations;referenceshere answers 14 and 12 — the same locations plus the three top-level instantiations inhw/top_{earlgrey,darjeeling,englishbreakfast}/rtl/autogen/*_pd_main.sv(aes #(at 2069/1521/933 and their.clk_i(clkmgr_clocks_i.clk_main_aes)), which are real (hierarchyupfromaeslistsearlgrey_pd_main.u_aes). Stable after a 30 s settle, so not an indexing race. Not investigated in this lane. -
Resource wording:
lucisv://unit/{name}for a unit declared twice answers-32002withunit_interface's sentence, its "passfile" replaced by "call the unit_interface tool with its file argument to pick one" (resources.rs), since a URI has nofileargument. -
MCP-3 (PLAN §7) stays a candidate:
hierarchywalksinstantiations()keyed by the owner's(FileId, name_span.start)exactly asdesign_hierarchy::snapshotdoes; they agree on the fixtures and ontop_earlgrey. -
Wanted but worked around: a
Semantics::symbol_id(&Symbol)would savelocal_sitesasymbol_atlookup.
Status / TODO
definition: position / line+name / file+name / bare name (+unit) selector;`includeline; macro use; local (detail, name, redeclarations); cross-file overlay; by-name units, members, hierarchical members, macros; lists, never guessesreferences:find_referencesover the whole indexed set; grouped,line:col text,limit/offset,include_declaration; one- declaration rule for a bare name; macro refusalhierarchy: down (default: every top) / up,depth(3, cap 20), overrides,(not indexed),(declared N times),(recursive), node cap, flat structured listdiagnostics: parse errors + lint under the per-filelucisv.toml,rules,severity, waivers, index oracle, census for the workspace form, CLI JSON names,limit/offsetdefines: file / name / project table, body capped; expansion not offered (MCP-5)- resources: list, templates, read,
-32002 - QA rework: findings 1–11 fixed or ruled,
qa_m2.rs32/32 green - carry-over: M1 QA finding 11 (
read_item\a@12) fixed; the QA test un-ignored - wire tests over the new
tests/fixtures/navtree; the opentitan census (tests/opentitan.rs,#[ignore]) - gates through
tools/guard.sh; sizes
Work log
2026-09-23 (dev, M2).
Built: src/tools/nav.rs (selector, definition, references),
src/tools/hierarchy.rs, src/tools/diagnostics.rs, src/tools/defines.rs,
src/tools/source.rs (per-call file texts, checked sites, the word finder,
comment stripping and capping shared by the four), src/resources.rs;
tools/mod.rs registers the five tools and gains Ty::Bool/Args::flag;
rpc.rs answers the three resources/* methods from resources.rs;
project/analysis.rs keeps tokens and defines and computes the overlay on
request (Analysis::external), with token_at and line_text.
Decisions and deviations from PLAN/TODO:
- A new fixture tree
tests/fixtures/navinstead of extendingtests/fixtures/design: M1's wire and QA tests pin that tree's file count, unit counts, top modules and paging (… and 6 more), and a lucisv.toml with[lint]there would change them. The new tree has every case the brief listed: abindconnecting a bare net (core_bind.sv), au_core0.state_qtail (top.sv), a port that is also a net (dual.sv), a class member used through a handle in another file (tb/sb.sv,tb/env.sv), macros defined in an included.svhand used in two files,coreinstantiated twice undertopwith different#(...), a self-instantiatinggeneratetree (tree.sv), a five-deep chain ending in a missing module (chain.sv), and alucisv.tomlwith[lint] select,[lint.line-length] length = 40and a waiver file. - Two files beyond the brief's list:
src/tools/defines.rs(PLAN putdefinesinread.rs, M1's file) andsrc/tools/source.rs(helpers the four tools share; without ithierarchy.rsanddefines.rswould import fromnav.rs).src/main.rsgained the one linemod resources;— unavoidable for a new top-level module. - Two edits to existing tests, both forced by the lane:
wire.rs'stools_list_describes_every_tool_for_the_agentlists the eleven tools;qa_m1.rs'sqa_everything_but_initialize_and_ping_waits_for_the_handshakeassertedtools/listhas 6 entries, now 11 (with a comment). Neither weakens an assertion. - The selector grew
file+line+nameandfile+namebeyond the plan'sfile,line,col | name,unit?— agents rarely know byte columns.colstays exact. referencesrefuses a macro use (the engine would say "no symbol to rename", which reads wrong in a references answer) and points atdefines.hierarchytakeslimit/offsetand a 50 000-node cap (PLAN §4.5: every list is capped) and does not expand a module declared more than once (opentitan's technology variants:pinmux_jtag_breakout×4).- Missing-closer warnings and one-step expansion are not offered (Assumptions; MCP-5).
- Carry-over, M1 QA finding 11 (
tools/read_item.rs::select): when the@LINEreading matches nothing and the name starts with\, the whole spelling (after an optionalkind:) is tried as the name; the first refusal stands if that fails too. Unit testan_escaped_name_ending_in_at_digits_is_its_own_name_when_no_line_matches;qa_rework_an_escaped_name_ending_in_at_digits_is_selectable_by_itselfun-ignored and green.
The opentitan census (tests/opentitan.rs, one session over the whole
checkout, read-only). Wall time per call, debug build (the test) / release
build (the same calls through a stdio driver):
| call | debug | release |
|---|---|---|
| first call (index build, 3 944 files) | 10.1–10.4 s | 1.9 s |
references entropy_masking_req from aes.sv |
62 ms | 18 ms |
references state_q from entropy_src_main_sm.sv:42 |
928 ms | 165 ms |
references aes at tb.sv:45 |
266 ms | ~50 ms |
references .clk_i at tb.sv:46 |
10.0 s | 1.6 s |
references clk_i from prim_fifo_sync.sv |
9.9 s | 1.6 s |
hierarchy down top_earlgrey depth 2 |
22–384 ms | 10 ms |
hierarchy up prim_fifo_sync depth 1 (77 instances) |
21 ms | 7 ms |
definition prim_fifo_sync |
21 ms | 8 ms |
diagnostics hw/ip/aes/rtl/aes.sv |
8 ms | 7 ms |
diagnostics whole project (2 102 findings) |
— | 1.9 s |
Parity with the language server (release lucisv-server rebuilt at this
commit, same checkout, textDocument/references/definition at the same
positions): entropy_masking_req 6 = 6 locations (aes_bind.sv:45,54
included); state_q 5 = 5 (entropy_src_core.sv:3092 included); aes 14
⊇ 11 and .clk_i 12 ⊇ 9 (MCP-6); every definition equal. hierarchy
down from top_earlgrey depth 2 lists earlgrey_pd_main : earlgrey_pd_main and under it u_aes : aes #(...). diagnostics on
aes.sv finds nothing, as lucisv check does; uartdpi.sv's three
wire-reg-mixup findings match the CLI's. git -C opentitan status --porcelain was byte-identical before and after (the owner's three
modified files, untouched).
Tests: unit 28 → 37 (source 3, defines 2, resources 1, analysis 1,
read_item 1, tools/mod 1 extended; hierarchy 1); wire.rs 11 → 19;
qa_m1.rs 50 + 1 ignored → 51 + 0; opentitan.rs 1 (ignored).
Sizes (production lines: non-blank, non-comment, before #[cfg(test)]):
tools/nav.rs 446, tools/hierarchy.rs 311, tools/diagnostics.rs 293,
tools/defines.rs 158, tools/source.rs 134, resources.rs 112,
tools/mod.rs 146, rpc.rs 241, project/analysis.rs 77,
tools/read_item.rs 213, main.rs 68. No function over 50 lines.
Gates (all through tools/guard.sh, one cargo invocation at a time):
cargo fmt -p lucisv_mcp -- --check exit 0; cargo clippy -p lucisv_mcp --all-targets Finished, no warnings; cargo test -p lucisv_mcp unit 37
passed, opentitan 0 passed / 1 ignored, qa_m1 51 passed, wire 19
passed; cargo test --workspace exit 0 in 238 s, 4 566 passed, 0 failed,
47 ignored (4 548 before). The ignored census, run by hand as above:
1 passed in 32 s.
2026-09-23 (dev, M2 rework after QA). The lead's rulings on the QA
findings, as applied; every qa_m2.rs test is un-ignored and green (32).
- 1 (blocking) — ruled: the whole set.
tools/nav.rs::all_filesreplacesin_scope;leaves_fileandspelled_atare gone (nothing else used them). The false "declared outside the files lucisv indexes" refusal went with the narrowing. Wire testreferences_reach_bind_connections_hierarchical_tails_and_class_membersnow also asks from the use sites (top.sv:8tail,env.sv:4handle chain) and asserts the declaration's answer. Handshake MCP-7 filed; opentitan timings below. - 2 + 3 (blocking) — fixed. The selector moved to a new
tools/select.rs(nav.rs had reached 446 lines);select.rs::on_linepicks by token and refuses a name found only in a macro argument. - 4 (blocking) — fixed.
hierarchy.rs:Child::first(the statement's first instance name) ends the override slice;Child::ofbuilds both directions' children. Unit test extended with#(.W(2)) u_a (), u_b (). - 5 — ruled: whole-tree semantics kept. Tool description and
Assumptions say so; no code change.
qa_finding_5_…was written to assert single-file parity "delete it if the project-wide semantics is kept": I rewrote it (renamedqa_finding_5_one_files_diagnostics_match_lucisv_check_of_the_whole_tree) to assert the ruling —unknown-portreported fortop.svalone — rather than delete it, so the ruling stays pinned. - 6 — fixed.
diagnostics.rs:Run::used(aRefCell<WaiverUse>) merges every file's usage;Runs::unused_waiversreports after the whole-project loop;lint_findingtakes aLineIndexso a waiver file's findings render like any other.Runs::heldbecame aBTreeMapso the order is stable. - 7 — fixed.
tools/mod.rs:Ty::Range { min, max }(schemaminimum/maximum, refusal "an integer from 1 to 20");hierarchy'sdepthuses it and the silent.min(MAX_DEPTH)is gone.wire.rs's depth-99 call became 20 plus a 21-is-refused assertion;tools/mod.rsunit test pins the schema. - 8 — fixed.
select.rs::at_columnrefuses "line N is L bytes long;colC is past its end". - 9 — fixed.
nav.rs::engine_refusalprefixes and rewords the engine's six rename-worded sentences (vlog_refactoruntouched); unit testengine_refusals_are_prefixed_and_never_speak_of_renaming. A bare macro-onlynameis now refused as a macro too (QA's side note). - 10 — fixed.
resources.rsrewrites the "passfile" clause. QA's test asserts the message does not contain`file`(backticked), so the wording is "with its file argument" rather than the lead's backticked`file`— same meaning, test and ruling both honoured. - 11 (blocking) — fixed.
select.rs::one_useresolves every use of the name in a file that declares none (Analysis::external+definition_of); two or more distinct targets are refused listing a line per target.
Whole-set references on opentitan (release, stdio driver, after the
index): entropy_masking_req 1.62 s, state_q 1.92 s / 1.89 s, aes at
tb.sv:45 1.70 s, clk_i from prim_fifo_sync.sv 2.55 s; debug (the
census test): 9.8 s, 12.1 s, 10.9 s, 14.2–14.6 s. Answers unchanged from
the narrowed ones on every census symbol (6, 5, 14, 12 hits; the census
test's assertions still pass). The census test: 1 passed in 72 s; git status --porcelain of the checkout byte-identical before and after.
Sizes after the rework (same awk rule): tools/nav.rs 343,
tools/select.rs 177 (new), tools/hierarchy.rs 316,
tools/diagnostics.rs 313, tools/mod.rs 151, resources.rs 118; the
rest unchanged. No function over 45 lines.
Gates (through tools/guard.sh, one cargo invocation at a time):
cargo fmt -p lucisv_mcp -- --check exit 0; cargo clippy -p lucisv_mcp --all-targets Finished, no warnings; cargo test -p lucisv_mcp unit 38
passed, opentitan 1 ignored, qa_m1 51 passed, qa_m2 32 passed,
wire 19 passed; cargo test --workspace exit 0 in 254 s, 4 599
passed, 0 failed, 47 ignored.
2026-09-23 (dev, feedback-1). references now ends with an unresolved mentions section and carries unresolved_mentions in its JSON (handshake change: a new trailing section and a new JSON key; hits unchanged); references/definition/hierarchy descriptions trimmed, hierarchy leads with "who instantiates a module" — docs/features/mcp-feedback-1.
2026-09-23 (dev, feedback-3). hierarchy's text lines show the #( … ) overrides only on overrides: true (handshake change: the default line drops them; the JSON keeps overrides on every node) — docs/features/mcp-feedback-3.
QA log
2026-09-23 (QA, M2). Verdict: rework needed — four blocking findings
(1, 2, 4, 11: wrong or partial answers), seven non-blocking. No crash, no
hang, no write: every attack was answered, the server kept answering after
each refusal, and opentitan's git status --porcelain was byte-identical
before and after the whole session (the owner's three modified files).
Method: every attack against the real binary over scratch trees
(crates/lucisv_mcp/tests/qa_m2.rs, 32 tests: 20 green, 12
#[ignore = "QA finding N"] asserting the correct behaviour, each confirmed
failing for the stated reason with --ignored). Where "the right answer"
was in question, the oracle was vlog_refactor::find_references over the
whole file set (a throwaway binary in the QA scratch directory, not in the
tree) and target/release/lucisv check for diagnostics.
Findings
Blocking
referencesomits uses reached through a resolution-only file, and refuses from the use with a false sentence (tools/nav.rs:444-464,in_scope). (a)top2.sv: wire w2 = u_a.u_b.sig2;wheremid.sv(leaf u_b) never writessig2:references {name: sig2, unit: leaf}answers onlyleaf.sv:2:9; the whole-set engine also liststop2.sv:4:21(and drops it whenmid.svis removed from its set — the narrowing is the cause). (b) The class case the brief lists:e.s.countint.sv, withenv.sv(sb s;) never writingcount— same omission. From the use ({file: t.sv, line: 4, name: count})referencesis refused: "countis declared outside the files lucisv indexes, so a rename here would only be half a rename" — the declaration is indexed (definitionfinds it). The README's known limit names only a struct typedef; multi-level hierarchical tails and UVM handle chains (cfg.agent_cfg.x) are the common case. Testsqa_finding_1_a_two_level_tail_to_an_internal_net_is_a_reference,qa_finding_1_a_class_handle_chain_through_a_third_file_is_a_reference. Suggested fix (for the lead to rule, it touches the narrowing ruling): add the files that resolve the path — for a member of a unit, the up-closure of the unit's instantiating files (instantiations_of(owner)→edge.file, recursively overedge.owner.name); for a class member, the files declaring the types/classes the selected files name, to a fixed point — or fall back to the whole indexed set for names off the connection surface. At minimum an engine refusal on a narrowed set must not be reported as "declared outside the files lucisv indexes".file+line+nameinside a macro call's argument answers the macro'sdefine(tools/nav.rs:142-149viasource::word_in, thenat_position:233-239).top.sv:5isassign peek = `ID(u_core0.state_q);;definition {file: top.sv, line: 5, name: state_q}answersdefs.svh:1:9 define:define ID(x) x— a declaration of a different name. Testqa_finding_2_…. Fix: pick the occurrence by token — the first identifier token on the line spellingname(a macro token only whennameis ``NAME``); when the word is only inside a macro token, refuse naming the macro. The same change fixes finding 3.hierarchyoverrides of the 2nd+ instance of one statement include the earlier instances (tools/hierarchy.rs:359-367).leaf #(.W(2)) u_a (), u_b ();→u_b : leaf #(.W(2)) u_a (),(down, andov.u_b #(.W(2)) u_a (), ov.sv:4up; the JSONoverrideslikewise). The README's "sub u1 (), u2 ();shows the one#(...)on both instances" holds only when there are no overrides. Testqa_finding_4_…. Fix: end the slice at the edge's first instance name (carry it inChild), or take the balanced#( … )after the module name.file+nameguesses when the file's uses resolve to different declarations (tools/nav.rs:178-181,first_occurrence).top3.svdeclares nosig;u.signamesleaf's andv.signamesother's.definition {file: top3.sv, name: sig}answersleaf.sv:1:27alone andreferenceslists onlyleaf's — a pick, where the brief and the tool description say "ambiguity is a list, never a guess". Testqa_finding_11_…. Fix: when the file declares nothing, resolve every use ofname; more than one distinct target → refuse listing the lines (as the declared-twice rule does).
Non-blocking
file+line+nametakes the first textual occurrence, so one in a comment or string hides the code one:/* q */ assign q = a;→ "nothing at m.sv:2:6 names a declaration" (also"a" == a). Same place and fix as 2. Testqa_finding_3_….- One file's
diagnostics≠lucisv check <file>— the brief's parity criterion.diagnostics.rs:149always passesworkspace = truetoselect_rules, so the workspace rules (unknown-port,unused-signal,undeclared-identifier, …) run for one file, where the CLI runs them only when its run holds more than one file. Differences on opentitan:hw/ip/aes/dv/sva/aes_idle_check.sv17:28 unused-signal,hw/ip/aes/pre_dv/aes_sbox_tb/rtl/aes_sbox_tb.sv118:6 unknown-port,hw/ip/i3c/rtl/i3c_dat.sv134:17 unused-signal,hw/ip/kmac/rtl/sha3pad.sv776:37 unused-signal,hw/ip/entropy_src/pre_dv/entropy_src_tb.sv339:9 and 340:9 unknown-port — each one exactly whatlucisv check .reports for that file. Arguably the better answer (the project exists); it needs a lead ruling and a sentence in the tool description and README either way. Testqa_finding_5_…(asserts CLI single-file parity; delete it if the project-wide semantics is kept). - Unused external waivers are not reported (
diagnostics.rs:215discardslint_with's used-waiver answer). A[lint] waiversdirective matching nothing:lucisv check .(andcheck m.sv) reportw.waiver:1:1 unused-waiver;diagnosticssays "no findings". Testqa_finding_6_…. hierarchydepthabove 20 is silently the same as 20: the schema has nomaximum(Ty::Inthas onlymin), and a node cut by the depth limit looks like a leaf.hierarchy.rs:50-55,120. Testqa_finding_7_…. The brief's "depth 21 → schema refusal" is not what happens; 0 and negative are refused.- A
colpast the end of its line is clamped to the line end (LineIndex::offset), and the refusal names the clamped column (col: 99→ "nothing at clamp.sv:2:15 …").nav.rs:135-141. No wrong answer found (the clamped offset sits after the last token), but the agent is told about a position it did not ask for. Testqa_finding_8_…. referencesrefusals pass the rename engine's sentences through: "there is no symbol to rename at this position" (whitespace, a keyword, a comment) and "… a rename here would only be half a rename".nav.rs:394. Testqa_finding_9_…. Also a by-namereferences {name: ONLY_MAC}says "no declaration … is indexed" where the position form says "is a macro … (defineslists …)".lucisv://unit/{name}for an ambiguous unit is-32002(correct) but the reason says "passfileto pick one", which a URI cannot.resources.rs:94(the text isunit_interface's). Testqa_finding_10_….
Verified (green qa_* tests)
- Selectors: a package member through
import p::*and throughp::PW(definition + 4 references from either end); abindconnection's bare name (bind core chk u_chk (.s(state_q))→core.sv:2:9, 4 uses from the bind side and the declaration side); one- and two-level tails to a port (u_a.u_b.sig→leaf.sv:1:44, listed in references); the port-that-is-a-net lists header, body andwire(never picks), references 4; a class member declared in two classes lists both,referencesrefuses naming both,unitpicks; a name declared twice in one file is refused with its lines; an escaped identifier by name and by position; a macro-only name by name,`NAMEand position,referencesrefuses it with the pointer todefines; whitespace, a keyword, a comment: clean refusals;line: 0a schema refusal; past EOF and5 000 000 000refused; a column inside the two bytes oférefused (no panic, server alive); byte columns after a multibyte comment (zzat 29, not 27) and in a CRLF file;unitthat does not exist refused naming it. references: a comment and a string in a third file never reported; paginglimit/offsetwithtotalconstant and an offset past the end empty;include_declaration: false(also cross-file, from the use).hierarchy: agenerate-self-instantiation and mutual recursion terminate ((recursive), both directions); a 30-deep chain stops at 20;depth0, -1, 2.5, "3" anddirectionUp/sideways/""refused by the schema; a package, a class and an unknown name asrootrefused; a module declared twice marked(declared 2 times)and not expanded;upfrom a leaf with two parents lists both; overrides with a/* … ) … */comment, a// … )comment,c#(4)::Nand a string holdingu_x (are sliced right; 250 × 250 instances stop at 50 000 nodes withcut: true.diagnostics:[lint] select,ignore,[lint.line-length] lengthand a waiver file honoured under the root config, and a file underb/lucisv.tomlgets that config's own select and top-levelline-length = 60;rulesreplaces select while the config'signorestill applies (as the CLI'spick);severityfilters; parse errors first, then lint, in a file with both; the project form's pages concatenate to the whole list with a constanttotal; a bad option (length = 30) refused naminglucisv.toml:5; an unknown rule refused. Every expected string was checked againstlucisv checkon the same tree.defines: a macro defined in two files lists both (anddefinitionat a use lists both, never picks); a parameterised multi-line body one-lined; an unknown name "no defines";file+namefilters that file's table (with its`undef); a missing file refused.- Resources:
resources/templates/listentries carryuriTemplate,name,mimeType(andtitle,description);%20,%C3%BCand%25decode; an ambiguous unit, a bad escape (%,%FF),..%2F.., an absolute path outside the root, a directory, a symlink leading out,LUCISV://, a query string: all-32002, never a crash; a non-stringuri-32602. - Freshness: an edit shows in the next
referencesandhierarchy; a deleted declaring file makes the root refused and its instance(not indexed); a new file is seen after a miss-walk (M1's 5 s rule otherwise).
CLI-vs-MCP diagnostics (opentitan, release builds, no lucisv.toml)
- Single files, (rule, line, col) sets:
hw/ip/aes/rtl/aes.sv0 = 0,aes_core.sv,aes_cipher_core.sv,uart_core.sv,prim_fifo_sync.sv,aes_env_pkg.sv,tb.sv0 = 0;aes_scoreboard.sv4 = 4,uartdpi.sv4 = 4,aes_env_cfg.sv,dv_utils_pkg.sv,aes_base_vseq.sv1 = 1 — identical. The five files of finding 5 differ. - Whole project: MCP
diagnostics2 102 in 1.77 s vslucisv check .1 158 in 0.92 s. Lint findings identical except the symlinkhw/ip/tlul/rtl/tlul_adapter_shim.sv → tlul_adapter_vh.sv(the MCP lints the canonical path, M1's ruling, so the CLI'smodule-filenameon the shim name has no MCP twin). The other 941 areparse-error, whichlucisv checkdoes not report at all (by the plan).
opentitan (release, 3 944 files)
Index 1.8 s; references clk_i from prim_fifo_sync.sv 1.60 s (83 hits)
and from tb.sv (first occurrence = key_sideload_if's port, 5 hits)
1.58 s — the huge-census case is bounded as the README says. The generate-
scope path aes_bind.sv:58 …gen_masks.u_aes_prng_masking.u_prim_bivium. state_q is not among prim_trivium's state_q references, but the
whole-set engine over 472 aes/prim/tlul files does not list it either: an
engine limit, not the narrowing. The dev's census test: 1 passed in
32.7 s (debug).
Sizes and style
Production lines (non-blank, not starting with //, before the first
#[cfg(test)], one awk rule for all): tools/nav.rs 446,
tools/hierarchy.rs 311, tools/diagnostics.rs 293, tools/defines.rs
158, tools/source.rs 134, resources.rs 112, tools/mod.rs 146,
rpc.rs 241, project/analysis.rs 77, tools/read_item.rs 213,
main.rs 68 — the dev's numbers, all under 600. No function over 40 lines
(brace-matched scan). No unwrap/expect/panic! outside #[cfg(test)],
no #[allow], no unsafe.
Gates (through tools/guard.sh, one cargo invocation at a time)
cargo fmt -p lucisv_mcp -- --check→ exit 0cargo clippy -p lucisv_mcp --all-targets→Finished, no warningscargo test -p lucisv_mcp→ unit 37 passed;opentitan0 passed, 1 ignored;qa_m151 passed;qa_m220 passed, 12 ignored;wire19 passedcargo test --workspace(before finding 11's ignored test was added) → exit 0, 4 586 passed, 0 failed, 58 ignored (4 566 + 20 QA; 47 + 11)LUCISV_OPENTITAN=… cargo test -p lucisv_mcp --test opentitan -- --ignored→ 1 passed in 32.7 s; checkout status byte-identical- No guard kill.
TODO-MCP M2 QA box left unticked (rework needed).
2026-09-23 (QA, M2 re-check after the rework). Verdict: pass. All
eleven findings are fixed or pinned under the lead's rulings; no new
finding. Every earlier qa_finding_* test is un-ignored and green with
its assertion unchanged, except finding 5's, which the dev rewrote to pin
the ruling. It now asserts that one file's diagnostics reports
unknown-port for top.sv, as lucisv check . does and lucisv check top.sv does not. That is exactly the ruling. QA added
qa_recheck_one_files_diagnostics_are_its_lines_of_lucisv_check_dot, which
pins the whole text line (2:12 error … [unknown-port], and nothing for
leaf.sv) rather than a substring. Finding 10's new wording, "call the
unit_interface tool with its file argument to pick one", is acceptable: it
names the tool that can pick, and it no longer suggests that the URI takes
an argument.
Re-derived by hand (release binary, scratch trees, then pinned):
- 1: the two-level tail
u_a.u_b.sig2gives the same 3 locations (leaf.sv:2:9,top2.sv:3:21,top2.sv:4:21) from the bare name, from the declaration, and from each of the two uses. The class chain gives the same 4 (sb.sv:2:7,sb.sv:3:24,t.sv:4:9,t2.sv:3:33) from the bare name, the declaring file's own use,e.s.countande2.s.count. Both lists equal the whole-set oracle (find_referencesover every file). - 2+3: in
/* q */ initial $display("q"); assign r =ID(q); assign q = a; // qthe selector picks the codeqat column 60.referenceslists it with the declaration and the two uses on line 5. A line whoseqis only in strings: "not written on line 6". ``ID(q)alone on its line and `a` only insideID(a)`` are refused as "inside a macro argument" by both tools, whileqelsewhere on line 5 and ``ID`` are still found. - 4: three instances in one statement with overrides (
#(.W(2)) u_a, u_b, u_c) each show#(.W(2)). Three without overrides show none. A statement whose#(…)spans three lines, with a// threecomment, a/* between ) , */comment between instances and the last instance after a leading comma, shows#( .W(3) )on all three, down and up. Two separate statements of the same module in one owner keep their own#(.W(4))/#(.W(5)), and an instance array has none. - 11: three uses naming three declarations (
l1,l2,l3) are refused by both tools with "sigon line 3 → l1.sv:1, line 7 → l2.sv:1, line 12 → l3.sv:1; addline".line: 7then answersl2.sv:1:25. Two uses of one declaration answer it. A use of a module declared twice lists both declarations. On opentitan,references {file: hw/ip/aes/dv/tb/tb.sv, name: clk_i}now refuses, namingkey_sideload_if.sv:8(line 35) andaes.sv:42(line 46). Before the rework it silently picked the first.
New attacks (11 qa_recheck_* tests, all green): the four hand
derivations above; depth schema minimum 1 / maximum 20, where 20
walks 20 levels and 21 is refused "from 1 to 20"; col on the last byte
and one past it are positions, two past is refused "line 2 is 13 bytes
long" (CRLF line) or "line 3 is 9 bytes long" (a last line with no
newline); references from a file the walk skips (a gitignored .sv and
a notes.txt) answers the real uses, including the file asked from,
while the by-name answer stays the indexed files, and a path that does not
exist is refused naming it, never a crash; whole-set references after
deleting one file mid-session drops its hit, and after deleting the
declaring file the refusal is prefixed "lucisv cannot follow this position:"
with no "rename"; unused waivers match lucisv check . (one
unused-waiver at w.waiver:1:1; a waiver file named by two configs is
read once; rules: no-tabs reports nothing, as --select no-tabs . does;
the per-file form reports none, as ruled).
Observation for the lead (not a finding): the coordinator's brief expected
references from a file that is not indexed to be a clean refusal. It
answers instead. That is consistent with M1's path rule (outline,
definition and diagnostics all read any file inside a root), and the
answer is correct. If a refusal is wanted, that is a ruling for all the
tools, not a fix in references.
opentitan (release, whole-set references): clk_i from
prim_fifo_sync.sv 2.37 s, 83 hits, the same count as the narrowed answer.
The dev's census test: 1 passed in 73.1 s (debug; per-call 9.8–14.9 s for
the five references calls). git status --porcelain of the checkout was
byte-identical before and after, and identical to the first QA pass's
snapshot.
Sizes (same awk rule): tools/nav.rs 343, tools/select.rs 177,
tools/hierarchy.rs 316, tools/diagnostics.rs 313, tools/mod.rs 151,
resources.rs 118. The rest are unchanged. No function over 45 lines. No
unwrap/expect/panic!/#[allow]/unsafe outside #[cfg(test)].
Gates (through tools/guard.sh, one cargo invocation at a time, no guard
kill):
cargo fmt -p lucisv_mcp -- --check→ exit 0cargo clippy -p lucisv_mcp --all-targets→Finished, no warningscargo test -p lucisv_mcp→ unit 38 passed;opentitan1 ignored;qa_m151 passed;qa_m243 passed, 0 ignored;wire19 passedcargo test --workspace→ exit 0, 4 610 passed, 0 failed, 47 ignored (the dev's 4 599 + 11 re-check tests)LUCISV_OPENTITAN=… cargo test -p lucisv_mcp --test opentitan -- --ignored→ 1 passed in 73.1 s; checkout status byte-identical
TODO-MCP M2 QA box ticked.
Review
Lead, 2026-09-23. Read every source file after the rework. The one
ruling worth restating: the reference-narrowing rule in PLAN §2.1 was
mine and it was wrong — a two-level tail or a class-handle chain resolves
through files that never spell the name, so references now hands the
engine the whole indexed set (≈ 2 s on opentitan) and MCP-7 asks
vlog_refactor for a KnownFacts variant so M6 can feed cached records.
Correctness first; the census will show whether 2 s matters to an agent.
Other rulings: diagnostics matches lucisv check . (the whole-tree
run — "what will CI say"); a name on a line is chosen by token, never by
text; hierarchy overrides belong to the statement, so every instance of
one statement shows them; depth is 1..=20 in the schema; every read
tool reads any file inside a root, indexed or not (QA's closing question —
kept, the answer is correct and the rule is M1's). Missing-closer warnings
and one-step macro expansion are not offered (server-only code; MCP-5
filed). MCP-6 — the LSP omits three real aes instantiations in the
*_pd_main.sv tops — is a possible LSP bug to file in TODO.md at the end
of the block. Committed as M2.