edit
Assess code-change safety: verify safe-to-change gates, blast radius, impact, refactor options, PR issues, and AST diffs through one action-driven code-intelligence interface.
Instructions
Code-intelligence (codegraph-compatible) safety and change-management facade. Covers codegraph_pr_review (PR analysis via codegraph), safe-to-edit gates, blast-radius guards, change impact scanning, refactoring suggestions, constraint checks, semantic classification, and AST diff in one tool. Pick a capability via action:
action=safe — pre-edit safety gate: is this file safe to edit right now? Returns SAFE/UNSAFE verdict. Params: file_path, edit_type, access_mode, snapshot_id, source_generation, output_format.
action=guard — blast-radius guard BEFORE touching a symbol: how many callers, what test coverage, what risk level. Params: symbol* (required), modification_type* (required), file_path.
action=impact — post-edit dependency blast-radius scan combining git diff + dependency graph: affected files, must-run tests, risk verdict (SAFE/REVIEW/WARN). Call after every non-trivial edit. Params: mode (diff|staged|branch|pr, default: diff), scope_paths, output_format, access_mode, capture_diff_snapshot (boolean; explicit opt-in, same-process POSIX producer only and forbidden with access_mode).
action=verify — explicitly execute a bound verification plan after rebuilding it. Runs project tests, which may write files or access the network. Params: request, output_format.
action=refactor — refactoring-opportunity analysis for a source file: extract candidates, complexity hotspots, skeleton. Params: file_path, language, max_suggestions, include_extractions, include_skeleton, output_format.
action=rename — rename a unique Python module-level function or class and its direct absolute from-import references, including aliases. Uses fresh AST identifier locations; preserves literals, comments, encoding and newlines. Ambiguous bindings, affected unsupported languages and dynamic references are rejected before writing. Params: symbol* (unqualified name), new_name*, mode (preview|apply, default: preview), output_format. mode=preview lists exact changes without writing; mode=apply WRITES files. This differs from action=refactor, which only suggests changes.
action=constraints — scan the project for constraint/rule violations. For RFC-0022 frozen read-only evaluation pass persist=false, diff_snapshot_id, and the impact-produced scope_paths. Params: severity_min, persist, diff_snapshot_id, scope_paths, access_mode, snapshot_id, source_generation, output_format.
action=pr — AI review of a PR diff via codegraph: structural issues, blast-radius, test-coverage gaps (codegraph_pr_review equivalent). Params: pr_url or diff (see inner schema).
action=classify — semantic change classification: classify a file's diff between git refs (file_path [+ old_ref/new_ref]) or two code strings (old_source + new_source + language). With only file_path, defaults to the file/git-ref mode. Params: file_path | old_source+new_source+language, access_mode, output_format.
action=ast_diff — structural AST diff between two snapshots/versions of a file: added/removed/changed nodes. Mode is inferred from args when omitted. Modes: diff_files (old_file + new_file), diff_strings (old_source + new_source + language), diff_git (old_ref + new_ref + file_path). Params: see inner schema; frozen consumption also accepts access_mode.
action=release_snapshot — idempotently release a process-local frozen diff. Params: diff_snapshot_id + route_lease_id.
action=plan_rename — preview an AST-aware rename of a unique Python module-level function or class and its direct absolute from-import references, including aliases (RFC-0027 §L8). Uses fresh identifier locations and rejects ambiguous bindings, affected unsupported languages and dynamic references. Returns exact edit sites and files_affected. PREVIEW ONLY — it never writes, and passing mode/dry_run/apply/write/force is REJECTED with PLAN_RENAME_IS_PREVIEW_ONLY rather than honoured. Params: symbol, new_name, output_format.
action=mutation_probe — on-demand query: does this test constrain this code? (RFC-0029). Applies one AST mutation at a source line in memory (never writes to disk), runs only the named test, and returns constrains/does_not_constrain/unknown. Fail-closed: unknown on any uncertainty; constrains only on AssertionError. Params: test_node_id* (required), source_path* (required), target_line* (required), timeout_seconds (default 60), output_format. NOTE:
safe/impact/classify/constraints/pr/ast_diff/plan_rename/mutation_probeare read-only in practice;refactor/guardsuggest changes but do not write files; rename with mode=apply writes files, and verify runs user tests with possible file and network side effects. readOnlyHint is False and destructiveHint is True for the whole facade (mixed action set).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | Action sub-mode (e.g. summary|cycles). | |
| limit | No | Max results. | |
| query | No | Search query/pattern. | |
| scope | No | Action discriminator (e.g. point|graph). | |
| action | Yes | Which capability to invoke. One of: ast_diff, classify, constraints, guard, impact, mutation_probe, plan_rename, pr, refactor, release_snapshot, rename, safe, verify | |
| symbol | No | Symbol/function name. | |
| persist | No | Write evaluated violations through to the cache. Set false for RFC-0022 read-only evaluation; no database or file is created. | |
| language | No | Language hint (usually auto). | |
| file_path | No | Target file path. | |
| access_mode | No | Explicit P0.4 zero-write access mode for routed read adapters. | |
| scope_paths | No | Primitive-issued frozen scope for action=constraints, or impact capture scope for action=impact. | |
| snapshot_id | No | Certified P0.1 index snapshot capability ID. | |
| function_name | No | Function name (alias of symbol). | |
| output_format | No | Output format: JSON. | |
| route_lease_id | No | Ownership token required by action=release_snapshot. | |
| diff_snapshot_id | No | RFC-0022 frozen diff ID for constraints/classify/ast_diff/release_snapshot. | |
| modification_type | No | Required for action=guard: type of planned modification. One of: add_feature, behavior_change, delete, fix_bug, refactor, rename, signature_change. | |
| source_generation | No | Certified P0.1/P0.2 source generation. | |
| capture_diff_snapshot | No | Explicitly produce a frozen diff ID for same-process consumers; supported only on POSIX. |