feat(health): report production or all code, and name a cause you can fix - #2154
Merged
Conversation
|
🔍 2 things to check
✅ Health gate: passed 📊 See the full report for this PR |
… 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
force-pushed
the
feat/health-scope-surfaces
branch
from
September 7, 2026 13:07
63f67a5 to
8249fbf
Compare
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
approved these changes
Sep 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_firstcould name a file whose entire deficit is git history — an instruction with nothing to act on.What changed
scope=all|productionon the health overview, files, map, trend and work-queue routes, onget_health, and onrepowise health. The default staysall: 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.driver,structure_deltaandhistory_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_firstnames a cause an edit can remove, picking the highest-leverage file that has one. History-derived leads move to awatchfield that says plainly there is nothing there to fix.non_code_filesandaverage_health_code_onlyare 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=allreads 7.17 over 3,776 files andscope=productionreads 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.pycovers 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.