Skip to content

Commit 55f0bdd

Browse files
committed
fix: derive changed nodes from graph and improve MEDIUM risk reason
Derive changed_node_ids from the already-built graph by matching source_file paths instead of running a separate extraction pass. Removes implicit dependency on graphify ID stability across independent extractions. Fix MEDIUM risk reason to reflect the actual trigger (cluster spread vs high-connectivity entity) instead of always reporting cluster count.
1 parent 913cb28 commit 55f0bdd

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

.agents/tools/structural_impact.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ def _changed_files_mode(changed_files: list[Path]) -> str:
193193
analysis = _build_graph(_collect_source_files())
194194
G, communities, gods = analysis["graph"], analysis["communities"], analysis["god_nodes"]
195195

196-
changed_node_ids = {n["id"] for n in extract(changed_files)["nodes"]}
196+
changed_paths = {str(p.resolve()) for p in changed_files}
197+
changed_node_ids = {nid for nid in G.nodes() if G.nodes[nid].get("source_file") in changed_paths}
197198

198199
node_to_community = {n: cid for cid, nodes in communities.items() for n in nodes}
199200
affected_gods = [{"rank": gods.index(g) + 1, **g} for g in gods if g["id"] in changed_node_ids]
@@ -228,7 +229,13 @@ def _changed_files_mode(changed_files: list[Path]) -> str:
228229
reasons.append(f"{len(unique_violations)} import direction violation(s)")
229230
risk, risk_reason = "HIGH", "; ".join(reasons)
230231
elif len(affected_communities) > 3 or any(h["degree"] > 20 for h in high_impact):
231-
risk, risk_reason = "MEDIUM", f"{len(affected_communities)} clusters affected"
232+
medium_reasons = []
233+
if len(affected_communities) > 3:
234+
medium_reasons.append(f"{len(affected_communities)} clusters affected")
235+
high_deg = [h for h in high_impact if h["degree"] > 20]
236+
if high_deg:
237+
medium_reasons.append(f"high-connectivity entity ({high_deg[0]['label']}, {high_deg[0]['degree']} deps)")
238+
risk, risk_reason = "MEDIUM", "; ".join(medium_reasons)
232239
else:
233240
risk, risk_reason = "LOW", "localized change"
234241

0 commit comments

Comments
 (0)