Skip to content

fix: align CLI and HTML score color thresholds to prevent green/yellow inconsistency at 0.80-0.85 boundary #300

@decko

Description

@decko

Finding

File: src/raki/report/html_report.py:396 / src/raki/report/cli_summary.py:82

After PR #297, html_color_for_score() uses ZONE_THRESHOLDS where green >= 0.85, but cli_summary.color_for_score() (line 82) still uses the old green >= 0.80 / amber >= 0.60 constants. A score of 0.82 now renders as green in terminal output but yellow in the HTML report — a user-visible inconsistency between the two rendering paths.

The old HTML docstring explicitly stated "Matches the CLI color_for_score semantics", so this drift is likely unintentional.

Suggested Fix

Option A — share the threshold source:

  • Import ZONE_THRESHOLDS in cli_summary.py and update color_for_score() to use ZONE_THRESHOLDS["score"]["green"] / ZONE_THRESHOLDS["score"]["amber"].

Option B — revert HTML threshold:

  • If 0.85 was not an intentional product decision, set ZONE_THRESHOLDS["score"]["green"] = 0.80 to restore parity.

Option C — document the divergence:

  • Add a code comment in both files explaining the intentional difference if it is a deliberate product choice.

Context

Found during review of PR #297 (ticket #287 — fix: severity distribution chart and zone coloring in score cards). Did not block the PR.

Acceptance criteria

  • CLI color_for_score() and HTML html_color_for_score() use the same thresholds
  • CLI imports thresholds from ZONE_THRESHOLDS in html_report.py (single source of truth)
  • A score of 0.82 renders the same color in both CLI and HTML
  • Existing color behavior for cost/duration metrics unchanged
  • Tests verify CLI and HTML agree for boundary values (0.60, 0.80, 0.85)
  • Towncrier fragment (changes/300.fix)

Plan

  1. Extract ZONE_THRESHOLDS to a shared location (or import from html_report.py into cli_summary.py)
  2. Update cli_summary.color_for_score() to use ZONE_THRESHOLDS["score"]["green"] and ZONE_THRESHOLDS["score"]["amber"]
  3. Add tests comparing CLI and HTML output for boundary scores
  4. Towncrier fragment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions