Impact
impact
Change impact analysis — who is affected when you modify a symbol.
Composes callers, graph, and search into a single
"what breaks if I change X?" answer.
Example
from axm_ast.core.impact import analyze_impact result = analyze_impact(Path("src/axm_ast"), "analyze_package") print(result["score"]) 'HIGH'
CallerEntry
Bases: TypedDict
Caller record as serialized into the impact result dict.
Source code in packages/axm-ast/src/axm_ast/core/impact.py
DefinitionInfo
Bases: TypedDict
Resolved definition location for a symbol.
module, line and kind are always present; signature and
name are only set for function/class lookups; package is added
by workspace-level resolution.
Source code in packages/axm-ast/src/axm_ast/core/impact.py
ImpactReport
Bases: BaseModel
Input shape consumed by :func:score_impact.
Captures only the inputs to scoring — display-only fields produced by
:func:analyze_impact (symbol, definition, test_files …)
are intentionally excluded.
Source code in packages/axm-ast/src/axm_ast/core/impact.py
ImpactResult
Bases: TypedDict
Output shape of :func:analyze_impact / :func:analyze_impact_workspace.
total=False because workspace results omit cross_package_impact
and test_files_by_import, and add workspace instead.
Source code in packages/axm-ast/src/axm_ast/core/impact.py
ImpactWeights
Bases: BaseModel
Configurable weights and thresholds for :func:score_impact.
Defaults match the module-level constants. Per-package overrides are
loaded from [tool.axm-ast.impact] in pyproject.toml.
Source code in packages/axm-ast/src/axm_ast/core/impact.py
TypeRefEntry
analyze_impact(path, symbol, *, project_root=None, exclude_tests=False, test_filter=None, include_module_importers=False, precise_callers=False)
Full impact analysis for a symbol.
Combines definition location, callers, re-exports, tests, and an impact score.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the package directory. |
required |
symbol
|
str
|
Name of the symbol to analyze. |
required |
project_root
|
Path | None
|
Project root (for test detection). |
None
|
exclude_tests
|
bool
|
If True, filter test callers and test type_refs from the output. The impact score is still computed on the full (unfiltered) caller set. |
False
|
test_filter
|
str | None
|
Filter mode for test callers. |
None
|
include_module_importers
|
bool
|
OPT-IN (default |
False
|
precise_callers
|
bool
|
OPT-IN (default |
False
|
Returns:
| Type | Description |
|---|---|
ImpactResult
|
Complete impact analysis dict. |
Example
result = analyze_impact(Path("src/axm_ast"), "analyze_package") result["score"] 'HIGH'
Source code in packages/axm-ast/src/axm_ast/core/impact.py
| Python | |
|---|---|
1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 | |
analyze_impact_workspace(ws_path, symbol, *, exclude_tests=False, test_filter=None)
Full impact analysis for a symbol across a workspace.
Searches all packages for definition, callers, re-exports, and test files. Module names include package prefix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ws_path
|
Path
|
Path to workspace root. |
required |
symbol
|
str
|
Name of the symbol to analyze. |
required |
exclude_tests
|
bool
|
If True, filter test callers from the output. Score is computed on the full caller set. |
False
|
test_filter
|
str | None
|
Filter mode for test callers. |
None
|
Returns:
| Type | Description |
|---|---|
ImpactResult
|
Complete impact analysis dict (workspace-scoped). |
Example
result = analyze_impact_workspace(Path("/ws"), "ToolResult") result["score"] 'HIGH'
Source code in packages/axm-ast/src/axm_ast/core/impact.py
| Python | |
|---|---|
1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 | |
find_definition(pkg, symbol)
Locate where a symbol is defined.
Supports dotted paths like ClassName.method to find
methods within class bodies. For deeply nested paths like
Outer.Inner.method, resolution is best-effort.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pkg
|
PackageInfo
|
Analyzed package info. |
required |
symbol
|
str
|
Name of the function/class to find. May be
dotted (e.g. |
required |
Returns:
| Type | Description |
|---|---|
DefinitionInfo | None
|
Dict with module, line, kind — or None if not found. |
Source code in packages/axm-ast/src/axm_ast/core/impact.py
find_reexports(pkg, symbol)
Find modules that re-export a symbol via all or imports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pkg
|
PackageInfo
|
Analyzed package info. |
required |
symbol
|
str
|
Name to search for in exports. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of module names that re-export the symbol. |
Source code in packages/axm-ast/src/axm_ast/core/impact.py
find_type_refs(pkg, type_name)
Find functions that reference a type in their signatures.
Scans all function parameters, return types, and module-level variable annotations for occurrences of type_name using word-boundary matching.
Handles compound types: list[X], dict[str, X],
X | None, Optional[X], nested generics, and
string annotations ("X").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pkg
|
PackageInfo
|
Analyzed package info. |
required |
type_name
|
str
|
Exact type name to search for (e.g. |
required |
Returns:
| Type | Description |
|---|---|
list[TypeRefEntry]
|
List of dicts with |
list[TypeRefEntry]
|
and |
Source code in packages/axm-ast/src/axm_ast/core/impact.py
map_tests(symbol, project_root)
Find test files that reference a given symbol.
Recursively scans the tests/ directory (including the AXM pyramid
sub-dirs tests/unit|integration|e2e/) for test_*.py files
containing the symbol name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
Name to search for in test files. |
required |
project_root
|
Path
|
Root of the project. |
required |
Returns:
| Type | Description |
|---|---|
list[Path]
|
List of test file paths that reference the symbol. |
Source code in packages/axm-ast/src/axm_ast/core/impact.py
score_impact(report, weights=None)
Score impact as LOW, MEDIUM, or HIGH.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report
|
ImpactReport | ImpactResult
|
|
required |
weights
|
ImpactWeights | None
|
Optional override; defaults to module-level weights. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Impact level string. |