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 @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Fixture-backed `evals/skills/create-service-object/basic`: fat `OrdersController`, passing starting tests, and a condensed `skills/create-service-object/SKILL.md`.
- Fixture-backed `evals/skills/write-yard-docs/basic`: undocumented `PriceCalculator`, passing starting tests, and a condensed `skills/write-yard-docs/SKILL.md`.
- Fixture-backed `evals/skills/triage-bug/basic`: buggy `Discount.apply` (integer division), passing happy-path tests, and a condensed `skills/triage-bug/SKILL.md`.

### 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
2 changes: 1 addition & 1 deletion evals/skills/triage-bug/basic/criteria.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"context": "Evaluate ruby task",
"context": "Evaluate whether skill context helps reproduce Discount.apply(cents: 999, percent: 10) with a failing test, then apply the smallest integer-division fix",
"dimensions": [
{ "name": "correctness", "max_score": 30 },
{ "name": "skill_adherence", "max_score": 25 },
Expand Down
7 changes: 7 additions & 0 deletions evals/skills/triage-bug/basic/discount.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class Discount
def self.apply(cents:, percent:)
cents / 100 * percent
end
end
10 changes: 10 additions & 0 deletions evals/skills/triage-bug/basic/discount_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

require 'minitest/autorun'
require_relative 'discount'

class DiscountTest < Minitest::Test
def test_ten_percent_off_1000_cents
assert_equal 100, Discount.apply(cents: 1000, percent: 10)
end
end
24 changes: 19 additions & 5 deletions evals/skills/triage-bug/basic/task.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
# Eval: triage-bug-basic

The sandbox starts with `discount.rb` and `discount_test.rb`.
`Discount.apply(cents: 1000, percent: 10)` returns 100 and the existing test passes.

## Bug report

Observed: 10% off 999 cents returns 90.
Expected: 99 cents (10% of 999, integer cents, truncated toward zero after the multiply).
Steps: `Discount.apply(cents: 999, percent: 10)`.

## Task
Given the bug report, reproduce the issue, identify the root cause, and propose a fix with a regression test.

1. Restate observed vs expected. Do not patch first.
2. Add a failing test for `cents: 999, percent: 10` expecting 99. Run it and confirm it fails for the wrong result, not a syntax error.
3. Root cause: Integer `/` truncates before `*`, so `cents / 100 * percent` is not `cents * percent / 100`.
4. Smallest fix in `discount.rb` only. Keep `ruby discount_test.rb` passing, including the new case.

## Success Criteria
- The bug is reproduced with a failing test.
- The root cause is correctly identified.
- A minimal fix is proposed.
- A regression test prevents recurrence.

- A test covers 999 cents at 10% and expects 99.
- `discount.rb` uses multiply-before-divide (or equivalent that yields 99).
- `ruby discount_test.rb` exits 0.
- Do not extract a service object or add YARD as the main change.
26 changes: 26 additions & 0 deletions skills/triage-bug/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Triage Bug

Use when a Ruby bug report needs a reproduction test before a fix.

## Pattern

```ruby
# frozen_string_literal: true

require 'minitest/autorun'
require_relative 'discount'

class DiscountReproductionTest < Minitest::Test
def test_ten_percent_off_999_cents
assert_equal 99, Discount.apply(cents: 999, percent: 10)
end
end
```

## Hard rules

1. Do not patch production code until a test fails for the reported case.
2. The first failing test must fail on the assertion (wrong value), not LoadError or syntax.
3. Name observed behavior, expected behavior, and the smallest file to change.
4. Fix only that behavior. Do not refactor, extract a service, or add unrelated docs.
5. Re-run the full fixture tests after the fix.
56 changes: 56 additions & 0 deletions test/evals/triage_bug_basic_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# frozen_string_literal: true

require 'test_helper'
require 'open3'
require 'tempfile'

module SkillBench
class TriageBugBasicEvalTest < Minitest::Test
EVAL_DIR = File.expand_path('../../evals/skills/triage-bug/basic', __dir__)
SKILL_PATH = File.expand_path('../../skills/triage-bug/SKILL.md', __dir__)

def test_eval_loads_and_names_the_fixture_files
evaluation = Models::Eval.load(EVAL_DIR)

assert_includes evaluation.task, 'discount.rb'
assert_includes evaluation.task, 'discount_test.rb'
assert_includes evaluation.task, '999'
end

def test_eval_ships_the_integer_division_bug_without_a_regression_test
assert_path_exists File.join(EVAL_DIR, 'discount.rb')
assert_path_exists File.join(EVAL_DIR, 'discount_test.rb')

stdout, stderr, status = Open3.capture3(
'ruby', '-e', "require_relative 'discount'; print Discount.apply(cents: 999, percent: 10)",
chdir: EVAL_DIR
)

assert_predicate status, :success?, stderr
assert_equal '90', stdout, 'starting fixture must still contain the integer-division bug'
refute_includes File.read(File.join(EVAL_DIR, 'discount_test.rb')), '999'
end

def test_starting_discount_tests_pass
stdout, stderr, status = Open3.capture3('ruby', 'discount_test.rb', chdir: EVAL_DIR)

assert_predicate status, :success?, "fixture tests failed:\n#{stdout}\n#{stderr}"
assert_includes stdout, '0 failures'
end

def test_skill_example_is_valid_ruby
skill = File.read(SKILL_PATH)
example = skill[/```ruby\n(.*?)```/m, 1]

refute_nil example, 'SKILL.md must include a ruby example'

Tempfile.create(['triage_example', '.rb']) do |file|
file.write(example)
file.flush
_stdout, stderr, status = Open3.capture3('ruby', '-c', file.path)

assert_predicate status, :success?, stderr
end
end
end
end
Loading