Blast Radius & Change Impact Analysis
Relevant source files
The following files were used as context for generating this wiki page:
Blast Radius and Change Impact Analysis is a core feature of the code-review-graph project designed to provide token-efficient, structural context during code reviews. By utilizing a SQLite-backed knowledge graph built from Tree-sitter AST parsing, the system identifies how changes in specific files or symbols propagate through the codebase. This analysis helps developers and AI agents understand the potential consequences of a change beyond the immediate lines of code modified.
Sources: CLAUDE.md:5-10, skills/review-delta/SKILL.md:5-10
The analysis identifies "impacted nodes" (functions, classes, and types) and "impacted files" by traversing the dependency graph. This structural context allows AI tools to prioritize high-risk areas—such as widely depended-upon code or critical execution paths—while ignoring unrelated parts of the repository, significantly reducing token consumption.
Sources: CLAUDE.md:213-220, skills/review-delta/SKILL.md:30-35
Core Components and Logic
The impact analysis logic is centered around the ability to detect changes via Git and traverse the graph to find affected entities.
Change Detection
The system automatically detects changed files using git diff. It compares the current state against a base (usually HEAD~1 or main). This detection forms the "seed" for the impact analysis.
Sources: code_review_graph/main.py:115-125, skills/review-pr/SKILL.md:14-18
Graph Traversal (BFS)
Once changed files are identified, the system performs a Breadth-First Search (BFS) on the dependency graph. The traversal depth is configurable, defaulting to 2 hops. This identifies:
- Direct Dependents: Symbols that directly call or import the changed code.
- Transitive Dependents: Symbols impacted through multiple layers of dependencies.
Sources: CLAUDE.md:28, code_review_graph/main.py:155-165, code-review-graph-vscode/src/extension.ts:133-135
Visualization of Impact
Impact analysis data can be exported to an interactive D3.js visualization. In this view, nodes are sized by their degree (connection count), allowing developers to visually identify "hotspots" or high-impact areas within the blast radius.
Sources: code_review_graph/visualization.py:465-475, code-review-graph-vscode/src/extension.ts:580-585
The following diagram illustrates the logical flow of a Change Impact Analysis:
This flowchart shows the progression from a Git diff to a prioritized list of impacted code entities.
Sources: skills/review-delta/SKILL.md:12-28, code_review_graph/main.py:112-160
Key Tools and Functions
The system exposes several MCP tools to interact with the blast radius analysis.
get_impact_radius_tool
The primary tool for calculating the blast radius. It returns a dictionary containing changed nodes and the set of nodes/files transitively affected.
| Parameter | Type | Description | Default |
|---|---|---|---|
changed_files | list[str] | Optional list of paths. Auto-detected if null. | None |
max_depth | int | Number of hops to traverse in the graph. | 2 |
base | str | Git ref for diffing (e.g., "main"). | "HEAD~1" |
detail_level | str | "standard" or "minimal" output verbosity. | "standard" |
Sources: code_review_graph/main.py:143-167
detect_changes_tool
A higher-level tool that produces risk-scored review guidance. It combines the raw impact radius with additional metrics like test coverage gaps.
Sources: code_review_graph/main.py:417-430, skills/review-changes/SKILL.md:9-12
get_affected_flows_tool
Identifies which high-level execution flows (e.g., API endpoints or CLI commands) pass through the impacted code. This helps determine the functional impact of a change.
Sequence of events during an automated impact analysis session.
Sources: code_review_graph/main.py:155-167, code-review-graph-vscode/src/extension.ts:503-530
Risk Assessment Metrics
The impact analysis results are often used to generate a risk profile for a set of changes.
| Metric | Derivation | Significance |
|---|---|---|
| Overall Risk | Composite of blast radius size and affected flows. | Determines review priority. |
| Blast Radius Size | Count of impacted functions and files. | High count indicates architectural "hotspots". |
| Test Coverage Gap | Absence of TESTED_BY edges for changed nodes. | Flagged as high-risk if changes are untested. |
| Inheritance Impact | Presence of INHERITS or IMPLEMENTS edges. | Indicates potential Liskov substitution issues. |
Sources: skills/review-pr/SKILL.md:22-30, code-review-graph-vscode/src/extension.ts:544-570
Implementation Example: VS Code Integration
The VS Code extension demonstrates how the blast radius is computed and displayed to the user.
// From code-review-graph-vscode/src/extension.ts
const config = vscode.workspace.getConfiguration("codeReviewGraph");
const depth = config.get<number>("blastRadiusDepth", 2);
const impact = sqliteReader.getImpactRadius([node.filePath], depth);
if (impact.impactedNodes.length === 0) {
vscode.window.showInformationMessage(
`Code Graph: No blast radius found for "${qualifiedName}".`
);
return;
}
Sources: code-review-graph-vscode/src/extension.ts:133-145
Conclusion
Blast Radius & Change Impact Analysis provides a structural lens for evaluating code changes. By mapping Git diffs to a structural graph, the system identifies transitive dependencies and affected execution paths, enabling risk-scored reviews and significant token savings for AI-driven development workflows.
Sources: skills/review-delta/SKILL.md:38-45, CLAUDE.md:210-215