Repository navigation
feat(review): label my own PR with the review run - #135
Merged
Merged
Conversation
A review run's verdict only lived on this machine, so nobody reading one of my pull requests could tell whether its head had been reviewed. A repository can now turn on labels.enabled, and my PRs there carry the approved or changes label that matches the run at the current head. A sweep takes the label off once the head moves, because a label on code nobody read is worse than no label. ADR 0012 records the carve-out from ADR 0002, and no-gh-writes admits exactly the two REST calls that move the label. Closes #134 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A review run's verdict lives only on this machine, so a teammate who opens one of my pull requests cannot tell whether its head was reviewed or what the review found. A repository that turns on
labels.enabledhas my pull requests carry the review label for their current head: approved when the review found nothing blocking, changes when it found a blocker. A sweep takes the label off once the head moves, because a label on code nobody has read is worse than no label. ADR 0012 records why this one write is allowed despite ADR 0002.Closes #134
What changes
src/domain/label.tsholds the rule. The label follows the review run at the current head, judged atstamp.blocks_on. A head with no run, or only a failed one, carries neither label. Every label that is not one of the two configured names is left alone.src/cli/sweep.tsandsrc/cli/review.tsapply the rule throughsrc/cli/label.ts.reviewtouches only a pull request I author.gh label createunder "Could not label", once per repository.src/adapters/label.tswrites through REST (gh api -X POST|DELETE …/issues/N/labels), nevergh pr edit.no-gh-writesadmits exactly those two vectors.labels: { enabled, approved, changes }inconfig.yamlis off by default and set per repository.v1-design.md,configuration.mdand thedw-mcskill agree with it.How it flows
flowchart LR sweep[sweep / review] --> runs[review run at head] runs --> rule{blocking findings?} rule -- none --> approved[approved] rule -- some --> changes[changes] rule -- no run at head --> none[neither] approved & changes & none --> diff[diff with PR labels] --> gh[POST / DELETE]Test plan
pnpm check: pass, 856 tests.src/domain/label.test.tscovers approved, changes, a stale head, no run, labelling off, a label already right, and someone else's label.src/cli/status.test.tscovers the sweep: it adds the label, removes it after a push, swaps the verdict, writes nothing when the label is already right, and never creates a label, with the hint printed once.src/cli/review.test.tscovers labelling my own PR and leaving someone else's alone.no-gh-writes.test.tsaccepts the two label writes and refuses PUT, an extra field, a POST to comments, label creation, an endpoint it cannot read, andpr edit --add-label.review: approvedandreview: changesin this repo, turn onlabels.enabled, then runnode dist/bin.js review <this PR>. Check that the label appears, push a commit, and check thatsweeptakes it off.Risk
A mistake here leaves a wrong label on one of my own pull requests. Turning
labels.enabledoff stops every write, and a label is one click to remove. No other write changes.🤖 Generated with Claude Code