feat(mcp): add tracedecay_move_symbol with impact report#414
Merged
Conversation
|
Relocate a function to another file and return an evidence-based impact report. dry_run defaults true and previews without writing; the report classes are caller_reference, dependency_broken/import_needed, visibility_required, collision/module_missing/cycle_risk, and orphaned_import/cfg_context. Docs/attrs travel with the symbol (attrs_start_line), unambiguous needed imports are auto-inserted at the destination, and callers are reported but never auto-edited. Dependency and use-statement analysis are built on the tree-sitter source-mask facility (comments and string literals masked, implicit format captures preserved) and a tree-sitter walk of use_declaration nodes so multi-line grouped imports are captured whole, with a line-scan fallback when the grammar is unavailable. Un-defers the edit_move_compute_grand_total_out agent-adoption scenario, live-verified against the fixture crate. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Five fixes from the move_symbol line review: - resolve_dest_rel now normalizes `./` (CurDir) components so a `./`-prefixed same-file dest hits the same-file guard/collision check instead of clobbering the same inode (silent symbol deletion). - Advance the moved span past leading `//!` inner module docs so the source keeps its module doc and the dest gets no mid-file `//!` (E0753). - insert_imports stops before an outer doc block (`///`/`/**`) so a use is never wedged between a doc and its item. - Destination read distinguishes NotFound (new file) from unreadable (refuse), and rollback deletes a newly created dest + empty dirs. - cfg_context hint drops the misleading dest `line`; reports the moved-span offset in detail instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
f9c05db to
2149311
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
tracedecay_move_symbol, an edit-tier MCP tool that relocates a function to another file and returns an evidence-based impact report rather than silently rewriting call sites.dry_rundefaults true: previews the combined source-removal / destination-insertion diff and the full impact report while writing nothing.dry_run: falseapplies (dest-first write with source-write rollback, reindex both).caller_reference(every breaking caller with its exact new path),dependency_broken/import_needed,visibility_required,collision/module_missing/cycle_risk,orphaned_import/cfg_context.attrs_start_linesemantics, incl. the fix(db): stop conflating attrs_start_line 0 with unset #353 first-in-file edge case).applied_imports); callers are reported, never auto-edited (update_referencesreserved).Implementation notes
use-statement analysis are built on the mastersource_maskfacility (comments + string literals masked, implicitformat!("{ident}")captures preserved) and a tree-sitter walk ofuse_declarationnodes, so multi-line grouped imports are captured whole andusetokens inside comments/strings are never matched. Falls back to a line scan when the Rust grammar is unavailable.cycle_riskis emitted by a file-level heuristic: the destination already importing from the source module.Verification
cargo fmt --check,cargo clippy --workspace --all-targets --locked -- -D warnings: clean.cargo nextest run --test mcp_suite(372) and--test agent_suite(498): green; touched lib modulesmove_symbol+edits(25 tests): green.edit_move_compute_grand_total_outun-deferred (status: active) and live-verified through the built binary against the fixture crate: auto-insertsuse crate::pricing::LineItem;and reportsmodule_missing→pub mod grand_total;.evals/agent_adoption/selftest.pypasses.🤖 Generated with Claude Code