MCP M7: the lean catalogue — nine tools, 3 440 model-visible bytes, no dry_run/paging, short answers
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:
1 parent
edad66947f
commit
bfa8e98eb5
59 files changed
+4895
-7672
No files matched your search
@@ -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.
|
||||
@@ -25,12 +25,12 @@ hour. Record the release, the date and any failure in the table at the end.
|
||||
| 16 | Star `aes`, then `hmac`. | Five sections in that order; "Other modules" has 297 roots; each section opens and closes on its own; a module under both keeps its own open state in each. Title bar "Clear DUTs" removes both. |
|
||||
| 17 | Add `"lucisv.hierarchy.duts": ["aes"]` to the workspace `.vscode/settings.json`. | The section appears without starring; right-clicking `aes` offers only a greyed "DUT from settings" whose tooltip names the setting; "Clear DUTs" leaves it. Remove the setting again. |
|
||||
| 18 | MCP (VS Code 1.101+, platform `.vsix` in a clean profile: `code --profile lucisv-mcp-qa --install-extension lucisv-<v>-darwin-arm64.vsix`, opentitan open). Command palette → **MCP: List Servers**. | `lucisv (opentitan)` listed under the `lucisv` provider without opening a Verilog file first (the contribution point activates the extension); no error toast. |
|
||||
| 19 | Start it from that list; accept VS Code's trust prompt. In Chat (agent mode) ask: "call lucisv's project_overview". | One trust prompt; the tool call answers with `roots: …/opentitan`, the file and unit counts; the server's MCP output log shows `lucisv-mcp: indexed N files` and no error. |
|
||||
| 19 | Start it from that list; accept VS Code's trust prompt. In Chat (agent mode) ask: "call lucisv's hierarchy with no arguments". | One trust prompt; the tool call answers with the file/module counts line and the top modules as `name file:line`; the server's MCP output log shows `lucisv-mcp: indexed N files` and no error. |
|
||||
| 20 | Settings → `lucisv.mcp.enabled` off, then on again (no reload). | The server leaves **MCP: List Servers** when off and returns when on; Output → lucisv logged nothing new except, on the next activation with it off, one "lucisv.mcp.enabled is false" line. |
|
||||
| 21 | File → Add Folder to Workspace… (a second folder); then remove it. | Two servers, `lucisv (opentitan)` and `lucisv (<second>)`, appear without a reload; removing the folder leaves one. |
|
||||
| 22 | `lucisv.mcp.path` set to `/nowhere/lucisv-mcp`; start the server from the list. Reset the setting. | Not started; Output → lucisv: `cannot start the MCP server: "/nowhere/lucisv-mcp" not found …`; record whether VS Code itself adds a toast (acceptable if it is only VS Code's own "did not start" notice, not an extension error dialog). |
|
||||
| 23 | Universal `lucisv-<v>.vsix` with no `lucisv-mcp` on PATH; start the server. | Same as 22 with `"lucisv-mcp" not found`; the language server (steps 1–5) unaffected. |
|
||||
| 24 | **lucisv: Copy MCP server config** → Claude Code; paste into `.mcp.json` of a scratch copy of a project; in a terminal there run `claude`, `/mcp`. Repeat for VS Code → `.vscode/mcp.json` in another window. | The info message names `.mcp.json` and warns the bundled path moves on update; Claude Code lists `lucisv` connected and answers `project_overview`; the `.vscode/mcp.json` server (`"type": "stdio"`) starts too. |
|
||||
| 24 | **lucisv: Copy MCP server config** → Claude Code; paste into `.mcp.json` of a scratch copy of a project; in a terminal there run `claude`, `/mcp`. Repeat for VS Code → `.vscode/mcp.json` in another window. | The info message names `.mcp.json` and warns the bundled path moves on update; Claude Code lists `lucisv` connected and answers `hierarchy` (no arguments); the `.vscode/mcp.json` server (`"type": "stdio"`) starts too. |
|
||||
| 25 | Optional, if a VS Code older than 1.101 is at hand: install the platform `.vsix` there. | Extension activates normally; Output → lucisv has one "no MCP server API (needs 1.101+)" line; the copy-config command still works. |
|
||||
|
||||
## Runs
|
||||
|
||||
+11
-8
@@ -247,6 +247,8 @@ newlines, stdout is protocol-only, stderr is human-only.
|
||||
|
||||
### 4.3 The tools
|
||||
|
||||
> **Superseded by §10 (the lean catalogue, 0.58).** Kept as the record of the 0.57 surface.
|
||||
|
||||
Inputs name things the way an agent already has them: a **file path**
|
||||
(absolute or root-relative), a **unit name**, a **line** (1-based) and
|
||||
optional **column**, or a **symbol name** with an optional **unit**. Outputs
|
||||
@@ -342,6 +344,8 @@ records MCP's own).
|
||||
|
||||
### 4.5 Rendering rules (the token budget is the product)
|
||||
|
||||
> **Superseded by §10.2.** Kept as the record of the 0.57 rules.
|
||||
|
||||
- Paths root-relative; a file named once per group, never per line.
|
||||
- Line numbers 1-based, columns 1-based, in `file:line:col` form.
|
||||
- Lists capped (`limit`, default 500 since feedback-2) with `… and N more` — the agent can
|
||||
@@ -532,15 +536,14 @@ Dropped from the catalogue (the engines stay in the CLI and the LSP):
|
||||
- Refusals are one sentence, `isError: true`, and when a name is unknown
|
||||
they list the near matches so the next call is right.
|
||||
|
||||
### 10.3 Instructions (≤ 400 bytes)
|
||||
### 10.3 Instructions (≤ 400 bytes; the shipped text, 398 bytes)
|
||||
|
||||
> lucisv-mcp answers from the SystemVerilog sources on disk (save first).
|
||||
> Use it before reading files: hierarchy for the instance tree and top
|
||||
> modules, find for where a name is declared and used, outline for a file
|
||||
> or a unit's ports, read for one item's source, check after edits. Edits
|
||||
> (rename, port, edit_item, format) are verified, all-or-nothing writes to
|
||||
> disk: call them like a file write, no dry run. Paths are root-relative,
|
||||
> lines 1-based.
|
||||
> 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.
|
||||
|
||||
### 10.4 What stays
|
||||
|
||||
|
||||
@@ -5,11 +5,13 @@ description: Give Claude Code, Cursor and VS Code's agent mode lucisv's parser,
|
||||
|
||||
`lucisv-mcp` is lucisv as a [Model Context Protocol](https://modelcontextprotocol.io)
|
||||
server. A coding agent spawns it over stdio and asks it about the
|
||||
Verilog/SystemVerilog tree instead of reading whole files: a module's ports,
|
||||
a file's outline, one `always` block, who instantiates what, every reference
|
||||
to a signal. It can also make the edits lucisv already knows how to make
|
||||
safely — format, lint fixes, rename, the port refactorings and single-item
|
||||
replacements — each one verified before anything is written.
|
||||
Verilog/SystemVerilog tree instead of reading whole files: the instance
|
||||
hierarchy and where each instance is written, where a name is declared and
|
||||
used, a module's ports, a file's outline, one `always` block. It can also
|
||||
make the edits a plain file write cannot make safely — a rename across the
|
||||
design, adding or removing a port in every instantiation, a single-item
|
||||
edit, formatting with the safe lint fixes — each one verified before
|
||||
anything is written.
|
||||
|
||||
It is the same engine as the CLI and the language server (parser, index,
|
||||
formatter, linter, refactorings), in a third binary that shares no state with
|
||||
@@ -97,48 +99,38 @@ description. The agent sees the full description and input schema.
|
||||
|
||||
| tool | writes | what it answers |
|
||||
|---|---|---|
|
||||
| `project_overview` | | Files, units by kind, top modules, largest files. |
|
||||
| `list_units` | | Units (modules, interfaces, packages, classes, programs) with file:line. |
|
||||
| `unit_interface` | | A unit's parameters, ports (direction, type, range), modports or members; `template: true` adds an instantiation. |
|
||||
| `outline` | | A file's declarations as a tree with line ranges, and its parse errors. |
|
||||
| `read_item` | | One item's exact source and lines. |
|
||||
| `search_symbols` | | Declarations whose name contains `query` (any case), members included. |
|
||||
| `defines` | | The \`define table (name, parameters, body, file:line) of a `file`, a macro `name`, or all. |
|
||||
| `definition` | | Where a name or macro is declared: file:line:col, kind, line. |
|
||||
| `references` | | Uses of one declaration, then its unresolved mentions (strings, comments, macro text). |
|
||||
| `hierarchy` | | Who instantiates a module (`up`, with file:line) or what it instantiates (`down`, default). |
|
||||
| `diagnostics` | | Parse errors and lint findings (`line:col severity message [rule]`) of `file` or all. |
|
||||
| `format` | yes | Format `file`/`files` as `lucisv format`; `lines` limits it. |
|
||||
| `fix_lint` | yes | Apply the safe lint fixes to `file`/`files`; says what remains. |
|
||||
| `rename` | yes | Rename a declaration and its uses; select as `definition`. |
|
||||
| `expand_wildcard` | yes | Replace one instance's `.*` with the named connections it binds. |
|
||||
| `convert_ports` | yes | Rewrite a module's non-ANSI header as an ANSI port list. |
|
||||
| `organize_imports` | yes | Remove unused `import`s in the scope at a position; sort the rest. |
|
||||
| `inline_module` | yes | Replace one instance with its module's body, connections substituted. |
|
||||
| `propagate_ports` | yes | Connect by name every port one instance leaves unconnected. |
|
||||
| `remove_port` | yes | Delete a port and its connection in every instantiation; refused while the body uses it. |
|
||||
| `add_port` | yes | Add an ANSI port to a module, connected in every instantiation; `after` positions it. |
|
||||
| `extract_module` | yes | Move whole items in lines `start_line`..`end_line` to a new module instantiated in their place. |
|
||||
| `replace_item` | yes | Replace one item with `text`: one item, same kind and names (unless `rename`; references untouched). |
|
||||
| `insert_item` | yes | Insert items `text` before or after item `anchor`, or at `end` (`end@NAME`) of the last unit (unit NAME). |
|
||||
| `delete_item` | yes | Delete one item and its leading comments; refused while its names are used (sites listed) or it holds a \`define, unless `force`. |
|
||||
| `instantiate` | | Instantiation text for module `name`: parameters, instance name, named or `.*` ports. |
|
||||
| `hierarchy` | | The instance tree of `root` to `depth` (1-20, default 1), each at its instantiation file:line; `up`: its instantiations; `peek`: each statement's source. |
|
||||
| `find` | | Every declaration of `name` or unit.name (kind name file:line; macros too); `refs: true` adds each one's uses as file:line and the unresolved mentions (strings, comments, macro text). |
|
||||
| `outline` | | Exactly one of: `file`, its declarations as a tree with line ranges, parse errors first; `unit`, its file:line, parameters and ports in order (modports, package members). |
|
||||
| `read` | | One item's exact source after its file:first–last line. |
|
||||
| `check` | | Parse errors and lint findings of `file` or the whole design, one per line (file:line:col severity message [rule]), errors first; `ok` when clean. |
|
||||
| `rename` | yes | Rename declaration `name` (or unit.name) to `new_name` with every resolved use (.name/.* written out); `file` and name@LINE pick among declarations. |
|
||||
| `port` | yes | On `module`, `add` an ANSI port declaration (after port `after`, else last) connected in every instantiation, or `remove` a port and its connections (refused while used). |
|
||||
| `edit_item` | yes | One item of `file` (selector as read): `op` replace it by `text` (same kind and names), insert `text` before/after it (item `end`/`end@UNIT`: a unit's end), or delete it if unused. |
|
||||
| `format` | yes | Format `files` (a path, directory or glob like `rtl/**/*.sv`) as lucisv format; `fix: true` applies safe lint fixes first. |
|
||||
|
||||
## What it promises
|
||||
|
||||
- **Answers come from the disk.** Every call first re-checks the files it
|
||||
indexes, so no answer is older than the disk at the moment the call
|
||||
arrived. Unsaved editor buffers are invisible to it — save before asking.
|
||||
- **Edits are verified, then written whole.** Every edit tool computes and
|
||||
verifies every file's new text before the first write; a refusal names the
|
||||
reason and touches nothing. The formatter's own safety net applies to
|
||||
`format`; `replace_item`, `insert_item` and `delete_item` require the file to
|
||||
still parse and change no byte outside the item.
|
||||
- **`dry_run: true`** on any edit tool returns the unified diff instead of
|
||||
writing.
|
||||
- **Answers are short.** One line per fact, root-relative `file:line`, no
|
||||
headers; a long answer is cut at a fixed cap with one `… and N more` line,
|
||||
and a better question (`root`, `file`, `depth`, `unit.name`) narrows it.
|
||||
A refusal is one sentence, and when a name is unknown it lists the near
|
||||
matches.
|
||||
- **Edits are verified, then written whole — there is no dry run.** Every
|
||||
edit tool computes and verifies every file's new text before the first
|
||||
write, and writes all of it or none of it; call it like a file write and
|
||||
trust the answer (`check` afterwards, when you want the lint verdict). A
|
||||
refusal names the reason and touches nothing. The formatter's own safety
|
||||
net applies to `format` (a file it refuses is named and left as it was);
|
||||
`edit_item` requires the file to still parse and changes no byte outside
|
||||
the item; `rename` and `port` list the name's unresolved mentions
|
||||
(strings, comments, macro text) for you to check.
|
||||
- **Nothing outside the roots.** Every path a tool takes must resolve inside a
|
||||
`--root`; anything else is refused.
|
||||
- **The language server's cache is never written.** `--index-cache` names
|
||||
the directory the extension gives `lucisv-server`; `lucisv-mcp` accepts it
|
||||
today and will read that store (read-only) for a warm start in a later
|
||||
release — never write it, so there are never two writers.
|
||||
the directory the extension gives `lucisv-server`; `lucisv-mcp` reads that
|
||||
store for a warm start and writes only its own, `index-cache-mcp`, beside
|
||||
it — never two writers of one file.
|
||||
+4
-3
@@ -153,7 +153,7 @@ what a change on the pointed-to side must not silently break.
|
||||
| `lucisv_server ◀──▶ vlog_refactor` | handshake | Request-scope selectors added for the performance wave: `prepare_rename_here` must produce the same answer/refusal text as whole-scope `prepare_rename`; `rename_name_at` must name the target that the rename engine acts on; `port_action_modules` and `enclosing_module` must name every module the corresponding port action/command can edit. The server uses those names to choose an index-derived file set; `extract_site`, `inline_site` and `imported_packages` also name source requirements. **`rename_preflight(semantics, offset, new_name)` (perf5r-preflight, 2026-09-08)** owes whole-scope `rename` the same *refusal* text one-directionally — it may always stand aside with `Ok(())` and never invents a refusal — and deliberately reads no workspace index (unlike `prepare_rename_here`): only refusals that are a pure function of the request buffer's own text (the new-name check, no symbol here, an unresolved or inherited-candidate reference, an unspelled declaration, the same name at a non-file-scope declaration); every index-answered refusal stays on the slow road. The engine remains the authority, and every selector must supply a superset of files needed for edits and refusals (inline gap: §2.9-33). |
|
||||
| `lucisv_server ──▶ vlog_formatter` | depends | `format_source`, `format_range`/`LineRanges` (range, ranges, on-type formatting), `Config`, `fence::protected_regions` (quick-fix filter). |
|
||||
| `lucisv_server ──▶ vlog_linter` | depends | `run`, `lint` + `LintContext::from_parse` (lints from the `Document`'s own parse — one-parse), `default_rules`, `apply_fixes`, `rule_by_name`. Same three promises the CLI relies on. |
|
||||
| `lucisv_mcp ──▶ lucisv_core, vlog_parser, vlog_semantic, vlog_refactor, vlog_formatter, vlog_linter` | depends | The MCP block (2026-09-23, `docs/mcp/PLAN.md`, `TODO-MCP.md`): `lucisv-mcp` composes the six libraries through their public APIs only — `Discovery`/`filelist`/`walk`/`content_hash`/`write_atomic`/`diff::unified` (core); `tokenize`, `parse_tolerant`, `parse_source` (strict, the structural edits' rule 1), `LineIndex`, `defines`, the AST (`Item`/`ItemKind`, `Meta::leading`, `Connections`), `PARSE_STACK_SIZE` (parser); `analyze`, `IndexBuilder::{add_file, add_facts}`, `WorkspaceIndex::{absorb, fingerprint, units, members_of, member_in, instantiations, workspace_symbols, find_define, files_mentioning, …}`, `resolve_external`, `FileFacts::{of, decode}`, `FACTS_FORMAT` (semantic); every refactoring entry point + `find_references` + `instantiation_plan` (refactor); `format_source`/`format_range`/`fence` (formatter); `LintContext::from_parse`, `lint_with`, `select_rules`, `apply_fixes`, `rules_markdown`, `MentionOracle` (linter). **Never `lucisv_server`** (bin-only) and never `lsp-types`. Feature READMEs `docs/features/mcp-*`. |
|
||||
| `lucisv_mcp ──▶ lucisv_core, vlog_parser, vlog_semantic, vlog_refactor, vlog_formatter, vlog_linter` | depends | The MCP block (2026-09-23, `docs/mcp/PLAN.md`, `TODO-MCP.md`): `lucisv-mcp` composes the six libraries through their public APIs only — `Discovery`/`filelist`/`walk`/`content_hash`/`write_atomic` (core); `tokenize`, `parse_tolerant`, `parse_source` (strict, the structural edits' rule 1), `LineIndex`, `defines`, the AST (`Item`/`ItemKind`, `Meta::leading`, `Connections`), `PARSE_STACK_SIZE` (parser); `analyze`, `IndexBuilder::{add_file, add_facts}`, `WorkspaceIndex::{absorb, fingerprint, units, members_of, member_in, instantiations, workspace_symbols, find_define, files_mentioning, …}`, `resolve_external`, `FileFacts::{of, decode}`, `FACTS_FORMAT` (semantic); `rename`, `add_port`, `remove_port`, `find_references`, `instantiation_plan`, `module_definition`, `enclosing_module` (refactor); `format_source`/`fence` (formatter); `LintContext::from_parse`, `lint_with`, `select_rules`, `apply_fixes`, `rules_markdown`, `MentionOracle` (linter). **Never `lucisv_server`** (bin-only) and never `lsp-types`. Feature READMEs `docs/features/mcp-*`. **M7 (2026-09-23, the lean catalogue):** nine tools; `diff::unified`, `format_range` and the cursor refactorings (`expand_wildcard`, `convert_to_ansi`, `organize_imports`, `inline_module`, `propagate_ports`, `extract_module`) are no longer called — they stay in the CLI and the server. |
|
||||
| `lucisv_server ──▶ lsp-server / lsp-types` | depends | The transport (synchronous, no async runtime) and the protocol data model. Both pinned exactly. cancel-request additionally relies on `lsp-server 0.10.0`'s stdio transport being a **rendezvous channel** (its own forwarder queue exists because of it) — a version bump must re-read that crate's `stdio.rs`. |
|
||||
| `editors/vscode ◀──▶ lucisv_server` | handshake | The **spawn contract**: binary named `lucisv-server`, no env, LSP over stdio, `initialize` works with no roots (single-file mode). The extension passes exactly `[]` by default or `['--verbose']` when `lucisv.verbose` is true; the server accepts only that spelling (repeats are idempotent) and refuses any other argument with exit 2. Changing that setting restarts the server because it is a process argument, not an LSP setting. Wire shapes pinned on both sides: the custom `lucisv/scopePairs` result, the other `lucisv.*` settings section (push and pull), `initializationOptions.storagePath`, the markdown fence tag `systemverilog` (server emits it, extension's grammar registers it), the `bin/` layouts of the platform `.vsix` packages. `smoke.js` still drives the default no-argument contract headlessly; `tests/e2e.rs` pins both spawns and `tests/grammar.rs` pins the grammar. |
|
||||
| `editors/vscode ◀──▶ vlog_parser` | handshake | The TextMate grammar's keyword alternation is **hand-maintained and test-locked to `vlog_parser::KEYWORDS`**: `crates/lucisv_server/tests/grammar.rs` fails, naming the missing/extra words, when they diverge (there is no generator script). Adding a keyword to `token.rs`'s `keywords!` macro is therefore also a hand edit to `editors/vscode/syntaxes/systemverilog.tmLanguage.json`. |
|
||||
@@ -659,7 +659,7 @@ engine-lane features are listed above; this table is the server-internal web.
|
||||
| `ci-release ──▶ release-prep / editor-platform-vsix` | depends | Workflow = one-liners over `tools/`; consumes the exact seven `.vsix` names (`prune_release_assets.sh` checks each), the `CHANGELOG.md` heading convention, tag == workspace version. |
|
||||
| `release-prep ──▶ editor-packaging` | depends | `release.sh` runs `smoke.js` as its gate; closed the missing-`LICENSE` item editor-packaging filed. Version lives in exactly four files — a promise to everyone. |
|
||||
| `editor-marketplace-page ──▶ lucisv-server` (docs) | depends | The Details page mirrors the shipped capability table in the server's README; drifts if that table does. |
|
||||
| `editor-packaging ◀──▶ lucisv-mcp` (mcp-packaging) | handshake | The MCP spawn contract (2026-09-23): the binary `lucisv-mcp[.exe]` found by the same three-rung ladder as the server (`lucisv.mcp.path` → `bin/` → `PATH`), spawned by VS Code from `McpStdioServerDefinition(label, command, ["--root", folder, "--index-cache", storage], env, version)` — the constructor is positional — one per workspace folder; `serverInfo.name == "lucisv-mcp"`, ≥ 26 tools (`mcp_smoke.js` `MIN_TOOLS`). Provider id `lucisv.mcp`; settings `lucisv.mcp.enabled`/`.path`; command `lucisv.mcp.copyConfig`. |
|
||||
| `editor-packaging ◀──▶ lucisv-mcp` (mcp-packaging) | handshake | The MCP spawn contract (2026-09-23): the binary `lucisv-mcp[.exe]` found by the same three-rung ladder as the server (`lucisv.mcp.path` → `bin/` → `PATH`), spawned by VS Code from `McpStdioServerDefinition(label, command, ["--root", folder, "--index-cache", storage], env, version)` — the constructor is positional — one per workspace folder; `serverInfo.name == "lucisv-mcp"`, exactly the nine lean tools in order — `hierarchy, find, outline, read, check, rename, port, edit_item, format` (`mcp_smoke.js` `TOOLS`; **amended by M7, 2026-09-23**, was ≥ 26); `mcp_smoke.js --tool-table` regenerates the Agents guide's table. Provider id `lucisv.mcp`; settings `lucisv.mcp.enabled`/`.path`; command `lucisv.mcp.copyConfig`. |
|
||||
| `release-prep / editor-platform-vsix ──▶ lucisv-mcp` (mcp-packaging) | depends | `release.sh` builds `-p lucisv_mcp` for every triple and stages it as the THIRD `bin/` entry (fifteen in the `all` package); `expect_vsix_bins` and `audit_artifacts.sh` pin the name; the seven `.vsix` names are unchanged. `mcp_smoke.js` is the gate beside `smoke.js`. |
|
||||
| `lucisv-mcp ──▶ lucisv-server` (index cache, M6) | depends (read-only) | MCP reads the server's `index-cache` store read-only when `--index-cache DIR` names it (header `CACHE_FORMAT`/`FACTS_FORMAT`/version must match, else ignored) and writes its own `index-cache-mcp` beside it; it never writes the server's file. A codec change on the server side costs MCP its warm start, never its correctness. |
|
||||
|
||||
@@ -704,7 +704,7 @@ update the filing README(s) and this file.
|
||||
| 32 | **The refactoring verifier does not catch a same-file relocation of a never-dropped piece written as two well-formed edits** (delete here, insert there): `verify_move` computes `after` by applying the edits, so `positions_match`'s reconstruction cannot diverge from it and equation 3 of the ledger is unreachable through any real caller. No planner produces the shape today. Wanted: an independent `after` (the client's applied text, or a second reconstruction) and a test that isolates equation 3. Found by extract-module's QA re-attack. | extract-inline-module (QA) | vlog_refactor |
|
||||
| ~~33~~ | ~~**`module_sources`' fan-out has no rung for a file that reaches an instance through an intermediate module it does not itself instantiate** (a bench naming `wrap.u_S.x` where `wrap` instantiates `S`): inline-module's hierarchical-reference refusal sees only the handed files, so such a reference is missed. Wanted: a transitive-instantiators rung (§49's hierarchical surface knows the path) in `module_sources` for the refactorings that must see every hierarchical use. Found by §53.2's QA.~~ — **closed 2026-09-07 by perf5-p2 (TODO §60.2): a fifth, opt-in rung** `Workspace::module_sources_reaching(file, modules, Reach { scopes })` in `lucisv_server/src/module_select.rs` — every file whose *token census* (`WorkspaceIndex::files_mentioning`, i.e. `FileFacts::words`) writes the dissolved instance's name down. That is exactly the set `no_hierarchy` can refuse from, so the selected set answers the refusal as the whole workspace does (asserted engine-run-twice on six shapes; QA attacked seven more incl. `$root`, a macro-built `bind` path, an escaped identifier, a generate label). **The transitive-instantiator walk this row asked for was implemented and rejected:** a `bind tb.u_wrapper.u_top.u_sub …` in an SVA file that instantiates nothing in the chain has no instantiation edge for any walk to follow — structurally weaker, confirmed by QA. Only inline-module asks for the rung (extract and ports pass `Reach::none()`, unchanged in answer and cost); worst corpus cost 2 % of files on a command, +1.2 ms at the measured site. | extract-inline-module (QA) | lucisv_server / vlog_refactor |
|
||||
| ~~34~~ | ~~**The format cache omits `Config::uvm_utils_indent`.** CLI `args.rs::config_with` applies the key, but `main.rs::entry_for` and core `cache::Entry` serialize/compare only content, line length and indent (plus the store version). On one UVM class: cache a clean verdict with the option false, change only the option to true, then cached `--check` exits 0 while `--no-cache --check` exits 1. Wanted: key/equality/codec coverage for the option and a regression for both toggle directions. Until fixed, use `--no-cache` or delete the format cache after toggling. See repository-analysis.md for the bounded reproduction.~~ — **fixed 2026-09-07 (TODO §59, 0.50.0):** `Entry` carries `uvm_utils_indent`, `entry_for` fills it, the store line has it as a fourth field; a well-formed five-field (0.49.0) line is dropped individually like another version's entry; the audit's probe is `changing_uvm_utils_indent_invalidates_the_entry` in `lucisv/tests/cli.rs`, both directions. | repository audit, 2026-09-07 | lucisv_core / lucisv |
|
||||
| 35 | **MCP-5 → `vlog_parser`:** lift the server's `expand.rs` (one-step macro expansion) into `vlog_parser::defines` as a pure move so `lucisv-mcp`'s `defines` can offer expansion | mcp-navigation | vlog_parser |
|
||||
| 35 | **MCP-5 → `vlog_parser`:** lift the server's `expand.rs` (one-step macro expansion) into `vlog_parser::defines` as a pure move so `lucisv-mcp`'s `defines` can offer expansion — *moot since M7: `defines` folded into `find`, which lists a macro's definitions and no expansion* | mcp-navigation | vlog_parser |
|
||||
| 36 | **MCP-6 → `lucisv_server` (possible bug):** LSP `references` omits three real `aes` instantiations in the `*_pd_main.sv` tops (and their `.clk_i` connections) that `lucisv-mcp`'s whole-set answer lists; stable after a 30 s settle, not investigated | mcp-navigation | lucisv_server |
|
||||
| 37 | **MCP-7 → `vlog_refactor`:** a `find_references` variant taking `&dyn KnownFacts` (like `rename_traced_with`) so whole-set callers feed cached records instead of re-parsing 3 944 files (≈2 s per opentitan call today) | mcp-navigation | vlog_refactor |
|
||||
| 38 | **MCP-8 → `vlog_refactor`:** false `remove_port` refusal when the only "use" of the port is a named connection from another module in the same file (`ports/remove.rs::body_uses_in`) | mcp-edit-tools | vlog_refactor |
|
||||
@@ -712,6 +712,7 @@ update the filing README(s) and this file.
|
||||
| 40 | **MCP-11/12 → `vlog_refactor`/`vlog_semantic`:** a batched `find_references` for several declarations; `find_references` misses a hierarchical use into a generate loop (`gen_l[0].z`) | mcp-structural-edits | vlog_refactor, vlog_semantic |
|
||||
| 41 | **MCP-13 → `vlog_linter`:** a forced deletion of a non-ANSI body port leaves a header port with no direction and no lint reports it | mcp-structural-edits | vlog_linter |
|
||||
| 42 | **Parser leniency → `vlog_parser`:** a trailing `,` in a named connection list, an empty concatenation element `{d,, d}`, and `type(x)'(y)` in a connection parse without a diagnostic (the rename verifier's position rule covers the rename; every other splice contract is exposed) | refactor-rename (M3.5) | vlog_parser |
|
||||
| 43 | **MCP-14 → `vlog_refactor`/`vlog_semantic`:** rename of a generate block label leaves hierarchical paths through it unrewritten and `find_references` does not report them — vlog_refactor/vlog_semantic; the MCP layer refuses the rename; the LSP still allows it | mcp-lean-catalogue | vlog_refactor, vlog_semantic |
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in new issue
Block a user