Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixture-backed `evals/skills/refactor-process/basic`: duplicated `OrderProcessor` methods, passing characterization tests, and a condensed `skills/refactor-process/SKILL.md`.
- xAI (Grok) provider: OpenAI-compatible client at `https://api.x.ai/v1/chat/completions`, default model `grok-4`, `skill-bench init --xai`, env `SKILL_BENCH_XAI_API_KEY` or `XAI_API_KEY`.
- Amazon Bedrock provider: Runtime OpenAI-compatible Chat Completions with a Bedrock API key (`AWS_BEARER_TOKEN_BEDROCK` or `SKILL_BENCH_BEDROCK_API_KEY`), default region `us-east-1`, default model `amazon.nova-lite-v1:0`. IAM SigV4 is not included.
- Judge golden trace fixture (`test/fixtures/judge_traces/canonical.json`) and `Judge::Variance` (sample mean/stddev/spread over repeated totals). Verdict math unchanged.

### Documentation
- Align user docs with shipped 1.3.1: OpenRouter and mock in the provider list, Azure env var `SKILL_BENCH_AZURE_OPENAI_API_KEY`, Mistral key via `skill-bench.json` (no env mapping).
Expand Down
12 changes: 3 additions & 9 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@ Do: turn a small set of those evals into fixture-backed tasks with `task.md`, `c

## 2. xAI / Grok provider

No `Clients::Providers` class exists for xAI. The surrounding skill ecosystem already runs on Grok. Pattern to copy: OpenAI-compatible subclass (see Mistral and OpenRouter).

Do not fold Bedrock into this item.
Shipped: `Clients::Providers::Xai`, `skill-bench init --xai`.

## 3. AWS Bedrock provider

Closed issue [#47](https://github.com/igmarin/ruby-skill-bench/issues/47) named Bedrock as the larger follow-up to Mistral. This is not a one-file client: auth, regions, and model IDs differ from the OpenAI-compatible adapters.

Do not start this before OpenRouter (already shipped) is documented and xAI is decided.
Shipped: `Clients::Providers::Bedrock` (Runtime OpenAI-compatible path + Bedrock API key). IAM SigV4 is still deferred.

## 4. Judge reliability

Scores come from an LLM judge (`Evaluation::Runner` → `Judge`) with no golden-trace fixture set and no recorded inter-run variance. Deltas are not product truth until that exists.

Do not change dimension names or verdict math in the same change as adding traces.
In progress. Golden parser fixture: `test/fixtures/judge_traces/canonical.json`. Sample variance: `Judge::Variance`. Remaining: record inter-run totals from live evals (no verdict-math change).
1 change: 1 addition & 0 deletions lib/skill_bench.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
require_relative 'skill_bench/judge/judge'
require_relative 'skill_bench/judge/prompt'
require_relative 'skill_bench/judge/response'
require_relative 'skill_bench/judge/variance'

# Agent subsystem
require_relative 'skill_bench/agent'
Expand Down
2 changes: 2 additions & 0 deletions lib/skill_bench/judge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Evaluates AI-generated code modifications by calling an LLM judge.
| `judge.rb` | `Judge::Judge` | Orchestrates the LLM judge call |
| `prompt.rb` | `Judge::Prompt` | Builds structured prompts from task + criteria |
| `response.rb` | `Judge::Response` | Parses and validates judge JSON responses |
| `variance.rb` | `Judge::Variance` | Sample mean/stddev/spread over repeated totals |
| `test/fixtures/judge_traces/` | — | Golden judge JSON that must keep parsing |

## Usage

Expand Down
49 changes: 49 additions & 0 deletions lib/skill_bench/judge/variance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# frozen_string_literal: true

require_relative '../error_logger'

module SkillBench
module Judge
# Sample statistics over repeated judge totals.
class Variance
# @param totals [Array<Numeric>] Judge totals from repeated runs of the same eval.
# @return [Hash] `{ success: true, response: { n:, mean:, stddev:, spread: } }`
def self.call(totals:)
new(totals).call
end

# @param totals [Array<Numeric>]
def initialize(totals)
@totals = totals
end

# @return [Hash]
def call
nums = Array(@totals).map { |total| Float(total) }
return empty_result(count: nums.size) if nums.size < 2

mean = nums.sum / nums.size
sample_variance = nums.sum { |value| (value - mean)**2 } / (nums.size - 1)

{
success: true,
response: {
n: nums.size,
mean: mean,
stddev: Math.sqrt(sample_variance),
spread: nums.max - nums.min
}
}
rescue StandardError => e
SkillBench::ErrorLogger.log_error(e, 'Judge::Variance Error')
{ success: false, response: { error: { message: e.message } } }
end

private

def empty_result(count:)
{ success: true, response: { n: count, mean: nil, stddev: nil, spread: nil } }
end
end
end
end
10 changes: 10 additions & 0 deletions test/fixtures/judge_traces/canonical.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dimensions": {
"correctness": { "score": 24, "max_score": 30, "reasoning": "Behavior matches the task." },
"skill_adherence": { "score": 20, "max_score": 25, "reasoning": "Follows the skill contract." },
"code_quality": { "score": 16, "max_score": 20, "reasoning": "Clear structure." },
"test_coverage": { "score": 12, "max_score": 15, "reasoning": "Starting tests still pass." },
"documentation": { "score": 8, "max_score": 10, "reasoning": "Public API is documented." }
},
"overall_reasoning": "Canonical golden trace for parser lock-in. Total 80."
}
29 changes: 29 additions & 0 deletions test/judge/golden_trace_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require 'test_helper'

module SkillBench
module Judge
class GoldenTraceTest < Minitest::Test
FIXTURE = File.expand_path('../fixtures/judge_traces/canonical.json', __dir__)

def test_canonical_trace_parses_to_expected_scores
json = File.read(FIXTURE)
result = Response.call(json: json)

assert result[:success], "parse failed: #{result.dig(:response, :error, :message)}"
response = result[:response][:judge_response]
dims = response.dimensions

assert_equal 24, dims['correctness'][:score]
assert_equal 20, dims['skill_adherence'][:score]
assert_equal 16, dims['code_quality'][:score]
assert_equal 12, dims['test_coverage'][:score]
assert_equal 8, dims['documentation'][:score]
total = dims.each_value.sum { |dim| dim[:score] }

assert_equal 80, total
end
end
end
end
33 changes: 33 additions & 0 deletions test/judge/variance_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require 'test_helper'

module SkillBench
module Judge
class VarianceTest < Minitest::Test
def test_call_returns_mean_stddev_and_spread
result = Variance.call(totals: [80, 86, 83])

assert result[:success]
stats = result[:response]

assert_equal 3, stats[:n]
assert_in_delta 83.0, stats[:mean], 0.001
assert_in_delta 3.0, stats[:stddev], 0.001
assert_in_delta 6.0, stats[:spread]
end

def test_call_returns_nils_when_fewer_than_two_totals
result = Variance.call(totals: [80])

assert result[:success]
stats = result[:response]

assert_equal 1, stats[:n]
assert_nil stats[:mean]
assert_nil stats[:stddev]
assert_nil stats[:spread]
end
end
end
end
Loading