diff --git a/docs/adr/0001-review-pushes-to-ready-pull-requests.md b/docs/adr/0001-review-pushes-to-ready-pull-requests.md new file mode 100644 index 0000000..57ea39a --- /dev/null +++ b/docs/adr/0001-review-pushes-to-ready-pull-requests.md @@ -0,0 +1,29 @@ +# Review the commits pushed to a ready pull request + +After the first review of a pull request, a new review starts only when someone posts a comment command, requests the review agent, or reopens the pull request or toggles it to draft and back. Pushing new commits starts nothing. Asking for a review is easy to forget after each round of changes. An agent that pushes fixes under the review agent's account cannot ask at all. The workflow ignores the review agent's own comment commands and Requested reviewer requests, so that one review cannot start another. So we added a fourth kind of review request, **Push**, decided in [#50](https://github.com/cipherstash/workflows/issues/50): + +- Push reviews only commits pushed to a ready pull request, never to a draft. Drafts stay free for work in progress, and marking a draft ready still makes one review of the whole pull request, from a Ready request. +- Push is opt-in per caller. A repository turns it on by adding the `synchronize` event to its caller. A caller that is not changed behaves as before Push. +- A Push request waits for pushes to settle (5 minutes by default, set by the caller, 0 to fire at once). If the pull request was pushed again, closed or made a draft in that time, the request is skipped. So a burst of pushes gets one review, of the last push. +- The review covers the pushed commits and the earlier commits not yet reviewed, with the whole pull request as context: it starts from the commit named by the review agent's last attestation when that is an ancestor of the commit before the push. So the commits of a push that got no review of its own, such as one superseded during the wait, are reviewed with the next push. After a force push or a rebase, it covers the whole pull request. Changes that only came from merging the base branch in, such as GitHub's "Update branch" button, are left out. +- Pushes made under the review agent's account are reviewed like anyone else's. One review still cannot start another, because the review routine never pushes. + +The settle wait and the opt-in answer the worry behind spec [#1](https://github.com/cipherstash/workflows/issues/1)'s choice: that a busy branch would start a review per commit. That worry still stands. It is now handled by the wait and by each repository's choice, not by never reviewing pushes. + +## Replaces + +This decision replaces two parts of spec #1: + +- Story 5: "As an engineer, I want no automatic review on every push, so that a busy branch does not start a review per commit." +- The out-of-scope line "Reviewing on every push (`synchronize`)." + +## Consequences + +We accept these trade-offs: + +- **Runner minutes for the wait.** Only a push that makes a Push request holds a runner for the settle wait. Every other push, to a draft included, still runs the short decision job. GitHub bills each job rounded up to a whole minute, so on private repositories a push that is skipped costs about 1 billed minute, and a Push request about 8 at the default (1 to decide, about 6 to wait, 1 to send). Runner minutes are free on public repositories. +- **Two attestations when a push lands during a review.** A review session that is already running is not stopped when a new push arrives. Both reviews post an attestation, and each names the commit it reviewed. +- **A duplicate when a push and a comment command arrive within the wait.** A Push request never cancels or delays a comment command, so both can start a review of the same commits. Push requests are sent from a queue of their own, apart from the queue that Ready requests, comment commands and Requested reviewer requests share, so a Push request cannot replace one of those while it waits to be sent. This departs from #50, which put all requests for a pull request in one queue. +- **The review routine finds where the last review stopped.** The workflow keeps no record of which commits were reviewed, so the request asks the review routine to find the last reviewed commit from the review agent's own attestations on the pull request. Only those count, so another commenter cannot move the start. If it finds none, it reviews the pushed commits. +- **A push during a running review can repeat its changes.** That review has not posted its attestation yet, so the next push's review starts from the one before it. +- **A skipped push waits for the next push.** When the last push in a burst is itself skipped, such as a bot's push, no review is sent. Its commits, and the earlier ones, are reviewed with the next push that is sent, or at once with a comment command.