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)
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
|
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 | |
|---|---|
801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 | |
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 | |
|---|---|
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 | |
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.
Scans tests/ directory 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. |