Class: SkillBench::Services::SummaryFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/skill_bench/services/summary_formatter.rb

Overview

Builds a compact JSON summary of a batch run for CI gating.

Surfaces the aggregate pass/fail counts plus rolled-up token and cost usage and the single worst skill-vs-baseline delta across the batch, so a CI job can gate on (and archive) one machine-readable artifact.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aggregate) ⇒ SummaryFormatter

Returns a new instance of SummaryFormatter.

Parameters:

  • aggregate (Hash)

    Aggregate envelope with :results and :summary.



22
23
24
25
# File 'lib/skill_bench/services/summary_formatter.rb', line 22

def initialize(aggregate)
  @results = aggregate[:results] || []
  @summary = aggregate[:summary] || {}
end

Class Method Details

.format(aggregate) ⇒ String

Format an aggregate batch envelope as a pretty JSON summary string.

Parameters:

  • aggregate (Hash)

    Aggregate envelope with :results and :summary.

Returns:

  • (String)

    Pretty-printed JSON summary.



17
18
19
# File 'lib/skill_bench/services/summary_formatter.rb', line 17

def self.format(aggregate)
  new(aggregate).format
end

Instance Method Details

#formatString

Builds the JSON summary document.

Returns:

  • (String)

    Pretty-printed JSON summary.



30
31
32
33
34
35
36
37
38
39
# File 'lib/skill_bench/services/summary_formatter.rb', line 30

def format
  JSON.pretty_generate(
    passed: summary[:passed],
    failed: summary[:failed],
    total: summary[:total],
    tokens: total_tokens,
    cost: total_cost,
    worst_delta: worst_delta
  )
end