Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
perf(architecture): classify each path once when rolling edges up to boxes (#4222)
Raghav Chamadiya2a61ef64ba1c
diff --git a/packages/core/src/repowise/core/analysis/c4/relations.py b/packages/core/src/repowise/core/analysis/c4/relations.pyindex e268cb52a..70f586746 100644--- a/packages/core/src/repowise/core/analysis/c4/relations.py+++ b/packages/core/src/repowise/core/analysis/c4/relations.py@@ -37,6 +37,15 @@ def roll_up_edges(externals = file_to_external or {}counts: dict[tuple[str, str], int] = defaultdict(int)types: dict[tuple[str, str], set[str]] = defaultdict(set)+ # Per path, not per edge: a file sits on hundreds of edges and the test+ # classifier is the cost of the whole roll-up.+ dropped: dict[str, bool] = {}++ def drop(path: str) -> bool:+ if path not in dropped:+ dropped[path] = is_config_path(path) or is_test_related_path(path)+ return dropped[path]+for src, tgt, etype in edges:if etype == "co_changes" and not include_co_changes:continue@@ -46,9 +55,7 @@ def roll_up_edges(tgt_box = file_to_box[tgt] if tgt in file_to_box else externals.get(tgt)if tgt_box is None or src_box == tgt_box:continue- if is_config_path(src) or is_config_path(tgt):- continue- if is_test_related_path(src) or is_test_related_path(tgt):+ if drop(src) or drop(tgt):continuecounts[(src_box, tgt_box)] += 1types[(src_box, tgt_box)].add(etype)diff --git a/packages/core/src/repowise/core/generation/architecture_map.py b/packages/core/src/repowise/core/generation/architecture_map.pyindex 19fbd66f7..d8228c747 100644--- a/packages/core/src/repowise/core/generation/architecture_map.py+++ b/packages/core/src/repowise/core/generation/architecture_map.py@@ -262,9 +262,11 @@ def _forward_entries(kind = classify_entry_point(path)if kind is None:continue- targets = {t for s, t, etype in edges if s == path and etype == "imports"}- if path in barrels and len(targets) == 1:- path = targets.pop()+ if path in barrels:+ # Scanned only for a launcher: the edge list is repository-sized.+ targets = {t for s, t, etype in edges if s == path and etype == "imports"}+ if len(targets) == 1:+ path = targets.pop()if (path, kind) not in out:out.append((path, kind))return out