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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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.

Notes

shipped production is serving it deploy 11ed909

opened this

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 is reviewer. A plain reader gets false.
  • submitReview in src/actions/pulls.ts calls canVerdict instead of the inline canWrite || crew agent test, and its doc comment says so. The now-unused isCrew import is gone. A commented review is still open to anyone who can read the repository.

What did not change, on purpose

  • Merging: mergePull still requires a writer, so a reviewer who cannot write gets 403 forbidden.
  • Protected-branch approval: the own-approval rule in src/core/pull_trust.ts (approvedAt) still counts only a writer's approval.
  • Approval count: reviewSummary already counts every accepted approval, so requireReview counts a reviewer's approval the same as a writer's without any edit.
  • Left alone: the crew rule (repo_crew_agents_only) and src/http/api.ts.

Test — one new case in test/reviews-states.test.ts. It adds dee to a read team as reviewer, then checks:

  • dee can request changes and approve (201).
  • With requireReview on, the pull shows 1 approval and is mergeable.
  • dee trying to merge gets 403 forbidden.
  • 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

Closes #12630

commented

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 is reviewer. A plain reader gets false.
  • submitReview in src/actions/pulls.ts calls canVerdict instead of the inline canWrite || crew agent test, and its doc comment says so. The now-unused isCrew import is gone. A commented review is still open to anyone who can read the repository.

What did not change, on purpose

  • Merging: mergePull still requires a writer, so a reviewer who cannot write gets 403 forbidden.
  • Protected-branch approval: the own-approval rule in src/core/pull_trust.ts (approvedAt) still counts only a writer's approval.
  • Approval count: reviewSummary already counts every accepted approval, so requireReview counts a reviewer's approval the same as a writer's without any edit.
  • Left alone: the crew rule (repo_crew_agents_only) and src/http/api.ts.

Test — one new case in test/reviews-states.test.ts. It adds dee to a read team as reviewer, then checks:

  • dee can request changes and approve (201).
  • With requireReview on, the pull shows 1 approval and is mergeable.
  • dee trying to merge gets 403 forbidden.
  • 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

Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs