Review and merge
accepted ADR-0022 engineering/ADR-0022-review-and-merge
review: by: maintainer approvals: 0Status
Section titled “Status”Accepted
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
Section titled “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
Section titled “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).
Adopted as recommended. Other repositories install this package, so a
person reads and merges every pull request. .claude/settings.json denies
gh pr merge. Dependabot’s patch updates keep their automerge
(ADR-0018), the exception rule 3 allows.
Ruled again on revision 3: review.merge_by: person, with ADR-0011’s forge.review: author, becomes review.by: maintainer with review.approvals: 0, as the revision maps it, and in line with ADR-0026 agent.identity: maintainer. .claude/settings.json denies gh pr review as well as gh pr merge.
Consequences
Section titled “Consequences”Positive
Section titled “Positive”- An agent opens its pull request, says when the checks are green, and
stops: nothing reaches
mainthat one person did not merge.
Negative
Section titled “Negative”- Every merge waits for one person, the release pull request included.
Neutral
Section titled “Neutral”- Whether
mainrefuses a direct push is a GitHub setting, outside the repository, and nothing here checks it.
Alternatives Considered
Section titled “Alternatives Considered”review.by: agent
Section titled “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
Section titled “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
Section titled “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
Section titled “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
Section titled “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
Section titled “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
Section titled “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.
