orchestrata_ultimate.refactor.codemod.analysis.blast_radius
Reference › orchestrata_ultimate › refactor › codemod › analysis › blast_radius
BlastRadiusAnalyzer is a read-only adapter over CodeIntelligenceGraph.blast_radius in _cig. analyze(target, hops=3) resolves the target module through the shared resolver in protocol and returns the BlastRadius (affected nodes, files and an impact score) found by walking up to hops steps in both directions along the graph's edges. It changes nothing and is imported by the analysis facade.
At a glance
| Source | src/orchestrata_ultimate/refactor/codemod/analysis/blast_radius.py |
| Lines of code | 48 |
| Classes | 1 |
| Functions | 0 |
| Imports (internal) | orchestrata_ultimate.core.base.traces, orchestrata_ultimate.refactor.codemod._cig, orchestrata_ultimate.refactor.codemod._types, orchestrata_ultimate.refactor.codemod.analysis.protocol |
| Imported by | orchestrata_ultimate.refactor.codemod.analysis |
| Tests that import it | none |
Class diagram
Dependency diagram
API
Classes
BlastRadiusAnalyzer
Decorators: traces(spec='110', story='US-110-006', reqs=['REQ-110-031', 'REQ-110-032']) · Line 18
Transitive impact of one module.
| Method | Signature | Summary |
|---|---|---|
__init__ |
__init__(cig: CodeIntelligenceGraph) -> None |
|
analyze |
analyze(target: str | None = None, *, hops: int = 3) -> BlastRadius |
BFS closure around target (a module path) up to hops hops. |
_resolve |
_resolve(target: str) -> int |
Source
"""BlastRadiusAnalyzer — read-only adapter over ``CodeIntelligenceGraph.blast_radius``."""
from __future__ import annotations
from typing import TYPE_CHECKING
from orchestrata_ultimate.core.base.traces import traces
from orchestrata_ultimate.refactor.codemod._types import BlastRadius
from orchestrata_ultimate.refactor.codemod.analysis.protocol import resolve_node_id
if TYPE_CHECKING:
from orchestrata_ultimate.refactor.codemod._cig import CodeIntelligenceGraph
__all__ = ["BlastRadiusAnalyzer"]
@traces(spec="110", story="US-110-006", reqs=["REQ-110-031", "REQ-110-032"])
class BlastRadiusAnalyzer:
"""Transitive impact of one module.
GAP-4: the CIG walks every edge type (IMPORTS, CALLS, DEFINES,
HAS_PARAMETER, TESTED_BY, OVERRIDES), so the numbers include DEFINES and
HAS_PARAMETER edges. The adapter returns the graph's result unchanged.
"""
name = "blast_radius"
@traces(spec="110", story="US-110-006", reqs=["REQ-110-031", "REQ-110-032"])
def __init__(self, cig: CodeIntelligenceGraph) -> None:
self._cig = cig
@traces(spec="110", story="US-110-006", reqs=["REQ-110-031", "REQ-110-032"])
def analyze(self, target: str | None = None, *, hops: int = 3) -> BlastRadius:
"""BFS closure around ``target`` (a module path) up to ``hops`` hops.
Raises:
ValueError: ``target`` is missing or names no module in the graph.
"""
if target is None:
raise ValueError("blast_radius requires a target module")
return self._cig.blast_radius(self._resolve(target), hops=hops)
@traces(spec="110", story="US-110-006", reqs=["REQ-110-031"])
def _resolve(self, target: str) -> int:
node_id = resolve_node_id(self._cig, target)
if node_id is None:
raise ValueError(f"module '{target}' not found in CIG")
return node_id