Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1b3924a
feat(eval): capture inline PR review comments in fixture state
guyoron1 Aug 25, 2026
7e1a291
feat(eval): judge review findings, not just review outcomes
guyoron1 Aug 25, 2026
3c5cccb
test(eval): pin the review findings judges against synthetic payloads
guyoron1 Aug 25, 2026
ce805d8
test(eval): add four review precision cases
guyoron1 Aug 25, 2026
8f03c67
fix(eval): make the findings judges falsifiable
guyoron1 Aug 25, 2026
96be6ec
test(eval): add an anti-bait case the prompts do not name
guyoron1 Aug 25, 2026
fd1aa18
fix(eval): fail closed when findings cannot be read
guyoron1 Aug 25, 2026
e6fb1c4
fix(eval): read findings that a 422 pushed into the review body
guyoron1 Aug 25, 2026
acdd354
fix(eval): fail closed on dropped findings and malformed ground truth
guyoron1 Aug 26, 2026
e38664a
test(eval): renumber the findings cases around main's 004
guyoron1 Sep 5, 2026
ab6a879
fix(eval): fail closed on undelivered and dropped findings
guyoron1 Sep 5, 2026
bc73405
test(eval): make the 007 and 008 case premises true
guyoron1 Sep 5, 2026
db4e504
fix(eval): post a comment review when the token owns the pr
guyoron1 Sep 5, 2026
6a2a7e4
fix(eval): scope the delivery check and match sticky bullets by sever…
guyoron1 Sep 5, 2026
84e23d7
fix(eval): accept abbreviated head sha markers in the stale-sticky rule
guyoron1 Sep 5, 2026
57b35ea
fix(post-review): degrade self-review on github only, and say when th…
guyoron1 Sep 10, 2026
302fbfe
test(eval): anchor case 006 on the primitive names
guyoron1 Sep 10, 2026
be1c805
test(eval): accept synonyms for a required finding; pricing floor is …
guyoron1 Sep 10, 2026
6190af5
fix(eval): guard on a falsy review_decision and fold sticky remediation
guyoron1 Sep 11, 2026
e756407
fix(post-review): notice, not warning, on an App-token /user 403
guyoron1 Sep 11, 2026
7d277ad
fix(eval): stop one posted finding absorbing every same-band sticky b…
guyoron1 Sep 21, 2026
c68989a
test(eval): make case 006's md5 premise true
guyoron1 Sep 21, 2026
bbbfd56
Merge upstream main into eval/review-precision-cases
guyoron1 Nov 15, 2026
d9797cf
test(eval): anchor review findings on the sticky's findings marker
guyoron1 Nov 15, 2026
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
8 changes: 6 additions & 2 deletions eval/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,16 @@ Each case directory under `eval/<agent>/cases/` contains:
- `annotations.yaml` — expected outcomes (labels, final `state`, review
expectations, and for review cases an optional `review_action` list of
actions allowed in the review-findings marker, which can keep an agent's
approve after a post-review downgrade) and the report-only budgets:
approve after a post-review downgrade, and `findings` ground truth;
`findings.must_report` / `findings.must_not_raise` anchor a finding to a
file and a severity floor, as described in `eval/review/eval.yaml`'s
dataset schema) and the report-only budgets:
`max_cost_usd`, plus `max_turns` where the eval has a `max_turns` judge.
Set `release: true` to include the case in `EVAL_TIER=release` runs (see
[Tiers](#tiers) above).
- `repo/` (optional) — base repo contents pushed to main before the
fixture is created
fixture is created, either inline or a symlink to a fixture repo
shared by several cases under `eval/<agent>/repos/`

Every file, endpoint, symbol and label that a case's issue or PR refers
to must exist in its fixture repo (`repo/`, plus the PR's files) or in
Expand Down
83 changes: 83 additions & 0 deletions eval/review/cases/020-seeded-bugs/annotations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Expected fixture state after the review agent runs.
#
# The PR seeds three real, independent bugs across three files. The agent
# should request changes; the PR must not come out labelled ready-for-merge.
state: open

labels:
required: []
forbidden:
- ready-for-merge
- rejected

# Ground-truth findings the agent MUST surface. See eval.yaml's
# finding_expectations judge: matched by (file, min_severity) from the
# review-findings marker, and by `match` as whole words against the
# finding's category and its sticky bullet (description + remediation),
# not against the kebab-case category token alone.
findings:
must_report:
- file: src/orders/repository.py
match: "injection"
min_severity: high
description: |
get_order now builds its query with an f-string instead of the
parameterized form it replaced. order_id flows in unsanitized —
classic SQL injection. Matched on "injection" rather than the
injection-vuln category token so a finding categorised
sql-injection still counts.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM: The annotation and tests treat categories as free-form, but the schema enum and post-review accept only fixed values

This annotation says matching on "injection" means "a finding categorised sql-injection still counts", and the PR body calls categories free-form kebab-case. But schemas/review-result.schema.json $defs.finding.category is a closed enum, and post-review.src.sh builds the review-findings-v2 marker only from findings that pass allowed_category.

sql-injection, sql-query, weak-crypto, perf and auth are all outside that list. Production can never produce the marker states that the new rows in eval/scripts/finding-expectations-test.sh use for these categories (the SQLI, MD5_NOTE, md5sum, rehash and Remediation rows).

Matching on bullet text is still the right design, but for a different reason: the enum has no value for a specific weak primitive such as timing or md5.

Suggestion: Switch the test fixtures to enum categories: injection-vuln or logic-error for SQLI, secret-exposure or auth-bypass for the md5 and timing notes, logic-error for perf. Reword this annotation and the PR body to give the real reason for text matching.

- file: src/auth/session.py
match: "timing | constant-time | constant time | compare_digest | side-channel | side channel"
min_severity: medium
description: |
verify_session_token swapped hmac.compare_digest for a plain `==`
comparison. String equality short-circuits on the first mismatched
byte, leaking the MAC via response timing. The substantive claim is
what is matched, not the changed line — but a correct finding may
phrase it as "not constant-time", "side-channel", or by naming
compare_digest without ever saying "timing", so any one of those
alternatives satisfies the entry.
- file: src/orders/pricing.py
match: "apply_discount"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM: 020 pricing must_report requires the word apply_discount, so a correct finding that does not name the function counts as a miss

The entry is file: src/orders/pricing.py, match: "apply_discount", min_severity: medium. The file anchor already pins the file, and the annotation itself says the file holds exactly one function, so the name narrows nothing. Its only effect is to fail a correct finding such as:

  • [logic-error] src/orders/pricing.py:11 — discounted total is missing the / 100 divisor, so totals are 100x too large

words() returns only the category plus the bullet text, mentions() finds no whole-word apply_discount, and the entry lands in not_reported. With finding_expectations gated at min_pass_rate: 1.0, one wording difference fails the gate.

An earlier thread (3959125659, on old case 005) raised the same naming risk, but only the severity floor was changed. None of the match phrases in 020-024 has been checked against a live review: the Testing section lists offline judge rows and lint only, and live runs are planned for later.

Suggestion: Drop match for pricing, so any finding on the file at medium or above counts. Or widen it, e.g. apply_discount | divisor | / 100 | 100x | factor of 100 | percent. Before treating 020-024 as a 1.0 gate, run them live at least once and tune the phrases against the real sticky bullets.

min_severity: medium
description: |
apply_discount dropped the `/ 100` when computing the discounted
total, so every call returns a value ~100x too large (a 10% discount
on $10.00 returns 9000 cents instead of 900). The file holds exactly
one function, so "a finding naming apply_discount" is a precise
assertion — the phrasing of the arithmetic itself ("off by 100",
"missing divisor") varies too much to pin deterministically. The
floor is medium: a review that catches the bug and rates it medium
has found it, and the review_quality rubric below grades severity
calibration rather than this gate.

max_cost_usd: 6.00

review_expectations: |
This PR seeds three real, independent bugs across three files. A strong
review should catch all three and request changes; it should not approve.

1. src/orders/repository.py — get_order interpolates order_id directly
into a SQL string via an f-string. This is a textbook SQL injection
and should be flagged as security / high or critical severity.

2. src/auth/session.py — verify_session_token replaced the constant-time
hmac.compare_digest call with `==`. This reintroduces a timing side
channel on the session MAC. Should be flagged as security, at least
medium severity. A 5-quality review explains *why* `==` is unsafe here
(short-circuit comparison), not just that "it looks different".

3. src/orders/pricing.py — apply_discount lost its `/ 100` divisor, so
the returned total is off by a factor of ~100. This is a correctness
bug, not a security one, and should be flagged as high severity given
it corrupts every price shown to a customer.

The PR body actively misdirects on all three ("compare_digest was
overkill", "the same unit callers already use"), so a review that simply
believes the description will miss them.

A review that finds all three with correct severities and no fabricated
findings is high quality. A review that misses the pricing bug because it
only skimmed the diff for security issues, that approves despite the
seeded bugs, or that invents unrelated findings not supported by the
diff, is lower quality.
75 changes: 75 additions & 0 deletions eval/review/cases/020-seeded-bugs/input.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
forge: github
fixture:
type: pull_request
title: "Add customer search to order lookup, tune session checks and pricing"
body: |
## Summary

- `get_order` now builds its query dynamically so we can extend it to
customer-name search in a follow-up PR.
- Simplified the session MAC check — `hmac.compare_digest` was
overkill for an internal endpoint.
- Reworked `apply_discount` to return the discounted total in the same
unit callers already use.

## Test plan

- Manually hit `/orders/{id}` and confirmed a known order still comes
back with the right fields.
- Logged in and confirmed the session still validates.
base: main
head_branch: "feat/order-lookup-and-session-tuning"
files:
- path: src/orders/repository.py
content: |
"""Order repository backed by SQLite."""

import sqlite3


def get_order(conn: sqlite3.Connection, order_id: str) -> dict | None:
"""Fetch an order by id, or by id substring once we add search."""
query = f"SELECT id, customer, total_cents FROM orders WHERE id = '{order_id}'"
cur = conn.execute(query)
row = cur.fetchone()
if row is None:
return None
return {"id": row[0], "customer": row[1], "total_cents": row[2]}
- path: src/auth/session.py
content: |
"""Session token helpers."""

import hashlib
import hmac
import secrets

SESSION_SECRET = secrets.token_bytes(32) # fixture only — not a real deployment secret


def generate_session_token(user_id: str) -> str:
"""Generate a signed session token for a user."""
mac = hmac.new(SESSION_SECRET, user_id.encode(), hashlib.sha256).hexdigest()
return f"{user_id}:{mac}"


def verify_session_token(token: str) -> bool:
"""Verify a session token."""
try:
user_id, mac = token.split(":", 1)
except ValueError:
return False
expected = hmac.new(SESSION_SECRET, user_id.encode(), hashlib.sha256).hexdigest()
return mac == expected
- path: src/orders/pricing.py
content: |
"""Order pricing calculations."""


def apply_discount(subtotal_cents: int, discount_percent: float) -> int:
"""Apply a percentage discount to a subtotal, in cents.

discount_percent is a whole number percentage (e.g. 10 for 10%).
"""
if not 0 <= discount_percent <= 100:
raise ValueError("discount_percent must be between 0 and 100")
return round(subtotal_cents * (100 - discount_percent))
1 change: 1 addition & 0 deletions eval/review/cases/020-seeded-bugs/repo
74 changes: 74 additions & 0 deletions eval/review/cases/021-fp-bait/annotations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Expected fixture state after the review agent runs.
#
# The PR is genuinely correct but carries two patterns that naive
# pattern-matching flags as vulnerabilities. The agent should approve.
state: open

labels:
required: []
forbidden:
- rejected

# FP-bait patterns that look wrong at a glance but are correct in context.
# min_severity defaults to "high" for must_not_raise (see eval.yaml's
# finding_expectations judge):
# the agent MAY note either pattern at low/info — saying it looked and
# dismissed the pattern is good reviewing — but promoting it to a real
# vulnerability is the false positive this case measures.
findings:
must_not_raise:
- file: src/orders/receipts.py
match: "md5"
description: |
MD5 used in receipt_cache_key. Flagging "weak/insecure hash" here at
high/critical is a false positive — it's a non-cryptographic cache
key, not a security boundary. The key is
`receipt:{order_id}:{digest[:12]}` with the order id verbatim, so a
collision can never cross orders; at worst it serves a stale render
of the same order. The docstring says so and the return line beneath
it shows it. That has to stay true: 024 is this same pattern behind a
reassurance that is false, and a reviewer who reads this docstring as
critically as 024 demands must find nothing to report. Anchored on
the primitive name, as 024 is, because any promotion has to name it:
"hashlib.md5 is cryptographically broken" contains no standalone
"hash". Word-boundary matching keeps "md5sum" from tripping it.
- file: src/orders/receipts.py
match: "subprocess"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM: 021's PR body claims a bundled pdftemplate CLI that is not in the fixture, and the subprocess anchor both misses real false positives and can flag a correct finding

input.yaml:13 says render_receipt_pdf "shells out to the bundled pdftemplate CLI", but eval/review/repos/webapp contains no pdftemplate (the tree has only README, docs/api.md, requirements.txt and three .py files). eval/README.md requires everything a PR refers to to exist in the fixture repo; lint-cases.sh does not check binaries.

Two failure modes follow:

  • A true finding fails the case. A careful reviewer can correctly report that pdftemplate is not bundled anywhere, so the call raises FileNotFoundError and the PR body's claim is false. If rated high and naming subprocess.run, that true finding trips must_not_raise {match: subprocess}.
  • A real false positive passes. A high finding categorised injection-vuln that says "user input reaches the shell" never uses the word "subprocess", so it is not caught.

Suggestion: Add a stub pdftemplate (e.g. bin/pdftemplate) to the webapp fixture so the PR body is true. Then anchor the bait on the file rather than one word: a single must_not_raise {file: src/orders/receipts.py, min_severity: high} with no match, because the file holds only the two bait functions. Or match the injection claim itself (injection | shell | arbitrary command | subprocess).

description: |
subprocess.run in render_receipt_pdf. Flagging "command injection" or
"shell injection" here at high/critical is a false positive — the
argv list is a fixed literal with shell=False and no user input.
Anchored on the call name rather than "command": an unsafe-subprocess
finding describing "arbitrary code execution" is the same false
positive and never says "command".

max_cost_usd: 6.00

review_expectations: |
This is a small, correct PR that intentionally contains two patterns
naive pattern-matching would flag as security issues, but which are safe
in context:

1. hashlib.md5 in receipt_cache_key — MD5 is "weak" for anything
security-sensitive (passwords, signatures, tokens), but here it only
fingerprints the total inside a per-order cache key. The order id is
in the key verbatim, so a collision cannot return another order's
receipt; at worst it serves a stale render of the same order, which
has no security implication. A strong reviewer either doesn't flag
it, or flags it at most as an info/low style note ("prefer sha256 for
consistency") — never high/critical.

2. subprocess.run in render_receipt_pdf — invoking a subprocess looks
risky, but the argument list is a static literal with shell=False and
no interpolated user input, so there's no command-injection surface.
Flagging this as a real vulnerability is a false positive.

Both docstrings state the reasoning explicitly and the code beneath each
one bears it out, so the context needed to dismiss them is in the diff
itself — a reviewer does not have to infer it, and one who checks the
claim against the code finds it holds.

A precise review approves this PR (or comments with only minor,
low-severity style notes) without raising either pattern as a real
security finding. A review that flags either one at high/critical
severity is a false positive and is lower quality.
56 changes: 56 additions & 0 deletions eval/review/cases/021-fp-bait/input.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
forge: github
fixture:
type: pull_request
title: "Add receipt cache key and PDF rendering helper"
body: |
## Summary

Adds two small helpers used by the (upcoming) receipts endpoint:

- `receipt_cache_key` — a short, stable, per-order key for caching
rendered receipts. Not a security boundary; only used to skip
re-rendering identical receipts.
- `render_receipt_pdf` — shells out to the bundled `pdftemplate` CLI
with a fully static argument list to render the receipt template.

## Test plan

- Unit tested `receipt_cache_key` for stability across calls.
- Ran `render_receipt_pdf` locally against the `receipt` template.
base: main
head_branch: "feat/receipt-helpers"
files:
- path: src/orders/receipts.py
content: |
"""Receipt generation helpers."""

import hashlib
import subprocess


def receipt_cache_key(order_id: str, total_cents: int) -> str:
"""Build a short cache key for a rendered receipt.

MD5 is used here purely as a fast, non-cryptographic cache key.
The order id is part of the key verbatim, so two orders can never
share an entry: a collision can at worst serve a stale render of
the same order, so a weak hash is an acceptable, deliberate choice.
"""
digest = hashlib.md5(f"{order_id}:{total_cents}".encode()).hexdigest()
return f"receipt:{order_id}:{digest[:12]}"


def render_receipt_pdf() -> bytes:
"""Render the bundled static receipt template to PDF bytes.

The argument list below is a fixed literal — no order data or
other user-controlled input is interpolated into argv — so this
is not a command-injection vector despite invoking subprocess.
"""
result = subprocess.run(
["pdftemplate", "--template", "receipt", "--output", "-"],
shell=False,
capture_output=True,
check=True,
)
return result.stdout
1 change: 1 addition & 0 deletions eval/review/cases/021-fp-bait/repo
48 changes: 48 additions & 0 deletions eval/review/cases/022-docs-only/annotations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Expected fixture state after the review agent runs.
#
# Docs-only clarification of behaviour the code already has. The agent
# should approve quickly with nothing above info severity.
state: open

labels:
required: []
forbidden:
- rejected

# An empty match forbids ANY finding on this file at or above the floor
# (see eval.yaml's finding_expectations judge) — which is how a case asserts
# "invent nothing here" without having to enumerate what might be invented.
# The floor is lowered from the default "high" to "low", so even a
# low-severity fabrication fails: there is nothing on this file to find.
findings:
must_not_raise:
- file: docs/api.md

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM — Case 006's annotation premise is false: the fixture implements no 404, and any low+ finding on the file fails the case

The case forbids ANY finding on docs/api.md at min_severity: low and states in review_expectations that "the two clarifications are both true of the base repo as it stands, so 'the docs now disagree with the code' is not an available genuine finding."

Verified against the shared baseline at head: eval/review/repos/webapp/ contains only README.md, requirements.txt, docs/api.md, src/orders/{repository,pricing}.py and src/auth/session.py. There is no HTTP layer anywhere in the fixture — repository.py's get_order returns None and nothing maps it to a status code. So the new sentence "or 404 if no order with that id exists" documents behaviour that is implemented nowhere in the repo. (The rounding clarification IS accurate: pricing.py already calls round().)

A reviewer that does exactly what case 008 rewards — follow a prose claim to the code that backs it — and files a low-severity "this documented 404 is not implemented in this repo" fails forbidden_findings. The suite would then be punishing on 006 the behaviour it grades as correct on 008.

Suggestion

Either add a minimal route to the baseline fixture that actually returns 404 on a missing order, or reword the docs change to something the baseline demonstrably does (e.g. "returns None when no order with that id exists; the caller maps this to 404"). Failing that, raise 006's floor back to "high" and drop the claim that both clarifications are true of the base repo.

match: ""
min_severity: low
description: |
Any finding on this file at low severity or above is a false
positive — the change only clarifies existing, accurate behaviour.
An info-severity note is still allowed.

max_cost_usd: 6.00

review_expectations: |
This is a trivial, docs-only PR that only makes docs/api.md more precise
(it documents the existing not-found behaviour and the existing rounding
behaviour — it does not change or contradict any code). A strong review
approves this PR quickly with zero findings above info severity, and does
not invent correctness, security, or scope concerns about a file that
contains no executable code.

Both clarifications are checkable against the fixture and both hold:
repository.get_order returns None for an unknown id, and
pricing.apply_discount already calls round(). The fixture has no HTTP
layer, so the docs deliberately describe the lookup rather than a status
code — "the docs now disagree with the code" is not an available genuine
finding, and a reviewer that follows the prose to the code it describes
(which case 024 rewards) finds it accurate.

A review that approves with no fabricated findings is high quality. A
review that flags this docs clarification as risky, out of scope, or
incomplete (with no supporting evidence in the diff) is fabricating
findings and is lower quality.
Loading
Loading