From 3a21324c621ce07bb309e4f56e891d8497d699f0 Mon Sep 17 00:00:00 2001 From: Roman PASSLER Date: Fri, 27 Nov 2026 07:57:40 +0100 Subject: [PATCH] feat(review): link, don't restate a value another doc already holds The review checklist now finds the home of each value, part number, pin assignment or limit a doc states (the place CONVENTIONS.md names, else the source outside the brain, else the accepted doc on the item) with km search on the item's name, then its values. Two figures for the same item that disagree are blocking, a matching unlinked one is a non-blocking request to link it, a retold page without a link is blocking, and a decision or transcript may quote the figures it was based on. Each such finding carries an origin tag. The eval case review-restated-value covers the disagreeing, the matching and the decision case. --- evals/README.md | 2 +- evals/lib/brain.sh | 10 ++++++++++ evals/review-restated-value/case.yaml | 4 ++++ evals/review-restated-value/fixture.sh | 3 +++ .../graders/asks-to-link-the-match.md | 7 +++++++ .../graders/blocks-the-wrong-figure.md | 7 +++++++ .../graders/decision-not-blocking.md | 7 +++++++ .../graders/names-the-home-line.md | 5 +++++ .../review-restated-value/graders/reads-reference.md | 5 +++++ evals/review-restated-value/graders/runs-km-search.md | 5 +++++ .../review-restated-value/graders/tags-the-origin.md | 5 +++++ evals/review-restated-value/prompt.md | 6 ++++++ skills/km/reference/review-and-pr.md | 11 +++++++++-- 13 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 evals/review-restated-value/case.yaml create mode 100755 evals/review-restated-value/fixture.sh create mode 100644 evals/review-restated-value/graders/asks-to-link-the-match.md create mode 100644 evals/review-restated-value/graders/blocks-the-wrong-figure.md create mode 100644 evals/review-restated-value/graders/decision-not-blocking.md create mode 100644 evals/review-restated-value/graders/names-the-home-line.md create mode 100644 evals/review-restated-value/graders/reads-reference.md create mode 100644 evals/review-restated-value/graders/runs-km-search.md create mode 100644 evals/review-restated-value/graders/tags-the-origin.md create mode 100644 evals/review-restated-value/prompt.md diff --git a/evals/README.md b/evals/README.md index f9fad99..0cc0e25 100644 --- a/evals/README.md +++ b/evals/README.md @@ -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@]` 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@]` 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: pins ...`, `km doctor: `, `ERRORS: `, ...) 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). diff --git a/evals/lib/brain.sh b/evals/lib/brain.sh index 0f7b651..d3cfef6 100644 --- a/evals/lib/brain.sh +++ b/evals/lib/brain.sh @@ -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" +} diff --git a/evals/review-restated-value/case.yaml b/evals/review-restated-value/case.yaml new file mode 100644 index 0000000..08624be --- /dev/null +++ b/evals/review-restated-value/case.yaml @@ -0,0 +1,4 @@ +schema_version: "1.1" +name: review-restated-value +context: + scaffold_script: fixture.sh diff --git a/evals/review-restated-value/fixture.sh b/evals/review-restated-value/fixture.sh new file mode 100755 index 0000000..02d0ea9 --- /dev/null +++ b/evals/review-restated-value/fixture.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +source "$(dirname "${BASH_SOURCE[0]}")/../lib/brain.sh" +restate_brain "$PWD" diff --git a/evals/review-restated-value/graders/asks-to-link-the-match.md b/evals/review-restated-value/graders/asks-to-link-the-match.md new file mode 100644 index 0000000..489142d --- /dev/null +++ b/evals/review-restated-value/graders/asks-to-link-the-match.md @@ -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. diff --git a/evals/review-restated-value/graders/blocks-the-wrong-figure.md b/evals/review-restated-value/graders/blocks-the-wrong-figure.md new file mode 100644 index 0000000..b3b4792 --- /dev/null +++ b/evals/review-restated-value/graders/blocks-the-wrong-figure.md @@ -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. diff --git a/evals/review-restated-value/graders/decision-not-blocking.md b/evals/review-restated-value/graders/decision-not-blocking.md new file mode 100644 index 0000000..c554405 --- /dev/null +++ b/evals/review-restated-value/graders/decision-not-blocking.md @@ -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. diff --git a/evals/review-restated-value/graders/names-the-home-line.md b/evals/review-restated-value/graders/names-the-home-line.md new file mode 100644 index 0000000..7f68b78 --- /dev/null +++ b/evals/review-restated-value/graders/names-the-home-line.md @@ -0,0 +1,5 @@ +--- +type: regex +pattern: 'pump-controller\.md(?::|,? line |#L)\d+' +target: last_message +--- diff --git a/evals/review-restated-value/graders/reads-reference.md b/evals/review-restated-value/graders/reads-reference.md new file mode 100644 index 0000000..8f6f1c1 --- /dev/null +++ b/evals/review-restated-value/graders/reads-reference.md @@ -0,0 +1,5 @@ +--- +type: tool_used +tool: Read +input_match: 'reference[/\\]+review-and-pr\.md' +--- diff --git a/evals/review-restated-value/graders/runs-km-search.md b/evals/review-restated-value/graders/runs-km-search.md new file mode 100644 index 0000000..cdd01cb --- /dev/null +++ b/evals/review-restated-value/graders/runs-km-search.md @@ -0,0 +1,5 @@ +--- +type: regex +target: trace +pattern: '"tool_use_result":(?:\{"stdout":)?"(?:(?:[^"\\]|\\.)*?\\n)?(?:coverage \(terms: |result: \d+ hits?; coverage )' +--- diff --git a/evals/review-restated-value/graders/tags-the-origin.md b/evals/review-restated-value/graders/tags-the-origin.md new file mode 100644 index 0000000..9896c8c --- /dev/null +++ b/evals/review-restated-value/graders/tags-the-origin.md @@ -0,0 +1,5 @@ +--- +type: regex +pattern: '\(origin: (?:datasheet|measurement|firmware|customer document|other|unknown)\)' +target: last_message +--- diff --git a/evals/review-restated-value/prompt.md b/evals/review-restated-value/prompt.md new file mode 100644 index 0000000..54a2183 --- /dev/null +++ b/evals/review-restated-value/prompt.md @@ -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 diff --git a/skills/km/reference/review-and-pr.md b/skills/km/reference/review-and-pr.md index 7a5f8dd..f3ce7f4 100644 --- a/skills/km/reference/review-and-pr.md +++ b/skills/km/reference/review-and-pr.md @@ -16,15 +16,22 @@ The author's own review before sign-off, run on the docs a branch adds or change 2. **Level.** Determine who may sign off (see Approval below). At level `human`, say so up front, review anyway, and hand the findings over. A missing `audience` is the author's to set: ask, do not set it yourself. 3. **Check the content, not the prose:** - every factual claim against its source (`sources`, linked docs, datasheets, the code it describes); a claim with no source and no evidence in the repo is a finding; - - contradictions with docs already in the brain on the same topic (search by tags and terms); + - contradictions with docs already in the brain on the same topic (`km search` with the doc's specific items, identifiers and values, then tags and terms); a record of a moment is judged as "link, don't restate" below says; - numbers, units, part numbers and versions copied correctly from the source; + - **link, don't restate:** a value, part number, pin assignment or limit is stated once, in its home, and the doc under review links it (a body link, `resource:`, `sources:` or `cites:`), with at most the one figure the reader needs, next to its link: + - **home:** the place the brain's `CONVENTIONS.md` names for that kind of fact, where it has such a section; else the source outside the brain (code, datasheet, cited file); else the accepted doc whose subject the item is. Find it with `km search`, which covers the brain, its mounted brains and their open PRs (grep does not): the item's name and identifiers first, then the values, since a value search cannot find a home whose figure differs. `km search` covers neither shared resources nor cited files: read those directly. A home that cannot be read (a mounted brain not checked out, a SharePoint file with no synced copy) is named as "not compared", not blocking; never block on a guess. Compare only where item, quantity and condition match (continuous or peak, hardware revision). Where the doc under review is the rightful home (a new reference page), an older passing mention elsewhere is no finding against it; + - **disagree:** two figures for the same item that disagree are blocking, reported as "the two disagree, one must change" with both files and lines, not as the doc under review being wrong; + - **matching:** a figure that matches its home but does not link it is a non-blocking request for the link, naming the home's file and line. A doc for an outside reader (a customer `audience`) is exempt from the link request, since its reader cannot follow internal links, but not from the disagree check; + - **retold page:** a doc that retells a page (same subject and scope, most of its content repeated) without `supersedes:`, `translates:`, `sources:` or `related:` to it, or a body link, is blocking; a `summary` that links its sources is fine; + - **records of a moment:** a `decision` or `transcript`, or a doc whose body says it records a state at a date (minutes, a log entry, a measurement report), may quote the figures it was based on: a differing or unlinked figure there is a finding, not blocking. An `artifact` or `verbatim-block` must stand alone: no link request, but a differing figure is blocking; + - **origin tag:** end each such finding with `(origin: firmware|datasheet|measurement|customer document|other|unknown)`, the one that names where the value's home is, so restatements can be counted by origin; - `audience` matches the content: a doc written for a customer or other outside reader that is marked internal, or has no audience, is blocking; - every pinned source (`sources`, `translates`) read against the doc. `pin:stale`: `git diff` from the pinned content shows the change; a doc that has not caught up with it is blocking, one that has is pinned in step 5. `pin:old`: the source was replaced; a doc still built on it is blocking, and repinning does not fix that; - `related`, `supersedes`, links and `_index.md` entries in place, and the doc reachable; - nothing that belongs elsewhere: a customer, project or person named outside where the brain's rules allow it, secrets, machine paths; - a generated image or diagram the docs add or change (made from a source that can be rerun, not a screenshot or an instrument capture) committed without that source (the script, `.drawio` file or small input data) beside it, or a doc that does not say how to regenerate it, is blocking. A draw.io export with the diagram embedded is its own source (the doc says to edit it in draw.io). Large input data, or data the author keeps out of git, may stay external: the doc names where it is (`resource:`). Where it is unclear whether an image was generated, ask the author; do not block on a guess. `km validate` scans only `.md` files, so read the source for secrets, machine paths and names it must not carry; - `owner` and a realistic `review_by` for the sign-off. -4. **Findings.** Each one names the file and line, what is wrong and the source that shows it. Blocking: wrong or unsupported facts, contradictions, validate errors, leaks, a generated image or diagram without its source or regeneration note. Not blocking: wording, style, structure preferences; mention them once, briefly, or leave them out. +4. **Findings.** Each one names the file and line, what is wrong and the source that shows it. Blocking: wrong or unsupported facts, contradictions, two figures for the same item that disagree (outside records of a moment), a retold page without a link, validate errors, leaks, a generated image or diagram without its source or regeneration note. Not blocking but always reported: a figure that matches its home, with the request to link it. Wording, style and structure preferences are not blocking either: mention them once, briefly, or leave them out. 5. **Outcome.** Blocking findings: list them and stop. Otherwise show the user the result, and on their OK: - a `draft` doc goes to `status: review` first (`km approve` signs off review docs); - `km repin ` where a pin is stale or has no hash, so the approval covers the sources just checked (run after `km approve`, it would take the approval back); no `pin:` warning is left;