Census round 1 (mcp_analysis.md, Sonnet arms on the opentitan clone): the mcp arm used more tokens than plain file tools on all three tasks (+18/+25/+20 %) and was incomplete on the rename — the `rename` tool renamed what the engine sees and warned about the macro argument, but nothing listed the old name still spelled as text (a DV force path built as the string ".state_q"), which the base arm's broad search found. Fixes (crates/lucisv_mcp/src/tools/{mentions,place,place/slot,place/verify}.rs + descriptions): `references`, `rename`, `remove_port` and `add_port` end with every whole-word spelling of the name in strings, comments, macro text, define bodies and macro-rooted paths that no engine answer accounted for, ranked edited-files-first, capped at 50, computed on the texts as written; `hierarchy` leads with "who instantiates a module", `references` routes a module name there, `instructions` say so; `tools/list` 30.2 kB → 18.0 kB with every argument still documented; `add_port` takes `after` — the engine appends, the placer moves the header element and each instance's connection to after the anchor in the neighbours' layout, refuses any list holding an unreadable element (an `(* attr *)` port the parser keeps as text would otherwise make the next port inherit the new type — QA's blocking find), and a checker compares every port's declaration text and pairs each comment with its anchoring name against the engine's result; stale `index-cache-mcp.*.tmp` files older than 10 min swept before a write. QA (Opus, two rounds): 23 qa_f1 tests. Gates through tools/guard.sh: fmt, clippy, workspace 4 918 passed.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
7.1 KiB
mcp_analysis.md — does lucisv-mcp help an agent? (the token census)
Owner's brief (2026-09-23): after the MCP block is complete, run the server against the OpenTitan tree, have sub-agents do real edits with and without it, compare the token usage, feed what is learned back into the server, and repeat for at least three rounds. This file is the record. It is written by the lead; numbers are measured, not asserted.
Method
Harness. ~/.cache/lucisv-eval/ (durable, outside the volatile session
scratchpad): a local clone of OpenTitan (ot/, 0098135), the three task
prompts (tasks/{a,b,c}.txt), the frozen server binary per round
(bin/lucisv-mcp-r<N>), and a stdio shim (mcpc <tool> '<json>',
mcpc --list) that runs one MCP session per call. Why a shim and
sub-agents rather than a headless claude -p --mcp-config session: the
claude CLI on this machine has an expired OAuth session that only the
owner can renew, and the lead's own agent harness cannot attach a new MCP
server mid-session. The shim costs the agent the same tokens a native tool
result would (the answer text lands in its context either way); what it
loses is the persistent process (each call re-indexes, ~1–2 s) and the
tool-schema exposure a host gives natively (the agent reads --list once
instead).
Arms. For each task, one sub-agent per arm, same model, same prompt
text, same clean clone (git checkout -- . && git clean -fdq before every
run), one agent at a time:
- base — ordinary file tools and search (
rg), no lucisv binaries; - mcp — the same, plus the shim and one paragraph telling it which
tools to prefer (the server's own
instructions, paraphrased).
Model. Claude Sonnet 5 for the arms (cost); one Opus 5.5 confirmation run on the hardest task in the last round if the budget allows. The lead grades.
Metrics per run. Tokens (the harness's total for the sub-agent, input plus output across all its turns), tool calls, wall time, and the outcome graded against a lead-computed ground truth:
- a (read-only census): set equality with
results/truth_a.txt— the 47 RTL instantiations ofprim_fifo_syncunderhw/ip/with theirWidth/Depthoverrides, computed withhierarchy upand checked by hand against the files (DV, FPV,ip_templatesandtop_*/ip_autogenexcluded by the task's wording); - b (two-file port propagation): the diff touches exactly
aes_cipher_core.svandaes_core.sv, addsinput logic dbg_iafterrst_niin both, and connects.dbg_i(dbg_i)on the instance; both files parse (diagnostics); style matches the neighbours; - c (cross-file rename): the seven sites in
results/truth_c.txtare renamed — five the engine sees, plus a macro-argument use (`PRIM_FLOP_SPARSE_FSM(…, state_q, …)) and a macro-rooted hierarchical path intop_earlgrey/dv/env/chip_if.sv— and none of the csrng/ednstate_qsites move; - hygiene: any file touched outside the task is a failure.
Rounds. After each round the mcp-arm transcripts are read for tool
misuse, refusals the agent could not recover from, and answers it had to
re-derive by reading files anyway; each becomes a change to the server
(descriptions, instructions, rendering, a missing tool, a bug) through a
dev+QA lane, the binary is re-frozen, and the round repeats.
Round 1 — server at 0f4830a (M1–M6 as committed)
| task | arm | tokens | tool calls | wall | outcome |
|---|---|---|---|---|---|
| a | base | 91 094 | 10 | 114 s | correct, 47/47 |
| a | mcp | 107 605 | 14 | 335 s | correct, 47/47 |
| b | base | 59 922 | 11 | 25 s | correct, clean |
| b | mcp | 74 720 | 17 | 78 s | correct, identical diff |
| c | base | 87 546 | 34 | 172 s | correct, 8/8 sites |
| c | mcp | 104 837 | 35 | 171 s | incomplete, 7/8 sites |
Observations
The server did not pay for itself in round 1. On every task the mcp arm
used more tokens than the base arm (+18 %, +25 %, +20 %), took longer, and
on the rename it was less complete. Sonnet with plain file tools is a
strong baseline on a tree this well organised: rg finds instantiations
and hierarchical paths by text, and reading a 1 000-line file is cheap
compared with a catalogue of 26 tool schemas plus several calls that each
re-index the tree through the shim. What the transcripts show:
- Wrong tool for the census (a). The agent asked
referencesfor the module name — a whole-set engine call, ≈4 s per shim call — and then read the instantiating files for the overrides.hierarchy upanswers the question in one call, instance names and#(…)overrides included; nothing in the descriptions told the agent so. - The catalogue is a fixed tax. The shim's condensed
--listis 11.6 kB (≈3 000 tokens; the rawtools/listJSON a native host sends is 30.3 kB, ≈7 500 tokens). Read once, it costs the mcp arm those tokens before any work — on a 25-second task (b) that is most of the gap. - Verified edits were not the bottleneck on b. Both arms produced the
identical three-line diff; the mcp arm's extra calls were
diagnosticschecks (useful, but they cost).add_portwas not used: it appends a port, and the task wanted a specific position with the file's alignment. - The rename missed what no engine sees, and said nothing (c). The
renametool renamed five sites and warned about the macro argument (the agent fixed it). It found the macro-rootedchip_if.svpath by its own search. It never looked for the DV string".state_q"that builds a force path, because nothing in the answer said "the old name is still spelled in these files as text". The base arm's broadrgfound it. A rename that lists the unresolved textual mentions of the old name — strings, comments, macro text, across the whole set — would have handed the agent exactly that list. - What worked: every
dry_run/diagnosticsanswer was trusted and correct; the macro-argument warning was acted on; the line-length lint finding onchip_if.svwas fixed by the agent (the base arm left a 105-column line). Correctness of the server's answers was never the problem; discoverability and completeness of what it says were.
Changes for round 2 (dev+QA lane "feedback-1"): (i) rename and
references end with an "unresolved mentions" section — every whole-word
spelling of the name in strings, comments and macro text across the whole
set, as file:line, with the sentence that the engine did not resolve them;
(ii) hierarchy's description leads with "who instantiates X — instance
names and parameter overrides", references' description points a module
name at hierarchy up, and instructions say the same in one line;
(iii) add_port takes an optional after port name so a positioned
insertion is one verified call; (iv) descriptions trimmed by about 40 % (30 kB → ≤ 18 kB of tools/list
JSON) — the catalogue is read by every agent on every session; (v) M6 QA's orphaned
temp-file sweep. The shim's per-call re-index is a harness artefact, not a
product one; a native host keeps the process alive, so wall time is not
graded.