Skip to content

feat(health): report production or all code, and name a cause you can fix - #2154

Merged
swati510 merged 2 commits into
mainfrom
feat/health-scope-surfaces
Sep 7, 2026
Merged

feat(health): report production or all code, and name a cause you can fix#2154
swati510 merged 2 commits into
mainfrom
feat/health-scope-surfaces

Conversation

@RaghavChamadiya

Copy link
Copy Markdown
Member

Builds on #2153.

The health surfaces reported one number for the whole repository and called it "Defect risk". There was no way to ask what production code alone scores, a decline could not say which half of the score moved, and fix_first could name a file whose entire deficit is git history — an instruction with nothing to act on.

What changed

  • scope=all|production on the health overview, files, map, trend and work-queue routes, on get_health, and on repowise health. The default stays all: tests score higher than production code, so narrowing lowers every figure without a defect having been found, and a caller should ask for that knowingly.
  • The headline reads "Code health". Higher is better, and nothing prints an inverted copy of it.
  • Trend alerts carry driver, structure_delta and history_delta, so a decline names the half that moved. Metric rows expose both halves and the unclamped score, which is the only number that moves for a file at the floor.
  • fix_first names a cause an edit can remove, picking the highest-leverage file that has one. History-derived leads move to a watch field that says plainly there is nothing there to fix.
  • non_code_files and average_health_code_only are gone; the population they described is no longer scored.

Behaviour

A narrowed response drops what it cannot honestly narrow rather than relabelling it. Snapshots record the production average, so a narrowed trend is weighted the same way as the headline; the hotspot figure, the worst performer and the per-file movement list have no narrowed copy and are omitted. Here, scope=all reads 7.17 over 3,776 files and scope=production reads 6.25 over 2,343.

Verification

Trend and KPI averages agree on a single response under both scopes, which they previously did not. The generated HTTP contract is regenerated. tests/unit/server/mcp/test_health.py covers the scope filter, the distinction between a file dropped by scope and one dropped by the exclude config, and the directive naming an actionable cause.

@repowise-bot

repowise-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

🔍 2 things to check

  1. get_health in .../mcp_server/tool_health.py signature changed. Review 46 callers outside this PR: tests/integration/test_mcp.py::test_mcp_health_accuracy, tests/integration/test_mcp.py::test_mcp_health_churn_complexity, tests/integration/test_mcp.py::test_mcp_health_default_is_lean (+43 more)
  2. Run .../__tests__/health.test.ts, .../health/health-file-drawer.test.tsx, .../src/hosted.fixtures.test.ts (+19 more) first: they import the changed files

⚠️ Health of changed files: 4.8 → 4.7 (-0.1)
🚨 Change risk: high, riskier than 71% of this repo's commits.

✅ Health gate: passed


📊 See the full report for this PR
Your repo map with this PR's blast radius lit up, every caller of the contracts it changes, and health before and after. No sign-in. · ⭐ Star Repowise · 📥 Install bot · Silence on a single PR with [skip repowise] in the title · Per-repo toggle on repowise.dev/settings?tab=bot · Updated 2026-09-07 13:51 UTC (since the last push: health 4.8 to 4.7)

Base automatically changed from feat/health-scoring-scope to main September 7, 2026 12:55
… fix

The health surfaces reported one number for the whole repository and called it
"Defect risk". There was no way to ask what production code alone scores, a
decline could not say which half of the score moved, and fix_first could name a
file whose entire deficit is git history - an instruction with nothing to act
on.

scope=all|production lands on the health overview, files, map, trend and
work-queue routes, on get_health, and on repowise health. The default stays
all: tests score higher than production code, so narrowing lowers every figure
without a defect having been found.

A narrowed response drops what it cannot honestly narrow rather than
relabelling it. Snapshots record the production average, so a narrowed trend is
weighted the same way as the headline; the hotspot figure, the worst performer
and the per-file movement list have no narrowed copy and are omitted.

Trend alerts carry the driver and both halves of the move. Metric rows expose
the two halves and the unclamped score. fix_first picks the highest-leverage
file whose leading cause is code shape, and history-derived leads move to a
watch field. The headline reads "Code health".

non_code_files and average_health_code_only are removed: the population they
described is no longer scored.
@RaghavChamadiya
RaghavChamadiya force-pushed the feat/health-scope-surfaces branch from 63f67a5 to 8249fbf Compare September 7, 2026 13:07
A snapshot only records a hotspot figure for the whole repository, so a
narrowed reading carries none. The sparkline now skips those rather than
holding a type that cannot represent them.
@swati510
swati510 merged commit a92ea0b into main Sep 7, 2026
9 checks passed
@swati510
swati510 deleted the feat/health-scope-surfaces branch September 7, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants