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.

feat(health): plain display labels for five health markers (#4119)

Raghav Chamadiya992524f53bf0
diff --git a/README.md b/README.md
index c11731e33..2f9fe0763 100644
--- a/README.md
+++ b/README.md
@@ -138,7 +138,7 @@ the page that answers it.
| *Can I get docs for this codebase?* | A wiki for every module and file, rendered from the code's structure with no key, or written by a model when you choose. It updates incrementally after each commit. [Docs](docs/layers/WIKI.md) |
| *Which of our docs are wrong?* | Markdown checked against the tree: every reference to a file or symbol the code no longer has, with the line to edit. [Doc drift](docs/layers/DOC_DRIFT.md) |
| *Why is it built this way?* | Decisions mined from ADRs, `# WHY:` comments, commit and PR history and your agent sessions, each tied to the code it governs and flagged when it goes stale. [Decisions](docs/layers/DECISIONS.md) |
-| *Who knows this code?* | Owners, bus factor, knowledge-loss risk when the main author goes quiet, and suggested reviewers. [Ownership](docs/layers/OWNERSHIP.md) |
+| *Who knows this code?* | Owners, bus factor, fading ownership when the main author goes quiet, and suggested reviewers. [Ownership](docs/layers/OWNERSHIP.md) |
| *Can I see the architecture?* | An explorable dependency map, C4 views, and a Structurizr export, no model involved. [Dashboard](docs/start/DASHBOARD.md) |
### Change it safely
diff --git a/docs/LINEAGE.md b/docs/LINEAGE.md
index aa3271f58..75fe6e0f2 100644
--- a/docs/LINEAGE.md
+++ b/docs/LINEAGE.md
@@ -162,7 +162,7 @@ language, every day. Where we departed from the source, we say so:
- **Missing evidence reads as no signal.** A class with no detected member references
reports LCOM4 of 1, not a high value; an unsupported language produces no health
findings, not guessed ones.
-- **Weak signals stay weak.** Developer congestion and knowledge loss calibrated
+- **Weak signals stay weak.** Many authors and fading ownership calibrated
weakly, so their weights are floored at 0.5 and 0.4 instead of being removed or
inflated.
diff --git a/docs/layers/CODE_HEALTH.md b/docs/layers/CODE_HEALTH.md
index 58f16dce6..d1856ee68 100644
--- a/docs/layers/CODE_HEALTH.md
+++ b/docs/layers/CODE_HEALTH.md
@@ -163,7 +163,7 @@ on the dashboard, in `get_health` and in `repowise health --format json`
`repowise next` prints the cross-layer list the dashboard calls Do next and
`get_overview` returns as `next_actions`. It reads stored actions, so it is
instant. Fix first items sit beside a live secret, fresh regressions, fragile
-files, files with knowledge loss, broken doc references, a dead-code batch,
+files, files with fading ownership, broken doc references, a dead-code batch,
missing or stale coverage, and decisions waiting for review. Rows are grouped as
Now, Worth planning and Improve what Repowise can see. Within a group, rows rank
by value times confidence over effort, and the top due Fix first item leads its
@@ -199,7 +199,7 @@ dominating a file.
| Size and complexity | 3 | 1.5 | Long or high-CCN functions, primitive obsession |
| Duplication | 1 | 1.0 | Cloned blocks |
| Error handling | 1 | 0.5 | Swallowed or catch-all handlers, `unwrap`/panic, discarded Go errors |
-| Change history | 10 | 1.0 to 3.5 | Churn, change entropy, co-change scatter, ownership, knowledge loss, prior bug fixes |
+| Change history | 10 | 1.0 to 3.5 | Churn, change entropy, co-change scatter, ownership, fading ownership, prior bug fixes |
| Test coverage | 3 | 2.0 + 2.0 | Untested hotspots, coverage gaps, uncovered lines (needs a coverage report) |
| Test quality | 4 | 0.5 | Oversized or duplicated assertion blocks; two advisory markers |
| SQL | 4 | none | Complex SQL, `SELECT *`, `UPDATE`/`DELETE` with no `WHERE`, cartesian joins; maintainability or performance only |
diff --git a/docs/layers/INTELLIGENCE_LAYERS.md b/docs/layers/INTELLIGENCE_LAYERS.md
index d517e11bd..07f9789dd 100644
--- a/docs/layers/INTELLIGENCE_LAYERS.md
+++ b/docs/layers/INTELLIGENCE_LAYERS.md
@@ -46,7 +46,7 @@ no import between them can still change together every week.
| Built on it | What you get | Read more |
|---|---|---|
-| Ownership and knowledge risk | Owners, bus factor, silos, knowledge loss when a main author goes quiet, suggested reviewers | [OWNERSHIP.md](OWNERSHIP.md) |
+| Ownership and knowledge risk | Owners, bus factor, silos, fading ownership when a main author goes quiet, suggested reviewers | [OWNERSHIP.md](OWNERSHIP.md) |
| Bug history | Fix commits traced to files and symbols, bug magnets | [BUG_HISTORY.md](BUG_HISTORY.md) |
| Hidden coupling | Files that change together with no import link | [CHANGE_RISK.md](CHANGE_RISK.md) |
| Branch overlap | Other branches editing the same files or their co-change partners | [CHANGE_RISK.md](CHANGE_RISK.md#branch-overlap) |
diff --git a/packages/core/src/repowise/core/analysis/change_health/service.py b/packages/core/src/repowise/core/analysis/change_health/service.py
index c83336785..d0f6cb086 100644
--- a/packages/core/src/repowise/core/analysis/change_health/service.py
+++ b/packages/core/src/repowise/core/analysis/change_health/service.py
@@ -18,6 +18,7 @@ from ...support_paths import TEMPLATE_EXTENSIONS, is_doc_or_config_path
from ...test_paths import is_test_related_path
from ..finding_registry import excluded_types, gate_for, is_served, language_label
from ..health import HEALTH_ANALYZER_VERSION, HealthFindingData
+from ..health.biomarker_labels import biomarker_label
from ..health.perf.causal import PERFORMANCE_MODEL_VERSION
from ..health.scoring import ADVISORY_DIMENSION, is_advisory
from .analyzer import RevisionAnalysis, RevisionHealthAnalyzer, language_for, language_of
@@ -361,7 +362,7 @@ class ChangeHealthDeltaService:
symbol=head.function_name,
line_start=head.line_start,
line_end=head.line_end,
- reason=head.reason or str(head.biomarker_type).replace("_", " "),
+ reason=head.reason or biomarker_label(str(head.biomarker_type)),
attribution_basis=attribution.basis,
attribution_confidence=attribution.confidence,
attribution_detail=attribution.detail,
diff --git a/packages/core/src/repowise/core/analysis/health/biomarker_labels.py b/packages/core/src/repowise/core/analysis/health/biomarker_labels.py
index 585655e47..805cecb93 100644
--- a/packages/core/src/repowise/core/analysis/health/biomarker_labels.py
+++ b/packages/core/src/repowise/core/analysis/health/biomarker_labels.py
@@ -11,19 +11,19 @@ from .biomarker_names import canonical_biomarker
BIOMARKER_LABELS: dict[str, str] = {
"brain_method": "Brain method",
- "nested_complexity": "Nested complexity",
+ "nested_complexity": "Deep nesting",
"repeated_nesting": "Repeated nesting",
"complex_method": "Complex method",
- "large_method": "Large method",
+ "large_method": "Long function",
"primitive_obsession": "Long parameter list",
"dry_violation": "DRY violation",
"untested_hotspot": "Untested hotspot",
"coverage_gap": "Coverage gap",
"coverage_gradient": "Coverage gradient",
- "developer_congestion": "Developer congestion",
- "knowledge_loss": "Knowledge loss",
+ "developer_congestion": "Many authors",
+ "knowledge_loss": "Fading ownership",
"hidden_coupling": "Hidden coupling",
- "complex_conditional": "Complex conditional",
+ "complex_conditional": "Compound condition",
"function_hotspot": "Function hotspot",
"code_age_volatility": "Code age volatility",
"low_cohesion": "Low cohesion",
@@ -67,3 +67,11 @@ def biomarker_label(name: str) -> str:
"""The glossary label; an id it does not know reads with spaces for underscores."""
name = canonical_biomarker(name)
return BIOMARKER_LABELS.get(name) or name.replace("_", " ")
+
+
+def biomarker_phrase(name: str) -> str:
+ """The label mid-sentence: ``Deep nesting`` reads ``deep nesting``, ``DRY violation`` stays."""
+ label = biomarker_label(name)
+ if len(label) > 1 and label[0].isupper() and label[1].islower():
+ return label[0].lower() + label[1:]
+ return label
diff --git a/packages/core/src/repowise/core/analysis/health/biomarkers/complex_conditional.py b/packages/core/src/repowise/core/analysis/health/biomarkers/complex_conditional.py
index 657cf178f..bc08a31af 100644
--- a/packages/core/src/repowise/core/analysis/health/biomarkers/complex_conditional.py
+++ b/packages/core/src/repowise/core/analysis/health/biomarkers/complex_conditional.py
@@ -1,4 +1,4 @@
-"""Complex Conditional — compound boolean expressions inside one branch.
+"""Compound condition — compound boolean expressions inside one branch.
Flags ``if`` / ``while`` / ``for`` / ternary / case guards whose
condition is glued together from three or more boolean operators
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 042d2184b..2b860878b 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
@@ -1,4 +1,4 @@
-"""Developer Congestion — too many hands on a single file.
+"""Many authors — too many hands on a single file.
When a file has a large contributor count over a 90-day window and is
also a hotspot, coordination cost explodes. This pattern is strongly
diff --git a/packages/core/src/repowise/core/analysis/health/biomarkers/knowledge_loss.py b/packages/core/src/repowise/core/analysis/health/biomarkers/knowledge_loss.py
index 8ac77554c..0e0b4bd4b 100644
--- a/packages/core/src/repowise/core/analysis/health/biomarkers/knowledge_loss.py
+++ b/packages/core/src/repowise/core/analysis/health/biomarkers/knowledge_loss.py
@@ -1,4 +1,4 @@
-"""Knowledge Loss — the primary owner is gone or barely present.
+"""Fading ownership — the primary owner is gone or barely present.
Bus-factor risk: the person who wrote most of this file no longer
contributes. When the primary owner of a hotspot is also the only deep
@@ -16,7 +16,7 @@ Fires when:
The activity gate is what makes this signal point the right way: an
abandoned-but-stable file is *low* risk (the survivor effect — code
-nobody touches doesn't break), so knowledge loss only matters while the
+nobody touches doesn't break), so fading ownership only matters while the
code is live and the lost author's intent is still being edited around.
Severity grades on whether the file is also a hotspot.
diff --git a/packages/core/src/repowise/core/analysis/health/biomarkers/large_method.py b/packages/core/src/repowise/core/analysis/health/biomarkers/large_method.py
index c49c1a88b..115822df5 100644
--- a/packages/core/src/repowise/core/analysis/health/biomarkers/large_method.py
+++ b/packages/core/src/repowise/core/analysis/health/biomarkers/large_method.py
@@ -1,4 +1,4 @@
-"""Large Method — function bodies that exceed a healthy line budget.
+"""Long function — function bodies that exceed a healthy line budget.
Counts lines of code, JSX markup lines excluded, once the judged CCN shows some
branching: a long flat body (a data literal, a dispatch of one-line arms) is
diff --git a/packages/core/src/repowise/core/analysis/health/biomarkers/nested_complexity.py b/packages/core/src/repowise/core/analysis/health/biomarkers/nested_complexity.py
index e8826c0b4..218ddc6bd 100644
--- a/packages/core/src/repowise/core/analysis/health/biomarkers/nested_complexity.py
+++ b/packages/core/src/repowise/core/analysis/health/biomarkers/nested_complexity.py
@@ -1,4 +1,4 @@
-"""Nested Complexity — deeply indented control flow.
+"""Deep nesting — deeply indented control flow.
Flags functions whose maximum nesting depth exceeds 4. Deep nesting is
strongly correlated with defect density in published studies.
diff --git a/packages/core/src/repowise/core/analysis/health/fix_first/text.py b/packages/core/src/repowise/core/analysis/health/fix_first/text.py
index 803857e18..4b9ffec9d 100644
--- a/packages/core/src/repowise/core/analysis/health/fix_first/text.py
+++ b/packages/core/src/repowise/core/analysis/health/fix_first/text.py
@@ -295,7 +295,7 @@ HISTORY_LABEL: dict[str, str] = {
"hidden_coupling": "hidden coupling",
"churn_risk": "churn",
"ownership_risk": "ownership",
- "knowledge_loss": "knowledge loss",
+ "knowledge_loss": "fading ownership",
"developer_congestion": "many hands",
"prior_defect": "past bugs",
"function_hotspot": "keeps changing",
diff --git a/packages/server/src/repowise/server/chat_suggestions.py b/packages/server/src/repowise/server/chat_suggestions.py
index e878fdb53..72704159e 100644
--- a/packages/server/src/repowise/server/chat_suggestions.py
+++ b/packages/server/src/repowise/server/chat_suggestions.py
@@ -17,6 +17,8 @@ from __future__ import annotations
from collections.abc import Callable, Mapping, Sequence
from typing import TYPE_CHECKING, Any
+from repowise.core.analysis.health.biomarker_labels import biomarker_phrase
+
if TYPE_CHECKING:
from repowise.server.chat_datasets import Dataset
@@ -131,7 +133,7 @@ def _from_get_risk(target: str, result: Mapping[str, Any]) -> list[dict[str, Any
where = f" in {function}" if isinstance(function, str) and function else f" in {name}"
out.append(
_suggestion(
- f"Explain the {_humanize(kind)} finding{where}", "page", "get_health"
+ f"Explain the {biomarker_phrase(kind)} finding{where}", "page", "get_health"
)
)
@@ -177,7 +179,7 @@ def _from_get_health(target: str, result: Mapping[str, Any]) -> list[dict[str, A
if isinstance(kind, str) and kind:
out.append(
_suggestion(
- f"Explain the {_humanize(kind)} finding{where}", "page", "get_health"
+ f"Explain the {biomarker_phrase(kind)} finding{where}", "page", "get_health"
)
)
diff --git a/packages/ui/__tests__/health/health-file-drawer.test.tsx b/packages/ui/__tests__/health/health-file-drawer.test.tsx
index 7f47538cb..ffc5cb1f0 100644
--- a/packages/ui/__tests__/health/health-file-drawer.test.tsx
+++ b/packages/ui/__tests__/health/health-file-drawer.test.tsx
@@ -220,7 +220,7 @@ describe("HealthFileDrawer finding grouping", () => {
/>,
);
openSection(/Other issues/);
- for (const label of [/Nested complexity · across the file/i, /Brain method · across the file/i]) {
+ for (const label of [/Deep nesting · across the file/i, /Brain method · across the file/i]) {
expect(within(screen.getByRole("button", { name: label })).queryByText("at limit"))
.not.toBeInTheDocument();
}
diff --git a/packages/ui/__tests__/health/legacy-biomarker-label.test.ts b/packages/ui/__tests__/health/legacy-biomarker-label.test.ts
new file mode 100644
index 000000000..9bfe8e87d
--- /dev/null
+++ b/packages/ui/__tests__/health/legacy-biomarker-label.test.ts
@@ -0,0 +1,10 @@
+import { describe, expect, it } from "vitest";
+import { biomarkerLabel } from "../../src/health/biomarker-glossary";
+import { humanizeBiomarker } from "../../src/refactoring/opportunity";
+
+describe("renamed biomarker ids", () => {
+ it("label a row stored under an old id with the current name", () => {
+ expect(biomarkerLabel("bumpy_road")).toBe("Repeated nesting");
+ expect(humanizeBiomarker("bumpy_road")).toBe("repeated nesting");
+ });
+});
diff --git a/packages/ui/__tests__/refactoring/opportunity-lifecycle.test.tsx b/packages/ui/__tests__/refactoring/opportunity-lifecycle.test.tsx
index a916e6b1f..778b76ed0 100644
--- a/packages/ui/__tests__/refactoring/opportunity-lifecycle.test.tsx
+++ b/packages/ui/__tests__/refactoring/opportunity-lifecycle.test.tsx
@@ -53,7 +53,7 @@ describe("OpportunityRows", () => {
expect(screen.getByText("packages/core/src/big.py")).toBeTruthy();
expect(screen.getByText("3 steps, 2 mechanical")).toBeTruthy();
// The lead cause, in words, not a token.
- expect(screen.getByText(/Split File, against nested complexity/)).toBeTruthy();
+ expect(screen.getByText(/Split File, against deep nesting/)).toBeTruthy();
});
it("keeps addresses_primary_problem in three states", () => {
diff --git a/packages/ui/src/health/ai-prompts/refactoring-prompts.ts b/packages/ui/src/health/ai-prompts/refactoring-prompts.ts
index 9ac5f9e3e..2ef33a1d5 100644
--- a/packages/ui/src/health/ai-prompts/refactoring-prompts.ts
+++ b/packages/ui/src/health/ai-prompts/refactoring-prompts.ts
@@ -7,6 +7,7 @@ import type {
} from "@repowise-dev/types/refactoring";
import { planBlurb, typeMeta } from "../../refactoring/meta";
+import { humanizeBiomarker } from "../../refactoring/opportunity";
import { blastFiles } from "../../refactoring/types";
import {
LINE_RULE_TEXT,
@@ -206,10 +207,10 @@ export interface BuildRefactoringOpportunityPromptOptions {
function stepApplicabilityLine(step: OpportunityStep): string {
const classification =
step.applicability.classification === "mechanical" ? "Mechanical" : "Judgment";
- const reasons = step.applicability.reasons.map((r) => r.replace(/_/g, " ")).join("; ");
+ const reasons = step.applicability.reasons.map(humanizeBiomarker).join("; ");
const unknowns = step.applicability.unknowns.length
? ` Not established: ${step.applicability.unknowns
- .map((u) => u.replace(/_/g, " "))
+ .map(humanizeBiomarker)
.join(", ")}.`
: "";
return `${classification}${reasons ? ` — ${reasons}` : ""}.${unknowns}`;
@@ -352,7 +353,7 @@ function opportunityFacts(opportunity: RefactoringOpportunityDetailResolved): st
`Opportunity: \`${opportunity.opportunity_id}\``,
`File: \`${opportunity.file_path}\``,
opportunity.lead_biomarker
- ? `Leading cause: ${opportunity.lead_biomarker.replace(/_/g, " ")}.`
+ ? `Leading cause: ${humanizeBiomarker(opportunity.lead_biomarker)}.`
: null,
`${opportunity.step_count} step${pluralS(opportunity.step_count)}: ${opportunity.mechanical_steps} mechanical, ${opportunity.judgment_steps} judgment.`,
opportunity.recoverable_health > 0
diff --git a/packages/ui/src/health/biomarker-glossary.ts b/packages/ui/src/health/biomarker-glossary.ts
index d81ba246c..182c0b27f 100644
--- a/packages/ui/src/health/biomarker-glossary.ts
+++ b/packages/ui/src/health/biomarker-glossary.ts
@@ -9,7 +9,7 @@
* map, so agent prompts and the page name a marker the same way.
*/
-import { BIOMARKER_LABELS } from "./generated/biomarker-labels";
+import { BIOMARKER_LABELS, canonicalBiomarker } from "./generated/biomarker-labels";
export type BiomarkerCategory =
| "structural_complexity"
@@ -366,7 +366,7 @@ export const BIOMARKER_GLOSSARY: Record<string, BiomarkerInfo> = {
export function biomarkerInfo(name: string): BiomarkerInfo {
return (
- BIOMARKER_GLOSSARY[name] ?? {
+ BIOMARKER_GLOSSARY[canonicalBiomarker(name)] ?? {
label: name.replace(/_/g, " "),
category: "size_and_complexity",
description: "",
diff --git a/packages/ui/src/health/generated/biomarker-labels.ts b/packages/ui/src/health/generated/biomarker-labels.ts
index af7b524b1..5cef4b1d0 100644
--- a/packages/ui/src/health/generated/biomarker-labels.ts
+++ b/packages/ui/src/health/generated/biomarker-labels.ts
@@ -5,19 +5,19 @@
export const BIOMARKER_LABELS = {
brain_method: "Brain method",
- nested_complexity: "Nested complexity",
+ nested_complexity: "Deep nesting",
repeated_nesting: "Repeated nesting",
complex_method: "Complex method",
- large_method: "Large method",
+ large_method: "Long function",
primitive_obsession: "Long parameter list",
dry_violation: "DRY violation",
untested_hotspot: "Untested hotspot",
coverage_gap: "Coverage gap",
coverage_gradient: "Coverage gradient",
- developer_congestion: "Developer congestion",
- knowledge_loss: "Knowledge loss",
+ developer_congestion: "Many authors",
+ knowledge_loss: "Fading ownership",
hidden_coupling: "Hidden coupling",
- complex_conditional: "Complex conditional",
+ complex_conditional: "Compound condition",
function_hotspot: "Function hotspot",
code_age_volatility: "Code age volatility",
low_cohesion: "Low cohesion",
@@ -55,3 +55,12 @@ export const BIOMARKER_LABELS = {
sql_update_delete_without_where: "UPDATE/DELETE without WHERE",
sql_cartesian_join: "Cartesian join",
} as const;
+
+/** Renamed ids (old -> current), so rows stored under an old id get the current label. */
+export const LEGACY_BIOMARKER_NAMES: Readonly<Record<string, string>> = {
+ bumpy_road: "repeated_nesting",
+};
+
+export function canonicalBiomarker(name: string): string {
+ return LEGACY_BIOMARKER_NAMES[name] ?? name;
+}
diff --git a/packages/ui/src/refactoring/opportunity.ts b/packages/ui/src/refactoring/opportunity.ts
index c0b0c9937..b4d4ce41c 100644
--- a/packages/ui/src/refactoring/opportunity.ts
+++ b/packages/ui/src/refactoring/opportunity.ts
@@ -13,6 +13,7 @@ import type {
RefactoringOpportunity,
} from "@repowise-dev/types/refactoring";
+import { BIOMARKER_LABELS, canonicalBiomarker } from "../health/generated/biomarker-labels";
import { STRUCTURAL_TYPES } from "./types";
import { TYPE_ORDER, typeMeta } from "./meta";
@@ -54,9 +55,11 @@ export function stepSummary(opportunity: RefactoringOpportunity): string {
return `${steps}, ${opportunity.mechanical_steps} mechanical`;
}
-/** `nested_complexity` -> `nested complexity`. */
+/** `nested_complexity` -> `deep nesting`: the glossary label mid-sentence, else the token spaced. */
export function humanizeBiomarker(token: string): string {
- return token.replace(/_/g, " ").trim();
+ const label = (BIOMARKER_LABELS as Record<string, string>)[canonicalBiomarker(token)];
+ if (!label) return token.replace(/_/g, " ").trim();
+ return /^[A-Z][a-z]/.test(label) ? label.charAt(0).toLowerCase() + label.slice(1) : label;
}
/** One sentence naming what the opportunity is, for a row's second line. */
diff --git a/scripts/generate_biomarker_labels.py b/scripts/generate_biomarker_labels.py
index f4239e86b..80374cf76 100644
--- a/scripts/generate_biomarker_labels.py
+++ b/scripts/generate_biomarker_labels.py
@@ -25,9 +25,19 @@ _HEADER = """// Generated from repowise.core.analysis.health.biomarker_labels. D
"""
-def render(labels: dict[str, str]) -> str:
- rows = "".join(f" {name}: {json.dumps(label, ensure_ascii=False)},\n" for name, label in labels.items())
- return f"{_HEADER}\nexport const BIOMARKER_LABELS = {{\n{rows}}} as const;\n"
+def _rows(mapping: dict[str, str]) -> str:
+ return "".join(f" {key}: {json.dumps(value, ensure_ascii=False)},\n" for key, value in mapping.items())
+
+
+def render(labels: dict[str, str], legacy: dict[str, str] | None = None) -> str:
+ legacy = _legacy() if legacy is None else legacy
+ return (
+ f"{_HEADER}\nexport const BIOMARKER_LABELS = {{\n{_rows(labels)}}} as const;\n"
+ "\n/** Renamed ids (old -> current), so rows stored under an old id get the current label. */\n"
+ f"export const LEGACY_BIOMARKER_NAMES: Readonly<Record<string, string>> = {{\n{_rows(legacy)}}};\n"
+ "\nexport function canonicalBiomarker(name: string): string {\n"
+ " return LEGACY_BIOMARKER_NAMES[name] ?? name;\n}\n"
+ )
def _labels() -> dict[str, str]:
@@ -36,6 +46,12 @@ def _labels() -> dict[str, str]:
return BIOMARKER_LABELS
+def _legacy() -> dict[str, str]:
+ from repowise.core.analysis.health.biomarker_names import LEGACY_BIOMARKER_NAMES
+
+ return LEGACY_BIOMARKER_NAMES
+
+
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--check", action="store_true", help="Fail if the file is stale.")
diff --git a/tests/unit/health/test_plain_marker_labels.py b/tests/unit/health/test_plain_marker_labels.py
new file mode 100644
index 000000000..3eed848ba
--- /dev/null
+++ b/tests/unit/health/test_plain_marker_labels.py
@@ -0,0 +1,34 @@
+"""Marker labels use plain engineering terms."""
+
+from __future__ import annotations
+
+import pytest
+
+from repowise.core.analysis.health.biomarker_labels import biomarker_label, biomarker_phrase
+
+
+ ("marker", "label"),
+ [
+ ("nested_complexity", "Deep nesting"),
+ ("large_method", "Long function"),
+ ("complex_conditional", "Compound condition"),
+ ("developer_congestion", "Many authors"),
+ ("knowledge_loss", "Fading ownership"),
+ ],
+)
+def test_marker_label(marker: str, label: str) -> None:
+ assert biomarker_label(marker) == label
+
+
+ ("marker", "phrase"),
+ [
+ ("nested_complexity", "deep nesting"),
+ ("dry_violation", "DRY violation"),
+ ("io_in_loop", "I/O in loop"),
+ ("sql_select_star", "SELECT * in a view"),
+ ],
+)
+def test_marker_phrase_reads_mid_sentence(marker: str, phrase: str) -> None:
+ assert biomarker_phrase(marker) == phrase
diff --git a/tests/unit/server/test_chat_suggestions.py b/tests/unit/server/test_chat_suggestions.py
index 80e909769..f74efe322 100644
--- a/tests/unit/server/test_chat_suggestions.py
+++ b/tests/unit/server/test_chat_suggestions.py
@@ -71,7 +71,7 @@ def test_risk_names_a_biomarker_and_the_function_it_sits_in():
}
}
}
- assert "Explain the nested complexity finding in _db_messages_to_llm_format" in _texts(
+ assert "Explain the deep nesting finding in _db_messages_to_llm_format" in _texts(
page_suggestions("get_risk", "src/a.py", result)
)