Risk-based code review: which agent changes need a closer look

Stefan-Iulian Tesoi · · 6 min read

A watch repairer with a loupe examining one watch under a lamp while a wall of clocks hangs behind, most things glanced at and one read closely

Changes that are hard to undo or wide in reach: database migrations, authentication and permissions, payment paths, public APIs, and anything that deletes or sends. Read those line by line against the criteria. A copy change or a new test can be approved on its evidence. Reviewing every diff the same way spreads attention too thin to catch either.

That is risk-based code review, and coding agents turn it from a nice idea into a necessity. A team whose agents open fifteen pull requests a day cannot read all of them with the care a migration deserves, and a reviewer who tries ends up skimming the migration along with everything else.

What is risk-based code review?

Setting code review depth by what a change could break, not by who wrote it or how long the diff is.

The idea comes from risk-based testing, the established practice of choosing and ordering tests by the likelihood and impact of a failure. Applied to review, the question is the same: if this change is wrong, how much damage does it do, and how long before anyone notices?

Size is a poor proxy. A 600-line diff adding tests to an isolated module carries less risk than a one-line change to a permission check. Authorship is a poor proxy too. An agent and a senior engineer can both write a migration that locks a large table for twenty minutes, and the review that catches it is the same review.

Two questions: how far does it reach, and can it be undone?

Ask both of every change, and let the worse answer set the tier.

TierTypical changesReview
1. EvidenceCopy, styles, isolated tests, internal toolingRead the hand-back and the test results, skim the diff
2. StandardFeature code behind existing interfacesRead the diff against the acceptance criteria
3. Line by lineMigrations, auth, payments, public APIs, deletion, infrastructureA named owner reads every line, and runs it where possible

Most work sits in the middle tier, which is what AI code review covers in detail: the diff is the evidence, and the agent's summary is a claim about it.

Which paths always get a line-by-line read?

The ones where a mistake outlives the revert. Keep the list short on purpose:

  1. Database migrations, including index builds on large tables and anything that renames, drops or retypes a field.
  2. Authentication and authorisation: login, sessions, tokens, role checks, tenant isolation.
  3. Payment and billing paths, where an error turns into a refund conversation.
  4. Public APIs and webhooks, which other people's code depends on in ways nobody here can see.
  5. Anything that deletes or sends: retention jobs, bulk email, outbound notifications.
  6. Infrastructure and CI configuration, including the files that decide who reviews what.

The last item is the easiest to miss. A change to a CODEOWNERS file or a CI workflow can quietly lower the tier of everything that follows it, which is why changing its own controls belongs among the agent guardrails worth enforcing.

High risk code changes in these paths are never approved on evidence alone. Passing tests are necessary there and nowhere near sufficient, because the failures that matter in these paths are the ones nobody thought to test.

Passing tests show that a change does what its author expected. A line-by-line read is for what nobody expected.

One from our own backend makes the point. A follow-up change added a counter field to an existing collection and selected records with a less-than comparison on it. Every test passed, because tests create records through the current schema, which fills in the default. In production, records written by the previous build had no such field, a missing field fails every less-than comparison, and those records could no longer be picked up. The question that catches this is about the rows already in production, and only a reader asks it.

Enforcing the tiers with CODEOWNERS and path rules

Write the tiers down as path rules, so the platform requests the right reviewer instead of someone remembering to.

On GitHub, a CODEOWNERS file maps path patterns to people or teams, and owners are requested automatically when a pull request touches their paths. GitHub's documentation sets out three rules worth knowing: the last matching pattern wins, a file of 3 MB or more is not loaded at all, and a requested review becomes a required one only when a branch protection rule or ruleset turns on "Require review from Code Owners".

/db/migrations/   @acme/data-owners
/src/auth/        @acme/security
/src/billing/     @acme/payments
/.github/         @acme/platform

That last condition is where codeowners review most often fails without anyone noticing. GitHub's plan comparison lists code owners and protected branches for private repositories only on the paid plans. On the free organisation plan, a private repository can hold a carefully written CODEOWNERS file that looks like policy and requests nobody. Before trusting the rules, open a test pull request that touches a tier-3 path and confirm it cannot merge without the owner.

Laimonade applies the same idea one step earlier, at the item. Each item names its blast radius, the repos and paths it touches and what must not break there, before a coding agent starts, so the tier is visible before a diff exists. The agent's work stops at In Review, carrying the checks it ran and the steps a person should verify. That is where the attention goes once agents stop being the bottleneck for engineering leaders, and it is the last step of a definition of done for agent work.

Where review tiers go wrong

Four failure modes, all of them quiet:

Frequently asked questions

Does a low-risk change still need a human approval?

Usually, but a light one. Someone confirms that the evidence covers the acceptance criteria and that the diff matches its description, which takes minutes. Risk changes the depth of the read, not whether it happens. In Laimonade a coding agent cannot move its own item past In Review; Laimon, the product owner agent, can close one once nothing is left for a person to check, and stamps that closure as its own.

Who decides which paths count as high risk?

The people who would be paged when those paths fail, agreed once and written into the repository. That is usually the tech lead together with whoever owns security, data and payments. Revisit the list when the architecture changes, and never let a single change redraw its own tier.

Should an agent be told which tier its change falls into?

Yes. Put the tier, and the paths that set it, in the item. An agent that knows a migration will be read line by line can write it to be read: small, reversible where possible, with the rollback stated. Telling it the tier does not let it choose one; the paths decide.