Code review: resolving disagreements (AI reviewers included) and a worked review
When the reviewer, the author and a review bot disagree: classify the disagreement, move from opinion to measurement (Little's law), escalate, disagree and commit with an ADR, through a case study of a 5-minute fraud-check wait. Which decisions stay human when AI does the first pass, plus a worked review of a Spring Boot booking flow.
On this page
1. The problem
A payment PR waits up to 300,000 ms for a fraud check. The reviewer blocks it, the author won't budge, and an AI review bot suggests "raise the timeout to reduce errors". Three comment rounds, 9 days, and the PR is still open.
2. Key idea
Both sides argue opinions when what they need is facts or a shared priority. Move from opinion to fact, then to a decision the whole team follows (disagree and commit), recorded in an ADR.
| Kind of disagreement | Sign | Fix |
|---|---|---|
| Taste | naming, loop style | NIT, or turn it into a formatter/linter rule |
| Measurable assumption | "slow", "won't handle the load" | measure, load test, small PoC |
| Different priorities | on time or safe, fast or cheap | establish context, escalate, write an ADR |
2.1 Which step?
| Approach | Use when | Don't use when |
|---|---|---|
| Reply in the MR | first time, small point, you want a record | two rounds on the same point already |
| 15-minute talk | after two rounds; misunderstood intent | there's no data |
| Measure, PoC | the assumption can be checked in hours | priorities differ: numbers don't answer "what matters more" |
| Escalate | priorities differ and both options are written down | you haven't fully heard the other side |
| Follow the AI bot | the suggestion matches team standards and has a test | it needs context the bot lacks: SLAs, money risk, old ADRs |
3. In Java
Measure before arguing: 200 Tomcat worker threads, each request waiting 5 seconds, runs out of threads at 40 requests/s. Decision: a named 2-second business timeout, returning PENDING_REVIEW when it expires.
@ConfigurationProperties("payment.fraud-check")
record FraudCheckProperties(Duration timeout) {} // payment.fraud-check.timeout=2s
PaymentStatus pay(PaymentCommand cmd) {
Verdict verdict = fraudClient.check(cmd) // CompletableFuture<Verdict>
.completeOnTimeout(Verdict.UNKNOWN,
props.timeout().toMillis(), TimeUnit.MILLISECONDS)
.join(); // waits at most 2 seconds
return switch (verdict) {
case APPROVED -> PaymentStatus.APPROVED;
case REJECTED -> PaymentStatus.REJECTED;
case UNKNOWN -> PaymentStatus.PENDING_REVIEW; // fail-closed: unsure means not approved
};
}
// fraud answers after 100 ms: APPROVED; after 5 seconds: PENDING_REVIEW at 2.1 sOther languages: Go uses context.WithTimeout; Node.js uses AbortSignal.timeout().
Fail-open or fail-closed, and timeouts borrowed from infrastructure
- Fail-open: let it through when the dependency fails (recommendations, analytics). Fail-closed: unsure means no (payments, authorization). This is a business decision, not the bot's.
- The original 300,000 ms was the Redis client timeout reused as a business timeout. Infrastructure timeouts (connect, socket read) and business timeouts ("how long can the customer wait") are different numbers and need different names.
- When the person disagreeing is a junior: ask for their reasoning first, let them measure; the decision still goes in the MR.
4. Working with AI
Hand to AI: a fair summary of each side's argument, a pros-and-cons table, load test scripts, a draft ADR. Humans keep: team priorities, failure behavior, decisions in old ADRs, and the approval.
Check yourself when an AI joins the debate:
- Bot suggestions are treated as
OPTIONALcomments unless a human reviewer upgrades them toTODO. - Numbers the AI gives (threads, latency, load) were measured or recomputed.
- Suggestions like "raise the timeout", "retry more", "fail open" are checked against SLAs and money risk.
- AI-drafted ADRs list rejected options, reasons and review conditions.
5. Exercises
Exercise 1: Review an agent-written booking flow
An agent opens a PR "Booking v2, tests green" (Spring Boot, PostgreSQL). Find the merge-blocking issues and write TODOs with consequences and fixes.
@SneakyThrows
@Transactional // jakarta.transaction.Transactional
public BookingResponse execute(BookingRequest request) {
if (request.checkin().isBefore(LocalDate.now())) throw new InvalidDatesException();
List<HomestayAvailability> nights = availabilityRepo.lockNights( // PESSIMISTIC_WRITE,
request.homestayId(), request.checkin(), request.checkout()); // no ORDER BY
Booking booking = bookingRepo.save(Booking.from(request, nights)); // request_id not UNIQUE
emailService.sendConfirmation(booking);
kafka.send("booking-created", booking.id());
return BookingResponse.of(booking);
}Solution 1
| Where | Consequence | Fix |
|---|---|---|
@SneakyThrows + jakarta.transaction.Transactional |
checked exceptions don't roll back: the transaction commits | drop @SneakyThrows, or rollbackOn = Exception.class |
| Email, Kafka inside the transaction | a failed commit still sends an email for a booking that doesn't exist | @TransactionalEventListener(AFTER_COMMIT); an outbox for events that must not be lost |
request_id not UNIQUE |
a client retry creates two bookings | UNIQUE (request_id), return the existing booking on conflict |
Night locks without ORDER BY |
overlapping bookings lock in different orders: deadlock, 500 | ORDER BY ha.date |
LocalDate.now() |
on a UTC server, from midnight to 7 a.m. Vietnam time it accepts a past check-in date | inject a Clock, use the homestay's time zone |
Write each row as a TODO comment: concrete consequence first, then the fix. Add a PRAISE for the one-row-per-night availability table with row locks.
Exercise 2: The bot and the human disagree
On the PR from section 3, an AI review bot comments: "A 2-second timeout may raise the PENDING_REVIEW rate. Suggest raising it to 10 seconds and failing open (APPROVED) on timeout so customers aren't blocked." The author wants to follow it. How do you reply?
Solution 2
- Separate two points: timeout length is a measurable assumption; fail-open is a priority difference.
- Measure: what's the fraud service's p99? If it's 800 ms, 2 seconds already has headroom. 10 seconds with 200 threads leaves only 20 requests/s.
- Failing open on payments is a money-risk decision: the product owner or tech lead decides, in an ADR. The bot knows nothing about fraud rates or chargeback costs.
- Answer the bot as an
OPTIONALcomment: thank it, record why you're not doing it, and open a ticket to track thePENDING_REVIEWrate on a dashboard.
Summary
- Classify disagreements: taste, measurable assumption, different priorities.
- Two rounds on one point means talking directly; record the conclusion in the MR.
- Little's law turns a timeout argument into a multiplication.
- An AI bot is one opinion; humans decide failure behavior and own it.
- A
TODOstates a concrete consequence and a fix.
Further reading: Effective code review.
Comments
Community rules