From 74c56318c08f61e1ceb6ab8a2987af32fe3c5361 Mon Sep 17 00:00:00 2001 From: Guoliang Chen Date: Tue, 29 Sep 2026 01:38:54 -0700 Subject: [PATCH] MCP: hierarchy caps at 300 instances (100 with peek), peek lines no longer count; census round 5 (read-only, same-day base control) written up; 0.59.0 notes dated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Round 5 found `hierarchy up` + `peek` cut to 20 of 77 instantiations by the 300-line cap. Same-day base controls put read-only mode at parity with file tools (a +8 %, d −8 %) and show the base arm itself moved 22–29 % in six days. Co-Authored-By: Claude Fable 5.1 --- CHANGELOG.md | 6 +- crates/lucisv_mcp/src/tools/hierarchy.rs | 27 ++-- crates/lucisv_mcp/tests/hierarchy_cap.rs | 137 +++++++++++++++++++++ crates/lucisv_mcp/tests/qa_m7.rs | 8 +- crates/lucisv_mcp/tests/qa_m8.rs | 135 ++++++++++++++++++++ docs/features/mcp-lean-catalogue/README.md | 32 ++++- docs/features/mcp-read-only/README.md | 71 +++++++++++ docs/mcp/PLAN.md | 2 +- docs/mcp/census-runs.txt | 9 ++ editors/vscode/CHANGELOG.md | 2 +- editors/vscode/README.md | 10 +- mcp_analysis.md | 67 ++++++++++ 12 files changed, 488 insertions(+), 18 deletions(-) create mode 100644 crates/lucisv_mcp/tests/hierarchy_cap.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index b306b8f..420fa31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to lucisv are recorded here. Versions follow [semantic versioning](https://semver.org/); until 1.0 the CLI's exit codes (see `README.md`) are the only frozen contract. -## 0.59.0 — unreleased +## 0.59.0 — 2026-09-29 ### MCP read-only mode @@ -38,6 +38,10 @@ PLAN §11, the owner's request of 2026-09-29: one binary, two modes. tools, one `hierarchy`, `rename` refused, files untouched); `tools/release.sh` runs both smokes on the host binary and on the one embedded in the package. +- `hierarchy` caps at 300 instances, 100 with `peek`; `peek` lines no + longer count toward the cap (census round 5: `prim_fifo_sync` up with + peek showed 20 of 77 instantiations). Without `peek` the answer is + unchanged. ## 0.58.0 — 2026-09-24 diff --git a/crates/lucisv_mcp/src/tools/hierarchy.rs b/crates/lucisv_mcp/src/tools/hierarchy.rs index fd197d0..b0be46b 100644 --- a/crates/lucisv_mcp/src/tools/hierarchy.rs +++ b/crates/lucisv_mcp/src/tools/hierarchy.rs @@ -32,9 +32,16 @@ const MAX_DEPTH: i64 = 20; /// The most nodes one walk collects before it stops. const NODE_CAP: usize = 50_000; -/// The most lines an answer holds before `… and N more`. +/// The most lines the overview holds, and the most nodes (tree lines, the +/// root's included) a tree answer without `peek` shows, before +/// `… and N more`. const CAP: usize = 300; +/// The most nodes a tree answer with `peek` shows. A node's `peek` lines +/// never count — the cap is on instances — but each costs up to 13 lines, +/// so the answer stays short (PLAN §10.1). +const PEEK_CAP: usize = 100; + /// The most source lines `peek` shows of one statement before `…`. const PEEK_LINES: usize = 12; @@ -271,14 +278,21 @@ impl<'a> Walk<'a> { } /// The nodes as lines, two spaces per level (`up` starts at no indent), -/// each followed by its statement on `peek`; cut whole nodes at [`CAP`]. +/// each followed by its statement on `peek`; at most [`CAP`] nodes +/// ([`PEEK_CAP`] with `peek`), then `… and N more` counting the nodes not +/// shown. fn render_nodes(project: &Project, nodes: &[Node], up: bool, peek: bool) -> Vec { let mut texts = Texts::default(); let mut lines: Vec = Vec::new(); + let cap = if peek { PEEK_CAP } else { CAP }; for (at, node) in nodes.iter().enumerate() { + if at == cap { + lines.push(render::more(nodes.len() - at)); + return lines; + } let level = if up { node.depth - 1 } else { node.depth }; let indent = " ".repeat(level); - let mut block = vec![format!("{indent}{}", node_line(project, &mut texts, node, up))]; + lines.push(format!("{indent}{}", node_line(project, &mut texts, node, up))); if let (true, Some(child)) = (peek, &node.instance) { let source = statement(project, &mut texts, child); // A blank line of the statement stays blank: no indent of ours. @@ -286,13 +300,8 @@ fn render_nodes(project: &Project, nodes: &[Node], up: bool, peek: bool) -> Vec< true => line, false => format!("{indent} {line}"), }; - block.extend(source.into_iter().map(shown)); + lines.extend(source.into_iter().map(shown)); } - if lines.len() + block.len() > CAP { - lines.push(render::more(nodes.len() - at)); - return lines; - } - lines.extend(block); } lines } diff --git a/crates/lucisv_mcp/tests/hierarchy_cap.rs b/crates/lucisv_mcp/tests/hierarchy_cap.rs new file mode 100644 index 0000000..51034b9 --- /dev/null +++ b/crates/lucisv_mcp/tests/hierarchy_cap.rs @@ -0,0 +1,137 @@ +//! The `hierarchy` cap counts instances, never `peek` lines (census round 5, +//! 2026-09-29): an agent asking for every instantiation of a module with +//! `peek` gets every one up to 100 (300 without `peek`), each with its +//! statement, not a quarter of them. Each test writes a generated design into a scratch directory and +//! talks to the real binary over it. + +use std::fs; +use std::io::Write; +use std::path::PathBuf; +use std::process::{Command, Stdio}; +use std::sync::atomic::{AtomicUsize, Ordering}; + +use serde_json::{json, Value}; + +static NEXT_DIR: AtomicUsize = AtomicUsize::new(0); + +/// A scratch design, removed on drop. +struct Tree(PathBuf); + +impl Tree { + fn with(files: &[(&str, String)]) -> Tree { + let unique = NEXT_DIR.fetch_add(1, Ordering::SeqCst); + let dir = std::env::temp_dir() + .join(format!("lucisv-mcp-hierarchy-cap-{}-{unique}", std::process::id())); + let _ = fs::remove_dir_all(&dir); + fs::create_dir_all(&dir).unwrap(); + for (rel, text) in files { + fs::write(dir.join(rel), text).unwrap(); + } + Tree(fs::canonicalize(dir).unwrap()) + } +} + +impl Drop for Tree { + fn drop(&mut self) { + let _ = fs::remove_dir_all(&self.0); + } +} + +/// One `hierarchy` call over `tree` that must succeed: its text. +fn hierarchy(tree: &Tree, arguments: Value) -> String { + let mut child = Command::new(env!("CARGO_BIN_EXE_lucisv-mcp")) + .args(["--root", tree.0.to_str().unwrap()]) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::null()) + .spawn() + .unwrap(); + let init = json!({"jsonrpc": "2.0", "id": 0, "method": "initialize", "params": { + "protocolVersion": "2025-06-18", "capabilities": {}, + "clientInfo": {"name": "hierarchy_cap", "version": "0"}}}); + let params = json!({"name": "hierarchy", "arguments": arguments}); + let call = json!({"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": params}); + let mut stdin = child.stdin.take().unwrap(); + stdin.write_all(format!("{init}\n{call}\n").as_bytes()).unwrap(); + drop(stdin); + let output = child.wait_with_output().unwrap(); + let stdout = String::from_utf8(output.stdout).unwrap(); + let reply: Value = stdout + .lines() + .map(|line| serde_json::from_str::(line).unwrap()) + .find(|reply| reply["id"] == 1) + .expect("the call is answered"); + assert_eq!(reply["result"]["isError"], false, "{reply}"); + reply["result"]["content"][0]["text"].as_str().unwrap().to_string() +} + +/// `count` instantiations of `sub` in `top`, each written over `ports + 2` +/// lines: the header, one line per port, the closer. +fn crowded(count: usize, ports: usize) -> Tree { + let names: Vec = (0..ports).map(|p| format!("p{p}")).collect(); + let declared: Vec = names.iter().map(|n| format!("input logic {n}")).collect(); + let sub = format!("module sub #(parameter int W = 1) ({});\nendmodule\n", declared.join(", ")); + let mut top = format!("module top;\n logic {};\n", names.join(", ")); + for i in 0..count { + top.push_str(&format!(" sub #(.W({i})) u_{i:03} (\n")); + for (at, name) in names.iter().enumerate() { + let comma = if at + 1 < names.len() { "," } else { "" }; + top.push_str(&format!(" .{name}({name}){comma}\n")); + } + top.push_str(" );\n"); + } + top.push_str("endmodule\n"); + Tree::with(&[("sub.sv", sub), ("top.sv", top)]) +} + +/// The tree lines of an answer: every line that is not a peeked statement. +fn node_lines(text: &str, statement_indent: &str) -> Vec { + text.lines().filter(|l| !l.starts_with(statement_indent)).map(str::to_string).collect() +} + +#[test] +fn up_with_peek_lists_every_instantiation_whatever_the_statements_cost() { + // 30 instantiations of 14 lines each: peek shows 12 lines and `…` per + // statement, 420 lines in all — every one is still there. + let tree = crowded(30, 12); + let text = hierarchy(&tree, json!({"root": "sub", "up": true, "peek": true})); + let nodes = node_lines(&text, " "); + let expected: Vec = + (0..30).map(|i| format!("top.u_{i:03} top.sv:{}", 3 + i * 14)).collect(); + assert_eq!(nodes, expected, "{text}"); + assert!(!text.contains("… and "), "{text}"); + assert_eq!(text.lines().count(), 30 * 14); + // Each statement: its first 12 lines as written, then `…`. + let first: Vec<&str> = text.lines().skip(1).take(13).collect(); + assert_eq!(first[0], " sub #(.W(0)) u_000 ("); + assert_eq!(first[11], " .p10(p10),"); + assert_eq!(first[12], " …"); +} + +#[test] +fn over_100_instances_with_peek_shows_100_and_over_300_without_shows_300() { + let tree = crowded(350, 1); + // Up with peek: 350 instantiations, 100 shown, each with its 3-line statement. + let up = hierarchy(&tree, json!({"root": "sub", "up": true, "peek": true})); + let lines: Vec<&str> = up.lines().collect(); + assert_eq!(lines.len(), 100 * 4 + 1, "{up}"); + assert_eq!(*lines.last().unwrap(), "… and 250 more"); + let nodes = node_lines(&up, " "); + assert_eq!(nodes.len(), 101); + assert_eq!(nodes[99], "top.u_099 top.sv:300"); + assert_eq!(lines[lines.len() - 2], " );", "the last statement is whole"); + // Down with peek: the root line and 99 instances make 100 nodes; 251 are left. + let down = hierarchy(&tree, json!({"root": "top", "peek": true})); + let nodes = node_lines(&down, " "); + assert_eq!(nodes.len(), 101, "{down}"); + assert_eq!(nodes[0], "top top.sv:1"); + assert_eq!(nodes[99], " u_098: sub top.sv:297"); + assert_eq!(nodes[100], "… and 251 more"); + // Without peek: 300 lines, then the count. + let plain = hierarchy(&tree, json!({"root": "sub", "up": true})); + assert_eq!(plain.lines().count(), 301); + assert!(plain.ends_with("\n… and 50 more\n"), "{plain}"); + let plain = hierarchy(&tree, json!({"root": "top"})); + assert_eq!(plain.lines().count(), 301); + assert!(plain.ends_with("\n… and 51 more\n"), "{plain}"); +} diff --git a/crates/lucisv_mcp/tests/qa_m7.rs b/crates/lucisv_mcp/tests/qa_m7.rs index ab49bf6..939f9f1 100644 --- a/crates/lucisv_mcp/tests/qa_m7.rs +++ b/crates/lucisv_mcp/tests/qa_m7.rs @@ -197,7 +197,7 @@ fn qa_every_cap_cuts_once_with_the_right_count_and_whole_lines() { let expected = [ (300, 101), // the root line + 400 instances (300, 100), // 400 instantiations - (299, 251), // root + 149 two-line blocks; the 150th block would pass 300 + (199, 301), // root + 99 two-line blocks: with peek the cap is 100 nodes (300, 23), // counts line + 322 tops (300, 20), // 320 declarations (300, 51), // file:line + 350 ports @@ -220,9 +220,11 @@ fn qa_every_cap_cuts_once_with_the_right_count_and_whole_lines() { assert_eq!(file, "rtl/big.sv"); number.parse::().unwrap(); } - // A peek block is never split: the last shown line is a statement. + // A peek block is never split: the last shown line is the 99th + // instance's statement. let peek: Vec<&str> = said[2].text.lines().collect(); - assert_eq!(peek[298], " leaf u_148 (.a(a));"); + assert_eq!(peek[197], " u_098: leaf rtl/big.sv:101"); + assert_eq!(peek[198], " leaf u_098 (.a(a));"); for line in said[7].text.lines().take(200) { assert!(line.starts_with("rtl/wide.sv:") && line.ends_with("[unused-signal]"), "{line}"); } diff --git a/crates/lucisv_mcp/tests/qa_m8.rs b/crates/lucisv_mcp/tests/qa_m8.rs index 41a4081..a3b23e4 100644 --- a/crates/lucisv_mcp/tests/qa_m8.rs +++ b/crates/lucisv_mcp/tests/qa_m8.rs @@ -420,3 +420,138 @@ fn qa_a_read_only_index_cache_outside_the_root_leaves_the_root_alone() { assert_eq!(before, snapshot(&tree)); assert!(cache.join(".gitignore").exists(), "the store directory was written"); } + +// --------------------------------------------------------------------------- +// Re-check 2026-09-29: `hierarchy`'s cap counts nodes, never peek lines. +// --------------------------------------------------------------------------- + +/// `module name` with `count` instances of `child`, each written over 14 +/// lines (header, 12 port lines, closer), so each peek block is cut to 12 +/// lines and `…` — 14 answer lines per node. +fn wide_parent(name: &str, child: &str, count: usize) -> (String, String) { + let mut text = format!("module {name};\n"); + for i in 0..count { + text.push_str(&format!(" {child} u_{i:03} (\n")); + for p in 0..12 { + let comma = if p < 11 { "," } else { "" }; + text.push_str(&format!(" .p{p}(1'b0){comma}\n")); + } + text.push_str(" );\n"); + } + text.push_str("endmodule\n"); + (format!("{name}.sv"), text) +} + +/// A 12-input leaf module. +fn leaf(name: &str) -> (String, String) { + let ports: Vec = (0..12).map(|p| format!("input logic p{p}")).collect(); + (format!("{name}.sv"), format!("module {name} ({});\nendmodule\n", ports.join(", "))) +} + +/// `dN` declares N instances (N + 1 nodes with its root line); `uN` is +/// instantiated N times (N nodes up). Sizes sit on both caps' boundaries: +/// 300/301 nodes without `peek`, 100/101 with it. +fn boundary_tree() -> Tree { + let tree = Tree::empty(); + let files = [ + leaf("x"), + leaf("y"), + leaf("u100"), + leaf("u101"), + leaf("u300"), + leaf("u301"), + wide_parent("d99", "x", 99), + wide_parent("d100", "y", 100), + wide_parent("d299", "x", 299), + wide_parent("d300", "y", 300), + wide_parent("h100", "u100", 100), + wide_parent("h101", "u101", 101), + wide_parent("h300", "u300", 300), + wide_parent("h301", "u301", 301), + ]; + for (path, text) in files { + fs::write(tree.0.join(path), text).unwrap(); + } + tree +} + +/// Each call's text, in order, from one session in `mode_args`. +fn hierarchy_texts(tree: &Tree, calls: &[Value], mode_args: &[&str]) -> Vec { + let mut args = vec!["--root", tree.arg()]; + args.extend_from_slice(mode_args); + let mut lines = vec![initialize("i")]; + lines.extend( + calls + .iter() + .enumerate() + .map(|(n, a)| call(&format!("h{n}"), json!("hierarchy"), a.clone())), + ); + let answers = answers(&run(&args, &lines)); + (0..calls.len()) + .map(|n| { + let reply = &answers[&format!("\"h{n}\"")]; + assert_eq!(reply["result"]["isError"], false, "{reply}"); + reply["result"]["content"][0]["text"].as_str().unwrap().to_string() + }) + .collect() +} + +/// The node cap without `peek` (PLAN §10.1). +const PLAIN_CAP: usize = 300; +/// The node cap with `peek` (M8 rework 3). +const PEEK_CAP: usize = 100; + +#[test] +fn qa_the_node_cap_is_exact_at_300_and_301_plain_and_100_and_101_with_peek() { + let tree = boundary_tree(); + // (arguments, nodes in the whole answer, statement indent) + let cases = [ + (json!({"root": "d99"}), 100, " "), + (json!({"root": "d100"}), 101, " "), + (json!({"root": "d299"}), 300, " "), + (json!({"root": "d300"}), 301, " "), + (json!({"root": "u100", "up": true}), 100, " "), + (json!({"root": "u101", "up": true}), 101, " "), + (json!({"root": "u300", "up": true}), 300, " "), + (json!({"root": "u301", "up": true}), 301, " "), + ]; + let mut calls = Vec::new(); + for (arguments, _, _) in &cases { + calls.push(arguments.clone()); + let mut peeked = arguments.clone(); + peeked["peek"] = json!(true); + calls.push(peeked); + } + let full = hierarchy_texts(&tree, &calls, &[]); + assert_eq!(full, hierarchy_texts(&tree, &calls, &["--read-only"]), "the modes disagree"); + for (at, (arguments, total, indent)) in cases.iter().enumerate() { + let root_lines = usize::from(arguments["up"] != true); + let cut_line = |cap: usize| (*total > cap).then(|| format!("… and {} more", total - cap)); + // Without peek: one line per node, at most 300, then the cut line. + let plain: Vec<&str> = full[2 * at].lines().collect(); + let (plain_shown, plain_cut) = ((*total).min(PLAIN_CAP), cut_line(PLAIN_CAP)); + assert_eq!(plain.len(), plain_shown + usize::from(plain_cut.is_some()), "{arguments}"); + if let Some(cut) = &plain_cut { + assert_eq!(plain.last().copied(), Some(cut.as_str()), "{arguments}"); + } + // With peek: the first 100 of the same node lines, then its own cut line. + let peek: Vec<&str> = full[2 * at + 1].lines().collect(); + let (shown, cut) = ((*total).min(PEEK_CAP), cut_line(PEEK_CAP)); + let nodes: Vec<&str> = peek.iter().copied().filter(|l| !l.starts_with(indent)).collect(); + let mut expected: Vec<&str> = plain[..shown].to_vec(); + if let Some(cut) = &cut { + expected.push(cut.as_str()); + } + assert_eq!(nodes, expected, "{arguments}"); + // Every instance node is followed by a whole block: 12 lines, then `…`. + let instances = shown - root_lines; + let cut_lines = usize::from(cut.is_some()); + assert_eq!(peek.len(), root_lines + instances * 14 + cut_lines, "{arguments}"); + let blocks = peek.iter().filter(|l| l.trim() == "…").count(); + assert_eq!(blocks, instances, "{arguments}"); + if cut.is_some() { + // The block before the cut line is whole: it ends in `…`. + assert_eq!(peek[peek.len() - 2].trim(), "…", "{arguments}"); + } + } +} diff --git a/docs/features/mcp-lean-catalogue/README.md b/docs/features/mcp-lean-catalogue/README.md index 036cbb5..8c756ab 100644 --- a/docs/features/mcp-lean-catalogue/README.md +++ b/docs/features/mcp-lean-catalogue/README.md @@ -76,8 +76,10 @@ Decisions where PLAN §10 is silent (the simplest thing, recorded): 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 +- The cap is 300 nodes (instance lines, a root line included) without + `peek` and 100 nodes with it, down and up alike; `peek` lines never count + toward it, and a peek block is never split. `… and N more` counts the nodes not shown. (Was a 300-*line* cap + until 2026-09-29, which with `peek` showed as few as 23 instances.) 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. @@ -348,6 +350,32 @@ for `down`. `verify.rs` lost its dead forced path. exact; the pinned test stays ignored with its reason. **R3:** no change. - Catalogue 3 440 bytes, instructions 398 (unchanged). +### 2026-09-29 — dev (M8 rework 2: the hierarchy cap counts instances) + +- Census round 5 found `hierarchy {"root":"prim_fifo_sync","up":true, + "peek":true}` on the OpenTitan clone cut to 20 of 77 instantiations by + the 300-line cap. Lead ruling: the cap counts nodes, never peek lines. + `hierarchy.rs` `render_nodes` now stops at the 300th node; without + `peek` the answer is byte-identical (one line per node). `qa_m7.rs`'s + caps test updated (root + 400 with peek: 599 lines shown, `… and 101 + more`); new `tests/hierarchy_cap.rs` (30 fourteen-line instantiations, + up + peek: all 30; 350 instantiations with peek: 300 shown, `… and 50 + more` up, `… and 51 more` down). Descriptions and byte budgets unchanged. + PLAN §10.1's row amended. + +### 2026-09-29 — dev (M8 rework 3: 100 instances with peek) + +- QA finding 6 (M8): with the node cap alone a peeked answer reached + 150 kB (`top_earlgrey` depth 3, 3 759 lines). Lead ruling: 300 nodes + without `peek`, 100 with it (`CAP`, `PEEK_CAP` in `hierarchy.rs`); + everything else from rework 2 stands. Tests: `hierarchy_cap.rs` (350 + instantiations with peek: 100 shown, `… and 250 more` up, `… and 251 + more` down; without peek 300 and 50/51), `qa_m7.rs` caps test (root + + 400 with peek: 199 lines, then `… and 301 more`), QA's + `qa_m8.rs` boundary test renamed + `qa_the_node_cap_is_exact_at_300_and_301_plain_and_100_and_101_with_peek` + with 100/101-node fixtures added. PLAN §10.1's row amended again. + ## QA log ### 2026-09-24 — QA (M7) diff --git a/docs/features/mcp-read-only/README.md b/docs/features/mcp-read-only/README.md index 962333a..82cae8a 100644 --- a/docs/features/mcp-read-only/README.md +++ b/docs/features/mcp-read-only/README.md @@ -154,6 +154,22 @@ Where §11 is silent, the simplest thing, recorded: - No Rust changed. `node --test editors/vscode/*_test.js` 6/6; both smokes OK against `target/release/lucisv-mcp`. +### 2026-09-29 — dev (Opus), rework 2 + +- The `hierarchy` cap now counts instances, not peek lines (census round + 5 finding on `prim_fifo_sync` up + peek). The change and its tests are + logged in `docs/features/mcp-lean-catalogue/README.md` (work log, + 2026-09-29); tool descriptions and both modes' byte figures unchanged. + +### 2026-09-29 — dev (Opus), rework 3 + +- QA finding 6: the `hierarchy` cap is 300 instances without `peek`, 100 + with it (lead ruling). Logged in the M7 README (work log, rework 3). + QA's boundary test in `qa_m8.rs` is renamed + `qa_the_node_cap_is_exact_at_300_and_301_plain_and_100_and_101_with_peek` + (the QA log below still names it by its old name). Descriptions and both + modes' byte figures unchanged. + ## QA log ### 2026-09-29 — QA (Opus) @@ -272,6 +288,61 @@ Findings, by severity: Tests added: `crates/lucisv_mcp/tests/qa_m8.rs` (5 tests, all green). +### 2026-09-29 — QA (Opus), re-check: `hierarchy` cap counts nodes + +Rework under test: `tools/hierarchy.rs` `render_nodes` caps at 300 nodes +(the down root line included), peek lines never count. **Verdict: PASS with +one finding.** + +- **No-peek identity with b757e82** (`lucisv-mcp-r6` vs a fresh release + build): 43 calls on `fixtures/design` and 85 on `fixtures/edit` (every + unit down / down depth 20 / up / up depth 20, with and without peek) — + 0 differ. Eval clone, 9 calls — `top_earlgrey` depth 2 (50 lines) and + depth 3 (`… and 165 more`), `prim_fifo_sync` up (77) and up depth 3 + (`… and 1421 more`), `top_darjeeling` depth 3 (`… and 174 more`), + `prim_flop` up (`… and 176 more`) and up depth 4 (`… and 45166 more`), + `uart` depth 20, the overview (`… and 69 more`) — byte-identical, and + identical again under `--read-only`. +- **`prim_fifo_sync` up + peek** (eval clone): 1 078 lines, no cut. Its + lines that are neither statement lines (4-space indent) nor blank are + exactly the 77 lines of the no-peek answer, in order; every node is + followed by at least one statement line; no block exceeds 12 lines + `…` + (69 blocks end in `…`). r6 gave 21 of them then `… and 56 more`. +- **`qa_m7.rs` diff vs HEAD:** one expected tuple `(299, 251)` → `(599, + 101)` (root + 299 two-line blocks, 401 − 300 = 101 — what the rule + requires) and the peek assertion now pins *two* lines (`peek[597]` the + 299th instance's node line, `peek[598]` its statement) where it pinned + one; no other assertion touched. +- **Boundaries** (`qa_m8.rs` + `qa_the_node_cap_is_exact_at_300_and_301_down_and_up_with_and_without_peek`, + 14-line statements so every block is cut to 12 + `…`): down 299 + instances (300 nodes) → 300 lines, no cut; down 300 → root + 299 and + `… and 1 more`; up 300 → 300, no cut; up 301 → 300 and `… and 1 more`. + With peek: the same node lines and cut line in the same order, exactly + 14 lines per instance node, the line before the cut is the last block's + `…` (never split). The down count counts the root as a node consistently: + 401 nodes → `… and 101 more` = the 101 instances not shown. +- **Modes:** every text above is identical in full and `--read-only` mode + (asserted in the test, and on the eval clone with and without peek). +- **Gates:** `cargo test -p lucisv_mcp` 16 suites, 381 passed, 0 failed, 4 + ignored (guard exit 0, no `guard.sh:` line); clippy `-p lucisv_mcp + --all-targets -D warnings` clean. Eval clone `git status` empty. + +Finding: + +6. **Medium (answer size, design consequence).** A peeked answer is no + longer bounded by ~300 lines but by 300 × 14 lines. Repro on the eval + clone: `hierarchy {"root":"top_earlgrey","depth":3,"peek":true}` → 3 759 + lines, 151 224 bytes (r6: 295 lines, 10 152 bytes); + `{"root":"prim_fifo_sync","up":true,"depth":3,"peek":true}` → 4 154 + lines, 152 356 bytes (r6: 10 457); `prim_flop` up peek → 2 984 lines, + 89 972 bytes. That is roughly 40 k tokens in one answer, against the + lean catalogue's short-answer goal (PLAN §10). The fix the brief asked for + (77 of 77) needs only ~31 KB; whether a byte ceiling on peek belongs + beside the node cap is the lead's call. Not changed. + +Tests added: `qa_m8.rs` `qa_the_node_cap_is_exact_at_300_and_301_down_and_up_with_and_without_peek`. + ## Review 2026-09-29 (lead). Examined the diff, the registry filter, the QA log and diff --git a/docs/mcp/PLAN.md b/docs/mcp/PLAN.md index cfe9128..a09fcf0 100644 --- a/docs/mcp/PLAN.md +++ b/docs/mcp/PLAN.md @@ -504,7 +504,7 @@ its text. The `annotations` stay (`readOnlyHint`, `destructiveHint: false`) | tool | arguments | answers | |---|---|---| -| `hierarchy` | `root?`, `up?` (bool), `depth?` (1–20, default 1), `peek?` (bool) | Without `root`: one line `N files, M modules, K top` then the top modules as `name file:line`. With `root`, down: the instance tree, one line per instance, two spaces per level: `instance: module file:line` where `file:line` is the **instantiation site**. `up`: every instantiation of `root`, `parent.instance file:line`, all levels up to `depth`. `peek: true` appends each instantiation statement's source under its line (indented, as written, at most 12 lines each then `…`). Cap 300 lines then `… and N more`. Unknown `root`: a refusal that lists up to 10 contains-matches. | +| `hierarchy` | `root?`, `up?` (bool), `depth?` (1–20, default 1), `peek?` (bool) | Without `root`: one line `N files, M modules, K top` then the top modules as `name file:line`. With `root`, down: the instance tree, one line per instance, two spaces per level: `instance: module file:line` where `file:line` is the **instantiation site**. `up`: every instantiation of `root`, `parent.instance file:line`, all levels up to `depth`. `peek: true` appends each instantiation statement's source under its line (indented, as written, at most 12 lines each then `…`). Cap 300 instances, 100 with `peek`; peek lines do not count; then `… and N more`. Unknown `root`: a refusal that lists up to 10 contains-matches. | | `find` | `name`, `refs?` (bool) | Every declaration of `name` (whole-name, any case-exact): `kind name file:line`, then, with `refs`, per declaration its uses as `file:line` (one file per line, lines joined with `,` when several are in one file: `ip/uart/rtl/uart.sv:120,133,140`), then `unresolved:` and the textual mentions (strings, comments, macro text) the same way. No declaration: up to 20 contains-matches of declarations as a refusal (`no declaration named X; similar: …`). Cap 300 lines. | | `outline` | `file?` **or** `unit?` (exactly one) | `file`: its declarations as a tree with line ranges, two spaces per level: `kind name start–end`, parse errors first as `error line: message`. `unit`: its `file:line`, then parameters `param name = default` and ports `dir type[range] name` in declaration order, one per line; interfaces add modports, packages their exports. No template, no counts. Cap 300 lines. | | `read` | `item`, `file?` | The item's source, exact bytes, preceded by one line `file:start–end`. Selector as today's `read_item` (`name`, `kind:name`, `name@LINE`, `always@LINE`). Without `file` the item is looked up design-wide; several matches → a refusal listing them as `file:line`. | diff --git a/docs/mcp/census-runs.txt b/docs/mcp/census-runs.txt index 7ce1975..f4c11cd 100644 --- a/docs/mcp/census-runs.txt +++ b/docs/mcp/census-runs.txt @@ -25,3 +25,12 @@ r4 d mcp sonnet tokens=104897 calls=22 wall=278s outcome=correct 71/20, all coun r4 c mcp sonnet tokens=101137 calls=45 wall=403s outcome=correct 8/8 sites in 4 files (rename wrote 2 files + listed the macro arg, chip_if path and the DV string path as unresolved; agent fixed those by hand); +16% vs r1 base, +9% vs r2 base rerun; agent lost time waiting on its own background rename (interim stop, nudged) r4 d mcp sonnet (re-run) tokens=99525 calls=24 wall=302s outcome=correct 71/20, all counts; mean of the two r4 runs 102 211 vs base 102 579 r4 c mcp OPUS: tokens=68948 tool_calls=10 wall_s=214 outcome=correct 8/8 in 4 files (−1% vs r3 Opus mcp, +13% vs r3 Opus base) + +# Round 5 — server b757e82 (M8 read-only mode, bin/lucisv-mcp-r6 --read-only, shim mcpc6ro, prompt_mcp_r5_ro.txt) +r5 a read-only sonnet tokens=67230 calls=7 wall=41s outcome=correct 47/47 table, all values (prose first said 55 then corrected itself to 47); hierarchy up hit the 300-line cap (… and 56 more), agent fell back to grep over hw/ip +r5 d read-only sonnet tokens=80487 calls=10 wall=121s outcome=correct 71/20, all counts (same content as the graded r4 answer); hierarchy depth 1 + outline unit per module +r5 a read-only sonnet (re-run) tokens=72361 calls=7 wall=56s outcome=correct 47/47 (same table); hierarchy up truncated again, agent scanned the RTL sources; mean of the two r5 runs 69 796 vs base 91 094 +r5 d read-only sonnet (re-run) tokens=67104 calls=8 wall=151s outcome=correct 71/20, all counts; mean of the two r5 runs 73 796 vs base 102 579 +r5 a BASE control sonnet (same day, 2026-09-29) tokens=64817 calls=3 wall=40s outcome=correct 47/47 — the base arm is 29% cheaper than on 2026-09-23 (91 094): the sub-agent environment changed; earlier rounds are not comparable with round 5 +r5 d BASE control sonnet (same day) tokens=80194 calls=10 wall=78s outcome=correct 71/20, all counts (2026-09-23 base was 102 579) +r5b a read-only sonnet (cap fix, bin r7) tokens=72247 calls=8 wall=50s outcome=correct 47/47; hierarchy up+peek now complete (77 instantiations, 31 kB); agent still cross-checked with grep; +11% vs same-day base 64 817 diff --git a/editors/vscode/CHANGELOG.md b/editors/vscode/CHANGELOG.md index 0e1dcc7..de8fa36 100644 --- a/editors/vscode/CHANGELOG.md +++ b/editors/vscode/CHANGELOG.md @@ -5,7 +5,7 @@ for you. The extension and its bundled language server share one version number; the full engineering notes live in the [project changelog](https://git.luci.ooo/lucio/lucisv/src/branch/master/CHANGELOG.md). -## Unreleased (0.59.0) +## 0.59.0 — 2026-09-29 - New setting `lucisv.mcp.mode`: `"read-only"` offers agent mode a `lucisv read-only ()` server with only the five read tools — diff --git a/editors/vscode/README.md b/editors/vscode/README.md index 85d27a8..0104067 100644 --- a/editors/vscode/README.md +++ b/editors/vscode/README.md @@ -30,7 +30,7 @@ Install **lucisv — Verilog/SystemVerilog** from the VS Code Extensions view, then open a Verilog or SystemVerilog file. There is no separate server or CLI setup. -The current release is **0.58.0**. Its platform packages include +The current release is **0.59.0**. Its platform packages include `lucisv-server`, the `lucisv` command-line tool and `lucisv-mcp` (see [Agents (MCP)](#agents-mcp)): @@ -404,6 +404,14 @@ Every nesting color is a proper VS Code theme color: } ``` +## Release 0.59.0 highlights + +Version 0.59.0 adds a read-only mode to `lucisv-mcp`: with +`lucisv.mcp.mode` set to `read-only` (or `--read-only` on the command +line) the agent sees five tools — hierarchy, find, outline, read, check — +in under 1.8 kB, and the server never writes inside the project. The full +nine-tool mode is unchanged and stays the default. + ## Release 0.58.0 highlights Version 0.58.0 slims `lucisv-mcp` to nine tools whose whole catalogue is diff --git a/mcp_analysis.md b/mcp_analysis.md index 5cf57fa..5fcd480 100644 --- a/mcp_analysis.md +++ b/mcp_analysis.md @@ -303,6 +303,63 @@ nothing where the old one cost 15–25 %; the small edit tasks now sit at server's answers. The remaining gap is bounded by how the agent works, not by what the server sends. +## Round 5 — server at b757e82 (M8, read-only mode) + +`lucisv-mcp --read-only`: five tools (`hierarchy, find, outline, read, +check`), a 1 797-byte catalogue, 297-byte instructions, and no way to +write. Only the two read tasks apply. Each arm ran twice; **the base arm +was re-run the same day as a control**, and that control is the finding. + +| task | arm | model | tokens | tool calls | wall | outcome | +|---|---|---|---|---|---|---| +| a | read-only | Sonnet 5 | 67 230 | 7 | 41 s | correct, 47/47 | +| a | read-only (re-run) | Sonnet 5 | 72 361 | 7 | 56 s | correct, 47/47 | +| a | base (same day) | Sonnet 5 | 64 817 | 3 | 40 s | correct, 47/47 | +| a | read-only, cap fixed | Sonnet 5 | 72 247 | 8 | 50 s | correct, 47/47 | +| d | read-only | Sonnet 5 | 80 487 | 10 | 121 s | correct, 71/20, all counts | +| d | read-only (re-run) | Sonnet 5 | 67 104 | 8 | 151 s | correct, 71/20, all counts | +| d | base (same day) | Sonnet 5 | 80 194 | 10 | 78 s | correct, 71/20, all counts | + +### Observations + +**Against the old base figures the read-only mode looks 23–28 % cheaper; +against a same-day base it is at parity** (a: mean 69.8 k vs 64.8 k, +8 %; +d: mean 73.8 k vs 80.2 k, −8 %). The base arm itself fell from 91.1 k to +64.8 k on task a and from 102.6 k to 80.2 k on task d between 2026-09-23 +and 2026-09-29 with no change to the task, the clone or the prompt: the +sub-agent environment changed under the census. Two consequences. Rounds +1–4 compared each mcp arm with a base arm measured the same day or within +a day, so their deltas stand; round 5 must not be compared with them, and +no figure in this file should be read as an absolute. And every future +round needs its base arm re-run alongside. + +- **a: the server's own answer was cut short.** Both read-only runs asked + `hierarchy up` with `peek` (they needed the `#(…)` values), and the + 300-line cap, which counted peek lines, showed 20 of 77 instantiations + and `… and 56 more`. Both agents then scanned the RTL sources themselves + — which is what the base arm does, in 3 calls. Without `peek` the same + call lists all 77 in 77 lines. Fixed after the round: the cap counts + instances (300, or 100 with `peek`, which bounds a peeked answer near + 40 kB), peek lines do not count (0.59.0). Re-measured on the fixed + binary: the one call now returns all 77 with their source (31 kB), the + agent reported the server and its own search agreed — and still ran the + search, so the cost did not move (72.2 k). A complete answer removes the + need for the fallback; it does not remove the agent's habit of checking. +- **d: the server answered.** `hierarchy` at depth 1 gave the 71 instances + in one call and `outline unit:` the port counts; 8–10 calls, the same as + the base arm's 10, with a wider spread in wall time (the shim re-indexes + on every call). +- **Catalogue.** Through the shim the read-only `--list` is 1.1 kB + (≈ 300 tokens) against 2.1 kB for the nine tools; a native host sends + 1.8 kB of schemas against 3.4 kB. The saving is real and small: a few + hundred tokens per session, below the run-to-run noise of any task here. + +**What the round says.** Read-only mode does what it is for: a smaller +surface that cannot write, with the same answers. It does not change the +token picture, and nothing at the catalogue level will: on these tasks +the model's own reading and answer dominate, and a current Sonnet with +plain file tools is already efficient at both. + ## Verdict, and what to do next **Helpful, not a toy — for the questions an engine answers better than @@ -334,6 +391,16 @@ them as file writes"), not the server. For scoped edits (b) a design-wide `port add` is the wrong tool and the agent should edit the two files; for renames (c) the `unresolved:` list is what makes 8/8 repeatable. +**After round 5 (read-only mode, 0.59.0).** Six more runs, all correct. +With a same-day base control the read-only server is at parity with file +tools on both read tasks (+8 %, −8 %), and the control showed the base arm +itself had become 22–29 % cheaper in six days — so no round here supports +an absolute claim, only same-day comparisons. The round also found a real +defect (the `peek` cap cutting `hierarchy up` to a quarter of its answer), +fixed in 0.59.0. The honest summary of five rounds: the server is correct +and safe, it matches file tools on cost, and it does not beat them on +these tasks with these models. + **Superseded by the ruling above — kept for the record.** (feedback-3 and after, as planned before round 4): the instantiation template opt-in on `unit_interface`; a terser `hierarchy` line (overrides only on request);