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
fix(wiki): bug-fix counts on file and module pages name their 6-month window (#4369)
Raghav Chamadiyaf8bd4ac834a9
diff --git a/packages/core/src/repowise/core/generation/page_generator/pertype.py b/packages/core/src/repowise/core/generation/page_generator/pertype.pyindex 10bb00cee..e8463e1a3 100644--- a/packages/core/src/repowise/core/generation/page_generator/pertype.py+++ b/packages/core/src/repowise/core/generation/page_generator/pertype.py@@ -16,6 +16,7 @@ from typing import Anyimport structlog+from repowise.core.ingestion.git_indexer._constants import PRIOR_DEFECT_WINDOW_LABELfrom repowise.core.ingestion.models import ParsedFile, RepoStructurefrom repowise.core.providers.llm.error_hints import describe_provider_error@@ -377,6 +378,7 @@ class PerTypeGenerationMixin:concept_rows=rows,concept_omitted=omitted,signals=signals,+ fix_window=PRIOR_DEFECT_WINDOW_LABEL,)page.digest = re.sub(r"\n{3,}", "\n\n", digest).strip()return pagediff --git a/packages/core/src/repowise/core/generation/structural_labels.py b/packages/core/src/repowise/core/generation/structural_labels.pyindex baa6f00b1..eeb8dd69d 100644--- a/packages/core/src/repowise/core/generation/structural_labels.py+++ b/packages/core/src/repowise/core/generation/structural_labels.py@@ -27,6 +27,10 @@ what the system prompt already tells the model to do.from __future__ import annotations+from ..ingestion.git_indexer._constants import (+ PRIOR_DEFECT_WINDOW_DAYS,+ PRIOR_DEFECT_WINDOW_LABEL,+)from .languages import sanitize_language_codeENGLISH_LABELS: dict[str, str] = {@@ -77,7 +81,12 @@ ENGLISH_LABELS: dict[str, str] = {"history_owner": "**{owner}** is its primary maintainer, at {pct}% of commits.","history_owner_lines": "**{owner}** wrote {line}% of its current lines ({commit}% of commits).","history_owner_lines_only": "**{owner}** wrote {line}% of its current lines.",- "history_fixes": "{count} of those commits fixed a bug.",+ # Its own sentence, never "of those commits": the fix count covers the+ # prior-defect window, not the 90 days the commit sentence ends on.+ "history_fixes": "{count} {fix_word} in the last {window}.",+ "fix_commit_singular": "bug-fix commit",+ "fix_commit_plural": "bug-fix commits",+ "fix_window": PRIOR_DEFECT_WINDOW_LABEL,"history_hotspot": "It is one of the repository's change hotspots.","history_stable": "It has been stable: nothing has changed it lately.","commit_singular": "commit",@@ -221,7 +230,11 @@ LOCALIZED_LABELS: dict[str, dict[str, str]] = {"**{owner}** hat {line}% ihrer aktuellen Zeilen geschrieben ({commit}% der Commits)."),"history_owner_lines_only": "**{owner}** hat {line}% ihrer aktuellen Zeilen geschrieben.",- "history_fixes": "{count} dieser Commits haben einen Fehler behoben.",+ "history_fixes": "{count} {fix_word} in den letzten {window}.",+ "fix_commit_singular": "Bugfix-Commit",+ "fix_commit_plural": "Bugfix-Commits",+ # Dative after "in den letzten"; same months as PRIOR_DEFECT_WINDOW_LABEL.+ "fix_window": f"{PRIOR_DEFECT_WINDOW_DAYS // 30} Monaten","history_hotspot": "Sie gehört zu den Änderungs-Hotspots des Repositorys.","history_stable": "Sie ist stabil: zuletzt hat sich nichts an ihr geändert.","commit_singular": "Commit",diff --git a/packages/core/src/repowise/core/generation/templates/_agent_digest.j2 b/packages/core/src/repowise/core/generation/templates/_agent_digest.j2index 59843c1dd..45f3bba54 100644--- a/packages/core/src/repowise/core/generation/templates/_agent_digest.j2+++ b/packages/core/src/repowise/core/generation/templates/_agent_digest.j2@@ -44,7 +44,9 @@ From git history over the {{ signals.get("files", 0) }} files this page covers.{% endif %}{%- if signals.get("bus_factor_one") %}- Files with a bus factor of one: {{ signals.get("bus_factor_one") }}{% endif %}-{%- if signals.get("bug_fixes") %}- Bug-fix commits: {{ signals.get("bug_fixes") }}{% if signals.get("most_fixed_file") %}, most in `{{ signals.get("most_fixed_file") }}`{% endif %}+{#- Summed over the files' own fix counts, so a fix touching two files counts+ twice: a count of fixes per file, not of distinct commits. -#}+{%- if signals.get("bug_fixes") %}- Bug fixes in the last {{ fix_window }}, counted per file: {{ signals.get("bug_fixes") }}{% if signals.get("most_fixed_file") %}, most in `{{ signals.get("most_fixed_file") }}`{% endif %}{% endif %}{%- if signals.get("stable") %}- Stable files: {{ signals.get("stable") }}{% endif %}diff --git a/packages/core/src/repowise/core/generation/templates/file_page.j2 b/packages/core/src/repowise/core/generation/templates/file_page.j2index 848a2de9c..4f723c7a0 100644--- a/packages/core/src/repowise/core/generation/templates/file_page.j2+++ b/packages/core/src/repowise/core/generation/templates/file_page.j2@@ -162,7 +162,7 @@ _{{ labels.and_more.format(count=paths | length - 25) }}_that has been moved, so the fixes belong to a path this page no longerdescribes. -#}{%- if git.get("prior_defect_count") and git.get("prior_defect_count") <= commits -%}-{%- set _ = history.append(labels.history_fixes.format(count=git.get("prior_defect_count"))) -%}+{%- set _ = history.append(labels.history_fixes.format(count=git.get("prior_defect_count"), fix_word=labels.fix_commit_plural if git.get("prior_defect_count") != 1 else labels.fix_commit_singular, window=labels.fix_window)) -%}{%- endif -%}{%- if git.get("is_hotspot") -%}{%- set _ = history.append(labels.history_hotspot) -%}diff --git a/packages/ui/src/docs/module-history.tsx b/packages/ui/src/docs/module-history.tsxindex fec13cab0..7a55c68d7 100644--- a/packages/ui/src/docs/module-history.tsx+++ b/packages/ui/src/docs/module-history.tsx@@ -83,10 +83,12 @@ export function ModuleHistory({ metadata }: { metadata: Record<string, unknown><Row label="Single maintainer" value={`${s.bus_factor_one}${of} files`} />) : null}{s.bug_fixes ? (+ // Summed over the files' own 6-month fix counts, so a fix touching two+ // files counts twice: name the window and say it is per file.<Row- label="Bug fixes"+ label="Bug fixes · 6 mo"value={s.most_fixed_file ? `${s.bug_fixes} · most in ${basename(s.most_fixed_file)}` : `${s.bug_fixes}`}- title={s.most_fixed_file ? `${s.bug_fixes} bug-fix commits, most in ${s.most_fixed_file}` : undefined}+ title={`${s.bug_fixes} bug fixes in the last 6 months, counted per file${s.most_fixed_file ? `, most in ${s.most_fixed_file}` : ""}`}/>) : null}{s.most_active_file && (diff --git a/tests/unit/generation/test_agent_digest.py b/tests/unit/generation/test_agent_digest.pyindex 0daadcb5a..53dcccc77 100644--- a/tests/unit/generation/test_agent_digest.py+++ b/tests/unit/generation/test_agent_digest.py@@ -134,7 +134,7 @@ async def test_git_signals_reach_the_digest_and_the_card_not_the_body(sample_conassert signals["bug_fixes"] == 3assert signals["owners"] == [{"name": "Ada", "files": 1}]assert "## Signals" in page.digest- assert "Bug-fix commits: 3, most in `pkg/parser.py`" in page.digest+ assert "Bug fixes in the last 6 months, counted per file: 3, most in `pkg/parser.py`" in page.digestassert "hotspot" not in page.content.lower()diff --git a/tests/unit/generation/test_structural_labels.py b/tests/unit/generation/test_structural_labels.pyindex 5438a83cf..91675664a 100644--- a/tests/unit/generation/test_structural_labels.py+++ b/tests/unit/generation/test_structural_labels.py@@ -44,6 +44,27 @@ def test_german_labels_are_used_where_they_exist() -> None:assert resolve_structural_labels("de")["overview"] == "Überblick"+ ("code", "count", "expected"),+ [+ (None, 12, "12 bug-fix commits in the last 6 months."),+ (None, 1, "1 bug-fix commit in the last 6 months."),+ ("de", 12, "12 Bugfix-Commits in den letzten 6 Monaten."),+ ("de", 1, "1 Bugfix-Commit in den letzten 6 Monaten."),+ ],+)+def test_the_fix_sentence_names_its_own_window(code: str | None, count: int, expected: str) -> None:+ # The fix count spans the prior-defect window, so the sentence names it+ # rather than reading as a share of the 90-day commit count before it.+ labels = resolve_structural_labels(code)+ sentence = labels["history_fixes"].format(+ count=count,+ fix_word=labels["fix_commit_plural" if count != 1 else "fix_commit_singular"],+ window=labels["fix_window"],+ )+ assert sentence == expected++@pytest.mark.parametrize("code", [None, "", "xx", "klingon", " ", "de-DE"])def test_an_absent_or_unsupported_code_renders_the_full_english_catalog(code: str | None) -> None:# Never a partial mix and never a missing key: a template reading any labeldiff --git a/tests/unit/generation/test_structural_pages_read_like_a_wiki.py b/tests/unit/generation/test_structural_pages_read_like_a_wiki.pyindex b17a6be07..6e81bf268 100644--- a/tests/unit/generation/test_structural_pages_read_like_a_wiki.py+++ b/tests/unit/generation/test_structural_pages_read_like_a_wiki.py@@ -108,7 +108,9 @@ class TestHistory:assert "27 commits in its history, 9 in the last 90 days." in pageassert "Ada Lovelace" in pageassert "62%" in page- assert "12 of those commits fixed a bug." in page+ assert "12 bug-fix commits in the last 6 months." in page+ # The fix count spans 6 months, not the 90 days the sentence before it ends on.+ assert "of those commits" not in pageassert "change hotspots" in pagedef test_a_blame_owner_is_credited_with_lines_not_commits(self, generator):@@ -147,7 +149,15 @@ class TestHistory:)assert "## History" in page- assert "fixed a bug" not in page+ assert "bug-fix" not in page++ def test_one_fix_is_not_described_in_the_plural(self, generator):+ page = render(+ generator,+ _context(git_metadata={"commit_count_total": 3, "prior_defect_count": 1}),+ )++ assert "1 bug-fix commit in the last 6 months." in pagedef test_one_commit_is_not_described_in_the_plural(self, generator):page = render(generator, _context(git_metadata={"commit_count_total": 1}))@@ -607,7 +617,7 @@ Also defined: `log = structlog.get_logger(__name__)`.27 commits in its history, 9 in the last 90 days. The last landed on 2026-08-17. \**Ada Lovelace** is its primary maintainer, at 62% of commits. \-12 of those commits fixed a bug. It is one of the repository's change hotspots.+12 bug-fix commits in the last 6 months. It is one of the repository's change hotspots.## Changes together with