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
2 changes: 1 addition & 1 deletion evals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

One case per row of the dispatch table in `skills/km/SKILL.md`, plus a negative case. Each case scaffolds a brain with `km init` from this checkout (`lib/brain.sh`), so run with `--scaffold`; the write and shell cases need `--allow-tools Bash Write Edit`, and every shell command then runs in Claude Code's sandbox inside the fixture brain. That sandbox has no network and gives the run its own empty home, so `lib/brain.sh` installs a uv-managed Python with `bin/km`'s PyYAML pin into that home before the session (this step needs uv and network): `bin/km` then starts offline on its first call. Without it, a run spends its turns getting km to start. The step stands in for what a user's first run fetches from the network, so a passing eval does not show that `bin/km` starts in a sandbox without network.

Each case whose row names a reference file has a `reads-reference` grader (that file was read); `help` and `save content` name only the core, so they have none. `save-cites` is a second case of the save row: a note that links a SharePoint file with a synced copy at hand, which the save flow cites with `km cite add` before the commit. `save-generated` is a third: a note with an SVG plotted from a local measurement export, which the save flow commits together with the script that draws it and a line on how to regenerate it. Its fixture brain lacks the rule in CONVENTIONS.md, like a brain set up before it, so the case measures the skill alone; the model mostly keeps the script without the plugin too (baseline 0.67 and 1.00 in two runs), so it guards against a regression rather than showing a lift. `save-owner` and `save-owner-named` are two more cases of the save row, in a team brain (`team_brain` in `lib/brain.sh`): a note saved without naming an owner gets `owner:` the author's initials, one where the user names someone else gets theirs and keeps the author, and the reply says who owns it; the graders read the doc the run leaves at the path the prompt names. `promote-owner` and `promote-owner-off-roster` are cases of the `promote` row in a team brain with an `owners:` roster: an author on it becomes the promoted doc's owner (the grader reads the file the run leaves); an author off it makes `km promote` refuse, and the run must then pass an `--owner` from the roster or ask whom to name, never edit the roster or write the doc by hand (an `llm` grader on the trace, and the roster line is checked to be unchanged); `promote-owner` also has a `reads-reference` grader, the off-roster case none, since a run may ask before it reads further. Measured without the plugin (3 runs each): `save-owner` 0.67 and `promote-owner` 0.22 against 1.00 with it; `save-owner-named` and `promote-owner-off-roster` pass either way (the model follows a named owner, and reads the roster and asks), so those two guard against a regression rather than show a lift. `lookup-all-brains` is a second case of the question row: a brain with two mounted brains (`brain_with_two_peers` in `lib/brain.sh`) and a fact only in the second mount's merged doc, asked without `@`; it checks that the run starts with `km search` (a `regex` on the trace for its coverage or result line), answers the fact with a `[gamma@<sha>]` citation, and (an `llm` grader) names the open pull requests as not searched (the fixture's brains have no GitHub remote, so km search reports them NOT SEARCHED) rather than saying nothing is in review. `lookup-question` allows Bash so that it can run `km search` too. `pr-review-comments` is a second case of the `pr` row: an open PR whose unresolved review threads the user saved to a file, which the flow verifies, fixes, folds and answers, with replies and resolves to post after the push. The threads come from a file because a stand-in `gh` cannot be put in front of the real one: the session keeps the operator's PATH, and neither a `gh` in the run's home nor a PATH in the workspace's `.claude/settings.json` got ahead of it. Without the plugin the model works the threads well enough too (two of its three `llm` graders pass in the baseline); `folds-the-fix` is the one the skill decides. It measures neither posting nor the OK-before-posting rule: nothing is posted. Every case has one grader on the flow's key step (the `km` command it runs, the file it writes, the line it answers). Graders are `tool_used` and `regex`, except the `llm` graders in `fix-in-mounted-brain`, `lookup-all-brains`, `save-generated`, `pr-review-comments` and `promote-owner-off-roster` (those of the latter two judge the trace, not the reply).
Each case whose row names a reference file has a `reads-reference` grader (that file was read); `help` and `save content` name only the core, so they have none. `save-cites` is a second case of the save row: a note that links a SharePoint file with a synced copy at hand, which the save flow cites with `km cite add` before the commit. `save-generated` is a third: a note with an SVG plotted from a local measurement export, which the save flow commits together with the script that draws it and a line on how to regenerate it. Its fixture brain lacks the rule in CONVENTIONS.md, like a brain set up before it, so the case measures the skill alone; the model mostly keeps the script without the plugin too (baseline 0.67 and 1.00 in two runs), so it guards against a regression rather than showing a lift. `save-owner` and `save-owner-named` are two more cases of the save row, in a team brain (`team_brain` in `lib/brain.sh`): a note saved without naming an owner gets `owner:` the author's initials, one where the user names someone else gets theirs and keeps the author, and the reply says who owns it; the graders read the doc the run leaves at the path the prompt names. `promote-owner` and `promote-owner-off-roster` are cases of the `promote` row in a team brain with an `owners:` roster: an author on it becomes the promoted doc's owner (the grader reads the file the run leaves); an author off it makes `km promote` refuse, and the run must then pass an `--owner` from the roster or ask whom to name, never edit the roster or write the doc by hand (an `llm` grader on the trace, and the roster line is checked to be unchanged); `promote-owner` also has a `reads-reference` grader, the off-roster case none, since a run may ask before it reads further. Measured without the plugin (3 runs each): `save-owner` 0.67 and `promote-owner` 0.22 against 1.00 with it; `save-owner-named` and `promote-owner-off-roster` pass either way (the model follows a named owner, and reads the roster and asks), so those two guard against a regression rather than show a lift. `lookup-all-brains` is a second case of the question row: a brain with two mounted brains (`brain_with_two_peers` in `lib/brain.sh`) and a fact only in the second mount's merged doc, asked without `@`; it checks that the run starts with `km search` (a `regex` on the trace for its coverage or result line), answers the fact with a `[gamma@<sha>]` citation, and (an `llm` grader) names the open pull requests as not searched (the fixture's brains have no GitHub remote, so km search reports them NOT SEARCHED) rather than saying nothing is in review. `lookup-question` allows Bash so that it can run `km search` too. `review-restated-value` is a second case of the review row (link, don't restate): a brain whose accepted `docs/pump-controller.md` states two values of the pump controller, and two docs in review that restate them without a link: a note with one value right and the other off by one digit, and a `type: decision` that quotes the rating it was based on, which differs. It checks that the run searches with `km search` (the `regex` on the trace that `lookup-all-brains` uses; it checks the method, since the rule names `km search`, and fails a run that finds the home with grep), that the reply names the home's file and line and tags a finding with its origin (`regex` graders), and (`llm` graders) that the disagreeing figure is blocking, the matching one is a non-blocking request to link, and the decision, which the reply must cover, is not blocked on its figure. `pr-review-comments` is a second case of the `pr` row: an open PR whose unresolved review threads the user saved to a file, which the flow verifies, fixes, folds and answers, with replies and resolves to post after the push. The threads come from a file because a stand-in `gh` cannot be put in front of the real one: the session keeps the operator's PATH, and neither a `gh` in the run's home nor a PATH in the workspace's `.claude/settings.json` got ahead of it. Without the plugin the model works the threads well enough too (two of its three `llm` graders pass in the baseline); `folds-the-fix` is the one the skill decides. It measures neither posting nor the OK-before-posting rule: nothing is posted. Every case has one grader on the flow's key step (the `km` command it runs, the file it writes, the line it answers). Graders are `tool_used` and `regex`, except the `llm` graders in `fix-in-mounted-brain`, `lookup-all-brains`, `review-restated-value`, `save-generated`, `pr-review-comments` and `promote-owner-off-roster` (those of the latter two judge the trace, not the reply).

A grader on a `km` command (`runs-km-*`) checks that km ran, not how the model typed it: it is a `regex` on the `trace` that matches a line km itself prints (`repin: <doc> pins ...`, `km doctor: <root>`, `ERRORS: <n>`, ...) at the start of a line of a tool result. The model calls km as `km`, as the full path to `bin/km` or through a variable it set (`$KM repin`), and the command text also turns up in descriptions, commit messages and `echo`s, so a match on the Bash input passes when km never started and fails when it ran. Where a command prints several lines, the pattern accepts more than one of them (`km doctor:` or its closing line, `ERRORS:` or `WARNINGS:`), so output cut by `| head` or `| tail` usually still passes. A run whose output was thrown away (`>/dev/null`, `km sync --quiet` with nothing to do, a `| tail` that keeps only the findings under `WARNINGS:`) fails the grader, and so does a refused edit, promote or stub that forwards km validate's report: that is not a validate run of its own. A change to what one of these commands prints changes its grader too, and so does a change to how `claude plugin eval` writes a tool result into the trace (`"tool_use_result":` followed by the output as a JSON string, or by an object whose `stdout` comes first).

Expand Down
10 changes: 10 additions & 0 deletions evals/lib/brain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,13 @@ brain_with_two_peers(){
git -C "$1" "${G[@]}" submodule add -q "$T/beta" brains/beta && git -C "$1" "${G[@]}" submodule add -q "$T/gamma" brains/gamma
git -C "$1" "${G[@]}" commit -q -m "chore(brains): mount beta and gamma"
}
# restate_brain DIR: a brain whose accepted docs/pump-controller.md states two values of the pump
# controller; two docs in review restate them without linking it: a note with one value right and
# the other one digit off, and a decision that quotes the rating it was based on, which differs
restate_brain(){
brain "$1" EV
doc "$1" docs/pump-controller.md "Pump controller" accepted "The pump controller's supply input is rated for 3.5 A continuous. The controller shuts the pump down when its heatsink reaches 85 degrees Celsius."
doc "$1" inbox/coolant-pump-wiring.md "Coolant pump wiring" review "The coolant pump is fed from the 24 V auxiliary rail through the pump controller. Fuse the feed above the controller's 3.5 A continuous rating. The controller stops the pump when its heatsink reaches 95 degrees Celsius, so mount it away from the inverter."
printf -- '---\ntitle: Pump controller for the coolant loop\ntype: decision\nstatus: review\nauthor: EV\ndate: 2026-01-12\ntags: [eval]\n---\n\n# Pump controller for the coolant loop\n\nOn 2026-01-12 we chose the pump controller for the coolant loop: its supply rating of 3.2 A, as given in the offer we had then, covers the pump'"'"'s 2.8 A draw.\n' > "$1/inbox/coolant-pump-decision.md"
git -C "$1" "${G[@]}" add -A && git -C "$1" "${G[@]}" commit -q -m "docs: pump controller and coolant pump"
}
4 changes: 4 additions & 0 deletions evals/review-restated-value/case.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
schema_version: "1.1"
name: review-restated-value
context:
scaffold_script: fixture.sh
3 changes: 3 additions & 0 deletions evals/review-restated-value/fixture.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
source "$(dirname "${BASH_SOURCE[0]}")/../lib/brain.sh"
restate_brain "$PWD"
7 changes: 7 additions & 0 deletions evals/review-restated-value/graders/asks-to-link-the-match.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
---

inbox/coolant-pump-wiring.md, under review, repeats the 3.5 A continuous rating that docs/pump-controller.md already states, correctly, without linking it.
PASS only if the reply asks for a link to docs/pump-controller.md for the matching 3.5 A figure (or to give the value there and link it) and does not call that matching figure itself blocking. A link request listed beside the blocking 95 degrees Celsius finding passes. A blocking finding about a different claim that only mentions 3.5 A (for example an unsourced fusing or wiring instruction) does not count as calling the matching figure blocking.
FAIL otherwise: no request to link the 3.5 A figure, or the matching 3.5 A figure itself called blocking.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
---

docs/pump-controller.md, an accepted doc, says the pump controller shuts the pump down at a heatsink temperature of 85 degrees Celsius. inbox/coolant-pump-wiring.md, under review, says 95 degrees Celsius and does not link it.
PASS if the reply reports the 95 versus 85 degrees Celsius mismatch as a blocking finding (blocking, must be resolved before sign-off, or the like), either as an error in inbox/coolant-pump-wiring.md or as "the two disagree, one must change", and names docs/pump-controller.md as the other doc.
FAIL if the reply does not mention the 95 versus 85 degrees mismatch, reports it only as a minor or non-blocking point, or does not name docs/pump-controller.md.
7 changes: 7 additions & 0 deletions evals/review-restated-value/graders/decision-not-blocking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
---

inbox/coolant-pump-decision.md is a `type: decision` doc under review that quotes a 3.2 A supply rating from the offer the decision was based on; docs/pump-controller.md gives 3.5 A today. A decision is a record of a moment and may quote the figures it was based on, so this is at most a non-blocking finding.
PASS only if the reply covers inbox/coolant-pump-decision.md (gives a verdict or at least one finding for it) AND does not list its 3.2 A figure as blocking because it differs from, or restates, docs/pump-controller.md. A blocking finding on the decision for another reason (an unsourced claim, a missing field) does not fail this grader.
FAIL if the reply says nothing about inbox/coolant-pump-decision.md, or lists its 3.2 A figure as blocking because it differs from docs/pump-controller.md or restates it, or says the decision cannot be signed off for that reason.
5 changes: 5 additions & 0 deletions evals/review-restated-value/graders/names-the-home-line.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
type: regex
pattern: 'pump-controller\.md(?::|,? line |#L)\d+'
target: last_message
---
5 changes: 5 additions & 0 deletions evals/review-restated-value/graders/reads-reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
type: tool_used
tool: Read
input_match: 'reference[/\\]+review-and-pr\.md'
---
5 changes: 5 additions & 0 deletions evals/review-restated-value/graders/runs-km-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
type: regex
target: trace
pattern: '"tool_use_result":(?:\{"stdout":)?"(?:(?:[^"\\]|\\.)*?\\n)?(?:coverage \(terms: |result: \d+ hits?; coverage )'
---
5 changes: 5 additions & 0 deletions evals/review-restated-value/graders/tags-the-origin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
type: regex
pattern: '\(origin: (?:datasheet|measurement|firmware|customer document|other|unknown)\)'
target: last_message
---
6 changes: 6 additions & 0 deletions evals/review-restated-value/prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
max_turns: 15
allowed_tools: [Read, Glob, Grep, Skill, Bash, Write, Edit]
---

/km review inbox/coolant-pump-wiring.md inbox/coolant-pump-decision.md
Loading