A small puzzle that shows what reviewing a diff can and can't see. Here is the only file the PR changes:
# pricing.py (changed in the PR)
def discount_for(tier):
# BEFORE: returns a fraction (0.10 = 10%)
# AFTER: returns a percentage (10 = 10%)
return {"basic": 0, "plus": 10, "pro": 20}[tier]
The PR description says: "Make discount values easier to read in config: use percentages." Locally it looks reasonable and the change is tiny.
Where's the bug? It isn't in this file. It's in a caller that the PR doesn't touch:
# checkout.py (not in the diff)
from pricing import discount_for
def total(price, tier):
return round(price * (1 - discount_for(tier)), 2)
Running it:
basic 100
plus -900
pro -1900
A 10% discount turns a 100 price into -900. The tests for pricing.py would pass if they were updated to match the new values, and the diff alone wouldn't show who relies on the old meaning.
What the example suggests to me, as a developer thinking about review workflows:
- A change of meaning (units, scale, nullability, ordering) is riskier than a change of syntax, and it often leaves no trace in the diff.
- Whether a reviewer, human or AI, can catch it depends on whether it looks at callers outside the diff. I don't know how well any specific tool does this, and I'd like to hear actual experiences.
- Some habits that seem to help regardless of the reviewer: PR descriptions that say what contract changed, a search for usages before merging a signature or semantics change, and a test at the caller's level (here a
total() test would have failed immediately). - Types or naming can help:
discount_percent vs discount_fraction would have made the change visible in the call sites.
Questions for people using AI review:
- Has an AI review caught a problem like this, outside the changed files, or does it mostly comment on the diff?
- Do you add anything to the PR (a list of callers, a note on what contract changed) to help it?
- Which kinds of cross-file bugs still need a human in your experience?