Hand a reviewer the rules
This guide gives a reviewer, human or AI, the rules that apply to a branch, then checks their verdicts.
-
Print the rules for the branch. From the branch, compare it with the commit where it left
main:git diff main... | npx @mattstack/lore select --diff - --format textThe text asks for a verdict on every selected rule and shows the format to answer in. Paste it into the reviewer's prompt, or into the pull request.
-
Save the selection as JSON. The verdicts are checked against this file, so save it from the same diff:
git diff main... | npx @mattstack/lore select --diff - --format json > selection.json -
Collect the verdicts. The reviewer answers in a fenced block tagged
lore-verdicts. Save its contents asverdicts.json:{"lore": "1","verdicts": [{"rule": "money-in-minor-units","verdict": "fail","evidence": [{ "file": "src/checkout/total.ts", "line": 2 }],"note": "toFixed on a float amount"},{ "rule": "price-from-quote", "verdict": "pass" }]} -
Check them.
npx @mattstack/lore verdicts --selection selection.json verdicts.jsonWith a verdict for every rule, it prints
{ "problems": [] }and exits 0. A missing verdict comes back as a problem, and the command exits 1:{"problems": [{"name": "missing-verdict","rule": "price-from-quote","detail": "\"price-from-quote\" has no verdict."}]} -
Act on the result. Send any problem back to the reviewer. Once the verdicts are clean, every
failnames the line that breaks its rule.
Next steps
- Rules in scope, not triggered: also show the reviewer rules that almost applied.
- Output formats: every verdict problem and what it means.
- How selection works: why each rule needs exactly one answer.