MCP M7: the lean catalogue — nine tools, 3 440 model-visible bytes, no dry_run/paging, short answers
ci / checks (push) Successful in 1m43s
ci / corpus (push) Successful in 36s

hierarchy (file:line per instance, peek), find (every declaration by
name, refs + unresolved mentions), outline, read, check, rename, port,
edit_item, format. Name lookup reaches every declaration the symbol
tables hold (tools/declared.rs); rename of a generate-block label is
refused (engine gap filed as topo §2.9 MCP-14). Text-only results,
engine sentences made root-relative. Tests ported or deleted per the
README; QA lane in tests/qa_m7.rs. Docs, smoke gate, release notes
(0.58.0 unreleased) updated.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
lucioandClaude Fable 5.1 committed 2026-09-24 01:40:53 -07:00
1 parent edad66947f
commit bfa8e98eb5
59 files changed
+4895 -7672

No files matched your search

+575
View File
@@ -0,0 +1,575 @@
# mcp-lean-catalogue
Lane **M7** of the MCP block (`TODO-MCP.md`, `docs/mcp/PLAN.md` §10).
## Goal
The census (`mcp_analysis.md`) found `lucisv-mcp` right on every run and
dearer than plain file reads on every small task: a 5 400-token catalogue
read each session, answers carrying more than the question asked, and
agents dry-running what they were told to trust. The owner's ruling is
*accuracy over breadth*: keep what only this server can do — the design's
hierarchy as `file:line`, where a name is declared and used, and the bulk
edits a file write cannot make safely — as **nine tools** (`hierarchy`,
`find`, `outline`, `read`, `check`, `rename`, `port`, `edit_item`,
`format`), a model-visible catalogue under 3 500 bytes, instructions under
400, short answers with fixed caps, no `dry_run` and no paging. The engines,
the write path, the M4 verifier and its attack suite, freshness, roots and
the cache are reused unchanged in substance.
## Assumptions
Decisions where PLAN §10 is silent (the simplest thing, recorded):
### Wire
- **Annotations** keep all four hints (`readOnlyHint`, `destructiveHint:
false`, `idempotentHint`, `openWorldHint: false`); hosts read them, the
budget counts only `name` + `description` + `inputSchema` (compact JSON
array of the nine objects, `serde_json::to_string`). `idempotentHint` is
`true` for the five read tools and `format`, `false` for `rename`, `port`
and `edit_item`.
- A range argument (`depth`) is `{"type": "integer"}` in the schema (§10.1:
`type` alone); the range is still enforced by validation and named in
the description (`1-20`).
- `required` is always present, `[]` when nothing is required.
- A result is `{content: [{type: text, text}], isError}` — nothing else.
### Rendering
- A line range is `first–last` (en dash), a one-line range the single
number, everywhere (`outline`, `read`, `edit_item`).
- Counts are pluralised (`1 file`, `2 files`), so the §10.1 forms read
`renamed 1 site in 1 file`, `… 1 instantiation in 1 file`.
- Engine sentences (refusals of `vlog_refactor::{rename, add_port,
remove_port, find_references}`, `place::after`, and the engine warnings a
rename or port edit carries) name files by base name; the MCP layer
rewrites a base name to the root-relative path when exactly one file it
handed the engine has that base name (`WholeSet::rooted`). When two files
share it the sentence is left as the engine wrote it.
- Engine and write-path warnings are facts, not hints: each is one
`warning: …` line after the answer's first line (the skipped-file line
`warning: not indexed, so not searched or edited: …`, the rename
engine's macro warnings, `port`'s TODO-connection lines).
- The `unresolved:` block is the label, then one file per line
(` file:12,40`), at most 50 mentions then ` … and N more` — the kinds
(string, comment, macro, define, path) and the line text are gone, per
"the same way" in §10.1.
### hierarchy
- Without `root` it **walks the roots first** (the successor of
`project_overview`, which always walked), then `N files, M modules, K
top`; `M` counts `Module`-kind units (programs included), `K` and the
list are every module nothing instantiates, **one line per declaration**
(a module declared in two files is two tops at their two lines).
- Down: the root line `module file:line` (its declaration) is kept at
indent 0, instances at two spaces per level. Each instance's `file:line`
is the line of the instance name (the old tool's site line). A module
declared twice is still two root lines.
- Up: no root line; level 1 at indent 0, deeper levels two spaces each;
walked once by name (a root declared twice is not repeated). An
uninstantiated root answers `nothing instantiates X`.
- The notes stay as suffixes: ` (recursive)`, ` (not indexed)`,
` (declared N times)`.
- `peek` lines are the statement from the start of the line naming the
module to the end of the line holding its `;`, the common indentation
removed, indented four spaces past the node's line, at most 12 lines then
`…`. Nothing is shown when the file no longer spells the module there.
- The 300-line cap cuts whole nodes (a node's peek block is never split);
`… and N more` counts the nodes left. The 50 000-node walk cap stays, so
on a cut walk `N` is a lower bound.
- Unknown root: up to 10 module/interface names containing it, any case.
### find
- Declarations are the index's units, exported members and module
internals (`hierarchical_declarations`), each checked against the bytes
on disk, sorted by file and line; then `` `define``s (`macro NAME
file:line`, `` `undef`` omitted). A `program` says `program`.
- **`unit.name` / `pkg::name`** (not in §10.1, which gives `find` no way to
pick one of many declarations): the member of that unit only
(`member_in(..., Surface::Hierarchical)`); an escaped identifier is never
split. `rename` accepts it too. Found necessary on opentitan, where
`state_q` has hundreds of declarations.
- `refs` walks the roots once first (the whole set must be complete), then
runs `find_references` (declaration excluded) per declaration — **at most
5 declarations** (`REFS_CAP`): each is a whole-set engine run (≈ 2 s on
opentitan), so a name declared more often gets a closing line `uses
listed for 5 of N declarations`. Macros have no uses listed (no engine
follows them). An engine refusal is ` uses not listed: …`, reworded so it
never speaks of renaming.
- Besides the index, every declaration the files' own symbol tables hold
is found (`declared.rs`): the files whose word census holds the name are
read from disk and analysed, and each symbol of that name is a
declaration (typedefs, enum values, functions, tasks, genvars, generate
blocks and what they declare, procedural locals). `unit.name` keeps those
whose innermost enclosing module, interface, package or class is `unit`.
An escaped identifier is not in the word census (it holds plain
identifiers only), so an escaped *local* name the index does not record —
a function's `\loc.v`, say — is not found by name (QA re-check R2,
accepted; `outline` and `read` with `file` still reach it).
- No declaration: `no declaration named X; similar: …` — up to 20 names
containing it, any case, from the same table (`declared.rs` with a part
of a name, plus `workspace_symbols` for escaped names) and the define
tables. A short part reads most files (≈ 1–2 s on opentitan, refusal
path only).
### outline, read, check
- `outline unit:` first line is the unit's `file:line` alone; then
`param NAME = DEFAULT` (`param NAME` without one), ports
`dir type [range] name [unpacked]` with empty parts left out, `modport
…` lines, and for packages and classes `extends BASE` and `kind name
LINE`. A unit declared twice is refused listing both (the file outline
is the way to pick one); via the `lucisv://unit/` resource the sentence
points at the file outline resource instead.
- `outline file:` parse errors are `error LINE: message` (the column is in
`check`).
- `read` without `file` looks the name up among the index's declarations,
counts matching declarations (kind and `@LINE` honoured) in each file,
and needs exactly one; `always@LINE` and friends need `file`.
- `check` sorts stably by severity (error, warning, rest), so a file's
parse errors lead and each file keeps its order within a severity; the
message is collapsed to one line; `rules`, `severity` and `in` are gone.
### Edits
- **`rename`**: `name` may be `name@LINE` (with `file`, picks one of two
declarations in one file) or `unit.name`. A name already equal to
`new_name` answers `renamed 0 sites in 0 files`. `N sites` is the
engine's edit count, `M files` the files written.
- **`rename`** refuses every `block`-kind declaration (the symbol table's
kind for a generate block label, and for a named `begin : label` too):
no engine rewrites or reports a hierarchical path through a block.
- **`port`**: the module is found by `module_definition` (exactly one
declaring file). `remove` finds the port by name in the module's own
scope in that file. `N instantiations in K files` is the index's census
of the module's instances before the edit (every instance the engine
visits), not the files written.
- **`edit_item`**: `item` is the anchor for inserts. `replace` refuses a
text declaring other names (no `rename` flag) and points at `rename`;
the no-op answers `unchanged CLASS NAMES file:lines`. `delete` has no
`force`: a used item, a nested `` `define``, a fence stay refusals. The
answer's lines are the new item's (replace/insert) or the removed lines
(delete). `rewalk: true` (a delete needs the complete set).
- **`format`**: `files` is a path (resolved as every path argument), else
a directory or glob matched against every indexed file's root-relative
path (`glob.rs`, the old `in` matcher). `formatted N files (M
unchanged)`: `N` counts every file that passed the safety net, `M` those
already formatted. A refused file is one `not formatted: FILE (why)` line
and the rest are still written (all-or-nothing among them); when every
file is refused the call is a refusal. `fix` runs the safe fixes (the
CLI's `--fix` filter, fences honoured, parse-error guard), then formats.
- There is no dry run anywhere: `apply::run` checks roots and freshness,
then writes, and returns which files it wrote.
### The verifier
- `Expect::Nothing { force }` became `Expect::Nothing` and the forced
path (`dropped` macros) was removed from `tools/item/verify.rs`: dead
once `force` left the wire, and it was a *relaxation* — removing it can
only refuse more (CLAUDE.md invariant 4 is about widening). Every other
rule is byte-identical; `tests/attacks.rs` passes with its cases as
written (a call translator maps them; the three forced cases became
refusals).
## Handshakes
Consumed (unchanged): `vlog_refactor::{rename, add_port, remove_port,
find_references, instantiation_plan, module_definition, enclosing_module}`,
`vlog_semantic::WorkspaceIndex` (`units`, `member_in`, `members_of`,
`workspace_symbols`, `hierarchical_declarations`, `find_define`, `defines`,
`instantiations`, `instantiations_of`, `instantiable_units`, `units_of`),
the linter and formatter entry points `diagnostics.rs`/`format.rs` used
before. No longer consumed: `lucisv_core::diff::unified`,
`vlog_formatter::format_range`, the six cursor refactorings.
Promised: the spawn contract with the extension is amended — `tools/list`
is exactly the nine names in order (`editors/vscode/mcp_smoke.js`
`TOOLS`, was `MIN_TOOLS = 26`); `docs/topo.md` §2.8 updated.
Requests (not edits):
- **MCP-11 → `vlog_refactor`:** `find_references` over several
declarations in one `Scope` (one index build), so `find refs` need not
cap at 5 declarations. Today each declaration is a full build.
- **MCP-14 → `vlog_refactor`/`vlog_semantic` (topo §2.9 row 43):** a
rename of a generate block label leaves hierarchical paths through it
(`g_lane[0].lane_q`) unrewritten, and `find_references` does not report
them; the MCP layer refuses the rename (any `block`-kind declaration);
the LSP still allows it.
- **MCP-13 → release/docs owners (outside this lane's files):**
`tools/release.sh` (comments at lines 134 and 257), `tools/RELEASING.md:129`
("at least 26 tools, one `project_overview`") and
`docs/manual-acceptance.md` rows 19 and 24 ("call lucisv's
project_overview") name the old catalogue; the smoke gate itself
(`mcp_smoke.js`) is updated. They should say nine tools and `hierarchy`.
- **MCP-12 → lead:** PLAN §10.3's instruction text is 444 bytes against
its own 400-byte budget; the shipped text (398 bytes) is a tightening of
it (below). Rule on the wording.
## Status / TODO
- [x] registry: nine tools in order, no `title`/`structuredContent`, no
per-argument descriptions; `wire.rs` pins names, order, budgets and
the absence of `dry_run`, `limit`, `offset`, `in`, `template`,
`overrides`, `force`
- [x] `hierarchy` (no root, down, up, peek, cap, near matches); opentitan
instance set identical to 0.57.0 (`tests/opentitan.rs`)
- [x] `find` (declarations, macros, `refs`, `unresolved:`, near matches)
- [x] `outline` (`file` xor `unit`), `read` (design-wide), `check` (`ok`;
0.57.0 line set on every fixture)
- [x] `rename`, `port`, `edit_item`, `format`
- [x] instructions ≤ 400 bytes; resources render through `hierarchy` and
`outline`
- [x] tests ported or deleted (below); invariants kept
- [x] docs: this README, Agents guide table + promises, extension
README/CHANGELOG, `CHANGELOG.md` 0.58.0, topo §2.8, PLAN §4.3/§4.5
marked superseded
- [x] QA (2026-09-24: PASS with findings — QA log)
- [ ] census round 4 (lead), release 0.58.0
## Work log
### 2026-09-23 — dev (M7)
**Byte figures** (release binary, `tools/list` over the design fixture):
model-visible catalogue **3 440 bytes** (was 17 900 for `tools/list`);
instructions **398 bytes**. Per tool (compact name+description+schema):
`hierarchy` 433, `find` 362, `outline` 345, `read` 357, `check` 294,
`rename` 395, `port` 404, `edit_item` 482, `format` 358.
**Instructions shipped** (§10.3's text is 444 bytes; tightened, same
facts): "lucisv-mcp reads the SystemVerilog on disk (save first). Use it
before reading files: hierarchy for instance trees and top modules, find
for a name's declarations and uses, outline for a file or unit's ports,
read for one item, check after edits. Edits (rename, port, edit_item,
format) are verified, all-or-nothing writes: trust them as file writes, no
dry run. Paths root-relative, lines 1-based."
**Code.** `tools/mod.rs` holds the nine; `Answer` is `{text}`; `Param` has
no description; `Ty::Int` gone. New: `find.rs`, `names.rs` (declarations
by name, near matches, `unit.name`), `outline.rs`, `port.rs`, `glob.rs`
(moved from `read.rs`). Rewritten: `hierarchy.rs`, `read.rs` (the `read`
tool; the slicer stays `read_item.rs`), `interface.rs` (outline's unit
half), `diagnostics.rs` (`check`), `edit.rs` (`rename` + the shared
whole-set/write/mentions step), `item.rs` (`edit_item`), `format.rs`,
`apply.rs` (no dry run, no diff, returns `Written`), `render.rs` (caps,
`by_file`, counts), `mentions.rs` (the `unresolved:` block), `source.rs`.
Deleted: `defines.rs` (macros are `find` declarations), `select.rs`
(position selectors; name-based now), `nav.rs` (→ `find.rs`/`names.rs`),
`refactor.rs` (`add_port` → `port.rs`; `extract_module`, `instantiate`
dropped). Dead project/analysis helpers removed. All files under 460 lines.
**Differential.** Built `v0.57.0` (`git archive` into scratch) and
compared: `check` line sets identical on all six fixtures and on five
opentitan files; `hierarchy top_earlgrey` identical at depth 1 (2) and 2
(49 instances), depth 3 identical over the 299 lines shown (464 in all);
`hierarchy prim_fifo_sync up` identical (77). The r4 eval binary reports
0.56.0 and agrees too. The depth-2 set is pinned in `tests/opentitan.rs`.
Opentitan timings (release): startup 2.1 s cold / 0.9 s warm; `find
aes.entropy_masking_req refs` 2.1 s; `find aes refs` (5 declarations)
9.4 s; `hierarchy top_earlgrey depth 2` 0.4 s; the checkout's `git status`
unchanged by every run.
**Tests** (347 pass, 3 ignored opentitan pass with `--ignored`):
| suite | before → after | what happened |
|---|---|---|
| unit (`src`) | 77 → 72 | paging/table/`in`/check-line/overrides/`defines` unit tests deleted with their code; glob tests moved; `qualified`, `count`, `by_file`, instructions-budget tests added |
| `attacks.rs` | 23 → 23 | unchanged cases through a `lean` call translator; `rename: true` variant dropped (the refusal was the same); the three `force` controls are now asserted refusals |
| `wire.rs` | 57 → 40 | rewritten per tool; budgets, names/order, bare schemas, text-only results pinned |
| `qa_m1.rs` | 51 → 48 | `list_units` freshness checks → `find` hits / `hierarchy` walks; deleted: `list_units` glob `?` (covered by `glob.rs`), `outline depth/limit/offset`, `search_symbols` empty query |
| `qa_m2.rs` | 43 → 35 | `references`/`definition` → `find refs`; deleted: position-selector attacks (whitespace/keyword/column/byte-column/macro-argument positions, findings 2, 3, 8, 9-by-position), paging, `rules`/`severity` filters, `defines` table shape, overrides JSON |
| `qa_m3.rs` | 33 → 31 | edit tools → `rename`/`port`/`edit_item`/`format`; deleted: cursor refactorings, `extract_module` paths and CRLF (finding 3), `instantiate` (finding 5), `lines` ranges, `dry_run` diff checks; the references-vs-warning sweep now sweeps `find` |
| `qa_m4.rs` | 45 → 45 | unchanged cases through a translator; forced deletes are refusals; dry-run diffs → real writes |
| `qa_m6.rs` | 17 → 17 | probes and instructions ported; forced-delete pair → refusal + plain delete |
| `qa_f1.rs` | 23 → 21 | `add_port` → `port`; mentions read from the `unresolved:` block; deleted: the dry-run-diff-equals-write test and QA finding 6 (dry-run mention lines) |
| `qa_f2.rs` | 14 → 6 | paging, count lines, `in` on every tool and the check line deleted; kept the hierarchy walk over the tree and the path glob (now `format`'s) |
| `qa_f3.rs` | 7 → deleted | `template` and `overrides` are gone; the flag-type refusals are covered in `wire.rs`/`qa_m3.rs` |
| `cache.rs` | 4 → 4 | tool names |
| `opentitan.rs` | 2 → 3 | `find`/`hierarchy`/`check`; the whole-set timing is `find refs` (read-only; the old dry-run rename would now write); new 0.57.0 instance-set test |
Kept invariants, with their tests: verifier attacks (`attacks.rs`,
`qa_m4.rs`), all-or-nothing writes (`apply.rs` unit tests, `qa_m3.rs`
commit tests, the racing-writer test), roots (`wire.rs`, `qa_m1.rs`,
`qa_m3.rs::qa_rewritten_paths_never_leave_the_root`), freshness (`qa_m1.rs`
freshness section, `wire.rs::answers_follow_the_disk_between_calls`), cache
read-only (`cache.rs`, `qa_m6.rs`), unresolved mentions on `rename`/`find`/
`port` (`wire.rs`, `qa_f1.rs`), rename over `.name`/`.*` (`qa_m3.rs`
finding 1, `qa_f1.rs` star binding).
**Deviations from §10.** Instructions text tightened to fit 400 bytes
(MCP-12). `find`/`rename` accept `unit.name`. `find refs` caps at 5
declarations. `format` answers `not formatted: FILE (why)` lines and is a
refusal only when every file is refused. The hierarchy root line is kept
for `down`. `verify.rs` lost its dead forced path.
### 2026-09-24 — dev (M7 rework after QA)
- **Finding 1 (every declaration by name).** New `tools/declared.rs`: the
files whose word census holds the name are read and analysed, and every
symbol of that name in their own tables is a declaration, merged (by file
and offset) with the index's. `find`, `read` without `file` and `rename`
now reach typedefs, enum values, functions, tasks, genvars, generate
blocks and their contents, and procedural locals; `unit.name` filters by
the enclosing unit. `rename` hands the declaration's file and offset to
`vlog_refactor::rename` exactly as before (no new rename). Repro fixed:
`rename {"name":"StIdle","new_name":"StRest","file":"rtl/fsm.sv"}` →
`renamed 2 sites in 1 file`. Opentitan: `find clk_i` + `find StIdle` +
a miss, with the index build, 3.1 s; census timings unchanged (`find aes
refs` 8.4 s, `aes.entropy_masking_req` 1.9 s).
- **Finding 2 (near matches).** `similar` reads the same table with a part
of a name (`Wanted::Containing`). `qa_m2` near-match expectation updated
(`similar: sig, sig2` — `sig2` is a module internal `find` lists).
- **Finding 4 (peek blank line).** A blank line of a peeked statement is
an empty line — no indent; every other line exact. QA's pinned test
asserted *no* empty line at all, which contradicts the ruling; its
assertion now forbids whitespace-only lines and checks the empty one
(the test name already said "whitespace-only").
- **Finding 3 (root-relative files).** `WholeSet::rooted` rewrites a base
file name in an engine sentence to the root-relative path when exactly
one file of the set has it; applied to `rename`, `port` (engine and
`place::after` refusals), the engine warnings of both, and `find`'s
`uses not listed`. Test `wire.rs::engine_sentences_name_files_root_relative`
(and a unit test of the whole-word replacement). The MCP-built lines were
root-relative already.
- Findings 5 and 6: no change (lead's ruling).
- Catalogue unchanged: 3 440 bytes; instructions 398.
### 2026-09-24 — dev (M7 rework 2)
- **R1:** `rename` of a `block`-kind declaration is refused with the
lead's sentence before any engine runs; QA's pinned test un-ignored, its
assertion now requires the refusal and an untouched source. Topo §2.9
row 43 (MCP-14) and a Handshakes line added.
- **R2:** accepted; the Assumptions sentence on escaped local names made
exact; the pinned test stays ignored with its reason. **R3:** no change.
- Catalogue 3 440 bytes, instructions 398 (unchanged).
## QA log
### 2026-09-24 — QA (M7)
**Verdict: PASS with findings.** Every attack in the TODO M7 QA box held;
no corruption, no partial write, no invariant broken. Finding 1 is a
capability regression against 0.57.0 the lead should rule on before the
0.58.0 release.
**Gates.** `cargo fmt --all` clean; `cargo clippy --all-targets -p
lucisv_mcp` clean; `tools/guard.sh -t 1500 -- cargo test -p lucisv_mcp`
**356 passed**, 6 ignored (3 opentitan, 3 QA findings pinned below) —
the dev's 347 + 9 new in `tests/qa_m7.rs`.
**What was verified, and how.**
1. *Byte budget.* `wire.rs::tools_list_is_the_nine_tools_in_order_within_the_byte_budget`
measures `serde_json::to_string` of `{name, description, inputSchema}`
for all nine; an external measure (Python, compact, UTF-8) gives the same
3 440. Mutation: `format`'s description +57 bytes (3 497) passes, +76
(3 516) fails at `wire.rs:211` "the model-visible catalogue is 3516
bytes"; reverted, `cmp` identical. Instructions 398 bytes, also pinned in
`rpc.rs::the_instructions_stay_under_400_bytes`.
2. *Caps* (400 instances, 350 ports + 320 nets, 320 declarations of `sig`):
`hierarchy` down (`… and 101 more`), up (100), down+peek (whole blocks,
251), no root (23), `find` (20), `outline unit` (51) and `file` (371),
`check` (200 lines, 120 more) — each exactly one cut line, counts right,
every line before it whole. On the eval clone `hierarchy prim_fifo_sync
up depth 20` says `… and 22588 more` = the old tool's 22 888 − 300.
3. *Ambiguity*: `read`/`rename` of a name in two files refuse listing both
`file:line` and what picks one; `unit.name` picks without `file`;
unknown `find`/`hierarchy root` list contains-matches (but see finding 2).
4. *peek*: a statement with `#(…)` over two lines, `//` and `/* */`
comments holding `;`, a tab-indented `.*` line, a two-instance statement
and a 16-line statement: exact text (common indent removed), the 12-line
cut ends `…`, exactly 12 lines is not cut.
5. *port*: `after` a non-existent port, both / neither of add/remove,
`after` with `remove`, `remove` of a port the body uses, an unknown
module — all refused, tree byte-identical. `add` on a module instantiated
3× in 2 files (named, `.name` shorthand, `.*`) connected each (`.*` gets
its warning); with a positional instantiation in a third file the whole
edit is refused and nothing is written.
6. *edit_item*: delete of a used signal and a called function refused with
`file:line:col` sites; `replace` that changes the name refused pointing
at `rename`; `insert_after end@n` lands before `endmodule` of `n`;
`end@nope` refused. `tests/attacks.rs` diffed against HEAD: 23 tests,
62 → 63 `refused(` (the three forced deletes became refusals), 24 → 22
`accepted(` (the two forced ones); the `lean` translator only renames
tools/arguments; the one dropped case is `rename: true` (argument gone).
`verify.rs` diff only removes the forced relaxation. `qa_m4.rs`: 45
tests kept, the removed assertions are dry-run diffs and forced deletes.
7. *format*: a glob matching nothing refused (`nothing written`); one
unparsable file among four: the other three written, one `not
formatted: rtl/bad.sv (…)` line, the bad file untouched; the refused file
alone is a refusal. A non-UTF-8 file is not indexed, so a glob skips it.
8. *Differential against the r4 binary on the eval clone*:
`hierarchy top_earlgrey depth 2` — 49 instances, same tree (the old
one had no sites; all 49 new `file:line` checked to spell the instance);
`hierarchy prim_fifo_sync up` — first 300 identical, same total;
`check` vs `diagnostics` on `earlgrey_pd_main.sv` (10 findings),
`uart.sv`, `prim_fifo_sync.sv`, `i2c_fifos.sv`, `uart_core.sv`,
`aes_core.sv`, `cheriot_tag_filter.sv` — identical line sets; whole design
2 101 both; `find prim_fifo_sync refs` vs `references` — 78 uses = the
old 79 hits minus the declaration itself, `unresolved:` 29 sites = the
old 29. The clone's `git status` was clean after every run.
9. *Answer shape*: every read tool over the six fixtures plus the attack
trees — no absolute path, no hint line, no trailing whitespace, no blank
line except finding 4; refusals are one sentence.
10. *Invariants*: freshness (`qa_m1`, `wire`), roots (`wire`, `qa_m1`,
`qa_m3`), cache read-only (`cache`, `qa_m6`), all-or-nothing
(`apply.rs` units, `qa_m3`) all pass. Manual: `rename sub` over three
files with `rtl/p2.sv` chmod 444 → `` `rtl/p2.sv` is read-only; nothing
written.`` and `p1.sv` (written first in path order) untouched; pinned
as `qa_a_rename_whose_later_file_is_read_only_writes_nothing`.
**Findings** (pinned ones are `#[ignore = "QA finding N"]` in
`tests/qa_m7.rs`, asserting the correct behaviour):
1. **Medium — name lookup cannot reach module-local declarations other
than ports, parameters, nets, variables and top-level instances.**
`names.rs:88` `defs_named` reads units, exported members and
`hierarchical_declarations`; a module's `typedef`, enum values,
functions, tasks, genvars, generate blocks and everything inside them,
and procedural locals are in none. `outline` lists them and `read` with
`file` slices them, but `find`, `read` without `file` and **`rename`**
answer `no declaration named X` — with `file` too. 0.57.0 renamed them
by position (checked: the r4 binary renames `StIdle` via
`file/line/col`), so an FSM state rename is no longer possible through
MCP. Repro: `rtl/fsm.sv` = `module fsm; typedef enum logic [1:0]
{StIdle, StBusy} state_e; …` then `rename {"name":"StIdle",
"new_name":"StRest","file":"rtl/fsm.sv"}` → refused. Pinned:
`qa_find_and_rename_reach_every_declaration_outline_lists`. A likely
remedy: with `file`, fall back to the file's own semantics (as `read`'s
slicer does) for the offset handed to `vlog_refactor::rename`.
2. **Low — near matches omit module internals.** `names.rs:165`
`similar` reads `workspace_symbols` (units and exported members) and the
define tables, not the module internals `find` lists. Repro: `logic mid;`
in a module, `find {"name":"mi"}` → `no declaration named `mi`.` with no
`similar`; on the eval clone `find rx_fifo_rvali` suggests only
`rx_fifo_rvalid_o` although `find rx_fifo_rvalid` lists 3 declarations.
Pinned: `qa_find_near_matches_include_the_module_internals_find_lists`.
3. **Low — engine sentences name files by basename, not root-relative
(§10.2).** `port` refusals `would not leave p3.sv with the signature…`,
`still used inside `sub` at sub.sv:6`; `port` warnings `at `u_s`
(p1.sv:2)`; `rename` refusal `` `u_b` at top.sv:16 connects with `.*` ``.
The sentences come from `vlog_refactor` unchanged (so 0.57.0 said the
same); ambiguous when two directories share a basename. Not pinned.
4. **Low — `peek` answers a whitespace-only line** for a blank line inside
an instantiation statement (`hierarchy.rs:284` indents every source line,
`statement` at `hierarchy.rs:328` keeps blank ones): `" "` in the
answer, against §10.2 "no blank lines". Exactness vs the rule is the
lead's call. Pinned: `qa_peek_never_answers_a_whitespace_only_line`.
5. **Cosmetic — four descriptions are two sentences** (`hierarchy`,
`read`, `rename`, `format`) where §10.1 says "the one-sentence tool
description". Not pinned; merging them costs no bytes.
6. *Info* — `port add` then `port remove` of the same port is refused when
the add left `/* TODO: connect */` (comments are never dropped), so the
pair is not an undo. Safe; engine behaviour, noted for the agent guide.
**Fixed directly:** nothing in production code.
**Tests added** (`crates/lucisv_mcp/tests/qa_m7.rs`, 9 + 3 ignored):
caps with counts, peek exactness and the 12-line cut, ambiguity and
unknown-name refusals, `port` shapes and all-or-nothing across files,
`edit_item` delete/replace/`end@UNIT`, `format` partial and empty glob,
read-only all-or-nothing, answer shape, `find refs` five-declaration line.
### 2026-09-24 — QA re-check (M7 rework)
**Verdict: PASS with findings.** Findings 1–4 are fixed and their pinned
tests pass un-ignored. The rework opens a gap that was already in the
engine but is now reachable by name with no dry run (R1). Gates: fmt and
clippy clean; `tools/guard.sh -t 1500 -- cargo test -p lucisv_mcp`
**365 passed**, 5 ignored (3 opentitan, R1, R2).
- *(a) Declarations local to a module* — typedef, enum value, function,
function-local, task, genvar, generate block, generate-local and
procedural local: `find` and `find unit.name` answer each; `rename` by
name, with `file` and with `fsm.name` rewrites every use and leaves no
old name behind, except for the generate label (R1). `read hl` / `read
tmp` / `read gi` return only the name's bytes — 0.57.0's `read_item` did
the same (the slicer never changed), so this is noted, not a finding.
- *(b)* `rtl/x/p1.sv` and `rtl/y/p1.sv` both declare `dup`: `rename`
without `file` lists both root-relative paths, and with `file` renames
only the right file. Engine sentences keep the bare `p1.sv` (two files
have that name) and rewrite `p1b.sv` to `rtl/z/p1b.sv:3`. No
sub-string damage.
- *(c)* A package enum value used in `case` arms in two files, plain and
`pkg::`: `find refs` lists `rtl/a.sv:7,11` and `rtl/b.sv:6`; `rename`
answers `renamed 4 sites in 3 files` and lists the comment and string
mentions as `unresolved:`.
- *(d)* A name that appears only in a comment or string gets `no declaration
named` with no similar names; `StRu` suggests `StRun`.
- *(e)* The escaped net `\my.sig` is still found, with its uses and
renamed across a hierarchical reference. See R2 for escaped locals.
- *(f)* The eval clone has no `StIdle` in `entropy_src_main_sm` (its state is
`Idle`, from a package). `find StIdle` lists 35 enum values (1.96 s).
`rename StIdle file ip/hmac/rtl/hmac_core.sv` gives `renamed 7 sites in
1 file`; all 7 spellings changed, no other file was touched, and it took
13.8 s. The 20 warnings about macro arguments belong to *other* modules'
`StIdle` and match what 0.57.0 printed for a position-based rename.
Restored with `git checkout`; the clone's status is clean.
- *(g)* The only `tests/` files changed since the first QA run are
`qa_m7.rs`, `qa_m2.rs` and `wire.rs`. `qa_m7.rs`: every assertion is
intact except the three un-ignores and the finding-4 assertion (the
ruling's reading). `qa_m2.rs`: the `similar: sig, sig2.` expectation.
`wire.rs`: one new test, `engine_sentences_name_files_root_relative`
(test count 40 → 41).
- *(h) Timing on the eval clone* (release build; `hierarchy {}` takes
2.03 s, which is the startup): `find clk_i` (a hit) 2.62 s; misses
`clk_x` 1.84 s, `rst_` 2.87 s (about 2 131 files hold a word containing
it, and `similar` in `declared.rs` parses them all), `zzzz` 1.86 s, `q_`
2.93 s (about 1 693 files); a hit on the common `dat` takes 1.83 s. Every
miss is well under 10 s, so there is no finding here.
**Findings.**
- **R1 — Medium (code-breaking rename, no warning).** Renaming a
generate block label leaves a hierarchical path through the block
unchanged. `rename {"name":"g_lane","new_name":"g_ln"}` on
`for (…) begin : g_lane … end` plus `busy = tmp | g_lane[0].lane_q;`
answers `renamed 1 site in 1 file`. Line 19 still says `g_lane[0]`,
which is now undeclared. The answer has no warning and no `unresolved:`
line, and `find g_lane refs` lists no uses. Yet `edit_item delete
g_lane` refuses, citing `rtl/fsm.sv:19:18`. The engine
(`vlog_refactor::rename`) did the same by position in 0.57.0, but
`declared.rs` now makes generate labels reachable by name, and the
instructions say to trust edits. Remedy for the lead to rule on: refuse
a `block`-kind rename, or have the engine warn the way it does for
`lane_q`'s tail. Pinned:
`qa_rework_renaming_a_generate_label_never_leaves_a_path_through_it_behind`.
- **R2 — Low.** Escaped local names are not found. `declared.rs:35`
(`in_census`) checks the word census, which holds identifier-shaped
words only, so a file is never opened for `\loc.v` (a function-local)
or an escaped enum value. The dev records this as an assumption (under find: escaped names are found "through the index only"), so it is known, but `outline` lists them, but `find`, `rename`
and `read` without `file` answer `no declaration`. Pinned:
`qa_rework_an_escaped_local_outline_lists_is_found`.
- **R3 — Cosmetic.** `find e.\my.sig` is refused because `qualified`
(`names.rs:44`) splits on the `.` inside the escaped member. `find my`
does not suggest `\my.sig`. Not pinned.
**Tests added** (`tests/qa_m7.rs`, 4 + 2 ignored):
`qa_rework_every_local_kind_is_found_and_renamed_by_name_file_and_unit`,
`qa_rework_a_shared_base_name_is_named_by_path_or_left_alone`,
`qa_rework_an_enum_value_in_case_arms_is_renamed_across_files_with_its_mentions`,
`qa_rework_an_escaped_net_is_still_found_through_the_index`; R1 and R2
pinned.
## Review
2026-09-24 (lead). Examined the diff (51 files, +2 649/−7 620), the
registry, `declared.rs`/`names.rs`, the QA logs and the live answers on
the fixture design and the eval clone. Accepted. The catalogue is
3 440 bytes for nine tools (was 17.9 kB for 26), instructions 398 bytes,
answers one line per fact with fixed caps. Rulings: MCP-12 — the shipped
398-byte instructions stand, PLAN §10.3 is amended to them; finding 4 — a
blank line inside a peeked statement is an empty line; R1 — `rename` of a
`block`-kind declaration is refused in the MCP layer and the engine gap is
filed as topo §2.9 row 43 (MCP-14) for the LSP/CLI; R2 accepted as an
assumption; MCP-13 fixed by the lead (release script comments,
RELEASING.md, manual-acceptance rows 19/24). Deviations from §10 accepted:
qualified `unit.name`/`pkg::name`, the 5-declaration cap on `find refs`
(MCP-11 filed), per-file `format` refusals, the root line on `hierarchy`
down. Gates at commit: lucisv_mcp 366 passed / 4 ignored, workspace 4 922
passed / 0 failed. Census round 4 follows on this binary.