Review and merge
proposed checked A convention of ontrack-engineering 0.6.0. How ontrack ruled on it.
traits: review: by: approvals:Status
Proposed
What is this file? A question governance asks your repository, with the answer it recommends. While it says
status: proposed, you may edit it freely.revision:dates the question, not the file: you do not fill it, and it only moves when the question changes. rejected is a full answer: when the question does not apply here, rule rejected, remove the wholetraits:block, and say what stands in for it. ADR-0001 explains the mechanics.
Context
A coding agent branches, commits and opens the pull request (ADR-0009). While these keys are empty, it does not know whether it may approve a pull request, or merge one once the checks are green. It either waits without saying so, or merges what nobody read.
An agent’s act cannot be told apart afterwards. The agent works with a
person’s gh session or token, so GitHub records its merge, and its
approval, under that person’s name. The history shows a merge or an
approval, never who decided it. The rule can only be enforced before
the act, not audited after it, unless the agent acts under an identity of
its own (ADR-0026).
Where the review happens depends on who else can approve. GitHub does not let the author of a pull request approve it. In a repository kept by one person, no approval is possible, so the moment that person reads the diff and merges it is the review. Once another account can approve, the review moves to that approval, and the merge can follow from it.
Two ADRs already settle a case: ADR-0018 lets some updates merge without a person, and ADR-0019 has a person approve or merge every vulnerability ignore rule. This ADR states the rule they are cases of.
Not concerned: who owns which path (CODEOWNERS). It routes a review;
it does not change what the agent may do.
Decision
What governance recommends, and why.
| Key | Recommended value | Reason |
|---|---|---|
review.by |
maintainer |
a person reads every change before it lands, and in a repository kept by one person, their merge is the only review GitHub allows. Rule peer once another account can approve |
review.approvals |
0 with maintainer, 1 with peer |
the number of approvals the ruleset requires, written where an agent and the check can read it |
review.by says where the review a person does happens:
maintainer: the merge of the one person who keeps the repository;peer: the approval of the latest push by an account other than the one that opened the pull request;agent: nowhere. Acceptable for a repository nobody depends on, such as a demo or a throwaway, and justified here when you rule it.
review.approvals follows from it: 0 with maintainer and agent,
because a maintainer cannot approve their own pull request and the agent
never approves; 1 or more with peer. The number is your own choice,
and it changes nothing the agent does.
What governance fixes, whatever you rule:
- The agent opens the pull request ready for review, says when its checks are green, and never approves a pull request, its own or another’s, under any account. Not as a draft: a draft adds a click and no review.
- With
maintainer, the agent merges nothing. Not withgh pr merge, not by enabling auto-merge (--auto), not through the API, not by pushing to the default branch. - With
peer, the agent may merge once GitHub accepts the merge, and never by working around the ruleset. The ruleset below refuses the merge until another account approved the latest push. - With
agent, the agent merges once the checks are green. - A bot that a workflow runs under another ADR’s ruling is not an agent session. ADR-0018’s automerge is that exception: Dependabot’s pull request is merged by a workflow the repository ruled, not by the agent.
- A review the agent runs is advice. It can find faults and fix them. It never stands in for the person’s merge or approval.
On GitHub, a ruleset backs the rule. On the default branch:
review.by |
Ruleset |
|---|---|
maintainer |
require a pull request before merging, with zero approvals |
peer |
require a pull request with review.approvals approvals, dismiss stale approvals when new commits are pushed, and require approval of the most recent push |
agent |
require a pull request before merging, with zero approvals |
Leave the bypass list empty, except Dependabot under peer, which
ADR-0018 names, and, with ADR-0026’s
agent.identity: own, the repository admin role, for pull requests only. Pushing to the default branch then fails for everyone, the
agent included. The approval of the most recent push is what makes peer
safe: an agent that pushes a fix after the approval needs a new one.
What maintainer leaves, beside each value of
ADR-0011’s forge.gate. With none, no
control but the maintainer’s reading. With blocking, the pipeline and
that reading. With informative, the pipeline reports and the maintainer
alone decides what to do with a red.
Each agent host denies what the agent may not do, in its committed
settings, for every host in ADR-0017’s
agent.hosts.
With claude-code, .claude/settings.json. With maintainer:
{ "permissions": { "deny": ["Bash(gh pr merge:*)", "Bash(gh pr review:*)"] }}With peer, only "Bash(gh pr review:*)": denying the merge would block
the merge rule 3 allows. The agent comments on its own pull request with
gh pr comment, which the deny leaves open.
With opencode, opencode.json. opencode applies the last rule that
matches, so the denies go last in permissions, after any broader
allow. With maintainer:
{ "permissions": [ { "action": "shell", "resource": "gh pr review *", "effect": "deny" }, { "action": "shell", "resource": "gh pr merge *", "effect": "deny" } ]}With peer, only the gh pr review * rule.
With copilot, .claude/settings.json again, but Copilot CLI ignores
permissions, so the claude-code denies do not hold for it. A
PreToolUse hook does: Copilot CLI and Claude Code both run it, and both
block the call when it exits 2. With maintainer:
{ "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "grep -q 'gh pr review' && { echo 'the agent never approves a pull request (ADR-0022)' >&2; exit 2; } || exit 0" }, { "type": "command", "command": "grep -q 'gh pr merge' && { echo 'a person merges this pull request (ADR-0022)' >&2; exit 2; } || exit 0" } ] } ] }}With peer, only the gh pr review hook. Each hook reads the tool call on
its standard input. With [claude-code, copilot], keep both the denies and
the hooks.
If the GitHub MCP server is installed, deny its review and merge tools as
well, under the names your configuration gives the server (for example
mcp__github__create_pull_request_review and
mcp__github__merge_pull_request).
Everything below disappears when you rule, from this sentence up to the Consequences heading, which stays.
How to rule: five steps, all in this file. Read all of them before doing any, because the last one deletes the other four, and do them in one commit.
- Write the value of each key under
traits:in the frontmatter, or, if you rule rejected, remove the wholetraits:block. - Change
status:from proposed to accepted or rejected. - Fill
date:andauthors::date:asYYYY-MM-DD, the day you rule;authors:, the names of the people who decided, without email addresses. - Rewrite the Positive, Negative and Neutral lists under Consequences for your verdict: what it makes easier, and what it costs.
- Last, delete this block, from its first sentence up to the Consequences heading, which stays. In its place, write the reason for your decision wherever you depart from the recommendation, or, if you adopt it as is, one line that says so.
The first step is the one people forget: a decision written only in prose leaves an agent guessing. This is what the frontmatter looks like once filled, and it is the one part of the file an agent reads without interpreting it:
---adr: ADR-0022slug: review-and-mergetitle: Review and mergestatus: acceptedrevision: 3date: 2026-11-15authors: [Your Name]supersedes: []check: npx --no-install ontrack-engineering-check ADR-0022traits: review: by: maintainer approvals: 0---The check: line stays. Once this ADR is accepted, ontrack check
runs it from your repository’s root:
- It fails when the two keys disagree:
maintaineroragentwithapprovalsother than0,peerwith0. Withagent, there is nothing else to check. - With
maintainerorpeer, it checks each host of ADR-0017’sagent.hosts, and fails if one fails. The commands to deny aregh pr review, and withmaintaineralsogh pr merge:- with
claude-code, the committed.claude/settings.jsonholds, underpermissions.deny, an entry that starts withBash(and the command. The same entry underalloworaskfails, and.claude/settings.local.jsonis not read; - with
copilot, the committed.claude/settings.jsonholds, underhooks.PreToolUse, an entry whosematchercoversBash(absent, empty,*, or a pattern matchingBash) with acommandhook that contains the command. Apermissionsentry alone fails, and the check does not run the hook: one that names the command without blocking it passes; - with
opencode, it reads the committedopencode.json, then.opencode/opencode.json, joins theirpermissionsin that order, and replays them as opencode does: for the command alone and with an argument, the last rule whoseactionmatchesshelland whoseresourcematches the command must be adeny. A laterallow, no rule at all, anopencode.jsonc, or the V1permissionobject fails.policiesand the rules outside the repository (global, agent-level) are not read; - with
agent.hosts: [], or no accepted ADR-0017, there is no deny to check. ADR-0017 still holding its revision 1 keyagent.hostfails, with the line to write.
- with
- In GitHub Actions only, it reads the rules active on the default branch
through
gh api, and fails unless they require a pull request with exactlyreview.approvalsapprovals and, withpeer, dismiss stale approvals and require approval of the most recent push. Pass the job’s token asGH_TOKEN. Outside CI it says it did not read the ruleset. It reads rulesets, not classic branch protection. - It cannot see the bypass list: reading it needs admin rights. Its output says the bypass list is not verified.
review.merge_by, left from revision 1, fails and namesreview.by.
The check denies nothing itself, and the deny has a ceiling. It
protects against an agent that approves or merges by mistake, not against
one working around the rule. Claude Code and opencode both match the entry
inside a compound command (cd x && gh pr merge 1), and the copilot hook
matches the command anywhere in the call, but each matches
command text, and Claude Code’s documentation says deny rules are not a security boundary:
gh api on the review or merge endpoint and a push to the default branch
match none of them, and /usr/bin/gh pr merge passes the denies though not
the hook. The ruleset above closes the merge; nothing closes an approval
made under a teammate’s token except the deny or the hook.
The Alternatives Considered below were weighed by governance without knowing your context. Weighing them against yours is still to do, and it is what makes a decision different from an accepted default.
Consequences
Positive
- An agent at a green pull request knows what to do: say so and stop, or,
with
peer, merge once GitHub accepts it. - No approval in a person’s name comes from an agent.
- Nothing reaches the default branch without a person having read it, except the updates ADR-0018 lets merge.
- ADR-0018 and ADR-0019 apply one rule instead of two separate ones.
Negative
- With
maintainer, every change waits for the maintainer, even a trivial one. - The deny entries protect against a mistake, not against a workaround; without the ruleset, the merge rule is an intention.
Neutral
- The ruleset lives on GitHub, outside the repository. The check reads it in CI, but not its bypass list.
Alternatives Considered
review.by: agent
The agent merges once the checks are green. No wait, and no reader: a green check is not a review (ADR-0018 says why). Tenable for a repository nobody installs from or depends on.
A person merges even under peer
The approval and the merge both wait for a person. The second wait proves nothing the approval of the latest push does not already prove, once the ruleset requires it.
Two keys: who reviews, and whether the team is one person or several
review.by: person | agent beside review.team: solo | team. One
combination, agent with team, has no effect: the agent never approves,
so it merges with zero approvals in either case. Two keys with a dead
combination carry no more than one key with three values.
One required approval for a single maintainer
The usual rule for a team. For one maintainer it cannot work: GitHub refuses the author’s own approval, so every merge is blocked or bypassed, and a rule bypassed on every merge is not a rule. It becomes workable once the agent has an identity of its own: see ADR-0026.
CODEOWNERS
Routes each path to its owners for review. It belongs with peer, and it
changes who approves, not what the agent may do.
Draft pull requests
The agent opens a draft, and the person marks it ready, then merges. The extra step proves nothing the merge does not already prove.
References
- Original to governance; no surdesrails SDR asks this question.
- ADR-0001: how governance ADRs are ruled on.
- ADR-0009: one change, one branch, one pull request.
- ADR-0011: the required checks a merge waits for.
- ADR-0017:
agent.hosts, which decides what the check reads. - ADR-0018 and ADR-0019: the two cases this ADR generalises.
- Claude Code: permissions. opencode: permissions, and its source (
anomalyco/opencode, branchdev:packages/core/src/permission.ts,util/wildcard.ts,config.ts) for the order rules are joined and evaluated in. GitHub: about rulesets, available rules, rules for a branch, approving a pull request. Read on 2026-11-15.
The keys.
| Key | What it holds | Allowed values |
|---|---|---|
review.by |
where the review a person does happens | maintainer (the maintainer’s merge), peer (another account’s approval of the latest push), agent (no person) |
review.approvals |
the approvals the default branch’s ruleset requires | 0 with maintainer and agent; 1 or more with peer |
An empty key is not an answer: both are required. The values are written in this file and nowhere else; whoever needs them links here. See ADR-0001 for the check command.
Revisions. What changed in the question at each revision, and what a repository that already ruled must re-answer.
- Revision 2:
review.merge_byis replaced byreview.byandreview.approvals, which also take over ADR-0011’sforge.review. The agent never approves; withpeerit may merge once GitHub accepts it. Re-answer both keys and deletereview.merge_by:forge.review: authorwithmerge_by: personbecomesmaintainerwithapprovals: 0;forge.review: peerbecomespeerwith the approvals your ruleset requires, at least1;merge_by: agentbecomesagentwithapprovals: 0. Add theBash(gh pr review:*)deny. - Revision 3: the denies are required on each host of ADR-0017’s
agent.hosts, and the Decision shows the opencode rules. The keys are unchanged: nothing to re-answer; a repository whoseagent.hostsholdsopencodeadds the denies toopencode.json.
