All posts

Who should review this PR? Tier it before a human looks

Dec 3, 2026 5 min read Oleg Savelev
review agents architecture guardrails

Review is the last place where a team still reads everything. Tests run on every commit, lint runs on every save, deploys are gated by health checks. Then a rename in a leaf helper and a migration to the billing table arrive in the same queue with the same weight.

That is not a discipline problem. GitHub has no idea what a diff touches. It shows files and hunks, and the reviewer supplies the missing graph from memory. On a good day that memory is right.

We built the Review Gatekeeper to move that graph into the gate. It is part of TokenSafe Team and Enterprise, it runs on the same repository graph the context engine already builds, and it starts in shadow mode by default.

What a reviewer actually needs

A reviewer needs three things before opening a diff: how far a change can reach, what could break, and whether the checks prove anything. All three are computable before a human is pinged.

The router reuses the graph TokenSafe already scans for slicing:

  • Graph centrality. How many callers depend on the changed symbol, and whether it is an architectural hub.
  • Blast radius. The files and static callers that import the changed one, by name.
  • Affected routes. Handlers and registrations that serve the changed code.
  • Contract changes. Edits to exported signatures, route registrations, SQL, Prisma or OpenAPI schemas.
  • Critical paths. Auth, billing, payments, migrations, security and CI workflows, from repository policy.
  • Mechanical edits. Tests, docs, formatting and lockfiles, counted separately instead of inflating the score.

Each hunk is labelled a hotspot or mechanical. The score comes from the code, not from a model's opinion, so the same diff always gets the same tier.

Three tiers, and a hard floor

Tier What it means What happens
T0 Tests, docs, lockfiles, leaf code, green gate Auto-merge eligible, only if a team enables it
T1 Moderate blast radius Fast-track review with a one-screen brief
T2 God node, public route, migration, auth, billing, or any gate failure Deep human review

The important part is the floor. Any failing test, Guard block, secret hit, syntax error or critical-path touch forces T2 regardless of how small the diff looks. A low score never overrides a red gate. Failures escalate; they do not average out.

The gate runs before the push

The same local engine that slices context also inspects the diff:

  1. Guard catches hardcoded secret fallbacks, disabled TLS checks, raw SQL interpolation, unsafe CORS and staged credential files.
  2. The redactor scans added lines before any payload could reach a model or a log.
  3. Syntax parses every changed file, so a broken edit never reaches the reviewer.
  4. Tests report pass or fail, or reuse the latest OUMV verification when the runtime is active.

In enforce mode a blocked diff returns to the coding agent with a compact fix list, before the commit is public. That is the cheapest possible review comment: the agent that wrote the bug fixes it without a human round trip.

The loop is capped per diff state, max_pre_review_loops: 2, so an agent cannot burn tokens on the same failure forever. A loop cap is not a nice-to-have. Without it, a pre-commit gate becomes an infinite retry machine.

One screen instead of a wall of hunks

The brief is the part reviewers see. It carries four things:

  • The tier and the reasons that produced it, not just a number.
  • The blast radius as a table: files, callers, routes.
  • Verification proof: which checks ran, on which commit, with what result.
  • Two or three attention hotspots, the hunks where a human eye changes the outcome.

Everything mechanical stays collapsed. On GitHub the same content lands as a Check Run named TokenSafe Review Gate, a sticky pull-request comment and a tokensafe:tier-0|1|2 label.

The GitHub App is native: RS256 app JWT, installation tokens, HMAC verification of X-Hub-Signature-256, Check Runs and GraphQL auto-merge. There is no gh CLI dependency, so the gate runs in a webhook server or a team's own pipeline.

Start in shadow mode

Dry-run is the default, and it writes nothing to the branch. Every pull request gets a tier, a brief and a ledger entry. Nothing blocks and nothing merges.

That matters because a tier system is a claim about a team's code. A month of shadow mode produces the only evidence that counts: how many PRs landed in each tier, and which ones a reviewer would have ranked differently. The panel records the split and the review hours the split would have saved, labelled as estimates.

Turning on enforce is a separate decision. Turning on auto-merge is a third one. Tier 0 is the only tier that can ever merge itself, and only after an admin enables it.

What it does not do

  • It does not replace a human on Tier 2. Auth, billing, migrations and security always wait for a person.
  • The semantic critic is off by default. Structural routing and the deterministic gate work without a model call.
  • Auto-merge is off until an admin enables it, and it applies to Tier 0 only.
  • A low score cannot override a red gate.
  • The graph is per repository. Cross-repo contracts are not routed yet.
  • Saved review hours are estimates, not measurements. They are never mixed into the measured token numbers.

Where it sits in the loop

The three tools now cover the path a change takes. TokenSafe cuts what the agent reads. Sextant makes it verify the change in the running app. Review Gatekeeper decides who needs to look at the diff, and proves the checks before the push.

Each one works alone. Together they close the loop from context to merge. If your team already runs Tier 0 changes through a human queue, start with shadow mode and compare the split with your own judgment.

The product page is at tokensafe.dev/review, and the CLI reference is in the docs. Review Gatekeeper is part of Team and Enterprise, with a 7-day trial.

Oleg Savelev, Founder, TokenSafe · 15+ years shipping production software
Oleg Savelev

Founder, TokenSafe · 15+ years shipping production software

LinkedIn
Try it on your own repo first

No account, no cloud. The engine runs on your machine and shows what it would cut before you buy anything.