From 27c755798e8e20f63261a0653fae9d59f0e3f476 Mon Sep 17 00:00:00 2001 From: Ismael Marin Date: Sun, 13 Sep 2026 21:56:44 -0600 Subject: [PATCH] feat: fixture-backed triage-bug eval Ship Discount.apply with an integer-division bug that 1000-cent tests miss. The agent must add a 999-cent reproduction, then fix multiply before divide. Include a condensed skill and a bench test that the bug is still present. --- CHANGELOG.md | 1 + evals/skills/triage-bug/basic/criteria.json | 2 +- evals/skills/triage-bug/basic/discount.rb | 7 +++ .../skills/triage-bug/basic/discount_test.rb | 10 ++++ evals/skills/triage-bug/basic/task.md | 24 ++++++-- skills/triage-bug/SKILL.md | 26 +++++++++ test/evals/triage_bug_basic_test.rb | 56 +++++++++++++++++++ 7 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 evals/skills/triage-bug/basic/discount.rb create mode 100644 evals/skills/triage-bug/basic/discount_test.rb create mode 100644 skills/triage-bug/SKILL.md create mode 100644 test/evals/triage_bug_basic_test.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 38d3e34..129a0b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). diff --git a/evals/skills/triage-bug/basic/criteria.json b/evals/skills/triage-bug/basic/criteria.json index fb4eaca..055c560 100644 --- a/evals/skills/triage-bug/basic/criteria.json +++ b/evals/skills/triage-bug/basic/criteria.json @@ -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 }, diff --git a/evals/skills/triage-bug/basic/discount.rb b/evals/skills/triage-bug/basic/discount.rb new file mode 100644 index 0000000..ba581d3 --- /dev/null +++ b/evals/skills/triage-bug/basic/discount.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class Discount + def self.apply(cents:, percent:) + cents / 100 * percent + end +end diff --git a/evals/skills/triage-bug/basic/discount_test.rb b/evals/skills/triage-bug/basic/discount_test.rb new file mode 100644 index 0000000..b407832 --- /dev/null +++ b/evals/skills/triage-bug/basic/discount_test.rb @@ -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 diff --git a/evals/skills/triage-bug/basic/task.md b/evals/skills/triage-bug/basic/task.md index f900a84..dcd6b4e 100644 --- a/evals/skills/triage-bug/basic/task.md +++ b/evals/skills/triage-bug/basic/task.md @@ -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. diff --git a/skills/triage-bug/SKILL.md b/skills/triage-bug/SKILL.md new file mode 100644 index 0000000..1a6c14b --- /dev/null +++ b/skills/triage-bug/SKILL.md @@ -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. diff --git a/test/evals/triage_bug_basic_test.rb b/test/evals/triage_bug_basic_test.rb new file mode 100644 index 0000000..72ad394 --- /dev/null +++ b/test/evals/triage_bug_basic_test.rb @@ -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