Skip to content

Commit c795252

Browse files
authored
Merge pull request #15 from mayur-tolexo/feat/conf-percentage
feat(report): show confidence score % alongside the band
2 parents 070f136 + 8ba3ab2 commit c795252

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

internal/report/report.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func writeRecommendations(b *strings.Builder, recs []model.Recommendation, opts
199199
func writeLegend(b *strings.Builder, opts Options) {
200200
lines := []string{
201201
"CPU/MEM = current → proposed request · SAVINGS = $/mo (↑ grow = reliability, not a saving)",
202-
"CONF = confidence: ▒ low · ▓ med · █ high — grows with data history (tier, window, samples). --explain shows the %.",
202+
"CONF = confidence: ▒ low · ▓ med · █ high + score% — grows with data history (tier, window, samples).",
203203
}
204204
for _, l := range lines {
205205
if opts.Color {
@@ -234,18 +234,20 @@ func savingsCell(rec model.Recommendation) string {
234234
return fmt.Sprintf("%s/mo", formatDollarsAbs(rec.MonthlySavings))
235235
}
236236

237-
// confidenceCell renders the qualitative confidence band with a shaded glyph that reads as a
238-
// fill level even without color. A precise percentage is intentionally omitted here (it implies
239-
// false precision); the number is available under --explain.
237+
// confidenceCell renders the confidence as a shaded band glyph (a fill level readable without
238+
// color) + the band label + the score percent, e.g. "▒ low 31%". The band leads so the column
239+
// scans at a glance; the percent gives the precise score for those who want it.
240240
func confidenceCell(rec model.Recommendation) string {
241+
var glyph, label string
241242
switch rec.Confidence.Band() {
242243
case model.ConfidenceHigh:
243-
return "█ high"
244+
glyph, label = "█", "high"
244245
case model.ConfidenceMedium:
245-
return "▓ med"
246+
glyph, label = "▓", "med"
246247
default:
247-
return "▒ low"
248+
glyph, label = "▒", "low"
248249
}
250+
return fmt.Sprintf("%s %s %d%%", glyph, label, rec.Confidence.Percent())
249251
}
250252

251253
// JSON renders a stable machine-readable schema of the scan result.

internal/report/report_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ func TestTableRecommendationRow(t *testing.T) {
172172
if !strings.Contains(out, "$210/mo") {
173173
t.Errorf("missing savings\n--- got ---\n%s", out)
174174
}
175-
if !strings.Contains(out, "█ high") {
176-
t.Errorf("missing confidence band\n--- got ---\n%s", out)
175+
if !strings.Contains(out, "█ high 96%") {
176+
t.Errorf("missing confidence band + percent\n--- got ---\n%s", out)
177177
}
178178
// Evidence is indented under the row with the └ marker.
179179
if !strings.Contains(out, " └ P95 cpu 280m") {

0 commit comments

Comments
 (0)