Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(health): require recent commits for developer_congestion (#3675)

Yunus Ozend215734cc331
diff --git a/packages/core/src/repowise/core/analysis/health/biomarkers/developer_congestion.py b/packages/core/src/repowise/core/analysis/health/biomarkers/developer_congestion.py
index 9c61e1f90..042d2184b 100644
--- a/packages/core/src/repowise/core/analysis/health/biomarkers/developer_congestion.py
+++ b/packages/core/src/repowise/core/analysis/health/biomarkers/developer_congestion.py
@@ -10,6 +10,10 @@ Fires when ALL of:
- ``churn_percentile`` ≥ 0.75 (the file is genuinely active *for this
repository* — a fixed commit count is a different bar on a repository
landing dozens a day than on one landing a handful a week)
+- ``commit_count_90d`` ≥ ``HOTSPOT_MIN_COMMITS_90D`` (the file actually
+ changed recently: the percentile ranks a decayed score that stays high
+ long after the commits stop, the same reason the hotspot flag has this
+ floor)
- the primary owner's share is below 50% (no clear DRI)
Reads ``ctx.git_meta`` only; no AST work needed.
@@ -17,6 +21,7 @@ Reads ``ctx.git_meta`` only; no AST work needed.
from __future__ import annotations
+from ....ingestion.git_indexer._constants import HOTSPOT_MIN_COMMITS_90D
from ..models import Severity
from .base import BiomarkerResult, FileContext
@@ -56,6 +61,10 @@ class DeveloperCongestionDetector:
# landing a handful a week than on one landing dozens a day.
if _as_float(meta.get("churn_percentile")) < _CHURN_PERCENTILE_FLOOR:
return []
+ # The percentile ranks a decayed score that stays high after the
+ # commits stop, so also require recent commits, as the hotspot flag does.
+ if commits_90d < HOTSPOT_MIN_COMMITS_90D:
+ return []
# primary_owner_commit_pct may be stored as a 0-1 fraction or
# 0-100 percentage depending on the source - normalize.
share = primary_pct / 100.0 if primary_pct > 1.0 else primary_pct
diff --git a/tests/unit/health/test_organizational_biomarkers.py b/tests/unit/health/test_organizational_biomarkers.py
index b5ef0bb67..d87fe21db 100644
--- a/tests/unit/health/test_organizational_biomarkers.py
+++ b/tests/unit/health/test_organizational_biomarkers.py
@@ -97,6 +97,27 @@ def test_developer_congestion_skips_quiet_files_for_this_repo():
assert DeveloperCongestionDetector().detect(_ctx(meta)) == []
+def _quiet_hotspot_meta(commits_90d: int) -> dict:
+ return {
+ "contributor_count": 5,
+ "churn_percentile": 0.9,
+ "commit_count_90d": commits_90d,
+ "primary_owner_commit_pct": 0.3,
+ }
+
+
+def test_developer_congestion_skips_files_with_no_recent_commits():
+ """A high percentile alone does not mean the file changed in the window."""
+ assert DeveloperCongestionDetector().detect(_ctx(_quiet_hotspot_meta(0))) == []
+
+
+def test_developer_congestion_needs_the_hotspot_commit_floor():
+ assert DeveloperCongestionDetector().detect(_ctx(_quiet_hotspot_meta(2))) == []
+ out = DeveloperCongestionDetector().detect(_ctx(_quiet_hotspot_meta(3)))
+ assert len(out) == 1
+ assert out[0].severity == "low"
+
+
# ---- knowledge_loss ------------------------------------------------------