vlog_refactor: a rename used to cut a `.name` shorthand or a `.*` wildcard binding — port d → din of leaf left `leaf u (.*)` binding nothing and turned `.d` into `.din` against a parent with no net din; renaming the parent's net cut both — and verified clean, because the semantic layer records the port half of `.name` and nothing of `.*` (M3 QA finding 1; the LSP shared it). rename/{connections,sites,layout}.rs: an AST walk over every named connection list finds the implicit bindings and looks each name up the way the language does (nearest declaration outward; a bind's target module; a bare instance name resolved through the instantiation table with the bind's enclosing module's own instances winning, §23.11); `.p` becomes `.q(p)`, a `.*` that bound the name gains `.q(p)` / `.n(m)` appended in the list's own layout (comma before a trailing // comment, CRLF kept); every rewrite listed in warnings; refused by name: a `.*` into a module lucisv cannot read or finds declared twice, a list split by ifdefs or holding unparsed text, a hierarchical bind target, a `.*` that would start binding the new name, a package variable an import might hand to a `.*`. check/implicit.rs: the verifier learns the shape — a file with insertions passes only if every replacement is the old name becoming the new and every insertion is one of four connection templates at the exact slot the rewrite writes (a shorthand's name end; between a `.*` list's last element and its `)`), the comma and its `.X(Y)` only as a pair in one list, no slot at all in a list holding an error element — and every implicit binding (port half and net half) is printed before and after and must match. lucisv_server: rename_sources_traced hands the engine one more hop — the declaring files of every module a handed-over file instantiates (module_select::instantiated_by, index edges only) — so a `.*` into a module declaring neither name is read, not refused. lucisv_mcp: the rename tool's known-limit sentence replaced; the M3 QA finding-1 test un-ignored.
Three QA rounds (Opus) attacked the widened verifier and found, in order, position-blind insertions, a lone trailing comma, and a slot after an error element — each fixed (the last by the lead) and pinned by 40+ qa_* tests incl. masked-corruption pairs; opentitan copies: prim_count err_o/clr_i, aes_core clk_i, entropy_src clk_i, prim_packer_fifo wready_o rename cleanly with their .* cov binds written out; prim_fifo_sync clr_i refused over the FPV binds that really target fifo instances. Accepted gap: a bind onto an instance that exists only inside a generate block of the enclosing module. Filed to vlog_parser: trailing `,` / `{d,, d}` / `type(x)'(y)` in a connection list parse without a diagnostic. Gates through tools/guard.sh: fmt, clippy, workspace 4 762 passed.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
20 KiB
TODO-MCP — the Model Context Protocol block
Planned 2026-09-23 by the lead at 0.55.0. The analysis and design are in
docs/mcp/PLAN.md; read it before touching any lane.
This file is the tracking sheet for the block and stays separate from
TODO.md on purpose: the block is independent of the LSP and CLI lanes, and
its lanes collide with nothing in docs/topo.md except where a lane below
says so.
Rules that apply to every lane, restated once: CLAUDE.md in full (guard
every suite and sweep through tools/guard.sh; no git commit/push; a
feature README kept current as you work; no file outside the lane's list;
cross-module wants are Handshake requests, not edits); opentitan is
read-only; no sleep over 60 s; cargo fmt -p per package while another
lane is live. Each lane is one Opus dev then one Opus QA (owner's ruling
2026-09-23: both Opus 5.5), working directly on trunk, then the lead's
self-inspection and a commit; no release until every lane is done. A QA
"rework" loops inside its lane.
Fixed names (the wire shapes every lane pins by test)
| thing | name |
|---|---|
| crate / binary | crates/lucisv_mcp / lucisv-mcp |
| arguments | --root DIR (repeatable; default cwd), --filelist FILE, --index-cache DIR, --verbose; anything else → usage: on stderr, exit 2 (the server's posture) |
| vsix entry | extension/bin/lucisv-mcp[.exe] (platform), extension/bin/<vsce-target>/lucisv-mcp[.exe] (all) |
| VS Code provider id | lucisv.mcp; settings lucisv.mcp.enabled (true), lucisv.mcp.path (""); command lucisv.mcp.copyConfig |
| feature READMEs | docs/features/mcp-transport, mcp-read-tools, mcp-navigation, mcp-edit-tools, mcp-structural-edits, mcp-packaging, mcp-cache-and-census |
M1. Transport and the read tools
Files: Cargo.toml (workspace members += crates/lucisv_mcp),
Cargo.lock, everything under crates/lucisv_mcp/ (src/main.rs,
transport.rs, rpc.rs, project.rs, render.rs, tools/mod.rs,
tools/read.rs, tests/wire.rs, tests/fixtures/), the two feature
READMEs. Nothing else — in particular no change to any library crate; a
missing public query is a Handshake entry.
- crate skeleton:
main.rsargument contract (table above), thePARSE_STACK_SIZEmain thread, the ordered loop;transport.rsnewline-delimited JSON-RPC over stdio (stdout protocol-only, stderr log-only; a line that is not JSON →-32700, never a crash) rpc.rs:initialize(version negotiation over a listed set, the pinned current revision first;serverInfo;capabilities;instructions),notifications/initialized,ping,tools/list,tools/callenvelope (contenttext +structuredContent,isErrorfor refusals),notifications/cancelledaccepted, unknown method/tool/params →-32601/-32602project.rs: roots,Discovery, filelist-or-walk file set with the 1 MiB cap,IndexBuilderbuild, lazy per-fileSemantics, the per-call stat sweep +update_file/remove_file+ re-walk policy (PLAN §4.4); a path outside every root is refused by name- tools
project_overview,list_units,unit_interface(ports, parameters, template viainstantiation_plan; modports for an interface; exports for a package),outline,read_item(incl. thealways@<line>spelling for unlabelled blocks),search_symbols— each withinputSchema,annotations(readOnlyHint: true), a one-sentence description written for the agent, and the compact rendering rules of PLAN §4.5 tests/wire.rs: spawns the built binary; the handshake; every tool over a fixture tree of ≥ 6 files (a package, two modules with a.*instance, an interface with a modport, a class, a file with a parse error); a freshness test (edit a fixture on disk between two calls, second answer reflects it; delete one, it disappears; fingerprint equals a rebuild after each); a malformed-line test; a--rootoutside-path refusal- README
mcp-transport: Goal, Assumptions (why normcp; the pinned protocol revisions; sync one-at-a-time), Handshakes (none consumed beyond public APIs — list them), work log; READMEmcp-read-toolslikewise, with the rendering rules as its contract - gates through
tools/guard.sh; sizes reported per file - QA: protocol attacks (an
idthat is a string, a nullid, a notification with anid, a 10 MB line, a request beforeinitialize, an unsupportedprotocolVersion), rendering attacks (a unit named with an escaped identifier, a port with a packed and unpacked range, a file with CRLF line endings — line numbers must still be right), the freshness promise under a rename-then-recreate of a file within one second; verdict in the QA logs
M2. Navigation, diagnostics, resources
Files: crates/lucisv_mcp/src/tools/nav.rs, resources.rs,
tools/mod.rs (registry entries only), rpc.rs (the three resources/*
methods), tests/wire.rs (additions), the mcp-navigation README.
Depends on M1 merged.
definition(selector:file,line,colorname,unit?; local viaSemantics::definition_of, cross-file viaresolve_external; ambiguity is a list),references(vlog_refactor::find_references, grouped by file, capped withlimit/offset),hierarchy(down fromrootor every top-level module;uplists parents; parameter overrides as written;depth),diagnostics(parse errors, missing-closer warnings via the tolerant tree, lint throughselect_rules+ the project's[lint]config + external waivers + an index-backedMentionOracle; the CLI's JSON field names),defines(table; one-step expansion when called withname+args)- resources
lucisv://overview,lucisv://unit/{name},lucisv://rules(rules_markdown()),lucisv://file/{path}/outline;resources/templates/listfor the two parameterised ones - the opentitan parity census as an
#[ignore]test taking the checkout path from an env var:references/definitionon thereferences-navsymbols andhierarchydown fromtop_earlgreycompared with the LSP's answers recorded in that README (read-only;git statusof the checkout identical before and after) - README
mcp-navigation; work log; gates; sizes - QA: a
bindconnection's bare name, au_x.sigtail, a name that is both a port and an internal net (must list both, not pick), a class member, a macro-only name (files_naming_in_macros), ahierarchyover a recursive/generate-instantiated module (must terminate with the depth cap), lint options fromlucisv.tomlhonoured; verdict
M3. Edit tools (wrapping the verified engines)
Files: crates/lucisv_mcp/src/tools/edit.rs, apply.rs, tools/mod.rs
(entries), tests/wire.rs (additions), tests/fixtures/ (additions), the
mcp-edit-tools README. Depends on M2 merged and on the ruling for
Handshake MCP-1 (the diff lift) — until MCP-1 lands, apply.rs carries a
private copy of unified marked // TODO(MCP-1) and the README says so.
apply.rs:RefactorEdit→ (dry_run) unified diff per file | the all-computed-then-written loop overwrite_atomic, refusing before the first write on any verifier failure; the summary (files, +/- lines, warnings, created); the "written N of M then failed" reportformat(files[]orfile+lines,dry_run),fix_lint(apply_fixesthroughfence::protected_regions, safe fixes only),rename,expand_wildcard,convert_ports,organize_imports,inline_module,propagate_ports,remove_port,add_port,extract_module(home: new file / same file; the created file is written too),instantiate(text only;style) — every one withdestructiveHint: false,idempotentHintwhere true- the source-set rule: each refactor gets the whole in-scope file set (PLAN §2.1 — the server narrows; MCP does not, so it can never be narrower than the engine needs); the README states the cost on opentitan and M6 measures it
- tests: every tool
dry_runthen real on the fixtures; run twice → second run is a no-op with an empty diff; a refusal leaves the fixture tree byte-identical (hash the tree before/after); anextract_moduleinto a new file; a rename that touches three files; afix_lintwhose finding sits in a format fence (must not touch it) - README
mcp-edit-tools; Handshake MCP-1 filed there with the exact move; work log; gates; sizes - QA: an edit whose target file changed on disk between the stat
sweep and the write (the freshness promise vs the write — the write
must be refused, not applied over the newer bytes; the dev states the
mechanism); a read-only file; a path through a symlink leaving the
root; concurrent
lucisv --checkon the same tree; a CRLF file throughformat; verdict — done 2026-09-23 (Opus, two rounds + lead fixes): pass for the lane; the write path held under a 50 ms writer race, chmod 444, symlinked escapes and a concurrent CLI;format/fix_lintbyte-identical to the CLI. Findings ruled: skipped files refuse a whole-word match; whole-set tools re-walk first. Open, out of lane: the engine's rename breaks.*/.nameshorthand connections → M3.5 below.
M3.5. Rename vs implicit connections (inserted 2026-09-23 after M3 QA)
Files: crates/vlog_refactor/src/rename/**, crates/vlog_refactor/src/check/**
only if the verifier must learn the shape, crates/vlog_refactor/tests/
(or the crate's test modules), docs/features/refactor-rename/README.md
(a dated section), crates/lucisv_mcp/src/tools/edit.rs (drop the
known-limit sentence) + tests/qa_m3.rs (un-ignore finding 1), TODO.md
(one line under the §8 rope-port refactorings noting the fix). An engine
lane: the LSP's rename inherits the fix.
vlog_refactor::renamerewrites implicit connections: renaming a portp→qturns.pinto.q(p)and adds.q(p)beside a.*that bound it (explicit connections beside.*are legal); renaming a netn→min a module whose instantiations bind it through.nor.*turns.ninto.n(m)and adds.n(m)beside the.*; comments and layout of the connection list preserved (append after the last connection, before the closing paren, on its own line when the list is one-per-line); every such rewrite listed inwarningsso the user sees it; refuse (never guess) when the instantiation's port list cannot be read (ifdef-split, error element)- the verifier sees the new edits as intended (no false "moved"
refusal); attack tests:
.*+ explicit of the same port; nested instances; a.namewhose net and port differ; a bind instance - QA: attack the rewrite on opentitan copies (
prim_fifo_syncports under.*users); LSP parity viavlog_refactor::renamedirectly
M4. Structural edits (the one new verifier in the block)
Files: crates/lucisv_mcp/src/tools/item.rs, tools/mod.rs (entries),
tests/wire.rs and tests/attacks.rs (new), fixtures, the
mcp-structural-edits README. Depends on M3 merged.
replace_item,insert_item,delete_itemwith the PLAN §4.3 contracts: bytes outside the span untouched (asserted by the test, not trusted), strict re-parse of the whole file (or no growth in tolerant error count when it did not parse before), one item at the position, the declared name matches unlessrename: true,delete_itemrefuses over surviving references unlessforcetests/attacks.rs, written by the dev, every case asserted refused with the tree byte-identical: atextopening a block it does not close; one that closes the enclosing module; one that re-declares a port; a UTF-8 boundary inside the span; an item inside a format fence; a file with an unterminated string; aninsert_itemafterend— the CLAUDE.md invariant-4 discipline applied to the block's own verifier- README
mcp-structural-edits: the contract as a table, the attack list, what the tool deliberately does not check (semantic sense of the new text) - gates; sizes (
item.rsis expected to be the largest file in the crate; if it passes 600 lines the verifier moves toitem/verify.rs) - QA: re-attack with at least eight new cases (a
textthat is two items; an emptytext; atextequal to the old bytes — must be a no-op, not a refusal; a macro-bracketed item; agenerateblock target; an item whose leading comment is shared with the previous item's trailing one; a 40 000-line file for timing;delete_itemon the last item of a module); verdict
M5. Packaging and the extension (parallel with M2–M4)
Files: tools/release.sh, tools/audit_artifacts.sh,
tools/RELEASING.md, .gitea/workflows/ci.yml (two lines: the MCP wire
test is already in cargo test; add node --test editors/vscode/*_test.js),
editors/vscode/{package.json,package-lock.json,extension.js,mcp.js, mcp_test.js,mcp_smoke.js,.vscodeignore,README.md,CHANGELOG.md},
docs/site/src/content/docs/guides/agents.md (new) and the guides index,
README.md (an "Agents (MCP)" paragraph under Editor setup), the
mcp-packaging README. May start once M1's binary answers initialize on
trunk; touches no Rust. extension.js changes are limited to requiring
mcp.js and calling its activate(context).
release.sh: stagelucisv-mcp[.exe]intobin/(platform) andbin/<target>/(all);expect_vsix_binslists grow to three;mcp_smoke.jsrun against the host binary and against the one unzipped from the host vsix and the all-platforms vsix (mirrorsmoke_embedded_server);audit_artifacts.shaccepts the third name; the universal vsix still asserts noextension/bin/*mcp.js: the three-rung binary ladder reusingbundledBinary; the guardedregisterMcpServerDefinitionProvider("lucisv.mcp", …)with oneMcpStdioServerDefinitionper workspace folder (--root,--index-cache <storagePath>,cwd,versionfrompackage.json), re-fired on folder changes;lucisv.mcp.enabled/lucisv.mcp.pathread likeserverPath(inspect(), blank = unset); thelucisv.mcp.copyConfigcommand with the three dialects (Claude Code.mcp.json, Cursor, VS Code.vscode/mcp.json) naming the resolved binary;mcp_test.jswith a stubbedvscode(thehierarchyView_testpattern) covering the ladder, the guard on an old VS Code (nolm), and the three snippetspackage.json:contributes.mcpServerDefinitionProviders, the two settings, the command + palette entry; engine stays^1.82.0unlessvsce packagerefuses — then bump to^1.101.0and record why in the README and CHANGELOG- docs: the site guide page (install via vsix → nothing to do; Claude
Code / Cursor snippets; the standalone
cargo buildline; the tool list generated fromtools/listoutput, checked in);README.mdparagraph;tools/RELEASING.md(three binaries; the smoke); the extension README and CHANGELOG - CI:
node --test editors/vscode/*_test.jsinci.yml - README
mcp-packaging; work log;node --testgreen; a localtools/release.sh(host only) producing a darwin-arm64 vsix with the three binaries, unzipped and checked - QA: install the vsix into a clean VS Code profile: the server listed
under MCP: List Servers, trusted,
project_overviewanswered in agent mode;lucisv.mcp.enabled: falseremoves it; a multi-root workspace registers one server per folder; the universal vsix on a machine withoutlucisv-mcpon PATH degrades to a clear output-channel line, not an error dialog; the Claude Code snippet pasted into a.mcp.jsonworks from a terminal; rows indocs/manual-acceptance.md; verdict
M6. Cache reuse, census, closing release
Files: crates/lucisv_mcp/src/{project.rs,cache.rs} (new cache.rs),
tests/ additions, docs/mcp/census.md (new), docs/perf/README.md (an
MCP section), docs/topo.md (§1.1 node + §2.8 rows for lucisv_mcp, an
§1.4 touch-set row), docs/manual-acceptance.md, CHANGELOG.md,
docs/repository-analysis.md (the crate count and map row), the
mcp-cache-and-census README, TODO-MCP.md (this file's closing entries).
Depends on M4 and M5 merged.
cache.rs: the read-only reader of the LSP'sindex-cache(header check onCACHE_FORMAT/FACTS_FORMAT/version, per-line checksum,FileFacts::decode,record_path); on--index-cache DIRa file whosecontent_hashhas a record isadd_facts'd instead of parsed; MCP's ownindex-cache-mcpwritten with the same codec on exit and read on start; never a write to the LSP's file (a test opens the store read-only and asserts its bytes after a full MCP session)- startup timing on opentitan cold / warm-from-LSP-store /
warm-from-own-store, and the per-call stat sweep, recorded in
docs/perf/README.mdnext to the LSP's scan trace numbers; the whole-set refactor cost from M3 measured onrenameinaes - the token census (PLAN §8): the three tasks, each run twice (file
tools only / with lucisv-mcp) by the same agent model, tokens in and
out from the transcripts, written up in
docs/mcp/census.mdwith the transcripts' task ids; if a task saved nothing, say so — the number is the deliverable, not its sign instructionsand tool descriptions revised from what the census transcripts show the agent misunderstood;prompts/*added only if the census shows a repeated multi-tool sequence worth one promptdocs/topo.md: thelucisv_mcpnode (──▶the six libraries;-.spawn contract.->fromeditors/vscode;-.builds/packages.->fromtools/), the §2.8 rows, the Handshake MCP-1 status (delivered or still open), and MCP-3 filed in §2.9 if M2's hierarchy walk and the server's snapshot driftedCHANGELOG.mdsection,README.mdarchitecture table row (nine crates),docs/repository-analysis.mdmap row, CLAUDE.md measurement line refreshed with the new crate's sizes- release 0.56.0 (or the next minor free at the time): tag, CI
green, 8 assets, the darwin-arm64 vsix unzipped and checked for three
binaries, the MCP smoke in the release log; the install line and the
claude mcp addline given to the owner - QA: the read-only promise on the LSP store attacked (a store with a torn last line; one from a different version; one whose record hash matches but whose facts checksum does not — each must be skipped, not trusted, and the file left byte-identical); a cold start with no store directory permission (must still answer, warn on stderr); the census transcripts spot-checked for a tool answer the agent had to correct by reading the file anyway (each is a finding against a tool's rendering); verdict
Open questions for the owner (answer before the lane that needs it)
- Engine bump (M5): if
vsceaccepts the contribution point on^1.82.0, keep it; if not, bump to^1.101.0and drop VS Code < 1.101 users. The lane records which happened; no ruling needed unless the bump is unwelcome. - Whole-set refactors (M3): MCP hands every refactor the full in-scope
set. On opentitan that is a parse of ~3 000 files per
renameunlessKnownFactsfrom the cache is threaded through (M6 can). Acceptable for the first release, or should M3 already narrow withfiles_mentioningthe way the server does? - Structural edits and the formatter (M4): after
replace_item, the agent's text is left as written. The alternative — format the replaced item's lines throughformat_rangeautomatically — costs a refusal path when the safety net objects. Default in this plan: not automatic; the agent callsformatwithlines.