Skip to content

feat(mcp): add tracedecay_move_symbol with impact report#414

Merged
ScriptedAlchemy merged 3 commits into
masterfrom
codex/move-symbol
Jul 10, 2026
Merged

feat(mcp): add tracedecay_move_symbol with impact report#414
ScriptedAlchemy merged 3 commits into
masterfrom
codex/move-symbol

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

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_run defaults true: previews the combined source-removal / destination-insertion diff and the full impact report while writing nothing. dry_run: false applies (dest-first write with source-write rollback, reindex both).
  • Impact classes: 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.
  • Docs/attrs travel with the symbol (attrs_start_line semantics, incl. the fix(db): stop conflating attrs_start_line 0 with unset #353 first-in-file edge case).
  • Unambiguous needed imports are auto-inserted at the destination (applied_imports); callers are reported, never auto-edited (update_references reserved).
  • Empty impact on a clean move is a tested contract.

Implementation notes

  • Dependency and use-statement analysis are built on the master source_mask facility (comments + string literals masked, implicit format!("{ident}") captures preserved) and a tree-sitter walk of use_declaration nodes, so multi-line grouped imports are captured whole and use tokens inside comments/strings are never matched. Falls back to a line scan when the Rust grammar is unavailable.
  • cycle_risk is 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 modules move_symbol + edits (25 tests): green.
  • Agent-adoption scenario edit_move_compute_grand_total_out un-deferred (status: active) and live-verified through the built binary against the fixture crate: auto-inserts use crate::pricing::LineItem; and reports module_missingpub mod grand_total;. evals/agent_adoption/selftest.py passes.

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2149311

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

ScriptedAlchemy and others added 3 commits July 10, 2026 00:42
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>
@ScriptedAlchemy ScriptedAlchemy merged commit cd5ef58 into master Jul 10, 2026
12 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant