Skip to content

feat(health): stop alarming for a fall the code did not cause - #2171

Merged
swati510 merged 1 commit into
mainfrom
feat/health-decline-attribution
Sep 8, 2026
Merged

feat(health): stop alarming for a fall the code did not cause#2171
swati510 merged 1 commit into
mainfrom
feat/health-decline-attribution

Conversation

@RaghavChamadiya

Copy link
Copy Markdown
Member

About half of a file's code-health deduction comes from git-derived markers —
churn, co-change, ownership, prior fixes — which rise as a file is worked on. So
a week of refactoring dropped the headline and the trend printed "Declining
health."
in error red at the person who did the work. That is the reading this
removes.

A decline that names its cause

A fall now comes back as a third kind, history_drag, when the composite fell,
history is the driver, and history is the only half that moved down. It keeps
every number and swaps the reading:

Code health dropped 0.60 points vs. snapshot 5 ago (7.60 → 7.00), and code
shape improved 0.30 over the same window. Change history is the only half that
moved down, and no edit to these files settles it.

It takes the neutral treatment history findings already have in the file drawer
rather than the error colour, in the web view and the CLI alike.

Both halves are checked, not the driver alone. driver names the half that
moved furthest, which is not the half that moved down: the halves are deduction
means and the score is a mean of clamped scores, so on a repo with floored files
they can disagree about direction. Muting the alarm on that basis would have
blamed a fall on a half that had just improved.

Maintainability is watched

It is the one figure that is pure code shape, nothing alerted on it, and its
fall is the one that always deserves the alarm. It has no halves to split, so it
never softens. Both detectors now run over the three metrics uniformly, skipping
any a snapshot never recorded rather than reading a missing figure as zero, and
the composite is named "Code health" in their messages instead of "Average
Health".

The alert lead no longer names a figure. Three different things raise this alert
and the message says which, so a fixed "Declining health." above "Maintainability
dropped 0.60 points" contradicted itself.

The trend leads with the number a refactor moves

Maintainability is the heaviest line; drawing the composite loudest emphasised
the number that misleads. That left the history band looking as though it bounded
maintainability, so the band's edges are stroked in the code-health colour it
actually belongs to — which also states what the band means, since its upper edge
is where the score would sit with no history against it.

Verification

  • 54 Python trend and projection tests, 21 UI tests, root npm run type-check
    and ruff check all green after rebasing onto the current headline work,
    which this overlapped on the trend view.
  • Alert rows read out of the rendered page in light and dark, with all three
    kinds side by side.

About half of the code-health score comes from git history markers, which
rise as a file is worked on. So a week of refactoring dropped the headline and
the trend printed "Declining health." in error red at the person who did the
work. That is the reading this change removes.

A decline now carries a third kind, history_drag, when the composite fell,
history is the driver, and history is the only half that moved down. It keeps
every number and swaps the reading: "Code health dropped 0.60 points (7.60 →
7.00), and code shape improved 0.30 over the same window. Change history is
the only half that moved down, and no edit to these files settles it." It
takes the neutral treatment history findings already have in the drawer, not
the error colour, in the web view and the CLI alike.

Both halves are checked rather than the driver alone. The driver names the
half that moved furthest, which is not the half that moved down: the halves
are deduction means and the score is a mean of clamped scores, so on a repo
with floored files they can disagree about direction. Muting the alarm on
that basis would have blamed a fall on a half that had just improved.

Maintainability is watched now. It is the one figure that is pure code shape,
nothing alerted on it, and its fall is the one that always deserves the alarm.
It has no halves to split, so it never softens. Alerts run over the three
metrics uniformly, skipping any a snapshot never recorded rather than reading
a missing figure as zero, and the composite is named "Code health" in their
messages instead of "Average Health".

The alert lead no longer names a figure. Three different things raise this
alert and the message says which, so a fixed "Declining health." above
"Maintainability dropped 0.60 points" contradicted itself.

The trend chart leads with maintainability. It is the series that answers "is
my code getting better", and drawing the composite loudest emphasised the
number that misleads. Making it the heaviest line left the history band
looking as though it bounded maintainability, so the band's edges are stroked
in the code-health colour it actually belongs to.
@swati510
swati510 merged commit ce350d1 into main Sep 8, 2026
9 checks passed
@swati510
swati510 deleted the feat/health-decline-attribution branch September 8, 2026 17:54
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