Files
lucisv/mcp_analysis.md
T
lucioandClaude Fable 5.1 c2e42b8840
ci / checks (push) Successful in 1m39s
ci / corpus (push) Successful in 33s
MCP feedback-2: the count line leads every paged answer, default limit 500, in path-glob filter on the listing tools, post-edit check hint; census round 2 written up
Census round 2 (mcp_analysis.md): with feedback-1 the rename task became complete (the unresolved-mentions list surfaced the DV string path) at a token cost inside the base arm's run-to-run variance; the port task was unchanged; the census task regressed — the agent chose `hierarchy up` (right) but paged the 77-row answer with a small limit and never read the trailing "… and N more". Fixes: every paged text answer opens with `N <noun> (showing a–b)` (JSON gains `shown`), DEFAULT_LIMIT 500; `list_units`, `search_symbols`, `references`, `hierarchy`, `diagnostics` and `defines` take `in`, a root-relative path glob (`*` within a component, `**` across, `?`; a bare directory means everything below it) applied before paging — `hierarchy up prim_fifo_sync` with `in: "ip/**/rtl/*.sv"` answers the census's 47 in one call; the six design-wide edits end with `check: diagnostics on <files>`. Catalogue 17 993 B, instructions 896 chars. QA (Opus): 14 qa_f2 tests, four notes. Gates through tools/guard.sh: fmt, clippy, workspace 4 943 passed (+1 lead test).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-23 21:50:34 -07:00

9.6 KiB
Raw Blame History

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 of prim_fifo_sync under hw/ip/ with their Width/Depth overrides, computed with hierarchy up and checked by hand against the files (DV, FPV, ip_templates and top_*/ip_autogen excluded by the task's wording);
  • b (two-file port propagation): the diff touches exactly aes_cipher_core.sv and aes_core.sv, adds input logic dbg_i after rst_ni in 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.txt are renamed — five the engine sees, plus a macro-argument use (`PRIM_FLOP_SPARSE_FSM(…, state_q, …)) and a macro-rooted hierarchical path in top_earlgrey/dv/env/chip_if.sv — and none of the csrng/edn state_q sites 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:

  1. Wrong tool for the census (a). The agent asked references for the module name — a whole-set engine call, ≈4 s per shim call — and then read the instantiating files for the overrides. hierarchy up answers the question in one call, instance names and #(…) overrides included; nothing in the descriptions told the agent so.
  2. The catalogue is a fixed tax. The shim's condensed --list is 11.6 kB (≈3 000 tokens; the raw tools/list JSON 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.
  3. Verified edits were not the bottleneck on b. Both arms produced the identical three-line diff; the mcp arm's extra calls were diagnostics checks (useful, but they cost). add_port was not used: it appends a port, and the task wanted a specific position with the file's alignment.
  4. The rename missed what no engine sees, and said nothing (c). The rename tool renamed five sites and warned about the macro argument (the agent fixed it). It found the macro-rooted chip_if.sv path 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 broad rg found 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.
  5. What worked: every dry_run/diagnostics answer was trusted and correct; the macro-argument warning was acted on; the line-length lint finding on chip_if.sv was 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.

Round 2 — server at 4671b91 (feedback-1 applied)

Base arms are independent of the server, so rounds 2 and 3 re-run only the mcp arms; task c's base arm is re-run once for run-to-run variance.

task arm tokens tool calls wall outcome
a mcp 106 938 7 105 s incomplete, 35/47
b mcp 70 136 18 86 s correct, identical diff
c mcp 98 636 35 206 s correct, 8/8 sites
c base (re-run) 92 625 30 131 s correct, 8/8 sites

Observations

Completeness moved; tokens did not. The rename (c) is now complete — the unresolved-mentions list put the DV string path in front of the agent and it fixed it — at 99 k tokens against the base arm's 88–93 k (run-to-run variance on the base arm is about 6 %, so c is now a wash on tokens and a win on correctness). Task b is unchanged: an identical three-line diff either way, the mcp arm ~15 % dearer for its diagnostics checks. Task a regressed: the agent now reached for hierarchy up (7 calls, half the wall time) but paged the 77-row answer with a small limit and never read the trailing "… and 28 more" line — 35 of 47 instantiations reported as "complete and final". Two lessons:

  1. Put the total first. A paged answer must open with 77 instantiations (showing 1–50); a count at the bottom is invisible to an agent that stops reading when the table looks done. The default limit of 200 is also too low for a "list everything" question on a 4 000-file tree once DV and FPV rows are interleaved with RTL.
  2. Let the agent filter by path. All three census tasks wanted "under ip/, RTL only"; every mcp run spent turns dropping dv/, fpv/, ip_templates/ rows by hand. A path filter on the listing tools (in: "ip/**/rtl/*") would return exactly the rows asked for.

Changes for round 3 (lane "feedback-2"): (i) every paged answer opens with N <things> (showing a–b) and the cap moves to 500 by default; (ii) hierarchy, references, list_units, search_symbols and diagnostics take an optional in path glob (*, **, ?), applied to root-relative paths; (iii) the rename/add_port answers end with one line naming the files to check with diagnostics (the agents ran it anyway; saying so saves a decision). Round 3 also adds a fourth, understanding-heavy task (d: the instance tree of entropy_src to depth 3 with each leaf module's port count) where reading files is the expensive path, and repeats task c with Opus 5.5 on both arms once.