Public: anyone can read this; the crew can change it.
A person on a team as reviewer can approve or request changes on a pull, and still cannot merge it #12632
Check · Review · Land · Live done — Landed and live in production.
A person whose role on a team in the repository's org is reviewer can now approve a pull or request changes on it. They still cannot merge it. This is part 1 of #12063: the rule only.
shipped production is serving it deploy 11ed909
A person whose role on a team in the repository's org is reviewer can now approve a pull or request changes on it. They still cannot merge it. This is part 1 of #12063: the rule only.
What moved where
- New
src/core/verdict.ts, with one function,canVerdict(db, repo, user). It is true for a writer, for an agent on the crew, and for a person on any team of the repository's owning org whose role isreviewer. A plain reader gets false. submitReviewinsrc/actions/pulls.tscallscanVerdictinstead of the inlinecanWrite || crew agenttest, and its doc comment says so. The now-unusedisCrewimport is gone. Acommentedreview is still open to anyone who can read the repository.
What did not change, on purpose
- Merging:
mergePullstill requires a writer, so a reviewer who cannot write gets403 forbidden. - Protected-branch approval: the own-approval rule in
src/core/pull_trust.ts(approvedAt) still counts only a writer's approval. - Approval count:
reviewSummaryalready counts every accepted approval, sorequireReviewcounts a reviewer's approval the same as a writer's without any edit. - Left alone: the crew rule (
repo_crew_agents_only) andsrc/http/api.ts.
Test — one new case in test/reviews-states.test.ts. It adds dee to a read team as reviewer, then checks:
deecan request changes and approve (201).- With
requireReviewon, the pull shows 1 approval and is mergeable. deetrying to merge gets 403forbidden.- A writer approving and merging works as before.
The existing test "a reader may comment and may not approve" still covers the reader refusing case. With the src/actions/pulls.ts change stashed, the new test fails (403 where 201 was expected); with it, it passes.
Checks run: bun scripts/gate.ts and bun x tsc --noEmit pass. scripts/fast.ts named 2,356 test files, too many to run, so I ran the 90 test files that call review-states or submitReview instead: 693 tests, all passing.
Try it: add a person to a read team with POST /api/v1/orgs/:org/teams/:team/members {"user": "...", "role": "reviewer"}. As that person, POST …/pulls/:n/review-states {"state":"approved"} returns 201, and POST …/pulls/:n/merge returns 403.
🤖 Generated with Claude Code
Small, single-purpose, matches the issue: canVerdict in its own module, submitReview uses it, merge stays a writer's (test shows 403), a commented review stays open. No UI surface changes, no new dependency, README untouched. Next two: (1) add docs/features note and a TUI/API surface for granting the reviewer role when part 2 of #12063 lands, since today only the API sets it; (2) the team check is org-wide (any team in the owning org), so decide in part 2 whether a reviewer on one team should judge every repo of the org or only those the team is scoped to.
A person whose role on a team in the repository's org is
reviewercan now approve a pull or request changes on it. They still cannot merge it. This is part 1 of #12063: the rule only.What moved where
src/core/verdict.ts, with one function,canVerdict(db, repo, user). It is true for a writer, for an agent on the crew, and for a person on any team of the repository's owning org whose role isreviewer. A plain reader gets false.submitReviewinsrc/actions/pulls.tscallscanVerdictinstead of the inlinecanWrite || crew agenttest, and its doc comment says so. The now-unusedisCrewimport is gone. Acommentedreview is still open to anyone who can read the repository.What did not change, on purpose
mergePullstill requires a writer, so a reviewer who cannot write gets403 forbidden.src/core/pull_trust.ts(approvedAt) still counts only a writer's approval.reviewSummaryalready counts every accepted approval, sorequireReviewcounts a reviewer's approval the same as a writer's without any edit.repo_crew_agents_only) andsrc/http/api.ts.Test — one new case in
test/reviews-states.test.ts. It addsdeeto areadteam asreviewer, then checks:deecan request changes and approve (201).requireReviewon, the pull shows 1 approval and is mergeable.deetrying to merge gets 403forbidden.The existing test "a reader may comment and may not approve" still covers the reader refusing case. With the
src/actions/pulls.tschange stashed, the new test fails (403 where 201 was expected); with it, it passes.Checks run:
bun scripts/gate.tsandbun x tsc --noEmitpass.scripts/fast.tsnamed 2,356 test files, too many to run, so I ran the 90 test files that callreview-statesorsubmitReviewinstead: 693 tests, all passing.Try it: add a person to a read team with
POST /api/v1/orgs/:org/teams/:team/members {"user": "...", "role": "reviewer"}. As that person,POST …/pulls/:n/review-states {"state":"approved"}returns 201, andPOST …/pulls/:n/mergereturns 403.🤖 Generated with Claude Code
Closes #12630