MCP Hardening + vlog_refactor References / L-9 Support (Round 3)
Goal
Harden lucisv_mcp and vlog_refactor on the concrete bugs, performance gaps, and protocol edges identified across audit rounds:
- Cached
FileFactsin references & MCP tools (#37/#40): Addfind_references_with,find_references_batch, andfind_references_batch_withincrates/vlog_refactor/src/references.rsaccepting&dyn KnownFacts, sharing oneScope::build_keeping+ occurrence walk; implementKnownFactsonProjectkeyed by FNV-1acontent_hash(text)and wire it intofind,rename, andedit_item(item/refs.rs). - Future-mtime settlement (
#54): Anchor monotonic first-observation time (Stamp::first_mono) and inherit it across unchanged re-reads (Stamp::inherit_observation) incrates/lucisv_mcp/src/project/files.rsandproject/mod.rsso files with future timestamps settle afterRACYwhile reacting to wall-clock catch-up, clock step-backs, and edits. - Windows
--all-targetstest build (#56): Gate Unix-only symlink andPermissionsExt::from_modetests incrates/lucisv_mcp/tests/qa_m3.rswith#[cfg(unix)]and add non-Unixmode_bitsinsnapshot(). - L-9 Parity & Qualified
findFocus Scoping: Exposeafter_dotand bind-awarehome_set_for/home_sets_forfromvlog_refactor, wirementions.rs,edit.rs, andfind.rsto match the engine's dotted-mention and K2bindrules, and wireFocus::uniton qualifiedunit.name(and single-unit) queries infind. checkDirectory & Glob Support: Allowcheck(diagnostics.rs/tools/glob.rs) to accept directory and globfilearguments matchingformat's indexing/root-containment rules, keepingunused_waiverswhole-design-only.- Protocol & Budgets (
rpc.rs,wire.rs,read_only.rs,docs/mcp/PLAN.md): Drop unused"prompts": {}frominitializecapabilities and raise catalogue/instruction ceilings to2,000/330 B(read-only) and3,800/440 B(full) while preserving thehierarchy {}lazy-walk freshness contract.
Assumptions
KnownFactsonProjectmust returnNonewhenevercontent_hash(text.as_bytes()) != stamp.hashso a disk modification betweenProject::refreshandWholeSet::readalways triggers a fresh parse.- Existing
INSTRUCTIONSandINSTRUCTIONS_READ_ONLYtexts remain within<= 400 B/<= 300 Bfor compatibility withqa_m6.rsandqa_f1.rs, whilewire.rs,read_only.rs, andrpc.rspin the updated440 / 330 / 3,800 / 2,000 Bceilings. hierarchy {}continues callingproject.ensure_walked_for_miss()when unpopulated (preserving M1 freshness).
Handshakes
vlog_refactor↔lucisv_mcp:find_references_with,find_references_batch,find_references_batch_withtake&dyn KnownFacts.after_dot(&str) -> boolis the shared boundary check for dotted spellings acrossrename::scopedandlucisv_mcp::tools::mentions.home_set_for/home_sets_forexpose the engine's include + K2bindhome set cleanly toedit.rsandfind.rs.
tools/glob↔tools/diagnostics:glob::normalize_globvalidates root containment beforeglob::path_matchevaluates indexed files;Project::resolve_existingvalidates file or directory existence within roots.
Status / TODO
vlog_refactor:find_references_with,find_references_batch,find_references_batch_with,after_dot,home_set_for,home_sets_for+ unit/integration testslucisv_mcp::project:#54future-mtimefirst_monosettlement +KnownFactsonProjectlucisv_mcp::tools&rpc.rs:KnownFactswiring, L-9 parity, qualifiedfind,checkdir/glob, remove"prompts": {}, updated budgets- Cross-platform gate (
#56) inqa_m3.rs+ docs (PLAN.md, this doc) - Full verification suite (
fmt,stamp_author,clippy, guardedcargo test, Windows--all-targetscheck, live OpenTitan stdio probe)
Work log
- Implemented
find_references_with,find_references_batch, andfind_references_batch_withincrates/vlog_refactor/src/references.rssharingcollect_batch/build_scope/collect_one, and exported them alongsideafter_dot,home_set_for, andhome_sets_forfromcrates/vlog_refactor/src/lib.rs(withpub(crate) use/pub useincrates/vlog_refactor/src/rename/mod.rs). - Added
first_monoandinherit_observationtoStampincrates/lucisv_mcp/src/project/files.rsand wired observation inheritance +vlog_refactor::KnownFactsforProject(keyed bystamp.hash == content_hash(text.as_bytes())) incrates/lucisv_mcp/src/project/mod.rs. - Wired
KnownFactsintofind.rs(find_references_batch_with),edit.rs(rename_traced_with), andtools/item/refs.rs(find_references_batch_with); updatedmentions.rs(vlog_refactor::after_dot),edit.rs/find.rs(home_set_for/home_sets_for), and qualifiedFocus::unitscoping infind.rs. - Added directory and glob support to
check(diagnostics.rs,tools/glob.rs::normalize_glob,Project::resolve_existing); removed"prompts": {}frominitializecapabilities inrpc.rs; raised catalogue/instruction ceilings to2,000 / 330 B(RO) and3,800 / 440 B(full) indocs/mcp/PLAN.md,rpc.rs,wire.rs, andread_only.rs(measured sizes:1,826 B / 297 BRO,3,469 B / 398 Bfull). - Gated Unix-specific symlink/permission tests in
crates/lucisv_mcp/tests/qa_m3.rswith#[cfg(unix)]and added cross-platformmode_bitshelper forsnapshot(). - Verified:
cargo fmt&python3 tools/stamp_author.py --check(would stamp 0 files; left 249 untouched).cargo clippy -p vlog_refactor -p lucisv_mcp --all-targets -- -D warnings: passed (0 errors/warnings on crate code).cargo check --target x86_64-pc-windows-gnu --all-targets -p lucisv_mcp: passed (0 errors)../tools/guard.sh -m 8 -t 600 -- cargo test -p vlog_refactor -p lucisv_mcp --all-targets: 0 failures across all targets (lucisv_mcp: 88 unit + 23attacks+ 4cache+ 2hierarchy_cap+ 21qa_f1+ 6qa_f2+ 48qa_m1+ 35qa_m2+ 36qa_m3+ 45qa_m4+ 17qa_m6+ 19qa_m7(+1 ignored) + 6qa_m8+ 5read_only+ 44wire+ 3 ignoredopentitan;vlog_refactor: 218 unit + 54ansi+ 11corpus(+1 ignored) + 33expand+ 41extract+ 9import_offers+ 35imports+ 37inline+ 3 ignoredopentitan_top_rooted+ 7parsed_selectors+ 10port_offers+ 54ports+ 11preflight_oracle+ 11qa_correctness_r1+ 26qa_generate_label+ 26qa_rename_implicit(+1 ignored) + 24qa_warning_scope+ 2references_and_scope+ 71rename+ 15rename_bind(+1 ignored) + 17rename_generate_label+ 24rename_implicit+ 10rename_macro_carry+ 8rename_warning_scope+ 15top_rooted_paths).- Release stdio probe (
./target/release/lucisv-mcp --root /Users/lucio/repo/opentitan/hw --read-only, no--index-cache):initializecapabilities{'resources': {}, 'tools': {}}(no"prompts");hierarchy {}returned4043 files, 1355 modules, 372 top(301 lines);checkonip/aes/rtl(34.4 ms,ok) andip/aes/rtl/*.sv(34.5 ms,ok, matching dir), bad glob refused cleanly;findwithrefs: trueonaes_core.AES192Enableran in1,460.1 mscold /461.4 mswarm (rst_nibatch ofREFS_CAP=5ran in1,938.6 mscold /1,915.1 mswarm, identical output);/Users/lucio/repo/opentitangit working tree verified clean.
QA log
Verdict: PASS (Round 3 QA audit against HEAD 4d384ec uncommitted diff).
- Invariants & deduplication:
- Every changed/added library file (
crates/vlog_refactor/src/{lib.rs,references.rs,rename/mod.rs,rename/home.rs,rename/scoped.rs}andcrates/lucisv_mcp/src/{project/files.rs,project/mod.rs,rpc.rs,tools/diagnostics.rs,tools/edit.rs,tools/find.rs,tools/glob.rs,tools/item/refs.rs,tools/mentions.rs}) has<= 312non-blank non-comment production lines beforemod tests(well under600) and0.unwrap(),.expect(),panic!, orunsafeoccurrences in non-test production code. - Shared helpers verified without duplication:
references.rs(collect_single,collect_batch,build_scope,collect_one),home.rs(home_sets_for,home_with_graph),scoped.rs/home.rs(file_binds_into,push_defines,defs_from_sources),scoped.rs/mentions.rs(vlog_refactor::after_dot), anddiagnostics.rs(lint_paths,match_with_rewalk).
- Every changed/added library file (
- Adversarial code & contract checks:
- #37 / #40 (
KnownFacts):Project::facts_forverifiesstamp.hash == lucisv_core::cache::content_hash(text.as_bytes())so staleFileFactsare never returned after on-disk edits betweenrefreshandWholeSet::read;Scope::takealso checksfacts.path() == path.find_references_batch_with/find_references_withmatchfind_referencesidentically onfind.rs,edit.rs(rename_traced_with), andtools/item/refs.rs. - #54 (Future-mtime settlement):
Stamp::first_mono,Stamp::inherit_observation, andStamp::racy(now)preserve observation age across unchanged re-reads (same && !prev.clock_stepped_back(now)), settle afterRACYmonotonic elapsed, force re-read into normal rules on wall-clock catch-up (now.wall >= time), reset on hash/metadata changes, and markSuspecton wall-clock step-backs. - #56 (Windows
--all-targets):qa_m3.rsgates only Unix-specific symlink/PermissionsExt::from_modetests with#[cfg(unix)]while keeping portable tests active withmode_bits.cargo check --target x86_64-pc-windows-gnu --all-targets -p lucisv_mcpcompiled with0errors. - L-9 & Qualified
find:after_dothandles blanks,/* ... */comments, and``pastes identically inscoped.rsandmentions.rs;home_set_for/home_sets_forinclude direct and macro-expandedbindhome sets (K2);find.rspopulatesFocus::uniton qualifiedunit.nameand single-unit queries. checkdir/glob, budgets &hierarchy {}:tools/glob.rs::normalize_glob+Project::resolve_existingenforce root containment and refuse empty, missing, non-matching, and outside-root (..,../../etc/*.sv) targets;lint_paths(..., false)omits whole-designunused_waiverson subset checks.rpc.rsinitializereturnscapabilities: {"tools": {}, "resources": {}}(no"prompts"). Budgets verified inrpc.rs,wire.rs,read_only.rs, anddocs/mcp/PLAN.md(measured: RO1,826 Bcatalogue /297 Binstructions vs2,000 / 330 Bcaps; full3,469 Bcatalogue /398 Binstructions vs3,800 / 440 Bcaps).hierarchy.rs:107retainsproject.ensure_walked_for_miss()forhierarchy {}.
- #37 / #40 (
- Executed verification commands:
python3 tools/stamp_author.py --check:would stamp 0 files; left 249 untouched../tools/gates.sh --only fmt,clippy,suite:vlog_refactor,suite:lucisv_mcp,docs,node,cross:PASSacross all 7 steps (fmtpass,clippypass,suite:vlog_refactor769/0,suite:lucisv_mcp399/0,docs1/0,node37/0,crosspass).- Windows
--all-targets:env RUSTC="$HOME/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc" "$HOME/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo" check --target x86_64-pc-windows-gnu --all-targets -p lucisv_mcppassed with0errors. - OpenTitan stdio probe (
./target/release/lucisv-mcp --root /Users/lucio/repo/opentitan/hw --read-only):initializecapabilities{'resources': {}, 'tools': {}}(297 Binstructions);hierarchy {}->4043 files, 1355 modules, 372 top(301lines,1069.8 ms);findaes_core.AES192Enable(refs: true,486.9 mscold /459.5 mswarm, identical output) andaes_control_fsm.aes_ctrl_ns(refs: true, returnedaes_bind.sv:65+aes_control_fsm.svuses +unresolvedline909);findrst_ni(refs: true,1944.3 ms->1937.3 ms,301lines);checkonip/aes/rtl(34.8 ms,ok),./ip/aes/rtl/(33.8 ms,ok),ip/aes/rtl/*.sv(34.5 ms,ok),ip/aes/**/rtl/aes_core.sv(19.7 ms,ok),ip/uart/dvvsip/uart/dv/**/*.sv(identical5findings),ip/uart/dv/*.sv/ip/aes/rtl/*.none(isError=true,no indexed file matches ...),../../etc/*.sv/..(isError=true,resolves outside every root),ip/aes/no_such_dir(isError=true,does not exist under any root). git -C /Users/lucio/repo/opentitan status --porcelain: empty (strictly clean).
Review
Lead Self-Inspect (2026-11-26): APPROVED for trunk commit.
- Verified Plan Review rulings were respected:
hierarchy.rsretainsensure_walked_for_miss()on no-roothierarchy {}calls;rename/mod.rsandlib.rsexportafter_dot,home_set_for, andhome_sets_for;find_references_with/find_references_batch_withmatchfind_referenceserror and tuple types (Result<Vec<(PathBuf, TextRange)>, String>). - Checked
rpc.rs("prompts": {}removed frominitializecapabilities),references.rs(KnownFactshash-checked caching with sharedcollect_single/collect_batch/build_scope/collect_one),files.rs(first_mono/inherit_observation#54future-mtime settlement),qa_m3.rs(#[cfg(unix)]#56portability),diagnostics.rs/glob.rs(checkdir/glob support), and owner-ruled catalogue/instruction ceilings (2,000/330 BRO,3,800/440 Bfull). - Pending final full
./tools/gates.sh+stamp_author.py --checkbefore local commit and closing#37,#40,#54,#56indocs/topo.md.