Skip to content

feat(health): one band vocabulary, and counts for the CLI and MCP - #2180

Merged
swati510 merged 2 commits into
mainfrom
feat/health-band-vocabulary
Sep 10, 2026
Merged

swati510 merged 2 commits into
mainfrom
feat/health-band-vocabulary

Conversation

@RaghavChamadiya

Copy link
Copy Markdown
Member

Summary

  • One band vocabulary. Six competing scales collapse into five absolute bands — Excellent 8.5+, Good 7.0–8.5, Fair 5.5–7.0, Needs work 4.0–5.5, At risk below 4.0 — defined once per language and locked by a parity test on each side. No score moves; only the word attached to it.
  • counts reaches repowise health and get_health, matching what scope already had. An agent asking whether a repository's code is getting better could previously only get the churn-contaminated number.
  • Every figure now says which reading it is on, and every surface that paints a score paints it on the same ramp.

Why

A score meant different things depending on where you read it. The canonical three bands called a 6.9 Warning; the workspace repo list called the same number Good on a five-step ladder of its own; the file-table pills ran a four-step ramp agreeing with neither; two 0-100 surfaces had a third and fourth set of cutoffs; and two scatter charts plus five colour tables carried inline copies that had drifted. The same file could read amber on a treemap tile and green in the tooltip attached to it.

Bands are absolute rather than percentile, so a score means the same thing behind a firewall as against a public corpus. Green starts at 7.0 because a 7 is not a warning. 4.0 keeps its long-standing meaning, so no repo's most severe classification changes.

HEALTHY_MIN was doing two jobs — naming a band, and being the score a refactoring's leverage is measured against. It keeps the second as TARGET_SCORE at the same value, deliberately not a band edge, asserted as such.

Notable fixes found in review

  • only=["kpis"], counts="code_shape" returned the projected score with the reading stripped by the projection. It survives now, but only once it is not the default.
  • Trends and the two ranked queues are built from the calibrated score and cannot be projected; a code-shape response names them in counts_not_applied_to.
  • The five detail-lookup paths (finding_id / plan_id / opportunity_id) bypassed the controls entirely and answered about a calibrated row under a flag asking for the other reading.
  • A misspelled scope / counts fell back silently over MCP; now named in ignored_arguments.
  • The SVG export painted Fair amber while the canvas it was exporting painted it gold. The coupling legend still read healthy/warning/alert over dots drawn on five bands, leaving a needs-work node unexplained. The treemap gave Excellent and Good one green on tiles carrying no word.
  • A server predating the five bands made the distribution bar report 128 files with none in any band.

Test Plan

  • Tests pass — packages/ui 1678, packages/web 84, packages/types 142, packages/api-client 63, vscode webview 45; Python server / CLI / health / generation scope green, with only the failures that are already red on main
  • Lint passes (ruff check, npm run lint)
  • Type-check passes (npm run type-check)
  • Web build passes (npm run build)

Verified that no score changes for any repo — the band cutoffs are referenced only inside band_for / bandForScore, and TARGET_SCORE is pinned at 8.0 with a test asserting it is not a band edge.

Checklist

  • My code follows the project's code style
  • I have added tests for new functionality
  • All existing tests still pass
  • I have updated documentation if needed

A score meant six different things depending on where you read it. The
canonical three bands said a 6.9 was Warning; the workspace repo list called
the same number Good on a five-step ladder of its own; the file-table pills ran
a four-step ramp that agreed with neither; two 0-100 surfaces had a third and
fourth set of cutoffs; and two scatter charts and five colour tables carried
inline copies that had drifted apart. The same file could read amber on a
treemap tile and green in the tooltip attached to it.

There is now one scale, defined once per language and locked by a parity test:
Excellent 8.5+, Good 7.0-8.5, Fair 5.5-7.0, Needs work 4.0-5.5, At risk below
4.0. Absolute rather than percentile, so a score means the same thing behind a
firewall as against a public corpus. Excellent and Good share one green and are
told apart by the word. 4.0 keeps its long-standing meaning, so no repo's most
severe classification changes.

No score moves. Only the word attached to it.

The canvas surfaces cannot separate five bands by word, so the node ramp gains
a fifth token and the zoom palette a fourth; without that a 6.0 file read gold
in the detail panel and amber on the card behind it.

HEALTHY_MIN was doing two jobs. It named a band, and it was the score a
refactoring's leverage is measured against. It keeps the second job as
TARGET_SCORE at the same value, deliberately not a band edge, asserted as such.

Separately, `counts` now reaches `repowise health` and `get_health`, matching
what `scope` already had. An agent asking whether a repository's code is
getting better could only get the churn-contaminated number. A target the
projection cannot read is reported as `not_measured` rather than `not_indexed`,
which would have sent the caller to run an update that changes nothing.
…er surface

Review of the band vocabulary change found the same defect in three places: a
figure that had been projected, next to nothing saying so.

`only=["kpis"], counts="code_shape"` returned the projected score with the
reading stripped by the projection — the exact failure the echo was added to
prevent. It survives now, but only once it is not the default, so an ordinary
`only` call does not grow three empty keys. Trends and the two ranked queues
are built from the calibrated score and cannot be projected at all; a
code-shape response names them rather than letting a reader assume the
headline projected everything beside it. A lookup by id answers about one
stored row, so the five detail paths report the controls as inapplicable
instead of silently returning a calibrated row under a flag that asked for the
other reading. A misspelled control is named rather than quietly defaulted,
and an explicit null is not a misspelling.

The canvas surfaces had the same split brain the bands were meant to end. The
SVG export painted Fair amber while the canvas it was exporting painted it
gold; the coupling legend still read healthy/warning/alert in three rows over
dots drawn on five bands, so a needs-work node had no entry at all; and the
treemap gave Excellent and Good one green on tiles that carry no word. All
three now share the one five-value ramp.

A server predating the five bands made the distribution bar report 128 files
with none in any band. That is a confident false statement, so it falls
through to the unknown state. The CLI reported `unscored_files: 0` always,
because it scores live and the split is never missing; a constant reading as
"every file measured" is worse than no field.

The share test passed under three different implementations, so it gets the
row that discriminates. The exporter's new branch, the legacy-band guard, the
CLI's distribution line and trend warning, badge hex coverage, and the range
and colour tables all get the coverage they were shipped without.

MCP_TOOLS.md told agents get_health reports under `unknown_only_keys` in a
list shape while it emits a flat map under `ignored_arguments`, documented
neither control, and `repo` had lost its docstring entry while the parameter
remained.
@swati510
swati510 merged commit e88db81 into main Sep 10, 2026
8 checks passed
@swati510
swati510 deleted the feat/health-band-vocabulary branch September 10, 2026 05:23
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