Skip to content

Commit 580c0c8

Browse files
committed
+ lemans report: credit in summary
1 parent 9038f85 commit 580c0c8

3 files changed

Lines changed: 22 additions & 6 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## [Unreleased]
22

33
- `lemant report` normalizes metrics (credit, cost, steps, and tokens) within each task individually before combining them in the final report.
4+
- `lemans report`: add credit to summary lines.
45

56
## [1.5.1] - 2026-10-06
67

‎lib/lemans/cli/report.rb‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,19 @@ def stats(group)
292292
totals = self.class.tally(group).merge(cost_usd: group.sum { it[:cost_usd].to_f })
293293
rank = totals[:scored].positive? ? " (#{(100.0 * totals[:solved] / totals[:scored]).round}%)" : ""
294294
"#{totals[:total]} trials: #{totals[:scored]} scored, #{totals[:invalid]} invalid, " \
295-
"#{totals[:solved]} solved#{rank} · $#{format("%.4f", totals[:cost_usd])}#{pass_at_k(group)}"
295+
"#{totals[:solved]} solved#{rank}#{mean_credit(group)} · $#{format("%.4f", totals[:cost_usd])}" \
296+
"#{pass_at_k(group)}"
297+
end
298+
299+
# Each task weighs the same, as in the aggregate view
300+
def mean_credit(group)
301+
return "" unless fractional?
302+
303+
means = group.group_by { it[:task] }.values.filter_map do |rows|
304+
credits = rows.filter_map { it[:credit] }
305+
credits.sum(0.0) / credits.size unless credits.empty?
306+
end
307+
means.empty? ? "" : " · credit #{format("%.2f", means.sum / means.size)}"
296308
end
297309

298310
def pass_at_k(group)

‎test/lemans/cli/report_test.rb‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_the_rows_show_every_trial_and_the_summary_owns_up_to_the_totals
6363
assert_equal "-", invalid[rows.first.index("reward")]
6464
assert_equal "-", invalid[rows.first.index("credit")]
6565
assert_equal "-", invalid[rows.first.index("tokens")]
66-
assert_includes report.summary_lines.join("\n"), "3 trials: 2 scored, 1 invalid, 1 solved (50%)"
66+
assert_includes report.summary_lines.join("\n"), "3 trials: 2 scored, 1 invalid, 1 solved (50%) · credit 0.70"
6767
end
6868
end
6969

@@ -76,6 +76,7 @@ def test_the_credit_column_appears_only_once_a_credit_differs_from_its_reward
7676

7777
refute_includes report.to_rows.first, "credit"
7878
refute_includes Lemans::CLI::Report::Aggregate.new(report, keys: %i[task]).to_rows.first, "credit"
79+
refute_includes report.summary_lines.join, "credit"
7980
assert_includes report.to_csv.lines.first, "credit"
8081
end
8182
end
@@ -115,16 +116,18 @@ def test_a_sweep_groups_the_summary_per_model_with_short_names
115116
store = Lemans::Stores::FS.new(runs_dir)
116117
store_result(store, trial: "a__1", model: "openrouter/openai/gpt-5.6-luna", reward: 1.0)
117118
store_result(store, trial: "a__2", model: "openrouter/openai/gpt-5.6-luna", reward: 0.0)
118-
store_result(store, trial: "a__3", model: "openrouter/z-ai/glm-5.2", reward: 1.0)
119+
store_result(store, trial: "a__3", model: "openrouter/z-ai/glm-5.2", reward: 0.0, credit: 0.6)
120+
store_result(store, trial: "b__4", task: "b", model: "openrouter/z-ai/glm-5.2", reward: 1.0)
119121

120122
report = Lemans::CLI::Report.load(store)
121123
lines = report.summary_lines
122124

123125
assert_equal 3, lines.size
124-
assert(lines[0..1].any? { it.start_with?("gpt-5.6-luna") && it.include?("1 solved (50%)") })
125-
assert(lines[0..1].any? { it.start_with?("glm-5.2") && it.include?("1 solved (100%)") })
126+
assert(lines[0..1].any? { it.start_with?("gpt-5.6-luna") && it.include?("1 solved (50%) · credit 0.50") })
127+
assert(lines[0..1].any? { it.start_with?("glm-5.2") && it.include?("1 solved (50%) · credit 0.80") })
126128
assert lines.last.start_with?("total")
127-
assert_includes lines.last, "2 solved (67%)"
129+
# Each task weighs the same: a averages 0.53, b 1.0.
130+
assert_includes lines.last, "2 solved (50%) · credit 0.77"
128131
# The table shows the short name; the CSV keeps the full provenance.
129132
assert_includes report.to_rows.flatten, "gpt-5.6-luna"
130133
assert_includes report.to_csv, "openrouter/openai/gpt-5.6-luna"

0 commit comments

Comments
 (0)