# mcp-feedback-3 Lane **feedback-3** of the MCP block, the last census lane: the changes the third token-census round asked for (`mcp_analysis.md`, Round 3 → Observations and "Still to do"). Tracked in `TODO-MCP.md` → "Feedback rounds". ## Goal Round 3's task d (the `entropy_src` instance tree with 20 port counts) came out at +4 % tokens with a third of the tool calls. Most of the server's overhead there was twenty `unit_interface` answers, each carrying a 30-line instantiation template the task never used. `hierarchy` lines had the same problem: every line carried the instance's `#( … )` overrides, which a census rarely reads. This lane makes both **opt-in**: `unit_interface` gains `template` and `hierarchy` gains `overrides`, both default false. The JSON of `hierarchy` keeps `overrides` on every node, because it costs little there. `unit_interface`'s section headers now carry their counts (`parameters (6):`, `ports (12):`), so a port count can be read without counting lines. ## Assumptions - **`unit_interface` without `template`** (or with `template: false`): the text is the head line, `parameters (N):` (if any), `ports (N):` (if any), `modports:` (if any), then the `warning:` lines. There is no `template:` section. The JSON has no `template` key at all (not `null`). **With `template: true`** the text ends with `template:` and the rendered plan, and the JSON has `template` as before. Otherwise the JSON is identical key for key (pinned by a wire test). The plan is still built either way: ports and parameters come from it. Only the `render` step is skipped. - **Packages and classes** take the `template` flag and ignore it: they have no template. The member answer is unchanged, and its `members:` header gets no count, because the brief named only ports and parameters. - **`modports:`** keeps its header without a count, for the same reason. - **`hierarchy` without `overrides`**: each line is exactly the old line without the ` #( … )` segment: `instance : module` (`down`), `parent.instance file:line` (`up`), and root lines as before. A note (`(recursive)`, `(not indexed)`, `(declared N times)`) still ends the line. **With `overrides: true`** the line is byte-identical to the old default, capped at `OVERRIDES_CAP` (200) as before. The JSON is the same with or without the flag: `overrides` is on every node (`null` where the site has none). - The brief wrote the `up` line as "`instance : module file:line`". The line has been `parent.instance file:line` since M2, and the brief also says "exactly as today minus the overrides". I kept today's shape. - **Census task a** asks for "both params on every row", so it now needs `overrides: true`. The `hierarchy` parameter description and `INSTRUCTIONS` both say so. A re-run of task a should be read with this in mind. ## Handshakes - **Consumed:** unchanged: `instantiation_plan` and `InstantiationPlan::render` (`vlog_refactor`), `Args::flag` (`tools/mod.rs`). - **Promised, changed (answer shapes):** - `unit_interface`'s default text no longer ends with `template:`, and its default JSON has no `template` key. Its headers read `parameters (N):` / `ports (N):`. A new optional boolean argument, `template`. - `hierarchy`'s default text lines drop the `#( … )` segment. There is a new optional boolean argument, `overrides`. The JSON is unchanged. - The resources (`lucisv://…`) do not call either tool; nothing else in the crate consumes these texts. - **Out-of-ownership edit (flagged for the lead's ruling):** `crates/lucisv_mcp/src/tools/edit.rs:30`. The shared `DRY_RUN` parameter description changed from "Return the diff only." to "Diff only.". The two new parameters took `tools/list` to 18 273 B. Trimming every description in this lane's files as far as it would go, without losing meaning, got it to 18 074 B, still over the 18 000 B pinned by `the_tool_catalogue_stays_under_18_kb` and `qa_the_catalogue_is_small_fully_described_and_spec_shaped`. `dry_run` appears 14 times, so this one edit saves 154 B. The catalogue is now **17 943 B**. The brief allowed "trim a description if needed" and did not say whose. To revert: restore the string and trim ~75 B elsewhere. - **Request (not done, outside ownership):** the Agents guide `docs/site/src/content/docs/guides/agents.md:102` still promises "a ready-to-paste instantiation" by default. Line 109 still shows `instance : module #(overrides)` lines. Both need "on `template: true`" / "on `overrides: true`". `docs/mcp/PLAN.md:146,263` describe the original design and can stay as history. ## Status / TODO - [x] `unit_interface`: `template` (Bool, default false); text and JSON without the template by default; `parameters (N):` / `ports (N):`; description names `template: true` - [x] `hierarchy`: `overrides` (Bool, default false) on the text line; JSON unchanged; description updated - [x] `INSTRUCTIONS`: the hierarchy clause names `overrides: true` (896 characters, unchanged length). `template: true` does not fit (940 with both); the `unit_interface` description carries it - [x] wire tests: both defaults and both opt-ins, text and JSON; existing pins moved to the opt-in (listed in the work log); catalogue ≤ 18 000 B - [x] measured on the eval clone (below) - [x] QA — PASS 2026-09-23 (see QA log) ## Work log **2026-09-23 (dev, Opus).** - `src/tools/interface.rs`: `UNIT_INTERFACE` gains the `template` param (l.36–41). The description is "A unit's parameters, ports (direction, type, range), modports or members; `template: true` adds an instantiation." The brief's "paste-ready" wording was trimmed for the catalogue budget. The handler reads `args.flag("template", false)` (l.67). `instantiable` takes `with_template` and renders the plan only then (l.144). `template` is added to the JSON only when present (l.156–157). `interface_text` takes `Option<&str>` and writes the counted headers (l.183, l.189) and the template section only on request (l.205). The module doc says the template is on request. - `src/tools/hierarchy.rs`: `HIERARCHY` gains the `overrides` param (l.81–86, "Add each `#(…)` to the text lines."). The description no longer lists overrides: "Who instantiates a module (`up`, with file:line) or what it instantiates (`down`, default). Textual." `render` reads the flag (l.341) and passes it to `Line::text`, which shows the overrides only then (l.394–400). The JSON's `Line::json` is untouched. Trimmed for the budget: `depth` → "Default 3." (the schema's `maximum: 20` says the rest), `in` → "Path glob on the instantiating file (`up`) or the module's (`down`), e.g. `ip/**/rtl/*.sv`.". - `src/rpc.rs` `INSTRUCTIONS`: "Who instantiates module X (instances, overrides): hierarchy with direction up, not references." → "Who instantiates module X: hierarchy direction up (overrides: true adds #(…)), not references." (896 → 896 characters). The old clause promised overrides in the default answer, which is no longer true. Adding `template: true` as well measured 940 characters, so it was left out. - `src/tools/mod.rs`: no change needed (`Ty::Bool` and `Args::flag` already existed). - `src/tools/edit.rs:30`: `DRY_RUN` description "Diff only." (see Handshakes: an out-of-ownership edit, flagged). - Tests (`tests/wire.rs`): - New: `unit_interface_template_is_opt_in`. It checks that the default text ends at the last port, the JSON has no `template` key, and `template: false` equals the default. With `template: true` the template section comes after the ports and the JSON equals the default plus `template`. It also covers an interface's template after its modports, the refusal of `"template": "yes"`, and a package ignoring the flag. - New: `hierarchy_overrides_are_opt_in_on_the_text_and_always_in_the_json`. It checks that `up` with `overrides: true` is byte-identical to the old default, the JSON is equal with and without the flag, `false` equals the default, and `down` and a recursive line work with the flag. It also covers the refusal of `"overrides": 1`. - Existing assertions changed (they pinned the old default output): - `wire.rs`: - `unit_interface_answers_ports_parameters_modports_and_members`: the header prefix now reads `parameters (2):` … `ports (4):`, and the template assertion now asserts that `template:` is absent. - `hierarchy_walks_down_and_up_and_terminates_on_recursion`: the three literals (tops, `tree`, `core` up) lose their overrides. The JSON node assertion still has `"overrides": "#( .W (8) )"`. - `qa_m1.rs`: - `qa_an_escaped_identifier_unit_is_listed_described_and_instantiable` now passes `template: true`. - `qa_a_typed_parameter_keeps_its_default_and_a_localparam_is_not_offered` now passes `template: true` (it reads `structuredContent.template`). - `qa_m2.rs`: - `qa_hierarchy_terminates_on_self_and_mutual_recursion`: the `selfm` call now passes `overrides: true`. - `qa_finding_4_every_instance_of_one_statement_shows_only_the_overrides`: the text `up` call now passes `overrides: true`. - `qa_recheck_overrides_split_across_lines_and_comments_between_instances`: both calls now pass `overrides: true`. - `opentitan.rs` (ignored without the checkout): the `top_earlgrey` call that asserts `u_aes : aes #(` now passes `overrides: true`. - **Measured** on the eval clone, read-only (`target/release/lucisv-mcp --root ~/.cache/lucisv-eval/ot/hw`, no `--index-cache`, so nothing is written; `git status --porcelain` in the clone was empty before and after). Bytes of `content[0].text` and of the compact `structuredContent`: | call | text B (lines) | JSON B | |---|---|---| | `unit_interface prim_fifo_sync` | **596** (21) | 1 284 | | … `template: true` | 999 (43) | 1 710 | | `hierarchy up prim_fifo_sync in ip/**/rtl/*.sv` (default depth 3) | **22 163** (349) | 102 939 | | … `overrides: true` | 64 783 (349) | 102 939 | | same, `depth: 1` (task a's 47 rows) | **3 238** (49) | — | | … `overrides: true` | 7 230 (49) | — | So `unit_interface` is −40 % by default (403 B saved per call; round 3's task d made 20 such calls; the saving grows with the port count), and the `hierarchy up` text is −66 % at depth 3 and −55 % at depth 1. The JSON of `hierarchy` does not change. `tools/list` is 17 943 B, down from 18 273 B with the two new parameters before the trims. Catalogue at c2e42b8: 17 993 B, per mcp-feedback-2. - Gates (through `tools/guard.sh`, one at a time): `cargo fmt --all` clean; `cargo clippy --all-targets` `Finished`, no warnings; `cargo test -p lucisv_mcp` 390 passed, 0 failed, 4 ignored (wire 55 → 57); `cargo test --workspace` **4 946 passed, 0 failed, 51 ignored**. - Production lines (non-blank, non-comment, before `mod tests`): `interface.rs` 334, `hierarchy.rs` 364, `mod.rs` 181, `rpc.rs` 265, `edit.rs` 288. ## QA log **2026-09-23 (QA) — verdict: PASS, no findings against the lane.** Read `CLAUDE.md`, this README, `git diff` of `src/tools/{interface,hierarchy,edit}.rs`, `src/rpc.rs` and `tests/{wire,qa_m1,qa_m2,opentitan}.rs`. - **Baseline binary, not a re-derivation.** HEAD (c2e42b8) was exported with `git archive HEAD` into the scratchpad (no worktree, repo untouched) and built there (`--target-dir` in the scratchpad), so "`template: true` / `overrides: true` equals the old default" was checked against the old binary's own bytes. `vlog_parser`, `vlog_refactor`, `vlog_formatter` and `vlog_semantic` have no diff since v0.56.0, so the template renderer is the 0.56.0 one; the 0.56.0 vsix `lucisv-mcp` agreed on every `unit_interface` too (its `hierarchy` predates feedback-2's count line, so only HEAD's is a valid hierarchy baseline). - **Differential, all six fixture trees** (`tests/fixtures/*`, every unit from `list_units`; every module `down` and `up` at depth 20): 50/50 `unit_interface` — `template: true` text = old text with only `parameters:`/`ports:` → `(N)`; JSON = old JSON key for key; default text = that text cut at `template:\n`; default JSON = old minus the `template` key (absent, not `null`); counts = rows = JSON array lengths; packages/classes identical with and without the flag. 78/78 `hierarchy` — `overrides: true` text byte-identical to the old text (refusals too), JSON identical across old/flag/default, no default line holds `#(`, every node has an `overrides` key. - **Same differential on the eval clone** (`~/.cache/lucisv-eval/ot/hw`, read-only, no `--index-cache`; `git status --porcelain` empty before and after): 12 units (`prim_fifo_sync`, `aes`, `entropy_src`, `top_earlgrey`, `uart`, `tl_if`, …, two declared-twice refusals identical) and 5 hierarchy calls (`top_earlgrey` depth 2, `prim_fifo_sync` up with `in`/depth 1, `aes` up, `entropy_src` depth 3): all equal. Default text (characters) is 17–45 % smaller for `unit_interface` (`tl_if` least, few ports) and 48–83 % for `hierarchy`. - **`tests/qa_f3.rs`** (new, 7 tests, all pass), pinned against literals the c2e42b8 binary produced on the same tree: 1. `template: true` byte-identical for an interface with modports, a module with `ifdef`'d lists (warnings, then the template), an empty module, multi-declarator/unpacked ports; JSON `template` = the old section; default ends before `template:` with no `template` key. 2. a `program` is instantiable (template on request); a package's answer is identical with `template: true`. 3. counts: `parameters (N):`/`ports (N):` = indented rows = JSON length for 5 shapes. **Zero parameters or zero ports: the header is absent, not `(0)`** — the pre-lane rule (an empty section is left out), and sensible: the JSON still has `[]`, and a `(0)` header would cost tokens to say nothing. `modports:` keeps no count; rows complete. 4. `hierarchy` `up` and `down` over an instance whose overrides exceed the 200-char cap, one without, one with a comment inside `#(…)`: `overrides: true` = old text (cap and `…` kept); default = each old line minus exactly ` ` of that node; JSON equal with/without flag, full uncapped overrides present. 5. default vs `overrides: true` under `limit`/`offset`, `in`, `depth: 1` and the no-root listing: same count line, same line count, same JSON, no `#(` in the default. 6. `"true"`, `1`, `[true]`, `{}` refused for both flags naming the field and "true or false"; `null` is taken as the default (as for every `Ty::Bool` flag — `Args::flag` uses `as_bool`); each flag is refused on the other tool as an unknown argument. 7. catalogue ≤ 18 000 B (measured **17 943 B**, 57 B headroom), both flags `boolean` and not required; `unit_interface`'s description names `` `template: true` ``, `hierarchy`'s no longer promises `#(`; `INSTRUCTIONS` **896 chars**, says `overrides: true`, dropped "(instances, overrides)", names only existing tools. - **Changed existing assertions** — every hunk read: `wire.rs` (header prefix gains the counts and `ports (4):`, the template assertion becomes its absence; three `hierarchy` literals lose exactly their `#(…)` segments, the JSON node assertion is unchanged), `qa_m1.rs` (2 calls add `template: true`), `qa_m2.rs` (4 calls add `overrides: true`, literals unchanged), `opentitan.rs` (1 call adds `overrides: true`). Each is a flag addition or a literal minus the overrides/template; nothing weakened. `opentitan_navigation_matches_the_language_server` run (`--ignored`, read-only over /Users/guoliangchen/repo/opentitan): ok, 83 s; checkout status unchanged. - **Out-of-ownership `edit.rs:30`** (`DRY_RUN` → "Diff only."): no test or consumer depends on the old string; meaning survives next to `dry_run: true shows the diff first` in `INSTRUCTIONS`. Left for the lead's ruling as flagged. - **Size/style:** production lines `interface.rs` 334, `hierarchy.rs` 364, `edit.rs` 288, `rpc.rs` 265; the changed functions (`instantiable`, `interface_text`, `render`, `Line::text`) are all under 50 lines. No `unwrap`/`expect` added to library code. - **Gates** (through `tools/guard.sh`, one at a time): `cargo fmt --all --check` clean; `cargo clippy --all-targets` `Finished`, no warnings; `cargo test -p lucisv_mcp` **397 passed, 0 failed, 4 ignored** (390 + 7); `cargo test --workspace` **4 953 passed, 0 failed, 51 ignored** (4 946 + 7). - **Not done here (lead's list):** the Agents guide request in Handshakes; the census re-measure of tasks a/d. ## Review **Lead, 2026-09-23 (feedback-3).** The last census lesson was answer weight: twenty `unit_interface` answers each carrying a template the task never used. Both the template and the hierarchy overrides are now opt-in, the ports and parameters headers carry their counts, and QA proved the opt-in text byte-identical to the old output over every fixture and the opentitan clone. The `dry_run` wording trim in `edit.rs` is accepted. The Agents guide's tool table was regenerated from the binary by the lead. Committed; the release binary is this one.